Plugin Directory

Changeset 1506564


Ignore:
Timestamp:
10/01/2016 06:19:05 PM (10 years ago)
Author:
123teru321
Message:

1.1.0

Location:
ucb-recommend
Files:
273 added
22 edited

Legend:

Unmodified
Added
Removed
  • ucb-recommend/trunk/controllers/010-widget.php

    r1499492 r1506564  
    3030    public function load()
    3131    {
    32         $loading_image = $this->apply_filters( "loading_image", UCB_RECOMMEND_LIB_IMG_DIR . DIRECTORY_SEPARATOR . 'loading.gif', -1 );
     32        $loading_image = $this->apply_filters( "loading_image", UCB_RECOMMEND_LIB_IMG_DIR . DIRECTORY_SEPARATOR . UCB_RECOMMEND_LOADING_IMAGE, -1 );
    3333        $loading_image = $this->dir2path( $loading_image );
    3434
  • ucb-recommend/trunk/languages/UCBRecommend-ja.po

    r1503880 r1506564  
    33"Project-Id-Version: ucb-recommend0.0.0.0.1\n"
    44"POT-Creation-Date: 2016-07-19 20:40+0900\n"
    5 "PO-Revision-Date: 2016-09-28 02:08+0900\n"
     5"PO-Revision-Date: 2016-10-02 01:41+0900\n"
    66"Last-Translator: \n"
    77"Language-Team: \n"
     
    431431msgid "Whether to check referer when ajax access without nonce check"
    432432msgstr "nonceチェックをせずにAjaxアクセスする場合にリファラをチェックするかどうか"
     433
     434msgid "Please update your PHP. <strong>%s</strong> requires PHP version 5.4 or above"
     435msgstr "PHPをアップデートして下さい。 <strong>%s</strong>の動作にはPHP5.4以上が必要です。"
     436
     437msgid "Standard Deviation to use calculate score from ucb score"
     438msgstr "UCB値からスコア計算時の標準偏差"
     439
     440msgid "Changed [%s] to [%s]"
     441msgstr "[%s]を[%s]に変更しました"
     442
     443msgid "Whether to show test button"
     444msgstr "テストボタンを表示するかどうか"
     445
     446msgid "Whether to consider page cache"
     447msgstr "ページキャッシュを考慮するかどうか"
     448
     449msgid "Whether to check develop update"
     450msgstr "開発版のアップデートをチェックするかどうか"
     451
     452msgid "Test"
     453msgstr "動作テスト"
     454
     455msgid "Retest"
     456msgstr "再テスト"
     457
     458msgid "There's no problem"
     459msgstr "設定に問題はありません"
     460
     461msgid "Ajax test"
     462msgstr "Ajaxテスト"
  • ucb-recommend/trunk/lib/common/010-defines.php

    r1499492 r1506564  
    4343define( 'UCB_RECOMMEND_TMP_DIR', UCB_RECOMMEND_ROOT_DIR . DIRECTORY_SEPARATOR . "tmp" );
    4444define( 'UCB_RECOMMEND_UPLOAD_DIR', UCB_RECOMMEND_ROOT_DIR . DIRECTORY_SEPARATOR . "upload" );
    45 define( 'UCB_RECOMMEND_LANGUAGES_DIR', UCB_RECOMMEND_ROOT_DIR . DIRECTORY_SEPARATOR . "languages" );
    4645
    4746//lib url
  • ucb-recommend/trunk/lib/common/030-base-class.php

    r1503880 r1506564  
    1010    private static $settings = array(
    1111        "exclude_loggedin_user" => array( "label" => "Whether to exclude logged in user", "type" => "bool", "default" => UCB_RECOMMEND_EXCLUDE_LOGGEDIN_USER ),
    12 //      "update_cookie_expire" => array( "label" => "Whether to update cookie expiration when accessed or not", "type" => "bool", "default" => UCB_RECOMMEND_UPDATE_COOKIE_EXPIRE ),
    13 //      "user_expire" => array( "label" => "Expiration of user's cookie", "type" => "int", "default" => UCB_RECOMMEND_USER_EXPIRE, "min" => 0 ),
    14 //      "sampling_rate" => array( "label" => "Sampling rate", "type" => "float", "default" => UCB_RECOMMEND_SAMPLING_RATE, "min" => 0, "max" => 1, "option" => "sampling_rate", "option_default" => UCB_RECOMMEND_DEFAULT_SAMPLING_RATE ),
    15 //      "check_data" => array( "label" => "Whether to validate cookie data or not", "type" => "bool", "default" => UCB_RECOMMEND_CHECK_DATA ),
    16 //      "nonce_check" => array( "label" => "Whether to check nonce or not", "type" => "bool", "default" => UCB_RECOMMEND_NONCE_CHECK ),
    17 //      "calc_interval" => array( "label" => "Interval of calculate", "type" => "int", "default" => UCB_RECOMMEND_CALC_INTERVAL, "min" => MINUTE_IN_SECONDS ),
    18 //      "calc_timeout" => array( "label" => "Timeout of calculate", "type" => "int", "default" => UCB_RECOMMEND_CALC_TIMEOUT, "min" => MINUTE_IN_SECONDS ),
    19 //      "calc_log" => array( "label" => "Whether to log calculate process", "type" => "bool", "default" => UCB_RECOMMEND_CALC_LOG ),
     12        //      "update_cookie_expire" => array( "label" => "Whether to update cookie expiration when accessed or not", "type" => "bool", "default" => UCB_RECOMMEND_UPDATE_COOKIE_EXPIRE ),
     13        //      "user_expire" => array( "label" => "Expiration of user's cookie", "type" => "int", "default" => UCB_RECOMMEND_USER_EXPIRE, "min" => 0 ),
     14        //      "sampling_rate" => array( "label" => "Sampling rate", "type" => "float", "default" => UCB_RECOMMEND_SAMPLING_RATE, "min" => 0, "max" => 1, "option" => "sampling_rate", "option_default" => UCB_RECOMMEND_DEFAULT_SAMPLING_RATE ),
     15        //      "check_data" => array( "label" => "Whether to validate cookie data or not", "type" => "bool", "default" => UCB_RECOMMEND_CHECK_DATA ),
     16        //      "nonce_check" => array( "label" => "Whether to check nonce or not", "type" => "bool", "default" => UCB_RECOMMEND_NONCE_CHECK ),
     17        //      "calc_interval" => array( "label" => "Interval of calculate", "type" => "int", "default" => UCB_RECOMMEND_CALC_INTERVAL, "min" => MINUTE_IN_SECONDS ),
     18        //      "calc_timeout" => array( "label" => "Timeout of calculate", "type" => "int", "default" => UCB_RECOMMEND_CALC_TIMEOUT, "min" => MINUTE_IN_SECONDS ),
     19        //      "calc_log" => array( "label" => "Whether to log calculate process", "type" => "bool", "default" => UCB_RECOMMEND_CALC_LOG ),
    2020        "clear_interval" => array( "label" => "Interval of clear test data", "type" => "int", "default" => UCB_RECOMMEND_CLEAR_INTERVAL, "min" => MINUTE_IN_SECONDS ),
    21 //      "clear_timeout" => array( "label" => "Timeout of clear test data", "type" => "int", "default" => UCB_RECOMMEND_CLEAR_TIMEOUT, "min" => MINUTE_IN_SECONDS ),
     21        //      "clear_timeout" => array( "label" => "Timeout of clear test data", "type" => "int", "default" => UCB_RECOMMEND_CLEAR_TIMEOUT, "min" => MINUTE_IN_SECONDS ),
    2222        "clear_log" => array( "label" => "Whether to log clear test data process", "type" => "bool", "default" => UCB_RECOMMEND_CLEAR_LOG ),
    2323        "data_expire" => array( "label" => "Expiration of test data", "type" => "int", "default" => UCB_RECOMMEND_DATA_EXPIRE, "min" => MINUTE_IN_SECONDS ),
     
    2525        "minify_js" => array( "label" => "Whether to minify js that generated by this plugin", "type" => "bool", "default" => UCB_RECOMMEND_MINIFY_JS ),
    2626        "minify_css" => array( "label" => "Whether to minify css that generated by this plugin", "type" => "bool", "default" => UCB_RECOMMEND_MINIFY_CSS ),
    27 //      "jaccard_threshold" => array( "label" => "Threshold of jaccard to get results, which is used when argument is not supplied to function", "type" => "float", "default" => UCB_RECOMMEND_JACCARD_THRESHOLD, "min" => 0, "max" => 1 ),
    28 //      "jaccard_min_number" => array( "label" => "Min data number to be required to get results, which is used when argument is not supplied to function", "type" => "int", "default" => UCB_RECOMMEND_JACCARD_MIN_NUMBER, "min" => 0 ),
    29 //      "calculate_number" => array( "label" => "Max number of calculations of per", "type" => "int", "default" => UCB_RECOMMEND_CALCULATE_NUMBER, "min" => 10 ),
    30 //      "show_result" => array( "label" => "Whether to set button to show result", "type" => "bool", "default" => UCB_RECOMMEND_SHOW_RESULT ),
    31         //"check_update" => array( "label" => "Whether to check update", "type" => "bool", "default" => UCB_RECOMMEND_CHECK_UPDATE ),
     27        //      "jaccard_threshold" => array( "label" => "Threshold of jaccard to get results, which is used when argument is not supplied to function", "type" => "float", "default" => UCB_RECOMMEND_JACCARD_THRESHOLD, "min" => 0, "max" => 1 ),
     28        //      "jaccard_min_number" => array( "label" => "Min data number to be required to get results, which is used when argument is not supplied to function", "type" => "int", "default" => UCB_RECOMMEND_JACCARD_MIN_NUMBER, "min" => 0 ),
     29        //      "calculate_number" => array( "label" => "Max number of calculations of per", "type" => "int", "default" => UCB_RECOMMEND_CALCULATE_NUMBER, "min" => 10 ),
     30        //      "show_result" => array( "label" => "Whether to set button to show result", "type" => "bool", "default" => UCB_RECOMMEND_SHOW_RESULT ),
    3231        "ucb_const" => array( "label" => "Constant of UCB Algorithm", "type" => "int", "default" => UCB_RECOMMEND_UCB_CONST, "min" => 0 ),
     32        "std_dev" => array( "label" => "Standard Deviation to use calculate score from ucb score", "type" => "float", "default" => UCB_RECOMMEND_BANDIT_RANDOM_STD_DEV, "min" => 0 ),
    3333        "front_admin_ajax" => array( "label" => "Whether to use admin-ajax.php on front page", "type" => "bool", "default" => UCB_RECOMMEND_FRONT_ADMIN_AJAX ),
    3434        "check_referer" => array( "label" => "Whether to check referer when ajax access without nonce check", "type" => "bool", "default" => UCB_RECOMMEND_CHECK_REFERER ),
     35        "test" => array( "label" => "Whether to show test button", "type" => "bool", "default" => UCB_RECOMMEND_TEST ),
     36        "consider_page_cache" => array( "label" => "Whether to consider page cache", "type" => "bool", "default" => UCB_RECOMMEND_CONSIDER_PAGE_CACHE ),
     37        "check_update" => array( "label" => "Whether to check develop update", "type" => "bool", "default" => UCB_RECOMMEND_CHECK_UPDATE ),
    3538    );
    3639
     
    265268        return hash_hmac( $this->get_algo(), $data, $this->get_server_key() );
    266269    }
     270
     271    protected function consider_page_cache()
     272    {
     273        return $this->apply_filters( 'consider_page_cache', COLLABORATIVE_FILTERING_CONSIDER_PAGE_CACHE );
     274    }
     275
     276    protected static function generate_norm( $average = 0.0, $std_dev = 1.0 )
     277    {
     278        static $z1, $z2, $mt_max, $ready = true;
     279        if ( $mt_max === null ) {
     280            $mt_max = mt_getrandmax();
     281        }
     282        $ready = !$ready;
     283        if ( $ready ) {
     284            return $z2 * $std_dev + $average;
     285        }
     286        $u1 = mt_rand( 1, $mt_max - 1 ) / $mt_max;
     287        $u2 = mt_rand( 1, $mt_max - 1 ) / $mt_max;
     288        $v1 = sqrt( -2 * log( $u1 ) );
     289        $v2 = 2 * M_PI * $u2;
     290        $z1 = $v1 * cos( $v2 );
     291        $z2 = $v1 * sin( $v2 );
     292        return $z1 * $std_dev + $average;
     293    }
    267294}
  • ucb-recommend/trunk/lib/common/090-api-base.php

    r1504161 r1506564  
    229229    private function get_output_js_nonce()
    230230    {
     231        if ( $this->consider_page_cache() ) {
     232            return $this->get_output_js_nonce2();
     233        }
     234
     235        $nonce = wp_create_nonce( $this->get_api_name() );
     236        $ret = <<< EOS
     237<script>
     238    var ucbr_obj = ucbr_obj || {};
     239    ucbr_obj.{$this->nonce_key()} = '{$nonce}';
     240    ucbr_obj.{$this->get_api_name()} = function( data, done, fail, always ){
     241EOS;
     242
     243        if ( $this->is_form_data() ) {
     244            $ret .= <<< EOS
     245        var d = data;
     246        d.append('action', '{$this->get_api_full_name()}');
     247        d.append('{$this->nonce_key()}', ucbr_obj.{$this->nonce_key()});
     248EOS;
     249        } else {
     250            $ret .= <<< EOS
     251        var d = data || {};
     252        d.action = '{$this->get_api_full_name()}';
     253        d.{$this->nonce_key()} = ucbr_obj.{$this->nonce_key()};
     254EOS;
     255        }
     256        $ret .= <<< EOS
     257
     258        return jQuery.ajax({
     259            type: '{$this->get_method()}',
     260            url: ucbr_obj.ajaxurl,
     261            data: d
     262EOS;
     263        if ( null !== $this->data_type() ) {
     264            if ( !in_array( $this->data_type(), array( "true", "false" ) ) ) {
     265                $ret .= ",\n            contentType: '{$this->data_type()}'";
     266            } else {
     267                $ret .= ",\n            contentType: {$this->data_type()}";
     268            }
     269        }
     270        if ( null !== $this->content_type() ) {
     271            if ( !in_array( $this->content_type(), array( "true", "false" ) ) ) {
     272                $ret .= ",\n            contentType: '{$this->content_type()}'";
     273            } else {
     274                $ret .= ",\n            contentType: {$this->content_type()}";
     275            }
     276        }
     277        if ( null !== $this->process_data() ) {
     278            if ( !in_array( $this->process_data(), array( "true", "false" ) ) ) {
     279                $ret .= ",\n            processData: '{$this->process_data()}'";
     280            } else {
     281                $ret .= ",\n            processData: {$this->process_data()}";
     282            }
     283        }
     284        $ret .= <<< EOS
     285
     286        }).done( function( res ){
     287            if( done ) done( res );
     288        }).fail( function( xhr, status, error ){
     289            if( fail ) fail( error );
     290        }).always( function( ){
     291            if( always ) always( );
     292        });
     293    };
     294</script>
     295EOS;
     296
     297        return $ret;
     298    }
     299
     300    private function get_output_js_nonce2()
     301    {
    231302        $ret = <<< EOS
    232303<script>
    233304    var ucbr_obj = ucbr_obj || {};
    234305    ucbr_obj.{$this->get_api_name()} = function( data, done, fail, always ){
    235         if (ucbr_obj.{$this->get_api_name()}_nonce) {
     306        if (ucbr_obj.{$this->nonce_key()}) {
    236307
    237308EOS;
  • ucb-recommend/trunk/lib/common/110-api-loader.php

    r1503468 r1506564  
    4040            $this->use_functions = array();
    4141        }
     42        $name = str_replace( "-", "_", $name );
    4243        if ( !in_array( $name, $this->use_functions ) ) {
    43             $this->use_functions[] = str_replace( "-", "_", $name );
     44            $this->use_functions[] = $name;
    4445        }
    4546    }
  • ucb-recommend/trunk/lib/common/120-controller-loader.php

    r1499492 r1506564  
    190190        if ( count( $this->errors ) > 0 ) {
    191191            ?>
    192             <div class="error">
     192            <div class="error ucbr-admin-message">
    193193                <ul>
    194194                    <?php foreach ( $this->errors as $m ): ?>
     
    201201        if ( count( $this->messages ) > 0 ) {
    202202            ?>
    203             <div class="updated">
     203            <div class="updated ucbr-admin-message">
    204204                <ul>
    205205                    <?php foreach ( $this->messages as $m ): ?>
  • ucb-recommend/trunk/lib/load.php

    r1499492 r1506564  
    55    exit;
    66
    7 define( 'UCB_RECOMMEND_ROOT_DIR', WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . UCB_RECOMMEND_PLUGIN_DIR_NAME );
     7define( 'UCB_RECOMMEND_ROOT_DIR', UCB_RECOMMEND_PLUGIN_DIR );
    88define( 'UCB_RECOMMEND_LIB_ROOT_DIR', UCB_RECOMMEND_ROOT_DIR . DIRECTORY_SEPARATOR . "lib" );
    99define( 'UCB_RECOMMEND_COMMON_DIR', UCB_RECOMMEND_ROOT_DIR . DIRECTORY_SEPARATOR . "common" );
  • ucb-recommend/trunk/lib/services/option-service.php

    r1499492 r1506564  
    6161    public function set( $key, $value, $save = true )
    6262    {
     63        $prev = isset( $this->data[$key] ) ? $this->data[$key] : null;
    6364        $this->data[$key] = $value;
     65        if ( $prev !== $value ) {
     66            $this->do_action( 'changed_option', $key, $value, $prev );
     67        }
    6468        if ( $save )
    6569            return $this->save();
  • ucb-recommend/trunk/lib/services/system-service.php

    r1499492 r1506564  
    2525    private function initialize()
    2626    {
    27         load_plugin_textdomain( UCB_RECOMMEND_TEXT_DOMAIN, false, preg_replace( '#^' . str_replace( '\\', '\\\\', WP_PLUGIN_DIR . DIRECTORY_SEPARATOR ) . '#', '', UCB_RECOMMEND_LANGUAGES_DIR ) );
     27//      load_plugin_textdomain( UCB_RECOMMEND_TEXT_DOMAIN, false, preg_replace( '#^' . str_replace( '\\', '\\\\', WP_PLUGIN_DIR . DIRECTORY_SEPARATOR ) . '#', '', UCB_RECOMMEND_LANGUAGES_DIR ) );
    2828
    29 //      if ( $this->apply_filters( "check_update", UCB_RECOMMEND_CHECK_UPDATE ) ) {
    30 //          if ( !class_exists( '\PucFactory' ) ) {
    31 //              require_once UCB_RECOMMEND_LIB_LIBRARY_DIR . DIRECTORY_SEPARATOR . 'plugin-update-checker' . DIRECTORY_SEPARATOR . 'plugin-update-checker.php';
    32 //          }
    33 //          \PucFactory::buildUpdateChecker(
    34 //              UCB_RECOMMEND_UPDATE_INFO_FILE_URL,
    35 //              UCB_RECOMMEND_PLUGIN_FILE_NAME,
    36 //              UCB_RECOMMEND_PLUGIN_DIR_NAME
    37 //          );
    38 //      }
     29        if ( $this->apply_filters( "check_update", UCB_RECOMMEND_CHECK_UPDATE ) ) {
     30            if ( !class_exists( '\PucFactory' ) ) {
     31                require_once UCB_RECOMMEND_LIB_LIBRARY_DIR . DIRECTORY_SEPARATOR . 'plugin-update-checker' . DIRECTORY_SEPARATOR . 'plugin-update-checker.php';
     32            }
     33            \PucFactory::buildUpdateChecker(
     34                UCB_RECOMMEND_UPDATE_INFO_FILE_URL,
     35                UCB_RECOMMEND_PLUGIN_FILE_NAME,
     36                UCB_RECOMMEND_PLUGIN_DIR_NAME
     37            );
     38        }
    3939
    4040        add_action( 'init', function () {
  • ucb-recommend/trunk/lib/views/modal-script.php

    r1499492 r1506564  
    3939                }
    4040            };
    41             setTimeout(function(){
     41            setTimeout(function () {
    4242                check_resize();
    4343            }, 100);
     
    7070            $('<div id="ucbr-modal"><div class="ucbr-loading"></div>' + '<div class="ucbr-loading-message"></div>' + '</div>' + '<div id="ucbr-modal-message-warp">' + '<div id="ucbr-modal-message"></div>' + '</div>').prependTo("#container").hide();
    7171            <?php endif;?>
     72            $('#ucbr-modal-message').click(function () {
     73                return false;
     74            });
    7275        });
    7376    })(jQuery);
  • ucb-recommend/trunk/readme.txt

    r1504161 r1506564  
    44Requires at least: 3.9.14
    55Tested up to: 4.6.1
    6 Stable tag: 1.0.7
     6Stable tag: 1.1.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3535== Changelog ==
    3636
     37= 1.1.0 =
     38* 2016-10-02  Performance
     39
     40= 1.0.9 =
     41* 2016-10-02  Small bug fix
     42
     43= 1.0.8 =
     44* 2016-10-02
     45* Add test
     46* Show message if PHP version < 5.4
     47* Add mode not to consider cache page
     48* Add changed option filter
     49* Add mode to check develop update
     50* Change algorithm to decide widget post
     51* Small bug fix
     52
    3753= 1.0.7 =
    3854* 2016-09-28  SERVER_NAME => HTTP_HOST
    3955
    4056= 1.0.6 =
    41 * 2016-09-28  changed default front_admin_ajax setting
     57* 2016-09-28  Change default front_admin_ajax setting
    4258
    4359= 1.0.5 =
    44 * 2016-09-28  add filter to decide whether to check ajax referer
     60* 2016-09-28  Add filter to decide whether to check ajax referer
    4561
    4662= 1.0.4 =
    4763* 2016-09-27
    48 * ajax access without using admin-ajax.php
     64* Ajax access without using admin-ajax.php
    4965* PHP7
    50 * small bug fix
     66* Small bug fix
    5167
    5268= 1.0.3 =
    53 * 2016-09-26  small bug fix
     69* 2016-09-26  Small bug fix
    5470
    5571= 1.0.2 =
    5672* 2016-09-26
    57 * add ucb constant setting
    58 * small bug fix
     73* Add ucb constant setting
     74* Small bug fix
    5975
    6076= 1.0.1 =
    61 * 2016-09-22  small bug fix
     77* 2016-09-22  Small bug fix
    6278
    6379= 1.0.0 =
    64 * 2016-09-21  registered wordpress plugin directory
     80* 2016-09-21  Registered wordpress plugin directory
    6581
    6682= 0.2.9 =
    67 * 2016-09-21  small bug fix
     83* 2016-09-21  Small bug fix
    6884
    6985= 0.2.8 =
    70 * 2016-09-21  small bug fix
     86* 2016-09-21  Small bug fix
    7187
    7288= 0.2.7 =
    73 * 2016-09-21  changed logo
     89* 2016-09-21  Changed logo
    7490
    7591= 0.2.6 =
    76 * 2016-09-21  changed custom post type name
     92* 2016-09-21  Changed custom post type name
    7793
    7894= 0.2.5 =
    79 * 2016-09-21  bug fix
     95* 2016-09-21  Bug fix
    8096
    8197= 0.2.4 =
    82 * 2016-09-20  bug fix
     98* 2016-09-20  Bug fix
    8399
    84100= 0.2.3 =
    85 * 2016-09-20  small design changes
     101* 2016-09-20  Small design changes
    86102
    87103= 0.2.2 =
    88 * 2016-09-20  do shortcode of widget text
     104* 2016-09-20  Do shortcode of widget text
    89105
    90106= 0.2.1 =
    91 * 2016-09-20  small bug fix
     107* 2016-09-20  Small bug fix
    92108
    93109= 0.2.0 =
    94110* 2016-09-20
    95 * modified design preview behavior
    96 * small bug fix
     111* Modified design preview behavior
     112* Small bug fix
    97113
    98114= 0.1.9 =
    99 * 2016-09-20  small bug fix
     115* 2016-09-20  Small bug fix
    100116
    101117= 0.1.8 =
    102 * 2016-09-20  small bug fix
     118* 2016-09-20  Small bug fix
    103119
    104120= 0.1.7 =
    105121* 2016-09-20
    106 * support multiple redirect urls
    107 * small bug fix
     122* Support multiple redirect urls
     123* Small bug fix
    108124
    109125= 0.1.6 =
    110 * 2016-09-20  small bug fix
     126* 2016-09-20  Small bug fix
    111127
    112128= 0.1.5 =
    113129* 2016-09-20
    114 * changed post type condition set
    115 * add redirect url condition set
    116 * add filter to custom post type settings
     130* Changed post type condition set
     131* Add redirect url condition set
     132* Add filter to custom post type settings
    117133
    118134= 0.1.4 =
    119135* 2016-09-20
    120 * add custom post type for redirect
    121 * add new redirect behavior
    122 * small bug fix
     136* Add custom post type for redirect
     137* Add new redirect behavior
     138* Small bug fix
    123139
    124140= 0.1.3 =
    125 * 2016-09-19  modified design setting behavior
     141* 2016-09-19  Modified design setting behavior
    126142
    127143= 0.1.2 =
    128144* 2016-09-19
    129 * add design preview
    130 * small bug fix
     145* Add design preview
     146* Small bug fix
    131147
    132148= 0.1.1 =
    133149* 2016-09-18
    134 * support no context mode
    135 * small bug fix
     150* Support no context mode
     151* Small bug fix
    136152
    137153= 0.1.0 =
    138 * 2016-09-17  small bug fix
     154* 2016-09-17  Small bug fix
    139155
    140156= 0.0.9 =
    141 * 2016-09-17  small change to admin page’s design
     157* 2016-09-17  Small change to admin page’s design
    142158
    143159= 0.0.8 =
    144160* 2016-09-17
    145 * small bug fix
    146 * small change to admin menu
     161* Small bug fix
     162* Small change to admin menu
    147163
    148164= 0.0.7 =
    149 * 2016-09-17  small bug fix
     165* 2016-09-17  Small bug fix
    150166
    151167= 0.0.6 =
    152 * 2016-09-17  small bug fix
     168* 2016-09-17  Small bug fix
    153169
    154170= 0.0.5 =
    155 * 2016-09-17  preview bug fix
     171* 2016-09-17  Preview bug fix
    156172
    157173= 0.0.4 =
    158 * 2016-09-17  translation
     174* 2016-09-17  Translation
    159175
    160176= 0.0.3 =
  • ucb-recommend/trunk/services/ajax.php

    r1503468 r1506564  
    3030
    3131        $exploded = explode( '?', home_url( $_SERVER["REQUEST_URI"] ) );
    32         if ( $exploded[0] !== $this->get_ajax_url() ) {
     32        if ( $exploded[0] !== $this->get_ajax_url( false ) ) {
    3333            return;
    3434        }
     
    6060    }
    6161
    62     public function get_ajax_url()
     62    public function get_ajax_url( $admin_ajax = null )
    6363    {
    64         if ( $this->apply_filters( 'front_admin_ajax', UCB_RECOMMEND_FRONT_ADMIN_AJAX ) ) {
    65             return admin_url( 'admin-ajax.php' );
     64        if ( is_null( $admin_ajax ) ) {
     65            if ( $this->apply_filters( 'front_admin_ajax', UCB_RECOMMEND_FRONT_ADMIN_AJAX ) ) {
     66                return admin_url( 'admin-ajax.php', is_ssl() ? 'https' : 'http' );
     67            }
     68            return $this->apply_filters( 'ajax_url', UCB_RECOMMEND_PLUGIN_URL . '/' . UCB_RECOMMEND_AJAX_FILE );
     69        }
     70
     71        if ( $admin_ajax ) {
     72            return admin_url( 'admin-ajax.php', is_ssl() ? 'https' : 'http' );
    6673        }
    6774        return $this->apply_filters( 'ajax_url', UCB_RECOMMEND_PLUGIN_URL . '/' . UCB_RECOMMEND_AJAX_FILE );
  • ucb-recommend/trunk/services/calculate.php

    r1502274 r1506564  
    8787            }
    8888            return array_slice( array_map( function ( $p ) {
    89                 return array( 'post_id' => $p, 'bandit' => PHP_INT_MAX, 'n' => 0, 'c' => 0 );
     89                return array( 'post_id' => $p, 'bandit' => PHP_INT_MAX, 'score' => PHP_INT_MAX, 'n' => 0, 'c' => 0 );
    9090            }, $posts ), 0, $number );
    9191        }
     
    103103            );
    104104            $posts = array_map( function ( $p ) {
    105                 return array( 'post_id' => $p, 'bandit' => PHP_INT_MAX, 'n' => 0, 'c' => 0 );
     105                return array( 'post_id' => $p, 'bandit' => PHP_INT_MAX, 'score' => PHP_INT_MAX, 'n' => 0, 'c' => 0 );
    106106            }, $posts );
    107107
     
    113113
    114114            $posts = array_map( function ( $p ) {
    115                 return array( 'post_id' => $p, 'bandit' => PHP_INT_MAX, 'n' => 0, 'c' => 0 );
     115                return array( 'post_id' => $p, 'bandit' => PHP_INT_MAX, 'score' => PHP_INT_MAX, 'n' => 0, 'c' => 0 );
    116116            }, $not_exists );
    117117        }
     
    133133            if ( $const <= 0 ) {
    134134                $bandit = 1.0 * $c_i / $n_i;
     135                $score = $this->get_score( $bandit );
    135136            } elseif ( $n_i <= 0 ) {
    136137                $bandit = PHP_INT_MAX;
     138                $score = PHP_INT_MAX;
    137139            } else {
    138140                $bandit = 1.0 * $c_i / $n_i + $const * sqrt( $log / $n_i );
     141                $score = $this->get_score( $bandit );
    139142            }
    140             return array( 'post_id' => $post_id, 'bandit' => $bandit, 'n' => $n_i, 'c' => $c_i );
     143            return array( 'post_id' => $post_id, 'bandit' => $bandit, 'score' => $score, 'n' => $n_i, 'c' => $c_i );
    141144        }, $rows );
    142145
    143146        $rows = array_merge( $posts, $rows );
    144147        usort( $rows, function ( $a, $b ) {
    145             if ( $a['bandit'] == $b['bandit'] ) {
     148            if ( $a['score'] == $b['score'] ) {
    146149                return 0;
    147150            }
    148             return ( $a['bandit'] > $b['bandit'] ) ? -1 : 1;
     151            return ( $a['score'] > $b['score'] ) ? -1 : 1;
    149152        } );
     153
    150154        return array_slice( $rows, 0, $number );
     155    }
     156
     157    private function get_score( $bandit )
     158    {
     159        if ( $bandit >= PHP_INT_MAX ) {
     160            return $bandit;
     161        }
     162        //return mt_rand() / ( 1.0 + mt_getrandmax() ) * $bandit;
     163        return self::generate_norm( $bandit, $this->apply_filters( 'std_dev', UCB_RECOMMEND_BANDIT_RANDOM_STD_DEV ) );
    151164    }
    152165}
  • ucb-recommend/trunk/services/design.php

    r1499883 r1506564  
    282282    {
    283283        add_filter( 'the_content', array( $this, 'the_content' ) );
    284         add_filter( 'the_excerpt', array( $this, 'the_excerpt' ) );
     284        //  add_filter( 'get_the_excerpt', array( $this, 'get_the_excerpt' ) );
    285285        if ( $items_html ) {
    286286            if ( is_null( $list_template ) ) {
     
    301301            }
    302302            if ( false !== strpos( $html, '{$post->post_excerpt}' ) ) {
    303                 $html = str_replace( '{$post->post_excerpt}', apply_filters( 'the_excerpt', get_the_excerpt( $post_id ) ), $html );
     303                $html = str_replace( '{$post->post_excerpt}', $this->get_the_excerpt( $post ), $html );
    304304            }
    305305            foreach ( $post as $key => $value ) {
     
    320320        }
    321321        remove_filter( 'the_content', array( $this, 'the_content' ) );
    322         remove_filter( 'the_excerpt', array( $this, 'the_excerpt' ) );
     322        //  remove_filter( 'get_the_excerpt', array( $this, 'get_the_excerpt' ) );
    323323        return $html;
    324324    }
     
    327327    {
    328328        add_filter( 'the_content', array( $this, 'the_content' ) );
    329         add_filter( 'the_excerpt', array( $this, 'the_excerpt' ) );
     329        //add_filter( 'get_the_excerpt', array( $this, 'get_the_excerpt' ) );
    330330        $content_autop = has_filter( 'the_content', 'wpautop' );
    331         $excerpt_autop = has_filter( 'the_excerpt', 'wpautop' );
    332331        if ( false !== $content_autop ) {
    333332            remove_filter( 'the_content', 'wpautop', $content_autop );
    334         }
    335         if ( false !== $excerpt_autop ) {
    336             remove_filter( 'the_excerpt', 'wpautop', $excerpt_autop );
    337333        }
    338334        if ( is_null( $item_template ) ) {
     
    359355            }
    360356            $GLOBALS['post'] = $item_post;
     357            setup_postdata( $item_post );
    361358
    362359            $bandit = $d['bandit'];
     
    370367            }
    371368            if ( false !== strpos( $item_html, '{$post->post_excerpt}' ) ) {
    372                 $item_html = str_replace( '{$post->post_excerpt}', apply_filters( 'the_excerpt', get_the_excerpt( $item_post ) ), $item_html );
     369                $item_html = str_replace( '{$post->post_excerpt}', $this->get_the_excerpt( $item_post ), $item_html );
    373370            }
    374371            foreach ( $item_post as $key => $value ) {
     
    435432        }
    436433        remove_filter( 'the_content', array( $this, 'the_content' ) );
    437         remove_filter( 'the_excerpt', array( $this, 'the_excerpt' ) );
     434        //remove_filter( 'get_the_excerpt', array( $this, 'get_the_excerpt' ) );
    438435        if ( false !== $content_autop ) {
    439436            add_filter( 'the_content', 'wpautop', $content_autop );
    440437        }
    441         if ( false !== $excerpt_autop ) {
    442             add_filter( 'the_excerpt', 'wpautop', $excerpt_autop );
    443         }
    444438        if ( is_null( $tmp_post ) ) {
    445439            unset( $GLOBALS['post'] );
     440            setup_postdata( null );
    446441        } else {
    447442            $GLOBALS['post'] = $tmp_post;
     443            setup_postdata( $tmp_post );
    448444        }
    449445        return $items_html;
     
    467463    }
    468464
    469     public function the_excerpt( $excerpt )
    470     {
    471         $excerpt = strip_tags( $excerpt );
    472         $excerpt = strip_shortcodes( $excerpt );
    473         /*  $excerpt = preg_replace('#<\s*br(\s+.+)?>#', ' ', $excerpt);*/
    474         if ( "" === $excerpt ) {
    475             return " ";
    476         }
    477         //return nl2br( $excerpt );
    478         return $excerpt;
     465    //  public function get_the_excerpt( $excerpt )
     466    //  {
     467    ////        $excerpt = strip_tags( $excerpt );
     468    ////        $excerpt = strip_shortcodes( $excerpt );
     469    //      if ( "" === $excerpt ) {
     470    //          return " ";
     471    //      }
     472    //      //return nl2br( $excerpt );
     473    //      return $excerpt;
     474    //  }
     475
     476    private function get_the_excerpt( $post )
     477    {
     478        if ( '' !== $post->post_excerpt ) {
     479            return $post->post_excerpt;
     480        }
     481        if ( '' === $post->post_content ) {
     482            return '';
     483        }
     484        $text = strip_shortcodes( $post->post_content );
     485    //  $text = apply_filters( 'the_content', $text );
     486        $text = str_replace(']]>', ']]&gt;', $text);
     487        $excerpt_length = apply_filters( 'excerpt_length', 55 );
     488        $excerpt_more = apply_filters( 'excerpt_more', ' ' . '[&hellip;]' );
     489        $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
     490        return $text;
    479491    }
    480492
  • ucb-recommend/trunk/services/update.php

    r1504145 r1506564  
    3737            if ( version_compare( $version, '1.0.6', '<' ) ) {
    3838                $this->version_1_0_6();
     39            }
     40            if ( version_compare( $version, '1.0.8', '<' ) ) {
     41                $this->version_1_0_8();
    3942            }
    4043        } );
     
    9093        }
    9194    }
     95
     96    private function version_1_0_8()
     97    {
     98        global $ucbr_option;
     99        $name = $this->get_filter_prefix() . 'check_update';
     100        $ucbr_option->set( $name, 'false' );
     101    }
    92102}
    93103
  • ucb-recommend/trunk/settings.php

    r1504145 r1506564  
    22if ( !defined( 'UCB_RECOMMEND_PLUGIN' ) )
    33    exit;
    4 
    5 define( 'UCB_RECOMMEND_PLUGIN_NAME', 'UCB Recommend' );
    6 
    7 define( 'UCB_RECOMMEND_TEXT_DOMAIN', 'UCBRecommend' );
    84
    95define( 'UCB_RECOMMEND_OUTPUT_LOG', true );
     
    3026define( 'UCB_RECOMMEND_CLEAR_LOG', false );
    3127define( 'UCB_RECOMMEND_DISPLAY_LOG_NUMBER', 100 );
    32 define( 'UCB_RECOMMEND_CHECK_UPDATE', true );
    3328define( 'UCB_RECOMMEND_MINIFY_JS', true );
    3429define( 'UCB_RECOMMEND_MINIFY_CSS', true );
     
    5247define( 'UCB_RECOMMEND_FRONT_ADMIN_AJAX', false );
    5348define( 'UCB_RECOMMEND_CHECK_REFERER', true );
     49define( 'UCB_RECOMMEND_BANDIT_RANDOM_STD_DEV', 0.02 );
     50define( 'UCB_RECOMMEND_TEST', true );
     51define( 'UCB_RECOMMEND_CONSIDER_PAGE_CACHE', true );
     52
     53//from github
     54define( 'UCB_RECOMMEND_CHECK_UPDATE', false );
    5455
    5556//redirect url
  • ucb-recommend/trunk/ucb-recommend.php

    r1504161 r1506564  
    55  Description: Recommendation and AB test plugin using ucb algorithm
    66  Author: 123teru321
    7   Version: 1.0.7
     7  Version: 1.1.0
    88  Author URI: http://technote.space/
    99  Text Domain: UCBRecommend
     
    1717    return;
    1818
     19if ( defined( 'WP_INSTALLING' ) && WP_INSTALLING )
     20    return;
     21
    1922//plugin
    2023define( 'UCB_RECOMMEND_PLUGIN', 'UCB_RECOMMEND_PLUGIN' );
    2124
    22 if ( version_compare( phpversion(), '5.4', '<' ) ) {
    23     // php version isn't high enough
    24 
    25     return;
    26 }
     25//plugin name
     26define( 'UCB_RECOMMEND_PLUGIN_NAME', 'UCB Recommend' );
    2727
    2828//plugin version
    29 define( 'UCB_RECOMMEND_PLUGIN_VERSION', '1.0.7' );
     29define( 'UCB_RECOMMEND_PLUGIN_VERSION', '1.1.0' );
     30
     31//required php version
     32define( 'UCB_RECOMMEND_REQUIRED_PHP_VERSION', '5.4' );
    3033
    3134//plugin file name
    3235define( 'UCB_RECOMMEND_PLUGIN_FILE_NAME', __FILE__ );
    3336
     37//plugin directory
     38define( 'UCB_RECOMMEND_PLUGIN_DIR', dirname( UCB_RECOMMEND_PLUGIN_FILE_NAME ) );
     39
    3440//plugin directory name
    35 define( 'UCB_RECOMMEND_PLUGIN_DIR_NAME', basename( __DIR__ ) );
     41define( 'UCB_RECOMMEND_PLUGIN_DIR_NAME', basename( UCB_RECOMMEND_PLUGIN_DIR ) );
    3642
    3743//plugin base name
    3844define( 'UCB_RECOMMEND_PLUGIN_BASE_NAME', plugin_basename( UCB_RECOMMEND_PLUGIN_FILE_NAME ) );
     45
     46//text domain
     47define( 'UCB_RECOMMEND_TEXT_DOMAIN', 'UCBRecommend' );
     48define( 'UCB_RECOMMEND_LANGUAGES_DIR', UCB_RECOMMEND_PLUGIN_DIR . DIRECTORY_SEPARATOR . "languages" );
     49load_plugin_textdomain( UCB_RECOMMEND_TEXT_DOMAIN, false, preg_replace( '#^' . str_replace( '\\', '\\\\', WP_PLUGIN_DIR . DIRECTORY_SEPARATOR ) . '#', '', UCB_RECOMMEND_LANGUAGES_DIR ) );
     50
     51if ( version_compare( phpversion(), UCB_RECOMMEND_REQUIRED_PHP_VERSION, '<' ) ) {
     52    // php version isn't high enough
     53    require_once 'unsupported.php';
     54    return;
     55}
    3956
    4057//load
  • ucb-recommend/trunk/update.json

    r1504161 r1506564  
    33  "slug": "ucb-recommend",
    44  "download_url": "https://github.com/123teru321/UCB-Recommend/archive/master.zip",
    5   "version": "1.0.7",
     5  "version": "1.1.0",
    66  "tested": "4.6.1",
    77  "homepage": "https://technote.space/",
  • ucb-recommend/trunk/views/style-template.php

    r1499492 r1506564  
    44?>
    55<style>
     6    /*
     7    Eric Meyer's CSS Reset
     8    http://meyerweb.com/eric/tools/css/reset/
     9    v1.0 | 20080212
     10    CSSresetr.com
     11    */
     12    html, body, div, span, applet, object, iframe,
     13    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
     14    a, abbr, acronym, address, big, cite, code,
     15    del, dfn, em, font, img, ins, kbd, q, s, samp,
     16    small, strike, strong, sub, sup, tt, var,
     17    b, u, i, center,
     18    dl, dt, dd, ol, ul, li,
     19    fieldset, form, label, legend,
     20    table, caption, tbody, tfoot, thead, tr, th, td {
     21        margin: 0;
     22        padding: 0;
     23        border: 0;
     24        outline: 0;
     25        font-size: 100%;
     26        vertical-align: baseline;
     27        background: transparent;
     28    }
     29
     30    body {
     31        line-height: 1;
     32    }
     33
     34    ol, ul {
     35        list-style: none;
     36    }
     37
     38    blockquote, q {
     39        quotes: none;
     40    }
     41
     42    blockquote:before, blockquote:after,
     43    q:before, q:after {
     44        content: '';
     45        content: none;
     46    }
     47
     48    /* remember to define focus styles! */
     49    :focus {
     50        outline: 0;
     51    }
     52
     53    /* remember to highlight inserts somehow! */
     54    ins {
     55        text-decoration: none;
     56    }
     57
     58    del {
     59        text-decoration: line-through;
     60    }
     61
     62    /* tables still need 'cellspacing=0' in the markup */
     63    table {
     64        border-collapse: collapse;
     65        border-spacing: 0;
     66    }
     67
     68    /*ucbr default*/
    669    .ucbr-loading-widget {
    770        text-align: center;
    871        height: 50px;
    972    }
     73
    1074    .ucbr-loading-widget img {
    1175        height: 100%;
     
    1680        font-size: 1.5em;
    1781    }
     82
    1883    .ucbr-hover-card {
    1984        cursor: pointer;
     
    2287        box-shadow: none;
    2388    }
     89
    2490    .ucbr-hover-card:hover {
    2591        background-color: #f7f7f7;
    2692    }
     93
    2794    .ucbr-related-entry {
    2895        border-bottom: 1px solid #F0F0F0;
     
    34101        clear: both;
    35102    }
     103
    36104    .ucbr-related-entry-thumb {
    37105        float: left;
     
    40108        padding-bottom: 5px;
    41109    }
     110
    42111    .ucbr-related-entry-thumb a {
    43112        display: block;
    44113    }
     114
    45115    .ucbr-related-entry-thumb img {
    46116        border: 0;
     
    49119        display: block;
    50120    }
     121
    51122    .ucbr-related-entry-content {
    52123        margin-left: 110px;
    53124    }
     125
    54126    .ucbr-related-entry-title {
    55127        margin-bottom: 5px;
    56128        clear: none;
    57129    }
     130
    58131    .ucbr-related-entry-title a {
    59132        text-decoration: none;
     
    62135        color: #333;
    63136    }
     137
    64138    .ucbr-related-entry-snippet {
    65139        margin: 0 0 5px 0;
     
    67141        word-wrap: break-word;
    68142    }
    69     .ucbr-related-entry-title{
     143
     144    .ucbr-related-entry-title {
    70145        margin-top: 0;
    71146    }
     
    78153        visibility: hidden;
    79154    }
     155
    80156    .clearfix {
    81157        display: inline-block;
    82158    }
     159
    83160    * html .clearfix {
    84161        height: 1%;
    85162    }
     163
    86164    .clearfix {
    87165        display: block;
  • ucb-recommend/trunk/views/widget-settings-script.php

    r1502274 r1506564  
    10291029                        html += '<th><?php _e( "Post name", UCB_RECOMMEND_TEXT_DOMAIN ); ?></th>';
    10301030                        html += '<th><?php _e( "Score", UCB_RECOMMEND_TEXT_DOMAIN ); ?></th>';
     1031                        html += '<th><?php _e( "Score", UCB_RECOMMEND_TEXT_DOMAIN ); ?>(rand)</th>';
    10311032                        html += '<th><?php _e( "Display number", UCB_RECOMMEND_TEXT_DOMAIN ); ?></th>';
    10321033                        html += '<th><?php _e( "Clicked number", UCB_RECOMMEND_TEXT_DOMAIN ); ?></th>';
     
    10401041                                html += '<td>' + data.result.list[key].post_title + '</td>';
    10411042                                html += '<td>' + data.result.list[key].bandit + '</td>';
     1043                                html += '<td>' + data.result.list[key].score + '</td>';
    10421044                                html += '<td>' + data.result.list[key].n + '</td>';
    10431045                                html += '<td>' + data.result.list[key].c + '</td>';
Note: See TracChangeset for help on using the changeset viewer.