Plugin Directory

Changeset 586917


Ignore:
Timestamp:
08/17/2012 05:04:18 PM (14 years ago)
Author:
jasie
Message:

added options for custom widget support

just the html for the plugin options - not working yet

Location:
widget-pagination/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • widget-pagination/trunk/inc/wgpag-options.php

    r586897 r586917  
    4242                <p><?php _e("If you want a pagination, enter the designated items per page for each widget. Otherwise, leave it emtpy.", 'wgpag') ?></p>
    4343
    44                 <table class="form-table">
     44                <table class="form-table" id="items_per_page">
    4545                    <?php
    4646                    foreach ($this->widgets as $w => $name) :
     
    6161                        </tr>
    6262                    <?php endforeach; ?>
     63
     64                    <tr>
     65                        <th for="">
     66                            <?php _e("Custom Widgets", 'wgpag') ?>
     67                        </th>
     68                        <td>
     69                            <select id="wgpag-customwidget" name="wgpag-customwidget">
     70                                <option value=""><?php _e("please chose", 'wgpag') ?></option>
     71                                <option value="widget_views">WP PostViews</option>
     72                            </select>
     73                        </td>
     74                    </tr>
    6375                </table>
    6476            </div><!-- /postbox -->
  • widget-pagination/trunk/js/admin.js

    r500612 r586917  
    2323    });
    2424
     25    // Add custom widgets
     26    $('#wgpag-customwidget').change(function() {
     27        // clone a row with a standard widget
     28        var customWidget = jQuery('#items_per_page tr').first().clone();
     29
     30        //console.log(customwidget);
     31
     32        // append it
     33        jQuery('#items_per_page').append(customWidget);
     34
     35        var widgetName = $(this).find("option:selected").text();
     36        var widgetID   = $(this).val();
     37
     38        // change label and value and id and name
     39        customWidget.find('label').html(widgetName); //LABEL text
     40        customWidget.find('input').attr('name', 'wgpag-items_per_page_' + widgetID); //INPUT name
     41        customWidget.find('input').attr('id', 'wgpag-items_per_page_' + widgetID); //INPUT id
     42        customWidget.find('input').val(''); //empty value
     43        customWidget.find('span').remove(); //remove hint
     44
     45        // disable selected option and reset dropdown
     46        $(this).find("option:selected").attr("disabled","disabled");
     47        $(this).val('');
     48
     49    });
     50
    2551});
Note: See TracChangeset for help on using the changeset viewer.