mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-11 18:46:03 +09:00
Refactor widgets
All widgets use new form/builder class and updater class. Also fixes function visibility issues, defaults.
This commit is contained in:
@@ -326,6 +326,7 @@ class Display_Featured_Image_Genesis {
|
||||
);
|
||||
|
||||
require_once plugin_dir_path( __FILE__ ) . 'widgets/class-displayfeaturedimagegenesis-widgets.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . 'widgets/class-displayfeaturedimagegenesis-widgets-update.php';
|
||||
foreach ( $widgets as $file => $widget ) {
|
||||
require_once plugin_dir_path( __FILE__ ) . 'widgets/displayfeaturedimagegenesis-' . $file . '-widget.php';
|
||||
register_widget( $widget );
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$value = isset( $instance[ $args['id'] ] ) ? $instance[ $args['id'] ] : $this->parent->defaults[ $args['id'] ];
|
||||
$defaults = $this->parent->defaults();
|
||||
$value = isset( $instance[ $args['id'] ] ) ? $instance[ $args['id'] ] : $defaults[ $args['id'] ];
|
||||
echo '<p>';
|
||||
printf( '<input type="hidden" name="%s" value="0" />', esc_attr( $this->parent->get_field_name( $args['id'] ) ) );
|
||||
printf( '<input id="%s" type="checkbox" name="%s" value="1" %s/>', esc_attr( $this->parent->get_field_id( $args['id'] ) ), esc_attr( $this->parent->get_field_name( $args['id'] ) ), checked( 1, esc_attr( $value ), false ) );
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class DisplayFeaturedImageGenesisWidgetsUpdate
|
||||
*/
|
||||
class DisplayFeaturedImageGenesisWidgetsUpdate {
|
||||
/**
|
||||
* Update a particular instance.
|
||||
*
|
||||
* This function should check that $new_instance is set correctly.
|
||||
* The newly calculated value of $instance should be returned.
|
||||
* If "false" is returned, the instance won't be saved/updated.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param array $new_instance New settings for this instance as input by the user via form()
|
||||
* @param $old_instance
|
||||
* @param $fields
|
||||
*
|
||||
* @return array Settings to save or bool false to cancel saving
|
||||
*/
|
||||
public function update( $new_instance, $old_instance, $fields ) {
|
||||
foreach ( $fields as $field ) {
|
||||
$value = $field['args']['id'];
|
||||
if ( ! isset( $new_instance[ $value ] ) ) {
|
||||
continue;
|
||||
}
|
||||
switch ( $field['method'] ) {
|
||||
// Sanitize numbers
|
||||
case 'number':
|
||||
$new_instance[ $value ] = $new_instance[ $value ] ? absint( $new_instance[ $value ] ) : '';
|
||||
break;
|
||||
|
||||
// Sanitize checkboxes
|
||||
case 'checkbox':
|
||||
$new_instance[ $value ] = (int) (bool) $new_instance[ $value ];
|
||||
break;
|
||||
|
||||
// Sanitize text fields
|
||||
case 'text':
|
||||
$new_instance[ $value ] = strip_tags( $new_instance[ $value ] );
|
||||
break;
|
||||
|
||||
// Escape select options
|
||||
case 'select':
|
||||
$new_instance[ $value ] = is_numeric( $new_instance[ $value ] ) ? (int) $new_instance[ $value ] : esc_attr( $new_instance[ $value ] );
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
if ( function_exists( 'sanitize_textarea_field' ) ) {
|
||||
$new_instance[ $value ] = sanitize_textarea_field( $new_instance[ $value ] );
|
||||
} else {
|
||||
$new_instance[ $value ] = esc_textarea( $new_instance[ $value ] );
|
||||
}
|
||||
break;
|
||||
|
||||
// Default
|
||||
default:
|
||||
$new_instance[ $value ] = esc_attr( $new_instance[ $value ] );
|
||||
break;
|
||||
}
|
||||
} // End foreach().
|
||||
|
||||
// Title is never included in the fields.
|
||||
$new_instance['title'] = strip_tags( $new_instance['title'] );
|
||||
|
||||
return $new_instance;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class DisplayFeaturedImageGenesisWidgets
|
||||
*/
|
||||
class DisplayFeaturedImageGenesisWidgets {
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
public $instance;
|
||||
|
||||
/**
|
||||
* DisplayFeaturedImageGenesisWidgets constructor.
|
||||
*
|
||||
* @param $parent
|
||||
* @param $instance
|
||||
*/
|
||||
public function __construct( $parent, $instance ) {
|
||||
$this->parent = $parent;
|
||||
$this->instance = $instance;
|
||||
@@ -36,6 +51,66 @@ class DisplayFeaturedImageGenesisWidgets {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get image fields (used in CPT and term).
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_image_fields() {
|
||||
return array(
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_image',
|
||||
'label' => __( 'Show Featured Image', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'image_size',
|
||||
'label' => __( 'Image Size:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $this->get_image_size(),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'image_alignment',
|
||||
'label' => __( 'Image Alignment', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $this->get_image_alignment(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text fields (used in CPT and term).
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_text_fields() {
|
||||
return array(
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_title',
|
||||
'label' => __( 'Show Term Title', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_content',
|
||||
'label' => __( 'Show Term Intro Text', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build boxes with fields.
|
||||
*
|
||||
@@ -57,17 +132,20 @@ class DisplayFeaturedImageGenesisWidgets {
|
||||
|
||||
/**
|
||||
* Add a description to a widget settings box.
|
||||
*
|
||||
* @param $box
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function box_description( $box ) {
|
||||
$method = "describe_{$box}";
|
||||
|
||||
return method_exists( $this, $method ) ? $this->$method() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Cycle through the fields for a given box, pick the appropriate method, and go.
|
||||
*
|
||||
* @param $instance
|
||||
* @param $fields
|
||||
*/
|
||||
@@ -82,6 +160,7 @@ class DisplayFeaturedImageGenesisWidgets {
|
||||
|
||||
/**
|
||||
* Generic function to build a text input for the widget form.
|
||||
*
|
||||
* @param $instance
|
||||
* @param $args
|
||||
*/
|
||||
@@ -91,6 +170,7 @@ class DisplayFeaturedImageGenesisWidgets {
|
||||
|
||||
/**
|
||||
* Generic function to build a select input for the widget form.
|
||||
*
|
||||
* @param $instance
|
||||
* @param $args
|
||||
*/
|
||||
@@ -100,6 +180,7 @@ class DisplayFeaturedImageGenesisWidgets {
|
||||
|
||||
/**
|
||||
* Generic function to build a number input.
|
||||
*
|
||||
* @param $instance
|
||||
* @param $args
|
||||
*/
|
||||
@@ -109,6 +190,7 @@ class DisplayFeaturedImageGenesisWidgets {
|
||||
|
||||
/**
|
||||
* Generic function to build a checkbox input.
|
||||
*
|
||||
* @param $instance
|
||||
* @param $args
|
||||
*/
|
||||
@@ -118,6 +200,7 @@ class DisplayFeaturedImageGenesisWidgets {
|
||||
|
||||
/**
|
||||
* Generic function to build a textarea input
|
||||
*
|
||||
* @param $instance
|
||||
* @param $args
|
||||
*/
|
||||
|
||||
@@ -12,33 +12,14 @@
|
||||
class Display_Featured_Image_Genesis_Author_Widget extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Holds widget settings defaults, populated in constructor.
|
||||
*
|
||||
* @var array
|
||||
* @var $form_class \DisplayFeaturedImageGenesisWidgets
|
||||
*/
|
||||
protected $defaults;
|
||||
protected $form_class;
|
||||
|
||||
/**
|
||||
* Constructor. Set the default widget options and create widget.
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
$this->defaults = array(
|
||||
'title' => '',
|
||||
'show_featured_image' => 0,
|
||||
'featured_image_alignment' => '',
|
||||
'featured_image_size' => 'medium',
|
||||
'gravatar_alignment' => 'left',
|
||||
'user' => '',
|
||||
'show_gravatar' => 0,
|
||||
'size' => '45',
|
||||
'author_info' => '',
|
||||
'bio_text' => '',
|
||||
'page' => '',
|
||||
'page_link_text' => __( 'Read More', 'display-featured-image-genesis' ) . '…',
|
||||
'posts_link' => '',
|
||||
'link_text' => __( 'View My Blog Posts', 'display-featured-image-genesis' ),
|
||||
);
|
||||
public function __construct() {
|
||||
|
||||
$widget_ops = array(
|
||||
'classname' => 'author-profile',
|
||||
@@ -56,61 +37,85 @@ class Display_Featured_Image_Genesis_Author_Widget extends WP_Widget {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the widget defaults.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function defaults() {
|
||||
return array(
|
||||
'title' => '',
|
||||
'show_featured_image' => 0,
|
||||
'featured_image_alignment' => 'alignnone',
|
||||
'featured_image_size' => 'medium',
|
||||
'gravatar_alignment' => 'left',
|
||||
'user' => '',
|
||||
'show_gravatar' => 0,
|
||||
'size' => 45,
|
||||
'author_info' => '',
|
||||
'bio_text' => '',
|
||||
'page' => '',
|
||||
'page_link_text' => __( 'Read More', 'display-featured-image-genesis' ) . '…',
|
||||
'posts_link' => 0,
|
||||
'link_text' => __( 'View My Blog Posts', 'display-featured-image-genesis' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Echo the widget content.
|
||||
*
|
||||
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
|
||||
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
|
||||
* @param array $instance The settings for the particular instance of the widget
|
||||
*/
|
||||
function widget( $args, $instance ) {
|
||||
public function widget( $args, $instance ) {
|
||||
|
||||
// Merge with defaults
|
||||
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
||||
$instance = wp_parse_args( (array) $instance, $this->defaults() );
|
||||
|
||||
echo $args['before_widget'];
|
||||
|
||||
if ( ! empty( $instance['title'] ) ) {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title'];
|
||||
if ( ! empty( $instance['title'] ) ) {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title'];
|
||||
}
|
||||
|
||||
if ( $instance['show_featured_image'] ) {
|
||||
$image_id = get_the_author_meta( 'displayfeaturedimagegenesis', $instance['user'] );
|
||||
$image_src = wp_get_attachment_image_src( $image_id, $instance['featured_image_size'] );
|
||||
if ( $image_src ) {
|
||||
echo '<img src="' . esc_url( $image_src[0] ) . '" alt="' . esc_html( get_the_author_meta( 'display_name', $instance['user'] ) ) . '" class="' . esc_attr( $instance['featured_image_alignment'] ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
$text = '';
|
||||
|
||||
if ( $instance['show_gravatar'] ) {
|
||||
if ( ! empty( $instance['gravatar_alignment'] ) ) {
|
||||
$text .= '<span class="align' . esc_attr( $instance['gravatar_alignment'] ) . '">';
|
||||
}
|
||||
|
||||
if ( $instance['show_featured_image'] ) {
|
||||
$image_id = get_the_author_meta( 'displayfeaturedimagegenesis', $instance['user'] );
|
||||
$image_src = wp_get_attachment_image_src( $image_id, $instance['featured_image_size'] );
|
||||
if ( $image_src ) {
|
||||
echo '<img src="' . esc_url( $image_src[0] ) . '" alt="' . esc_html( get_the_author_meta( 'display_name', $instance['user'] ) ) . '" class="' . esc_attr( $instance['featured_image_alignment'] ) . '" />';
|
||||
}
|
||||
$text .= get_avatar( $instance['user'], $instance['size'] );
|
||||
|
||||
if ( ! empty( $instance['gravatar_alignment'] ) ) {
|
||||
$text .= '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$text = '';
|
||||
if ( $instance['author_info'] ) {
|
||||
$text .= 'text' === $instance['author_info'] ? $instance['bio_text'] : get_the_author_meta( 'description', $instance['user'] );
|
||||
}
|
||||
|
||||
if ( $instance['show_gravatar'] ) {
|
||||
if ( ! empty( $instance['gravatar_alignment'] ) ) {
|
||||
$text .= '<span class="align' . esc_attr( $instance['gravatar_alignment'] ) . '">';
|
||||
}
|
||||
$text .= $instance['page'] ? sprintf( ' <a class="pagelink" href="%s">%s</a>', get_page_link( $instance['page'] ), $instance['page_link_text'] ) : '';
|
||||
|
||||
$text .= get_avatar( $instance['user'], $instance['size'] );
|
||||
// Echo $text
|
||||
echo wp_kses_post( wpautop( $text ) );
|
||||
|
||||
if ( ! empty( $instance['gravatar_alignment'] ) ) {
|
||||
$text .= '</span>';
|
||||
}
|
||||
}
|
||||
// If posts link option checked, add posts link to output
|
||||
$display_name = get_the_author_meta( 'display_name', $instance['user'] );
|
||||
$user_name = ! empty( $display_name ) && function_exists( 'genesis_a11y' ) && genesis_a11y() ? '<span class="screen-reader-text">' . $display_name . ': </span>' : '';
|
||||
|
||||
if ( $instance['author_info'] ) {
|
||||
$text .= 'text' === $instance['author_info'] ? $instance['bio_text'] : get_the_author_meta( 'description', $instance['user'] );
|
||||
}
|
||||
|
||||
$text .= $instance['page'] ? sprintf( ' <a class="pagelink" href="%s">%s</a>', get_page_link( $instance['page'] ), $instance['page_link_text'] ) : '';
|
||||
|
||||
// Echo $text
|
||||
echo wp_kses_post( wpautop( $text ) );
|
||||
|
||||
// If posts link option checked, add posts link to output
|
||||
$display_name = get_the_author_meta( 'display_name', $instance['user'] );
|
||||
$user_name = ! empty( $display_name ) && function_exists( 'genesis_a11y' ) && genesis_a11y() ? '<span class="screen-reader-text">' . $display_name . ': </span>' : '';
|
||||
|
||||
if ( $instance['posts_link'] && $instance['link_text'] ) {
|
||||
printf( '<div class="posts_link posts-link"><a href="%s">%s%s</a></div>', esc_url( get_author_posts_url( $instance['user'] ) ), wp_kses_post( $user_name ), esc_attr( $instance['link_text'] ) );
|
||||
}
|
||||
if ( $instance['posts_link'] && $instance['link_text'] ) {
|
||||
printf( '<div class="posts_link posts-link"><a href="%s">%s%s</a></div>', esc_url( get_author_posts_url( $instance['user'] ) ), wp_kses_post( $user_name ), esc_attr( $instance['link_text'] ) );
|
||||
}
|
||||
|
||||
echo $args['after_widget'];
|
||||
|
||||
@@ -125,16 +130,22 @@ class Display_Featured_Image_Genesis_Author_Widget extends WP_Widget {
|
||||
*
|
||||
* @param array $new_instance New settings for this instance as input by the user via form()
|
||||
* @param array $old_instance Old settings for this instance
|
||||
*
|
||||
* @return array Settings to save or bool false to cancel saving
|
||||
*/
|
||||
function update( $new_instance, $old_instance ) {
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
|
||||
$new_instance['title'] = strip_tags( $new_instance['title'] );
|
||||
$new_instance['bio_text'] = current_user_can( 'unfiltered_html' ) ? $new_instance['bio_text'] : genesis_formatting_kses( $new_instance['bio_text'] );
|
||||
$new_instance['page_link_text'] = strip_tags( $new_instance['page_link_text'] );
|
||||
$new_instance['link_text'] = esc_html( $new_instance['link_text'] );
|
||||
$fields = array_merge(
|
||||
$this->get_image_fields(),
|
||||
$this->get_gravatar_fields(),
|
||||
$this->get_description_fields(),
|
||||
$this->get_archive_fields()
|
||||
);
|
||||
|
||||
return $new_instance;
|
||||
$new_instance['user'] = (int) $new_instance['user'];
|
||||
$updater = new DisplayFeaturedImageGenesisWidgetsUpdate();
|
||||
|
||||
return $updater->update( $new_instance, $old_instance, $fields );
|
||||
|
||||
}
|
||||
|
||||
@@ -143,11 +154,11 @@ class Display_Featured_Image_Genesis_Author_Widget extends WP_Widget {
|
||||
*
|
||||
* @param array $instance Current settings
|
||||
*/
|
||||
function form( $instance ) {
|
||||
public function form( $instance ) {
|
||||
|
||||
// Merge with defaults
|
||||
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
||||
$form = new DisplayFeaturedImageGenesisWidgets( $this, $instance );
|
||||
$instance = wp_parse_args( (array) $instance, $this->defaults() );
|
||||
$form = $this->get_form_class( $instance );
|
||||
|
||||
$form->do_text( $instance, array(
|
||||
'id' => 'title',
|
||||
@@ -162,132 +173,187 @@ class Display_Featured_Image_Genesis_Author_Widget extends WP_Widget {
|
||||
) );
|
||||
|
||||
$form->do_boxes( array(
|
||||
'author' => array(
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_featured_image',
|
||||
'label' => __( 'Show the user\'s featured image.', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'featured_image_size',
|
||||
'label' => __( 'Image Size:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $form->get_image_size(),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'featured_image_alignment',
|
||||
'label' => __( 'Image Alignment:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $form->get_image_alignment(),
|
||||
),
|
||||
),
|
||||
),
|
||||
'author' => $this->get_image_fields(),
|
||||
), 'genesis-widget-column-box-top' );
|
||||
|
||||
$form->do_boxes( array(
|
||||
'gravatar' => array(
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_gravatar',
|
||||
'label' => __( 'Show the user\'s gravatar.', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'size',
|
||||
'label' => __( 'Gravatar Size:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $this->get_gravatar_sizes(),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'gravatar_alignment',
|
||||
'label' => __( 'Gravatar Alignment:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => array(
|
||||
'' => __( 'None', 'display-featured-image-genesis' ),
|
||||
'left' => __( 'Left', 'display-featured-image-genesis' ),
|
||||
'right' => __( 'Right', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'gravatar' => $this->get_gravatar_fields(),
|
||||
) );
|
||||
|
||||
$form->do_boxes( array(
|
||||
'description' => array(
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'author_info',
|
||||
'label' => __( 'Text to use as the author description:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => array(
|
||||
'' => __( 'None', 'display-featured-image-genesis' ),
|
||||
'bio' => __( 'Author Bio (from profile)', 'display-featured-image-genesis' ),
|
||||
'text' => __( 'Custom Text (below)', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'textarea',
|
||||
'args' => array(
|
||||
'id' => 'bio_text',
|
||||
'label' => __( 'Custom Text Content', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'rows' => 6,
|
||||
),
|
||||
),
|
||||
),
|
||||
'description' => $this->get_description_fields(),
|
||||
) );
|
||||
|
||||
$form->do_boxes( array(
|
||||
'archive' => array(
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'page',
|
||||
'label' => __( 'Choose your extended "About Me" page from the list below. This will be the page linked to at the end of the author description.', 'display-featured-image-genesis' ),
|
||||
'choices' => $this->get_pages(),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'text',
|
||||
'args' => array(
|
||||
'id' => 'page_link_text',
|
||||
'label' => __( 'Extended page link text', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'posts_link',
|
||||
'label' => __( 'Show Author Archive Link?', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'text',
|
||||
'args' => array(
|
||||
'id' => 'link_text',
|
||||
'label' => __( 'Link Text:', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'archive' => $this->get_archive_fields(),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin widget forms class.
|
||||
*
|
||||
* @param array $instance
|
||||
*
|
||||
* @return \DisplayFeaturedImageGenesisWidgets
|
||||
*/
|
||||
protected function get_form_class( $instance = array() ) {
|
||||
if ( isset( $this->form_class ) ) {
|
||||
return $this->form_class;
|
||||
}
|
||||
$this->form_class = new DisplayFeaturedImageGenesisWidgets( $this, $instance );
|
||||
|
||||
return $this->form_class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the image fields (unique to this widget).
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_image_fields() {
|
||||
$form = $this->get_form_class();
|
||||
return array(
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_featured_image',
|
||||
'label' => __( 'Show the user\'s featured image.', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'featured_image_size',
|
||||
'label' => __( 'Image Size:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $form->get_image_size(),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'featured_image_alignment',
|
||||
'label' => __( 'Image Alignment:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $form->get_image_alignment(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the gravatar fields.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_gravatar_fields() {
|
||||
return array(
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_gravatar',
|
||||
'label' => __( 'Show the user\'s gravatar.', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'size',
|
||||
'label' => __( 'Gravatar Size:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $this->get_gravatar_sizes(),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'gravatar_alignment',
|
||||
'label' => __( 'Gravatar Alignment:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => array(
|
||||
'' => __( 'None', 'display-featured-image-genesis' ),
|
||||
'left' => __( 'Left', 'display-featured-image-genesis' ),
|
||||
'right' => __( 'Right', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the author description fields.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_description_fields() {
|
||||
return array(
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'author_info',
|
||||
'label' => __( 'Text to use as the author description:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => array(
|
||||
'' => __( 'None', 'display-featured-image-genesis' ),
|
||||
'bio' => __( 'Author Bio (from profile)', 'display-featured-image-genesis' ),
|
||||
'text' => __( 'Custom Text (below)', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'textarea',
|
||||
'args' => array(
|
||||
'id' => 'bio_text',
|
||||
'label' => __( 'Custom Text Content', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'rows' => 6,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the archive fields.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_archive_fields() {
|
||||
return array(
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'page',
|
||||
'label' => __( 'Choose your extended "About Me" page from the list below. This will be the page linked to at the end of the author description.', 'display-featured-image-genesis' ),
|
||||
'choices' => $this->get_pages(),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'text',
|
||||
'args' => array(
|
||||
'id' => 'page_link_text',
|
||||
'label' => __( 'Extended page link text', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'posts_link',
|
||||
'label' => __( 'Show Author Archive Link?', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'text',
|
||||
'args' => array(
|
||||
'id' => 'link_text',
|
||||
'label' => __( 'Link Text:', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authors on the site.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_users() {
|
||||
@@ -303,6 +369,8 @@ class Display_Featured_Image_Genesis_Author_Widget extends WP_Widget {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gravatar sizes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_gravatar_sizes() {
|
||||
@@ -321,6 +389,8 @@ class Display_Featured_Image_Genesis_Author_Widget extends WP_Widget {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pages on the site.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_pages() {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @link https://robincornett.com
|
||||
* @copyright 2014-2017 Robin Cornett Creative, LLC
|
||||
* @license GPL-2.0+
|
||||
* @since 2.0.0
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -19,11 +19,9 @@
|
||||
class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Holds widget settings defaults, populated in constructor.
|
||||
*
|
||||
* @var array
|
||||
* @var $form_class \DisplayFeaturedImageGenesisWidgets
|
||||
*/
|
||||
protected $defaults;
|
||||
protected $form_class;
|
||||
|
||||
/**
|
||||
* Constructor. Set the default widget options and create widget.
|
||||
@@ -32,16 +30,6 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->defaults = array(
|
||||
'title' => '',
|
||||
'post_type' => 'post',
|
||||
'show_image' => 0,
|
||||
'image_alignment' => '',
|
||||
'image_size' => 'medium',
|
||||
'show_title' => 0,
|
||||
'show_content' => 0,
|
||||
);
|
||||
|
||||
$widget_ops = array(
|
||||
'classname' => 'featured-posttype',
|
||||
'description' => __( 'Displays a post type archive with its featured image', 'display-featured-image-genesis' ),
|
||||
@@ -58,26 +46,42 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the widget defaults.
|
||||
* @return array
|
||||
*/
|
||||
public function defaults() {
|
||||
return array(
|
||||
'title' => '',
|
||||
'post_type' => 'post',
|
||||
'show_image' => 0,
|
||||
'image_alignment' => 'alignnone',
|
||||
'image_size' => 'medium',
|
||||
'show_title' => 0,
|
||||
'show_content' => 0,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Echo the widget content.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
*
|
||||
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
|
||||
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
|
||||
* @param array $instance The settings for the particular instance of the widget
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
|
||||
// Merge with defaults
|
||||
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
||||
$instance = wp_parse_args( (array) $instance, $this->defaults() );
|
||||
|
||||
$post_type = get_post_type_object( $instance['post_type'] );
|
||||
if ( ! $post_type ) {
|
||||
return;
|
||||
}
|
||||
$option = displayfeaturedimagegenesis_get_setting();
|
||||
$image_id = '';
|
||||
$option = displayfeaturedimagegenesis_get_setting();
|
||||
$image_id = '';
|
||||
|
||||
if ( 'post' === $instance['post_type'] ) {
|
||||
$frontpage = get_option( 'show_on_front' ); // either 'posts' or 'page'
|
||||
@@ -92,8 +96,7 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
$permalink = home_url();
|
||||
}
|
||||
$image_id = $postspage_image;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$title = $post_type->label;
|
||||
$permalink = esc_url( get_post_type_archive_link( $instance['post_type'] ) );
|
||||
if ( post_type_supports( $instance['post_type'], 'genesis-cpt-archives-settings' ) ) {
|
||||
@@ -110,15 +113,7 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title'];
|
||||
}
|
||||
|
||||
$image = '';
|
||||
if ( isset( $option['post_type'][ $post_type->name ] ) ) {
|
||||
$image_id = displayfeaturedimagegenesis_check_image_id( $option['post_type'][ $post_type->name ] );
|
||||
}
|
||||
$image_src = wp_get_attachment_image_src( $image_id, $instance['image_size'] );
|
||||
if ( $image_src ) {
|
||||
$image = '<img src="' . $image_src[0] . '" alt="' . $title . '" />';
|
||||
}
|
||||
|
||||
$image = $this->get_image( $image_id, $option, $post_type, $instance, $title );
|
||||
if ( $instance['show_image'] && $image ) {
|
||||
$role = empty( $instance['show_title'] ) ? '' : 'aria-hidden="true"';
|
||||
printf( '<a href="%s" title="%s" class="%s" %s>%s</a>', esc_url( $permalink ), esc_html( $title ), esc_attr( $instance['image_alignment'] ), $role, $image );
|
||||
@@ -126,15 +121,12 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
|
||||
if ( $instance['show_title'] ) {
|
||||
|
||||
if ( ! empty( $instance['show_title'] ) ) {
|
||||
|
||||
$title_output = sprintf( '<h2><a href="%s">%s</a></h2>', $permalink, esc_html( $title ) );
|
||||
if ( genesis_html5() ) {
|
||||
$title_output = sprintf( '<h2 class="archive-title"><a href="%s">%s</a></h2>', $permalink, esc_html( $title ) );
|
||||
}
|
||||
echo wp_kses_post( $title_output );
|
||||
|
||||
$title_output = sprintf( '<h2><a href="%s">%s</a></h2>', $permalink, esc_html( $title ) );
|
||||
if ( genesis_html5() ) {
|
||||
$title_output = sprintf( '<h2 class="archive-title"><a href="%s">%s</a></h2>', $permalink, esc_html( $title ) );
|
||||
}
|
||||
echo wp_kses_post( $title_output );
|
||||
|
||||
}
|
||||
|
||||
$intro_text = '';
|
||||
@@ -163,6 +155,28 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image_id
|
||||
* @param $option
|
||||
* @param $post_type
|
||||
* @param $instance
|
||||
* @param $title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_image( $image_id, $option, $post_type, $instance, $title ) {
|
||||
$image = '';
|
||||
if ( isset( $option['post_type'][ $post_type->name ] ) && $option['post_type'][ $post_type->name ] ) {
|
||||
$image_id = displayfeaturedimagegenesis_check_image_id( $option['post_type'][ $post_type->name ] );
|
||||
}
|
||||
$image_src = wp_get_attachment_image_src( $image_id, $instance['image_size'] );
|
||||
if ( $image_src ) {
|
||||
$image = '<img src="' . $image_src[0] . '" alt="' . $title . '" />';
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a particular instance.
|
||||
*
|
||||
@@ -174,13 +188,20 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
*
|
||||
* @param array $new_instance New settings for this instance as input by the user via form()
|
||||
* @param array $old_instance Old settings for this instance
|
||||
*
|
||||
* @return array Settings to save or bool false to cancel saving
|
||||
*/
|
||||
function update( $new_instance, $old_instance ) {
|
||||
|
||||
$new_instance['title'] = strip_tags( $new_instance['title'] );
|
||||
$new_instance['post_type'] = esc_attr( $new_instance['post_type'] );
|
||||
return $new_instance;
|
||||
$form = $this->get_form_class( $new_instance );
|
||||
$fields = array_merge(
|
||||
$this->get_post_type_fields(),
|
||||
$form->get_text_fields(),
|
||||
$form->get_image_fields()
|
||||
);
|
||||
$updater = new DisplayFeaturedImageGenesisWidgetsUpdate();
|
||||
|
||||
return $updater->update( $new_instance, $old_instance, $fields );
|
||||
|
||||
}
|
||||
|
||||
@@ -193,9 +214,9 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
|
||||
//* Merge with defaults
|
||||
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
||||
$form = new DisplayFeaturedImageGenesisWidgets( $this, $instance );
|
||||
// Merge with defaults
|
||||
$instance = wp_parse_args( (array) $instance, $this->defaults() );
|
||||
$form = $this->get_form_class( $instance );
|
||||
|
||||
$form->do_text( $instance, array(
|
||||
'id' => 'title',
|
||||
@@ -206,79 +227,84 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
echo '<div class="genesis-widget-column">';
|
||||
|
||||
$form->do_boxes( array(
|
||||
'post_type' => array(
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'post_type',
|
||||
'label' => __( 'Post Type:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $this->get_post_types(),
|
||||
),
|
||||
),
|
||||
),
|
||||
'post_type' => $this->get_post_type_fields(),
|
||||
), 'genesis-widget-column-box-top' );
|
||||
|
||||
$form->do_boxes( array(
|
||||
'text' => 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' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'words' => $this->get_text_fields(),
|
||||
) );
|
||||
|
||||
echo '</div>';
|
||||
echo '<div class="genesis-widget-column genesis-widget-column-right">';
|
||||
|
||||
$form->do_boxes( array(
|
||||
'image' => array(
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_image',
|
||||
'label' => __( 'Show Featured Image', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'image_size',
|
||||
'label' => __( 'Image Size:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $form->get_image_size(),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'image_alignment',
|
||||
'label' => __( 'Image Alignment', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $form->get_image_alignment(),
|
||||
),
|
||||
),
|
||||
),
|
||||
'image' => $form->get_image_fields(),
|
||||
), 'genesis-widget-column-box-top' );
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the post type fields.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_post_type_fields() {
|
||||
return array(
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'post_type',
|
||||
'label' => __( 'Post Type:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $this->get_post_types(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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 plugin widget forms class.
|
||||
*
|
||||
* @param array $instance
|
||||
*
|
||||
* @return \DisplayFeaturedImageGenesisWidgets
|
||||
*/
|
||||
protected function get_form_class( $instance = array() ) {
|
||||
if ( isset( $this->form_class ) ) {
|
||||
return $this->form_class;
|
||||
}
|
||||
$this->form_class = new DisplayFeaturedImageGenesisWidgets( $this, $instance );
|
||||
|
||||
return $this->form_class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the public registered post types on the site.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get_post_types() {
|
||||
$args = array(
|
||||
$args = array(
|
||||
'public' => true,
|
||||
'_builtin' => false,
|
||||
'has_archive' => true,
|
||||
@@ -288,9 +314,9 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
|
||||
|
||||
$options['post'] = __( 'Posts', 'display-featured-image-genesis' );
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$options[ $post_type->name ] = $post_type->label;
|
||||
$options[ $post_type->name ] = $post_type->label;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,17 @@
|
||||
*/
|
||||
class Display_Featured_Image_Genesis_Widget_Taxonomy extends WP_Widget {
|
||||
|
||||
/**
|
||||
* @var $form_class \DisplayFeaturedImageGenesisWidgets
|
||||
*/
|
||||
protected $form_class;
|
||||
|
||||
/**
|
||||
* Constructor. Set the default widget options and create widget.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
|
||||
$widget_ops = array(
|
||||
'classname' => 'featured-term',
|
||||
@@ -46,7 +51,7 @@ class Display_Featured_Image_Genesis_Widget_Taxonomy extends WP_Widget {
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function defaults() {
|
||||
public function defaults() {
|
||||
return array(
|
||||
'title' => '',
|
||||
'taxonomy' => 'category',
|
||||
@@ -187,12 +192,17 @@ class Display_Featured_Image_Genesis_Widget_Taxonomy extends WP_Widget {
|
||||
*
|
||||
* @return array Settings to save or bool false to cancel saving
|
||||
*/
|
||||
function update( $new_instance, $old_instance ) {
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
|
||||
$new_instance['title'] = strip_tags( $new_instance['title'] );
|
||||
|
||||
return $new_instance;
|
||||
$form = $this->get_form_class( $new_instance );
|
||||
$fields = array_merge(
|
||||
$form->get_text_fields(),
|
||||
$this->get_taxonomy_fields( $new_instance ),
|
||||
$form->get_image_fields()
|
||||
);
|
||||
$updater = new DisplayFeaturedImageGenesisWidgetsUpdate();
|
||||
|
||||
return $updater->update( $new_instance, $old_instance, $fields );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,7 +218,7 @@ class Display_Featured_Image_Genesis_Widget_Taxonomy extends WP_Widget {
|
||||
|
||||
// Merge with defaults
|
||||
$instance = wp_parse_args( (array) $instance, $this->defaults() );
|
||||
$form = new DisplayFeaturedImageGenesisWidgets( $this, $instance );
|
||||
$form = $this->get_form_class( $instance );
|
||||
|
||||
$form->do_text( $instance, array(
|
||||
'id' => 'title',
|
||||
@@ -223,19 +233,34 @@ class Display_Featured_Image_Genesis_Widget_Taxonomy extends WP_Widget {
|
||||
), 'genesis-widget-column-box-top' );
|
||||
|
||||
$form->do_boxes( array(
|
||||
'words' => $this->get_text_fields(),
|
||||
'words' => $form->get_text_fields(),
|
||||
) );
|
||||
|
||||
echo '</div>';
|
||||
echo '<div class="genesis-widget-column genesis-widget-column-right">';
|
||||
|
||||
$form->do_boxes( array(
|
||||
'image' => $this->get_image_fields( $form ),
|
||||
'image' => $form->get_image_fields(),
|
||||
), 'genesis-widget-column-box-top' );
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin widget forms class.
|
||||
* @param array $instance
|
||||
*
|
||||
* @return \DisplayFeaturedImageGenesisWidgets
|
||||
*/
|
||||
protected function get_form_class( $instance = array() ) {
|
||||
if ( isset( $this->form_class ) ) {
|
||||
return $this->form_class;
|
||||
}
|
||||
$this->form_class = new DisplayFeaturedImageGenesisWidgets( $this, $instance );
|
||||
|
||||
return $this->form_class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $instance
|
||||
*
|
||||
@@ -265,63 +290,6 @@ class Display_Featured_Image_Genesis_Widget_Taxonomy extends WP_Widget {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function get_text_fields() {
|
||||
return array(
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_title',
|
||||
'label' => __( 'Show Term Title', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_content',
|
||||
'label' => __( 'Show Term Intro Text', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $form \DisplayFeaturedImageGenesisWidgets
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_image_fields( $form ) {
|
||||
return array(
|
||||
array(
|
||||
'method' => 'checkbox',
|
||||
'args' => array(
|
||||
'id' => 'show_image',
|
||||
'label' => __( 'Show Featured Image', 'display-featured-image-genesis' ),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'image_size',
|
||||
'label' => __( 'Image Size:', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $form->get_image_size(),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'method' => 'select',
|
||||
'args' => array(
|
||||
'id' => 'image_alignment',
|
||||
'label' => __( 'Image Alignment', 'display-featured-image-genesis' ),
|
||||
'flex' => true,
|
||||
'choices' => $form->get_image_alignment(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user