Plugin Directory

Changeset 2138574


Ignore:
Timestamp:
08/13/2019 01:58:39 AM (7 years ago)
Author:
sebaxtian
Message:

Permitir componente con múltiples páginas

Location:
papier-mache
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • papier-mache/trunk/inc/settings/custom-controls/multiple-checkbox.php

    r1922542 r2138574  
    11<?php
    2 // File: multiselect-dropdown.php
     2namespace PapierMache\Controls;
    33
    44if (class_exists('WP_Customize_Control')) {
     
    66    * Class to create a custom multiselect dropdown control
    77    */
    8     class Multiple_Checkbox_Custom_Control extends WP_Customize_Control
     8    class Multiple_Checkbox_Custom_Control extends \WP_Customize_Control
    99    {
    1010        /**
     
    1515        public function enqueue()
    1616        {
    17             wp_enqueue_script('multiple-checkbox');
    18             wp_enqueue_style('multiple-checkbox');
     17            wp_enqueue_script('ppm_multiple-checkbox', plugin_dir_url(__FILE__)."multiple-checkbox.js", array(), PPM_V);
     18            wp_enqueue_style('ppm_multiple-checkbox', plugin_dir_url(__FILE__)."multiple-checkbox.css", array(), PPM_V);
    1919        }
    2020
     
    5151    <?php
    5252        }
     53
     54        public static function sanitize($values)
     55        {
     56            $multi_values = !is_array($values) ? explode(',', $values) : $values;
     57
     58            return !empty($multi_values) ? array_map('sanitize_text_field', $multi_values) : false;
     59        }
    5360    }
    5461}
  • papier-mache/trunk/inc/settings/custom-controls/multiple-select.php

    r1922542 r2138574  
    11<?php
    2 // File: multiple-select.php
     2namespace PapierMache\Controls;
    33
    44if (class_exists('WP_Customize_Control')) {
    5     /**
    6     * Class to create a custom multiselect dropdown control
    7     */
    8     class Multiple_Select_Custom_Control extends WP_Customize_Control
    9     {
    10         /**
    11         * Render the content on the theme customizer page
    12         */
    13         public $type = 'multiple-select';
     5    /**
     6    * Class to create a custom multiselect dropdown control
     7    */
     8    class Multiple_Select_Custom_Control extends \WP_Customize_Control
     9    {
     10        /**
     11        * Render the content on the theme customizer page
     12        */
     13        public $type = 'multiple-select';
     14        public $all_options_text = false;
     15        public $all_options_value = 0;
     16        public $rows = 5;
    1417
    15         public function render_content() {
    16             if ( empty( $this->choices ) )
    17                 return;
     18        public function enqueue()
     19        {
     20            wp_enqueue_script('ppm_multiple-select', plugin_dir_url(__FILE__)."multiple-select.js", array(), PLA_TAX_V);
     21            wp_enqueue_style('ppm_multiple-select', plugin_dir_url(__FILE__)."multiple-select.css", array(), PLA_TAX_V);
     22        }
    1823
    19             //Size
    20             $size = 5;
    21             if(isset($this->input_attrs['size'])) {
    22                 $size = $this->input_attrs['size'];
    23             }
    24        ?>
    25            <label>
    26                <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
    27                <select <?php $this->link(); ?> multiple="multiple" size="<?php echo $size; ?>">
    28                    <?php
    29                        foreach ( $this->choices as $value => $label ) {
    30                            $selected = ( in_array( $value, $this->value() ) ) ? selected( 1, 1, false ) : '';
    31                            echo '<option value="' . esc_attr( $value ) . '"' . $selected . '>' . $label . '</option>';
    32                        }
    33                    ?>
    34                </select>
    35            </label>
    36        <?php }
    37     }
     24        public function render_content()
     25        {
     26            if (empty($this->choices)) {
     27                return;
     28            }
     29
     30            $values = $this->value();
     31            if(!is_array($values)) {
     32                $values = explode(',', $this->value());
     33            }
     34
     35            ?>
     36            <div class="multiple_select_control">
     37                <?php if(!empty($this->label)) : ?>
     38                    <span class="customize-control-title"><?php echo $this->label; ?></span>
     39                <?php endif; ?>
     40
     41                <?php if(!empty($this->description)) : ?>
     42                    <span class="description customize-control-description"><?php echo $this->description; ?></span>
     43                <?php endif; ?>
     44
     45                <?php if(!empty($this->all_options_value)) : ?>
     46                    <?php echo $this->all_options_text; ?>
     47                    <input type='checkbox' data-value="<?php echo $this->all_options_value; ?>" class="all_options" <?php echo checked( in_array($this->all_options_value, $values) ); ?>>
     48                <?php endif; ?>
     49
     50                <select multiple="multiple" <?php if( in_array($this->all_options_value, $values) ) : ?>disabled<?php endif; ?> size="<?php echo $this->rows; ?>">
     51                    <?php foreach( $this->choices as $key => $label) : ?>
     52                        <option value="<?php echo $key; ?>" <?php echo selected( in_array($key, $values) ); ?>><?php echo $label; ?></option>
     53                    <?php endforeach; ?>
     54                </select>
     55
     56                <input type="hidden" <?php $this->link(); ?> value="<?php echo implode( ',', $values ); ?>" />
     57            </div>
     58
     59            <?php
     60        }
     61
     62        public static function sanitize($values)
     63        {
     64            $multi_values = !is_array($values) ? explode(',', $values) : $values;
     65
     66            return !empty($multi_values) ? array_map('sanitize_text_field', $multi_values) : false;
     67        }
     68    }
    3869}
  • papier-mache/trunk/inc/settings/custom-controls/palette.php

    r1922542 r2138574  
    11<?php
     2namespace PapierMache\Controls;
     3
    24if (! class_exists('WP_Customize_Control')) {
    35    return null;
     
    79 * Class to create a custom date picker
    810 */
    9 class Palette_Custom_Control extends WP_Customize_Control
     11class Palette_Custom_Control extends \WP_Customize_Control
    1012{
    1113    public $type = 'palette';
     
    1618    public function enqueue()
    1719    {
    18         wp_enqueue_style('palette');
    19         wp_enqueue_script('ppm-customize');
     20        wp_enqueue_script('ppm_palette', plugin_dir_url(__FILE__)."palette.js", array(), PPM_V);
     21        wp_enqueue_style('ppm_palette', plugin_dir_url(__FILE__)."palette.css", array(), PPM_V);
    2022    }
    2123
  • papier-mache/trunk/inc/settings/papier-mache.php

    r2037457 r2138574  
    4545            'default' => array( ),
    4646            'type' => 'option', // or 'theme_mod'
    47             'sanitize_callback' => 'sanitize_multiple_checkbox',
     47            'sanitize_callback' => '\PapierMache\Controls\Multiple_Checkbox_Custom_Control::sanitize',
    4848            'capability' => 'activate_plugins'
    4949        )
     
    5252    //Opción para definir el campo para 'max number of confetti'
    5353    $wp_customize->add_control(
    54         new Multiple_Checkbox_Custom_Control(
     54        new \PapierMache\Controls\Multiple_Checkbox_Custom_Control(
    5555            $wp_customize, 'ppm_props', array(
    5656                'label' => __( 'Type of confetti', 'papier-mache' ),
     
    8080    //Opción para definir el campo para 'colores'
    8181    $wp_customize->add_control(
    82         new Palette_Custom_Control(
     82        new \PapierMache\Controls\Palette_Custom_Control(
    8383            $wp_customize, 'ppm_colors', array(
    8484                'label' => __('Colors', 'papier-mache'),
     
    145145    );
    146146
    147     //Lostado de roles
     147    //Listado de roles
    148148    global $wp_roles;
    149149    $roles = $wp_roles->get_names();
     
    156156    //Opción para definir el campo para perfiles que no podrán vr el confeti
    157157    $wp_customize->add_control(
    158         new Multiple_Checkbox_Custom_Control(
     158        new \PapierMache\Controls\Multiple_Checkbox_Custom_Control(
    159159            $wp_customize, 'ppm_disabled_roles', array(
    160160                'label' => __( 'Roles that can not see the confetti', 'papier-mache' ),
     
    167167    );
    168168
    169     //Declarar el campo para 'mostrar_en'
    170     $wp_customize->add_setting(
    171         'papier_mache[show_in]',
    172         array(
    173             'type' => 'option', // or 'theme_mod'
    174             'capability'     => 'edit_theme_options'
    175         )
    176     );
    177 
    178     //Páginas
     169    //Dönde se mostrará el papel maché
     170    $wp_customize->add_setting(
     171        'papier_mache[show_in]',
     172        array(
     173            'default' => array( ),
     174            'type' => 'option', // or 'theme_mod'
     175            'sanitize_callback' => '\PapierMache\Controls\Multiple_Select_Custom_Control::sanitize',
     176            'capability' => 'activate_plugins'
     177        )
     178    );
     179
     180    //Páginas
    179181    $pages = array(
    180         '-1' => __( '&mdash; All site &mdash;', 'papier-mache' ),
     182        // '-1' => __( '&mdash; All site &mdash;', 'papier-mache' ),
    181183        '0' => __( '&mdash; Homepage &mdash;', 'papier-mache' ),
    182184    );
     
    197199    }
    198200
    199 
    200     //Opción para definir el campo para 'conocenos' de facebook
    201     $wp_customize->add_control(
    202         'papier_mache[show_in]',
    203         array(
    204             'type' => 'select',
    205             'label'      => __( 'Show in', 'papier-mache' ),
    206             'section'    => 'papier-mache',
    207             'settings'   => 'papier_mache[show_in]',
    208             'choices' => $pages
    209         )
    210     );
     201    //Opción para definir el campo para páginas
     202    $wp_customize->add_control(
     203        new \PapierMache\Controls\Multiple_Select_Custom_Control(
     204            $wp_customize,
     205            'papier_mache[show_in]',
     206            array(
     207                'label' => __('Display', 'papier-mache'),
     208                // 'description' => __('Description', 'papier-mache'),
     209                'section' => 'papier-mache',
     210                'settings' => 'papier_mache[show_in]',
     211                'type'     => 'multiple-select',
     212                'choices' => $pages,
     213                'all_options_value' => -1,
     214                'all_options_text' => __('In all site', 'papier-mache'),
     215                'rows' => 9
     216            )
     217        )
     218    );
    211219
    212220}
  • papier-mache/trunk/languages/papier-mache-es_ES.po

    r2037457 r2138574  
    55"Project-Id-Version: Confetti\n"
    66"Report-Msgid-Bugs-To: \n"
    7 "POT-Creation-Date: 2019-02-22 18:19-0500\n"
    8 "PO-Revision-Date: 2019-02-22 18:20-0500\n"
     7"POT-Creation-Date: 2019-08-12 19:10-0500\n"
     8"PO-Revision-Date: 2019-08-12 19:11-0500\n"
    99"Last-Translator: Juan Sebastián Echeverry <baxtian.echeverry@gmail.com>\n"
    1010"Language-Team: Juan Sebastián Echeverry <baxtian.echeverry@gmail.com>\n"
     
    1616"X-Poedit-Basepath: .\n"
    1717"Plural-Forms: nplurals=2; plural=n != 1;\n"
    18 "X-Generator: Poedit 2.1.1\n"
     18"X-Generator: Poedit 2.2.1\n"
    1919"X-Poedit-SourceCharset: UTF-8\n"
    2020"X-Poedit-SearchPath-0: ..\n"
    2121
    22 #: ../inc/settings/custom-controls/palette.php:30
     22#: ../inc/settings/custom-controls/palette.php:32
    2323msgid "Add color"
    2424msgstr "Agregar color"
    2525
    26 #: ../inc/settings/custom-controls/palette.php:30
     26#: ../inc/settings/custom-controls/palette.php:32
    2727msgid "Change color"
    2828msgstr "Cambiar color"
    2929
    30 #: ../inc/settings/custom-controls/palette.php:30
     30#: ../inc/settings/custom-controls/palette.php:32
    3131msgid "Reset palette"
    3232msgstr "Reiniciar paleta"
     
    8080msgstr "Perfiles que no verán el confeti"
    8181
    82 #: ../inc/settings/papier-mache.php:180
    83 msgid "&mdash; All site &mdash;"
    84 msgstr "&mdash; Todo el sitio &mdash;"
    85 
    86 #: ../inc/settings/papier-mache.php:181
     82#: ../inc/settings/papier-mache.php:183
    8783msgid "&mdash; Homepage &mdash;"
    8884msgstr "&mdash; Página de inicio &mdash;"
    8985
    90 #: ../inc/settings/papier-mache.php:205
    91 msgid "Show in"
    92 msgstr "Mostrar en"
     86#: ../inc/settings/papier-mache.php:207
     87msgid "Display"
     88msgstr "Desplegar"
     89
     90#: ../inc/settings/papier-mache.php:208
     91msgid "Description"
     92msgstr "Descripción"
     93
     94#: ../inc/settings/papier-mache.php:214
     95msgid "In all site"
     96msgstr "En todo el sitio"
     97
     98#~ msgid "&mdash; All site &mdash;"
     99#~ msgstr "&mdash; Todo el sitio &mdash;"
     100
     101#~ msgid "Show in"
     102#~ msgstr "Mostrar en"
    93103
    94104#~ msgid "Confetti"
  • papier-mache/trunk/languages/papier-mache.pot

    r2037457 r2138574  
    66"Project-Id-Version: Confetti\n"
    77"Report-Msgid-Bugs-To: \n"
    8 "POT-Creation-Date: 2019-02-22 18:19-0500\n"
     8"POT-Creation-Date: 2019-08-12 19:10-0500\n"
    99"PO-Revision-Date: 2014-10-09 21:36-0500\n"
    1010"Last-Translator: Juan Sebastián Echeverry <baxtian.echeverry@gmail.com>\n"
     
    1717"X-Poedit-Basepath: .\n"
    1818"Plural-Forms: nplurals=2; plural=n != 1;\n"
    19 "X-Generator: Poedit 2.1.1\n"
     19"X-Generator: Poedit 2.2.1\n"
    2020"X-Poedit-SourceCharset: UTF-8\n"
    2121"X-Poedit-SearchPath-0: ..\n"
    2222
    23 #: ../inc/settings/custom-controls/palette.php:30
     23#: ../inc/settings/custom-controls/palette.php:32
    2424msgid "Add color"
    2525msgstr ""
    2626
    27 #: ../inc/settings/custom-controls/palette.php:30
     27#: ../inc/settings/custom-controls/palette.php:32
    2828msgid "Change color"
    2929msgstr ""
    3030
    31 #: ../inc/settings/custom-controls/palette.php:30
     31#: ../inc/settings/custom-controls/palette.php:32
    3232msgid "Reset palette"
    3333msgstr ""
     
    8181msgstr ""
    8282
    83 #: ../inc/settings/papier-mache.php:180
    84 msgid "&mdash; All site &mdash;"
    85 msgstr ""
    86 
    87 #: ../inc/settings/papier-mache.php:181
     83#: ../inc/settings/papier-mache.php:183
    8884msgid "&mdash; Homepage &mdash;"
    8985msgstr ""
    9086
    91 #: ../inc/settings/papier-mache.php:205
    92 msgid "Show in"
     87#: ../inc/settings/papier-mache.php:207
     88msgid "Display"
    9389msgstr ""
     90
     91#: ../inc/settings/papier-mache.php:208
     92msgid "Description"
     93msgstr ""
     94
     95#: ../inc/settings/papier-mache.php:214
     96msgid "In all site"
     97msgstr ""
  • papier-mache/trunk/papier-mache.php

    r2041834 r2138574  
    6767    wp_enqueue_style('admin-confetti');
    6868
    69     //Para el multiple-checkbox
    70     wp_register_script('multiple-checkbox', plugin_dir_url(__FILE__)."scripts/multiple-checkbox.js", array( 'jquery' ), PPM_V);
    71     wp_register_style('multiple-checkbox', plugin_dir_url(__FILE__)."styles/multiple-checkbox.css", array( ), PPM_V);
    72 
    7369    //Para el customize
    7470    wp_register_style('palette', plugin_dir_url(__FILE__)."styles/palette.css", array(), PPM_V);
     
    107103    //Es una página habilitada
    108104    //Si es -1 es en toda la página
    109     if($show_in == -1 ) {
     105    if(in_array('-1', $show_in) ) {
    110106        //Está habilitado en todas las páginas
    111     } elseif($show_in == 0 ) {
     107    } elseif(in_array('0', $show_in) ) {
    112108        //Solo en home
    113109        if(!is_home() && !is_front_page()) {
     
    115111        }
    116112    } else {
    117         //Otra página
    118         if(!is_page( $show_in )) {
     113        if(!is_array($show_in) || count($show_in) == 0) { //¿Hay alguna página?
     114            $habilitado = false;
     115        } elseif(!is_page( $show_in )) { //¿Es esta la página?
    119116            $habilitado = false;
    120117        }
  • papier-mache/trunk/readme.txt

    r2037457 r2138574  
    44Requires at least: 4.1
    55Tested up to: 4.9.8
    6 Stable tag: 0.5
     6Stable tag: 0.6
    77
    88Show the world your site has something to celebrate.
Note: See TracChangeset for help on using the changeset viewer.