Plugin Directory

Changeset 1772382


Ignore:
Timestamp:
11/21/2017 02:35:55 PM (8 years ago)
Author:
jasie
Message:

huge restructuring of plugin - separate directories for admin and public

Location:
widget-pagination/trunk
Files:
33 added
5 deleted
1 edited
1 copied
2 moved

Legend:

Unmodified
Added
Removed
  • widget-pagination/trunk/README.txt

    r1772381 r1772382  
    1 === Widget Paginator ===
     1=== Widget Pagination ===
    22Contributors: jasie, larsu
    33Donate link: http://wgpag.jana-sieber.de/donate/
    44Tags: pagination, paging, paginator, widget, categories, archives, blogroll, links, bookmarks, recent posts, recent comments, meta, pages
    5 Requires at least: 2.9
    6 Tested up to: 3.4
    7 Stable tag: 0.8
     5Requires at least: 3.4
     6Tested up to: 4.8.3
     7Stable tag: 1.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1313== Description ==
    1414
    15 Currently, you can chose the widget, which is to be paginated, and set the items to show per widget page individually. You can also set the number of pages to show and change the labels of the previous/next link, as well as let the widget pages turn automatically. Finally, you can change the default styling to match your theme.
     15Currently, you can chose the widget, which is to be paginated, and set the items to show per widget page individually.
     16You can also set the number of pages to show and change the labels of the previous/next link, as well as let the widget
     17pages turn automatically. Finally, you can change the default styling to match your theme.
    1618
    1719**Plugin's Official Site**
     
    136138
    137139== Upgrade Notice ==
     140
     141= 1.0 =
     142todo
  • widget-pagination/trunk/uninstall.php

    r537490 r1772382  
    11<?php
     2
    23/**
    3  * Uninstalls the Widget Paginator options when an uninstall has been
    4  * requested from the WordPress admin plugin dashboard
     4 * Fired when the plugin is uninstalled.
    55 *
    6  * see notes @http://codex.wordpress.org/Function_Reference/register_uninstall_hook
     6 * When populating this file, consider the following flow
     7 * of control:
     8 *
     9 * - This method should be static
     10 * - Check if the $_REQUEST content actually is the plugin name
     11 * - Run an admin referrer check to make sure it goes through authentication
     12 * - Verify the output of $_GET makes sense
     13 * - Repeat with other user roles. Best directly by using the links/query string parameters.
     14 * - Repeat things for multisite. Once for a single site in the network, once sitewide.
     15 *
     16 * This file may be updated more in future version of the Boilerplate; however, this is the
     17 * general skeleton and outline for how the file should work.
     18 *
     19 * @link       https://wordpress.org/support/profile/jasie
     20 * @since      1.0.0
     21 *
     22 * @package    Widget_Pagination
    723 */
    824
    9 delete_option('wgpag_options');
     25// If uninstall not called from WordPress, then exit.
     26if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
     27    exit;
     28}
     29
     30if (!defined('WGPAG_NAME')) {
     31    define('WGPAG_NAME', trim(dirname(plugin_basename(__FILE__)), '/'));
     32}
     33
     34// Delete stored options created by the plugin
     35delete_option( WGPAG_NAME ); // options created via form inputs post
     36//delete_option('wgpag_options');
    1037?>
  • widget-pagination/trunk/widget-pagination.php

    r1772381 r1772382  
    11<?php
    2 /*
    3 Plugin Name: Widget Paginator
    4 Plugin URI: http://wgpag.jana-sieber.de/
    5 Description: This plugin lets you add a styleable pagination for the widgets Archives, Categories, Links, Meta, Pages, Recent Posts and Recent Comments.
    6 Version: 0.8
    7 Author: [jasie] and [larsu]
    8 Author URI: http://wordpress.org/support/profile/jasie
    9 License: GPL2
    10 Text Domain: widget_pagination
    11 Domain Path: /lang
    12 */
    132
    14 /*  Copyright 2011-2012  Jana Sieber <jana@jana-sieber.de>
    15                          Lars Uebernickel <lars@uebernic.de>
     3/**
     4 * The plugin bootstrap file
     5 *
     6 * This file is read by WordPress to generate the plugin information in the plugin
     7 * admin area. This file also includes all of the dependencies used by the plugin,
     8 * registers the activation and deactivation functions, and defines a function
     9 * that starts the plugin.
     10 *
     11 * @link              https://wordpress.org/support/profile/jasie
     12 * @since             1.0.0
     13 * @package           Widget_Pagination
     14 *
     15 * @wordpress-plugin
     16 * Plugin Name:       Widget Pagination
     17 * Plugin URI:        http://wgpag.jana-sieber.de/
     18 * Description:       This plugin lets you add a styleable pagination for the widgets Archives, Categories, Links, Meta, Pages, Recent Posts and Recent Comments.
     19 * Version:           1.0.0
     20 * Author:            Jana Sieber
     21 * Author URI:        https://wordpress.org/support/profile/jasie
     22 * License:           GPL-2.0+
     23 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
     24 * Text Domain:       wgpag
     25 * Domain Path:       /languages
     26 */
    1627
    17     This program is free software; you can redistribute it and/or modify
    18     it under the terms of the GNU General Public License, version 2, as
    19     published by the Free Software Foundation.
    20 
    21     This program is distributed in the hope that it will be useful,
    22     but WITHOUT ANY WARRANTY; without even the implied warranty of
    23     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    24     GNU General Public License for more details.
    25 
    26     You should have received a copy of the GNU General Public License
    27     along with this program; if not, write to the Free Software
    28     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    29 */
    30 ?>
    31 <?php
    32 define("WGPAG_VERSION", "0.8");
    33 
    34 if (!class_exists('WidgetPagination')) {
    35 
    36     class WidgetPagination {
    37 
    38         private $widgets = array(
    39             'widget_links'           => 'Links',
    40             'widget_categories'      => 'Categories',
    41             'widget_archive'         => 'Archive',
    42             'widget_recent_entries'  => 'Recent Posts',
    43             'widget_recent_comments' => 'Recent Comments',
    44             'widget_meta'            => 'Meta',
    45             'widget_pages'           => 'Pages');
    46 
    47         private $styles = array(
    48             'color'            => 'Text Colour',
    49             'border-color'     => 'Border Colour',
    50             'background-color' => 'Background Colour',
    51             'font-size'        => 'Font Size');
    52 
    53         function __construct() {
    54 
    55             // In dashboard
    56             if ( is_admin() ) {
    57                 add_action('admin_init', array($this, 'wgpag_admin_init')); //register_setting
    58                 add_action('admin_init', array($this, 'wgpag_load_plugin_textdomain'));
    59                 add_action('admin_menu', array($this, 'wgpag_admin_menu'));
    60                 register_activation_hook(__FILE__, array(&$this, 'initialize_defaults')); //registers a plugin function to be run when the plugin is activated
    61 
    62                 // Widget Pagination update options
    63                 if ( isset($_POST['wgpag']) && $_POST['wgpag']=='true' ) {
    64 
    65                     $options = get_option('wgpag_options');
    66 
    67                     // Update db options with the matching post value
    68                     foreach ($_POST as $name => $value) {
    69                         if (preg_match('/^wgpag-(items_per_page_.*)/', $name, $matches))
    70                                 $options[$matches[1]] = $value;
    71                         else if (preg_match('/^wgpag-(item_style_.*)/', $name, $matches))
    72                                 $options[$matches[1]] = $value;
    73                         else if (preg_match('/^wgpag-(cur_item_style_.*)/', $name, $matches))
    74                                 $options[$matches[1]] = $value;
    75                         else if (preg_match('/^wgpag-(hover_item_style_.*)/', $name, $matches))
    76                                 $options[$matches[1]] = $value;
    77                         else if (preg_match('/^wgpag-(pagination_style_.*)/', $name, $matches))
    78                                 $options[$matches[1]] = $value;
    79                     }
    80 
    81                     if (!empty($_POST['wgpag-list_item_style']))
    82                         $options['list_item_style'] = $_POST['wgpag-list_item_style'];
    83 
    84                     if (!empty($_POST['wgpag-pag_option_ptsh']))
    85                         $options['pag_option_ptsh'] = $_POST['wgpag-pag_option_ptsh'];
    86                     if (!empty($_POST['wgpag-pag_option_prev']))
    87                         $options['pag_option_prev'] = $_POST['wgpag-pag_option_prev'];
    88                     if (!empty($_POST['wgpag-pag_option_next']))
    89                         $options['pag_option_next'] = $_POST['wgpag-pag_option_next'];
    90                     if (!empty($_POST['wgpag-pag_option_prevnext_threshold']))
    91                         $options['pag_option_prevnext_threshold'] = $_POST['wgpag-pag_option_prevnext_threshold'];
    92                     if (!empty($_POST['wgpag-pag_option_hor_align']))
    93                         $options['pag_option_hor_align'] = $_POST['wgpag-pag_option_hor_align'];
    94                     if (isset($_POST['wgpag-pag_option_margin_top']))
    95                         $options['pag_option_margin_top'] = $_POST['wgpag-pag_option_margin_top'];
    96                     if (isset($_POST['wgpag-pag_option_margin_bottom']))
    97                         $options['pag_option_margin_bottom'] = $_POST['wgpag-pag_option_margin_bottom'];
    98                     if (isset($_POST['wgpag-pag_option_autoscroll_speed']))
    99                         $options['pag_option_autoscroll_speed'] = $_POST['wgpag-pag_option_autoscroll_speed'];
    100 
    101                     update_option('wgpag_options', $options);
    102                 }
    103             }
    104 
    105             // Not in dashboard
    106             if ( !is_admin() ) {
    107                 add_action('init', array($this, 'wgpag_page_init') );
    108             }
    109         }
    110 
    111         /**
    112          * Initialize defaults
    113          * @author Jana Sieber
    114          */
    115         function initialize_defaults() {
    116             $options = array();
    117 
    118             // Elements per page
    119             foreach ($this->widgets as $w => $name)
    120                 $options['items_per_page_' . $w] = '';
    121 
    122             // Pagination options
    123             $options['pag_option_ptsh'] = '7';
    124             $options['pag_option_prev'] = '<';
    125             $options['pag_option_next'] = '>';
    126             $options['pag_option_hor_align']     = 'center';
    127             $options['pag_option_margin_top']    = '0.5em';
    128             $options['pag_option_margin_bottom'] = '';
    129             $options['pag_option_autoscroll_speed'] = 0;
    130 
    131             // Styling options
    132             foreach ($this->styles as $s => $name) {
    133                 $options['item_style_' . $s]       = '';
    134                 $options['cur_item_style_' . $s]   = '';
    135                 $options['hover_item_style_' . $s] = '';
    136             }
    137             $options['item_style_border-color']         = '#F1F1F1';
    138             $options['cur_item_style_background-color'] = '#F1F1F1';
    139             $options['list_item_style']                 = '';
    140 
    141             // override defaults with potential old options
    142             $current_options = get_option('wgpag_options');
    143             if ($current_options)
    144                 $options = array_merge($options, $current_options);
    145 
    146             // ... and options from a previous release
    147             $old_option_names = array(
    148                 'wgpag-items_per_page_links',
    149                 'wgpag-items_per_page_categories',
    150                 'wgpag-items_per_page_archive',
    151                 'wgpag-items_per_page_archives',
    152                 'wgpag-items_per_page_recent_entries',
    153                 'wgpag-items_per_page_recent_comments',
    154                 'wgpag-items_per_page_meta',
    155                 'wgpag-items_per_page_pages',
    156                 'wgpag-items_per_page_widget_links',
    157                 'wgpag-items_per_page_widget_categories',
    158                 'wgpag-items_per_page_widget_archive',
    159                 'wgpag-items_per_page_widget_archives',
    160                 'wgpag-items_per_page_widget_recent_entries',
    161                 'wgpag-items_per_page_widget_recent_comments',
    162                 'wgpag-items_per_page_widget_meta',
    163                 'wgpag-items_per_page_widget_pages',
    164                 'wgpag-pag_option_ptsh',
    165                 'wgpag-pag_option_prev',
    166                 'wgpag-pag_option_next',
    167                 'wgpag-pag_option_hor_align',
    168                 'wgpag-pag_option_margin_top',
    169                 'wgpag-pag_option_margin_bottom',
    170                 'wgpag-cur_item_style_color',
    171                 'wgpag-cur_item_style_border-color',
    172                 'wgpag-cur_item_style_background-color',
    173                 'wgpag-cur_item_style_font-size',
    174                 'wgpag-item_style_color',
    175                 'wgpag-item_style_border-color',
    176                 'wgpag-item_style_background-color',
    177                 'wgpag-item_style_font-size',
    178                 'wgpag-hover_item_style_color',
    179                 'wgpag-hover_item_style_border-color',
    180                 'wgpag-hover_item_style_background-color',
    181                 'wgpag-hover_item_style_font-size',
    182                 'wgpag-list_item_style');
    183 
    184             foreach ($old_option_names as $option_name) {
    185                 $val = get_option($option_name);
    186                 if ($val !== false) {
    187                     $options[substr($option_name, 6)] = $val;
    188                     delete_option($option_name);
    189                 }
    190             }
    191 
    192             update_option('wgpag_options', $options);
    193         }
    194 
    195         /**
    196          * Initialize WgPag
    197          * @author Jana Sieber
    198          */
    199         function wgpag_page_init() {
    200             wp_register_script('wgpag', plugins_url('/js/wgpag.js',__FILE__),
    201                                array('jquery'), WGPAG_VERSION );
    202             wp_register_style('wgpag', plugins_url('/css/wgpag.css',__FILE__),
    203                               '', WGPAG_VERSION );
    204 
    205             wp_register_style('wgpag-options', plugins_url('/css/wgpag-options.css',__FILE__),
    206                               'wgpag' );
    207 
    208             add_filter('style_loader_tag', array($this, 'wgpag_replace_option_style'), 10, 2);
    209             wp_enqueue_style('wgpag');
    210             wp_enqueue_style('wgpag-options');
    211             wp_enqueue_script('wgpag');
    212             wp_enqueue_script('jquery');
    213 
    214             $options = get_option('wgpag_options');
    215 
    216             // send to js
    217             $widgets = array();
    218             foreach ($this->widgets as $w => $name) {
    219                 $widgets[] = array(
    220                     'selector' => '.' . $w,
    221                     'count'    => (int)$options['items_per_page_' . $w]
    222                 );
    223             }
    224 
    225             $options = array(
    226                 'widgets'            => $widgets,
    227                 'pages_to_show'      => $options['pag_option_ptsh'],
    228                 'prev_label'         => $options['pag_option_prev'],
    229                 'next_label'         => $options['pag_option_next'],
    230                 'prevnext_threshold' => $options['pag_option_prevnext_threshold'],
    231                 'hor_align'          => $options['pag_option_hor_align'],
    232                 'autoscroll_speed'   => $options['pag_option_autoscroll_speed']);
    233 
    234             wp_localize_script('wgpag', 'wgpag_options',
    235                 array('l10n_print_after' => 'wgpag_options = ' . json_encode($options) . ';'));
    236         }
    237 
    238         /**
    239          * Initialize WgPag admin (register settings)
    240          * @author Jana Sieber
    241          */
    242         function wgpag_admin_init() {
    243             wp_register_style('colorpicker',
    244                     plugins_url('/css/jquery.colorpicker.css',__FILE__));
    245             wp_register_style('wgpag-style',
    246                     plugins_url('/css/admin.css',__FILE__),
    247                               '', WGPAG_VERSION );
    248             wp_deregister_script('colorpicker');
    249             wp_register_script('colorpicker',
    250                     plugins_url('/js/jquery.colorpicker.js',__FILE__),
    251                     array('jquery'));
    252             wp_register_script('wgpag-script',
    253                     plugins_url('/js/admin.js', __FILE__),
    254                     array('jquery','colorpicker'), WGPAG_VERSION );
    255             load_plugin_textdomain( 'wgpag', false, 'widget_pagination/lang' );
    256             //XXX register_setting( 'widget_pagination', 'new_option_name' );
    257         }
    258 
    259         /**
    260          * Initialize WgPag admin panel
    261          * @author Jana Sieber
    262          */
    263         function wgpag_admin_menu() {
    264             $page = add_submenu_page('themes.php',
    265                                      'Widget Paginator',
    266                                      'Widget Paginator',
    267                                      'manage_options',
    268                                      __FILE__,
    269                                      array($this, 'wgpag_options_page'));
    270             add_action('admin_print_styles-'.$page,  array($this, 'wgpag_admin_styles'));
    271             add_action('admin_print_scripts-'.$page, array($this, 'wgpag_admin_scripts'));
    272         }
    273 
    274         /**
    275          * Initialize internationalisation
    276          * @author Jana Sieber
    277          */
    278         function wgpag_load_plugin_textdomain() {
    279             load_plugin_textdomain( 'wgpag', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/');
    280         }
    281 
    282         /**
    283          * Load WgPag admin styles
    284          * @author Jana Sieber
    285          */
    286         function wgpag_admin_styles() {
    287             wp_enqueue_style('wgpag-style');
    288             wp_enqueue_style('colorpicker');
    289         }
    290 
    291         /**
    292          * Load WgPag admin scripts
    293          * @author Jana Sieber
    294          */
    295         function wgpag_admin_scripts() {
    296             wp_enqueue_script('wgpag-script');
    297         }
    298 
    299         /**
    300          * Provide markup for WgPag settings page
    301          * @author Jana Sieber
    302          */
    303         function wgpag_options_page() {
    304             $options = get_option('wgpag_options');
    305             require_once ('inc/wgpag-options.php');
    306         }
    307 
    308         /**
    309          *
    310          * @return type
    311          */
    312         private function item_css () {
    313             $selectors = array(
    314                 'item_style'       => 'a',
    315                 'hover_item_style' => 'a:hover',
    316                 'cur_item_style'   => '.br-current'
    317             );
    318             $css = '';
    319             $options = get_option('wgpag_options');
    320             foreach($selectors as $name => $selector) {
    321                 $css .= ".br-pagination $selector { ";
    322                 foreach ($this->styles as $s => $title) {
    323                     $optval = $options["${name}_$s"];
    324                     if (!empty($optval))
    325                         $css .= "$s: $optval; ";
    326                 }
    327                 $css .= "}";
    328             }
    329 
    330             $pagcss = '';
    331 
    332             $borders = array ('top', 'bottom', 'left', 'right');
    333             foreach ($borders as $border) {
    334                 $borderstyle = $options['pagination_style_border_color_' . $border];
    335                 if ($borderstyle)
    336                     $pagcss .= "border-$border: 1px solid $borderstyle;";
    337             }
    338 
    339             $pagbg = $options['pagination_style_background_color'];
    340             if ($pagbg)
    341                 $pagcss .= "background-color: $pagbg;";
    342 
    343             $horalign = $options['pag_option_hor_align'];
    344             $pagcss .= "text-align: $horalign;";
    345 
    346             $margintop = $options['pag_option_margin_top'];
    347             $pagcss .= "margin-top: $margintop;";
    348 
    349             $marginbottom = $options['pag_option_margin_bottom'];
    350             $pagcss .= "margin-bottom: $marginbottom;";
    351 
    352             $css .= ".br-pagination { $pagcss; }";
    353 
    354             $liststyle = $options['list_item_style'];
    355             $css .= ".widget-container li { list-style-type: $liststyle; }";
    356 
    357             return $css;
    358         }
    359 
    360         /**
    361          * Replace wgpag-options css with an inline style which pulls
    362          * the style from the options database.
    363          * @author Lars Uebernickel
    364          */
    365         function wgpag_replace_option_style ($tag, $handle) {
    366             if ($handle == 'wgpag-options') {
    367                 return '<style type="text/css">' . $this->item_css() . '</style>';
    368             }
    369             else
    370                 return $tag;
    371         }
    372     }
     28// If this file is called directly, abort.
     29if ( ! defined( 'WPINC' ) ) {
     30    die;
    37331}
    37432
    375 // Init Widget Pagination
    376 $wgpag = new WidgetPagination();
     33define("WGPAG_VERSION", "1.0.0");
     34
     35if (!defined('WGPAG_NAME')) {
     36    define('WGPAG_NAME', trim(dirname(plugin_basename(__FILE__)), '/'));
     37}
     38
     39/**
     40 * The code that runs during plugin activation.
     41 * This action is documented in includes/class-widget-pagination-activator.php
     42 */
     43function activate_widget_pagination() {
     44    require_once plugin_dir_path( __FILE__ ) . 'includes/class-widget-pagination-activator.php';
     45    Widget_Pagination_Activator::activate();
     46}
     47
     48/**
     49 * The code that runs during plugin deactivation.
     50 * This action is documented in includes/class-widget-pagination-deactivator.php
     51 */
     52function deactivate_widget_pagination() {
     53    require_once plugin_dir_path( __FILE__ ) . 'includes/class-widget-pagination-deactivator.php';
     54    Widget_Pagination_Deactivator::deactivate();
     55}
     56
     57register_activation_hook( __FILE__, 'activate_widget_pagination' );
     58register_deactivation_hook( __FILE__, 'deactivate_widget_pagination' );
     59
     60/**
     61 * The core plugin class that is used to define internationalization,
     62 * admin-specific hooks, and public-facing site hooks.
     63 */
     64require plugin_dir_path( __FILE__ ) . 'includes/class-widget-pagination.php';
     65
     66/**
     67 * Begins execution of the plugin.
     68 *
     69 * Since everything within the plugin is registered via hooks,
     70 * then kicking off the plugin from this point in the file does
     71 * not affect the page life cycle.
     72 *
     73 * @since    1.0.0
     74 */
     75function run_widget_pagination() {
     76
     77    $plugin = new Widget_Pagination();
     78    $plugin->run();
     79
     80}
     81run_widget_pagination();
    37782?>
Note: See TracChangeset for help on using the changeset viewer.