'optimizer_front_posts postsblck', 'description' => __( 'This Widget lets you display WordPress Posts, Pages and Woocommerce Products.', 'optimizer' ), 'customize_selective_refresh' => true, ) ); $this->alt_option_name = 'optimizer_front_posts'; add_action('wp_enqueue_scripts', array(&$this, 'optimizer_posts_enqueue_css')); } /* ---------------------------- */ /* ------- Display Widget -------- */ /* ---------------------------- */ function widget( $args, $instance ) { extract( $args ); /* Our variables from the widget settings. */ $title = isset( $instance['title'] ) ? wp_kses_post($instance['title']) : __('Our Work', 'optimizer'); $subtitle = isset( $instance['subtitle'] ) ? wp_kses_post($instance['subtitle']) : __('Check Out Our Portfolio', 'optimizer'); $layout = isset( $instance['layout'] ) ? absint($instance['layout']) : '1'; $type = isset( $instance['type'] ) ? esc_attr($instance['type']) : 'post'; $count = isset( $instance['count'] ) ? absint($instance['count']) : '6'; $category = isset( $instance['category'] ) ? $instance['category'] : array(); $divider = isset( $instance['divider'] ) ? apply_filters('widget_title', $instance['divider'], $this->id_base) : 'fa-stop'; $navigation = isset( $instance['navigation'] ) ? esc_html($instance['navigation']) : 'numbered'; $postbgcolor = isset( $instance['postbgcolor'] ) ? esc_html($instance['postbgcolor']) : ''; $titlecolor = isset( $instance['titlecolor'] ) ? esc_html($instance['titlecolor']) : ''; $secbgcolor = isset( $instance['secbgcolor'] ) ? esc_html($instance['secbgcolor']) : ''; /* Before widget (defined by themes). */ echo $before_widget; if(is_customize_preview()) echo ''.$this->name.''; //THE QUERY if(!empty($category) && $type == 'post'){ $blogcat = array_map( 'esc_html', $category ); $blogcats =implode(',', $blogcat); }else{ $blogcats = ''; } echo '
'; echo '
'; if($title) { echo '

'.do_shortcode($title).'

';} if($subtitle) { echo '
'.do_shortcode($subtitle).'
'; } if ( $divider ){ if( $divider !== 'no_divider'){ if($divider == 'underline'){ $underline= 'title_underline';}else{$underline='';} echo '
'; } } echo '
'; //Call the Posts optimizer_posts($layout, $type, $count, $category, $navigation); echo '
'; /* After widget (defined by themes). */ echo $after_widget; } /* ---------------------------- */ /* ------- Update Widget -------- */ /* ---------------------------- */ function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip tags for title and name to remove HTML (important for text inputs). */ $instance['title'] = wp_kses_post( $new_instance['title'] ); /* No need to strip tags */ $instance['subtitle'] = wp_kses_post( $new_instance['subtitle'] ); $instance['layout'] = esc_html($new_instance['layout']); $instance['type'] = esc_html($new_instance['type']); $instance['count'] = esc_html($new_instance['count']); $instance['category'] = $new_instance['category']; $instance['divider'] = esc_html($new_instance['divider']); $instance['navigation'] = esc_html($new_instance['navigation']); $instance['postbgcolor'] = optimizer_sanitize_hex($new_instance['postbgcolor']); $instance['titlecolor'] = optimizer_sanitize_hex($new_instance['titlecolor']); $instance['secbgcolor'] = optimizer_sanitize_hex($new_instance['secbgcolor']); return $instance; } /* ---------------------------- */ /* ------- Widget Settings ------- */ /* ---------------------------- */ /** * Displays the widget settings controls on the widget panel. * Make use of the get_field_id() and get_field_name() function * when creating your form elements. This handles the confusing stuff. */ function form( $instance ) { /* Set up some default widget settings. */ $defaults = array( 'title' => __('Our Work','optimizer'), 'subtitle' => __('Check Out Our Work','optimizer'), 'layout' => '1', 'type' => 'post', 'count' => '6', 'category' => array(), 'divider' => 'fa-stop', 'navigation' => 'numbered', 'postbgcolor' => '', 'titlecolor' => '#333333', 'secbgcolor' => '#ffffff', ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

" type="text" />

" type="text" />

'ids' )); foreach($categories as $cat) { ?>

option_name); if ( empty( $settings ) ) { return; } foreach ( $settings as $instance_id => $instance ) { $id = $this->id_base . '-' . $instance_id; if ( ! is_active_widget( false, $id, $this->id_base ) ) { continue; } $postbgcolor = ''; $titlecolor = '#333333;'; $secbgcolor = 'background-color:#ffffff;'; if ( ! empty( $instance['layout'] ) ) {$layout = esc_html($instance['layout']); }else{$layout = '1';} if ( ! empty( $instance['postbgcolor'] ) ) { $postbgcolor = 'background-color: ' . esc_html($instance['postbgcolor']) . '; '; } if ( ! empty( $instance['titlecolor'] ) ) { $titlecolor = $instance['titlecolor'] . '; '; } if ( ! empty( $instance['secbgcolor'] ) ) { $secbgcolor = 'background-color: ' . esc_html($instance['secbgcolor']) . '; '; } $widget_style = '#'.$id.' .lay'.$layout.' .hentry{ '.$postbgcolor.' }#'.$id.' .lay'.$layout.'{ '.$secbgcolor.' }#'.$id.' .lay'.$layout.' .home_title, #'.$id.' .lay'.$layout.' .home_subtitle, #'.$id.' span.div_middle{color:'.$titlecolor.' }#'.$id.' span.div_left, #'.$id.' span.div_right{background-color:' . $titlecolor . '}'; wp_add_inline_style( 'optimizer-style', $widget_style ); } } } ?>