Plugin Directory

Changeset 668069


Ignore:
Timestamp:
02/14/2013 08:08:01 PM (13 years ago)
Author:
jureham
Message:

v2.5.1

Location:
related-posts
Files:
4 deleted
2 edited
22 copied

Legend:

Unmodified
Added
Removed
  • related-posts/tags/2.5.1/readme.txt

    r667144 r668069  
    55Requires at least: 3.3
    66Tested up to: 3.5
    7 Stable tag: 2.5
     7Stable tag: 2.5.1
    88
    99This WordPress plugin provides multiple options to show the via tags related posts of a post (for example via a sidebar widget).
     
    4646== Changelog ==
    4747
     48= 2.5.1 =
     49* Fixed bug with invalid output html
     50* Improved Infinite Stream theme
     51
    4852= 2.5 =
    4953* Mobile themes settings
  • related-posts/tags/2.5.1/wp_related_posts.php

    r667706 r668069  
    22/*
    33Plugin Name: Related Posts
    4 Version: 2.5
     4Version: 2.5.1
    55Plugin URI: http://wordpress.org/extend/plugins/related-posts/
    66Description: Quickly increase your readers' engagement with your posts by adding Related Posts in the footer of your content.
     
    330330function wp_rp_head_resources() {
    331331    global $post, $wpdb;
     332    global $wp_rp_session_id, $wp_rp_test_group; // used for AB test
     333   
     334    //error_log("call to wp_rp_head_resources");
    332335
    333336    if (wp_rp_should_exclude()) {
     
    372375                "\twindow._wp_rp_admin_ajax_url = '" . admin_url('admin-ajax.php') . "';\n" .
    373376                "\twindow._wp_rp_plugin_static_base_url = '" . esc_js(plugins_url('static/' , __FILE__)) . "';\n"
    374             : '');
     377            : '')  .
     378            wp_rp_render_head_script_variables();
    375379    }
    376380
     
    497501    return "\n" . $output . "\n";
    498502}
     503
     504
     505
     506// --------- mobile AB testing -----------
     507
     508define('WP_RP_AB_TEST_PARAM', 'wprptest');
     509define('WP_RP_AB_TEST_COOKIE', 'wprptest');
     510
     511global $wp_rp_session_id, $wp_rp_test_group;
     512$wp_rp_session_id = false; $wp_rp_test_group = 0;
     513
     514function wp_rp_render_head_script_variables() {
     515    // used when rendering <head>
     516    global $wp_rp_session_id, $wp_rp_test_group;
     517   
     518    $output = '';
     519    if (wp_is_mobile()){
     520        //error_log("AB data appended in head <script>");
     521        $output = "\twindow._wp_rp_test_group = " . $wp_rp_test_group . ";\n" .
     522        "\twindow._wp_rp_sid = \"" . $wp_rp_session_id . "\";\n";
     523    }
     524    return $output;
     525}
     526
     527function wp_rp_set_test_cookie() {
     528    global $wp_rp_session_id;
     529   
     530    //error_log("wp_rp_set_test_cookie");
     531    //error_log("session_id: " .$_COOKIE[WP_RP_AB_TEST_COOKIE]);
     532   
     533    $wp_rp_session_id = isset($_COOKIE[WP_RP_AB_TEST_COOKIE]) ? $_COOKIE[WP_RP_AB_TEST_COOKIE] : false;
     534    if ($wp_rp_session_id) {
     535        //error_log("cookie is set - type: " . gettype($wp_rp_session_id));
     536        return;
     537    }
     538   
     539    $wp_rp_session_id = (string)rand();
     540    //error_log("cookie is NOT set");
     541    setcookie(WP_RP_AB_TEST_COOKIE, $wp_rp_session_id, time() + 60 * 30);
     542}
     543
     544function wp_rp_is_suitable_for_test() {
     545    $options = wp_rp_get_options();
     546    return $options['ctr_dashboard_enabled'] && wp_is_mobile();
     547}
     548
     549function wp_rp_get_post_url($post_id) {
     550    global $wp_rp_test_group;
     551
     552    //error_log("wp_rp_get_post_url");
     553
     554    $post_url = get_permalink($post_id);
     555
     556    if (!wp_rp_is_suitable_for_test()) {
     557        return $post_url;
     558    }
     559
     560    if (strpos($post_url, '?') === false) {
     561        $post_url .= '?' .WP_RP_AB_TEST_PARAM. '=' . $wp_rp_test_group;
     562    } else {
     563        $post_url .= '&' .WP_RP_AB_TEST_PARAM. '=' . $wp_rp_test_group;
     564    }
     565    return $post_url;
     566}
     567
     568
     569function wp_rp_init_test() {
     570    $platform_options = wp_rp_get_platform_options();
     571    if ($platform_options['theme_name'] !== 'm-stream.css') {
     572        return;
     573    }
     574
     575    global $wp_rp_session_id, $wp_rp_test_group, $post;
     576   
     577    //error_log("wp_rp_init_test");
     578   
     579    if ($wp_rp_session_id) {
     580        //error_log("session id set");
     581        return;
     582    }
     583
     584    if (!wp_rp_is_suitable_for_test()) {
     585        //error_log("not suitable for test");
     586        return;
     587    }
     588   
     589    wp_rp_set_test_cookie();
     590
     591    if (isset($_GET[WP_RP_AB_TEST_PARAM])) {
     592        $wp_rp_test_group = intval($_GET[WP_RP_AB_TEST_PARAM]);
     593        //error_log("wp rep test param is set: " . $wp_rp_test_group);
     594        return;
     595    }
     596
     597    $wp_rp_test_group = abs(crc32($wp_rp_session_id) % 2);
     598
     599    $options = wp_rp_get_options();
     600    if ($post && $post->post_type === 'post' && (($options["on_single_post"] && is_single()))) {
     601        wp_redirect(wp_rp_get_post_url($post->ID), 301);
     602        //error_log("redirect done");
     603        exit;
     604    }
     605    //error_log("skipped redirect");
     606}
     607add_action('template_redirect', 'wp_rp_init_test');
     608
  • related-posts/trunk/readme.txt

    r667144 r668069  
    55Requires at least: 3.3
    66Tested up to: 3.5
    7 Stable tag: 2.5
     7Stable tag: 2.5.1
    88
    99This WordPress plugin provides multiple options to show the via tags related posts of a post (for example via a sidebar widget).
     
    4646== Changelog ==
    4747
     48= 2.5.1 =
     49* Fixed bug with invalid output html
     50* Improved Infinite Stream theme
     51
    4852= 2.5 =
    4953* Mobile themes settings
  • related-posts/trunk/wp_related_posts.php

    r667706 r668069  
    22/*
    33Plugin Name: Related Posts
    4 Version: 2.5
     4Version: 2.5.1
    55Plugin URI: http://wordpress.org/extend/plugins/related-posts/
    66Description: Quickly increase your readers' engagement with your posts by adding Related Posts in the footer of your content.
     
    330330function wp_rp_head_resources() {
    331331    global $post, $wpdb;
     332    global $wp_rp_session_id, $wp_rp_test_group; // used for AB test
     333   
     334    //error_log("call to wp_rp_head_resources");
    332335
    333336    if (wp_rp_should_exclude()) {
     
    372375                "\twindow._wp_rp_admin_ajax_url = '" . admin_url('admin-ajax.php') . "';\n" .
    373376                "\twindow._wp_rp_plugin_static_base_url = '" . esc_js(plugins_url('static/' , __FILE__)) . "';\n"
    374             : '');
     377            : '')  .
     378            wp_rp_render_head_script_variables();
    375379    }
    376380
     
    497501    return "\n" . $output . "\n";
    498502}
     503
     504
     505
     506// --------- mobile AB testing -----------
     507
     508define('WP_RP_AB_TEST_PARAM', 'wprptest');
     509define('WP_RP_AB_TEST_COOKIE', 'wprptest');
     510
     511global $wp_rp_session_id, $wp_rp_test_group;
     512$wp_rp_session_id = false; $wp_rp_test_group = 0;
     513
     514function wp_rp_render_head_script_variables() {
     515    // used when rendering <head>
     516    global $wp_rp_session_id, $wp_rp_test_group;
     517   
     518    $output = '';
     519    if (wp_is_mobile()){
     520        //error_log("AB data appended in head <script>");
     521        $output = "\twindow._wp_rp_test_group = " . $wp_rp_test_group . ";\n" .
     522        "\twindow._wp_rp_sid = \"" . $wp_rp_session_id . "\";\n";
     523    }
     524    return $output;
     525}
     526
     527function wp_rp_set_test_cookie() {
     528    global $wp_rp_session_id;
     529   
     530    //error_log("wp_rp_set_test_cookie");
     531    //error_log("session_id: " .$_COOKIE[WP_RP_AB_TEST_COOKIE]);
     532   
     533    $wp_rp_session_id = isset($_COOKIE[WP_RP_AB_TEST_COOKIE]) ? $_COOKIE[WP_RP_AB_TEST_COOKIE] : false;
     534    if ($wp_rp_session_id) {
     535        //error_log("cookie is set - type: " . gettype($wp_rp_session_id));
     536        return;
     537    }
     538   
     539    $wp_rp_session_id = (string)rand();
     540    //error_log("cookie is NOT set");
     541    setcookie(WP_RP_AB_TEST_COOKIE, $wp_rp_session_id, time() + 60 * 30);
     542}
     543
     544function wp_rp_is_suitable_for_test() {
     545    $options = wp_rp_get_options();
     546    return $options['ctr_dashboard_enabled'] && wp_is_mobile();
     547}
     548
     549function wp_rp_get_post_url($post_id) {
     550    global $wp_rp_test_group;
     551
     552    //error_log("wp_rp_get_post_url");
     553
     554    $post_url = get_permalink($post_id);
     555
     556    if (!wp_rp_is_suitable_for_test()) {
     557        return $post_url;
     558    }
     559
     560    if (strpos($post_url, '?') === false) {
     561        $post_url .= '?' .WP_RP_AB_TEST_PARAM. '=' . $wp_rp_test_group;
     562    } else {
     563        $post_url .= '&' .WP_RP_AB_TEST_PARAM. '=' . $wp_rp_test_group;
     564    }
     565    return $post_url;
     566}
     567
     568
     569function wp_rp_init_test() {
     570    $platform_options = wp_rp_get_platform_options();
     571    if ($platform_options['theme_name'] !== 'm-stream.css') {
     572        return;
     573    }
     574
     575    global $wp_rp_session_id, $wp_rp_test_group, $post;
     576   
     577    //error_log("wp_rp_init_test");
     578   
     579    if ($wp_rp_session_id) {
     580        //error_log("session id set");
     581        return;
     582    }
     583
     584    if (!wp_rp_is_suitable_for_test()) {
     585        //error_log("not suitable for test");
     586        return;
     587    }
     588   
     589    wp_rp_set_test_cookie();
     590
     591    if (isset($_GET[WP_RP_AB_TEST_PARAM])) {
     592        $wp_rp_test_group = intval($_GET[WP_RP_AB_TEST_PARAM]);
     593        //error_log("wp rep test param is set: " . $wp_rp_test_group);
     594        return;
     595    }
     596
     597    $wp_rp_test_group = abs(crc32($wp_rp_session_id) % 2);
     598
     599    $options = wp_rp_get_options();
     600    if ($post && $post->post_type === 'post' && (($options["on_single_post"] && is_single()))) {
     601        wp_redirect(wp_rp_get_post_url($post->ID), 301);
     602        //error_log("redirect done");
     603        exit;
     604    }
     605    //error_log("skipped redirect");
     606}
     607add_action('template_redirect', 'wp_rp_init_test');
     608
Note: See TracChangeset for help on using the changeset viewer.