Changeset 769552
- Timestamp:
- 09/10/2013 05:45:48 AM (12 years ago)
- File:
-
- 1 edited
-
wp-js-detect/trunk/wp-js-detect.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-js-detect/trunk/wp-js-detect.php
r769541 r769552 1 1 <?php 2 2 3 if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); } 3 if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { 4 die('You are not allowed to call this page directly.'); 5 } 4 6 5 7 /* … … 34 36 * 35 37 */ 36 interface JsDetectInterface{ 37 public function __construct(); 38 public function install(); 39 public function uninstall(); 40 public function plugin_settings(); 41 public function wp_non_js_notification(); 38 interface JsDetectInterface 39 { 40 public function __construct(); 41 public function install(); 42 public function uninstall(); 43 public function plugin_settings(); 44 public function wp_non_js_notification(); 42 45 } 43 46 … … 45 48 * Class JsDetect 46 49 * 47 */50 */ 48 51 class JsDetect implements JsDetectInterface 49 52 { … … 55 58 public function __construct() 56 59 { 57 add_action('wp_head', array($this,'wp_non_js_notification'));58 add_action('admin_menu', array($this,'admin_menu_customization'));59 60 register_activation_hook( __FILE__, array( $this, 'install' ));61 register_deactivation_hook( __FILE__, array( $this, 'uninstall' ));60 add_action('wp_head', array($this, 'wp_non_js_notification')); 61 add_action('admin_menu', array($this, 'admin_menu_customization')); 62 63 register_activation_hook(__FILE__, array($this, 'install')); 64 register_deactivation_hook(__FILE__, array($this, 'uninstall')); 62 65 } 63 66 … … 66 69 * This public function is used to add plugin option. 67 70 * 68 * @param -69 * @return -71 * @param - 72 * @return - 70 73 * 71 74 */ 72 75 public function install() 73 76 { 74 $wp_non_js_notification_text = __('For full functionality of this site it is necessary to enable JavaScript. Here are the <a href="http://www.enable-javascript.com/" target="_blank"> instructions how to enable JavaScript in your web browser</a>.');75 add_option( 'wp_non_js_notification_text', $wp_non_js_notification_text, '', 'yes');76 }77 $wp_non_js_notification_text = __('For full functionality of this site it is necessary to enable JavaScript. Here are the <a href="http://www.enable-javascript.com/" target="_blank"> instructions how to enable JavaScript in your web browser</a>.'); 78 add_option('wp_non_js_notification_text', $wp_non_js_notification_text, '', 'yes'); 79 } 77 80 78 81 /** … … 80 83 * This public function is used to remove plugin options. 81 84 * 82 * @param -83 * @return -85 * @param - 86 * @return - 84 87 * 85 88 */ 86 89 public function uninstall() 87 90 { 88 delete_option( 'wp_non_js_notification_text');89 }91 delete_option('wp_non_js_notification_text'); 92 } 90 93 91 94 /** … … 99 102 public function admin_menu_customization() 100 103 { 101 add_menu_page('Js Detect', 'Js Detect', 'administrator', 'js-detect-settings', array($this,'plugin_settings'),'', 99999999);104 add_menu_page('Js Detect', 'Js Detect', 'administrator', 'js-detect-settings', array($this, 'plugin_settings'), '', 99999999); 102 105 } 103 106 … … 106 109 * This public function is used to update plugin settings. 107 110 * 108 * @param - 109 * @return - 110 * 111 */ 112 public function plugin_settings(){ 113 114 if(isset($_POST['wp_non_js_notification_text'])){ 115 update_option('wp_non_js_notification_text',$_POST['wp_non_js_notification_text']); 116 } 117 ?> 118 <div class="wrap"> 119 <div id="icon-tools" class="icon32"><br /></div><h2>Js Detect Settings</h2> 120 <form action="#" method="post"> 121 <label for="wp_non_js_notification_text">No Js Notification:</label> 122 <textarea rows="10" class="large-text code" id="wp_non_js_notification_text" name="wp_non_js_notification_text"><?php echo get_option('wp_non_js_notification_text'); ?></textarea> 123 <input type="submit" value="<?php _e('Update'); ?>" class="button button-primary button-large"> 124 </form> 125 126 <br /> 127 <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&[email protected]&item_name=Donation+for+Wp+Js+Detect" target="_blank" title="Make a Donation for Wp Js Detect Plugin"> 128 <img src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" alt="" /> 129 </a> 130 </div> 131 </div> 132 <?php 133 } 111 * @param - 112 * @return - 113 * 114 */ 115 public function plugin_settings() 116 { 117 118 if (isset($_POST['wp_non_js_notification_text'])) { 119 update_option('wp_non_js_notification_text', $_POST['wp_non_js_notification_text']); 120 } 121 ?> 122 <div class="wrap"> 123 <div id="icon-tools" class="icon32"><br/></div> 124 <h2>Js Detect Settings</h2> 125 <table cellspacing="0" class="widefat post fixed" style="width: 100%"> 126 <thead> 127 <tr> 128 <th style="width:200px;" class="manage-column"> 129 </th> 130 <th></th> 131 </tr> 132 </thead> 133 <tfoot> 134 <tr> 135 <th class="manage-column"></th> 136 <th></th> 137 </tr> 138 </tfoot> 139 <tbody> 140 <tr> 141 <td class="column"> 142 <label for="wp_non_js_notification_text">No Js Notification:</label> 143 </td> 144 <td align="right" class="column"> 145 <form action="#" method="post"> 146 <textarea rows="10" class="large-text code" id="wp_non_js_notification_text" 147 name="wp_non_js_notification_text"><?php echo get_option('wp_non_js_notification_text'); ?></textarea> 148 <input type="submit" value="<?php _e('Update'); ?>" 149 class="button button-primary button-large"> 150 </form> 151 </td> 152 </tr> 153 <tr> 154 <td colspan="2" class="column"> 155 <p>Donate to support further development.</p> 156 157 <p>Im glad that you like my wordpress plugin and that you want to show your appreciation by 158 donating. With your help I can make these plugins even better!</p> 159 160 <p>You can donate money using the PayPal-button below (any amount makes me happy!)</p> 161 162 <p> 163 <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&[email protected]&item_name=Donation+for+Wp+Js+Detect" 164 target="_blank" title="Make a Donation for Wp Js Detect Plugin"> 165 <img src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" alt=""/> 166 </a> 167 </p> 168 </td> 169 </tr> 170 </tbody> 171 </table> 172 </div> 173 <?php 174 } 134 175 135 176 /** … … 140 181 public function wp_non_js_notification() 141 182 { 142 $plugin_path=get_bloginfo('url').'/wp-content/plugins/wp-js-detect/'; 143 ?> 144 <div id="jsDisabled"><p><?php echo get_option('wp_non_js_notification_text'); ?></p></div> 145 <script language="javascript"> 146 var item = document.getElementById('jsDisabled'); 147 if (item.style.display === "block" || !item.style.display ) 148 { 149 item.style.display = 'none'; 150 } 151 </script> 152 <style> 153 /*no JS message*/ 154 #jsDisabled{ 183 $plugin_path = get_bloginfo('url') . '/wp-content/plugins/wp-js-detect/'; 184 ?> 185 <div id="jsDisabled"><p><?php echo get_option('wp_non_js_notification_text'); ?></p></div> 186 <script language="javascript"> 187 var item = document.getElementById('jsDisabled'); 188 if (item.style.display === "block" || !item.style.display) { 189 item.style.display = 'none'; 190 } 191 </script> 192 <style> 193 /*no JS message*/ 194 #jsDisabled { 155 195 position: fixed; 156 196 width: 100%; … … 159 199 z-index: 2000; 160 200 } 161 #jsDisabled p {201 #jsDisabled p { 162 202 position: absolute; 163 top: 50%;203 top: 50%; 164 204 left: 50%; 165 205 width: 100%; … … 176 216 line-height: 26px; 177 217 } 178 #jsDisabled p a {218 #jsDisabled p a { 179 219 color: #d13131; 180 220 } 181 </style>182 <?php221 </style> 222 <?php 183 223 } 184 224 } 225 185 226 new JsDetect();
Note: See TracChangeset
for help on using the changeset viewer.