', ']]>', $text); $text = strip_tags($text); $words = explode(' ', $text, $posts_settings['ex_length'] + 1); if (count($words) > $posts_settings['ex_length']) { array_pop($words); $text = implode(' ', $words); } } return $text . '...'; } // Display on page. function featuredposts() { global $post, $wpdb, $posts_settings; $post = new WP_Query('p='.$posts_settings['posts_id'].''); $post->the_post(); if ($posts_settings['i_display'] == 'yes') { $headerimages =& get_children('post_type=attachment&post_mime_type=image&post_parent=' . $posts_settings['posts_id']); if ($headerimages) { $thumb_w = get_option('thumbnail_size_w'); $thumb_h = get_option('thumbnail_size_h'); if ($thumb_w < $posts_settings['i_width'] || $thumb_h < $posts_settings['i_height']) { $image_url = wp_get_attachment_image_src(array_shift(array_keys($headerimages)), $size='full'); $image_url = $image_url[0]; } else { $image_url = wp_get_attachment_image_src(array_shift(array_keys($headerimages)), $size='thumbnail'); $image_url = $image_url[0]; } echo '

',the_title(),'

'; if($posts_settings['fp_desc_custom'] == 'yes'){echo $posts_settings['fp_desc'];} else{ echo fp_custom_excerpt($post); } echo '

Read the story »

'; } } else { echo '

',the_title(),'

'; if($posts_settings['fp_desc_custom'] == 'yes'){echo $posts_settings['fp_desc'];} else{ echo fp_custom_excerpt($post); } echo '

Read the story »

'; } } // Add a settings link within wp-admin function featured_posts_add_pages() { add_options_page('Choose your featured post', 'Featured Posts', 8, 'featuredpostsoptions', 'featured_posts_options_page'); } // What to display on settings page. function featured_posts_options_page() { global $posts_settings, $_POST; if (!empty($_POST)) { if (isset($_POST['posts_id'])) { $posts_settings['posts_id'] = $_POST['posts_id']; } if (isset($_POST['ex_length'])) { $posts_settings['ex_length'] = $_POST['ex_length']; } if (isset($_POST['i_width'])) { $posts_settings['i_width'] = $_POST['i_width']; } if (isset($_POST['i_height'])) { $posts_settings['i_height'] = $_POST['i_height']; } if (isset($_POST['fp_desc'])) { $posts_settings['fp_desc'] = $_POST['fp_desc']; } $posts_settings['i_display'] = ($_POST['i_display'] == 'yes') ? 'yes' : 'no'; $posts_settings['fp_desc_custom'] = ($_POST['fp_desc_custom'] == 'yes') ? 'yes' : 'no'; update_option('posts_settings',$posts_settings); echo '

Your settings have been saved.

'; } echo '

Set Up Your Featured Posts

This plugin makes it easy to add featured posts to your site.

Paste this code outside the loop to display: <?php if function_exists(\'featuredposts\') { featuredposts(); } ?>

If you like this plugin, please consider linking to impNERD.com

'; } // Add CSS link to header. function headfeaturedposts() { echo ''; } add_action('admin_menu', 'featured_posts_add_pages'); add_action('wp_head','headfeaturedposts'); register_activation_hook( __FILE__, fp_activate); register_deactivation_hook( __FILE__, fp_deactivate); // Add option setting to database when this plugin is activated. function fp_activate() { $posts_settings = array('posts_id' => 1,'ex_length' => 55,'i_display' => 'yes','i_width' => 233,'i_height' => 175,'fp_desc_custom' => 'no','fp_desc' => ''); if (!get_option('posts_settings')){ add_option('posts_settings' , $posts_settings); } else { update_option('posts_settings' , $posts_settings); } } // Delete option setting from database when this plugin is deactivated. function fp_deactivate() { delete_option('posts_settings'); } ?>