diff --git a/includes/class-displayfeaturedimagegenesis-helper.php b/includes/class-displayfeaturedimagegenesis-helper.php index 8d86003..a55bb16 100644 --- a/includes/class-displayfeaturedimagegenesis-helper.php +++ b/includes/class-displayfeaturedimagegenesis-helper.php @@ -22,10 +22,10 @@ class Display_Featured_Image_Genesis_Helper { foreach ( $sections as $section ) { add_settings_section( - $section['id'], + $this->page . '_' . $section['id'], $section['title'], array( $this, $section['id'] . '_section_description' ), - $this->page + $this->page . '_' . $section['id'] ); } } @@ -44,8 +44,8 @@ class Display_Featured_Image_Genesis_Helper { '[' . $field['id'] . ']', sprintf( '', $this->page, $field['id'], $field['title'] ), array( $this, $field['callback'] ), - $this->page, - $sections[ $field['section'] ]['id'], + $this->page . '_' . $sections[ $field['section'] ]['id'], + $this->page . '_' . $sections[ $field['section'] ]['id'], empty( $field['args'] ) ? array() : $field['args'] ); } diff --git a/includes/class-displayfeaturedimagegenesis-settings.php b/includes/class-displayfeaturedimagegenesis-settings.php index a062e4d..fa366d6 100644 --- a/includes/class-displayfeaturedimagegenesis-settings.php +++ b/includes/class-displayfeaturedimagegenesis-settings.php @@ -63,9 +63,11 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen if ( $this->terms_need_updating() ) { $this->term_meta_notice(); } + $active_tab = $this->get_active_tab(); + echo $this->do_tabs( $active_tab ); echo '
'; settings_fields( 'displayfeaturedimagegenesis' ); - do_settings_sections( 'displayfeaturedimagegenesis' ); + do_settings_sections( 'displayfeaturedimagegenesis_' . $active_tab ); wp_nonce_field( 'displayfeaturedimagegenesis_save-settings', 'displayfeaturedimagegenesis_nonce', false ); submit_button(); settings_errors(); @@ -73,6 +75,35 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen echo ''; } + /** + * Output tabs. All tabs will be output if it's a single site or the main site, and the settings page is not disabled. + * @return string + * @since 2.5.0 + */ + protected function do_tabs( $active_tab ) { + $tabs = array( + 'main' => array( 'id' => 'main', 'title' => __( 'Main', 'display-featured-image-genesis' ) ), + 'cpt' => array( 'id' => 'cpt', 'title' => __( 'Content Types', 'display-featured-image-genesis' ) ), + ); + $output = ''; + + return $output; + } + + /** + * Set which tab is considered active. + * @return string + * @since 2.5.0 + */ + protected function get_active_tab() { + return isset( $_GET['tab'] ) ? $_GET['tab'] : 'main'; + } + /** * Settings for options screen * @return settings for backstretch image options @@ -101,7 +132,8 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen 'thumbnails' => 0, ); - return get_option( 'displayfeaturedimagegenesis', $defaults ); + $setting = get_option( 'displayfeaturedimagegenesis', $defaults ); + return wp_parse_args( $setting, $defaults ); } @@ -373,6 +405,7 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen check_admin_referer( 'displayfeaturedimagegenesis_save-settings', 'displayfeaturedimagegenesis_nonce' ); $new_value['less_header'] = absint( $new_value['less_header'] ); + $new_value = array_merge( $this->setting, $new_value ); // validate all checkbox fields foreach ( $this->fields as $field ) { @@ -506,13 +539,21 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen $archive_help .= '

' . __( 'This setting will set a fallback image for all content types in your archives. If there is no featured image, and no images uploaded to the post/page, the plugin will use the featured image for the term, or post type, as the thumbnail.', 'display-featured-image-genesis' ) . '

'; $archive_help .= '

' . __( 'The thumbnail will adhere to the settings from the Genesis settings page.', 'display-featured-image-genesis' ) . '

'; - $special_help = '

' . __( 'Featured Images for Custom Content Types', 'display-featured-image-genesis' ) . '

'; + $special_help = '

' . __( 'Featured Images for Special Pages', 'display-featured-image-genesis' ) . '

'; $special_help .= '

' . __( 'You can now set a featured image for search results and 404 (no results found) pages.', 'display-featured-image-genesis' ) . '

'; - $cpt_help = '

' . __( 'Some plugins and/or developers extend the power of WordPress by using Custom Post Types to create special kinds of content.', 'display-featured-image-genesis' ) . '

'; + $cpt_help = '

' . __( 'Featured Images for Custom Content Types', 'display-featured-image-genesis' ) . '

'; + $cpt_help .= '

' . __( 'Some plugins and/or developers extend the power of WordPress by using Custom Post Types to create special kinds of content.', 'display-featured-image-genesis' ) . '

'; $cpt_help .= '

' . __( 'Since you have custom post types with archives, you might like to set a featured image for each of them.', 'display-featured-image-genesis' ) . '

'; $cpt_help .= '

' . __( 'Featured Images for archives can be smaller than the Default Featured Image, but still need to be larger than your site\'s "medium" image size.', 'display-featured-image-genesis' ) . '

'; + $skip_help = '

' . __( 'Skip Content Types', 'display-featured-image-genesis' ) . '

'; + $skip_help .= '

' . __( 'Tell WordPress which content types should never have the featured image added.', 'display-featured-image-genesis' ) . '

'; + + $fallback_help = '

' . __( 'Fallback Images', 'display-featured-image-genesis' ) . '

'; + $fallback_help .= '

' . __( 'Instead of using the content type\'s Featured Image on singular posts, use one of the fallback images. This may be assigned to a term within a taxonomy, or be the content type featured image, or be the sitewide default image.', 'display-featured-image-genesis' ) . '

'; + $fallback_help .= '

' . __( 'If no fallback image exists, no featured image will display, as this will shortcut the check for the post\'s featured image.' , 'display-featured-image-genesis' ) . '

'; + $help_tabs = array( array( 'id' => 'displayfeaturedimage_less_header-help', @@ -554,12 +595,34 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen 'title' => __( 'Archive Thumbnails', 'display-featured-image-genesis' ), 'content' => $archive_help, ), - array( - 'id' => 'displayfeaturedimage_cpt-help', - 'title' => __( 'Custom Content Types', 'display-featured-image-genesis' ), - 'content' => $this->post_types ? $special_help . $cpt_help : $special_help, - ), ); + $active_tab = $this->get_active_tab(); + if ( 'cpt' === $active_tab ) { + $help_tabs = array( + array( + 'id' => 'displayfeaturedimage_special-help', + 'title' => __( 'Special Pages', 'display-featured-image-genesis' ), + 'content' => $special_help, + ), + array( + 'id' => 'displayfeaturedimage_skip-help', + 'title' => __( 'Skip Content Types', 'display-featured-image-genesis' ), + 'content' => $skip_help, + ), + array( + 'id' => 'displayfeaturedimage_fallback-help', + 'title' => __( 'Fallback Images', 'display-featured-image-genesis' ), + 'content' => $fallback_help, + ), + ); + if ( $this->get_content_types() ) { + $help_tabs[] = array( + 'id' => 'displayfeaturedimage_cpt-help', + 'title' => __( 'Custom Content Types', 'display-featured-image-genesis' ), + 'content' => $cpt_help, + ); + } + } foreach ( $help_tabs as $tab ) { $screen->add_help_tab( $tab ); }