From 963a170e4c4ecff08ad82ed6bbc548a9ea8d55ad Mon Sep 17 00:00:00 2001 From: Robin Cornett Date: Thu, 31 Mar 2016 11:35:12 -0400 Subject: [PATCH] Change variable names for sanity --- ...ass-displayfeaturedimagegenesis-common.php | 24 +++++++++---------- ...ass-displayfeaturedimagegenesis-helper.php | 6 ++++- ...ass-displayfeaturedimagegenesis-output.php | 16 ++++++------- ...s-displayfeaturedimagegenesis-settings.php | 22 ++++++++--------- 4 files changed, 36 insertions(+), 32 deletions(-) diff --git a/includes/class-displayfeaturedimagegenesis-common.php b/includes/class-displayfeaturedimagegenesis-common.php index f203b2a..7fb46ec 100644 --- a/includes/class-displayfeaturedimagegenesis-common.php +++ b/includes/class-displayfeaturedimagegenesis-common.php @@ -83,9 +83,9 @@ class Display_Featured_Image_Genesis_Common { */ public static function set_image_id( $image_id = '' ) { - $displaysetting = get_option( 'displayfeaturedimagegenesis' ); - $fallback = $displaysetting['default']; - $fallback_id = displayfeaturedimagegenesis_check_image_id( $fallback ); + $setting = get_option( 'displayfeaturedimagegenesis' ); + $fallback = $setting['default']; + $fallback_id = displayfeaturedimagegenesis_check_image_id( $fallback ); // set here with fallback preemptively, if it exists if ( ! empty( $fallback ) ) { @@ -104,20 +104,20 @@ class Display_Featured_Image_Genesis_Common { // also provisionally sets featured image for posts, similar to CPT archives $frontpage = get_option( 'show_on_front' ); // either 'posts' or 'page' if ( 'page' === $frontpage ) { - $postspage = get_option( 'page_for_posts' ); - $postspage_image = get_post_thumbnail_id( $postspage ); - $displaysetting['post_type']['post'] = (int) $postspage_image; + $postspage = get_option( 'page_for_posts' ); + $postspage_image = get_post_thumbnail_id( $postspage ); + $setting['post_type']['post'] = (int) $postspage_image; } // if a post type image exists, it takes priority over the fallback. check that next. $post_type = get_post_type(); - if ( ! empty( $displaysetting['post_type'][ $post_type ] ) ) { + if ( ! empty( $setting['post_type'][ $post_type ] ) ) { /** * Creates display_featured_image_genesis_use_post_type_image filter to check * whether get_post_type array should use the post type image. * @uses is_in_array() */ - $image_id = displayfeaturedimagegenesis_check_image_id( $displaysetting['post_type'][ $post_type ] ); + $image_id = displayfeaturedimagegenesis_check_image_id( $setting['post_type'][ $post_type ] ); if ( self::is_in_array( 'use_post_type_image' ) ) { return (int) $image_id; } @@ -135,13 +135,13 @@ class Display_Featured_Image_Genesis_Common { } // search page - if ( is_search() && isset( $displaysetting['post_type']['search'] ) ) { - $image_id = $displaysetting['post_type']['search']; + if ( is_search() && isset( $setting['post_type']['search'] ) ) { + $image_id = $setting['post_type']['search']; } // 404 - if ( is_404() && isset( $displaysetting['post_type']['fourohfour'] ) ) { - $image_id = $displaysetting['post_type']['fourohfour']; + if ( is_404() && isset( $setting['post_type']['fourohfour'] ) ) { + $image_id = $setting['post_type']['fourohfour']; } // any singular post/page/CPT diff --git a/includes/class-displayfeaturedimagegenesis-helper.php b/includes/class-displayfeaturedimagegenesis-helper.php index c6a3971..3c615cf 100644 --- a/includes/class-displayfeaturedimagegenesis-helper.php +++ b/includes/class-displayfeaturedimagegenesis-helper.php @@ -9,6 +9,10 @@ class Display_Featured_Image_Genesis_Helper { + protected $setting; + + protected $page = 'displayfeaturedimagegenesis'; + /** * Generic function to add settings sections * @@ -71,7 +75,7 @@ class Display_Featured_Image_Genesis_Helper { (int) $args['min'], (int) $args['max'], esc_attr( $args['setting'] ), - esc_attr( $this->displaysetting[ $args['setting'] ] ), + esc_attr( $this->setting[ $args['setting'] ] ), esc_attr( $this->page ) ); $this->do_description( $args['setting'] ); diff --git a/includes/class-displayfeaturedimagegenesis-output.php b/includes/class-displayfeaturedimagegenesis-output.php index 6a64b11..6e536c5 100644 --- a/includes/class-displayfeaturedimagegenesis-output.php +++ b/includes/class-displayfeaturedimagegenesis-output.php @@ -22,7 +22,7 @@ class Display_Featured_Image_Genesis_Output { /** * @var */ - protected $displaysetting; + protected $setting; /** * @var @@ -36,8 +36,8 @@ class Display_Featured_Image_Genesis_Output { */ public function manage_output() { - $this->displaysetting = displayfeaturedimagegenesis_get_setting(); - $skip = $this->displaysetting['exclude_front']; + $this->setting = displayfeaturedimagegenesis_get_setting(); + $exclude_front = $this->setting['exclude_front']; /** * Creates display_featured_image_genesis_skipped_posttypes filter to check * whether get_post_type array should not run plugin on this post type. @@ -148,7 +148,7 @@ class Display_Featured_Image_Genesis_Output { 'large' => $large[3] ? $large[1] : '', 'medium_large' => $medium_large[3] ? $medium_large[1] : '', ), - 'height' => (int) $this->displaysetting['less_header'], + 'height' => (int) $this->setting['less_header'], 'centeredX' => (int) (bool) $backstretch_vars['centeredX'], 'centeredY' => (int) (bool) $backstretch_vars['centeredY'], 'fade' => (int) $backstretch_vars['fade'], @@ -312,7 +312,7 @@ class Display_Featured_Image_Genesis_Output { $width = (int) $this->item->backstretch[1]; // check if they have enabled display on subsequent pages - $is_paged = ! empty( $this->displaysetting['is_paged'] ) ? $this->displaysetting['is_paged'] : 0; + $is_paged = ! empty( $this->setting['is_paged'] ) ? $this->setting['is_paged'] : 0; // if there is no backstretch image set, or it is too small, or the image is in the content, or it's page 2+ and they didn't change the setting, die if ( empty( $this->item->backstretch ) || $width <= $medium || ( is_paged() && ! $is_paged ) || ( is_singular() && false !== $this->item->content ) ) { $can_do = false; @@ -326,7 +326,7 @@ class Display_Featured_Image_Genesis_Output { * @since 2.0.0 (deprecated old function from 1.3.3) */ protected function move_excerpts() { - $move_excerpts = $this->displaysetting['move_excerpts']; + $move_excerpts = $this->setting['move_excerpts']; /** * Creates display_featured_image_genesis_omit_excerpt filter to check * whether get_post_type array should not move excerpts for this post type. @@ -344,7 +344,7 @@ class Display_Featured_Image_Genesis_Output { * @since 2.2.0 */ protected function move_title() { - $keep_titles = $this->displaysetting['keep_titles']; + $keep_titles = $this->setting['keep_titles']; /** * Creates display_featured_image_genesis_do_not_move_titles filter to check * whether get_post_type array should not move titles to overlay the featured image. @@ -366,7 +366,7 @@ class Display_Featured_Image_Genesis_Output { * @since 2.5.0 */ public function change_thumbnail_fallback( $defaults ) { - if ( ! isset( $this->displaysetting['thumbnails'] ) || ! $this->displaysetting['thumbnails'] ) { + if ( ! isset( $this->setting['thumbnails'] ) || ! $this->setting['thumbnails'] ) { return $defaults; } remove_action( 'genesis_entry_content', 'display_featured_image_genesis_add_archive_thumbnails', 5 ); diff --git a/includes/class-displayfeaturedimagegenesis-settings.php b/includes/class-displayfeaturedimagegenesis-settings.php index 4f43810..191cd13 100644 --- a/includes/class-displayfeaturedimagegenesis-settings.php +++ b/includes/class-displayfeaturedimagegenesis-settings.php @@ -15,7 +15,7 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen */ protected $common; protected $page; - protected $displaysetting; + protected $setting; protected $post_types; protected $fields; @@ -40,8 +40,8 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'load-appearance_page_displayfeaturedimagegenesis', array( $this, 'help' ) ); - $this->displaysetting = $this->get_display_setting(); - $this->post_types = $this->get_content_types(); + $this->setting = $this->get_display_setting(); + $this->post_types = $this->get_content_types(); } /** @@ -286,7 +286,7 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen */ public function set_default_image() { - $id = $this->displaysetting['default'] ? $this->displaysetting['default'] : ''; + $id = $this->setting['default'] ? $this->setting['default'] : ''; $name = 'displayfeaturedimagegenesis[default]'; if ( ! empty( $id ) ) { echo wp_kses_post( $this->render_image_preview( $id ) ); @@ -320,11 +320,11 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen public function set_cpt_image( $args ) { $post_type = is_object( $args['post_type'] ) ? $args['post_type']->name : $args['post_type']; - if ( empty( $this->displaysetting['post_type'][ $post_type ] ) ) { - $this->displaysetting['post_type'][ $post_type ] = $id = ''; + if ( empty( $this->setting['post_type'][ $post_type ] ) ) { + $this->setting['post_type'][ $post_type ] = $id = ''; } - $id = $this->displaysetting['post_type'][ $post_type ]; + $id = $this->setting['post_type'][ $post_type ]; $name = 'displayfeaturedimagegenesis[post_type][' . esc_attr( $post_type ) . ']'; if ( $id ) { echo wp_kses_post( $this->render_image_preview( $id ) ); @@ -373,21 +373,21 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen $size_to_check = $this->common->minimum_backstretch_width(); // validate default image - $new_value['default'] = $this->validate_image( $new_value['default'], $this->displaysetting['default'], __( 'Default', 'display-featured-image-genesis' ), $size_to_check ); + $new_value['default'] = $this->validate_image( $new_value['default'], $this->setting['default'], __( 'Default', 'display-featured-image-genesis' ), $size_to_check ); // search - $search = isset( $this->displaysetting['post_type']['search'] ) ? $this->displaysetting['post_type']['search'] : ''; + $search = isset( $this->setting['post_type']['search'] ) ? $this->setting['post_type']['search'] : ''; $new_value['post_type']['search'] = $this->validate_image( $new_value['post_type']['search'], $search, __( 'Search Results', 'display-featured-image-genesis' ), $size_to_check ); // 404 - $fourohfour = isset( $this->displaysetting['post_type']['fourohfour'] ) ? $this->displaysetting['post_type']['fourohfour'] : ''; + $fourohfour = isset( $this->setting['post_type']['fourohfour'] ) ? $this->setting['post_type']['fourohfour'] : ''; $new_value['post_type']['fourohfour'] = $this->validate_image( $new_value['post_type']['fourohfour'], $fourohfour, __( '404 Page', 'display-featured-image-genesis' ), $size_to_check ); foreach ( $this->post_types as $post_type ) { $object = get_post_type_object( $post_type ); // extra variables to pass through to image validation - $old_value = isset( $this->displaysetting['post_type'][ $object->name ] ) ? $this->displaysetting['post_type'][ $object->name ] : ''; + $old_value = isset( $this->setting['post_type'][ $object->name ] ) ? $this->setting['post_type'][ $object->name ] : ''; $label = $object->label; $size_to_check = get_option( 'medium_size_w' );