upPrev — Next Post Slide-in Box
[Plugin: upPrev: NYTimes Style "Next Post" Animated Button] small update to make friendly (1 post)

  1. sboisvert
    Posted 5 years ago #

    this is a small modification I made to the plugin to make it use the built in script and style queing function so that they could they be minified and cached.

    function upprev_head() {
    $plugin_path = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
    $options = get_option("upprev-settings-group");
    $sufix = $options['upprev_animation'] == "fade" ? "fade" : "flyout";
    wp_enqueue_script('upprev', $plugin_path .'upprev_js.php',array('jquery','jquery-ui'),1,false);
    wp_enqueue_style('upprev', $plugin_path .'upprev_'. $sufix .'.css');

    add_action('plugins_loaded', 'upprev_head');

    I also removed:
    as they are not in the local function scope and therefore unsetting them does nothing as they are already undefined.

    I also built a second function that takes the most related post from efficient related post plugin and serves that one as the recommendation.

    As this is only for our site, I'm only sharing the code in hopes in can be of use to someone else.

    function upprev_box() {
    //only run on single pages
    global $upprev_is_single;
    if (!$upprev_is_single)
    return true;

    $relatedPost = efficientRelatedPosts::getInstance();
    $posts = $relatedPost->getRelatedPostsArray();
    if (is_array($posts)){
    echo '<div id="upprev_box"><h6>'. __('You might also be interested in: ','plugin').'</h6>';
    echo '<button id="upprev_close" type="button">'.__('Close','plugin').'</button></div>';

    Thank you for this great plugin!



Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 5 years ago by sboisvert
  • This topic is not a support question
  • WordPress version: 3.0.1