Documentation'; $support_link = 'Support'; if ($file == plugin_basename(__FILE__)) { $links[] = $documentation_link; $links[] = $support_link; } return $links; } // plugin_meta_links // add settings link to plugins page function plugin_action_links($links) { $settings_link = 'Settings'; array_unshift($links, $settings_link); return $links; } // plugin_action_links // create the admin menu item function admin_menu() { add_theme_page('Premium Featured Posts Slider', 'Premium Featured Posts Slider', 'manage_options', 'wf-fps', array('wf_fps', 'options_page')); } // admin_menu // all settings are saved in one option function register_settings() { register_setting('wf_fps', 'wf_fps', array('wf_fps', 'sanitize_settings')); } // register_settings // set default settings function default_settings($force = false) { $defaults['width'] = '600px'; $defaults['source'] = 'post'; $defaults['limit'] = 5; $defaults['thumbnail'] = 'medium'; $defaults['layout'] = 'layout-2'; $defaults['custom-layout'] = ''; $defaults['prev-next'] = 1; $defaults['pagination'] = 1; $defaults['autoplay'] = 5000; $defaults['effect'] = 'slide'; $defaults['effect-speed'] = 350; $defaults['hover-pause'] = 1; $defaults['randomize'] = 0; $defaults['include-css'] = 1; $defaults['include-jquery'] = 0; $defaults['include-slides'] = 1; $defaults['shortcode'] = 'fps'; $defaults['additional-width'] = 330; $defaults['additional-height'] = 330; $defaults['additional-crop'] = 1; $defaults['conditional'] = ''; $defaults['thumbnail-width'] = 50; $defaults['thumbnail-height'] = 50; $options = get_option('wf_fps'); if ($force || !$options || !$options['source']) { update_option('wf_fps', $defaults); } } // default_settings // add custom boxes to all post types function add_custom_box() { add_meta_box('featured', 'Featured Posts Slider per-post options', array('wf_fps', 'inner_custom_box'), 'post', 'normal', 'high'); add_meta_box('featured', 'Featured Posts Slider per-post options', array('wf_fps', 'inner_custom_box'), 'page', 'normal', 'high'); // add box to custom post types $post_types = get_post_types(array('public' => true, '_builtin' => false), 'object', 'and'); if ($post_types) { foreach ($post_types as $post_type ) { add_meta_box('featured', 'Featured Posts Slider per-post options', array('wf_fps', 'inner_custom_box'), $post_type->query_var, 'normal', 'high'); } } } // add_custom_box // custom box for post/page edit function inner_custom_box() { global $post; $layouts[] = array('val' => '', 'label' => 'Default layout defined in global FPS options'); $layouts[] = array('val' => 'layout-1', 'label' => 'Layout 1 - Large image with title on image bottom'); $layouts[] = array('val' => 'layout-2', 'label' => 'Layout 2 - Thumbnail with content on right'); $layouts[] = array('val' => 'layout-3', 'label' => 'Layout 3 - Medium image with content on right'); $layouts[] = array('val' => 'layout-4', 'label' => 'Layout 4 - Large image with title above image '); $layouts[] = array('val' => 'layout-5', 'label' => 'Layout 5 - Thumbnail with content on left'); $layouts[] = array('val' => 'layout-6', 'label' => 'Layout 6 - Medium image with content on left'); $layouts[] = array('val' => 'custom', 'label' => 'Custom layout'); $featured = get_post_meta($post->ID, '_fps_featured', true); $thumbnail = get_post_meta($post->ID, '_fps_thumbnail', true); $layout = get_post_meta($post->ID, '_fps_layout', true); wp_nonce_field(plugin_basename(__FILE__), 'featured_noncename'); echo '



'; echo '

'; global $_wp_additional_image_sizes; $sizes[] = array('val'=> '', 'label' => 'Default thumbnail size defined in global FPS options'); $sizes[] = array('val'=> 'thumbnail', 'label' => 'Thumbnail, ' . get_option('thumbnail_size_w') . 'x' . get_option('thumbnail_size_h') . (get_option('thumbnail_crop')? ', cropped':'')); $sizes[] = array('val'=> 'medium', 'label' => 'Medium, ' . get_option('medium_size_w') . 'x' . get_option('medium_size_h')); $sizes[] = array('val'=> 'large', 'label' => 'Large, ' . get_option('large_size_w') . 'x' . get_option('large_size_h')); if ($_wp_additional_image_sizes) { foreach ($_wp_additional_image_sizes as $tmp => $tmp2) { $sizes[] = array('val'=> $tmp, 'label' => $tmp . ', ' . $tmp2['width'] . 'x' . $tmp2['height'] . ($tmp2['crop']? ', cropped':'')); } } echo '

