Changeset 1414345
- Timestamp:
- 05/11/2016 03:31:24 AM (10 years ago)
- Location:
- advanced-categories-widget
- Files:
-
- 28 added
- 5 edited
-
tags/1.1 (added)
-
tags/1.1/README.md (added)
-
tags/1.1/advanced-categories-widget.php (added)
-
tags/1.1/css (added)
-
tags/1.1/css/admin.css (added)
-
tags/1.1/css/front.css (added)
-
tags/1.1/css/index.php (added)
-
tags/1.1/css/widgins.css (added)
-
tags/1.1/inc (added)
-
tags/1.1/inc/class-advanced-categories-widget-fields.php (added)
-
tags/1.1/inc/class-advanced-categories-widget-init.php (added)
-
tags/1.1/inc/class-advanced-categories-widget-utils.php (added)
-
tags/1.1/inc/class-advanced-categories-widget-views.php (added)
-
tags/1.1/inc/class-widget-acw-advanced-categories.php (added)
-
tags/1.1/inc/index.php (added)
-
tags/1.1/inc/widget-form.php (added)
-
tags/1.1/index.php (added)
-
tags/1.1/js (added)
-
tags/1.1/js/admin.js (added)
-
tags/1.1/js/index.php (added)
-
tags/1.1/js/widgins.js (added)
-
tags/1.1/lang (added)
-
tags/1.1/lang/index.php (added)
-
tags/1.1/readme.txt (added)
-
tags/1.1/uninstall.php (added)
-
trunk/css/admin.css (modified) (1 diff)
-
trunk/css/widgins.css (added)
-
trunk/inc/class-advanced-categories-widget-fields.php (modified) (4 diffs)
-
trunk/inc/class-advanced-categories-widget-init.php (modified) (20 diffs)
-
trunk/js/admin.js (modified) (1 diff)
-
trunk/js/widgins.js (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/uninstall.php (added)
Legend:
- Unmodified
- Added
- Removed
-
advanced-categories-widget/trunk/css/admin.css
r1408895 r1414345 1 .widgin-widget-form { margin-bottom: 15px; }2 3 .widgin-section { margin: 5px 0; }4 5 .widgin-section-top {6 background: #f5f5f5 none repeat scroll 0 0;7 border: 1px solid #ddd;8 cursor: pointer;9 }10 11 .widgin-section-top.widgin-active,12 .widgin-section-top:hover {13 background: #f1f1f1 none repeat scroll 0 0;14 border: 1px solid #ccc;15 }16 17 .widgin-section-top.widgin-active {18 background: rgba(0, 0, 0, 0.1);19 }20 21 .widgin-top-action {22 float: right;23 position: relative;24 }25 26 .widgin-action-indicator {27 box-shadow: none;28 color: inherit;29 outline: medium none;30 text-decoration: none;31 }32 33 a.widgin-action-indicator:focus,34 a.widgin-action-indicator:focus::after {35 border: 0 none;36 box-shadow: 0 0 0 0 !important;37 }38 39 a.widgin-action-indicator:after {40 -webkit-font-smoothing: antialiased;41 -moz-osx-font-smoothing: grayscale;42 border: 0 none;43 background: none;44 content: "\f140";45 display: block;46 font: normal 20px/1 dashicons;47 margin-top: 10px;48 margin-right: 10px;49 padding: 1px 2px 1px 0px;50 position: relative;51 right: 0;52 speak: none;53 text-align: center;54 text-decoration: none !important;55 text-indent: 0;56 }57 58 .widgin-section-top.widgin-active a.widgin-action-indicator:after {59 content: "\f142";60 }61 62 .widgin-section-heading {63 font-size: 1em;64 line-height: 1;65 margin: 0;66 overflow: hidden;67 padding: 15px 10px;68 text-overflow: ellipsis;69 white-space: nowrap;70 }71 72 .widgin-fieldset {73 background-color: #fafafa;74 border-width: 0 1px 1px 1px;75 border-color: #e5e5e5;76 border-style: solid;77 padding: 0 10px 10px;78 }79 80 .widgin-preview-container {81 max-width: 378px;82 overflow: hidden;83 width: 100%;84 display: block;85 margin: 1em 0 13px;86 overflow-x: auto;87 overflow-y: hidden !important;88 width: 100%;89 }90 91 #customize-controls .widgin-preview-container { max-width: 210px; }92 93 .widgin-thumb-preview {94 background-color: #eee;95 border: 1px solid #ddd;96 display: block;97 padding: 5px;98 text-align: center;99 }100 .widgin-thumb-preview .dashicons {101 color: #ccc;102 font-size: inherit;103 height: 100%;104 width: 100%;105 }106 107 .widgin-excerpt-preview {108 background-color: #fafafa;109 display: block;110 font-style: italic;111 padding: 6px;112 }113 114 .widgin-excerpt { opacity: 0.8; }115 116 .widgin-thumbsize { display: inline-block; min-width: 50px;}117 118 .widgin-preview-l { display: block; margin-top: 1em; }119 120 .widgin-description {121 margin-bottom: 1em !important;122 padding-bottom: 0 !important;123 }124 125 .widgin-description b {126 color: #444;127 }128 129 .widgin-radio-block {130 display: block !important;131 margin: 3px 0;132 padding: 2px;133 }134 135 .widgin-date-time-text {136 display: inline-block;137 margin-right: 10px;138 min-width: 80px;139 }140 141 .widgin-fieldset label {142 display: inline-block;143 margin-bottom: 1px;144 padding: 1px 0;145 }146 147 .widgin-fieldset h5 {148 font-size: 1em;149 margin: 1150 }151 .widgin-multi-check {152 background: #fff none repeat scroll 0 0;153 border: 1px solid #e5e5e5;154 max-height: 150px;155 overflow: auto;156 margin-bottom: 10px;157 padding: 5px;158 } -
advanced-categories-widget/trunk/inc/class-advanced-categories-widget-fields.php
r1408895 r1414345 416 416 ob_start(); 417 417 ?> 418 <div class="widgin-thumb -size-wrap">418 <div class="widgin-thumbsize-wrap"> 419 419 420 420 <p> 421 421 <label><?php _e( 'Set Custom Size:', 'advanced-categories-widget' ); ?></label><br /> 422 <label class="widgin-thumbsize" for="<?php echo $widget->get_field_id( 'thumb_size_w' ); ?>"> 422 423 <label for="<?php echo $widget->get_field_id( 'thumb_size_w' ); ?>"> 423 424 <?php _e( 'Width:', 'advanced-categories-widget' ); ?> 424 425 </label> … … 427 428 <br /> 428 429 429 <label class="widgin-thumbsize"for="<?php echo $widget->get_field_id( 'thumb_size_h' ); ?>">430 <label for="<?php echo $widget->get_field_id( 'thumb_size_h' ); ?>"> 430 431 <?php _e( 'Height:', 'advanced-categories-widget' ); ?> 431 432 </label> … … 434 435 435 436 <p> 436 <?php _e( 'Preview Custom Size:', ' advanced-categories-widget' ); ?><br />437 <?php _e( 'Preview Custom Size:', 'easy-shuffle-widget' ); ?><br /> 437 438 <span class="widgin-preview-container"> 438 <span class="widgin-thumb -preview" style="font-size: <?php echo absint( $instance['thumb_size_h'] ); ?>px; height:<?php echo absint( $instance['thumb_size_h'] ); ?>px; width:<?php echo absint( $instance['thumb_size_w'] ); ?>px">439 <i class="widgin- thumbdashicons dashicons-format-image"></i>439 <span class="widgin-thumbnail-preview" style="font-size: <?php echo absint( $instance['thumb_size_h'] ); ?>px; height:<?php echo absint( $instance['thumb_size_h'] ); ?>px; width:<?php echo absint( $instance['thumb_size_w'] ); ?>px"> 440 <i class="widgin-preview-image dashicons dashicons-format-image"></i> 440 441 </span> 441 442 </span> … … 495 496 ?> 496 497 497 <p class="widgin-excerpt-size-wrap"> 498 <label for="<?php echo $widget->get_field_id( 'desc_length' ); ?>"> 499 <?php _e( 'Excerpt Length:', 'advanced-categories-widget' ); ?> 500 </label> 501 <input class="widefat widgin-excerpt-length" id="<?php echo $widget->get_field_id( 'desc_length' ); ?>" name="<?php echo $widget->get_field_name( 'desc_length' ); ?>" type="number" step="1" min="0" value="<?php echo absint( $instance['desc_length'] ); ?>" /> 502 503 <label class="widgin-preview-l"> 504 <?php _e( 'Preview:', 'advanced-categories-widget' ); ?> 505 </label> 506 507 <span class="widgin-excerpt-preview"> 508 <span class="widgin-excerpt"><?php echo wp_trim_words( Advanced_Categories_Widget_Utils::sample_description(), 15, '…' ); ?></span> 509 </span> 510 </p> 498 <div class="widgin-excerptsize-wrap"> 499 500 <p> 501 <label for="<?php echo $widget->get_field_id( 'desc_length' ); ?>"> 502 <?php _e( 'Excerpt Length:', 'advanced-categories-widget' ); ?> 503 </label> 504 <input class="widefat widgin-excerpt-length" id="<?php echo $widget->get_field_id( 'desc_length' ); ?>" name="<?php echo $widget->get_field_name( 'desc_length' ); ?>" type="number" step="1" min="0" value="<?php echo absint( $instance['desc_length'] ); ?>" /> 505 </p> 506 507 <p> 508 <?php _e( 'Preview:', 'advanced-categories-widget' ); ?><br /> 509 510 <span class="widgin-preview-container"> 511 <span class="widgin-excerpt-preview"> 512 <span class="widgin-excerpt"><?php echo wp_trim_words( Advanced_Categories_Widget_Utils::sample_description(), 15, '…' ); ?></span> 513 <span class="widgin-excerpt-sample" aria-hidden="true" role="presentation"><?php echo Advanced_Categories_Widget_Utils::sample_description(); ?></span> 514 </span> 515 </span> 516 </p> 517 518 </div> 511 519 512 520 <?php -
advanced-categories-widget/trunk/inc/class-advanced-categories-widget-init.php
r1408895 r1414345 8 8 * @package Advanced_Categories_Widget 9 9 * 10 * @since 1.0 11 * 10 * @since 1.0.0 12 11 */ 13 12 … … 26 25 * Full file path to plugin file 27 26 * 28 * @since 1.0 27 * @since 1.0.0 29 28 * 30 29 * @var string … … 36 35 * URL to plugin 37 36 * 38 * @since 1.0 37 * @since 1.0.0 39 38 * 40 39 * @var string … … 46 45 * Filesystem directory path to plugin 47 46 * 48 * @since 1.0 47 * @since 1.0.0 49 48 * 50 49 * @var string … … 58 57 * e.g. "advanced-categories-widget/advanced-categories-widget.php" 59 58 * 60 * @since 1.0 59 * @since 1.0.0 61 60 * 62 61 * @var string … … 70 69 * @access public 71 70 * 72 * @since 1.0 71 * @since 1.0.0 73 72 * 74 73 * @param string $file Full file path to calling plugin file … … 89 88 * @see Advanced_Categories_Widget_Init::init_admin_scripts_and_styles() 90 89 * @see Advanced_Categories_Widget_Init::store_css_option() 91 * @see Advanced_Categories_Widget_Init::init_ css_option()92 * 93 * @access public 94 * 95 * @since 1.0 90 * @see Advanced_Categories_Widget_Init::init_front_styles() 91 * 92 * @access public 93 * 94 * @since 1.0.0 96 95 */ 97 96 public function init() … … 100 99 $this->init_admin_scripts_and_styles(); 101 100 $this->store_css_option(); 102 $this->init_css_option(); 101 $this->init_front_styles(); 102 $this->init_del_options(); 103 103 } 104 104 … … 111 111 * @access public 112 112 * 113 * @since 1.0 113 * @since 1.0.0 114 114 */ 115 115 public function init_widget() … … 126 126 * @access public 127 127 * 128 * @since 1.0 128 * @since 1.0.0 129 129 */ 130 130 public function register_widget() … … 142 142 * @access public 143 143 * 144 * @since 1.0 145 * 146 * @return void 144 * @since 1.0.0 147 145 */ 148 146 public function init_admin_scripts_and_styles() … … 150 148 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); 151 149 add_action( 'customize_controls_enqueue_scripts', array( $this, 'admin_scripts' ) ); 152 150 153 151 add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) ); 154 152 add_action( 'customize_controls_enqueue_scripts', array( $this, 'admin_styles' ) ); … … 160 158 * Loads js admin scripts 161 159 * 162 * @access public163 * 164 * @ since 1.0165 * 166 * @ return void160 * Note: Only loads on customize.php or widgets.php 161 * 162 * @access public 163 * 164 * @since 1.0.0 167 165 */ 168 166 public function admin_scripts( $hook ) … … 180 178 }; 181 179 182 wp_enqueue_script( 'acatw-admin-scripts', $this->url . 'js/admin.js', array( 'jquery' ), '', true ); 183 184 $sample_description = Advanced_Categories_Widget_Utils::sample_description(); 185 186 wp_localize_script( 187 'acatw-admin-scripts', 188 'acatw_script_vars', 189 array( 190 'sample_description' => sprintf( __( '%s' ), $sample_description ) 191 ) 180 wp_enqueue_script( 'widgins', $this->url . 'js/widgins.js', array( 'jquery' ), '', true ); 181 182 #wp_enqueue_script( 'acatw-admin-scripts', $this->url . 'js/admin.js', array( 'widgins' ), '', true ); 183 } 184 185 186 /** 187 * Prints out css styles in admin head 188 * 189 * Note: Only loads on customize.php or widgets.php 190 * 191 * @access public 192 * 193 * @since 1.0.0 194 */ 195 public function admin_styles() 196 { 197 wp_enqueue_style( 198 'widgins', 199 $this->url . 'css/widgins.css', 200 array(), 201 '1.0.0', 202 'all' 192 203 ); 193 } 194 195 196 /** 197 * Prints out css styles in admin head 198 * 199 * Note: Only loads on customize.php or widgets.php 200 * 201 * @access public 202 * 203 * @since 1.0 204 * 205 * @return void 206 */ 207 public function admin_styles() 208 { 209 wp_enqueue_style( 'acatw-admin-styles', $this->url . 'css/admin.css', null, null ); 204 wp_enqueue_style( 205 'acatw-admin-styles', 206 $this->url . 'css/admin.css', 207 array( 'widgins' ), 208 '1.0.0', 209 'all' 210 ); 210 211 } 211 212 … … 218 219 * @access public 219 220 * 220 * @since 1.0 221 * @since 1.0.0 221 222 */ 222 223 public function store_css_option() … … 239 240 * @access public 240 241 * 241 * @since 1.0 242 * 243 * @param object $widget Widget|WP_Customize_Setting instance; depends on calling filter.244 * @param array $instanceCurrent widget settings pre-save245 * @param array $new_instance New settings for instance input by the user via WP_Widget::form().246 * @param array $old_instance Old settings for instance.242 * @since 1.0.0 243 * 244 * @param object $widget Widget|WP_Customize_Setting instance; depends on calling filter. 245 * @param array $instance Current widget settings pre-save 246 * @param array $new_instance New settings for instance input by the user via WP_Widget::form(). 247 * @param array $old_instance Old settings for instance. 247 248 */ 248 249 public function maybe_store_css( $widget, $instance = array(), $new_instance = array(), $old_instance = array() ) 249 250 { 250 251 $current_filter = current_filter(); 251 252 252 253 // The Customizer doesn't pass an $instance array like widgets.php does 253 254 if( 'customize_save_widget_advanced-categories-widget' === $current_filter ){ 254 255 $instance = $widget->post_value(); 255 } 256 256 } 257 257 258 // see if any widget instance IDs are stored 258 259 $widgets = get_option( 'acatw_use_css' ); … … 272 273 return; 273 274 } 274 275 275 276 // get the widget instance ID 276 277 $widget_id = $instance['widget_id']; … … 292 293 * @access public 293 294 * 294 * @since 1.0 295 */ 296 public function init_ css_option()295 * @since 1.0.0 296 */ 297 public function init_front_styles() 297 298 { 298 299 add_action( 'wp_enqueue_scripts', array( $this, 'front_styles' ) ); … … 307 308 * @access public 308 309 * 309 * @since 1.0 310 * @since 1.0.0 310 311 * 311 312 * @return void … … 327 328 328 329 if( $enqueue ) { 329 wp_enqueue_style( 'acatw-css-defaults', $this->url . 'css/front.css', null, null ); 330 } 331 330 wp_enqueue_style( 'eshuflw-css-defaults', $this->url . 'css/front.css', null, null ); 331 } 332 } 333 334 335 /** 336 * Calls to delete widget options on widget delete 337 * 338 * @see Advanced_Categories_Widget_Init::delete_widget_options() 339 * 340 * @access public 341 * 342 * @since 1.0.0 343 */ 344 public function init_del_options() 345 { 346 add_action( 'delete_widget', array( $this, 'delete_widget_options' ), 0, 3 ); 347 } 348 349 350 /** 351 * Unsticks/removes widget options when widget is deleted 352 * 353 * @access public 354 * 355 * @since 1.0.0 356 * 357 * @param string $widget_id ID of the widget marked for deletion. 358 * @param string $sidebar_id ID of the sidebar the widget was deleted from. 359 * @param string $id_base ID base for the widget. 360 */ 361 public function delete_widget_options( $widget_id = 0, $sidebar_id = '', $id_base = '' ) 362 { 363 // if there's no widget, bail 364 if( ! $widget_id ) { 365 return; 366 } 367 368 global $wp_registered_widgets; 369 370 if ( ! isset( $wp_registered_widgets[$widget_id] ) ) { 371 return; 372 } 373 374 Advanced_Categories_Widget_Utils::unstick_css( $widget_id ); 332 375 } 333 376 -
advanced-categories-widget/trunk/js/admin.js
r1408895 r1414345 1 1 /** 2 * Plugin functions file.2 * Plugin js file. 3 3 * 4 * @package Advanced_Categories_Widget 5 * @since 1.0.0 4 6 */ 5 if( "undefined"==typeof jQuery )throw new Error( "Advanced Categories Widget's javaScript requires jQuery" );6 7 (function ( $ ) {8 9 'use strict';10 11 /**12 * Thumbnail Preview13 *14 * @since15 */16 function change_thumb_div( e ){17 var $field = $( e.currentTarget );18 var $thumb_wrap = $field.closest( '.widgin-thumb-size-wrap' );19 var $thumb_div = $thumb_wrap.find( '.widgin-thumb-preview' );20 21 if( $thumb_div.length ) {22 var thumb = $( '.widgin-thumb', $thumb_div );23 var width = parseInt ( ( $.trim( $( '.widgin-thumb-width', $thumb_wrap ).val() ) * 1 ) + 0 );24 var height = parseInt ( ( $.trim( $( '.widgin-thumb-height', $thumb_wrap ).val() ) * 1 ) + 0 );25 26 $thumb_div.css( {27 'height' : height + 'px',28 'width' : width + 'px'29 } );30 thumb.css( { 'font-size' : height + 'px' } );31 }32 33 return;34 };35 36 // Change thumb size when form field changes37 $( '#customize-controls, #wpcontent' ).on( 'change', '.widgin-thumb-size', function ( e ) {38 change_thumb_div( e );39 return;40 });41 42 // Change thumb size as user types43 $( '#customize-controls, #wpcontent' ).on( 'keyup', '.widgin-thumb-size', function ( e ) {44 setTimeout( function(){45 change_thumb_div( e );46 }, 300 );47 return;48 });49 50 51 52 53 /**54 * Excerpt Preview55 *56 * @since 1.057 */58 function change_excerpt_size( e ) {59 var $field = $( e.currentTarget );60 var acatw_excerpt_div = $field.closest( '.widgin-excerpt-size-wrap' ).find( '.widgin-excerpt' );61 var size = parseInt ( ( $.trim( $field.val() ) * 1 ) + 0 );62 63 if( acatw_excerpt_div.length ) {64 var words = acatw_script_vars.sample_description.match(/\S+/g).length;65 var trimmed = '';66 if ( words > size ) {67 trimmed = acatw_script_vars.sample_description.split(/\s+/, size).join(" ");68 } else {69 trimmed = acatw_script_vars.sample_description;70 }71 72 acatw_excerpt_div.html( trimmed + "…" );73 74 //acatw_excerpt_div.html( acatw_script_vars.sample_description.substring( 0, size) + "…" );75 }76 }77 78 function update_excerpt_size( event, widget ){79 var $field = widget.find( '.widgin-excerpt-length' );80 var acatw_excerpt_div = $field.closest( '.widgin-excerpt-size-wrap' ).find( '.widgin-excerpt' );81 var size = parseInt ( ( $.trim( $field.val() ) * 1 ) + 0 );82 83 if( acatw_excerpt_div.length ) {84 var words = acatw_script_vars.sample_description.match(/\S+/g).length;85 var trimmed = '';86 if ( words > size ) {87 trimmed = acatw_script_vars.sample_description.split(/\s+/, size).join(" ");88 } else {89 trimmed = acatw_script_vars.sample_description;90 }91 92 acatw_excerpt_div.html( trimmed + "…" );93 94 //acatw_excerpt_div.html( acatw_script_vars.sample_description.substring( 0, size) + "…" );95 }96 }97 98 $( document ).on( 'widget-updated', update_excerpt_size );99 100 // Change excerpt size when form field changes101 $( '#customize-controls, #wpcontent' ).on( 'change', '.widgin-excerpt-length', function ( e ) {102 change_excerpt_size( e );103 return;104 });105 106 // Change excerpt size as user types107 $( '#customize-controls, #wpcontent' ).on( 'keyup', '.widgin-excerpt-length', function ( e ) {108 setTimeout( function(){109 change_excerpt_size( e );110 }, 300 );111 return;112 });113 114 115 116 /**117 * Toggle settings accordions118 *119 * @since 1.0120 */121 function widgin_close_accordions( widget ){122 var $sections = widget.find('.widgin-section');123 var $first_section = $sections.first();124 125 $first_section.addClass('expanded').find('.widgin-section-top').addClass('widgin-active');126 $first_section.siblings('.widgin-section').find('.widgin-settings').hide();127 }128 129 function widgin_on_form_update( event, widget ) {130 widgin_close_accordions( widget );131 }132 133 $( document ).on( 'widget-added widget-updated', widgin_on_form_update );134 135 $( '#widgets-right .widget:has(.widgin-widget-form)' ).each( function () {136 widgin_close_accordions( $( this ) );137 } );138 139 140 $( '#widgets-right, #accordion-panel-widgets' ).on( 'click', '.widgin-section-top', function( e ){141 var $header = $( this );142 var $section = $header.closest( '.widgin-section' );143 var $fieldset_id = $header.data( 'fieldset' );144 var $target_fieldset = $( 'fieldset[data-fieldset-id="' + $fieldset_id + '"]', $section );145 var $content = $section.find( '.widgin-settings' )146 147 $header.toggleClass( 'widgin-active' );148 $target_fieldset.addClass( 'targeted');149 $content.slideToggle( 300, function () {150 $section.toggleClass( 'expanded' );151 });152 });153 154 155 }(jQuery) ); -
advanced-categories-widget/trunk/readme.txt
r1408895 r1414345 1 1 === Advanced Categories Widget === 2 2 Contributors: dbmartin 3 Tags: category, categories, category-widget, categories-widget, post-category, post-categories, widget3 Tags: category, categories, category-widget, categories-widget, post-category, post-categories, 4 4 Requires at least: 4.4 5 5 Tested up to: 4.5 6 Stable tag: 1. 06 Stable tag: 1.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 74 74 == Changelog == 75 75 76 = 1.1.0 = 77 * Updated admin js to use Widgins core js 78 * Updated admin css to use Widgins core css 79 * Added functionality to remove widget option when widget instance is deleted. 80 * Added uninstall.php 81 76 82 = 1.0 = 77 83 * Initial release
Note: See TracChangeset
for help on using the changeset viewer.