Plugin Directory

Changeset 1416129


Ignore:
Timestamp:
05/13/2016 08:13:08 AM (10 years ago)
Author:
oxynotes
Message:

SBS_SocialCountCache 1.5.2 commit

Location:
step-by-step-social-count-cache/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • step-by-step-social-count-cache/trunk/readme.txt

    r1370117 r1416129  
    44Tags: cache, count, sns, social
    55Requires at least: 4.2.4
    6 Tested up to: 4.4.2
    7 Stable tag: 1.5.1
     6Tested up to: 4.5.2
     7Stable tag: 1.5.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    109109== Changelog ==
    110110
     1111.5.2
     112タグのカスタマイズ時に生成されるURLをエンティティ化。FacebookのAccess Tokenが誤っている場合、エラーメッセージを表示するように変更。
     113
    1111141.5
    112115count.jsoon APIを利用してTwitterのカウントを取得可能に変更。
  • step-by-step-social-count-cache/trunk/sbs-social-count-cache.php

    r1370117 r1416129  
    44Plugin URI: https://wordpress.org/plugins/step-by-step-social-count-cache/
    55Description: ソーシャルブックマークのカウントをキャッシュするプラグイン
    6 Version: 1.5.1
     6Version: 1.5.2
    77Author: oxynotes
    88Author URI: http://oxynotes.com
     
    986986     * @param   int     各SNSのカウント
    987987     * @return  str     ブランケットのタグを置き換えたボタンのタグ
     988
     989     * since    1.5.2   エスケープ対応(#等を含むと正常に動作しなかった)
    988990     */
    989991    function tag_rep( $arg, $count ) {
    990992        $url = get_permalink();
    991993        $site_title = get_bloginfo( 'name' );
    992         $title = get_the_title();
     994
     995        // html_entity_decode()を挟まないと"や'が文字参照で表示されてしまうので注意
     996        $title = urlencode( html_entity_decode( get_the_title(), ENT_COMPAT, 'UTF-8' ) );
    993997
    994998        $search = array( '[[url]]', '[[site_title]]', '[[title]]', '[[count]]' );
     
    9981002        return $rep_txt;
    9991003    }
    1000 
    10011004
    10021005
  • step-by-step-social-count-cache/trunk/views/options.php

    r1370114 r1416129  
    3030    settings_errors('app-token-empty'); // 引数でエラーのスラッグを指定するとエラーを限定できる
    3131
     32} else { // tokenが正しいかチェック
     33
     34    $url = site_url(); // テスト用に適当にURLを取得
     35    $graph_url = 'https://graph.facebook.com/v2.4/' . rawurlencode($url) . '?access_token=' . $this->sbs_facebook_app_token;
     36    $result = wp_remote_get( $graph_url, array( 'timeout' => 5 ) ); // たまに異常に重い時があるので注意
     37    $decoded_response = json_decode( $result["body"], true ); // jsonをデコード。trueで連想配列に変換
     38
     39    if( $decoded_response["error"]["type"] == "OAuthException" ) {
     40        // FacebookのApp Tokenが間違っている場合にエラーメッセージ
     41        add_settings_error(
     42            'app-token-invalid',
     43            'app-token-invalid',
     44            __('FacebookのApp Tokenが誤っています。値を確認してください。', 'sbs_social_count_cache'),
     45            'error'
     46        );
     47        settings_errors('app-token-invalid');
     48    }
    3249}
    3350
Note: See TracChangeset for help on using the changeset viewer.