__('You can feature a certain post in this widget and display it, where and however you want, in your widget areas. A backup post can be given to avoid dubble content. Define, on what pages the widget will show.', $afpw_language_file) ); $control_opts = array( 'width' => 400 ); parent::WP_Widget(false, $name = 'Advanced Featured Post', $widget_opts, $control_opts); } function form($instance) { global $afpw_language_file; // setup some default settings $defaults = array( 'homepage' => true, 'category' => true ); $instance = wp_parse_args( (array) $instance, $defaults ); $title = esc_attr($instance['title']); $thumb = esc_attr($instance['thumb']); $image = esc_attr($instance['image']); $article = esc_attr($instance['article']); $backup = esc_attr($instance['backup']); $width = esc_attr($instance['width']); $headline = esc_attr($instance['headline']); $excerpt = esc_attr($instance['excerpt']); $linespace = esc_attr($instance['linespace']); $notext = esc_attr($instance['notext']); $noshorts = esc_attr($instance['noshorts']); $readmore = esc_attr($instance['readmore']); $rmtext = esc_attr($instance['rmtext']); $adsense = esc_attr($instance['adsense']); $style = esc_attr($instance['style']); $homepage=esc_attr($instance['homepage']); $frontpage=esc_attr($instance['frontpage']); $page=esc_attr($instance['page']); $category=esc_attr($instance['category']); $single=esc_attr($instance['single']); $date=esc_attr($instance['date']); $tag=esc_attr($instance['tag']); $attachment=esc_attr($instance['attachment']); $taxonomy=esc_attr($instance['taxonomy']); $author=esc_attr($instance['author']); $search=esc_attr($instance['search']); $not_found=esc_attr($instance['not_found']); $features = get_posts('numberposts=-1'); ?>













'; $afpw_after_widget=''; endif; // hooking into ads easy for the google tags if (AE_AD_TAGS == 1 && $instance['adsense']) : $ae_options = get_option('ae_options'); do_action('google_end_tag'); if ($ae_options['ae_sidebar']==1) do_action('google_ignore_tag'); else do_action('google_start_tag'); endif; // widget starts echo $afpw_before_widget; if ( $title ) echo $before_title . $title . $after_title; global $wp_query; $afpw_post_id = get_post($instance['article']); $afpw_post_name = $afpw_post_id->post_name; $afpw_post = ($instance['article'] == $wp_query->get( 'p' ) || $afpw_post_name == $wp_query->get ( 'name' )) ? 'p='.$instance['backup'] : 'p='.$instance['article']; if ($afpw_post=='p=') $afpw_post = 'numberposts=1&orderby=rand'; /* This is the actual function of the plugin, it fills the widget with the customized post */ global $post; $afpw_posts = get_posts($afpw_post); foreach($afpw_posts as $post) : $imagetags = new A5_ImageTags; $afpw_tags = $imagetags->get_tags($post, $afpw_language_file); $afpw_image_alt = $afpw_tags['image_alt']; $afpw_image_title = $afpw_tags['image_title']; $afpw_title_tag = $afpw_tags['title_tag']; // headline, if wanted if ($instance['headline'] != 'none') : $afpw_options = get_option('afpw_options'); if (count ($afpw_options)!=0 && !empty ($afpw_options)) $afpw_class=' class="afpwlink"'; $eol = "\r\n"; $afpw_headline = '

'.$eol.''.get_the_title().''.$eol.'

'; endif; // thumbnail, if wanted if (!$instance['thumb']) : if ($instance['image']) : $args = array ( 'content' => $post->post_content, 'width' => $instance['width'] ); $afpw_image = new A5_Thumbnail; $afpw_image_info = $afpw_image->get_thumbnail($args); $afpw_thumb = $afpw_image_info['thumb']; $afpw_width = $afpw_image_info['thumb_width']; $afpw_height = $afpw_image_info['thumb_height']; if ($afpw_thumb) : if ($afpw_width) $afpw_img_tag = ''.$afpw_image_alt.''; else $afpw_img_tag = ''.$afpw_image_alt.''; endif; else : $afpw_img_tag = get_the_post_thumbnail(); endif; $afpw_image = ''.$afpw_img_tag.''.$eol.'
'.$eol; endif; // excerpt. if wanted if (!$instance['notext']) : $rmtext = ($instance['rmtext']) ? $instance['rmtext'] : '[…]'; $shortcode = ($instance['noshorts']) ? false : 1; $args = array( 'usertext' => $instance['excerpt'], 'excerpt' => $post->post_excerpt, 'content' => $post->post_content, 'shortcode' => $shortcode, 'linespace' => $instance['linespace'], 'link' => get_permalink(), 'title' => $afpw_title_tag, 'readmore' => $instance['readmore'], 'rmtext' => $rmtext ); $afpw_excerpt = new A5_Excerpt; $afpw_text = $afpw_excerpt->get_excerpt($args); endif; // writing the stuff in the widget if ($instance['headline'] == 'top') echo $afpw_headline.$eol; if (!$instance['thumb']) echo $afpw_image; if ($instance['headline'] == 'bottom') echo $afpw_headline.$eol; if (!$instance['notext']) echo '

'.do_shortcode($afpw_text).'

'.$eol; endforeach; // hooking into ads easy for the google tags echo $afpw_after_widget; if (AE_AD_TAGS == 1 && $instance['adsense']) : $ae_options = get_option('ae_options'); do_action('google_end_tag'); if ($ae_options['ae_sidebar']==1) do_action('google_start_tag'); else do_action('google_ignore_tag'); endif; endif; } // widget } // Advanced Featured Post Widget add_action('widgets_init', create_function('', 'return register_widget("Advanced_Featured_Post_Widget");')); ?>