Update settings classes

Remove unneeded define class, move help tab initialization to settings
page.
This commit is contained in:
Robin Cornett
2019-05-12 18:18:25 -04:00
parent 4a2e26ce05
commit e2574a30cd
5 changed files with 69 additions and 111 deletions
@@ -7,12 +7,6 @@
*/
class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Genesis_Helper {
/**
* The common plugin class.
* @var $common \Display_Featured_Image_Genesis_Common
*/
protected $common;
/**
* The plugin admin page.
* @var $page string
@@ -37,7 +31,6 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
*/
public function do_submenu_page() {
$this->common = new Display_Featured_Image_Genesis_Common();
$this->setting = $this->get_display_setting();
add_theme_page(
@@ -56,12 +49,27 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
* Build out the settings page sections/fields.
*/
public function build_settings_page() {
include_once plugin_dir_path( __FILE__ ) . 'class-displayfeaturedimagegenesis-settings-define.php';
$definitions = new Display_Featured_Image_Genesis_Settings_Define();
$sections = $definitions->register_sections();
$this->fields = $definitions->register_fields();
$sections = include 'sections.php';
$this->fields = $this->get_fields();
$this->add_sections( $sections );
$this->add_fields( $this->fields, $sections );
include_once 'class-displayfeaturedimagegenesis-helptabs.php';
$help = new Display_Featured_Image_Genesis_HelpTabs();
$help->help();
}
/**
* Get the settings fields.
* @return array
*/
protected function get_fields() {
$main = include 'fields-main.php';
$style = include 'fields-style.php';
$cpt = include 'fields-cpt.php';
$advanced = include 'fields-advanced.php';
return array_merge( $main, $style, $cpt, $advanced );
}
/**
@@ -273,6 +281,51 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
printf( '<p class="description">%s</p>', wp_kses_post( $description ) );
}
/**
* @return array
*/
public function pick_center() {
return array(
1 => __( 'Center', 'display-featured-image-genesis' ),
0 => __( 'Do Not Center', 'display-featured-image-genesis' ),
);
}
/**
* Get the post types as options.
* @return array
*/
protected function get_post_types() {
$post_types = $this->get_content_types_built_in();
$options = array();
foreach ( $post_types as $post_type ) {
$object = get_post_type_object( $post_type );
$options[ $post_type ] = $object->label;
}
return $options;
}
/**
* Get the hooks for the large image.
*
* @return array
*/
protected function large_hook_options() {
$hooks = array(
'genesis_before_loop' => 'genesis_before_loop ' . __( '(default)', 'display-featured-image-genesis' ),
'genesis_after_header' => 'genesis_after_header',
'genesis_before_content_sidebar_wrap' => 'genesis_before_content_sidebar_wrap',
);
$html5 = genesis_html5() ? array(
'genesis_before_entry' => 'genesis_before_entry ' . __( '(HTML5 themes)', 'display-featured-image-genesis' ),
'genesis_entry_header' => 'genesis_entry_header ' . __( '(HTML5 themes)', 'display-featured-image-genesis' ),
'genesis_entry_content' => 'genesis_entry_content ' . __( '(HTML5 themes)', 'display-featured-image-genesis' ),
) : array();
return array_merge( $hooks, $html5 );
}
/**
* validate all inputs
*
@@ -294,11 +347,8 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
check_admin_referer( $action, $nonce );
$new_value = array_merge( $this->setting, $new_value );
foreach ( array( 'define', 'validate' ) as $file ) {
include_once plugin_dir_path( __FILE__ ) . "class-displayfeaturedimagegenesis-settings-{$file}.php";
}
$definitions = new Display_Featured_Image_Genesis_Settings_Define();
$validation = new Display_Featured_Image_Genesis_Settings_Validate( $definitions->register_fields(), $this->setting );
include_once 'class-displayfeaturedimagegenesis-settings-validate.php';
$validation = new Display_Featured_Image_Genesis_Settings_Validate( $this->get_fields(), $this->setting );
return $validation->validate( $new_value );
}