'; echo '


Configure global FPS options

'; } // inner_custom_box // save fetured box data function save_postdata($post_id) { if (!wp_verify_nonce($_POST['featured_noncename'], plugin_basename(__FILE__)) || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) { return $post_id; } update_post_meta($post_id, '_fps_featured', $_POST['fps_featured']); update_post_meta($post_id, '_fps_layout', $_POST['fps_layout']); update_post_meta($post_id, '_fps_thumbnail', $_POST['fps_thumbnail']); return $post_id; } // save_postdata // mark post as fetured/unfeatured function ajax_callback_post_featured() { $post_id = (int) $_POST['post_id']; $state = (isset($_POST['state']) && !empty($_POST['state']))? 1: 0; update_post_meta($post_id, '_fps_featured', $state); die('1'); } // ajax_callback_post_featured // mark post as fetured/unfeatured function ajax_callback_copy_layout() { require('slider-layout-templates.php'); if (isset($layouts[$_POST['layout']])) { $template = $layouts[$_POST['layout']]; } else { $template = ''; } echo json_encode($template); die(); } // ajax_callback_post_featured // featured column for all posts/pages/custom post types function add_featured_column($cols) { $cols['fps_featured'] = 'Featured'; return $cols; } // add_featured_column // featured column content function manage_featured_column($column_name, $post_id) { if ($column_name == 'fps_featured') { echo ''; } return; } // manage_featured_column // admin JS/CSS function admin_head() { if (strpos($_SERVER['REQUEST_URI'], 'wf-fps') === false && strpos($_SERVER['REQUEST_URI'], 'edit.php') === false && strpos($_SERVER['REQUEST_URI'], 'post.php') === false ) { return; } ?> {$tmp['label']} \n"; } else { $out .= "\n"; } } if($output) { echo $out; } else { return $out; } } // create_select_options // sanitize settings on save function sanitize_settings($values) { foreach ($values as $key => $value) { switch ($key) { case 'limit': case 'prev-next': case 'pagination': case 'autoplay': case 'effect-speed': case 'hover-pause': case 'randomize': case 'include-css': case 'include-jquery': case 'include-slides': case 'additional-width': case 'additional-height': case 'thumbnail-width': case 'thumbnail-height': case 'additional-crop': $values[$key] = (int) $value; break; case 'width': case 'source': case 'thumbnail': case 'layout': case 'effect': case 'conditional': $values[$key] = trim($value); break; case 'shortcode': $values[$key] = strtolower(trim($value)); $values[$key] = str_replace(' ', '', $values[$key]); break; case 'custom-layout': break; } // switch } // foreach self::check_var_isset($values, array('prev-next' => 0, 'pagination' => 0, 'hover-pause' => 0, 'randomize' => 0, 'include-css' => 0, 'include-jquery' => 0, 'include-slides' => 0, 'additional-crop' => 0)); set_transient('wf-fps-updated', true, 10); return $values; } // sanitize_settings // helper function for $_POST checkbox handling function check_var_isset(&$values, $variables) { foreach ($variables as $key => $value) { if (!isset($values[$key])) { $values[$key] = $value; } } } // check_var_isset // output the whole options page function options_page() { if (!current_user_can('manage_options')) { wp_die('You do not have sufficient permissions to access this page.'); } $options = get_option('wf_fps'); if (get_transient('wf-fps-updated')) { echo '

Changes saved.

'; delete_transient('wf-fps-updated'); } echo '

Premium Featured Posts Slider

'; echo '
'; settings_fields('wf_fps'); echo '

Content & Layout

