'business-center-profeatured-content-widget',
'description' => esc_html__( 'A widget to display featured content.', 'business-center-pro' ),
);
parent::__construct( 'business-center-profeatured-content-widget', esc_html__( 'TP : Featured Content', 'business-center-pro' ), $widget_ops );
}
/**
* Outputs the content of the widget
*
* @param array $args
* @param array $instance
*/
public function widget( $args, $instance ) {
// outputs the content of the widget
if ( ! isset( $args['widget_id'] ) ) {
$args['widget_id'] = $this->id;
}
// Get title value
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : esc_html__( 'Featured Content', 'business-center-pro' );
// Get post type value
$post_type = isset( $instance['post_type'] ) ? esc_html( $instance['post_type'] ) : 'post';
// Get post id value
$post_id = isset( $instance['post_id'] ) ? absint( $instance['post_id'] ) : '';
// Get page id value
$page_id = isset( $instance['page_id'] ) ? absint( $instance['page_id'] ) : '';
// Get content type featured_image_size
$content_type = isset( $instance['content_type'] ) ? esc_html( $instance['content_type'] ) : '';
// Get featured image size
$featured_image_size = isset( $instance['featured_image_size'] ) ? esc_html( $instance['featured_image_size'] ) : '';
// Get hide image value
$hide_title = isset( $instance['hide_title'] ) ? (bool) $instance['hide_title'] : false;
echo $args['before_widget'];
if ( ! empty( $title ) ) {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
if ( 'post' == $post_type ) {
$query_args = array( 'p' => $post_id );
} elseif ( 'page' == $post_type ) {
$query_args = array( 'page_id' => $page_id );
}
$query = new WP_Query( $query_args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
if ( ! $hide_title ) { ?>
'ids', // Only get post IDs 'posts_per_page'=> -1, ) ); if ( ! in_array( $post_id, $post_ids ) ) : ?>
esc_attr( $this->get_field_name( 'page_id' ) ), 'selected' => $page_id ) );?>
/>