'widget_post_by_id', 'description' => esc_html__( 'Display post by ID', 'passport' ) ); parent::__construct( 'passport_post_by_id_widget', esc_html__( 'Passport Post by ID', 'passport' ), $widget_ops ); $this->alt_option_name = 'widget_post_by_id'; add_action( 'wp_enqueue_scripts', array( $this, 'passport_widget_inline_style' ) ); } /** * Styling the widget */ public function passport_widget_inline_style() { $i = 0; $widget_options = get_option( $this->option_name ); $custom_widget_css = ''; if( is_array( $widget_options ) && count( $widget_options ) > 0 ) { foreach ( $widget_options as $key => $widget_option ) { $widget_title_bgcolor_option = isset( $widget_option['widget_title_bgcolor'] ) ? $widget_option['widget_title_bgcolor'] : ''; if ( isset( $widget_title_bgcolor_option ) ) { $custom_widget_css .= "#{$this->id_base}-{$key} .widget-title {"; $custom_widget_css .= ! empty( $widget_title_bgcolor_option ) ? 'background-color:'. $widget_title_bgcolor_option .';' :'background-color: #333333;'; $custom_widget_css .= "}"; $custom_widget_css .= "#{$this->id_base}-{$key} .widget-title span {"; $custom_widget_css .= 'color: #ffffff;'; $custom_widget_css .= "}"; } $i++; } } wp_add_inline_style( PASSPORT_THEME_SLUG . '-custom-style', $custom_widget_css ); } // Creating widget front-end // This is where the action happens public function widget( $args, $instance ) { global $post; global $passport_section_settings; global $passport_front_page_column; global $passport_headline_column; global $passport_footer_column; $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; $id = ! empty( $instance['id'] ) ? absint( $instance['id'] ) : ''; $post_type = ! empty( $instance['post_type'] ) ? $instance['post_type'] : 'post'; $show_title = ! empty( $instance['show_title'] ) ? $instance['show_title'] : false; $show_media = ! empty( $instance['show_media'] ) ? $instance['show_media'] : false; $image_position = ! empty( $instance['image_position'] ) ? $instance['image_position'] : 'left'; $show_date = ! empty( $instance['show_date'] ) ? $instance['show_date'] : false; $show_excerpt = ! empty( $instance['show_excerpt'] ) ? $instance['show_excerpt'] : false; $show_button = ! empty( $instance['show_button'] ) ? $instance['show_button'] : false; $widget_icon = ! empty( $instance['widget_icon'] ) ? $instance['widget_icon'] : ''; $frontpage_id = get_option( 'page_on_front' ); $attachment_id = get_post_thumbnail_id( $frontpage_id ); $theme_setting = get_theme_mod( 'passport_theme_setting', 'full_width_container' ); $widget_args = array( 'p' => $id, 'post_type' => $post_type, 'posts_per_page' => 1, 'ignore_sticky_posts'=> TRUE, ); $wp_query = new WP_Query( $widget_args ); if ( $wp_query->have_posts() ) : ?> '. $title .''; } ?> have_posts() ) : $wp_query->the_post(); //Activate Post Format $post_format = get_post_format( get_the_ID() ); $aside_active = get_post_meta( get_the_ID(), 'as_active', true ); $audio_active = get_post_meta( get_the_ID(), 'a_active', true ); $gallery_active = get_post_meta( get_the_ID(), 'g_active', true ); $image_active = get_post_meta( get_the_ID(), 'i_active', true ); $link_active = get_post_meta( get_the_ID(), 'l_active', true ); $quote_active = get_post_meta( get_the_ID(), 'q_active', true ); $video_active = get_post_meta( get_the_ID(), 'v_active', true); //Check if do not want to show the content $aside_no_content = get_post_meta( get_the_ID(), 'as_no_content', true); $audio_no_content = get_post_meta( get_the_ID(), 'a_no_content', true ); $gallery_no_content = get_post_meta( get_the_ID(), 'g_no_content', true ); $image_no_content = get_post_meta( get_the_ID(), 'i_no_content', true ); $link_no_content = get_post_meta( get_the_ID(), 'l_no_content', true ); $quote_no_content = get_post_meta( get_the_ID(), 'q_no_content', true ); $video_no_content = get_post_meta( get_the_ID(), 'v_no_content', true); $archive_year = get_the_time( 'Y' ); $archive_month = get_the_time( 'm' ); $archive_day = get_the_time( 'd' ); if ( ! empty( $id ) ) : ?>
'alignright wp-post-image' ) ); elseif( 'right' == $image_position ) : the_post_thumbnail( 'small-140-110', array( 'class' => 'alignright wp-post-image' ) ); elseif( 'left' == $image_position && 'full_width_container' == $theme_setting && is_front_page() ) : the_post_thumbnail( 'medium-570-299', array( 'class' => 'alignleft wp-post-image' ) ); elseif( 'left' == $image_position ) : the_post_thumbnail( 'small-140-110', array( 'class' => 'alignleft wp-post-image' ) ); endif; ?>

aria-label="post-">

'', 'id' => '', 'post_type' => 'post', 'show_title' => '1', 'show_media' => '1', 'image_position' => 'center', 'show_date' => '1', 'show_excerpt' => '0', 'show_button' => '0', 'widget_icon' => '', 'widget_title_bgcolor' => '#333333' ) ); $title = $instance['title']; $id = $instance['id']; $show_title = $instance['show_title']; $show_media = $instance['show_media']; $show_date = $instance['show_date']; $show_excerpt = $instance['show_excerpt']; $show_button = $instance['show_button']; $widget_icon = $instance['widget_icon']; $widget_title_bgcolor = $instance['widget_title_bgcolor']; // Widget admin form ?>

id="get_field_id( 'show_title' ); ?>" name="get_field_name( 'show_title' ); ?>" />

id="get_field_id( 'show_media' ); ?>" name="get_field_name( 'show_media' ); ?>" />

id="get_field_id( 'show_date' ); ?>" name="get_field_name( 'show_date' ); ?>" />

id="get_field_id( 'show_excerpt' ); ?>" name="get_field_name( 'show_excerpt' ); ?>" />

id="get_field_id( 'show_button' ); ?>" name="get_field_name( 'show_button' ); ?>" />