'; echo ''; echo ''; $sources[] = array('val' => '_featured', 'label' => 'Posts, pages and custom types selected as featured'); $sources[] = array('val' => 'post', 'label' => 'Latest Posts'); $sources[] = array('val' => 'page', 'label' => 'Latest Pages'); $post_types = get_post_types(array('public' => true, '_builtin' => false), 'object', 'and'); if ($post_types) { foreach ($post_types as $post_type ) { $sources[] = array('val' => $post_type->query_var, 'label' => 'Latest ' . $post_type->labels->name); } } $excluded_items = array('nav_menu', 'link_category', 'post_format'); $taxonomies = get_taxonomies(array('public' => true), 'objects'); if ($taxonomies) { foreach ($taxonomies as $taxonomy) { if (!in_array($taxonomy->name, $excluded_items)) { $terms = get_terms($taxonomy->name); if ($terms) { foreach ($terms as $term) { $sources[] = array('val' => '|' . $taxonomy->name . '|' . $term->term_id, 'label' => 'Latest content from ' . $term->name . ' (' . $taxonomy->labels->name . ')'); } // foreach ($terms) } // if ($terms) } // if (!in_array) } // foreach ($taxonomies) } // if ($taxonomies) echo ''; $limit[] = array('val' => -1, 'label' => 'Unlimited'); for ($i=1; $i <= 20; $i++) { $limit[] = array('val' => $i, 'label' => $i); } echo ''; global $_wp_additional_image_sizes; $sizes[] = array('val'=> 'thumbnail', 'label' => 'Thumbnail, ' . get_option('thumbnail_size_w') . 'x' . get_option('thumbnail_size_h') . (get_option('thumbnail_crop')? ', cropped':'')); $sizes[] = array('val'=> 'medium', 'label' => 'Medium, ' . get_option('medium_size_w') . 'x' . get_option('medium_size_h')); $sizes[] = array('val'=> 'large', 'label' => 'Large, ' . get_option('large_size_w') . 'x' . get_option('large_size_h')); if ($_wp_additional_image_sizes) { foreach ($_wp_additional_image_sizes as $tmp => $tmp2) { $sizes[] = array('val'=> $tmp, 'label' => $tmp . ', ' . $tmp2['width'] . 'x' . $tmp2['height'] . ($tmp2['crop']? ', cropped':'')); } } echo ''; $img = plugins_url('/images/', __FILE__); $layouts[] = array('val' => 'layout-1', 'label' => 'Layout 1 - Large image with title on image bottom'); $layouts[] = array('val' => 'layout-2', 'label' => 'Layout 2 - Thumbnail with content on right'); $layouts[] = array('val' => 'layout-3', 'label' => 'Layout 3 - Medium image with content on right'); $layouts[] = array('val' => 'layout-4', 'label' => 'Layout 4 - Large image with title above image '); $layouts[] = array('val' => 'layout-5', 'label' => 'Layout 5 - Thumbnail with content on left'); $layouts[] = array('val' => 'layout-6', 'label' => 'Layout 6 - Medium image with content on left'); echo ''; echo '
'; echo ' Slider container width. Set the value according to your theme layout. Any CSS parsable value is accepted. We don\'t recommend using "100%". Default: 600px.
It\'s expected from editors to manually choose what content is featured but you can automate the process by featuring chronologically latest content. Default: latest posts.
Number of posts shown in slider. If the number of "featured" posts is greater than "number of slides" the later will take precedence. Default: 5.
Select the size that best fits your site\'s layout and selected FPS layout. You can customize the FPS thumbnail size. Thumbnail size can be chosen on a per-post basis while editing individual posts. Default: medium.

Large image with title on image bottom

Thumbnail with content on right

Medium image with content on right

Large image with title above image

Thumbnail with content on left

Medium image with content on left


'; echo '

Copy code from a predefined layout into the code editor:

The following 18 variables are available for use in custom layout code: (show variables)

Layouts can be chozen on a per-post basis while editing individual posts. Default: layout 2.

'; echo '

'; echo '

Options

