Move get_post_types to form class

This commit is contained in:
Robin Cornett
2019-06-23 16:46:24 -04:00
parent 20c6cc3128
commit f0451a1184
3 changed files with 23 additions and 23 deletions
@@ -26,6 +26,28 @@ class DisplayFeaturedImageGenesisWidgetsForm {
$this->instance = $instance;
}
/**
* Get the public registered post types on the site.
*
* @return mixed
*/
public function get_post_types() {
$args = array(
'public' => true,
'_builtin' => false,
'has_archive' => true,
);
$output = 'objects';
$post_types = get_post_types( $args, $output );
$options['post'] = __( 'Posts', 'display-featured-image-genesis' );
foreach ( $post_types as $post_type ) {
$options[ $post_type->name ] = $post_type->label;
}
return $options;
}
/**
* @return array
*/
@@ -163,26 +163,4 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
'archive' => include 'fields/archive.php',
) );
}
/**
* Get the public registered post types on the site.
*
* @return mixed
*/
protected function get_post_types() {
$args = array(
'public' => true,
'_builtin' => false,
'has_archive' => true,
);
$output = 'objects';
$post_types = get_post_types( $args, $output );
$options['post'] = __( 'Posts', 'display-featured-image-genesis' );
foreach ( $post_types as $post_type ) {
$options[ $post_type->name ] = $post_type->label;
}
return $options;
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ return array(
'id' => 'post_type',
'label' => __( 'Post Type:', 'display-featured-image-genesis' ),
'flex' => true,
'choices' => $this->get_post_types(),
'choices' => $form->get_post_types(),
),
),
);