mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-18 22:13:20 +09:00
Move get_post_types to form class
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user