'; echo ''; echo ''; $pagination[] = array('val' => '0', 'label' => 'No'); $pagination[] = array('val' => '1', 'label' => 'Yes, in form of circles'); $pagination[] = array('val' => '2', 'label' => 'Yes, in form of post thumbnails'); echo ''; $autoplay[] = array('val' => '0', 'label' => 'Disable autoplay'); $autoplay[] = array('val' => '500', 'label' => 'Every 0.5 seconds'); $autoplay[] = array('val' => '1000', 'label' => 'Every second'); $autoplay[] = array('val' => '1500', 'label' => 'Every 1.5 seconds'); for($i=2000; $i<=20000; $i+=500) { $autoplay[] = array('val' => $i, 'label' => 'Every ' . number_format($i/1000, 1) . ' seconds'); } echo ''; $effects[] = array('val' => 'slide', 'label' => 'Slide'); $effects[] = array('val' => 'fade', 'label' => 'Fade'); echo ''; for($i=50; $i<=2000; $i+=50) { $speed[] = array('val' => $i, 'label' => $i . ' miliseconds'); } echo ''; echo ''; echo ''; echo '
If checked previous and next buttons will be placed on left and right edges of the slider. Default: checked.
If checked pagination circles or thumbnails will be placed below the slider. Default: circles.
Time between each automatic slide switch. Default: 5 seconds.
Effect used for transitioning between slides. Default: slide.
Duration of transition effect/animation in milliseconds. Default: 350 milliseconds.
If checked autoplay will be stopped once user hovers over the slider. Default: checked.
Randomize slides order. By default they are orderd by publishing date, descending. Default: unchecked.
'; echo '

'; echo '

Advanced Options

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if (!$options['thumbnail-width'] || !$options['thumbnail-height']) { $options['thumbnail-width'] = 50; $options['thumbnail-height'] = 50; } echo ''; $conditionals[] = array('val' => '', 'label' => 'On all pages'); $conditionals[] = array('val' => 'is_front_page', 'label' => 'Only if is_front_page()'); $conditionals[] = array('val' => 'is_home', 'label' => 'Only if is_home()'); $conditionals[] = array('val' => 'is_category', 'label' => 'Only if is_category()'); $conditionals[] = array('val' => 'is_singular', 'label' => 'Only if is_singular()'); $conditionals[] = array('val' => 'is_not_singular', 'label' => 'Only if is_not_singular()'); echo ''; echo '
If you wrote your own CSS for slides or copy/pasted our CSS code into some other file then disable this option. Default: checked.
If your theme doesn\'t already have jQuery included enable this option. Default: unchecked.
If your theme already has Slides JS included uncheck this option. Default: checked.
'; echo ' Write only the shortcode name, without brackets. If the shortcode name you want is already taken you\'ll be notified after saving. Default: fps.
x px       '; echo '
If you need an additional image (thumbnail) size besides the default WordPress sizes (thumbnail, medium, large) you can define it here. Please note: changes to image sizes are not "retroactive" meaning they will only affect newly uploaded images. Once the size is changed you have to re-build or re-upload the images. We suggest using Image Sizes Manager. Default: 330x330px, cropped.
x px'; echo '
If you\'re using thumbnails for pagination please set the size that fits your theme and needs. Please note: changes to image sizes are not "retroactive" meaning they will only affect newly uploaded images. Once the size is changed you have to re-build or re-upload the images. We suggest using Image Sizes Manager. Default: 50x50px, cropped.
If you want FPS shown only on certain pages but you placed FPS code in ie header.php set this option to enable conditional display. Default: always display FPS.
'; echo '

