Changeset 2316295
- Timestamp:
- 06/02/2020 03:32:06 AM (6 years ago)
- Location:
- wp-theme-test
- Files:
-
- 4 edited
- 1 copied
-
tags/1.1.3 (copied) (copied from wp-theme-test/trunk)
-
tags/1.1.3/readme.txt (modified) (1 diff)
-
tags/1.1.3/wp-theme-test.php (modified) (5 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/readme.txt
r2244269 r2316295 4 4 Tags: : page, pages,theme, themes 5 5 Requires at least: 3.0 or higher 6 Tested up to: 5. 3.27 Stable tag: 1.1. 26 Tested up to: 5.4.1 7 Stable tag: 1.1.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
wp-theme-test/tags/1.1.3/wp-theme-test.php
r2244269 r2316295 5 5 Description: The theme can be changed and displayed to only logged in users. 6 6 Author: Nakashima Masahiro 7 Version: 1.1. 27 Version: 1.1.3 8 8 Author URI: http://www.kigurumi.asia 9 9 Text Domain: wptt 10 10 Domain Path: /languages/ 11 11 */ 12 define( 'WPTT_VERSION', '1.1.2');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 { 21 class WP_Theme_Test extends WPTT_Core 22 { 22 23 23 24 /** 24 25 * __construct 25 26 */ 26 public function __construct() { 27 public function __construct() 28 { 27 29 //他言語化 28 load_plugin_textdomain( WPTT_TEXT_DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages/');30 load_plugin_textdomain(WPTT_TEXT_DOMAIN, false, basename(dirname(__FILE__)) . '/languages/'); 29 31 //actions 30 add_action( 'init', array( $this, 'load_files' ));32 add_action('init', array($this, 'load_files')); 31 33 //filters 32 add_filter( 'template', array( $this, 'template_filter' ));33 add_filter( 'stylesheet', array( $this, 'stylesheet_filter' ));34 add_filter('template', array($this, 'template_filter')); 35 add_filter('stylesheet', array($this, 'stylesheet_filter')); 34 36 // プラグインが有効・無効化されたとき 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' ));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')); 38 40 } 39 41 … … 41 43 * load_files 42 44 */ 43 public function load_files() { 45 public function load_files() 46 { 44 47 // Classes 45 48 include_once WPTT_PLUGIN_DIR . '/classes/class.admin.php'; … … 49 52 * apply_test_theme 50 53 */ 51 function apply_test_theme() { 54 function apply_test_theme() 55 { 52 56 //GETでも変えれるようにする 53 if ( isset( $_GET['theme'] ) && $this->get_parameter()) {54 $theme_object = wp_get_theme( esc_html( $_GET['theme'] ));57 if (isset($_GET['theme']) && $this->get_parameter()) { 58 $theme_object = wp_get_theme(esc_html($_GET['theme'])); 55 59 return $theme_object; 56 60 } 57 61 58 62 //IPアドレスでも変えれるようにする 59 if ( $this->get_ip_list()) {63 if ($this->get_ip_list()) { 60 64 $ip_list = $this->get_ip_list(); 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());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()); 65 69 } 66 70 } 67 71 68 72 // ログイン状態とレベルをチェック 69 if ( $this->has_capability() && $this->is_test_enabled()) {73 if ($this->has_capability() && $this->is_test_enabled()) { 70 74 71 75 // 現在の設定されているテーマを取得 72 if ( !$theme = $this->get_theme()) {76 if (!$theme = $this->get_theme()) { 73 77 return false; 74 78 } 75 79 76 80 // 設定されているテーマがあれば取得する 77 $theme_object = wp_get_theme( $theme);78 if ( !empty( $theme_object )) {79 if ( isset( $theme_object->Status ) && $theme_object->Status != 'publish') {81 $theme_object = wp_get_theme($theme); 82 if (!empty($theme_object)) { 83 if (isset($theme_object->Status) && $theme_object->Status != 'publish') { 80 84 return false; 81 85 } … … 93 97 * テンプレートを設定 94 98 */ 95 function template_filter( $template ) { 99 function template_filter($template) 100 { 96 101 $theme = $this->apply_test_theme(); 97 if ( $theme === false) {102 if ($theme === false) { 98 103 return $template; 99 104 } … … 105 110 * スタイルシートを設定 106 111 */ 107 function stylesheet_filter( $stylesheet ) { 112 function stylesheet_filter($stylesheet) 113 { 108 114 $theme = $this->apply_test_theme(); 109 if ( $theme === false) {115 if ($theme === false) { 110 116 return $stylesheet; 111 117 } -
wp-theme-test/trunk/readme.txt
r2244269 r2316295 4 4 Tags: : page, pages,theme, themes 5 5 Requires at least: 3.0 or higher 6 Tested up to: 5. 3.27 Stable tag: 1.1. 26 Tested up to: 5.4.1 7 Stable tag: 1.1.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
wp-theme-test/trunk/wp-theme-test.php
r2244269 r2316295 5 5 Description: The theme can be changed and displayed to only logged in users. 6 6 Author: Nakashima Masahiro 7 Version: 1.1. 27 Version: 1.1.3 8 8 Author URI: http://www.kigurumi.asia 9 9 Text Domain: wptt 10 10 Domain Path: /languages/ 11 11 */ 12 define( 'WPTT_VERSION', '1.1.2');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 { 21 class WP_Theme_Test extends WPTT_Core 22 { 22 23 23 24 /** 24 25 * __construct 25 26 */ 26 public function __construct() { 27 public function __construct() 28 { 27 29 //他言語化 28 load_plugin_textdomain( WPTT_TEXT_DOMAIN, false, basename( dirname( __FILE__ ) ) . '/languages/');30 load_plugin_textdomain(WPTT_TEXT_DOMAIN, false, basename(dirname(__FILE__)) . '/languages/'); 29 31 //actions 30 add_action( 'init', array( $this, 'load_files' ));32 add_action('init', array($this, 'load_files')); 31 33 //filters 32 add_filter( 'template', array( $this, 'template_filter' ));33 add_filter( 'stylesheet', array( $this, 'stylesheet_filter' ));34 add_filter('template', array($this, 'template_filter')); 35 add_filter('stylesheet', array($this, 'stylesheet_filter')); 34 36 // プラグインが有効・無効化されたとき 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' ));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')); 38 40 } 39 41 … … 41 43 * load_files 42 44 */ 43 public function load_files() { 45 public function load_files() 46 { 44 47 // Classes 45 48 include_once WPTT_PLUGIN_DIR . '/classes/class.admin.php'; … … 49 52 * apply_test_theme 50 53 */ 51 function apply_test_theme() { 54 function apply_test_theme() 55 { 52 56 //GETでも変えれるようにする 53 if ( isset( $_GET['theme'] ) && $this->get_parameter()) {54 $theme_object = wp_get_theme( esc_html( $_GET['theme'] ));57 if (isset($_GET['theme']) && $this->get_parameter()) { 58 $theme_object = wp_get_theme(esc_html($_GET['theme'])); 55 59 return $theme_object; 56 60 } 57 61 58 62 //IPアドレスでも変えれるようにする 59 if ( $this->get_ip_list()) {63 if ($this->get_ip_list()) { 60 64 $ip_list = $this->get_ip_list(); 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());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()); 65 69 } 66 70 } 67 71 68 72 // ログイン状態とレベルをチェック 69 if ( $this->has_capability() && $this->is_test_enabled()) {73 if ($this->has_capability() && $this->is_test_enabled()) { 70 74 71 75 // 現在の設定されているテーマを取得 72 if ( !$theme = $this->get_theme()) {76 if (!$theme = $this->get_theme()) { 73 77 return false; 74 78 } 75 79 76 80 // 設定されているテーマがあれば取得する 77 $theme_object = wp_get_theme( $theme);78 if ( !empty( $theme_object )) {79 if ( isset( $theme_object->Status ) && $theme_object->Status != 'publish') {81 $theme_object = wp_get_theme($theme); 82 if (!empty($theme_object)) { 83 if (isset($theme_object->Status) && $theme_object->Status != 'publish') { 80 84 return false; 81 85 } … … 93 97 * テンプレートを設定 94 98 */ 95 function template_filter( $template ) { 99 function template_filter($template) 100 { 96 101 $theme = $this->apply_test_theme(); 97 if ( $theme === false) {102 if ($theme === false) { 98 103 return $template; 99 104 } … … 105 110 * スタイルシートを設定 106 111 */ 107 function stylesheet_filter( $stylesheet ) { 112 function stylesheet_filter($stylesheet) 113 { 108 114 $theme = $this->apply_test_theme(); 109 if ( $theme === false) {115 if ($theme === false) { 110 116 return $stylesheet; 111 117 }
Note: See TracChangeset
for help on using the changeset viewer.