mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-18 14:03:20 +09:00
Move more work into render function
This commit is contained in:
@@ -230,13 +230,9 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
$large = Display_Featured_Image_Genesis_Common::minimum_backstretch_width();
|
||||
$id = '';
|
||||
|
||||
if ( ! empty( $this->displaysetting['default'] ) ) {
|
||||
$id = $this->displaysetting['default'];
|
||||
if ( ! is_numeric( $this->displaysetting['default'] ) ) {
|
||||
$id = Display_Featured_Image_Genesis_Common::get_image_id( $this->displaysetting['default'] );
|
||||
}
|
||||
echo wp_kses_post( $this->render_image_preview( $id ) );
|
||||
}
|
||||
$id = $this->displaysetting['default'];
|
||||
echo wp_kses_post( $this->render_image_preview( $id ) );
|
||||
|
||||
echo '<input type="hidden" class="upload_image_id" id="displayfeaturedimagegenesis[default]" name="displayfeaturedimagegenesis[default]" value="' . absint( $id ) . '" />';
|
||||
printf( '<input type="button" class="upload_default_image button-secondary" value="%s" />',
|
||||
__( 'Select Image', 'display-featured-image-genesis' )
|
||||
@@ -340,14 +336,8 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
$this->displaysetting['post_type'][ $post_type ] = $id = '';
|
||||
}
|
||||
|
||||
if ( ! empty( $this->displaysetting['post_type'][ $post_type ] ) ) {
|
||||
$id = $this->displaysetting['post_type'][ $post_type ];
|
||||
if ( ! is_numeric( $this->displaysetting['post_type'][ $post_type ] ) ) {
|
||||
$id = Display_Featured_Image_Genesis_Common::get_image_id( $this->displaysetting['post_type'][ $post_type ] );
|
||||
}
|
||||
|
||||
echo wp_kses_post( $this->render_image_preview( $id ) );
|
||||
}
|
||||
$id = $this->displaysetting['post_type'][ $post_type ];
|
||||
echo wp_kses_post( $this->render_image_preview( $id ) );
|
||||
|
||||
echo '<input type="hidden" class="upload_image_id" id="displayfeaturedimagegenesis[post_type][' . esc_attr( $post_type ) . ']" name="displayfeaturedimagegenesis[post_type][' . esc_attr( $post_type ) . ']" value="' . absint( $id ) . '" />';
|
||||
printf( '<input type="button" class="upload_default_image button-secondary" value="%s" />',
|
||||
@@ -374,11 +364,18 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
*
|
||||
* @since x.y.z
|
||||
*/
|
||||
public function render_image_preview( $id ) {
|
||||
public static function render_image_preview( $id ) {
|
||||
if ( empty( $id ) ) {
|
||||
return;
|
||||
}
|
||||
if ( ! is_numeric( $id ) ) {
|
||||
$id = Display_Featured_Image_Genesis_Common::get_image_id( $id );
|
||||
}
|
||||
|
||||
$preview = wp_get_attachment_image_src( absint( $id ), 'medium' );
|
||||
$image = '<div id="upload_logo_preview">';
|
||||
$image .= '<img src="' . esc_url( $preview[0] ) . '" />';
|
||||
$image .= '</div>';
|
||||
$image = '<div id="upload_logo_preview">';
|
||||
$image .= '<img src="' . esc_url( $preview[0] ) . '" />';
|
||||
$image .= '</div>';
|
||||
return $image;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +52,9 @@ class Display_Featured_Image_Genesis_Taxonomies {
|
||||
__( 'Featured Image', 'display-featured-image-genesis' )
|
||||
);
|
||||
echo '<td>';
|
||||
if ( ! empty( $displaysetting['term_image'] ) ) {
|
||||
$id = $displaysetting['term_image'];
|
||||
if ( ! is_numeric( $displaysetting['term_image'] ) ) {
|
||||
$id = Display_Featured_Image_Genesis_Common::get_image_id( $displaysetting['term_image'] );
|
||||
}
|
||||
echo wp_kses_post( Display_Featured_Image_Genesis_Settings::render_image_preview( $id ) );
|
||||
}
|
||||
$id = $displaysetting['term_image'];
|
||||
echo wp_kses_post( Display_Featured_Image_Genesis_Settings::render_image_preview( $id ) );
|
||||
|
||||
echo '<input type="hidden" class="upload_image_id" id="term_image_id" name="displayfeaturedimagegenesis[term_image]" value="' . absint( $id ) . '" />';
|
||||
printf( '<input id="upload_default_image" type="button" class="upload_default_image button-secondary" value="%s" />',
|
||||
__( 'Select Image', 'display-featured-image-genesis' )
|
||||
|
||||
@@ -111,28 +111,28 @@ class Display_Featured_Image_Genesis {
|
||||
|
||||
$displaysetting = get_option( 'displayfeaturedimagegenesis' );
|
||||
|
||||
//* return early if the option doesn't exist yet
|
||||
// return early if the option doesn't exist yet
|
||||
if ( empty( $displaysetting ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( empty( $displaysetting['feed_image'] ) ) {
|
||||
$this->update_settings( array(
|
||||
'feed_image' => 0
|
||||
'feed_image' => 0,
|
||||
) );
|
||||
}
|
||||
|
||||
// new setting for titles added in 2.0.0
|
||||
if ( empty( $displaysetting['keep_titles'] ) ) {
|
||||
$this->update_settings( array(
|
||||
'keep_titles' => 0
|
||||
'keep_titles' => 0,
|
||||
) );
|
||||
}
|
||||
|
||||
// new setting for subsequent pages added in 2.2.0
|
||||
if ( empty( $displaysetting['is_paged'] ) ) {
|
||||
$this->update_settings( array(
|
||||
'is_paged' => 0
|
||||
'is_paged' => 0,
|
||||
) );
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ class Display_Featured_Image_Genesis {
|
||||
*/
|
||||
public function set_taxonomy_meta() {
|
||||
$args = array(
|
||||
'public' => true
|
||||
'public' => true,
|
||||
);
|
||||
$output = 'names';
|
||||
$taxonomies = get_taxonomies( $args, $output );
|
||||
|
||||
Reference in New Issue
Block a user