'; echo '
'; } // options_page // generate HTML code for slider public function generate_html() { $out = ''; $options = get_option('wf_fps'); // show slider only in certain circumstances if ($options['conditional']) { if ($options['conditional'] == 'is_home' && !is_home()) { return; } elseif ($options['conditional'] == 'is_front_page' && !is_front_page()) { return; } elseif ($options['conditional'] == 'is_category' && !is_category()) { return; } elseif ($options['conditional'] == 'is_singular' && !is_singular()) { return; } elseif ($options['conditional'] == 'is_not_singular' && is_singular()) { return; } } $types = array('post', 'page'); $post_types = get_post_types(array('public' => true, '_builtin' => false), 'object', 'and'); if ($post_types) { foreach ($post_types as $post_type ) { $types[] = $post_type->query_var; } } else { $post_types = array(); } if ($options['source'] == '_featured') { $filter = array('numberposts' => $options['limit'], 'meta_key' => '_fps_featured', 'meta_value' => 1, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => $types); } elseif (substr($options['source'], 0, 1) != '|') { $filter = array('numberposts' => $options['limit'], 'post_type' => $options['source'], 'orderby' => 'post_date', 'order' => 'DESC',); } else { $source = explode('|', $options['source']); if ($source[1] == 'category') { $category = 'category'; } else { $category = $source[1] . '_category'; } $filter = array('numberposts' => $options['limit'], 'post_type' => $types, $category => $source[2], 'orderby' => 'post_date', 'order' => 'DESC',); } $featured_posts = get_posts($filter); require('slider-layout-templates.php'); $out .= '
'; $out .= '
'; $slide_nb = 1; $pagination = ''; foreach($featured_posts as $featured) { $pagination .= '
  • ' . get_the_post_thumbnail($featured->ID, 'FPS pagination thumbnail', array('class' => 'fps-thumbnail-mini')) . '
  • '; // $featured "is" $post // get per-post or global layout if (get_post_meta($featured->ID, '_fps_layout', true)) { $layout = get_post_meta($featured->ID, '_fps_layout', true); } else { $layout = $options['layout']; } if ($layout == 'custom') { $template = $options['custom-layout']; } else { $template = $layouts[$layout]; } // get per-post or global thumbnail size if (get_post_meta($featured->ID, '_fps_thumbnail', true)) { $thumbnail_size = get_post_meta($featured->ID, '_fps_thumbnail', true); } else { $thumbnail_size = $options['thumbnail']; } $tags = get_the_tags($featured->ID); $tags2 = ''; if ($tags) foreach($tags as $tag) { $tags2 .= '' . $tag->name . ', '; } $tags2 = trim($tags2, ', '); $content = $featured->post_content; if (strpos($content, '')) { $content = substr($content, 0, strpos($content, '')) . ' (more...)'; } $content = apply_filters('the_content', $content); $thumbnail = get_post_thumbnail_id($featured->ID); $thumbnail = wp_get_attachment_image_src($thumbnail, $thumbnail_size); global $post; $post = $featured; $tmp = str_replace(array('{id}', '{permalink}', '{title}', '{excerpt}', '{content-full}', '{content}', '{author}', '{author-link}', '{date}', '{time}', '{comments-count}', '{categories}', '{tags}', '{thumbnail}', '{thumbnail-src}', '{thumbnail-width}', '{thumbnail-height}', '{slider-width}'), array($featured->ID, get_permalink($featured->ID), $featured->post_title, apply_filters('the_excerpt', $featured->post_excerpt), apply_filters('the_content', $featured->post_content), $content, get_the_author_meta('display_name', $featured->post_author), get_author_posts_url($featured->post_author), get_the_date(''), get_the_time(''), (int) $featured->comments_count, get_the_category_list(', ', '', $featured->ID), $tags2, get_the_post_thumbnail($featured->ID, $thumbnail_size, array('class' => 'fps-thumbnail')), $thumbnail[0], $thumbnail[1], $thumbnail[2], $options['width']), $template); if ($slide_nb != 1) { $tmp_display = 'display: none; '; } else { $tmp_display = ''; } $out .= '
    ' . $tmp . '
    '; $slide_nb++; } // foreach post $out .= '
    '; if ($options['pagination'] == 2) { $out .= ''; } $out .= "
    \n"; // include JS/CSS only if needed if ($featured_posts) { self::$do_footer = true; } return $out; } // generate_html // shortcode for FPS, just a wrapper function shortcode($options, $content) { return self::generate_html(); } // shortcode // slides JS code for footer function wp_footer() { if (!self::$do_footer) { return; } $options = get_option('wf_fps'); $preload_img = plugins_url('/images/preload.gif', __FILE__); if($options['include-css']) { $slides_css = plugins_url('/css/featured-posts-slider.css?v4', __FILE__); echo '\n"; } if($options['include-jquery']) { $jquery_js = plugins_url('/js/jquery-1.6.2.min.js', __FILE__); echo '' . "\n"; } if($options['include-slides']) { $slides_js = plugins_url('/js/slides.min.jquery.js', __FILE__); echo '' . "\n"; } echo '\n"; } // wp_footer // warning if [fps] shortcode is already taken public function warning() { $shortcode = get_option('wf_fps'); $shortcode = $shortcode['shortcode']; echo '

    Featured Posts Slider shortcode is not active! The shortcode [' . $shortcode . '] is already in use by another plugin. Please update the settings and select a different shortcode.

    '; } // warning } // class wf_fps // template function, echoes slider code function the_featured_posts_slider() { echo wf_fps::generate_html(); } // the_featured_posts_slider // template function, returns slider code function get_the_featured_posts_slider() { return wf_fps::generate_html(); } // get_the_featured_posts_slider // hook Featured Posts Plugin add_action('init', array('wf_fps', 'init')); add_action('after_setup_theme', array('wf_fps', 'add_thumb_support')); ?>