Changeset 2679505
- Timestamp:
- 02/15/2022 11:24:19 PM (4 years ago)
- Location:
- wp-theme-test
- Files:
-
- 6 edited
- 1 copied
-
tags/1.1.3/trunk (copied) (copied from wp-theme-test/trunk)
-
tags/1.1.3/trunk/classes/class.core.php (modified) (11 diffs)
-
tags/1.1.3/trunk/readme.txt (modified) (1 diff)
-
tags/1.1.3/trunk/wp-theme-test.php (modified) (5 diffs)
-
trunk/classes/class.core.php (modified) (11 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/wp-theme-test.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-theme-test/tags/1.1.3/trunk/classes/class.core.php
r1938975 r2679505 1 1 <?php 2 class WPTT_Core { 2 class WPTT_Core 3 { 3 4 // プラグイン有効化時のデフォルトオプション 4 5 private $wptt_default_options = array( … … 15 16 * @return [str] [description] 16 17 */ 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'])) { 20 22 return $options['theme']; 21 23 } else { … … 29 31 * @return string | bool 30 32 */ 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']) { 34 37 return true; 35 38 } … … 42 45 * @return boolean [description] 43 46 */ 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 } 50 57 } 51 58 } … … 58 65 * 設定レベルを取得 59 66 */ 60 function get_level() { 61 $options = get_option( WPTT_PLUGIN_NAME ); 67 function get_level() 68 { 69 $options = get_option(WPTT_PLUGIN_NAME); 62 70 $level = $options['level']; 63 71 64 if ( $level != '') {72 if ($level != '') { 65 73 return 'level_' . $level; 66 74 } else { … … 72 80 * 現在のパラメーターを取得 73 81 */ 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']) { 77 86 return true; 78 87 } … … 83 92 * IPアドレスを取得 84 93 */ 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']) { 88 98 return $options['ip_list']; 89 99 } … … 94 104 * 翻訳用 95 105 */ 96 public function e( $text ) { 97 _e( $text, WPTT_TEXT_DOMAIN ); 106 public function e($text) 107 { 108 _e($text, WPTT_TEXT_DOMAIN); 98 109 } 99 110 100 public function _( $text ) { 101 return __( $text, WPTT_TEXT_DOMAIN ); 111 public function _($text) 112 { 113 return __($text, WPTT_TEXT_DOMAIN); 102 114 } 103 115 … … 105 117 * プラグインが有効化されたときに実行 106 118 */ 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); 110 123 } 111 124 } … … 114 127 * 無効化ときに実行 115 128 */ 116 function deactivation_hook() { 117 delete_option( WPTT_PLUGIN_NAME ); 129 function deactivation_hook() 130 { 131 delete_option(WPTT_PLUGIN_NAME); 118 132 } 119 133 … … 121 135 * アンインストール時に実行 122 136 */ 123 function uninstall_hook() { 124 delete_option( WPTT_PLUGIN_NAME ); 137 function uninstall_hook() 138 { 139 delete_option(WPTT_PLUGIN_NAME); 125 140 } 126 141 } -
wp-theme-test/tags/1.1.3/trunk/readme.txt
r2316295 r2679505 4 4 Tags: : page, pages,theme, themes 5 5 Requires at least: 3.0 or higher 6 Tested up to: 5. 4.16 Tested up to: 5.9.0 7 7 Stable tag: 1.1.3 8 8 License: GPLv2 or later -
wp-theme-test/tags/1.1.3/trunk/wp-theme-test.php
r2316295 r2679505 10 10 Domain Path: /languages/ 11 11 */ 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');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' ); 18 18 19 19 require_once WPTT_PLUGIN_DIR . '/classes/class.core.php'; 20 20 21 class WP_Theme_Test extends WPTT_Core 22 { 21 class WP_Theme_Test extends WPTT_Core { 23 22 24 23 /** 25 24 * __construct 26 25 */ 27 public function __construct() 28 { 26 public function __construct() { 29 27 //他言語化 30 load_plugin_textdomain( WPTT_TEXT_DOMAIN, false, basename(dirname(__FILE__)) . '/languages/');28 load_plugin_textdomain( WPTT_TEXT_DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages/' ); 31 29 //actions 32 add_action( 'init', array($this, 'load_files'));30 add_action( 'init', array( $this, 'load_files' ) ); 33 31 //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' ) ); 36 34 // プラグインが有効・無効化されたとき 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' ) ); 40 38 } 41 39 … … 43 41 * load_files 44 42 */ 45 public function load_files() 46 { 43 public function load_files() { 47 44 // Classes 48 45 include_once WPTT_PLUGIN_DIR . '/classes/class.admin.php'; … … 52 49 * apply_test_theme 53 50 */ 54 function apply_test_theme() 55 { 51 function apply_test_theme() { 56 52 //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'] ) ); 59 55 return $theme_object; 60 56 } 61 57 62 58 //IPアドレスでも変えれるようにする 63 if ( $this->get_ip_list()) {59 if ( $this->get_ip_list() ) { 64 60 $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() ); 69 65 } 70 66 } 71 67 72 68 // ログイン状態とレベルをチェック 73 if ( $this->has_capability() && $this->is_test_enabled()) {69 if ( $this->has_capability() && $this->is_test_enabled() ) { 74 70 75 71 // 現在の設定されているテーマを取得 76 if ( !$theme = $this->get_theme()) {72 if ( !$theme = $this->get_theme() ) { 77 73 return false; 78 74 } 79 75 80 76 // 設定されているテーマがあれば取得する 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' ) { 84 80 return false; 85 81 } … … 97 93 * テンプレートを設定 98 94 */ 99 function template_filter($template) 100 { 95 function template_filter( $template ) { 101 96 $theme = $this->apply_test_theme(); 102 if ( $theme === false) {97 if ( $theme === false ) { 103 98 return $template; 104 99 } … … 110 105 * スタイルシートを設定 111 106 */ 112 function stylesheet_filter($stylesheet) 113 { 107 function stylesheet_filter( $stylesheet ) { 114 108 $theme = $this->apply_test_theme(); 115 if ( $theme === false) {109 if ( $theme === false ) { 116 110 return $stylesheet; 117 111 } -
wp-theme-test/trunk/classes/class.core.php
r1938975 r2679505 1 1 <?php 2 class WPTT_Core { 2 class WPTT_Core 3 { 3 4 // プラグイン有効化時のデフォルトオプション 4 5 private $wptt_default_options = array( … … 15 16 * @return [str] [description] 16 17 */ 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'])) { 20 22 return $options['theme']; 21 23 } else { … … 29 31 * @return string | bool 30 32 */ 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']) { 34 37 return true; 35 38 } … … 42 45 * @return boolean [description] 43 46 */ 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 } 50 57 } 51 58 } … … 58 65 * 設定レベルを取得 59 66 */ 60 function get_level() { 61 $options = get_option( WPTT_PLUGIN_NAME ); 67 function get_level() 68 { 69 $options = get_option(WPTT_PLUGIN_NAME); 62 70 $level = $options['level']; 63 71 64 if ( $level != '') {72 if ($level != '') { 65 73 return 'level_' . $level; 66 74 } else { … … 72 80 * 現在のパラメーターを取得 73 81 */ 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']) { 77 86 return true; 78 87 } … … 83 92 * IPアドレスを取得 84 93 */ 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']) { 88 98 return $options['ip_list']; 89 99 } … … 94 104 * 翻訳用 95 105 */ 96 public function e( $text ) { 97 _e( $text, WPTT_TEXT_DOMAIN ); 106 public function e($text) 107 { 108 _e($text, WPTT_TEXT_DOMAIN); 98 109 } 99 110 100 public function _( $text ) { 101 return __( $text, WPTT_TEXT_DOMAIN ); 111 public function _($text) 112 { 113 return __($text, WPTT_TEXT_DOMAIN); 102 114 } 103 115 … … 105 117 * プラグインが有効化されたときに実行 106 118 */ 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); 110 123 } 111 124 } … … 114 127 * 無効化ときに実行 115 128 */ 116 function deactivation_hook() { 117 delete_option( WPTT_PLUGIN_NAME ); 129 function deactivation_hook() 130 { 131 delete_option(WPTT_PLUGIN_NAME); 118 132 } 119 133 … … 121 135 * アンインストール時に実行 122 136 */ 123 function uninstall_hook() { 124 delete_option( WPTT_PLUGIN_NAME ); 137 function uninstall_hook() 138 { 139 delete_option(WPTT_PLUGIN_NAME); 125 140 } 126 141 } -
wp-theme-test/trunk/readme.txt
r2316295 r2679505 4 4 Tags: : page, pages,theme, themes 5 5 Requires at least: 3.0 or higher 6 Tested up to: 5. 4.16 Tested up to: 5.9.0 7 7 Stable tag: 1.1.3 8 8 License: GPLv2 or later -
wp-theme-test/trunk/wp-theme-test.php
r2316295 r2679505 10 10 Domain Path: /languages/ 11 11 */ 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');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' ); 18 18 19 19 require_once WPTT_PLUGIN_DIR . '/classes/class.core.php'; 20 20 21 class WP_Theme_Test extends WPTT_Core 22 { 21 class WP_Theme_Test extends WPTT_Core { 23 22 24 23 /** 25 24 * __construct 26 25 */ 27 public function __construct() 28 { 26 public function __construct() { 29 27 //他言語化 30 load_plugin_textdomain( WPTT_TEXT_DOMAIN, false, basename(dirname(__FILE__)) . '/languages/');28 load_plugin_textdomain( WPTT_TEXT_DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages/' ); 31 29 //actions 32 add_action( 'init', array($this, 'load_files'));30 add_action( 'init', array( $this, 'load_files' ) ); 33 31 //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' ) ); 36 34 // プラグインが有効・無効化されたとき 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' ) ); 40 38 } 41 39 … … 43 41 * load_files 44 42 */ 45 public function load_files() 46 { 43 public function load_files() { 47 44 // Classes 48 45 include_once WPTT_PLUGIN_DIR . '/classes/class.admin.php'; … … 52 49 * apply_test_theme 53 50 */ 54 function apply_test_theme() 55 { 51 function apply_test_theme() { 56 52 //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'] ) ); 59 55 return $theme_object; 60 56 } 61 57 62 58 //IPアドレスでも変えれるようにする 63 if ( $this->get_ip_list()) {59 if ( $this->get_ip_list() ) { 64 60 $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() ); 69 65 } 70 66 } 71 67 72 68 // ログイン状態とレベルをチェック 73 if ( $this->has_capability() && $this->is_test_enabled()) {69 if ( $this->has_capability() && $this->is_test_enabled() ) { 74 70 75 71 // 現在の設定されているテーマを取得 76 if ( !$theme = $this->get_theme()) {72 if ( !$theme = $this->get_theme() ) { 77 73 return false; 78 74 } 79 75 80 76 // 設定されているテーマがあれば取得する 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' ) { 84 80 return false; 85 81 } … … 97 93 * テンプレートを設定 98 94 */ 99 function template_filter($template) 100 { 95 function template_filter( $template ) { 101 96 $theme = $this->apply_test_theme(); 102 if ( $theme === false) {97 if ( $theme === false ) { 103 98 return $template; 104 99 } … … 110 105 * スタイルシートを設定 111 106 */ 112 function stylesheet_filter($stylesheet) 113 { 107 function stylesheet_filter( $stylesheet ) { 114 108 $theme = $this->apply_test_theme(); 115 if ( $theme === false) {109 if ( $theme === false ) { 116 110 return $stylesheet; 117 111 }
Note: See TracChangeset
for help on using the changeset viewer.