Plugin Directory

Changeset 2679505


Ignore:
Timestamp:
02/15/2022 11:24:19 PM (4 years ago)
Author:
kanakogi
Message:

1.1.3

Location:
wp-theme-test
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-theme-test/tags/1.1.3/trunk/classes/class.core.php

    r1938975 r2679505  
    11<?php
    2 class WPTT_Core {
     2class WPTT_Core
     3{
    34    // プラグイン有効化時のデフォルトオプション
    45    private $wptt_default_options = array(
     
    1516     * @return [str] [description]
    1617     */
    17     function get_theme() {
    18         $options = get_option( WPTT_PLUGIN_NAME );
    19         if ( !empty( $options['theme'] ) ) {
     18    function get_theme()
     19    {
     20        $options = get_option(WPTT_PLUGIN_NAME);
     21        if (!empty($options['theme'])) {
    2022            return $options['theme'];
    2123        } else {
     
    2931     * @return string | bool
    3032     */
    31     function is_test_enabled() {
    32         $options = get_option( WPTT_PLUGIN_NAME );
    33         if ( $options['status'] ) {
     33    function is_test_enabled()
     34    {
     35        $options = get_option(WPTT_PLUGIN_NAME);
     36        if ($options['status']) {
    3437            return true;
    3538        }
     
    4245     * @return boolean [description]
    4346     */
    44     function has_capability() {
    45         $options = get_option( WPTT_PLUGIN_NAME );
    46         if(!empty($options)) if (!empty($options['capabilities']) ) {
    47             foreach ($options['capabilities'] as $key => $value) {
    48                 if( current_user_can($value) ){
    49                     return true;
     47    function has_capability()
     48    {
     49        $options = get_option(WPTT_PLUGIN_NAME);
     50        if (!empty($options)) {
     51            if (!empty($options['capabilities'])) {
     52                global $current_user;
     53                foreach ($options['capabilities'] as $key => $value) {
     54                    if (array_key_exists($value, $current_user->caps)) {
     55                        return true;
     56                    }
    5057                }
    5158            }
     
    5865     * 設定レベルを取得
    5966     */
    60     function get_level() {
    61         $options = get_option( WPTT_PLUGIN_NAME );
     67    function get_level()
     68    {
     69        $options = get_option(WPTT_PLUGIN_NAME);
    6270        $level = $options['level'];
    6371
    64         if ( $level != '' ) {
     72        if ($level != '') {
    6573            return 'level_' . $level;
    6674        } else {
     
    7280     * 現在のパラメーターを取得
    7381     */
    74     function get_parameter() {
    75         $options = get_option( WPTT_PLUGIN_NAME );
    76         if ( $options['parameter'] ) {
     82    function get_parameter()
     83    {
     84        $options = get_option(WPTT_PLUGIN_NAME);
     85        if ($options['parameter']) {
    7786            return true;
    7887        }
     
    8392     * IPアドレスを取得
    8493     */
    85     function get_ip_list() {
    86         $options = get_option( WPTT_PLUGIN_NAME );
    87         if ( $options['ip_list'] ) {
     94    function get_ip_list()
     95    {
     96        $options = get_option(WPTT_PLUGIN_NAME);
     97        if ($options['ip_list']) {
    8898            return $options['ip_list'];
    8999        }
     
    94104     * 翻訳用
    95105     */
    96     public function e( $text ) {
    97         _e( $text, WPTT_TEXT_DOMAIN );
     106    public function e($text)
     107    {
     108        _e($text, WPTT_TEXT_DOMAIN);
    98109    }
    99110
    100     public function _( $text ) {
    101         return __( $text, WPTT_TEXT_DOMAIN );
     111    public function _($text)
     112    {
     113        return __($text, WPTT_TEXT_DOMAIN);
    102114    }
    103115
     
    105117     * プラグインが有効化されたときに実行
    106118     */
    107     function activation_hook() {
    108         if ( !get_option( WPTT_PLUGIN_NAME ) ) {
    109             update_option( WPTT_PLUGIN_NAME, $this->wptt_default_options );
     119    function activation_hook()
     120    {
     121        if (!get_option(WPTT_PLUGIN_NAME)) {
     122            update_option(WPTT_PLUGIN_NAME, $this->wptt_default_options);
    110123        }
    111124    }
     
    114127     * 無効化ときに実行
    115128     */
    116     function deactivation_hook() {
    117         delete_option( WPTT_PLUGIN_NAME );
     129    function deactivation_hook()
     130    {
     131        delete_option(WPTT_PLUGIN_NAME);
    118132    }
    119133
     
    121135     * アンインストール時に実行
    122136     */
    123     function uninstall_hook() {
    124         delete_option( WPTT_PLUGIN_NAME );
     137    function uninstall_hook()
     138    {
     139        delete_option(WPTT_PLUGIN_NAME);
    125140    }
    126141}
  • wp-theme-test/tags/1.1.3/trunk/readme.txt

    r2316295 r2679505  
    44Tags: : page, pages,theme, themes
    55Requires at least: 3.0 or higher
    6 Tested up to: 5.4.1
     6Tested up to: 5.9.0
    77Stable tag: 1.1.3
    88License: GPLv2 or later
  • wp-theme-test/tags/1.1.3/trunk/wp-theme-test.php

    r2316295 r2679505  
    1010Domain Path: /languages/
    1111*/
    12 define('WPTT_VERSION', '1.1.3');
    13 define('WPTT_PLUGIN_BASENAME', plugin_basename(__FILE__));
    14 define('WPTT_PLUGIN_NAME', trim(dirname(WPTT_PLUGIN_BASENAME), '/'));
    15 define('WPTT_PLUGIN_DIR', untrailingslashit(dirname(__FILE__)));
    16 define('WPTT_PLUGIN_URL', untrailingslashit(plugins_url('', __FILE__)));
    17 define('WPTT_TEXT_DOMAIN', 'wptt');
     12define( 'WPTT_VERSION', '1.1.3' );
     13define( 'WPTT_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
     14define( 'WPTT_PLUGIN_NAME', trim( dirname( WPTT_PLUGIN_BASENAME ), '/' ) );
     15define( 'WPTT_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) );
     16define( 'WPTT_PLUGIN_URL', untrailingslashit( plugins_url( '', __FILE__ ) ) );
     17define( 'WPTT_TEXT_DOMAIN', 'wptt' );
    1818
    1919require_once WPTT_PLUGIN_DIR . '/classes/class.core.php';
    2020
    21 class WP_Theme_Test extends WPTT_Core
    22 {
     21class WP_Theme_Test extends WPTT_Core {
    2322
    2423    /**
    2524     * __construct
    2625     */
    27     public function __construct()
    28     {
     26    public function __construct() {
    2927        //他言語化
    30         load_plugin_textdomain(WPTT_TEXT_DOMAIN, false, basename(dirname(__FILE__)) . '/languages/');
     28        load_plugin_textdomain( WPTT_TEXT_DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages/' );
    3129        //actions
    32         add_action('init', array($this, 'load_files'));
     30        add_action( 'init', array( $this, 'load_files' ) );
    3331        //filters
    34         add_filter('template', array($this, 'template_filter'));
    35         add_filter('stylesheet', array($this, 'stylesheet_filter'));
     32        add_filter( 'template', array( $this, 'template_filter' ) );
     33        add_filter( 'stylesheet', array( $this, 'stylesheet_filter' ) );
    3634        // プラグインが有効・無効化されたとき
    37         // register_activation_hook(__FILE__, array($this, 'activation_hook'));
    38         // register_deactivation_hook(__FILE__, array($this, 'deactivation_hook'));
    39         // register_uninstall_hook(__FILE__, array($this, 'uninstall_hook'));
     35        register_activation_hook( __FILE__, array( $this, 'activation_hook' ) );
     36        register_deactivation_hook( __FILE__, array( $this, 'deactivation_hook' ) );
     37        register_uninstall_hook( __FILE__, array( $this, 'uninstall_hook' ) );
    4038    }
    4139
     
    4341     * load_files
    4442     */
    45     public function load_files()
    46     {
     43    public function load_files() {
    4744        // Classes
    4845        include_once WPTT_PLUGIN_DIR . '/classes/class.admin.php';
     
    5249     * apply_test_theme
    5350     */
    54     function apply_test_theme()
    55     {
     51    function apply_test_theme() {
    5652        //GETでも変えれるようにする
    57         if (isset($_GET['theme']) && $this->get_parameter()) {
    58             $theme_object = wp_get_theme(esc_html($_GET['theme']));
     53        if ( isset( $_GET['theme'] ) && $this->get_parameter() ) {
     54            $theme_object = wp_get_theme( esc_html( $_GET['theme'] ) );
    5955            return $theme_object;
    6056        }
    6157
    6258        //IPアドレスでも変えれるようにする
    63         if ($this->get_ip_list()) {
     59        if ( $this->get_ip_list() ) {
    6460            $ip_list = $this->get_ip_list();
    65             $ip_list = str_replace(array("\r\n", "\n", "\r"), "\n", $ip_list); //改行を\nに統一
    66             $ip_list = explode("\n", $ip_list);
    67             if (in_array($_SERVER['REMOTE_ADDR'], $ip_list)) {
    68                 return wp_get_theme($this->get_theme());
     61            $ip_list = str_replace(array("\r\n", "\n", "\r"),"\n",$ip_list); //改行を\nに統一
     62            $ip_list = explode( "\n", $ip_list );
     63            if( in_array($_SERVER['REMOTE_ADDR'], $ip_list) ){
     64              return wp_get_theme( $this->get_theme() );
    6965            }
    7066        }
    7167
    7268        // ログイン状態とレベルをチェック
    73         if ($this->has_capability() && $this->is_test_enabled()) {
     69        if ( $this->has_capability() && $this->is_test_enabled() ) {
    7470
    7571            // 現在の設定されているテーマを取得
    76             if (!$theme = $this->get_theme()) {
     72            if ( !$theme = $this->get_theme() ) {
    7773                return false;
    7874            }
    7975
    8076            // 設定されているテーマがあれば取得する
    81             $theme_object = wp_get_theme($theme);
    82             if (!empty($theme_object)) {
    83                 if (isset($theme_object->Status) && $theme_object->Status != 'publish') {
     77            $theme_object = wp_get_theme( $theme );
     78            if ( !empty( $theme_object ) ) {
     79                if ( isset( $theme_object->Status ) && $theme_object->Status != 'publish' ) {
    8480                    return false;
    8581                }
     
    9793     * テンプレートを設定
    9894     */
    99     function template_filter($template)
    100     {
     95    function template_filter( $template ) {
    10196        $theme = $this->apply_test_theme();
    102         if ($theme === false) {
     97        if ( $theme === false ) {
    10398            return $template;
    10499        }
     
    110105     * スタイルシートを設定
    111106     */
    112     function stylesheet_filter($stylesheet)
    113     {
     107    function stylesheet_filter( $stylesheet ) {
    114108        $theme = $this->apply_test_theme();
    115         if ($theme === false) {
     109        if ( $theme === false ) {
    116110            return $stylesheet;
    117111        }
  • wp-theme-test/trunk/classes/class.core.php

    r1938975 r2679505  
    11<?php
    2 class WPTT_Core {
     2class WPTT_Core
     3{
    34    // プラグイン有効化時のデフォルトオプション
    45    private $wptt_default_options = array(
     
    1516     * @return [str] [description]
    1617     */
    17     function get_theme() {
    18         $options = get_option( WPTT_PLUGIN_NAME );
    19         if ( !empty( $options['theme'] ) ) {
     18    function get_theme()
     19    {
     20        $options = get_option(WPTT_PLUGIN_NAME);
     21        if (!empty($options['theme'])) {
    2022            return $options['theme'];
    2123        } else {
     
    2931     * @return string | bool
    3032     */
    31     function is_test_enabled() {
    32         $options = get_option( WPTT_PLUGIN_NAME );
    33         if ( $options['status'] ) {
     33    function is_test_enabled()
     34    {
     35        $options = get_option(WPTT_PLUGIN_NAME);
     36        if ($options['status']) {
    3437            return true;
    3538        }
     
    4245     * @return boolean [description]
    4346     */
    44     function has_capability() {
    45         $options = get_option( WPTT_PLUGIN_NAME );
    46         if(!empty($options)) if (!empty($options['capabilities']) ) {
    47             foreach ($options['capabilities'] as $key => $value) {
    48                 if( current_user_can($value) ){
    49                     return true;
     47    function has_capability()
     48    {
     49        $options = get_option(WPTT_PLUGIN_NAME);
     50        if (!empty($options)) {
     51            if (!empty($options['capabilities'])) {
     52                global $current_user;
     53                foreach ($options['capabilities'] as $key => $value) {
     54                    if (array_key_exists($value, $current_user->caps)) {
     55                        return true;
     56                    }
    5057                }
    5158            }
     
    5865     * 設定レベルを取得
    5966     */
    60     function get_level() {
    61         $options = get_option( WPTT_PLUGIN_NAME );
     67    function get_level()
     68    {
     69        $options = get_option(WPTT_PLUGIN_NAME);
    6270        $level = $options['level'];
    6371
    64         if ( $level != '' ) {
     72        if ($level != '') {
    6573            return 'level_' . $level;
    6674        } else {
     
    7280     * 現在のパラメーターを取得
    7381     */
    74     function get_parameter() {
    75         $options = get_option( WPTT_PLUGIN_NAME );
    76         if ( $options['parameter'] ) {
     82    function get_parameter()
     83    {
     84        $options = get_option(WPTT_PLUGIN_NAME);
     85        if ($options['parameter']) {
    7786            return true;
    7887        }
     
    8392     * IPアドレスを取得
    8493     */
    85     function get_ip_list() {
    86         $options = get_option( WPTT_PLUGIN_NAME );
    87         if ( $options['ip_list'] ) {
     94    function get_ip_list()
     95    {
     96        $options = get_option(WPTT_PLUGIN_NAME);
     97        if ($options['ip_list']) {
    8898            return $options['ip_list'];
    8999        }
     
    94104     * 翻訳用
    95105     */
    96     public function e( $text ) {
    97         _e( $text, WPTT_TEXT_DOMAIN );
     106    public function e($text)
     107    {
     108        _e($text, WPTT_TEXT_DOMAIN);
    98109    }
    99110
    100     public function _( $text ) {
    101         return __( $text, WPTT_TEXT_DOMAIN );
     111    public function _($text)
     112    {
     113        return __($text, WPTT_TEXT_DOMAIN);
    102114    }
    103115
     
    105117     * プラグインが有効化されたときに実行
    106118     */
    107     function activation_hook() {
    108         if ( !get_option( WPTT_PLUGIN_NAME ) ) {
    109             update_option( WPTT_PLUGIN_NAME, $this->wptt_default_options );
     119    function activation_hook()
     120    {
     121        if (!get_option(WPTT_PLUGIN_NAME)) {
     122            update_option(WPTT_PLUGIN_NAME, $this->wptt_default_options);
    110123        }
    111124    }
     
    114127     * 無効化ときに実行
    115128     */
    116     function deactivation_hook() {
    117         delete_option( WPTT_PLUGIN_NAME );
     129    function deactivation_hook()
     130    {
     131        delete_option(WPTT_PLUGIN_NAME);
    118132    }
    119133
     
    121135     * アンインストール時に実行
    122136     */
    123     function uninstall_hook() {
    124         delete_option( WPTT_PLUGIN_NAME );
     137    function uninstall_hook()
     138    {
     139        delete_option(WPTT_PLUGIN_NAME);
    125140    }
    126141}
  • wp-theme-test/trunk/readme.txt

    r2316295 r2679505  
    44Tags: : page, pages,theme, themes
    55Requires at least: 3.0 or higher
    6 Tested up to: 5.4.1
     6Tested up to: 5.9.0
    77Stable tag: 1.1.3
    88License: GPLv2 or later
  • wp-theme-test/trunk/wp-theme-test.php

    r2316295 r2679505  
    1010Domain Path: /languages/
    1111*/
    12 define('WPTT_VERSION', '1.1.3');
    13 define('WPTT_PLUGIN_BASENAME', plugin_basename(__FILE__));
    14 define('WPTT_PLUGIN_NAME', trim(dirname(WPTT_PLUGIN_BASENAME), '/'));
    15 define('WPTT_PLUGIN_DIR', untrailingslashit(dirname(__FILE__)));
    16 define('WPTT_PLUGIN_URL', untrailingslashit(plugins_url('', __FILE__)));
    17 define('WPTT_TEXT_DOMAIN', 'wptt');
     12define( 'WPTT_VERSION', '1.1.3' );
     13define( 'WPTT_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
     14define( 'WPTT_PLUGIN_NAME', trim( dirname( WPTT_PLUGIN_BASENAME ), '/' ) );
     15define( 'WPTT_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) );
     16define( 'WPTT_PLUGIN_URL', untrailingslashit( plugins_url( '', __FILE__ ) ) );
     17define( 'WPTT_TEXT_DOMAIN', 'wptt' );
    1818
    1919require_once WPTT_PLUGIN_DIR . '/classes/class.core.php';
    2020
    21 class WP_Theme_Test extends WPTT_Core
    22 {
     21class WP_Theme_Test extends WPTT_Core {
    2322
    2423    /**
    2524     * __construct
    2625     */
    27     public function __construct()
    28     {
     26    public function __construct() {
    2927        //他言語化
    30         load_plugin_textdomain(WPTT_TEXT_DOMAIN, false, basename(dirname(__FILE__)) . '/languages/');
     28        load_plugin_textdomain( WPTT_TEXT_DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages/' );
    3129        //actions
    32         add_action('init', array($this, 'load_files'));
     30        add_action( 'init', array( $this, 'load_files' ) );
    3331        //filters
    34         add_filter('template', array($this, 'template_filter'));
    35         add_filter('stylesheet', array($this, 'stylesheet_filter'));
     32        add_filter( 'template', array( $this, 'template_filter' ) );
     33        add_filter( 'stylesheet', array( $this, 'stylesheet_filter' ) );
    3634        // プラグインが有効・無効化されたとき
    37         // register_activation_hook(__FILE__, array($this, 'activation_hook'));
    38         // register_deactivation_hook(__FILE__, array($this, 'deactivation_hook'));
    39         // register_uninstall_hook(__FILE__, array($this, 'uninstall_hook'));
     35        register_activation_hook( __FILE__, array( $this, 'activation_hook' ) );
     36        register_deactivation_hook( __FILE__, array( $this, 'deactivation_hook' ) );
     37        register_uninstall_hook( __FILE__, array( $this, 'uninstall_hook' ) );
    4038    }
    4139
     
    4341     * load_files
    4442     */
    45     public function load_files()
    46     {
     43    public function load_files() {
    4744        // Classes
    4845        include_once WPTT_PLUGIN_DIR . '/classes/class.admin.php';
     
    5249     * apply_test_theme
    5350     */
    54     function apply_test_theme()
    55     {
     51    function apply_test_theme() {
    5652        //GETでも変えれるようにする
    57         if (isset($_GET['theme']) && $this->get_parameter()) {
    58             $theme_object = wp_get_theme(esc_html($_GET['theme']));
     53        if ( isset( $_GET['theme'] ) && $this->get_parameter() ) {
     54            $theme_object = wp_get_theme( esc_html( $_GET['theme'] ) );
    5955            return $theme_object;
    6056        }
    6157
    6258        //IPアドレスでも変えれるようにする
    63         if ($this->get_ip_list()) {
     59        if ( $this->get_ip_list() ) {
    6460            $ip_list = $this->get_ip_list();
    65             $ip_list = str_replace(array("\r\n", "\n", "\r"), "\n", $ip_list); //改行を\nに統一
    66             $ip_list = explode("\n", $ip_list);
    67             if (in_array($_SERVER['REMOTE_ADDR'], $ip_list)) {
    68                 return wp_get_theme($this->get_theme());
     61            $ip_list = str_replace(array("\r\n", "\n", "\r"),"\n",$ip_list); //改行を\nに統一
     62            $ip_list = explode( "\n", $ip_list );
     63            if( in_array($_SERVER['REMOTE_ADDR'], $ip_list) ){
     64              return wp_get_theme( $this->get_theme() );
    6965            }
    7066        }
    7167
    7268        // ログイン状態とレベルをチェック
    73         if ($this->has_capability() && $this->is_test_enabled()) {
     69        if ( $this->has_capability() && $this->is_test_enabled() ) {
    7470
    7571            // 現在の設定されているテーマを取得
    76             if (!$theme = $this->get_theme()) {
     72            if ( !$theme = $this->get_theme() ) {
    7773                return false;
    7874            }
    7975
    8076            // 設定されているテーマがあれば取得する
    81             $theme_object = wp_get_theme($theme);
    82             if (!empty($theme_object)) {
    83                 if (isset($theme_object->Status) && $theme_object->Status != 'publish') {
     77            $theme_object = wp_get_theme( $theme );
     78            if ( !empty( $theme_object ) ) {
     79                if ( isset( $theme_object->Status ) && $theme_object->Status != 'publish' ) {
    8480                    return false;
    8581                }
     
    9793     * テンプレートを設定
    9894     */
    99     function template_filter($template)
    100     {
     95    function template_filter( $template ) {
    10196        $theme = $this->apply_test_theme();
    102         if ($theme === false) {
     97        if ( $theme === false ) {
    10398            return $template;
    10499        }
     
    110105     * スタイルシートを設定
    111106     */
    112     function stylesheet_filter($stylesheet)
    113     {
     107    function stylesheet_filter( $stylesheet ) {
    114108        $theme = $this->apply_test_theme();
    115         if ($theme === false) {
     109        if ( $theme === false ) {
    116110            return $stylesheet;
    117111        }
Note: See TracChangeset for help on using the changeset viewer.