mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-11 18:46:03 +09:00
Change variable names for sanity
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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'] );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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' );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user