Changeset 3009226
- Timestamp:
- 12/13/2023 07:44:37 AM (2 years ago)
- Location:
- show-current-width
- Files:
-
- 21 added
- 7 edited
-
tags/1.2.4 (added)
-
tags/1.2.4/LICENSE.txt (added)
-
tags/1.2.4/assets (added)
-
tags/1.2.4/assets/show-current-width.css (added)
-
tags/1.2.4/assets/show-current-width.css.map (added)
-
tags/1.2.4/assets/show-current-width.js (added)
-
tags/1.2.4/assets/show-current-width.min.css (added)
-
tags/1.2.4/assets/show-current-width.min.css.map (added)
-
tags/1.2.4/assets/show-current-width.min.js (added)
-
tags/1.2.4/assets/show-current-width.scss (added)
-
tags/1.2.4/class (added)
-
tags/1.2.4/class/class-showcurrentwidth-admin.php (added)
-
tags/1.2.4/class/class-showcurrentwidth-core.php (added)
-
tags/1.2.4/class/trait-singleton.php (added)
-
tags/1.2.4/readme.txt (added)
-
tags/1.2.4/screenshot-1.png (added)
-
tags/1.2.4/screenshot-2.png (added)
-
tags/1.2.4/screenshot-3.png (added)
-
tags/1.2.4/show-current-width.php (added)
-
tags/1.2.4/uninstall.php (added)
-
tags/1.2.4/w83-show-current-width.php (added)
-
trunk/assets/show-current-width.js (modified) (1 diff)
-
trunk/assets/show-current-width.min.js (modified) (1 diff)
-
trunk/class/class-showcurrentwidth-admin.php (modified) (8 diffs)
-
trunk/class/class-showcurrentwidth-core.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/uninstall.php (modified) (1 diff)
-
trunk/w83-show-current-width.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
show-current-width/trunk/assets/show-current-width.js
r2973725 r3009226 6 6 this.timeoutWidth = undefined; 7 7 this.timeoutCountUp = undefined; 8 this.delay = 500;8 this.delay = ShowCurrentWidthVariables.animation_timeout; 9 9 this.widthFrom = 0; 10 10 this.widthTo = window.innerWidth; -
show-current-width/trunk/assets/show-current-width.min.js
r2973725 r3009226 1 "use strict";class ShowCurrentWidth{constructor(){this.timeoutWidth=void 0,this.timeoutCountUp=void 0,this.delay= 500,this.widthFrom=0,this.widthTo=window.innerWidth,this.widthNow=0,this.countUpProceeding=!1,window.addEventListener("load",this.showWidth()),window.addEventListener("load",this.showWidthDelay())}showWidth(){this.widthTo=window.innerWidth,1==ShowCurrentWidthVariables.animation_show?(this.countUpProceeding=!0,this.showWidthWithAnimation()):this.showWidthWithoutAnimation()}showWidthWithAnimation(){let t=Math.abs(this.widthTo-this.widthFrom)/30;if(this.showWidthCore(this.widthNow),!this.countUpProceeding)return clearTimeout(this.timeoutCountUp),void(this.widthFrom=this.widthTo);this.widthNow>this.widthTo?this.widthNow-=t:this.widthNow<this.widthTo&&(this.widthNow+=t),Math.abs(this.widthNow-this.widthTo)<=t&&(this.widthNow=this.widthTo,this.countUpProceeding=!1),this.timeoutCountUp=setTimeout(()=>{this.showWidthWithAnimation()},7)}showWidthWithoutAnimation(){this.showWidthCore(this.widthTo)}showWidthCore(t){let i=void 0,h=void 0,o=new Array,e="»",d=void 0;ShowCurrentWidthVariables.breakpoints_definition.split("\n").forEach((t,e)=>{let d=t.trim().split(/\s*,\s*/);d[0]<=this.widthNow&&this.widthNow<d[1]?(i=d[2],h=d[3],o[e]=!0):o[e]=!1}),document.querySelector("#wp-admin-bar-show-current-width .ab-icon .width").textContent=Math.round(t),document.querySelector("#wp-admin-bar-show-current-width .ab-label .width").textContent=Math.round(t),1==ShowCurrentWidthVariables.breakpoints_show&&(document.querySelector("#wp-admin-bar-show-current-width .breakpoint").textContent=i,document.querySelector("#wp-admin-bar-show-current-width-breakpoint .breakpoint").textContent=h,o.forEach((t,i)=>{d=t?e:"",document.querySelector("#wp-admin-bar-show-current-width-breakpoint-"+i+" .icon").textContent=d}))}showWidthDelay(){window.addEventListener("resize",()=>{clearTimeout(this.timeoutWidth),this.timeoutWidth=setTimeout(()=>{this.showWidth()},this.delay)},!1)}}new ShowCurrentWidth;1 "use strict";class ShowCurrentWidth{constructor(){this.timeoutWidth=void 0,this.timeoutCountUp=void 0,this.delay=ShowCurrentWidthVariables.animation_timeout,this.widthFrom=0,this.widthTo=window.innerWidth,this.widthNow=0,this.countUpProceeding=!1,window.addEventListener("load",this.showWidth()),window.addEventListener("load",this.showWidthDelay())}showWidth(){this.widthTo=window.innerWidth,1==ShowCurrentWidthVariables.animation_show?(this.countUpProceeding=!0,this.showWidthWithAnimation()):this.showWidthWithoutAnimation()}showWidthWithAnimation(){let t=Math.abs(this.widthTo-this.widthFrom)/30;if(this.showWidthCore(this.widthNow),!this.countUpProceeding)return clearTimeout(this.timeoutCountUp),void(this.widthFrom=this.widthTo);this.widthNow>this.widthTo?this.widthNow-=t:this.widthNow<this.widthTo&&(this.widthNow+=t),Math.abs(this.widthNow-this.widthTo)<=t&&(this.widthNow=this.widthTo,this.countUpProceeding=!1),this.timeoutCountUp=setTimeout(()=>{this.showWidthWithAnimation()},7)}showWidthWithoutAnimation(){this.showWidthCore(this.widthTo)}showWidthCore(t){let i=void 0,h=void 0,o=new Array,e="»",d=void 0;ShowCurrentWidthVariables.breakpoints_definition.split("\n").forEach((t,e)=>{let d=t.trim().split(/\s*,\s*/);d[0]<=this.widthNow&&this.widthNow<d[1]?(i=d[2],h=d[3],o[e]=!0):o[e]=!1}),document.querySelector("#wp-admin-bar-show-current-width .ab-icon .width").textContent=Math.round(t),document.querySelector("#wp-admin-bar-show-current-width .ab-label .width").textContent=Math.round(t),1==ShowCurrentWidthVariables.breakpoints_show&&(document.querySelector("#wp-admin-bar-show-current-width .breakpoint").textContent=i,document.querySelector("#wp-admin-bar-show-current-width-breakpoint .breakpoint").textContent=h,o.forEach((t,i)=>{d=t?e:"",document.querySelector("#wp-admin-bar-show-current-width-breakpoint-"+i+" .icon").textContent=d}))}showWidthDelay(){window.addEventListener("resize",()=>{clearTimeout(this.timeoutWidth),this.timeoutWidth=setTimeout(()=>{this.showWidth()},this.delay)},!1)}}new ShowCurrentWidth; -
show-current-width/trunk/class/class-showcurrentwidth-admin.php
r2979825 r3009226 21 21 22 22 /** 23 * Plugin constant.23 * Constructor. 24 24 * 25 25 * @return void … … 124 124 ), 125 125 ); 126 // Add field 1-4 (Animation on/off). 126 127 // Add section 2. 128 add_settings_section( 129 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-section2', 130 __( 'Display settings', 'show-current-width' ), 131 array( $this, 'register_section2_html' ), 132 ShowCurrentWidth_Core::PLUGIN_PREFIX 133 ); 134 // Add field 2-1 (Admin page display). 135 add_settings_field( 136 ShowCurrentWidth_Core::PLUGIN_PREFIX . '_admin_show', 137 __( 'Admin page display', 'show-current-width' ), 138 array( $this, 'register_field_admin_show_html' ), 139 ShowCurrentWidth_Core::PLUGIN_PREFIX, 140 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-section2', 141 array( 142 'label_for' => ShowCurrentWidth_Core::PLUGIN_PREFIX . '_admin_show', 143 ), 144 ); 145 // Add field 2-2 (Role condition). 146 add_settings_field( 147 ShowCurrentWidth_Core::PLUGIN_PREFIX . '_condition_role', 148 __( 'Role condition', 'show-current-width' ), 149 array( $this, 'register_field_condition_role_html' ), 150 ShowCurrentWidth_Core::PLUGIN_PREFIX, 151 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-section2', 152 array( 153 'label_for' => ShowCurrentWidth_Core::PLUGIN_PREFIX . '_condition_role', 154 ), 155 ); 156 // Add field 2-3 (Animation on/off). 127 157 add_settings_field( 128 158 ShowCurrentWidth_Core::PLUGIN_PREFIX . '_animation_show', … … 130 160 array( $this, 'register_field_animation_show_html' ), 131 161 ShowCurrentWidth_Core::PLUGIN_PREFIX, 132 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-section 1',162 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-section2', 133 163 array( 134 164 'label_for' => ShowCurrentWidth_Core::PLUGIN_PREFIX . '_animation_show', 135 165 ), 136 166 ); 137 138 // Add section 2. 139 add_settings_section( 167 // Add field 2-4 (Animation timeout). 168 add_settings_field( 169 ShowCurrentWidth_Core::PLUGIN_PREFIX . '_animation_timeout', 170 __( 'Animation timeout', 'show-current-width' ), 171 array( $this, 'register_field_animation_timeout_html' ), 172 ShowCurrentWidth_Core::PLUGIN_PREFIX, 140 173 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-section2', 141 __( 'Display condition settings', 'show-current-width' ), 142 array( $this, 'register_section2_html' ), 143 ShowCurrentWidth_Core::PLUGIN_PREFIX 144 ); 145 // Add field 2-1 (Admin page display). 146 add_settings_field( 147 ShowCurrentWidth_Core::PLUGIN_PREFIX . '_admin_show', 148 __( 'Admin page display', 'show-current-width' ), 149 array( $this, 'register_field_admin_show_html' ), 150 ShowCurrentWidth_Core::PLUGIN_PREFIX, 151 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-section2', 152 array( 153 'label_for' => ShowCurrentWidth_Core::PLUGIN_PREFIX . '_admin_show', 154 ), 155 ); 156 // Add field 2-2 (Role condition). 157 add_settings_field( 158 ShowCurrentWidth_Core::PLUGIN_PREFIX . '_condition_role', 159 __( 'Role condition', 'show-current-width' ), 160 array( $this, 'register_field_condition_role_html' ), 161 ShowCurrentWidth_Core::PLUGIN_PREFIX, 162 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-section2', 163 array( 164 'label_for' => ShowCurrentWidth_Core::PLUGIN_PREFIX . '_condition_role', 174 array( 175 'label_for' => ShowCurrentWidth_Core::PLUGIN_PREFIX . '_animation_timeout', 165 176 ), 166 177 ); … … 287 298 288 299 /** 289 * Field 1-4 HTML.290 *291 * @return void292 */293 public function register_field_animation_show_html() {294 printf(295 '<input type="hidden" name="%s_animation_show" value="0" />',296 esc_attr( ShowCurrentWidth_Core::PLUGIN_PREFIX )297 );298 printf(299 '<input type="checkbox" name="%s_animation_show" id="%s_animation_show" value="1" %s />',300 esc_attr( ShowCurrentWidth_Core::PLUGIN_PREFIX ),301 esc_attr( ShowCurrentWidth_Core::PLUGIN_PREFIX ),302 checked( get_option( ShowCurrentWidth_Core::PLUGIN_PREFIX . '_animation_show' ), '1', false )303 );304 printf(305 '<label for="%s_animation_show">%s</label>',306 esc_attr( ShowCurrentWidth_Core::PLUGIN_PREFIX ),307 esc_html__( 'Enable count up animation', 'show-current-width' )308 );309 }310 311 /**312 300 * Section 2 HTML. 313 301 * … … 315 303 */ 316 304 public function register_section2_html() { 317 echo esc_html__( 'Setting about display condition', 'show-current-width' );305 echo esc_html__( 'Setting about display', 'show-current-width' ); 318 306 } 319 307 … … 372 360 373 361 /** 362 * Field 2-3 HTML. 363 * 364 * @return void 365 */ 366 public function register_field_animation_show_html() { 367 printf( 368 '<input type="hidden" name="%s_animation_show" value="0" />', 369 esc_attr( ShowCurrentWidth_Core::PLUGIN_PREFIX ) 370 ); 371 printf( 372 '<input type="checkbox" name="%s_animation_show" id="%s_animation_show" value="1" %s />', 373 esc_attr( ShowCurrentWidth_Core::PLUGIN_PREFIX ), 374 esc_attr( ShowCurrentWidth_Core::PLUGIN_PREFIX ), 375 checked( get_option( ShowCurrentWidth_Core::PLUGIN_PREFIX . '_animation_show' ), '1', false ) 376 ); 377 printf( 378 '<label for="%s_animation_show">%s</label>', 379 esc_attr( ShowCurrentWidth_Core::PLUGIN_PREFIX ), 380 esc_html__( 'Enable count up animation', 'show-current-width' ) 381 ); 382 } 383 384 /** 385 * Field 2-4 HTML. 386 * 387 * @return void 388 */ 389 public function register_field_animation_timeout_html() { 390 printf( 391 '<label for="%s_animation_timeout">%s</label> ', 392 esc_attr( ShowCurrentWidth_Core::PLUGIN_PREFIX ), 393 esc_html__( 'Time to display the screen width after it is changed. (millisecond)', 'show-current-width' ) 394 ); 395 printf( 396 '<input type="text" name="%s_animation_timeout" id="%s_animation_timeout" class="small-text" value="%s" /> ms', 397 esc_attr( ShowCurrentWidth_Core::PLUGIN_PREFIX ), 398 esc_attr( ShowCurrentWidth_Core::PLUGIN_PREFIX ), 399 esc_attr( get_option( ShowCurrentWidth_Core::PLUGIN_PREFIX . '_animation_timeout' ) ) 400 ); 401 } 402 403 /** 374 404 * Section 3 HTML. 375 405 * … … 460 490 register_setting( 461 491 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-field1', 462 ShowCurrentWidth_Core::PLUGIN_PREFIX . '_animation_show',463 'esc_attr',464 );465 register_setting(466 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-field1',467 492 ShowCurrentWidth_Core::PLUGIN_PREFIX . '_admin_show', 468 493 'esc_attr', … … 475 500 'sanitize_callback' => array( $this, 'sanitize_array' ), 476 501 ), 502 ); 503 register_setting( 504 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-field1', 505 ShowCurrentWidth_Core::PLUGIN_PREFIX . '_animation_show', 506 'esc_attr', 507 ); 508 register_setting( 509 ShowCurrentWidth_Core::PLUGIN_PREFIX . '-field1', 510 ShowCurrentWidth_Core::PLUGIN_PREFIX . '_animation_timeout', 511 'esc_attr', 477 512 ); 478 513 register_setting( -
show-current-width/trunk/class/class-showcurrentwidth-core.php
r2994893 r3009226 23 23 * Plugin constant. 24 24 */ 25 const PLUGIN_VERSION = '1.2. 3';25 const PLUGIN_VERSION = '1.2.4'; 26 26 const PLUGIN_PREFIX = 'show-current-width'; 27 27 const PLUGIN_PREFIX_DEPRECATED = 'w83-show-current-width'; … … 41 41 const OPTION_DEFAULT_BREAKPOINTS_LIMITWIDTH_MAX = 9999; 42 42 const OPTION_DEFAULT_ANIMATION_SHOW = 1; 43 const OPTION_DEFAULT_ANIMATION_TIMEOUT = 500; 43 44 const OPTION_DEFAULT_ADMIN_SHOW = 0; 44 45 const OPTION_DEFAULT_CONDITION_ROLE = array( 'administrator' ); … … 59 60 'breakpoints_limitwidth_max' => self::OPTION_DEFAULT_BREAKPOINTS_LIMITWIDTH_MAX, 60 61 'animation_show' => self::OPTION_DEFAULT_ANIMATION_SHOW, 62 'animation_timeout' => self::OPTION_DEFAULT_ANIMATION_TIMEOUT, 61 63 'admin_show' => self::OPTION_DEFAULT_ADMIN_SHOW, 62 64 'condition_role' => self::OPTION_DEFAULT_CONDITION_ROLE, … … 173 175 'breakpoints_show' => get_option( self::PLUGIN_PREFIX . '_breakpoints_show' ), 174 176 'animation_show' => get_option( self::PLUGIN_PREFIX . '_animation_show' ), 177 'animation_timeout' => get_option( self::PLUGIN_PREFIX . '_animation_timeout' ), 175 178 ); 176 179 wp_localize_script( self::PLUGIN_PREFIX . '-js', 'ShowCurrentWidthVariables', $pass_to_js ); … … 205 208 foreach ( $breakpoints as $breakpoint_key => $breakpoint_value ) { 206 209 $breakpoints[ $breakpoint_key ] = explode( ',', $breakpoint_value ); 210 if ( count( $breakpoints[ $breakpoint_key ] ) < 4 ) { 211 unset( $breakpoints[ $breakpoint_key ] ); 212 } 207 213 } 208 214 -
show-current-width/trunk/readme.txt
r2994893 r3009226 4 4 Tags: admin,width,developement,design 5 5 Requires at least: 6.2 6 Tested up to: 6.4. 16 Tested up to: 6.4.2 7 7 Requires PHP: 7.4 8 Stable tag: 1.2. 38 Stable tag: 1.2.4 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 21 21 == Changelog == 22 22 23 = 1.2.4 - 2023-12-13 = 24 * Add: Animation timeout 25 * Tested up to WordPress 6.4.2. 26 23 27 = 1.2.3 - 2023-11-13 = 24 * Add: Setting link in adminbar.28 * Add: Setting link in adminbar. 25 29 * Tested up to WordPress 6.4.1. 26 30 -
show-current-width/trunk/uninstall.php
r2973725 r3009226 12 12 // Delete all options if option 'show-current-width_other_uninstall' is checked. 13 13 if ( is_multisite() ) { 14 global $wpdb; 15 $blogid_current = get_current_blog_id(); 16 $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); 17 foreach ( $blogids as $blogid ) { 18 switch_to_blog( $blogid ); 19 if ( '1' === get_option( 'show-current-width_other_uninstall' ) ) { 20 // Delete all options whose key begins with 'show-current-width_'. 21 delete_all_options( wp_load_alloptions( true ) ); 22 } 14 $sites = get_sites(); 15 foreach ( $sites as $site ) { 16 switch_to_blog( $site->blog_id ); 17 delete_all_related_options(); 18 restore_current_blog(); 23 19 } 24 switch_to_blog( $blogid_current );25 20 } else { 26 if ( '1' === get_option( 'show-current-width_other_uninstall' ) ) { 27 // Delete all options whose key begins with 'show-current-width_'. 28 delete_all_options( wp_load_alloptions( true ) ); 29 } 21 delete_all_related_options(); 30 22 } 31 23 32 24 /** 33 25 * Delete all options core. 34 *35 * @param array $alloptions Load all options.36 26 */ 37 function delete_all_options( $alloptions ) { 38 foreach ( $alloptions as $option_key => $option_value ) { 39 if ( false !== strpos( $option_key, 'show-current-width_' ) ) { 40 delete_option( $option_key ); 27 function delete_all_related_options() { 28 $alloptions = wp_load_alloptions( true ); 29 if ( '1' === get_option( 'show-current-width_other_uninstall' ) ) { 30 foreach ( $alloptions as $option_key => $option_value ) { 31 if ( false !== strpos( $option_key, 'show-current-width_' ) ) { 32 delete_option( $option_key ); 33 } 41 34 } 42 35 } -
show-current-width/trunk/w83-show-current-width.php
r2994893 r3009226 4 4 * Plugin URI: 5 5 * Description: This plugin shows a current screen width on WP adminbar. 6 * Version: 1.2. 36 * Version: 1.2.4 7 7 * Requires at least: 6.0 8 * Tested up to: 6.4. 18 * Tested up to: 6.4.2 9 9 * Requires PHP: 7.4 10 10 * Author: web83info <[email protected]>
Note: See TracChangeset
for help on using the changeset viewer.