mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-17 21:43:20 +09:00
Create an image settings class
I am sure that right now this breaks meta classes.
This commit is contained in:
@@ -204,82 +204,6 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
||||
return __( 'Optionally, change the hook location and priority of the featured image output. Use with caution. Note: this will change the hook/priority of the featured image sitewide. If you need to make changes based on content type, check the readme for code examples.', 'display-featured-image-genesis' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Default image uploader
|
||||
*
|
||||
* @since 1.2.1
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
public function set_default_image( $args ) {
|
||||
|
||||
$id = $this->setting[ $args['id'] ] ? $this->setting[ $args['id'] ] : '';
|
||||
$name = $this->page . '[' . $args['id'] . ']';
|
||||
if ( ! empty( $id ) ) {
|
||||
echo wp_kses_post( $this->render_image_preview( $id, $args['id'] ) );
|
||||
}
|
||||
$this->render_buttons( $id, $name );
|
||||
$this->do_description( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom Post Type image uploader
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
public function set_cpt_image( $args ) {
|
||||
|
||||
$this->do_image_buttons( $args );
|
||||
|
||||
if ( empty( $id ) || in_array( $args['id'], array( 'search', 'fourohfour', 'post' ), true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->do_cpt_description( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the featured image preview and buttons.
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
protected function do_image_buttons( $args ) {
|
||||
$show_on_front = get_option( 'show_on_front' );
|
||||
$posts_page = get_option( 'page_for_posts' );
|
||||
if ( 'page' === $show_on_front && $posts_page && 'post' === $args['id'] ) {
|
||||
$link = get_edit_post_link( $posts_page );
|
||||
/* translators: the link is to edit the posts page. */
|
||||
printf( wp_kses_post( __( 'You may set a fallback image for Posts on your <a href="%s">posts page</a>.', 'display-featured-image-genesis' ) ), esc_url( $link ) );
|
||||
return;
|
||||
}
|
||||
$id = isset( $this->setting['post_type'][ $args['id'] ] ) && $this->setting['post_type'][ $args['id'] ] ? $this->setting['post_type'][ $args['id'] ] : '';
|
||||
$name = $this->page . '[post_type][' . esc_attr( $args['id'] ) . ']';
|
||||
if ( $id ) {
|
||||
echo wp_kses_post( $this->render_image_preview( $id, $args['id'] ) );
|
||||
}
|
||||
$this->render_buttons( $id, $name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the CPT description.
|
||||
*
|
||||
* @param $args
|
||||
*/
|
||||
protected function do_cpt_description( $args ) {
|
||||
$archive_link = get_post_type_archive_link( $args['id'] );
|
||||
if ( ! $archive_link ) {
|
||||
return;
|
||||
}
|
||||
/* translators: placeholder is the post type name. */
|
||||
$description = sprintf( __( 'View your <a href="%1$s" target="_blank">%2$s</a> archive.', 'display-featured-image-genesis' ),
|
||||
esc_url( $archive_link ),
|
||||
esc_attr( $args['title'] )
|
||||
);
|
||||
printf( '<p class="description">%s</p>', wp_kses_post( $description ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user