Files
display-featured-image-genesis/includes/class-displayfeaturedimagegenesis-settings.php
T

607 lines
18 KiB
PHP
Raw Normal View History

2014-09-17 22:09:05 -04:00
<?php
/**
* @package DisplayFeaturedImageGenesis
* @author Robin Cornett <hello@robincornett.com>
* @license GPL-2.0+
2016-07-03 07:42:41 -04:00
* @link https://robincornett.com
2017-02-17 09:43:46 -05:00
* @copyright 2014-2017 Robin Cornett Creative, LLC
2014-09-17 22:09:05 -04:00
*/
2015-11-17 14:03:41 -05:00
class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Genesis_Helper {
2014-09-17 22:09:05 -04:00
2014-11-05 14:30:13 -05:00
/**
2016-04-30 14:20:30 -04:00
* The common plugin class.
* @var $commmon Display_Featured_Image_Genesis_Common
2014-11-05 14:30:13 -05:00
*/
2015-06-06 17:57:28 -04:00
protected $common;
2016-04-30 14:20:30 -04:00
/**
* The plugin admin page.
* @var $page string
*/
2016-04-30 14:20:04 -04:00
protected $page = 'displayfeaturedimagegenesis';
2016-04-30 14:20:30 -04:00
/**
* The plugin setting.
2017-10-24 18:04:55 -04:00
* @var $setting array
2016-04-30 14:20:30 -04:00
*/
2016-03-31 11:35:12 -04:00
protected $setting;
2016-04-30 14:20:30 -04:00
/**
* Public post types on the site.
* @var $post_types array
*/
2015-06-06 17:57:28 -04:00
protected $post_types;
2016-04-30 14:20:30 -04:00
/**
* The plugin settings fields.
* @var $fields array
*/
2015-06-07 12:05:14 -04:00
protected $fields;
2015-06-03 14:36:16 -04:00
2014-11-04 21:14:33 -05:00
/**
* add a submenu page under Appearance
2014-11-05 16:04:24 -05:00
* @since 1.4.0
2014-11-04 21:14:33 -05:00
*/
2014-11-02 19:20:00 -05:00
public function do_submenu_page() {
2016-04-30 14:20:04 -04:00
$this->common = new Display_Featured_Image_Genesis_Common();
$this->setting = $this->get_display_setting();
$this->post_types = $this->get_content_types();
2015-05-30 17:27:45 -04:00
2014-11-02 19:51:39 -05:00
add_theme_page(
2014-11-04 21:14:33 -05:00
__( 'Display Featured Image for Genesis', 'display-featured-image-genesis' ),
2015-11-17 14:03:41 -05:00
__( 'Display Featured Image for Genesis', 'display-featured-image-genesis' ),
2014-11-02 19:20:00 -05:00
'manage_options',
2015-05-30 17:27:45 -04:00
$this->page,
2014-11-02 19:20:00 -05:00
array( $this, 'do_settings_form' )
);
add_action( 'admin_init', array( $this, 'register_settings' ) );
2016-04-30 14:20:04 -04:00
$sections = $this->register_sections();
$this->fields = $this->register_fields();
2016-03-31 16:00:15 -04:00
$this->add_sections( $sections );
2016-04-04 15:51:28 -04:00
$this->add_fields( $this->fields, $sections );
2014-11-02 19:20:00 -05:00
}
2014-11-04 21:14:33 -05:00
/**
* create settings form
*
2014-11-05 16:04:24 -05:00
* @since 1.4.0
2014-11-04 21:14:33 -05:00
*/
2014-11-02 19:20:00 -05:00
public function do_settings_form() {
$page_title = get_admin_page_title();
echo '<div class="wrap">';
2016-03-31 16:00:15 -04:00
printf( '<h1>%s</h1>', esc_attr( $page_title ) );
2016-08-17 11:34:21 -04:00
$this->check_and_maybe_update_terms();
2016-04-01 17:06:57 -04:00
$active_tab = $this->get_active_tab();
echo $this->do_tabs( $active_tab );
2014-11-02 19:20:00 -05:00
echo '<form action="options.php" method="post">';
settings_fields( 'displayfeaturedimagegenesis' );
2016-04-01 17:06:57 -04:00
do_settings_sections( 'displayfeaturedimagegenesis_' . $active_tab );
2014-11-22 15:15:15 -05:00
wp_nonce_field( 'displayfeaturedimagegenesis_save-settings', 'displayfeaturedimagegenesis_nonce', false );
2014-11-02 19:20:00 -05:00
submit_button();
settings_errors();
echo '</form>';
echo '</div>';
}
2016-08-17 11:34:21 -04:00
/**
* Check if term images need to be updated because they were added before WP 4.4 and this plugin 2.4.
2016-08-17 16:25:49 -04:00
* @since 2.6.1
2016-08-17 11:34:21 -04:00
*/
protected function check_and_maybe_update_terms() {
if ( ! function_exists( 'get_term_meta' ) ) {
return;
}
if ( $this->terms_have_been_updated() ) {
return;
}
2016-08-17 11:34:21 -04:00
$previous_user = get_option( 'displayfeaturedimagegenesis', false );
if ( ! $previous_user ) {
update_option( 'displayfeaturedimagegenesis_updatedterms', true );
2017-10-24 18:04:55 -04:00
2016-08-17 11:34:21 -04:00
return;
}
2017-10-25 10:08:12 -04:00
include_once plugin_dir_path( __FILE__ ) . 'class-displayfeaturedimagegenesis-settings-terms.php';
$terms = new Display_Featured_Image_Genesis_Settings_Terms();
$terms->maybe_update_terms();
2016-08-17 11:34:21 -04:00
}
2016-04-01 17:06:57 -04:00
/**
2016-04-30 14:20:30 -04:00
* Output tabs.
2017-10-25 10:08:12 -04:00
*
* @param $active_tab
*
2016-04-01 17:06:57 -04:00
* @return string
* @since 2.5.0
*/
protected function do_tabs( $active_tab ) {
2016-07-06 09:42:48 -04:00
$tabs = $this->define_tabs();
2016-04-16 16:08:19 -04:00
$output = '<div class="nav-tab-wrapper">';
$output .= sprintf( '<h2 id="settings-tabs" class="screen-reader-text">%s</h2>', __( 'Settings Tabs', 'display-featured-image-genesis' ) );
$output .= '<ul>';
2016-04-01 17:06:57 -04:00
foreach ( $tabs as $tab ) {
$class = $active_tab === $tab['id'] ? ' nav-tab-active' : '';
2016-04-16 16:08:19 -04:00
$output .= sprintf( '<li><a href="themes.php?page=%s&tab=%s" class="nav-tab%s">%s</a></li>', $this->page, $tab['id'], $class, $tab['tab'] );
2016-04-01 17:06:57 -04:00
}
2016-04-16 16:08:19 -04:00
$output .= '</ul>';
$output .= '</div>';
2016-04-01 17:06:57 -04:00
return $output;
}
2014-09-17 22:09:05 -04:00
/**
2014-11-04 21:14:33 -05:00
* Settings for options screen
2014-09-17 22:09:05 -04:00
*
* @since 1.1.0
*/
public function register_settings() {
2017-10-24 18:04:55 -04:00
register_setting( 'displayfeaturedimagegenesis', 'displayfeaturedimagegenesis', array(
$this,
'do_validation_things',
) );
2015-07-26 14:57:22 -04:00
}
2016-07-06 09:42:48 -04:00
/**
* Define tabs for the settings page.
* @return array
* @since 2.6.0
*/
protected function define_tabs() {
return array(
2017-10-24 18:04:55 -04:00
'main' => array(
'id' => 'main',
'tab' => __( 'Main', 'display-featured-image-genesis' ),
),
'style' => array(
'id' => 'style',
'tab' => __( 'Backstretch Output', 'display-featured-image-genesis' ),
),
'cpt' => array(
'id' => 'cpt',
'tab' => __( 'Content Types', 'display-featured-image-genesis' ),
),
2016-07-06 09:42:48 -04:00
);
}
2015-07-26 14:57:22 -04:00
/**
* Register plugin settings page sections
*
* @since 2.3.0
*/
protected function register_sections() {
2016-03-31 16:00:15 -04:00
return array(
2017-10-24 18:04:55 -04:00
'main' => array(
2015-07-26 14:57:22 -04:00
'id' => 'main',
'title' => __( 'Optional Sitewide Settings', 'display-featured-image-genesis' ),
2015-05-30 13:38:41 -04:00
),
2016-07-06 09:42:48 -04:00
'style' => array(
'id' => 'style',
'title' => __( 'Display Settings', 'display-featured-image-genesis' ),
),
2017-10-24 18:04:55 -04:00
'cpt' => array(
2016-03-11 12:34:23 -05:00
'id' => 'cpt',
'title' => __( 'Featured Images for Custom Content Types', 'display-featured-image-genesis' ),
),
2014-09-17 22:09:05 -04:00
);
2016-03-11 12:34:23 -05:00
}
2015-07-26 14:57:22 -04:00
/**
* Register plugin settings fields
* @return array all settings fields
*
* @since 2.3.0
*/
2016-04-04 15:51:28 -04:00
protected function register_fields() {
2015-07-26 14:57:22 -04:00
2016-07-06 09:42:48 -04:00
return array_merge( $this->define_main_fields(), $this->define_style_fields(), $this->define_cpt_fields() );
2016-07-02 09:11:14 -04:00
}
2016-07-06 09:42:48 -04:00
/**
* Define the fields for the main/first tab.
* @return array
*/
2016-07-02 09:11:14 -04:00
protected function define_main_fields() {
return array(
2015-05-30 11:46:40 -04:00
array(
2015-07-12 12:59:50 -04:00
'id' => 'default',
2015-05-30 13:38:41 -04:00
'title' => __( 'Default Featured Image', 'display-featured-image-genesis' ),
'callback' => 'set_default_image',
2015-07-12 12:59:50 -04:00
'section' => 'main',
2015-05-30 11:46:40 -04:00
),
2016-07-02 14:02:54 -04:00
array(
'id' => 'always_default',
'title' => __( 'Always Use Default', 'display-featured-image-genesis' ),
'callback' => 'do_checkbox',
'section' => 'main',
2017-10-24 18:04:55 -04:00
'args' => array(
'setting' => 'always_default',
'label' => __( 'Always use the default image, even if a featured image is set.', 'display-featured-image-genesis' ),
),
2016-07-02 14:02:54 -04:00
),
2015-05-30 11:46:40 -04:00
array(
2015-07-12 12:59:50 -04:00
'id' => 'exclude_front',
2015-05-30 13:38:41 -04:00
'title' => __( 'Skip Front Page', 'display-featured-image-genesis' ),
2015-06-01 10:18:16 -04:00
'callback' => 'do_checkbox',
2015-07-12 12:59:50 -04:00
'section' => 'main',
2017-10-24 18:04:55 -04:00
'args' => array(
'setting' => 'exclude_front',
'label' => __( 'Do not show the Featured Image on the Front Page of the site.', 'display-featured-image-genesis' ),
),
2015-05-30 11:46:40 -04:00
),
array(
2015-07-12 12:59:50 -04:00
'id' => 'keep_titles',
2015-05-30 13:38:41 -04:00
'title' => __( 'Do Not Move Titles', 'display-featured-image-genesis' ),
2015-06-01 10:18:16 -04:00
'callback' => 'do_checkbox',
2015-07-12 12:59:50 -04:00
'section' => 'main',
2017-10-24 18:04:55 -04:00
'args' => array(
'setting' => 'keep_titles',
'label' => __( 'Do not move the titles to overlay the backstretch Featured Image.', 'display-featured-image-genesis' ),
),
2015-05-30 11:46:40 -04:00
),
array(
2015-07-12 12:59:50 -04:00
'id' => 'move_excerpts',
2015-05-30 13:38:41 -04:00
'title' => __( 'Move Excerpts/Archive Descriptions', 'display-featured-image-genesis' ),
2015-06-01 10:18:16 -04:00
'callback' => 'do_checkbox',
2015-07-12 12:59:50 -04:00
'section' => 'main',
2017-10-24 18:04:55 -04:00
'args' => array(
'setting' => 'move_excerpts',
'label' => __( 'Move excerpts (if used) on single pages and move archive/taxonomy descriptions to overlay the Featured Image.', 'display-featured-image-genesis' ),
),
2015-05-30 11:46:40 -04:00
),
array(
2015-07-12 12:59:50 -04:00
'id' => 'is_paged',
2015-05-30 13:38:41 -04:00
'title' => __( 'Show Featured Image on Subsequent Blog Pages', 'display-featured-image-genesis' ),
2015-06-01 10:18:16 -04:00
'callback' => 'do_checkbox',
2015-07-12 12:59:50 -04:00
'section' => 'main',
2017-10-24 18:04:55 -04:00
'args' => array(
'setting' => 'is_paged',
'label' => __( 'Show featured image on pages 2+ of blogs and archives.', 'display-featured-image-genesis' ),
),
2015-05-30 11:46:40 -04:00
),
array(
2015-07-12 12:59:50 -04:00
'id' => 'feed_image',
2015-05-30 13:38:41 -04:00
'title' => __( 'Add Featured Image to Feed?', 'display-featured-image-genesis' ),
2015-06-01 10:18:16 -04:00
'callback' => 'do_checkbox',
2015-07-12 12:59:50 -04:00
'section' => 'main',
2017-10-24 18:04:55 -04:00
'args' => array(
'setting' => 'feed_image',
'label' => __( 'Optionally, add the featured image to your RSS feed.', 'display-featured-image-genesis' ),
),
2015-05-30 11:46:40 -04:00
),
array(
'id' => 'thumbnails',
2016-03-11 13:44:19 -05:00
'title' => __( 'Archive Thumbnails', 'display-featured-image-genesis' ),
'callback' => 'do_checkbox',
'section' => 'main',
2017-10-24 18:04:55 -04:00
'args' => array(
'setting' => 'thumbnails',
'label' => __( 'Use term/post type fallback images for content archives?', 'display-featured-image-genesis' ),
),
),
array(
'id' => 'shortcode',
'title' => __( 'Add Shortcode Buttons', 'display-featured-image-genesis' ),
'callback' => 'do_checkbox_array',
'section' => 'main',
'args' => array(
'setting' => 'shortcode',
'options' => array(
'displayfeaturedimagegenesis_term' => __( 'Featured Term Widget', 'display-featured-image-genesis' ),
'displayfeaturedimagegenesis_author' => __( 'Featured Author Widget', 'display-featured-image-genesis' ),
'displayfeaturedimagegenesis_post_type' => __( 'Featured Post Type Widget', 'display-featured-image-genesis' ),
),
),
),
2016-07-02 09:11:14 -04:00
);
}
2016-07-06 09:42:48 -04:00
/**
* Define the fields for the style tab.
* @return array
*/
protected function define_style_fields() {
return array(
array(
'id' => 'less_header',
2017-10-24 18:04:55 -04:00
'title' => __( 'Height', 'display-featured-image-genesis' ),
2016-07-06 09:42:48 -04:00
'callback' => 'do_number',
'section' => 'style',
2017-10-24 18:04:55 -04:00
'args' => array(
'setting' => 'less_header',
'label' => __( 'pixels to remove', 'display-featured-image-genesis' ),
'min' => 0,
'max' => 400,
),
2016-07-06 09:42:48 -04:00
),
array(
'id' => 'max_height',
2017-10-24 18:04:55 -04:00
'title' => __( 'Maximum Height', 'display-featured-image-genesis' ),
2016-07-06 09:42:48 -04:00
'callback' => 'do_number',
'section' => 'style',
2017-10-24 18:04:55 -04:00
'args' => array(
'setting' => 'max_height',
'label' => __( 'pixels', 'display-featured-image-genesis' ),
'min' => 100,
'max' => 1000,
),
2016-07-06 09:42:48 -04:00
),
array(
'id' => 'centeredX',
2017-10-24 18:04:55 -04:00
'title' => __( 'Center Horizontally', 'display-featured-image-genesis' ),
2016-07-06 09:42:48 -04:00
'callback' => 'do_radio_buttons',
'section' => 'style',
'args' => array(
'setting' => 'centeredX',
'buttons' => $this->pick_center(),
'legend' => __( 'Center the backstretch image on the horizontal axis?', 'display-featured-image-genesis' ),
),
),
array(
'id' => 'centeredY',
2017-10-24 18:04:55 -04:00
'title' => __( 'Center Vertically', 'display-featured-image-genesis' ),
2016-07-06 09:42:48 -04:00
'callback' => 'do_radio_buttons',
'section' => 'style',
'args' => array(
'setting' => 'centeredY',
'buttons' => $this->pick_center(),
'legend' => __( 'Center the backstretch image on the vertical axis?', 'display-featured-image-genesis' ),
),
),
array(
'id' => 'fade',
2017-10-24 18:04:55 -04:00
'title' => __( 'Fade', 'display-featured-image-genesis' ),
2016-07-06 09:42:48 -04:00
'callback' => 'do_number',
'section' => 'style',
2017-10-24 18:04:55 -04:00
'args' => array(
'setting' => 'fade',
'label' => __( 'milliseconds', 'display-featured-image-genesis' ),
'min' => 0,
'max' => 20000,
),
2016-07-06 09:42:48 -04:00
),
);
}
/**
* Define the fields for the content types tab.
* @return array
*/
2016-07-02 09:11:14 -04:00
protected function define_cpt_fields() {
$fields = array(
2016-03-11 13:44:19 -05:00
array(
'id' => 'post_types][search',
'title' => __( 'Search Results', 'display-featured-image-genesis' ),
'callback' => 'set_cpt_image',
'section' => 'cpt',
'args' => array( 'post_type' => 'search' ),
),
array(
'id' => 'post_types][fourohfour',
'title' => __( '404 Page', 'display-featured-image-genesis' ),
'callback' => 'set_cpt_image',
'section' => 'cpt',
'args' => array( 'post_type' => 'fourohfour' ),
),
2016-03-31 16:00:15 -04:00
array(
'id' => 'skip',
'title' => __( 'Skip Content Types', 'display-featured-image-genesis' ),
'callback' => 'do_checkbox_array',
'section' => 'cpt',
2017-10-24 18:04:55 -04:00
'args' => array(
'setting' => 'skip',
'options' => $this->get_post_types(),
),
2016-03-31 16:00:15 -04:00
),
2016-03-11 12:34:23 -05:00
);
2014-10-16 08:53:41 -04:00
2015-01-03 17:43:18 -05:00
if ( $this->post_types ) {
2015-05-30 13:38:41 -04:00
2015-05-30 07:41:29 -04:00
foreach ( $this->post_types as $post ) {
2017-10-24 18:04:55 -04:00
$object = get_post_type_object( $post );
2016-04-04 15:51:28 -04:00
$fields[] = array(
2016-03-11 13:44:19 -05:00
'id' => 'post_types][' . esc_attr( $object->name ),
2016-03-11 12:34:23 -05:00
'title' => esc_attr( $object->label ),
2015-05-30 13:38:41 -04:00
'callback' => 'set_cpt_image',
2015-07-12 12:59:50 -04:00
'section' => 'cpt',
2016-03-11 12:34:23 -05:00
'args' => array( 'post_type' => $object ),
2015-05-30 07:41:29 -04:00
);
}
2015-01-03 17:43:18 -05:00
}
2017-10-24 18:04:55 -04:00
2016-04-04 15:51:28 -04:00
return $fields;
2014-09-17 22:09:05 -04:00
}
/**
* Section description
2016-03-11 13:44:19 -05:00
* @return string description
2014-09-17 22:09:05 -04:00
*
* @since 1.1.0
*/
2015-07-26 14:57:22 -04:00
public function main_section_description() {
2016-07-06 09:42:48 -04:00
$description = __( 'Use these settings to modify the plugin behavior throughout your site. Check the Help tab for more information. ', 'display-featured-image-genesis' );
$this->print_section_description( $description );
}
/**
* Style section description
*/
public function style_section_description() {
$description = __( 'These settings modify the output style/methods for the backstretch image.', 'display-featured-image-genesis' );
$this->print_section_description( $description );
2014-09-17 22:09:05 -04:00
}
2015-01-03 17:43:18 -05:00
/**
* Section description
2016-03-11 13:44:19 -05:00
* @return string description
2015-01-03 17:43:18 -05:00
*
* @since 1.1.0
*/
public function cpt_section_description() {
2016-03-11 13:44:19 -05:00
$description = __( 'Optional: set a custom image for search results and 404 (no results found) pages.', 'display-featured-image-genesis' );
if ( $this->post_types ) {
$description .= __( ' Additionally, since you have custom post types with archives, you might like to set a featured image for each of them.', 'display-featured-image-genesis' );
}
$this->print_section_description( $description );
2015-01-03 17:43:18 -05:00
}
/**
* Description for less_header setting.
* @return string description
*
* @since 2.3.0
*/
protected function less_header_description() {
return __( 'Changing this number will reduce the backstretch image height by this number of pixels. Default is zero.', 'display-featured-image-genesis' );
}
2016-07-02 09:13:30 -04:00
/**
* Description for the max_height setting.
* @return string|void description
* @since 2.6.0
*/
protected function max_height_description() {
return __( 'Optionally, set a max-height value for the header image; it will be added to your CSS.', 'display-featured-image-genesis' );
}
2014-10-21 18:16:00 -04:00
/**
* Default image uploader
*
* @since 1.2.1
*/
public function set_default_image() {
2014-11-04 21:14:33 -05:00
2016-03-31 11:35:12 -04:00
$id = $this->setting['default'] ? $this->setting['default'] : '';
$name = 'displayfeaturedimagegenesis[default]';
2015-05-30 17:27:45 -04:00
if ( ! empty( $id ) ) {
2016-04-18 11:53:13 -04:00
echo wp_kses_post( $this->render_image_preview( $id, 'default' ) );
}
2015-06-02 07:43:43 -04:00
$this->render_buttons( $id, $name );
$this->do_description( 'default_image' );
}
/**
* Description for default image setting
* @return string
*
* @since 2.3.0
*/
protected function default_image_description() {
$large = $this->common->minimum_backstretch_width();
2017-10-24 18:04:55 -04:00
return sprintf(
2015-06-07 12:05:14 -04:00
esc_html__( 'If you would like to use a default image for the featured image, upload it here. Must be at least %1$s pixels wide.', 'display-featured-image-genesis' ),
2015-02-27 09:10:06 -05:00
absint( $large + 1 )
2015-04-24 17:02:47 -04:00
);
2014-10-21 18:16:00 -04:00
}
2015-01-04 16:05:25 -05:00
/**
* Custom Post Type image uploader
*
2015-01-10 10:45:16 -05:00
* @since 2.0.0
2015-01-04 16:05:25 -05:00
*/
2015-05-30 07:41:29 -04:00
public function set_cpt_image( $args ) {
2015-01-04 16:05:25 -05:00
2016-03-11 12:34:23 -05:00
$post_type = is_object( $args['post_type'] ) ? $args['post_type']->name : $args['post_type'];
2016-03-31 11:35:12 -04:00
if ( empty( $this->setting['post_type'][ $post_type ] ) ) {
$this->setting['post_type'][ $post_type ] = $id = '';
2015-05-30 07:41:29 -04:00
}
2015-04-10 09:32:57 -04:00
if ( is_object( $args['post_type'] ) ) {
$fallback_args = array(
'setting' => "fallback][{$post_type}",
'label' => sprintf( __( 'Always use a fallback image for %s.', 'display-featured-image-genesis' ), esc_attr( $args['post_type']->label ) ),
'setting_name' => 'fallback',
'name' => $post_type,
);
2016-03-31 12:38:55 -04:00
echo '<p>';
$this->do_checkbox( $fallback_args );
2016-03-31 12:38:55 -04:00
echo '</p>';
}
2016-03-31 11:35:12 -04:00
$id = $this->setting['post_type'][ $post_type ];
2015-05-30 17:27:45 -04:00
$name = 'displayfeaturedimagegenesis[post_type][' . esc_attr( $post_type ) . ']';
if ( $id ) {
2016-04-18 11:53:13 -04:00
echo wp_kses_post( $this->render_image_preview( $id, $post_type ) );
2015-01-04 16:05:25 -05:00
}
2015-06-02 07:43:43 -04:00
$this->render_buttons( $id, $name );
2015-05-30 17:27:45 -04:00
2016-03-11 12:34:23 -05:00
if ( empty( $id ) || ! is_object( $args['post_type'] ) ) {
2015-05-30 17:27:45 -04:00
return;
}
2015-07-12 11:35:08 -04:00
$description = sprintf( __( 'View your <a href="%1$s" target="_blank">%2$s</a> archive.', 'display-featured-image-genesis' ),
2015-05-30 17:27:45 -04:00
esc_url( get_post_type_archive_link( $post_type ) ),
esc_attr( $args['post_type']->label )
);
2015-07-12 11:35:08 -04:00
printf( '<p class="description">%s</p>', wp_kses_post( $description ) );
2015-01-04 16:05:25 -05:00
}
2016-07-06 09:42:48 -04:00
/**
* @return array
*/
public function pick_center() {
return array(
1 => __( 'Center', 'display-featured-image-genesis' ),
0 => __( 'Do Not Center', 'display-featured-image-genesis' ),
);
}
2017-10-24 18:04:55 -04:00
/**
* 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;
}
2014-11-04 21:14:33 -05:00
/**
* validate all inputs
2017-10-24 18:04:55 -04:00
*
2017-10-25 10:07:40 -04:00
* @param $new_value array
2017-10-24 18:04:55 -04:00
*
2017-10-25 10:07:40 -04:00
* @return array
2014-11-04 21:14:33 -05:00
*
2014-11-05 16:04:24 -05:00
* @since 1.4.0
2014-11-04 21:14:33 -05:00
*/
public function do_validation_things( $new_value ) {
$action = 'displayfeaturedimagegenesis_save-settings';
$nonce = 'displayfeaturedimagegenesis_nonce';
// If the user doesn't have permission to save, then display an error message
if ( ! $this->user_can_save( $action, $nonce ) ) {
2015-06-07 12:05:14 -04:00
wp_die( esc_attr__( 'Something unexpected happened. Please try again.', 'display-featured-image-genesis' ) );
2014-11-22 15:15:15 -05:00
}
2016-08-18 14:38:34 -04:00
check_admin_referer( $action, $nonce );
2016-04-01 17:06:57 -04:00
$new_value = array_merge( $this->setting, $new_value );
2014-11-04 21:14:33 -05:00
2017-10-25 10:07:40 -04:00
include_once plugin_dir_path( __FILE__ ) . 'class-displayfeaturedimagegenesis-settings-validate.php';
2015-06-02 07:44:48 -04:00
2017-10-25 10:07:40 -04:00
$validation = new Display_Featured_Image_Genesis_Settings_Validate( $this->register_fields(), $this->setting );
return $validation->validate( $new_value );
}
/**
2016-04-30 14:20:30 -04:00
* Check whether terms need to be updated
* @return boolean true if on 4.4 and wp_options for terms exist; false otherwise
*
* @since 2.4.0
*/
protected function terms_have_been_updated() {
$updated = get_option( 'displayfeaturedimagegenesis_updatedterms', false );
2017-10-24 18:04:55 -04:00
2016-08-17 11:34:21 -04:00
return (bool) $updated;
}
2014-09-17 22:09:05 -04:00
}