Changeset 1686733
- Timestamp:
- 06/28/2017 07:11:42 AM (9 years ago)
- File:
-
- 1 edited
-
theme-changer/trunk/theme-changer.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
theme-changer/trunk/theme-changer.php
r1684621 r1686733 4 4 Plugin URI: http://www.elegants.biz/theme-changer.php 5 5 Description: Easy theme change in the get parameter. this to be a per-session only change, and one that everyone (all visitors) can use. I just enter the following URL. It's easy. e.g. http://wordpress_install_domain/?theme_changer=theme_folder_name 6 Version: 1. 16 Version: 1.2 7 7 Author: momen2009 8 8 Author URI: http://www.elegants.biz/ … … 40 40 session_start(); 41 41 } 42 43 global $theme_changer_theme; 44 $theme_changer_password = get_option("theme_changer_password"); 45 if($theme_changer_password != false){ 46 $now_theme = wp_get_theme(); 47 $theme_changer_theme = $now_theme -> get_stylesheet(); 48 if($theme_changer_password != $wpdb->escape($_GET["theme_changer_password"])) return; 49 } 50 42 51 $theme_changer = $wpdb->escape($_GET["theme_changer"]); 43 52 if(isset($theme_changer) && $theme_changer != ""){ … … 47 56 } 48 57 if($value = exist_search_theme($theme_changer)){ 49 global $theme_changer_theme;50 58 $theme_changer_theme = $value -> get_stylesheet(); 51 59 $_SESSION["theme_changer"]=$theme_changer; … … 91 99 function theme_changer_footer() { 92 100 global $theme_changer_theme; 93 $output .= "<style>#theme_changer{z-index:1000 !important;position:fixed;padding:10px;bottom:10px;left:10px;opacity:0.2;}#theme_changer label {color: #333 !important;display: block !important;font-weight: 800 !important;margin-bottom: 0.5em !important;font-family: 'Hiragino Kaku Gothic Pro', Meiryo, sans-serif !important;font-size: 16px !important;}#theme_changer select {font-weight:normal !important;font-size: 16px !important;color: #333 !important;border: 1px solid #bbb !important;-webkit-border-radius: 3px !important;border-radius: 3px !important;height: 3em !important;max-width: 100% !important;}#theme_changer p {font-size: 9px;}</style><script>jQuery(document).ready(function(){jQuery('#theme_changer select').change(function() {if (jQuery(this).val() != '') {insertParameter('theme_changer',jQuery(this).val());}});});function insertParameter(key, value){key = encodeURI(key); value = encodeURI(value);var kvp = document.location.search.substr(1).split('&');var i=kvp.length; var x; while(i--) {x = kvp[i].split('=');if (x[0]==key){x[1] = value;kvp[i] = x.join('=');break;}}if(i<0) {kvp[kvp.length] = [key,value].join('=');}document.location.search = kvp.join('&');} jQuery('body').append('"; 101 $output .= "<style>\r\n#theme_changer{z-index:1000 !important;position:fixed;padding:10px;bottom:10px;left:10px;opacity:0.2;}#theme_changer label {color: #333 !important;display: block !important;font-weight: 800 !important;margin-bottom: 0.5em !important;font-family: 'Hiragino Kaku Gothic Pro', Meiryo, sans-serif !important;font-size: 16px !important;}#theme_changer select {font-weight:normal !important;font-size: 16px !important;color: #333 !important;border: 1px solid #bbb !important;-webkit-border-radius: 3px !important;border-radius: 3px !important;height: 3em !important;max-width: 100% !important;}#theme_changer p {font-size: 9px;}</style><script>jQuery(document).ready(function(){jQuery('#theme_changer select').change(function() {if (jQuery(this).val() != '') {"; 102 $output .= "var kvp2; kvp2 = insertParameter(document.location.search.substr(1).split('&'),'theme_changer',jQuery(this).val());"; 103 $theme_changer_password = get_option("theme_changer_password"); 104 if($theme_changer_password != false){ 105 $output .= "kvp2 = insertParameter(kvp2.split('&'),'theme_changer_password','" . $theme_changer_password . "');"; 106 } 107 $output .= "document.location.search = kvp2;}});});"; 108 $output .= "function insertParameter(kvp, key, value) {key = encodeURI(key);value = encodeURI(value);var i = kvp.length;var x;while (i--) {x = kvp[i].split('=');if (x[0] == key) {x[1] = value;kvp[i] = x.join('=');break;}}if (i < 0) {kvp[kvp.length] = [key, value].join('=');}return kvp.join('&');}"; 109 $output .= " jQuery('body').append('"; 94 110 $output .= "<div id=\"theme_changer\"><label for=\"theme_changer_select\">Theme Changer</label><select id=\"theme_changer_select\">"; 95 111 … … 108 124 echo $output; 109 125 } 126 127 add_action('admin_menu','theme_changer_menu'); 128 129 function theme_changer_menu() { 130 add_options_page( 'Theme Changer Options', 'Theme Changer Options', 'manage_options', 'theme-changer-options', 'theme_changer_options' ); 131 } 132 133 function theme_changer_options() { 134 if ( !current_user_can( 'manage_options' ) ) { 135 wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); 136 } 137 138 if (isset($_POST['theme_changer_password'])) { 139 update_option('theme_changer_password', wp_unslash($_POST['theme_changer_password'])); 140 } 110 141 ?> 142 <div class="wrap"> 143 <h1>Theme Changer Options</h1> 144 <?php 145 if(isset($_POST['theme_changer_password'])) { 146 echo '<div id="setting-error-settings_updated" class="updated settings-error notice is-dismissible"><p><strong>Settings saved.</strong></p></div>'; 147 } 148 ?> 149 <form method="post" action=""> 150 <table class="form-table"> 151 <tr> 152 <th scope="row"><label for="theme_changer_password">Password</label></th> 153 <td><input name="theme_changer_password" type="text" id="theme_changer_password" value="<?php form_option('theme_changer_password'); ?>" class="regular-text" /><p class="description" id="theme-changer-password-description">You can attach a password to the Theme Changer. e.g. http://wordpress_install_domain/?theme_changer=theme_folder_name&<strong>theme_changer_password=input_password<strong></p></td> 154 </tr> 155 </table> 156 <?php submit_button(); ?> 157 </form> 158 </div> 159 <?php 160 } 161 ?>
Note: See TracChangeset
for help on using the changeset viewer.