mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-06-05 15:08:20 +09:00
Update settings classes
Remove unneeded define class, move help tab initialization to settings page.
This commit is contained in:
@@ -34,17 +34,15 @@ function display_featured_image_genesis_require() {
|
|||||||
'class-displayfeaturedimagegenesis',
|
'class-displayfeaturedimagegenesis',
|
||||||
'settings/class-displayfeaturedimagegenesis-getsetting',
|
'settings/class-displayfeaturedimagegenesis-getsetting',
|
||||||
'settings/class-displayfeaturedimagegenesis-helper',
|
'settings/class-displayfeaturedimagegenesis-helper',
|
||||||
'settings/class-displayfeaturedimagegenesis-settings-define',
|
|
||||||
'class-displayfeaturedimagegenesis-admin',
|
'class-displayfeaturedimagegenesis-admin',
|
||||||
'class-displayfeaturedimagegenesis-author',
|
'class-displayfeaturedimagegenesis-author',
|
||||||
'class-displayfeaturedimagegenesis-common',
|
'class-displayfeaturedimagegenesis-common',
|
||||||
'settings/class-displayfeaturedimagegenesis-customizer',
|
|
||||||
'class-displayfeaturedimagegenesis-description',
|
'class-displayfeaturedimagegenesis-description',
|
||||||
'settings/class-displayfeaturedimagegenesis-helptabs',
|
|
||||||
'class-displayfeaturedimagegenesis-output',
|
'class-displayfeaturedimagegenesis-output',
|
||||||
'class-displayfeaturedimagegenesis-postmeta',
|
'class-displayfeaturedimagegenesis-postmeta',
|
||||||
'class-displayfeaturedimagegenesis-rss',
|
'class-displayfeaturedimagegenesis-rss',
|
||||||
'settings/class-displayfeaturedimagegenesis-settings',
|
'settings/class-displayfeaturedimagegenesis-settings',
|
||||||
|
'settings/class-displayfeaturedimagegenesis-customizer',
|
||||||
'class-displayfeaturedimagegenesis-taxonomies',
|
'class-displayfeaturedimagegenesis-taxonomies',
|
||||||
'sixtenpress-shortcodes/sixtenpress-shortcodes',
|
'sixtenpress-shortcodes/sixtenpress-shortcodes',
|
||||||
'widgets/class-displayfeaturedimagegenesis-widgets',
|
'widgets/class-displayfeaturedimagegenesis-widgets',
|
||||||
@@ -63,7 +61,6 @@ $displayfeaturedimagegenesis_author = new Display_Featured_Image_Genesis_Au
|
|||||||
$displayfeaturedimagegenesis_common = new Display_Featured_Image_Genesis_Common();
|
$displayfeaturedimagegenesis_common = new Display_Featured_Image_Genesis_Common();
|
||||||
$displayfeaturedimagegenesis_customizer = new Display_Featured_Image_Genesis_Customizer();
|
$displayfeaturedimagegenesis_customizer = new Display_Featured_Image_Genesis_Customizer();
|
||||||
$displayfeaturedimagegenesis_description = new Display_Featured_Image_Genesis_Description();
|
$displayfeaturedimagegenesis_description = new Display_Featured_Image_Genesis_Description();
|
||||||
$displayfeaturedimagegenesis_helptabs = new Display_Featured_Image_Genesis_HelpTabs();
|
|
||||||
$displayfeaturedimagegenesis_output = new Display_Featured_Image_Genesis_Output();
|
$displayfeaturedimagegenesis_output = new Display_Featured_Image_Genesis_Output();
|
||||||
$displayfeaturedimagegenesis_post_meta = new Display_Featured_Image_Genesis_Post_Meta();
|
$displayfeaturedimagegenesis_post_meta = new Display_Featured_Image_Genesis_Post_Meta();
|
||||||
$displayfeaturedimagegenesis_rss = new Display_Featured_Image_Genesis_RSS();
|
$displayfeaturedimagegenesis_rss = new Display_Featured_Image_Genesis_RSS();
|
||||||
@@ -77,7 +74,6 @@ $displayfeaturedimage = new Display_Featured_Image_Genesis(
|
|||||||
$displayfeaturedimagegenesis_common,
|
$displayfeaturedimagegenesis_common,
|
||||||
$displayfeaturedimagegenesis_customizer,
|
$displayfeaturedimagegenesis_customizer,
|
||||||
$displayfeaturedimagegenesis_description,
|
$displayfeaturedimagegenesis_description,
|
||||||
$displayfeaturedimagegenesis_helptabs,
|
|
||||||
$displayfeaturedimagegenesis_output,
|
$displayfeaturedimagegenesis_output,
|
||||||
$displayfeaturedimagegenesis_post_meta,
|
$displayfeaturedimagegenesis_post_meta,
|
||||||
$displayfeaturedimagegenesis_rss,
|
$displayfeaturedimagegenesis_rss,
|
||||||
|
|||||||
@@ -45,12 +45,6 @@ class Display_Featured_Image_Genesis {
|
|||||||
*/
|
*/
|
||||||
protected $description;
|
protected $description;
|
||||||
|
|
||||||
/**
|
|
||||||
* Manages help tabs for settings page.
|
|
||||||
* @var $helptabs Display_Featured_Image_Genesis_HelpTabs
|
|
||||||
*/
|
|
||||||
protected $helptabs;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles all image output functionality
|
* Handles all image output functionality
|
||||||
* @var Display_Featured_Image_Genesis_Output $output
|
* @var Display_Featured_Image_Genesis_Output $output
|
||||||
@@ -96,19 +90,17 @@ class Display_Featured_Image_Genesis {
|
|||||||
* @param $common
|
* @param $common
|
||||||
* @param $customizer
|
* @param $customizer
|
||||||
* @param $description
|
* @param $description
|
||||||
* @param $helptabs
|
|
||||||
* @param $output
|
* @param $output
|
||||||
* @param $rss
|
* @param $rss
|
||||||
* @param $settings
|
* @param $settings
|
||||||
* @param $taxonomies
|
* @param $taxonomies
|
||||||
*/
|
*/
|
||||||
public function __construct( $admin, $author, $common, $customizer, $description, $helptabs, $output, $post_meta, $rss, $settings, $taxonomies, $widgets ) {
|
public function __construct( $admin, $author, $common, $customizer, $description, $output, $post_meta, $rss, $settings, $taxonomies, $widgets ) {
|
||||||
$this->admin = $admin;
|
$this->admin = $admin;
|
||||||
$this->author = $author;
|
$this->author = $author;
|
||||||
$this->common = $common;
|
$this->common = $common;
|
||||||
$this->customizer = $customizer;
|
$this->customizer = $customizer;
|
||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
$this->helptabs = $helptabs;
|
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
$this->post_meta = $post_meta;
|
$this->post_meta = $post_meta;
|
||||||
$this->rss = $rss;
|
$this->rss = $rss;
|
||||||
@@ -155,7 +147,6 @@ class Display_Featured_Image_Genesis {
|
|||||||
// Settings
|
// Settings
|
||||||
add_action( 'admin_menu', array( $this->settings, 'do_submenu_page' ) );
|
add_action( 'admin_menu', array( $this->settings, 'do_submenu_page' ) );
|
||||||
add_filter( 'displayfeaturedimagegenesis_get_setting', array( $this->settings, 'get_display_setting' ) );
|
add_filter( 'displayfeaturedimagegenesis_get_setting', array( $this->settings, 'get_display_setting' ) );
|
||||||
add_action( 'load-appearance_page_displayfeaturedimagegenesis', array( $this->helptabs, 'help' ) );
|
|
||||||
|
|
||||||
// Customizer
|
// Customizer
|
||||||
add_action( 'customize_register', array( $this->customizer, 'customizer' ) );
|
add_action( 'customize_register', array( $this->customizer, 'customizer' ) );
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* @package Display_Featured_Image_Genesis
|
* @package Display_Featured_Image_Genesis
|
||||||
* @copyright 2016 Robin Cornett
|
* @copyright 2016 Robin Cornett
|
||||||
*/
|
*/
|
||||||
class Display_Featured_Image_Genesis_Customizer extends Display_Featured_Image_Genesis_Settings_Define {
|
class Display_Featured_Image_Genesis_Customizer extends Display_Featured_Image_Genesis_Settings {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Section for the Customizer.
|
* Section for the Customizer.
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Display_Featured_Image_Genesis_Settings_Define
|
|
||||||
* @package DisplayFeaturedImageGenesis
|
|
||||||
* @copyright 2017 Robin Cornett
|
|
||||||
*/
|
|
||||||
class Display_Featured_Image_Genesis_Settings_Define extends Display_Featured_Image_Genesis_Helper {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register plugin settings page sections
|
|
||||||
*
|
|
||||||
* @since 2.3.0
|
|
||||||
*/
|
|
||||||
public function register_sections() {
|
|
||||||
return include 'sections.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register plugin settings fields
|
|
||||||
* @return array all settings fields
|
|
||||||
*
|
|
||||||
* @since 2.3.0
|
|
||||||
*/
|
|
||||||
public function register_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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,12 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Genesis_Helper {
|
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.
|
* The plugin admin page.
|
||||||
* @var $page string
|
* @var $page string
|
||||||
@@ -37,7 +31,6 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
|||||||
*/
|
*/
|
||||||
public function do_submenu_page() {
|
public function do_submenu_page() {
|
||||||
|
|
||||||
$this->common = new Display_Featured_Image_Genesis_Common();
|
|
||||||
$this->setting = $this->get_display_setting();
|
$this->setting = $this->get_display_setting();
|
||||||
|
|
||||||
add_theme_page(
|
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.
|
* Build out the settings page sections/fields.
|
||||||
*/
|
*/
|
||||||
public function build_settings_page() {
|
public function build_settings_page() {
|
||||||
include_once plugin_dir_path( __FILE__ ) . 'class-displayfeaturedimagegenesis-settings-define.php';
|
$sections = include 'sections.php';
|
||||||
$definitions = new Display_Featured_Image_Genesis_Settings_Define();
|
$this->fields = $this->get_fields();
|
||||||
$sections = $definitions->register_sections();
|
|
||||||
$this->fields = $definitions->register_fields();
|
|
||||||
$this->add_sections( $sections );
|
$this->add_sections( $sections );
|
||||||
$this->add_fields( $this->fields, $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 ) );
|
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
|
* validate all inputs
|
||||||
*
|
*
|
||||||
@@ -294,11 +347,8 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
|||||||
check_admin_referer( $action, $nonce );
|
check_admin_referer( $action, $nonce );
|
||||||
$new_value = array_merge( $this->setting, $new_value );
|
$new_value = array_merge( $this->setting, $new_value );
|
||||||
|
|
||||||
foreach ( array( 'define', 'validate' ) as $file ) {
|
include_once 'class-displayfeaturedimagegenesis-settings-validate.php';
|
||||||
include_once plugin_dir_path( __FILE__ ) . "class-displayfeaturedimagegenesis-settings-{$file}.php";
|
$validation = new Display_Featured_Image_Genesis_Settings_Validate( $this->get_fields(), $this->setting );
|
||||||
}
|
|
||||||
$definitions = new Display_Featured_Image_Genesis_Settings_Define();
|
|
||||||
$validation = new Display_Featured_Image_Genesis_Settings_Validate( $definitions->register_fields(), $this->setting );
|
|
||||||
|
|
||||||
return $validation->validate( $new_value );
|
return $validation->validate( $new_value );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user