Plugin Directory

Changeset 1414345


Ignore:
Timestamp:
05/11/2016 03:31:24 AM (10 years ago)
Author:
dbmartin
Message:
  • Updated admin js to use Widgins core js
  • Updated admin css to use Widgins core css
  • Added functionality to remove widget option when widget instance is deleted.
  • Added uninstall.php
Location:
advanced-categories-widget
Files:
28 added
5 edited

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: 1
    150 }
    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  
    416416        ob_start();
    417417        ?>
    418         <div class="widgin-thumb-size-wrap">
     418        <div class="widgin-thumbsize-wrap">
    419419
    420420            <p>
    421421                <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' ); ?>">
    423424                    <?php _e( 'Width:', 'advanced-categories-widget' ); ?>
    424425                </label>
     
    427428                <br />
    428429
    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' ); ?>">
    430431                    <?php _e( 'Height:', 'advanced-categories-widget' ); ?>
    431432                </label>
     
    434435
    435436            <p>
    436                 <?php _e( 'Preview Custom Size:', 'advanced-categories-widget' ); ?><br />
     437                <?php _e( 'Preview Custom Size:', 'easy-shuffle-widget' ); ?><br />
    437438                <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-thumb dashicons 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>
    440441                    </span>
    441442                </span>
     
    495496        ?>
    496497
    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, '&hellip;' ); ?></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, '&hellip;' ); ?></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>
    511519
    512520        <?php
  • advanced-categories-widget/trunk/inc/class-advanced-categories-widget-init.php

    r1408895 r1414345  
    88 * @package Advanced_Categories_Widget
    99 *
    10  * @since 1.0
    11  *
     10 * @since 1.0.0
    1211 */
    1312
     
    2625     * Full file path to plugin file
    2726     *
    28      * @since 1.0
     27     * @since 1.0.0
    2928     *
    3029     * @var string
     
    3635     * URL to plugin
    3736     *
    38      * @since 1.0
     37     * @since 1.0.0
    3938     *
    4039     * @var string
     
    4645     * Filesystem directory path to plugin
    4746     *
    48      * @since 1.0
     47     * @since 1.0.0
    4948     *
    5049     * @var string
     
    5857     * e.g. "advanced-categories-widget/advanced-categories-widget.php"
    5958     *
    60      * @since 1.0
     59     * @since 1.0.0
    6160     *
    6261     * @var string
     
    7069     * @access public
    7170     *
    72      * @since 1.0
     71     * @since 1.0.0
    7372     *
    7473     * @param string $file Full file path to calling plugin file
     
    8988     * @see Advanced_Categories_Widget_Init::init_admin_scripts_and_styles()
    9089     * @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
    9695     */
    9796    public function init()
     
    10099        $this->init_admin_scripts_and_styles();
    101100        $this->store_css_option();
    102         $this->init_css_option();
     101        $this->init_front_styles();
     102        $this->init_del_options();
    103103    }
    104104
     
    111111     * @access public
    112112     *
    113      * @since 1.0
     113     * @since 1.0.0
    114114     */
    115115    public function init_widget()
     
    126126     * @access public
    127127     *
    128      * @since 1.0
     128     * @since 1.0.0
    129129     */
    130130    public function register_widget()
     
    142142     * @access public
    143143     *
    144      * @since 1.0
    145      *
    146      * @return void
     144     * @since 1.0.0
    147145     */
    148146    public function init_admin_scripts_and_styles()
     
    150148        add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
    151149        add_action( 'customize_controls_enqueue_scripts', array( $this, 'admin_scripts' ) );
    152        
     150
    153151        add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
    154152        add_action( 'customize_controls_enqueue_scripts', array( $this, 'admin_styles' ) );
     
    160158     * Loads js admin scripts
    161159     *
    162      * @access public
    163      *
    164      * @since 1.0
    165      *
    166      * @return void
     160     * Note: Only loads on customize.php or widgets.php
     161     *
     162     * @access public
     163     *
     164     * @since 1.0.0
    167165     */
    168166    public function admin_scripts( $hook )
     
    180178        };
    181179
    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'
    192203        );
    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        );
    210211    }
    211212
     
    218219     * @access public
    219220     *
    220      * @since 1.0
     221     * @since 1.0.0
    221222     */
    222223    public function store_css_option()
     
    239240     * @access public
    240241     *
    241      * @since 1.0
    242      *
    243      * @param object $widget Widget|WP_Customize_Setting instance; depends on calling filter.
    244      * @param array $instance Current widget settings pre-save
    245      * @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.
    247248     */
    248249    public function maybe_store_css( $widget, $instance = array(), $new_instance = array(), $old_instance = array() )
    249250    {
    250251        $current_filter = current_filter();
    251                
     252
    252253        // The Customizer doesn't pass an $instance array like widgets.php does
    253254        if( 'customize_save_widget_advanced-categories-widget' === $current_filter ){
    254255            $instance = $widget->post_value();
    255         }   
    256    
     256        }
     257
    257258        // see if any widget instance IDs are stored
    258259        $widgets = get_option( 'acatw_use_css' );
     
    272273            return;
    273274        }
    274        
     275
    275276        // get the widget instance ID
    276277        $widget_id = $instance['widget_id'];
     
    292293     * @access public
    293294     *
    294      * @since 1.0
    295      */
    296     public function init_css_option()
     295     * @since 1.0.0
     296     */
     297    public function init_front_styles()
    297298    {
    298299        add_action( 'wp_enqueue_scripts', array( $this, 'front_styles' ) );
     
    307308     * @access public
    308309     *
    309      * @since 1.0
     310     * @since 1.0.0
    310311     *
    311312     * @return void
     
    327328
    328329        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 );
    332375    }
    333376
  • advanced-categories-widget/trunk/js/admin.js

    r1408895 r1414345  
    11/**
    2  * Plugin functions file.
     2 * Plugin js file.
    33 *
     4 * @package Advanced_Categories_Widget
     5 * @since 1.0.0
    46 */
    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 Preview
    13      *
    14      * @since
    15      */
    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 changes
    37     $( '#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 types
    43     $( '#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 Preview
    55      *
    56      * @since 1.0
    57      */
    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 + "&hellip;" );
    73            
    74             //acatw_excerpt_div.html( acatw_script_vars.sample_description.substring( 0, size) + "&hellip;" );
    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 + "&hellip;" );
    93            
    94             //acatw_excerpt_div.html( acatw_script_vars.sample_description.substring( 0, size) + "&hellip;" );
    95         }
    96     }
    97    
    98     $( document ).on( 'widget-updated', update_excerpt_size );
    99 
    100     // Change excerpt size when form field changes
    101     $( '#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 types
    107     $( '#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 accordions
    118      *
    119      * @since 1.0
    120      */
    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  
    11=== Advanced Categories Widget ===
    22Contributors: dbmartin
    3 Tags: category, categories, category-widget, categories-widget, post-category, post-categories, widget
     3Tags: category, categories, category-widget, categories-widget, post-category, post-categories,
    44Requires at least: 4.4
    55Tested up to: 4.5
    6 Stable tag: 1.0
     6Stable tag: 1.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7474== Changelog ==
    7575
     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
    7682= 1.0 =
    7783* Initial release
Note: See TracChangeset for help on using the changeset viewer.