mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-19 14:33:32 +09:00
Add custom text option to term/CPT widgets
This commit is contained in:
@@ -128,19 +128,32 @@ class DisplayFeaturedImageGenesisWidgetsForm {
|
||||
* @return array
|
||||
*/
|
||||
public function get_text_fields() {
|
||||
$label = 'featured-taxonomy' === $this->parent->id_base ? __( 'Term', 'display-featured-image-genesis' ) : __( 'Archive', 'display-featured-image-genesis' );
|
||||
return array(
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_title',
|
||||
'label' => __( 'Show Term Title', 'display-featured-image-genesis' ),
|
||||
'label' => sprintf( __( 'Show %s Title', 'display-featured-image-genesis' ), $label ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'show_content',
|
||||
'label' => __( 'Show Term Intro Text', 'display-featured-image-genesis' ),
|
||||
'id' => 'show_content',
|
||||
'label' => sprintf( __( 'Show %s Intro Text', 'display-featured-image-genesis' ), $label ),
|
||||
'choices' => array(
|
||||
'' => __( 'None', 'display-featured-image-genesis' ),
|
||||
1 => __( 'Intro Text', 'display-featured-image-genesis' ),
|
||||
'custom' => __( 'Custom Text (below)', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'textarea',
|
||||
'args' => array(
|
||||
'id' => 'custom_content',
|
||||
'label' => __( 'Custom Intro Text', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -54,6 +54,7 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
'image_size' => 'medium',
|
||||
'show_title' => 0,
|
||||
'show_content' => 0,
|
||||
'custom_content' => '',
|
||||
'archive_link' => 0,
|
||||
'archive_link_text' => __( 'View Content Type Archive', 'display-featured-image-genesis' ),
|
||||
);
|
||||
@@ -262,6 +263,10 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'custom' === $instance['show_content'] ) {
|
||||
$intro_text = $instance['custom_content'];
|
||||
}
|
||||
|
||||
return $intro_text;
|
||||
}
|
||||
|
||||
@@ -345,7 +350,7 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
), 'genesis-widget-column-box-top' );
|
||||
|
||||
$form->do_boxes( array(
|
||||
'words' => $this->get_text_fields(),
|
||||
'words' => $form->get_text_fields(),
|
||||
) );
|
||||
|
||||
$form->do_boxes( array(
|
||||
@@ -376,28 +381,6 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function get_text_fields() {
|
||||
return array(
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_title',
|
||||
'label' => __( 'Show Archive Title', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_content',
|
||||
'label' => __( 'Show Archive Intro Text', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the public registered post types on the site.
|
||||
*
|
||||
|
||||
@@ -56,6 +56,7 @@ class Display_Featured_Image_Genesis_Widget_Taxonomy extends WP_Widget {
|
||||
'image_size' => 'medium',
|
||||
'show_title' => 0,
|
||||
'show_content' => 0,
|
||||
'custom_content' => '',
|
||||
'archive_link' => 0,
|
||||
'archive_link_text' => __( 'View Term Archive', 'display-featured-image-genesis' ),
|
||||
);
|
||||
@@ -170,6 +171,10 @@ class Display_Featured_Image_Genesis_Widget_Taxonomy extends WP_Widget {
|
||||
$intro_text = $term->description;
|
||||
}
|
||||
|
||||
if ( 'custom' === $instance['show_content'] ) {
|
||||
$intro_text = $instance['custom_content'];
|
||||
}
|
||||
|
||||
echo wp_kses_post( wpautop( $intro_text ) );
|
||||
|
||||
echo genesis_html5() ? '</div>' : '';
|
||||
|
||||
Reference in New Issue
Block a user