Plugin Directory

Changeset 3469313


Ignore:
Timestamp:
02/25/2026 10:21:00 AM (4 weeks ago)
Author:
babbardel
Message:

Security hardening and WPCS compliance v2.0.0 — fixes CVE-2023-40205 and 13 additional security issues

Location:
pixtypes
Files:
68 edited
1 copied

Legend:

Unmodified
Added
Removed
  • pixtypes/tags/2.0.0/README.md

    r1744797 r3469313  
    139139```
    140140
    141 === Old Change Log  ===
    142 
    143 1.3.5
    144 Improved the multicheck field
    145 
    146 1.3.2
    147 WordPress 4.3 compatibility
    148 Fixed Sticky buttons for the PixBuilder field
    149 
    150 1.3.1
    151 
    152 Allow portfolio to be a jetpack compatible type
    153 Small fixes to the gallery field
    154 
    155 1.2.10
    156 
    157 Show / Hide options bug fix
    158 
    159 1.2.9
    160 
    161 Gmap pins added
    162 
    163 1.2.6
    164 
    165 Builder field added
    166 Support for wp 4.0
    167 Small fixes
    168 
    169 1.2.2
    170 
    171 Small fixes to metaboxes
    172 
    173 1.2.1
    174 
    175 Github Updater slug fix
    176 And small fixes...
    177 
    178 1.2.0
    179 
    180 Ajax Update
    181 Gallery Metabox works now even if there is no wp-editor on page
    182 And small fixes...
    183 
    184 1.1.0
    185 
    186 Add admin panel
    187 Fixes
    188 
    189 1.0.0 - Here we go
     141## Development Notes
     142Gulp 3.x doesn't work on Node.js 12.x or above. You have to downgrade Node.js to 11.5.0
     143```
     144nvm install 11.15.0
     145nvm use 11.15.0 # Just in case it didn't automatically select the 11.15.0 as the main node.
     146nvm uninstall 13.1.0
     147npm rebuild node-sass
     148```
  • pixtypes/tags/2.0.0/class-pixtypes.php

    r2127881 r3469313  
    106106         * Ajax Callbacks - only for logged in users
    107107         */
    108         add_action( 'wp_ajax_unset_pixtypes', array( &$this, 'ajax_unset_pixtypes' ) );
     108        add_action( 'wp_ajax_unset_pixtypes', array( $this, 'ajax_unset_pixtypes' ) );
    109109    }
    110110
     
    649649    function ajax_unset_pixtypes() {
    650650        $result = array( 'success' => false, 'msg' => 'Incorrect nonce' );
     651
     652        if ( ! current_user_can( 'manage_options' ) ) {
     653            wp_send_json_error( 'Unauthorized' );
     654        }
     655
    651656        if ( ! wp_verify_nonce( $_POST['_ajax_nonce'], 'unset_pixtype' ) ) {
    652             echo json_encode( $result );
     657            echo wp_json_encode( $result );
    653658            die();
    654659        }
    655660
    656661        if ( isset( $_POST['theme_slug'] ) ) {
    657             $key     = $_POST['theme_slug'];
     662            $key     = sanitize_key( $_POST['theme_slug'] );
    658663            $options = get_option( 'pixtypes_settings' );
    659664            if ( isset( $options['themes'][ $key ] ) ) {
    660665                unset( $options['themes'][ $key ] );
    661666                update_option( 'pixtypes_settings', $options );
    662                 $result['msg']     = 'Settings for ' . ucfirst( $key ) . ' have been cleaned up!';
     667                $result['msg']     = 'Settings for ' . esc_html( ucfirst( $key ) ) . ' have been cleaned up!';
    663668                $result['success'] = true;
    664669            }
    665670        }
    666671
    667         echo json_encode( $result );
     672        echo wp_json_encode( $result );
    668673        exit;
    669674    }
  • pixtypes/tags/2.0.0/core/bootstrap.php

    r1115891 r3469313  
    11<?php defined('ABSPATH') or die;
    22
    3     // ensure EXT is defined
    4     if ( ! defined('EXT')) {
    5         define('EXT', '.php');
     3    // ensure PIXTYPES_EXT is defined
     4    if ( ! defined('PIXTYPES_EXT')) {
     5        define('PIXTYPES_EXT', '.php');
    66    }
    77
    88    $basepath = dirname(__FILE__).DIRECTORY_SEPARATOR;
    9     require $basepath.'core'.EXT;
     9    require $basepath.'core'.PIXTYPES_EXT;
    1010
    1111    // load classes
  • pixtypes/tags/2.0.0/core/classes/HTMLTag.php

    r1744797 r3469313  
    5757                if ( ! empty($value)) {
    5858                    if (is_array($value)) {
    59                         $htmlvalue = implode(' ', $value);
     59                        $htmlvalue = esc_attr( implode(' ', $value) );
    6060                        $attr_segments[] = "$key=\"$htmlvalue\"";
    6161                    }
    6262                    else { // value is not an array
    63                         $attr_segments[] = "$key=\"$value\"";
     63                        $attr_segments[] = "$key=\"" . esc_attr( $value ) . "\"";
    6464                    }
    6565                }
    6666                else { // empty html tag; ie. no value html tag
    67                     $attr_segments[] = $key;
     67                    $attr_segments[] = esc_attr( $key );
    6868                }
    6969            }
  • pixtypes/tags/2.0.0/core/classes/Processor.php

    r1744797 r3469313  
    155155        $plugin_cleanup = $this->meta->get('cleanup', array());
    156156
     157        // Only process expected fields — discard any extra $_POST keys.
     158        $allowed_keys = array_keys( $this->fields->metadata_array() );
     159        $input = array_intersect_key( $input, array_flip( $allowed_keys ) );
     160
    157161        foreach ($this->fields->metadata_array() as $key => $field) {
    158162
  • pixtypes/tags/2.0.0/core/classes/forms/FormField.php

    r1744797 r3469313  
    7070            foreach ($template_paths as $path) {
    7171                $dirpath = rtrim($path, '\\/').DIRECTORY_SEPARATOR;
    72                 if (file_exists($dirpath.$pattern.EXT)) {
    73                     return $this->render_template_file($dirpath.$pattern.EXT);
     72                if (file_exists($dirpath.$pattern.PIXTYPES_EXT)) {
     73                    return $this->render_template_file($dirpath.$pattern.PIXTYPES_EXT);
    7474                }
    7575            }
  • pixtypes/tags/2.0.0/core/core.php

    r1275567 r3469313  
    2121    static function defaults() {
    2222        if (self::$defaults === null) {
    23             self::$defaults = include self::corepath().'defaults'.EXT;
     23            self::$defaults = include self::corepath().'defaults'.PIXTYPES_EXT;
    2424        }
    2525
     
    269269
    270270        foreach ($priority_list as $file => $priority) {
    271             if (strpos($file, EXT)) {
     271            if (strpos($file, PIXTYPES_EXT)) {
    272272                require $file;
    273273            }
  • pixtypes/tags/2.0.0/core/tests/bootstrap.php

    r1115891 r3469313  
    11<?php defined('ABSPATH') or die;
    22
    3     // ensure EXT is defined
    4     if ( ! defined('EXT')) {
    5         define('EXT', '.php');
     3    // ensure PIXTYPES_EXT is defined
     4    if ( ! defined('PIXTYPES_EXT')) {
     5        define('PIXTYPES_EXT', '.php');
    66    }
    77
     
    99
    1010    $basepath = realpath('..').DIRECTORY_SEPARATOR;
    11     require $basepath.'bootstrap'.EXT;
     11    require $basepath.'bootstrap'.PIXTYPES_EXT;
  • pixtypes/tags/2.0.0/core/views/form-partials/fields/color.php

    r1115891 r3469313  
    1010
    1111    $type = 'color';
    12     include 'text'.EXT;
     12    include 'text'.PIXTYPES_EXT;
    1313
  • pixtypes/tags/2.0.0/core/views/form-partials/fields/counter.php

    r1115891 r3469313  
    3737    <input <?php echo $field->htmlattributes($attrs) ?> class="small-text" />
    3838<?php else: # standard field ?>
    39     <label for="<?php echo $idname ?>">
     39    <label for="<?php echo esc_attr( $idname ) ?>">
    4040        <input <?php echo $field->htmlattributes($attrs) ?> />
    41         <?php echo $label ?>
     41        <?php echo esc_html( $label ) ?>
    4242    </label>
    4343<?php endif; ?>
  • pixtypes/tags/2.0.0/core/views/form-partials/fields/group.php

    r1115891 r3469313  
    2222            $fieldexample = $field->getmeta('group-example', null);
    2323            $fieldnote = $field->getmeta('group-note', null); ?>
    24                 <div class="field" <?php if ( $fieldconfig['type'] == 'group' ) echo 'id="' . $fieldname . '"'; ?> >
     24                <div class="field" <?php if ( $fieldconfig['type'] == 'group' ) echo 'id="' . esc_attr( $fieldname ) . '"'; ?> >
    2525                    <?php echo $field->render();
    2626                    if ( ! empty($fieldnote)): ?>
    27                         <span class="field-note"><?php echo $fieldnote ?></span>
     27                        <span class="field-note"><?php echo esc_html( $fieldnote ) ?></span>
    2828                    <?php endif; ?>
    2929                </div>
  • pixtypes/tags/2.0.0/core/views/form-partials/fields/postbox.php

    r1115891 r3469313  
    1212<div class="postbox">
    1313    <div class="handlediv" title="Click to toggle"><br></div>
    14     <h3 class="hndle"><span><?php echo $label ?></span></h3>
     14    <h3 class="hndle"><span><?php echo esc_html( $label ) ?></span></h3>
    1515
    1616    <div class="inside">
     
    2424            $show_group = $field->getmeta('show_group', null);  ?>
    2525
    26             <div class="row" <?php if ( $fieldconfig['type'] == 'group' ) echo 'id="' . $fieldname . '"'; ?>>
     26            <div class="row" <?php if ( $fieldconfig['type'] == 'group' ) echo 'id="' . esc_attr( $fieldname ) . '"'; ?>>
    2727                <?php if ( ! empty($fielddesc)): ?>
    28                     <div class="field-desc"><?php echo $fielddesc ?></div>
     28                    <div class="field-desc"><?php echo esc_html( $fielddesc ) ?></div>
    2929                <?php endif;
    3030                echo $field->render();
    3131                if ( ! empty($fieldnote)): ?>
    32                     <span class="note"><?php echo $fieldnote ?></span>
     32                    <span class="note"><?php echo esc_html( $fieldnote ) ?></span>
    3333                <?php endif; ?>
    3434            </div>
  • pixtypes/tags/2.0.0/core/views/form-partials/fields/select.php

    r1115891 r3469313  
    2424    <?php foreach ($this->getmeta('options', array()) as $key => $label): ?>
    2525        <option <?php if ($key == $selected): ?>selected<?php endif; ?>
    26                 value="<?php echo $key ?>">
    27             <?php echo $label ?>
     26                value="<?php echo esc_attr( $key ) ?>">
     27            <?php echo esc_html( $label ) ?>
    2828        </option>
    2929    <?php endforeach; ?>
  • pixtypes/tags/2.0.0/core/views/form-partials/fields/switch.php

    r1115891 r3469313  
    5555    <div class="switch">
    5656        <input <?php echo $field->htmlattributes($attrs) ?> />
    57         <label for="<?php echo $idname ?>"><?php echo $processed_label ?></label>
     57        <label for="<?php echo esc_attr( $idname ) ?>"><?php echo wp_kses_post( $processed_label ) ?></label>
    5858    </div>
    5959<?php else: # rendering != 'inline' ?>
    60     <label for="<?php echo $idname ?>">
     60    <label for="<?php echo esc_attr( $idname ) ?>">
    6161        <input <?php echo $field->htmlattributes($attrs) ?> />
    62         <?php echo $processed_label ?>
     62        <?php echo wp_kses_post( $processed_label ) ?>
    6363    </label>
    6464<?php endif; ?>
  • pixtypes/tags/2.0.0/core/views/form-partials/fields/tabular-group.php

    r1115891 r3469313  
    1212<tr valign="top">
    1313    <th scope="row">
    14         <?php echo $label ?>
     14        <?php echo esc_html( $label ) ?>
    1515    </th>
    1616    <td>
     
    1818
    1919            <legend class="screen-reader-text">
    20                 <span><?php echo $label ?></span>
     20                <span><?php echo esc_html( $label ) ?></span>
    2121            </legend>
    2222
     
    2828            <?php if ($field->hasmeta('note')): ?>
    2929                <small>
    30                     <em>(<?php echo $field->getmeta('note') ?>)</em>
     30                    <em>(<?php echo esc_html( $field->getmeta('note') ) ?>)</em>
    3131                </small>
    3232            <?php endif; ?>
  • pixtypes/tags/2.0.0/core/views/form-partials/fields/text.php

    r1115891 r3469313  
    2424<?php elseif ($rendering == 'blocks'):  ?>
    2525<div class="text">
    26     <label id="<?php echo $name ?>"><?php echo $label ?></label>
     26    <label id="<?php echo esc_attr( $name ) ?>"><?php echo esc_html( $label ) ?></label>
    2727    <input <?php echo $field->htmlattributes($attrs) ?> />
    28     <span><?php echo $desc ?></span>
     28    <span><?php echo esc_html( $desc ) ?></span>
    2929</div>
    3030<?php else: # ?>
    3131    <div>
    32         <p><?php echo $desc ?></p>
    33         <label id="<?php echo $name ?>">
    34             <?php echo $label ?>
     32        <p><?php echo esc_html( $desc ) ?></p>
     33        <label id="<?php echo esc_attr( $name ) ?>">
     34            <?php echo esc_html( $label ) ?>
    3535            <input <?php echo $field->htmlattributes($attrs) ?>/>
    3636        </label>
  • pixtypes/tags/2.0.0/features/metaboxes/cmb-field-select2-v2/cmb-field-select2.php

    r2124639 r3469313  
    3434 */
    3535function pw_select_v2( $field, $meta ) {
    36     echo '<select name="', $field['id'], '" id="', $field['id'], '" data-placeholder="' . $field['desc'] . '" class="select2">';
     36    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" data-placeholder="' . esc_attr( $field['desc'] ) . '" class="select2">';
    3737    echo '<option></option>';
    3838    if ( isset( $field['options'] ) && ! empty( $field['options'] ) ) {
     
    4141            $opt_value = is_array( $option ) && array_key_exists( 'value', $option ) ? $option['value'] : $option_key;
    4242
    43             echo '<option value="', $opt_value, '" ', selected( $meta == $opt_value ) ,'>', $opt_label, '</option>';
     43            echo '<option value="', esc_attr( $opt_value ), '" ', selected( $meta == $opt_value ) ,'>', esc_html( $opt_label ), '</option>';
    4444        }
    4545    }
     
    5353    $options = array();
    5454
    55     echo '<select name="', $field['id'], '[]" id="', $field['id'], '" data-placeholder="' . $field['desc'] . '" class="select2">';
     55    echo '<select name="', esc_attr( $field['id'] ), '[]" id="', esc_attr( $field['id'] ), '" data-placeholder="' . esc_attr( $field['desc'] ) . '" class="select2">';
    5656    echo '<option></option>';
    5757    if ( isset( $field['options'] ) && ! empty( $field['options'] ) ) {
     
    6060            $opt_value = is_array( $option ) && array_key_exists( 'value', $option ) ? $option['value'] : $option_key;
    6161
    62             echo '<option value="', $opt_value, '" ', selected( $meta == $opt_value ) ,'>', $opt_label, '</option>';
     62            echo '<option value="', esc_attr( $opt_value ), '" ', selected( $meta == $opt_value ) ,'>', esc_html( $opt_label ), '</option>';
    6363        }
    6464    }
     
    8686        }
    8787
    88         echo '<select name="', $field['id'], '[]" id="', $field['id'], '" data-placeholder="' . $field['desc'] . '" data-allow-clear="false" multiple class="select2">';
     88        echo '<select name="', esc_attr( $field['id'] ), '[]" id="', esc_attr( $field['id'] ), '" data-placeholder="' . esc_attr( $field['desc'] ) . '" data-allow-clear="false" multiple class="select2">';
    8989
    9090        if ( ! empty( $cpt_posts ) ) {
    9191            foreach ( $cpt_posts as $post ) {
    92                 echo '<option value="', $post->ID, '" ', selected( in_array( $post->ID, $meta ), true ) ,'>', $post->post_title, '</option>';
     92                echo '<option value="', esc_attr( $post->ID ), '" ', selected( in_array( $post->ID, $meta ), true ) ,'>', esc_html( $post->post_title ), '</option>';
    9393            }
    9494        }
  • pixtypes/tags/2.0.0/features/metaboxes/cmb-field-select2/cmb-field-select2.php

    r1410208 r3469313  
    3434 */
    3535function pw_select( $field, $meta ) {
    36     echo '<select name="', $field['id'], '" id="', $field['id'], '" data-placeholder="' . $field['desc'] . '" class="select2">';
     36    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" data-placeholder="' . esc_attr( $field['desc'] ) . '" class="select2">';
    3737    echo '<option></option>';
    3838    if ( isset( $field['options'] ) && ! empty( $field['options'] ) ) {
     
    4141            $opt_value = is_array( $option ) && array_key_exists( 'value', $option ) ? $option['value'] : $option_key;
    4242
    43             echo '<option value="', $opt_value, '" ', selected( $meta == $opt_value ) ,'>', $opt_label, '</option>';
     43            echo '<option value="', esc_attr( $opt_value ), '" ', selected( $meta == $opt_value ) ,'>', esc_html( $opt_label ), '</option>';
    4444        }
    4545    }
     
    7171    }
    7272
    73     echo '<input type="hidden" name="' . $field['id'] . '" id="' . $field['id'] . '" data-placeholder="' . $field['desc'] . '" class="select2" value="' . $meta . '" />';
     73    echo '<input type="hidden" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" data-placeholder="' . esc_attr( $field['desc'] ) . '" class="select2" value="' . esc_attr( $meta ) . '" />';
    7474}
    7575
     
    108108    }
    109109
    110     echo '<input type="hidden" name="' . $field['id'] . '" id="' . $field['id'] . '" data-placeholder="' . $field['desc'] . '" class="select2" value="' . $meta . '" />';
     110    echo '<input type="hidden" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" data-placeholder="' . esc_attr( $field['desc'] ) . '" class="select2" value="' . esc_attr( $meta ) . '" />';
    111111}
    112112
  • pixtypes/tags/2.0.0/features/metaboxes/css/style.css

    r1944663 r3469313  
    32203220    color: #DDD; }
    32213221  .cmb_metabox .selector-wrapper > select {
    3222     width: 100%; }
     3222    width: 100%;
     3223    -webkit-appearance: none;
     3224    -moz-appearance: none;
     3225    appearance: none; }
    32233226
    32243227.cmb_metabox .cmb-type-multicheck {
  • pixtypes/tags/2.0.0/features/metaboxes/fields/gallery.php

    r1591155 r3469313  
    1212wp_localize_script( 'pixgallery', 'locals', array(
    1313    'ajax_url'      => admin_url( 'admin-ajax.php' ),
     14    'nonce'         => wp_create_nonce( 'pixtypes_gallery_preview' ),
    1415    'pixtypes_l18n' => array(
    1516        'confirmClearGallery' => esc_html__( 'Are you sure you want to clear this gallery?', 'pixtypes' ),
     
    2021    <ul></ul>
    2122    <a class="open_pixgallery" href="#">
    22         <input type="hidden" name="<?php echo $field['id']; ?>" id="pixgalleries" value="<?php echo '' !== $meta ? $meta : $field['std'] ?>"/>
     23        <input type="hidden" name="<?php echo esc_attr( $field['id'] ); ?>" id="pixgalleries" value="<?php echo esc_attr( '' !== $meta ? $meta : $field['std'] ); ?>"/>
    2324        <div><i class="icon dashicons dashicons-images-alt2"></i>
    2425            <span><?php esc_html_e( 'Add Image', 'pixtypes' ); ?></span></div>
  • pixtypes/tags/2.0.0/features/metaboxes/fields/gmap_pins.php

    r1591155 r3469313  
    1717global $post; ?>
    1818<div class="gmap_pins_container">
    19     <ul class="gmap_pins" data-field_name="<?php echo $field['id']; ?>">
     19    <ul class="gmap_pins" data-field_name="<?php echo esc_attr( $field['id'] ); ?>">
    2020        <?php if ( empty( $meta ) ) {
    2121            $meta = array(
     
    3636                <fieldset class="pin_location_url">
    3737                    <label
    38                         for="<?php echo $field['id']; ?>[<?php echo $key ?>][location_url]">#<?php echo $key . ' ' . esc_html__( 'Location URL', 'pixtypes' ); ?></label>
    39                     <input type="text" name="<?php echo $field['id']; ?>[<?php echo $key ?>][location_url]"
    40                            value="<?php echo $pin['location_url']; ?>"/>
     38                        for="<?php echo esc_attr( $field['id'] ); ?>[<?php echo esc_attr( $key ); ?>][location_url]">#<?php echo esc_html( $key ) . ' ' . esc_html__( 'Location URL', 'pixtypes' ); ?></label>
     39                    <input type="text" name="<?php echo esc_attr( $field['id'] ); ?>[<?php echo esc_attr( $key ); ?>][location_url]"
     40                           value="<?php echo esc_attr( $pin['location_url'] ); ?>"/>
    4141                </fieldset>
    4242                <fieldset class="pin_name">
    4343                    <label
    44                         for="<?php echo $field['id']; ?>[<?php echo $key ?>][name]"><?php esc_html_e( 'Name', 'pixtypes' ); ?></label>
    45                     <input type="text" name="<?php echo $field['id']; ?>[<?php echo $key ?>][name]"
    46                            value="<?php echo $pin['name']; ?>"/>
     44                        for="<?php echo esc_attr( $field['id'] ); ?>[<?php echo esc_attr( $key ); ?>][name]"><?php esc_html_e( 'Name', 'pixtypes' ); ?></label>
     45                    <input type="text" name="<?php echo esc_attr( $field['id'] ); ?>[<?php echo esc_attr( $key ); ?>][name]"
     46                           value="<?php echo esc_attr( $pin['name'] ); ?>"/>
    4747                </fieldset>
    4848                <span class="pin_delete"></span>
     
    5454
    5555    <?php if ( isset( $field['desc'] ) && ! empty( $field['desc'] ) ) { ?>
    56         <span class="cmb_metabox_description"><?php echo $field['desc']; ?></span>
     56        <span class="cmb_metabox_description"><?php echo wp_kses_post( $field['desc'] ); ?></span>
    5757    <?php } ?>
    5858</div>
  • pixtypes/tags/2.0.0/features/metaboxes/fields/image.php

    r1591155 r3469313  
    1212wp_localize_script( 'piximage', 'locals', array(
    1313    'ajax_url'      => admin_url( 'admin-ajax.php' ),
     14    'nonce'         => wp_create_nonce( 'pixtypes_gallery_preview' ),
    1415    'pixtypes_l18n' => array(
    1516        'setThumbnailImageTitle' => esc_html__( 'Choose Image', 'pixtypes' ),
     
    2021
    2122$class = empty( $field['class'] ) ? '' : $field['class']; ?>
    22 <div id="<?php echo $field['id']; ?>" class="piximage_field hidden <?php echo $class; ?>">
     23<div id="<?php echo esc_attr( $field['id'] ); ?>" class="piximage_field hidden <?php echo esc_attr( $class ); ?>">
    2324    <ul></ul>
    2425    <a class="open_piximage" href="#">
    25         <input type="hidden" name="<?php echo $field['id']; ?>" class="piximage_id"
    26                value="<?php echo '' !== $meta ? $meta : $field['std'] ?>"/>
     26        <input type="hidden" name="<?php echo esc_attr( $field['id'] ); ?>" class="piximage_id"
     27               value="<?php echo esc_attr( '' !== $meta ? $meta : $field['std'] ); ?>"/>
    2728        <div><i class="icon dashicons dashicons-images-alt2"></i>
    28             <span><?php echo empty ( $field['button_text'] ) ? esc_html__( 'Add Image', 'pixtypes' ) : $field['button_text']; ?></span>
     29            <span><?php echo empty ( $field['button_text'] ) ? esc_html__( 'Add Image', 'pixtypes' ) : esc_html( $field['button_text'] ); ?></span>
    2930        </div>
    3031        <span
    31             class="clear_image"><?php echo empty ( $field['clear_text'] ) ? esc_html__( 'Clear', 'pixtypes' ) : $field['clear_text']; ?></span>
     32            class="clear_image"><?php echo empty ( $field['clear_text'] ) ? esc_html__( 'Clear', 'pixtypes' ) : esc_html( $field['clear_text'] ); ?></span>
    3233    </a>
    3334</div>
  • pixtypes/tags/2.0.0/features/metaboxes/fields/pix_builder.php

    r2124639 r3469313  
    55
    66    if( isset( $field['gridster_params'] ) ) {
    7         $gridster_params = ' data-params=\'' . json_encode( $field['gridster_params'] ) . '\'';
     7        $gridster_params = ' data-params=\'' . esc_attr( wp_json_encode( $field['gridster_params'] ) ) . '\'';
    88    }
    99
     
    2424    if ( $post_type !== 'page' ) {
    2525        echo '<style>
    26         .post-type-' . $post_type . ' #postdivrich {
     26        .post-type-' . esc_html( sanitize_html_class( $post_type ) ) . ' #postdivrich {
    2727            display: none !important;
    2828        }
     
    3030    }
    3131
    32     echo '<input type="hidden" name="', $field['id'], '" id="pix_builder" value="', '' !== $meta ? htmlspecialchars( $meta ) : $content, '" ' . $gridster_params . ' ' . ( $base64_decode ? 'data-base64_encoded="true"' : '' ) .' />'; ?>
     32    echo '<input type="hidden" name="', esc_attr( $field['id'] ), '" id="pix_builder" value="', '' !== $meta ? esc_attr( $meta ) : esc_attr( $content ), '" ' . $gridster_params . ' ' . ( $base64_decode ? 'data-base64_encoded="true"' : '' ) .' />'; ?>
    3333    <div class="pixbuilder-controls">
    3434        <button class="add_block button button-primary button-large"
     
    7878
    7979                                        if ( isset( $attach[0] ) && ! empty( $attach[0] ) ) {
    80                                             $content          = '<img class="image_preview" src="' . $attach[0] . '">';
    81                                             $controls_content = '<a class="open_media" href="#" class="wp-gallery" data-attachment_id="' . $block->content . '"><span>' . esc_html__( 'Set Image', 'pixtypes' ) . '</span></a>';
     80                                            $content          = '<img class="image_preview" src="' . esc_url( $attach[0] ) . '">';
     81                                            $controls_content = '<a class="open_media" href="#" class="wp-gallery" data-attachment_id="' . esc_attr( $block->content ) . '"><span>' . esc_html__( 'Set Image', 'pixtypes' ) . '</span></a>';
    8282                                        }
    8383                                    } else {
    8484                                        $content          = '<img class="image_preview">';
    85                                         $controls_content = '<a class="open_media" href="#" class="wp-gallery" data-attachment_id="' . $block->content . '"><span>' . esc_html__( 'Set Image', 'pixtypes' ) . '</pan></a>';
     85                                        $controls_content = '<a class="open_media" href="#" class="wp-gallery" data-attachment_id="' . esc_attr( $block->content ) . '"><span>' . esc_html__( 'Set Image', 'pixtypes' ) . '</pan></a>';
    8686                                    }
    8787                                }
     
    115115                            }
    116116                        } ?>
    117                         <li id="block_<?php echo $block->id ?>" class="block-type--<?php echo $block->type; ?> item"
    118                             data-type="<?php echo $block->type ?>" data-row="<?php echo $block->row ?>"
    119                             data-col="<?php echo $block->col ?>" data-sizex="<?php echo $block->size_x ?>"
    120                             data-sizey="<?php echo $block->size_y ?>">
     117                        <li id="block_<?php echo esc_attr( $block->id ); ?>" class="block-type--<?php echo esc_attr( $block->type ); ?> item"
     118                            data-type="<?php echo esc_attr( $block->type ); ?>" data-row="<?php echo esc_attr( $block->row ); ?>"
     119                            data-col="<?php echo esc_attr( $block->col ); ?>" data-sizex="<?php echo esc_attr( $block->size_x ); ?>"
     120                            data-sizey="<?php echo esc_attr( $block->size_y ); ?>">
    121121                            <div class="item__controls">
    122122                                <ul class="nav nav--controls">
     
    131131                                                        class="position__ui-cell top <?php echo 0 == intval($block->position['top']) ? '' : 'active'; ?>">
    132132                                                        <div class="position__ui-handle"
    133                                                              data-step="<?php echo $block->position['top']; ?>"><?php esc_html_e( 'top', 'pixtypes' ); ?></div>
     133                                                             data-step="<?php echo esc_attr( $block->position['top'] ); ?>"><?php esc_html_e( 'top', 'pixtypes' ); ?></div>
    134134                                                    </div>
    135135                                                </div>
     
    138138                                                        class="position__ui-cell left <?php echo 0 == intval($block->position['left']) ? '' : 'active'; ?>">
    139139                                                        <div class="position__ui-handle"
    140                                                              data-step="<?php echo $block->position['left']; ?>"><?php esc_html_e( 'left', 'pixtypes' ); ?></div>
    141                                                     </div>
    142                                                     <div class="position__ui-cell middle <?php echo $middle_status; ?>">
     140                                                             data-step="<?php echo esc_attr( $block->position['left'] ); ?>"><?php esc_html_e( 'left', 'pixtypes' ); ?></div>
     141                                                    </div>
     142                                                    <div class="position__ui-cell middle <?php echo esc_attr( $middle_status ); ?>">
    143143                                                        <div class="position__ui-handle">middle</div>
    144144                                                    </div>
     
    146146                                                        class="position__ui-cell right <?php echo 0 == intval($block->position['right']) ? '' : 'active'; ?>">
    147147                                                        <div class="position__ui-handle"
    148                                                              data-step="<?php echo $block->position['right']; ?>"><?php esc_html_e( 'right', 'pixtypes' ); ?></div>
     148                                                             data-step="<?php echo esc_attr( $block->position['right'] ); ?>"><?php esc_html_e( 'right', 'pixtypes' ); ?></div>
    149149                                                    </div>
    150150                                                </div>
     
    153153                                                        class="position__ui-cell bottom <?php echo 0 == intval($block->position['bottom']) ? '' : 'active'; ?>">
    154154                                                        <div class="position__ui-handle"
    155                                                              data-step="<?php echo $block->position['bottom']; ?>"><?php esc_html_e( 'bottom', 'pixtypes' ); ?></div>
     155                                                             data-step="<?php echo esc_attr( $block->position['bottom'] ); ?>"><?php esc_html_e( 'bottom', 'pixtypes' ); ?></div>
    156156                                                    </div>
    157157                                                </div>
     
    164164                                </ul>
    165165                            </div>
    166                             <div class="item__content block_content <?php echo $empty_class; ?>">
     166                            <div class="item__content block_content <?php echo esc_attr( $empty_class ); ?>">
    167167                                <?php echo $content ?>
    168168                            </div>
     
    175175    </div>
    176176</div>
    177 <?php add_action( 'admin_footer', 'my_admin_footer_function' );
    178 function my_admin_footer_function() { ?>
     177<?php add_action( 'admin_footer', 'pixtypes_admin_footer_function' );
     178function pixtypes_admin_footer_function() { ?>
    179179    <div class="pix_builder_editor_modal_container" style="display:none">
    180180        <div class="modal_wrapper">
  • pixtypes/tags/2.0.0/features/metaboxes/fields/playlist.php

    r1591155 r3469313  
    1111wp_localize_script( 'pixplaylist', 'playlist_locals', array(
    1212    'ajax_url'      => admin_url( 'admin-ajax.php' ),
     13    'nonce'         => wp_create_nonce( 'pixtypes_playlist_preview' ),
    1314    'playlist_type' => $playlist_type,
    1415    'pixtypes_l18n' => array(
     
    2021    <ul></ul>
    2122    <a class="open_pixvideos" href="#">
    22         <input type="hidden" name="<?php echo $field['id'] ?>" id="pixplaylist" value="<?php echo '' !== $meta ? $meta : $field['std']; ?>"/>
     23        <input type="hidden" name="<?php echo esc_attr( $field['id'] ); ?>" id="pixplaylist" value="<?php echo esc_attr( '' !== $meta ? $meta : $field['std'] ); ?>"/>
    2324        <div><i class="icon dashicons dashicons-format-video"></i> <span><?php esc_html_e('Add Video', 'pixtypes' ); ?></span></div>
    2425        <span class="clear_gallery"><?php esc_html_e( 'Clear', 'pixtypes' ); ?></span>
  • pixtypes/tags/2.0.0/features/metaboxes/fields/portfolio-gallery.php

    r1115891 r3469313  
    6565    }
    6666
    67     echo '<input type="hidden" name="'. $field['id'] .'" id="portfolio_gallery_val" />'; ?>
     67    echo '<input type="hidden" name="'. esc_attr( $field['id'] ) .'" id="portfolio_gallery_val" />'; ?>
    6868
    6969    <div id="wpgrade_portfolio_editor_modal" style="display: none">
  • pixtypes/tags/2.0.0/features/metaboxes/init.php

    r2956824 r3469313  
    116116        global $pagenow;
    117117        if ( $upload && in_array( $pagenow, array( 'page.php', 'page-new.php', 'post.php', 'post-new.php' ) ) ) {
    118             add_action( 'admin_head', array( &$this, 'add_post_enctype' ) );
     118            add_action( 'admin_head', array( $this, 'add_post_enctype' ) );
    119119        }
    120120
     
    122122            $this->add();
    123123        } else {
    124             add_action( 'admin_menu', array( &$this, 'add' ) );
    125         }
    126 
    127         add_action( 'save_post', array( &$this, 'save' ) );
    128 
    129         add_action( 'admin_head', array( &$this, 'fold_display' ) );
    130 
    131         add_filter( 'cmb_show_on', array( &$this, 'add_for_id' ), 10, 2 );
    132         //add_filter( 'cmb_show_on', array( &$this, 'add_for_page_template' ), 10, 2 );
    133         //add_filter( 'cmb_show_on', array( &$this, 'add_for_specific_select_value' ), 10, 2 );
     124            add_action( 'admin_menu', array( $this, 'add' ) );
     125        }
     126
     127        add_action( 'save_post', array( $this, 'save' ) );
     128
     129        add_action( 'admin_head', array( $this, 'fold_display' ) );
     130
     131        add_filter( 'cmb_show_on', array( $this, 'add_for_id' ), 10, 2 );
     132        //add_filter( 'cmb_show_on', array( $this, 'add_for_page_template' ), 10, 2 );
     133        //add_filter( 'cmb_show_on', array( $this, 'add_for_specific_select_value' ), 10, 2 );
    134134
    135135        //add_filter('_wp_post_revision_field_post_content', array( $this, 'pixtypes_fix_builder_revisions_display'), 915, 4 );
     
    172172                    $this->_meta_box['id'],
    173173                    $this->_meta_box['title'],
    174                     array( &$this, 'show' ),
     174                    array( $this, 'show' ),
    175175                    $page,
    176176                    $this->_meta_box['context'],
     
    195195        // If we're showing it based on ID, get the current ID
    196196        if ( isset( $_GET['post'] ) ) {
    197             $post_id = $_GET['post'];
     197            $post_id = absint( $_GET['post'] );
    198198        } elseif ( isset( $_POST['post_ID'] ) ) {
    199             $post_id = $_POST['post_ID'];
     199            $post_id = absint( $_POST['post_ID'] );
    200200        }
    201201        if ( ! isset( $post_id ) ) {
     
    223223        // Get the current ID
    224224        if ( isset( $_GET['post'] ) ) {
    225             $post_id = $_GET['post'];
     225            $post_id = absint( $_GET['post'] );
    226226        } elseif ( isset( $_POST['post_ID'] ) ) {
    227             $post_id = $_POST['post_ID'];
     227            $post_id = absint( $_POST['post_ID'] );
    228228        }
    229229        if ( ! ( isset( $post_id ) || is_page() ) ) {
     
    254254        // Get the current ID
    255255        if ( isset( $_GET['post'] ) ) {
    256             $post_id = $_GET['post'];
     256            $post_id = absint( $_GET['post'] );
    257257        } elseif ( isset( $_POST['post_ID'] ) ) {
    258             $post_id = $_POST['post_ID'];
     258            $post_id = absint( $_POST['post_ID'] );
    259259        }
    260260
     
    369369
    370370        // Use nonce for verification
    371         echo '<input type="hidden" name="wp_meta_box_nonce" value="', wp_create_nonce( basename( __FILE__ ) ), '" />';
     371        echo '<input type="hidden" name="wp_meta_box_nonce" value="', wp_create_nonce( 'pixtypes_save_metabox' ), '" />';
    372372
    373373        // load assets only when we have a metabox on page
    374         cmb_enqueue_scripts();
     374        pixtypes_cmb_enqueue_scripts();
    375375
    376376        echo '<ul class="form-table cmb_metabox">';
     
    435435                        $on = $display_on['on'];
    436436
    437                         $requires .= 'data-when_key="' . $on['field'] . '"';
     437                        $requires .= 'data-when_key="' . esc_attr( $on['field'] ) . '"';
    438438
    439439                        if ( is_array( $on['value'] ) ) {
    440                             $requires .= 'data-has_value=\'' . json_encode( $on['value'] ) . '\'';
     440                            $requires .= 'data-has_value=\'' . esc_attr( wp_json_encode( $on['value'] ) ) . '\'';
    441441                        } else {
    442                             $requires .= 'data-has_value="' . $on['value'] . '"';
     442                            $requires .= 'data-has_value="' . esc_attr( $on['value'] ) . '"';
    443443                        }
    444444                    }
    445445                }
    446446
    447                 echo '<li class="' . $classes . '" ' . $requires . '>';
     447                echo '<li class="' . esc_attr( $classes ) . '" ' . $requires . '>';
    448448            }
    449449
     
    452452                if ( isset( $this->_meta_box['show_names'] ) && $this->_meta_box['show_names'] == true ) {
    453453                    if ( isset( $field['show_names'] ) && $field['show_names'] == true ) {
    454                         echo '<h3><label for="', $field['id'], '">', $field['name'], '</label></h3>';
     454                        echo '<h3><label for="', esc_attr( $field['id'] ), '">', esc_html( $field['name'] ), '</label></h3>';
    455455                    }
    456456                }
    457457            }
    458458            if ( ! empty($field['desc']) ) {
    459                 echo "<div>" . $field['desc'] . "</div>";
     459                echo "<div>" . wp_kses_post( $field['desc'] ) . "</div>";
    460460            }
    461461            echo '</div>';
     
    469469
    470470                case 'text':
    471                     echo '<input class="cmb_text" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta, '" />';
     471                    echo '<input class="cmb_text" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( $meta ), '" />';
    472472                    break;
    473473                case 'text_small':
    474                     echo '<input class="cmb_text cmb_text_small" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta, '" />';
     474                    echo '<input class="cmb_text cmb_text_small" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( $meta ), '" />';
    475475                    break;
    476476                case 'text_medium':
    477                     echo '<input class="cmb_text cmb_text_medium" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta, '" />';
     477                    echo '<input class="cmb_text cmb_text_medium" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( $meta ), '" />';
    478478                    break;
    479479
     
    483483                    if ( isset( $field['html_args'] ) && ! empty( $field['html_args'] ) ) {
    484484                        foreach ( $field['html_args'] as $key => $att ) {
    485                             $atts .= $key . '="' . $att . '" ';
     485                            $atts .= esc_attr( $key ) . '="' . esc_attr( $att ) . '" ';
    486486                        }
    487487                    } ?>
    488                     <input class="cmb_text_range" type="range" name="<?php echo $field['id']; ?>"
    489                            id="<?php echo $field['id'] ?>"
    490                            value="<?php echo '' !== $meta ? $meta : $field['std']; ?>" <?php echo $atts ?>
    491                            style="background-size: <?php echo 0 !== $meta ? $meta : $field['std']; ?>% 100%;"
    492                            oninput="<?php echo $field['id'] . '_output.value = ' . $field['id'] . '.value'; ?>"/>
    493                     <output name="<?php echo $field['id'] ?>_output" id="<?php echo $field['id']; ?>_output">
    494                         <?php echo '' !== $meta ? $meta : $field['std']; ?>
     488                    <input class="cmb_text_range" type="range" name="<?php echo esc_attr( $field['id'] ); ?>"
     489                           id="<?php echo esc_attr( $field['id'] ); ?>"
     490                           value="<?php echo esc_attr( '' !== $meta ? $meta : $field['std'] ); ?>" <?php echo $atts; ?>
     491                           style="background-size: <?php echo esc_attr( 0 !== $meta ? $meta : $field['std'] ); ?>% 100%;"
     492                           oninput="<?php echo esc_attr( $field['id'] . '_output.value = ' . $field['id'] . '.value' ); ?>"/>
     493                    <output name="<?php echo esc_attr( $field['id'] ); ?>_output" id="<?php echo esc_attr( $field['id'] ); ?>_output">
     494                        <?php echo esc_html( '' !== $meta ? $meta : $field['std'] ); ?>
    495495                    </output>
    496496                    <?php break;
    497497                case 'text_date':
    498                     echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? $meta : $field['std'], '" />';
     498                    echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( '' !== $meta ? $meta : $field['std'] ), '" />';
    499499                    break;
    500500                case 'text_date_timestamp':
    501                     echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? date( 'm\/d\/Y', $meta ) : $field['std'], '" />';
     501                    echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( '' !== $meta ? date( 'm\/d\/Y', $meta ) : $field['std'] ), '" />';
    502502                    break;
    503503
    504504                case 'text_datetime_timestamp':
    505                     echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', $field['id'], '[date]" id="', $field['id'], '_date" value="', '' !== $meta ? date( 'm\/d\/Y', $meta ) : $field['std'], '" />';
    506                     echo '<input class="cmb_timepicker text_time" type="text" name="', $field['id'], '[time]" id="', $field['id'], '_time" value="', '' !== $meta ? date( 'h:i A', $meta ) : $field['std'], '" />';
     505                    echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', esc_attr( $field['id'] ), '[date]" id="', esc_attr( $field['id'] ), '_date" value="', esc_attr( '' !== $meta ? date( 'm\/d\/Y', $meta ) : $field['std'] ), '" />';
     506                    echo '<input class="cmb_timepicker text_time" type="text" name="', esc_attr( $field['id'] ), '[time]" id="', esc_attr( $field['id'] ), '_time" value="', esc_attr( '' !== $meta ? date( 'h:i A', $meta ) : $field['std'] ), '" />';
    507507                    break;
    508508                case 'text_time':
    509                     echo '<input class="cmb_timepicker text_time" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? $meta : $field['std'], '" />';
     509                    echo '<input class="cmb_timepicker text_time" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( '' !== $meta ? $meta : $field['std'] ), '" />';
    510510                    break;
    511511                case 'text_money':
    512                     echo '$ <input class="cmb_text_money" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? $meta : $field['std'], '" />';
     512                    echo '$ <input class="cmb_text_money" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( '' !== $meta ? $meta : $field['std'] ), '" />';
    513513                    break;
    514514                case 'colorpicker':
     
    523523                        $meta = "#";
    524524                    }
    525                     echo '<input class="cmb_colorpicker cmb_text_small" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta, '" />';
     525                    echo '<input class="cmb_colorpicker cmb_text_small" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( $meta ), '" />';
    526526                    break;
    527527                case 'textarea':
    528                     echo '<textarea class="cmb_textarea" name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="10">', $meta, '</textarea>';
     528                    echo '<textarea class="cmb_textarea" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" cols="60" rows="10">', esc_textarea( $meta ), '</textarea>';
    529529                    break;
    530530                case 'textarea_small':
    531                     echo '<textarea class="cmb_textarea" name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4">', $meta, '</textarea>';
     531                    echo '<textarea class="cmb_textarea" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" cols="60" rows="4">', esc_textarea( $meta ), '</textarea>';
    532532                    break;
    533533                case 'textarea_code':
    534534                    $rows = $cols = '';
    535535                    if( isset( $field['rows'] ) && ! empty( $field['rows'] ) ) {
    536                         $rows =  'rows="' . $field['rows'] . '"';
     536                        $rows =  'rows="' . esc_attr( $field['rows'] ) . '"';
    537537                    }
    538538
    539539                    if( isset( $field['cols'] ) && ! empty( $field['cols'] ) ) {
    540                         $cols = 'cols="' . $field['cols'] . '"';
     540                        $cols = 'cols="' . esc_attr( $field['cols'] ) . '"';
    541541                    } else {
    542542                        $cols = 'style="width: 100%"';
    543543                    }
    544544
    545                     echo '<textarea name="', $field['id'], '" id="', $field['id'], '" ' . $cols .' ' . $rows . ' class="cmb_textarea cmb_textarea_code">', $meta, '</textarea>';
     545                    echo '<textarea name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" ' . $cols .' ' . $rows . ' class="cmb_textarea cmb_textarea_code">', esc_textarea( $meta ), '</textarea>';
    546546                    break;
    547547                case 'select':
     
    552552
    553553                    echo '<div class="selector-wrapper dashicons-before dashicons-arrow-down-alt2">';
    554                     echo '<select name="', $field['id'], '" id="', $field['id'], '">';
     554                    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '">';
    555555
    556556                    foreach ( $field['options'] as $option ) {
     
    562562                            $option['value'] = 0;
    563563                        }
    564                         echo '<option value="', $option['value'], '"', $meta == $option['value'] ? ' selected="selected"' : '', '>', $option['name'], '</option>';
     564                        echo '<option value="', esc_attr( $option['value'] ), '"', $meta == $option['value'] ? ' selected="selected"' : '', '>', esc_html( $option['name'] ), '</option>';
    565565                    }
    566566                    echo '</select>';
     
    571571
    572572                    echo '<div class="selector-wrapper dashicons-before dashicons-arrow-down-alt2">';
    573                     echo '<select name="', $field['id'], '" id="', $field['id'], '">';
     573                    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '">';
    574574                    $args = array(
    575575                        'posts_per_page' => - 1,
     
    581581                    if ( ! empty( $cpt_posts ) ) {
    582582                        foreach ( $cpt_posts as $post ) {
    583                             echo '<option value="', $post->ID, '"', $meta == $post->ID ? ' selected="selected"' : '', '>', $post->post_title, '</option>';
     583                            echo '<option value="', esc_attr( $post->ID ), '"', $meta == $post->ID ? ' selected="selected"' : '', '>', esc_html( $post->post_title ), '</option>';
    584584                        }
    585585                    }
     
    590590                case 'select_cpt_term':
    591591                    echo '<div class="selector-wrapper dashicons-before dashicons-arrow-down-alt2">';
    592                     echo '<select name="', $field['id'], '" id="', $field['id'], '">';
     592                    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '">';
    593593                    $cpt_terms = get_terms( $field['taxonomy'], 'orderby=count&hide_empty=0' );
    594594                    if ( ! empty( $cpt_terms ) ) {
    595595                        foreach ( $cpt_terms as $term ) {
    596                             echo '<option value="', $term->slug, '"', $meta == $term->slug ? ' selected="selected"' : '', '>', $term->name, '</option>';
     596                            echo '<option value="', esc_attr( $term->slug ), '"', $meta == $term->slug ? ' selected="selected"' : '', '>', esc_html( $term->name ), '</option>';
    597597                        }
    598598                    }
     
    607607                    $i = 1;
    608608                    foreach ( $field['options'] as $option ) {
    609                         echo '<div class="cmb_radio_inline_option"><input type="radio" name="', $field['id'], '" id="', $field['id'], $i, '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', $field['id'], $i, '">', $option['name'], '</label></div>';
     609                        echo '<div class="cmb_radio_inline_option"><input type="radio" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] . $i ), '" value="', esc_attr( $option['value'] ), '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', esc_attr( $field['id'] . $i ), '">', esc_html( $option['name'] ), '</label></div>';
    610610                        $i ++;
    611611                    }
     
    619619                    $i = 1;
    620620                    foreach ( $field['options'] as $option ) {
    621                         echo '<li><input type="radio" name="', $field['id'], '" id="', $field['id'], $i, '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', $field['id'], $i, '">', $option['name'] . '</label></li>';
     621                        echo '<li><input type="radio" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] . $i ), '" value="', esc_attr( $option['value'] ), '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', esc_attr( $field['id'] . $i ), '">', esc_html( $option['name'] ) . '</label></li>';
    622622                        $i ++;
    623623                    }
     
    625625                    break;
    626626                case 'checkbox':
    627                     echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', ( $meta === 'on' ) ? ' checked="checked"' : '', ' />';
     627                    echo '<input type="checkbox" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '"', ( $meta === 'on' ) ? ' checked="checked"' : '', ' />';
    628628                    break;
    629629                case 'multicheck':
     
    637637                        // Append `[]` to the name to get multiple values
    638638                        // Use in_array() to check whether the current option should be checked
    639                         echo '<li><input type="checkbox" name="', $field['id'], '[]" id="', $field['id'], $i, '" value="', $value, '"', in_array( $value, $meta ) ? ' checked="checked"' : '', ' /><label for="', $field['id'], $i, '">', $name, '</label></li>';
     639                        echo '<li><input type="checkbox" name="', esc_attr( $field['id'] ), '[]" id="', esc_attr( $field['id'] . $i ), '" value="', esc_attr( $value ), '"', in_array( $value, $meta ) ? ' checked="checked"' : '', ' /><label for="', esc_attr( $field['id'] . $i ), '">', esc_html( $name ), '</label></li>';
    640640                        $i ++;
    641641                    }
     
    644644                case 'title':
    645645                    if ( isset( $field['value']) ) {
    646                         echo '<div class="cmb_metabox_title" id="', $field['id'], '">', $field['value'], '</div>';
     646                        echo '<div class="cmb_metabox_title" id="', esc_attr( $field['id'] ), '">', esc_html( $field['value'] ), '</div>';
    647647                    }
    648648                    break;
     
    653653
    654654                    echo '<div class="selector-wrapper dashicons-before dashicons-arrow-down-alt2">';
    655                     echo '<select name="', $field['id'], '" id="', $field['id'], '">';
     655                    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '">';
    656656                    $names = wp_get_object_terms( $post->ID, $field['taxonomy'] );
    657657                    $terms = get_terms( $field['taxonomy'], 'hide_empty=0' );
    658658                    foreach ( $terms as $term ) {
    659659                        if ( ! is_wp_error( $names ) && ! empty( $names ) && ! strcmp( $term->slug, $names[0]->slug ) ) {
    660                             echo '<option value="' . $term->slug . '" selected>' . $term->name . '</option>';
     660                            echo '<option value="' . esc_attr( $term->slug ) . '" selected>' . esc_html( $term->name ) . '</option>';
    661661                        } else {
    662                             echo '<option value="' . $term->slug . '  ', $meta == $term->slug ? $meta : ' ', '  ">' . $term->name . '</option>';
     662                            echo '<option value="' . esc_attr( $term->slug ) . '  ', $meta == $term->slug ? esc_attr( $meta ) : ' ', '  ">' . esc_html( $term->name ) . '</option>';
    663663                        }
    664664                    }
     
    672672                    foreach ( $terms as $term ) {
    673673                        if ( ! is_wp_error( $names ) && ! empty( $names ) && ! strcmp( $term->slug, $names[0]->slug ) ) {
    674                             echo '<li><input type="radio" name="', $field['id'], '" value="' . $term->slug . '" checked>' . $term->name . '</li>';
     674                            echo '<li><input type="radio" name="', esc_attr( $field['id'] ), '" value="' . esc_attr( $term->slug ) . '" checked>' . esc_html( $term->name ) . '</li>';
    675675                        } else {
    676                             echo '<li><input type="radio" name="', $field['id'], '" value="' . $term->slug . '  ', $meta == $term->slug ? $meta : ' ', '  ">' . $term->name . '</li>';
     676                            echo '<li><input type="radio" name="', esc_attr( $field['id'] ), '" value="' . esc_attr( $term->slug ) . '  ', $meta == $term->slug ? esc_attr( $meta ) : ' ', '  ">' . esc_html( $term->name ) . '</li>';
    677677                        }
    678678                    }
     
    684684                    $terms = get_terms( $field['taxonomy'], 'hide_empty=0' );
    685685                    foreach ( $terms as $term ) {
    686                         echo '<li><input type="checkbox" name="', $field['id'], '[]" id="', $field['id'], '" value="', $term->name, '"';
     686                        echo '<li><input type="checkbox" name="', esc_attr( $field['id'] ), '[]" id="', esc_attr( $field['id'] ), '" value="', esc_attr( $term->name ), '"';
    687687                        foreach ( $names as $name ) {
    688688                            if ( $term->slug == $name->slug ) {
     
    690690                            };
    691691                        }
    692                         echo ' /><label>', $term->name, '</label></li>';
     692                        echo ' /><label>', esc_html( $term->name ), '</label></li>';
    693693                    }
    694694                    echo '</ul>';
    695695                    break;
    696696                case 'file_list':
    697                     echo '<input class="cmb_upload_file" type="text" size="36" name="', $field['id'], '" value="" />';
     697                    echo '<input class="cmb_upload_file" type="text" size="36" name="', esc_attr( $field['id'] ), '" value="" />';
    698698                    echo '<input class="cmb_upload_button button" type="button" value="Upload File" />';
    699699                    $args        = array(
     
    720720                        $input_type_url = "text";
    721721                    }
    722                     echo '<input class="cmb_upload_file" type="' . $input_type_url . '" size="45" id="', $field['id'], '" name="', $field['id'], '" value="', $meta, '" />';
     722                    echo '<input class="cmb_upload_file" type="' . esc_attr( $input_type_url ) . '" size="45" id="', esc_attr( $field['id'] ), '" name="', esc_attr( $field['id'] ), '" value="', esc_attr( $meta ), '" />';
    723723                    echo '<input class="cmb_upload_button button" type="button" value="Upload File" />';
    724                     echo '<input class="cmb_upload_file_id" type="hidden" id="', $field['id'], '_id" name="', $field['id'], '_id" value="', get_post_meta( $post->ID, $field['id'] . "_id", true ), '" />';
    725                     echo '<div id="', $field['id'], '_status" class="cmb_media_status">';
     724                    echo '<input class="cmb_upload_file_id" type="hidden" id="', esc_attr( $field['id'] ), '_id" name="', esc_attr( $field['id'] ), '_id" value="', esc_attr( get_post_meta( $post->ID, $field['id'] . "_id", true ) ), '" />';
     725                    echo '<div id="', esc_attr( $field['id'] ), '_status" class="cmb_media_status">';
    726726                    if ( $meta != '' ) {
    727727                        $check_image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $meta );
    728728                        if ( $check_image ) {
    729729                            echo '<div class="img_status">';
    730                             echo '<img src="', $meta, '" alt="" />';
    731                             echo '<a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">Remove Image</a>';
     730                            echo '<img src="', esc_url( $meta ), '" alt="" />';
     731                            echo '<a href="#" class="cmb_remove_file_button" rel="', esc_attr( $field['id'] ), '">Remove Image</a>';
    732732                            echo '</div>';
    733733                        } else {
     
    736736                                $title = $parts[ $i ];
    737737                            }
    738                             echo 'File: <strong>', $title, '</strong>&nbsp;&nbsp;&nbsp; (<a href="', $meta, '" target="_blank" rel="external">Download</a> / <a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">Remove</a>)';
     738                            echo 'File: <strong>', esc_html( $title ), '</strong>&nbsp;&nbsp;&nbsp; (<a href="', esc_url( $meta ), '" target="_blank" rel="external">Download</a> / <a href="#" class="cmb_remove_file_button" rel="', esc_attr( $field['id'] ), '">Remove</a>)';
    739739                        }
    740740                    }
     
    747747                        $input_type_url = "text";
    748748                    }
    749                     echo '<input class="cmb_upload_file attachment" type="' . $input_type_url . '" size="45" id="', $field['id'], '" name="', $field['id'], '" value=\'', $meta, '\' />';
     749                    echo '<input class="cmb_upload_file attachment" type="' . esc_attr( $input_type_url ) . '" size="45" id="', esc_attr( $field['id'] ), '" name="', esc_attr( $field['id'] ), '" value=\'', esc_attr( $meta ), '\' />';
    750750                    echo '<input class="cmb_upload_button button" type="button" value="Upload File" />';
    751                     echo '<input class="cmb_upload_file_id" type="hidden" id="', $field['id'], '_id" name="', $field['id'], '_id" value="', get_post_meta( $post->ID, $field['id'] . "_id", true ), '" />';
    752                     echo '<div id="', $field['id'], '_status" class="cmb_media_status">';
     751                    echo '<input class="cmb_upload_file_id" type="hidden" id="', esc_attr( $field['id'] ), '_id" name="', esc_attr( $field['id'] ), '_id" value="', esc_attr( get_post_meta( $post->ID, $field['id'] . "_id", true ) ), '" />';
     752                    echo '<div id="', esc_attr( $field['id'] ), '_status" class="cmb_media_status">';
    753753                    if ( $meta != '' ) {
    754754                        $check_image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $meta );
     
    756756                            echo '<div class="img_status">';
    757757                            $meta_img = (array) json_decode( $meta );
    758                             echo '<img src="' . $meta_img["link"] . '" alt="" />';
    759                             echo '<a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">Remove Image</a>';
     758                            echo '<img src="' . esc_url( $meta_img["link"] ) . '" alt="" />';
     759                            echo '<a href="#" class="cmb_remove_file_button" rel="', esc_attr( $field['id'] ), '">Remove Image</a>';
    760760                            echo '</div>';
    761761                        } else {
     
    764764                                $title = $parts[ $i ];
    765765                            }
    766                             echo 'File: <strong>', $title, '</strong>&nbsp;&nbsp;&nbsp; (<a href="', $meta, '" target="_blank" rel="external">Download</a> / <a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">Remove</a>)';
     766                            echo 'File: <strong>', esc_html( $title ), '</strong>&nbsp;&nbsp;&nbsp; (<a href="', esc_url( $meta ), '" target="_blank" rel="external">Download</a> / <a href="#" class="cmb_remove_file_button" rel="', esc_attr( $field['id'] ), '">Remove</a>)';
    767767                        }
    768768                    }
     
    848848
    849849                case 'oembed':
    850                     echo '<input class="cmb_oembed" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? $meta : $field['std'], '" />';
     850                    echo '<input class="cmb_oembed" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( '' !== $meta ? $meta : $field['std'] ), '" />';
    851851                    echo '<p class="cmb-spinner spinner"></p>';
    852                     echo '<div id="', $field['id'], '_status" class="cmb_media_status ui-helper-clearfix embed_wrap">';
     852                    echo '<div id="', esc_attr( $field['id'] ), '_status" class="cmb_media_status ui-helper-clearfix embed_wrap">';
    853853                    if ( $meta != '' ) {
    854854                        $check_embed = $GLOBALS['wp_embed']->run_shortcode( '[embed]' . esc_url( $meta ) . '[/embed]' );
     
    856856                            echo '<div class="embed_status">';
    857857                            echo $check_embed;
    858                             echo '<a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">Remove Embed</a>';
     858                            echo '<a href="#" class="cmb_remove_file_button" rel="', esc_attr( $field['id'] ), '">Remove Embed</a>';
    859859                            echo '</div>';
    860860                        } else {
     
    872872                    $i = 1;
    873873                    foreach ( $field['options'] as $option ) {
    874                         echo '<li><input type="radio" name="', $field['id'], '" id="', $field['id'], $i, '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', $field['id'], $i, '">', '<span>' . $option['value'] . '</span>' . '</label></li>';
     874                        echo '<li><input type="radio" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] . $i ), '" value="', esc_attr( $option['value'] ), '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', esc_attr( $field['id'] . $i ), '">', '<span>' . esc_html( $option['value'] ) . '</span>' . '</label></li>';
    875875                        $i ++;
    876876                    }
     
    920920            (function ($) {
    921921                $(document).ready(function () {
    922                     var metabox = $('#<?php echo $this->_meta_box['id'];  ?>');
     922                    var metabox = $('#<?php echo esc_js( $this->_meta_box['id'] );  ?>');
    923923                    metabox.addClass('display_on')
    924924                        .attr('data-action', '<?php echo 'show'; ?>')
    925                         .attr('data-when_key', '<?php echo $display_on['on']['field']; ?>')
    926                         .attr('data-has_value', '<?php echo $display_on['on']['value']; ?>');
     925                        .attr('data-when_key', '<?php echo esc_js( $display_on['on']['field'] ); ?>')
     926                        .attr('data-has_value', '<?php echo esc_js( $display_on['on']['value'] ); ?>');
    927927                });
    928928            })(jQuery);
     
    937937
    938938        // verify nonce
    939         if ( ! isset( $_POST['wp_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['wp_meta_box_nonce'], basename( __FILE__ ) ) ) {
     939        if ( ! isset( $_POST['wp_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['wp_meta_box_nonce'], 'pixtypes_save_metabox' ) ) {
    940940            return $post_id;
    941941        }
     
    10531053 * Adding scripts and styles
    10541054 */
    1055 function cmb_register_scripts( $hook ) {
     1055function pixtypes_cmb_register_scripts( $hook ) {
    10561056
    10571057    global $pixtypes_plugin;
     
    11061106}
    11071107
    1108 add_action( 'admin_enqueue_scripts', 'cmb_register_scripts', 10 );
    1109 
    1110 function cmb_enqueue_scripts(){
     1108add_action( 'admin_enqueue_scripts', 'pixtypes_cmb_register_scripts', 10 );
     1109
     1110function pixtypes_cmb_enqueue_scripts(){
    11111111    wp_enqueue_script( 'cmb-timepicker' );
    11121112    wp_enqueue_script( 'cmb-scripts' );
     
    11141114}
    11151115
    1116 function cmb_editor_footer_scripts() {
    1117     if ( isset( $_GET['cmb_force_send'] ) && 'true' == $_GET['cmb_force_send'] ) {
    1118         $label = $_GET['cmb_send_label'];
     1116function pixtypes_cmb_editor_footer_scripts() {
     1117    if ( isset( $_GET['cmb_force_send'] ) && 'true' === $_GET['cmb_force_send'] ) {
     1118        $label = isset( $_GET['cmb_send_label'] ) ? sanitize_text_field( $_GET['cmb_send_label'] ) : '';
    11191119        if ( empty( $label ) ) {
    11201120            $label = esc_html__( 'Select File', 'pixtypes' );
     
    11221122        <script type="text/javascript">
    11231123            jQuery(function ($) {
    1124                 $('td.savesend input').val('<?php echo esc_html( $label , 'pixtypes' ); ?>');
     1124                $('td.savesend input').val(<?php echo wp_json_encode( $label ); ?>);
    11251125            });
    11261126        </script>
     
    11291129}
    11301130
    1131 add_action( 'admin_print_footer_scripts', 'cmb_editor_footer_scripts', 99 );
     1131add_action( 'admin_print_footer_scripts', 'pixtypes_cmb_editor_footer_scripts', 99 );
    11321132
    11331133// Force 'Insert into Post' button from Media Library
    1134 add_filter( 'get_media_item_args', 'cmb_force_send' );
    1135 function cmb_force_send( $args ) {
     1134add_filter( 'get_media_item_args', 'pixtypes_cmb_force_send' );
     1135function pixtypes_cmb_force_send( $args ) {
    11361136
    11371137    // if the Gallery tab is opened from a custom meta box field, add Insert Into Post button
     
    11841184}
    11851185
    1186 add_action( 'wp_ajax_cmb_oembed_handler', 'cmb_oembed_ajax_results' );
     1186add_action( 'wp_ajax_cmb_oembed_handler', 'pixtypes_cmb_oembed_ajax_results' );
    11871187/**
    11881188 * Handles our oEmbed ajax request
    11891189 */
    1190 function cmb_oembed_ajax_results() {
     1190function pixtypes_cmb_oembed_ajax_results() {
    11911191
    11921192    // verify our nonce
     
    12081208        // Post ID is needed to check for embeds
    12091209        if ( isset( $_REQUEST['post_id'] ) ) {
    1210             $GLOBALS['post'] = get_post( $_REQUEST['post_id'] );
     1210            $GLOBALS['post'] = get_post( absint( $_REQUEST['post_id'] ) );
    12111211        }
    12121212        // ping WordPress for an embed
     
    12171217        if ( $check_embed && $check_embed != $fallback ) {
    12181218            // Embed data
    1219             $return = '<div class="embed_status">' . $check_embed . '<a href="#" class="cmb_remove_file_button" rel="' . $_REQUEST['field_id'] . '">' . esc_html__( 'Remove Embed', 'pixtypes' ) . '</a></div>';
     1219            $return = '<div class="embed_status">' . $check_embed . '<a href="#" class="cmb_remove_file_button" rel="' . esc_attr( sanitize_text_field( $_REQUEST['field_id'] ) ) . '">' . esc_html__( 'Remove Embed', 'pixtypes' ) . '</a></div>';
    12201220            // set our response id
    12211221            $found = 'found';
     
    12391239
    12401240// create an ajax call which will return a preview to the current gallery
    1241 function ajax_pixgallery_preview() {
     1241function pixtypes_ajax_pixgallery_preview() {
     1242    check_ajax_referer( 'pixtypes_gallery_preview', 'nonce' );
     1243
     1244    if ( ! current_user_can( 'upload_files' ) ) {
     1245        wp_send_json_error( 'Unauthorized' );
     1246    }
     1247
    12421248    $result = array( 'success' => false, 'output' => '' );
    12431249
    1244     if ( isset( $_REQUEST['attachments_ids'] ) ) {
    1245         $ids = $_REQUEST['attachments_ids'];
    1246     }
     1250    $ids = isset( $_REQUEST['attachments_ids'] ) ? sanitize_text_field( $_REQUEST['attachments_ids'] ) : '';
     1251
    12471252    if ( empty( $ids ) ) {
    1248         echo json_encode( $result );
     1253        echo wp_json_encode( $result );
    12491254        exit;
    12501255    }
    12511256
    1252     $ids = rtrim( $ids, ',' );
    1253     $ids = explode( ',', $ids );
     1257    $ids = array_map( 'absint', explode( ',', rtrim( $ids, ',' ) ) );
     1258    $ids = array_filter( $ids );
    12541259
    12551260    $size = 'thumbnail';
     
    12611266    foreach ( $ids as $id ) {
    12621267        $attach = wp_get_attachment_image_src( $id, $size, false );
    1263 
    1264         $result["output"] .= '<li><img src="' . $attach[0] . '" /></li>';
     1268        if ( $attach ) {
     1269            $result["output"] .= '<li><img src="' . esc_url( $attach[0] ) . '" /></li>';
     1270        }
    12651271    }
    12661272    $result["success"] = true;
    1267     echo json_encode( $result );
     1273    echo wp_json_encode( $result );
    12681274    exit;
    12691275}
    12701276
    1271 add_action( 'wp_ajax_ajax_pixgallery_preview', 'ajax_pixgallery_preview' );
    1272 
    1273 function ajax_pixplaylist_preview() {
    1274 
    1275     if ( isset( $_REQUEST['attachments_ids'] ) ) {
    1276         $ids = $_REQUEST['attachments_ids'];
    1277     }
     1277add_action( 'wp_ajax_ajax_pixgallery_preview', 'pixtypes_ajax_pixgallery_preview' );
     1278
     1279function pixtypes_ajax_pixplaylist_preview() {
     1280    check_ajax_referer( 'pixtypes_playlist_preview', 'nonce' );
     1281
     1282    if ( ! current_user_can( 'upload_files' ) ) {
     1283        wp_send_json_error( 'Unauthorized' );
     1284    }
     1285
     1286    $ids = isset( $_REQUEST['attachments_ids'] ) ? sanitize_text_field( $_REQUEST['attachments_ids'] ) : '';
    12781287
    12791288    if ( empty( $ids ) ) {
     
    12821291    }
    12831292
    1284     $ids = explode( ',', $ids );
     1293    $ids = array_map( 'absint', explode( ',', $ids ) );
     1294    $ids = array_filter( $ids );
    12851295
    12861296    $result = '';
    12871297    foreach ( $ids as $id ) {
    1288         $result .= '<li><span class="dashicons dashicons-format-video"></span><span class="attachment_title">' . get_the_title( $id ) . '</span></li>';
     1298        $result .= '<li><span class="dashicons dashicons-format-video"></span><span class="attachment_title">' . esc_html( get_the_title( $id ) ) . '</span></li>';
    12891299    }
    12901300
     
    12931303}
    12941304
    1295 add_action( 'wp_ajax_pixplaylist_preview', 'ajax_pixplaylist_preview' );
     1305add_action( 'wp_ajax_pixplaylist_preview', 'pixtypes_ajax_pixplaylist_preview' );
    12961306
    12971307
  • pixtypes/tags/2.0.0/features/metaboxes/js/pixgallery.js

    r2487861 r3469313  
    121121        if ( ids !== '' ) {
    122122            $.ajax({
    123                 type: "post", url: locals.ajax_url, data: {action: 'ajax_pixgallery_preview', attachments_ids: ids},
     123                type: "post", url: locals.ajax_url, data: {action: 'ajax_pixgallery_preview', attachments_ids: ids, nonce: locals.nonce},
    124124                beforeSend: function () {
    125125                    $('.open_pixgallery i').removeClass('dashicons-images-alt2');
  • pixtypes/tags/2.0.0/features/metaboxes/js/piximage.js

    r2487861 r3469313  
    129129        if ( id != '' && id != '-1' ) {
    130130            $.ajax({
    131                 type: "post", url: locals.ajax_url, data: {action: 'ajax_pixgallery_preview', attachments_ids: id},
     131                type: "post", url: locals.ajax_url, data: {action: 'ajax_pixgallery_preview', attachments_ids: id, nonce: locals.nonce},
    132132                beforeSend: function () {
    133133                    $elem.find('.open_piximage i').removeClass('dashicons-images-alt2');
  • pixtypes/tags/2.0.0/features/metaboxes/js/pixplaylist.js

    r2487861 r3469313  
    108108                data: {
    109109                    action: 'pixplaylist_preview',
    110                     attachments_ids: ids
     110                    attachments_ids: ids,
     111                    nonce: playlist_locals.nonce
    111112                },
    112113                success: function( response ) {
  • pixtypes/tags/2.0.0/features/metaboxes/metaboxes.php

    r1745422 r3469313  
    1010
    1111
    12 function load_metaboxes_fromdb( $meta_boxes ) {
     12function pixtypes_load_metaboxes_fromdb( $meta_boxes ) {
    1313    // make sure we are in good working order
    1414    if ( empty( $meta_boxes ) ) {
     
    4040    return $meta_boxes;
    4141}
    42 add_filter( 'cmb_meta_boxes', 'load_metaboxes_fromdb', 1 );
     42add_filter( 'cmb_meta_boxes', 'pixtypes_load_metaboxes_fromdb', 1 );
    4343
    4444/**
     
    4949 * @return array
    5050 */
    51 function gather_metaboxes_dynamically( $meta_boxes ) {
     51function pixtypes_gather_metaboxes_dynamically( $meta_boxes ) {
    5252    // make sure we are in good working order
    5353    if ( empty( $meta_boxes ) ) {
     
    5757    return apply_filters( 'pixelgrade_filter_metaboxes', $meta_boxes );
    5858}
    59 add_filter( 'cmb_meta_boxes', 'gather_metaboxes_dynamically', 10 );
     59add_filter( 'cmb_meta_boxes', 'pixtypes_gather_metaboxes_dynamically', 10 );
    6060
    6161/*
    6262 * Initialize the metabox class.
    6363 */
    64 function cmb_initialize_cmb_meta_boxes() {
     64function pixtypes_cmb_initialize_meta_boxes() {
    6565
    6666    if ( ! class_exists( 'cmb_Meta_Box' ) ) {
     
    7272
    7373}
    74 add_action( 'init', 'cmb_initialize_cmb_meta_boxes', 9999 );
     74add_action( 'init', 'pixtypes_cmb_initialize_meta_boxes', 9999 );
  • pixtypes/tags/2.0.0/pixtypes.php

    r2956824 r3469313  
    44 * Plugin URI: https://wordpress.org/plugins/pixtypes/
    55 * Description: Custom post types and meta-boxes needed by your themes.
    6  * Version: 1.4.16
     6 * Version: 2.0.0
    77 * Author: Pixelgrade
    88 * Author URI: https://pixelgrade.com
    99 * Author Email: [email protected]
    10  * Requires at least: 4.9.9
    11  * Tested up to: 6.3.0
     10 * Requires at least: 6.0
     11 * Tested up to: 6.7
     12 * Requires PHP: 7.4
    1213 * Text Domain: pixtypes
    1314 * License:     GPL-2.0 or later.
     
    2122}
    2223
    23 // ensure EXT is defined
    24 if ( ! defined( 'EXT' ) ) {
    25     define( 'EXT', '.php' );
     24// ensure PIXTYPES_EXT is defined
     25if ( ! defined( 'PIXTYPES_EXT' ) ) {
     26    define( 'PIXTYPES_EXT', '.php' );
    2627}
    2728
    28 require 'core/bootstrap' . EXT;
     29require 'core/bootstrap' . PIXTYPES_EXT;
    2930
    30 $config = include 'plugin-config' . EXT;
     31$config = include 'plugin-config' . PIXTYPES_EXT;
    3132// set textdomain
    3233pixtypes::settextdomain( $config['textdomain'] );
     
    3536// ----------------
    3637
    37 $defaults = include 'plugin-defaults' . EXT;
     38$defaults = include 'plugin-defaults' . PIXTYPES_EXT;
    3839
    3940$current_data = get_option( $config['settings-key'] );
     
    6162
    6263global $pixtypes_plugin;
    63 $pixtypes_plugin = PixTypesPlugin::get_instance( '1.4.15' );
     64$pixtypes_plugin = PixTypesPlugin::get_instance( '2.0.0' );
  • pixtypes/tags/2.0.0/plugin-config.php

    r1591155 r3469313  
    33$basepath = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
    44
    5 $debug = false;
    6 if ( isset( $_GET['debug'] ) && $_GET['debug'] == 'true' ) {
    7     $debug = true;
    8 }
     5$debug = defined( 'WP_DEBUG' ) && WP_DEBUG;
    96
    107$options = get_option( 'pixtypes_settings' );
     
    3027    'fields' => array(
    3128        'hiddens'
    32         => include 'settings/hiddens' . EXT,
     29        => include 'settings/hiddens' . PIXTYPES_EXT,
    3330        'post_types'
    34         => include 'settings/post_types' . EXT,
     31        => include 'settings/post_types' . PIXTYPES_EXT,
    3532        'taxonomies'
    36         => include 'settings/taxonomies' . EXT,
     33        => include 'settings/taxonomies' . PIXTYPES_EXT,
    3734    ),
    3835
  • pixtypes/tags/2.0.0/readme.txt

    r2956824 r3469313  
    22Contributors: pixelgrade, babbardel, vlad.olaru, razvanonofrei
    33Tags: custom, post-types, metadata, builder, gallery
    4 Requires at least: 4.9.9
    5 Tested up to: 6.3.0
    6 Requires PHP: 5.3.0
    7 Stable tag: 1.4.16
     4Requires at least: 6.0
     5Tested up to: 6.9.1
     6Requires PHP: 7.4
     7Stable tag: 2.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2424
    2525== Changelog ==
     26
     27= 2.0.0 =
     28* Security: Fixed Stored XSS vulnerability in HTML attribute rendering (HTMLTag class).
     29* Security: Fixed Reflected XSS via field_id parameter in oEmbed handler.
     30* Security: Fixed XSS via cmb_send_label using proper JS escaping (wp_json_encode).
     31* Security: Added nonce verification and capability checks to gallery AJAX preview handler.
     32* Security: Added nonce verification and capability checks to playlist AJAX preview handler.
     33* Security: Added capability check (manage_options) to theme settings cleanup AJAX handler.
     34* Security: Removed URL-controllable debug mode; now tied to WP_DEBUG constant.
     35* Security: Added output escaping throughout admin views and form templates.
     36* Security: Restricted POST input processing to expected fields only.
     37* Security: Sanitized all $_GET/$_POST/$_REQUEST superglobal usage with appropriate functions.
     38* Security: Updated nonce action strings to use specific identifiers.
     39* Improvement: Prefixed all global functions with pixtypes_ to prevent namespace collisions.
     40* Improvement: Removed deprecated &$this reference patterns for PHP 8 compatibility.
     41* Improvement: Updated minimum requirements to WordPress 6.0 and PHP 7.4.
     42* Improvement: Replaced EXT constant with PIXTYPES_EXT to avoid conflicts.
    2643
    2744= 1.4.16 =
  • pixtypes/tags/2.0.0/views/admin.php

    r2895213 r3469313  
    1313 */
    1414
    15 $config = include pixtypes::pluginpath() . 'plugin-config' . EXT;
     15$config = include pixtypes::pluginpath() . 'plugin-config' . PIXTYPES_EXT;
    1616
    1717// invoke processor
     
    6262        <?php echo $f->endform() ?>
    6363
    64     <?php elseif ( $status['state'] == 'error' ): ?>
     64    <?php elseif ( 'error' === $status['state'] ): ?>
    6565
    6666        <h3><?php esc_html_e( 'Critical Error', 'pixtypes' ); ?></h3>
    6767
    68         <p><?php echo $status['message'] ?></p>
     68        <p><?php echo esc_html( $status['message'] ); ?></p>
    6969
    7070    <?php endif; ?>
     
    8989                        if ( isset( $options['themes'] ) && count( $options['themes'] ) > 1 ) {
    9090                            foreach ( $options['themes'] as $key => $theme ) {
    91                                 echo '<li><button class="button delete-action" type="submit" name="unset_pixtype" value="' . $key . '">' . esc_html__( 'Clean-up after', 'pixtypes' ) . ' ' . ucfirst( $key ) . '</button></li>';
     91                                echo '<li><button class="button delete-action" type="submit" name="unset_pixtype" value="' . esc_attr( $key ) . '">' . esc_html__( 'Clean-up after', 'pixtypes' ) . ' ' . esc_html( ucfirst( $key ) ) . '</button></li>';
    9292                            }
    9393                        } ?>
  • pixtypes/trunk/README.md

    r1744797 r3469313  
    139139```
    140140
    141 === Old Change Log  ===
    142 
    143 1.3.5
    144 Improved the multicheck field
    145 
    146 1.3.2
    147 WordPress 4.3 compatibility
    148 Fixed Sticky buttons for the PixBuilder field
    149 
    150 1.3.1
    151 
    152 Allow portfolio to be a jetpack compatible type
    153 Small fixes to the gallery field
    154 
    155 1.2.10
    156 
    157 Show / Hide options bug fix
    158 
    159 1.2.9
    160 
    161 Gmap pins added
    162 
    163 1.2.6
    164 
    165 Builder field added
    166 Support for wp 4.0
    167 Small fixes
    168 
    169 1.2.2
    170 
    171 Small fixes to metaboxes
    172 
    173 1.2.1
    174 
    175 Github Updater slug fix
    176 And small fixes...
    177 
    178 1.2.0
    179 
    180 Ajax Update
    181 Gallery Metabox works now even if there is no wp-editor on page
    182 And small fixes...
    183 
    184 1.1.0
    185 
    186 Add admin panel
    187 Fixes
    188 
    189 1.0.0 - Here we go
     141## Development Notes
     142Gulp 3.x doesn't work on Node.js 12.x or above. You have to downgrade Node.js to 11.5.0
     143```
     144nvm install 11.15.0
     145nvm use 11.15.0 # Just in case it didn't automatically select the 11.15.0 as the main node.
     146nvm uninstall 13.1.0
     147npm rebuild node-sass
     148```
  • pixtypes/trunk/class-pixtypes.php

    r2127881 r3469313  
    106106         * Ajax Callbacks - only for logged in users
    107107         */
    108         add_action( 'wp_ajax_unset_pixtypes', array( &$this, 'ajax_unset_pixtypes' ) );
     108        add_action( 'wp_ajax_unset_pixtypes', array( $this, 'ajax_unset_pixtypes' ) );
    109109    }
    110110
     
    649649    function ajax_unset_pixtypes() {
    650650        $result = array( 'success' => false, 'msg' => 'Incorrect nonce' );
     651
     652        if ( ! current_user_can( 'manage_options' ) ) {
     653            wp_send_json_error( 'Unauthorized' );
     654        }
     655
    651656        if ( ! wp_verify_nonce( $_POST['_ajax_nonce'], 'unset_pixtype' ) ) {
    652             echo json_encode( $result );
     657            echo wp_json_encode( $result );
    653658            die();
    654659        }
    655660
    656661        if ( isset( $_POST['theme_slug'] ) ) {
    657             $key     = $_POST['theme_slug'];
     662            $key     = sanitize_key( $_POST['theme_slug'] );
    658663            $options = get_option( 'pixtypes_settings' );
    659664            if ( isset( $options['themes'][ $key ] ) ) {
    660665                unset( $options['themes'][ $key ] );
    661666                update_option( 'pixtypes_settings', $options );
    662                 $result['msg']     = 'Settings for ' . ucfirst( $key ) . ' have been cleaned up!';
     667                $result['msg']     = 'Settings for ' . esc_html( ucfirst( $key ) ) . ' have been cleaned up!';
    663668                $result['success'] = true;
    664669            }
    665670        }
    666671
    667         echo json_encode( $result );
     672        echo wp_json_encode( $result );
    668673        exit;
    669674    }
  • pixtypes/trunk/core/bootstrap.php

    r1115891 r3469313  
    11<?php defined('ABSPATH') or die;
    22
    3     // ensure EXT is defined
    4     if ( ! defined('EXT')) {
    5         define('EXT', '.php');
     3    // ensure PIXTYPES_EXT is defined
     4    if ( ! defined('PIXTYPES_EXT')) {
     5        define('PIXTYPES_EXT', '.php');
    66    }
    77
    88    $basepath = dirname(__FILE__).DIRECTORY_SEPARATOR;
    9     require $basepath.'core'.EXT;
     9    require $basepath.'core'.PIXTYPES_EXT;
    1010
    1111    // load classes
  • pixtypes/trunk/core/classes/HTMLTag.php

    r1744797 r3469313  
    5757                if ( ! empty($value)) {
    5858                    if (is_array($value)) {
    59                         $htmlvalue = implode(' ', $value);
     59                        $htmlvalue = esc_attr( implode(' ', $value) );
    6060                        $attr_segments[] = "$key=\"$htmlvalue\"";
    6161                    }
    6262                    else { // value is not an array
    63                         $attr_segments[] = "$key=\"$value\"";
     63                        $attr_segments[] = "$key=\"" . esc_attr( $value ) . "\"";
    6464                    }
    6565                }
    6666                else { // empty html tag; ie. no value html tag
    67                     $attr_segments[] = $key;
     67                    $attr_segments[] = esc_attr( $key );
    6868                }
    6969            }
  • pixtypes/trunk/core/classes/Processor.php

    r1744797 r3469313  
    155155        $plugin_cleanup = $this->meta->get('cleanup', array());
    156156
     157        // Only process expected fields — discard any extra $_POST keys.
     158        $allowed_keys = array_keys( $this->fields->metadata_array() );
     159        $input = array_intersect_key( $input, array_flip( $allowed_keys ) );
     160
    157161        foreach ($this->fields->metadata_array() as $key => $field) {
    158162
  • pixtypes/trunk/core/classes/forms/FormField.php

    r1744797 r3469313  
    7070            foreach ($template_paths as $path) {
    7171                $dirpath = rtrim($path, '\\/').DIRECTORY_SEPARATOR;
    72                 if (file_exists($dirpath.$pattern.EXT)) {
    73                     return $this->render_template_file($dirpath.$pattern.EXT);
     72                if (file_exists($dirpath.$pattern.PIXTYPES_EXT)) {
     73                    return $this->render_template_file($dirpath.$pattern.PIXTYPES_EXT);
    7474                }
    7575            }
  • pixtypes/trunk/core/core.php

    r1275567 r3469313  
    2121    static function defaults() {
    2222        if (self::$defaults === null) {
    23             self::$defaults = include self::corepath().'defaults'.EXT;
     23            self::$defaults = include self::corepath().'defaults'.PIXTYPES_EXT;
    2424        }
    2525
     
    269269
    270270        foreach ($priority_list as $file => $priority) {
    271             if (strpos($file, EXT)) {
     271            if (strpos($file, PIXTYPES_EXT)) {
    272272                require $file;
    273273            }
  • pixtypes/trunk/core/tests/bootstrap.php

    r1115891 r3469313  
    11<?php defined('ABSPATH') or die;
    22
    3     // ensure EXT is defined
    4     if ( ! defined('EXT')) {
    5         define('EXT', '.php');
     3    // ensure PIXTYPES_EXT is defined
     4    if ( ! defined('PIXTYPES_EXT')) {
     5        define('PIXTYPES_EXT', '.php');
    66    }
    77
     
    99
    1010    $basepath = realpath('..').DIRECTORY_SEPARATOR;
    11     require $basepath.'bootstrap'.EXT;
     11    require $basepath.'bootstrap'.PIXTYPES_EXT;
  • pixtypes/trunk/core/views/form-partials/fields/color.php

    r1115891 r3469313  
    1010
    1111    $type = 'color';
    12     include 'text'.EXT;
     12    include 'text'.PIXTYPES_EXT;
    1313
  • pixtypes/trunk/core/views/form-partials/fields/counter.php

    r1115891 r3469313  
    3737    <input <?php echo $field->htmlattributes($attrs) ?> class="small-text" />
    3838<?php else: # standard field ?>
    39     <label for="<?php echo $idname ?>">
     39    <label for="<?php echo esc_attr( $idname ) ?>">
    4040        <input <?php echo $field->htmlattributes($attrs) ?> />
    41         <?php echo $label ?>
     41        <?php echo esc_html( $label ) ?>
    4242    </label>
    4343<?php endif; ?>
  • pixtypes/trunk/core/views/form-partials/fields/group.php

    r1115891 r3469313  
    2222            $fieldexample = $field->getmeta('group-example', null);
    2323            $fieldnote = $field->getmeta('group-note', null); ?>
    24                 <div class="field" <?php if ( $fieldconfig['type'] == 'group' ) echo 'id="' . $fieldname . '"'; ?> >
     24                <div class="field" <?php if ( $fieldconfig['type'] == 'group' ) echo 'id="' . esc_attr( $fieldname ) . '"'; ?> >
    2525                    <?php echo $field->render();
    2626                    if ( ! empty($fieldnote)): ?>
    27                         <span class="field-note"><?php echo $fieldnote ?></span>
     27                        <span class="field-note"><?php echo esc_html( $fieldnote ) ?></span>
    2828                    <?php endif; ?>
    2929                </div>
  • pixtypes/trunk/core/views/form-partials/fields/postbox.php

    r1115891 r3469313  
    1212<div class="postbox">
    1313    <div class="handlediv" title="Click to toggle"><br></div>
    14     <h3 class="hndle"><span><?php echo $label ?></span></h3>
     14    <h3 class="hndle"><span><?php echo esc_html( $label ) ?></span></h3>
    1515
    1616    <div class="inside">
     
    2424            $show_group = $field->getmeta('show_group', null);  ?>
    2525
    26             <div class="row" <?php if ( $fieldconfig['type'] == 'group' ) echo 'id="' . $fieldname . '"'; ?>>
     26            <div class="row" <?php if ( $fieldconfig['type'] == 'group' ) echo 'id="' . esc_attr( $fieldname ) . '"'; ?>>
    2727                <?php if ( ! empty($fielddesc)): ?>
    28                     <div class="field-desc"><?php echo $fielddesc ?></div>
     28                    <div class="field-desc"><?php echo esc_html( $fielddesc ) ?></div>
    2929                <?php endif;
    3030                echo $field->render();
    3131                if ( ! empty($fieldnote)): ?>
    32                     <span class="note"><?php echo $fieldnote ?></span>
     32                    <span class="note"><?php echo esc_html( $fieldnote ) ?></span>
    3333                <?php endif; ?>
    3434            </div>
  • pixtypes/trunk/core/views/form-partials/fields/select.php

    r1115891 r3469313  
    2424    <?php foreach ($this->getmeta('options', array()) as $key => $label): ?>
    2525        <option <?php if ($key == $selected): ?>selected<?php endif; ?>
    26                 value="<?php echo $key ?>">
    27             <?php echo $label ?>
     26                value="<?php echo esc_attr( $key ) ?>">
     27            <?php echo esc_html( $label ) ?>
    2828        </option>
    2929    <?php endforeach; ?>
  • pixtypes/trunk/core/views/form-partials/fields/switch.php

    r1115891 r3469313  
    5555    <div class="switch">
    5656        <input <?php echo $field->htmlattributes($attrs) ?> />
    57         <label for="<?php echo $idname ?>"><?php echo $processed_label ?></label>
     57        <label for="<?php echo esc_attr( $idname ) ?>"><?php echo wp_kses_post( $processed_label ) ?></label>
    5858    </div>
    5959<?php else: # rendering != 'inline' ?>
    60     <label for="<?php echo $idname ?>">
     60    <label for="<?php echo esc_attr( $idname ) ?>">
    6161        <input <?php echo $field->htmlattributes($attrs) ?> />
    62         <?php echo $processed_label ?>
     62        <?php echo wp_kses_post( $processed_label ) ?>
    6363    </label>
    6464<?php endif; ?>
  • pixtypes/trunk/core/views/form-partials/fields/tabular-group.php

    r1115891 r3469313  
    1212<tr valign="top">
    1313    <th scope="row">
    14         <?php echo $label ?>
     14        <?php echo esc_html( $label ) ?>
    1515    </th>
    1616    <td>
     
    1818
    1919            <legend class="screen-reader-text">
    20                 <span><?php echo $label ?></span>
     20                <span><?php echo esc_html( $label ) ?></span>
    2121            </legend>
    2222
     
    2828            <?php if ($field->hasmeta('note')): ?>
    2929                <small>
    30                     <em>(<?php echo $field->getmeta('note') ?>)</em>
     30                    <em>(<?php echo esc_html( $field->getmeta('note') ) ?>)</em>
    3131                </small>
    3232            <?php endif; ?>
  • pixtypes/trunk/core/views/form-partials/fields/text.php

    r1115891 r3469313  
    2424<?php elseif ($rendering == 'blocks'):  ?>
    2525<div class="text">
    26     <label id="<?php echo $name ?>"><?php echo $label ?></label>
     26    <label id="<?php echo esc_attr( $name ) ?>"><?php echo esc_html( $label ) ?></label>
    2727    <input <?php echo $field->htmlattributes($attrs) ?> />
    28     <span><?php echo $desc ?></span>
     28    <span><?php echo esc_html( $desc ) ?></span>
    2929</div>
    3030<?php else: # ?>
    3131    <div>
    32         <p><?php echo $desc ?></p>
    33         <label id="<?php echo $name ?>">
    34             <?php echo $label ?>
     32        <p><?php echo esc_html( $desc ) ?></p>
     33        <label id="<?php echo esc_attr( $name ) ?>">
     34            <?php echo esc_html( $label ) ?>
    3535            <input <?php echo $field->htmlattributes($attrs) ?>/>
    3636        </label>
  • pixtypes/trunk/features/metaboxes/cmb-field-select2-v2/cmb-field-select2.php

    r2124639 r3469313  
    3434 */
    3535function pw_select_v2( $field, $meta ) {
    36     echo '<select name="', $field['id'], '" id="', $field['id'], '" data-placeholder="' . $field['desc'] . '" class="select2">';
     36    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" data-placeholder="' . esc_attr( $field['desc'] ) . '" class="select2">';
    3737    echo '<option></option>';
    3838    if ( isset( $field['options'] ) && ! empty( $field['options'] ) ) {
     
    4141            $opt_value = is_array( $option ) && array_key_exists( 'value', $option ) ? $option['value'] : $option_key;
    4242
    43             echo '<option value="', $opt_value, '" ', selected( $meta == $opt_value ) ,'>', $opt_label, '</option>';
     43            echo '<option value="', esc_attr( $opt_value ), '" ', selected( $meta == $opt_value ) ,'>', esc_html( $opt_label ), '</option>';
    4444        }
    4545    }
     
    5353    $options = array();
    5454
    55     echo '<select name="', $field['id'], '[]" id="', $field['id'], '" data-placeholder="' . $field['desc'] . '" class="select2">';
     55    echo '<select name="', esc_attr( $field['id'] ), '[]" id="', esc_attr( $field['id'] ), '" data-placeholder="' . esc_attr( $field['desc'] ) . '" class="select2">';
    5656    echo '<option></option>';
    5757    if ( isset( $field['options'] ) && ! empty( $field['options'] ) ) {
     
    6060            $opt_value = is_array( $option ) && array_key_exists( 'value', $option ) ? $option['value'] : $option_key;
    6161
    62             echo '<option value="', $opt_value, '" ', selected( $meta == $opt_value ) ,'>', $opt_label, '</option>';
     62            echo '<option value="', esc_attr( $opt_value ), '" ', selected( $meta == $opt_value ) ,'>', esc_html( $opt_label ), '</option>';
    6363        }
    6464    }
     
    8686        }
    8787
    88         echo '<select name="', $field['id'], '[]" id="', $field['id'], '" data-placeholder="' . $field['desc'] . '" data-allow-clear="false" multiple class="select2">';
     88        echo '<select name="', esc_attr( $field['id'] ), '[]" id="', esc_attr( $field['id'] ), '" data-placeholder="' . esc_attr( $field['desc'] ) . '" data-allow-clear="false" multiple class="select2">';
    8989
    9090        if ( ! empty( $cpt_posts ) ) {
    9191            foreach ( $cpt_posts as $post ) {
    92                 echo '<option value="', $post->ID, '" ', selected( in_array( $post->ID, $meta ), true ) ,'>', $post->post_title, '</option>';
     92                echo '<option value="', esc_attr( $post->ID ), '" ', selected( in_array( $post->ID, $meta ), true ) ,'>', esc_html( $post->post_title ), '</option>';
    9393            }
    9494        }
  • pixtypes/trunk/features/metaboxes/cmb-field-select2/cmb-field-select2.php

    r1410208 r3469313  
    3434 */
    3535function pw_select( $field, $meta ) {
    36     echo '<select name="', $field['id'], '" id="', $field['id'], '" data-placeholder="' . $field['desc'] . '" class="select2">';
     36    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" data-placeholder="' . esc_attr( $field['desc'] ) . '" class="select2">';
    3737    echo '<option></option>';
    3838    if ( isset( $field['options'] ) && ! empty( $field['options'] ) ) {
     
    4141            $opt_value = is_array( $option ) && array_key_exists( 'value', $option ) ? $option['value'] : $option_key;
    4242
    43             echo '<option value="', $opt_value, '" ', selected( $meta == $opt_value ) ,'>', $opt_label, '</option>';
     43            echo '<option value="', esc_attr( $opt_value ), '" ', selected( $meta == $opt_value ) ,'>', esc_html( $opt_label ), '</option>';
    4444        }
    4545    }
     
    7171    }
    7272
    73     echo '<input type="hidden" name="' . $field['id'] . '" id="' . $field['id'] . '" data-placeholder="' . $field['desc'] . '" class="select2" value="' . $meta . '" />';
     73    echo '<input type="hidden" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" data-placeholder="' . esc_attr( $field['desc'] ) . '" class="select2" value="' . esc_attr( $meta ) . '" />';
    7474}
    7575
     
    108108    }
    109109
    110     echo '<input type="hidden" name="' . $field['id'] . '" id="' . $field['id'] . '" data-placeholder="' . $field['desc'] . '" class="select2" value="' . $meta . '" />';
     110    echo '<input type="hidden" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" data-placeholder="' . esc_attr( $field['desc'] ) . '" class="select2" value="' . esc_attr( $meta ) . '" />';
    111111}
    112112
  • pixtypes/trunk/features/metaboxes/css/style.css

    r1944663 r3469313  
    32203220    color: #DDD; }
    32213221  .cmb_metabox .selector-wrapper > select {
    3222     width: 100%; }
     3222    width: 100%;
     3223    -webkit-appearance: none;
     3224    -moz-appearance: none;
     3225    appearance: none; }
    32233226
    32243227.cmb_metabox .cmb-type-multicheck {
  • pixtypes/trunk/features/metaboxes/fields/gallery.php

    r1591155 r3469313  
    1212wp_localize_script( 'pixgallery', 'locals', array(
    1313    'ajax_url'      => admin_url( 'admin-ajax.php' ),
     14    'nonce'         => wp_create_nonce( 'pixtypes_gallery_preview' ),
    1415    'pixtypes_l18n' => array(
    1516        'confirmClearGallery' => esc_html__( 'Are you sure you want to clear this gallery?', 'pixtypes' ),
     
    2021    <ul></ul>
    2122    <a class="open_pixgallery" href="#">
    22         <input type="hidden" name="<?php echo $field['id']; ?>" id="pixgalleries" value="<?php echo '' !== $meta ? $meta : $field['std'] ?>"/>
     23        <input type="hidden" name="<?php echo esc_attr( $field['id'] ); ?>" id="pixgalleries" value="<?php echo esc_attr( '' !== $meta ? $meta : $field['std'] ); ?>"/>
    2324        <div><i class="icon dashicons dashicons-images-alt2"></i>
    2425            <span><?php esc_html_e( 'Add Image', 'pixtypes' ); ?></span></div>
  • pixtypes/trunk/features/metaboxes/fields/gmap_pins.php

    r1591155 r3469313  
    1717global $post; ?>
    1818<div class="gmap_pins_container">
    19     <ul class="gmap_pins" data-field_name="<?php echo $field['id']; ?>">
     19    <ul class="gmap_pins" data-field_name="<?php echo esc_attr( $field['id'] ); ?>">
    2020        <?php if ( empty( $meta ) ) {
    2121            $meta = array(
     
    3636                <fieldset class="pin_location_url">
    3737                    <label
    38                         for="<?php echo $field['id']; ?>[<?php echo $key ?>][location_url]">#<?php echo $key . ' ' . esc_html__( 'Location URL', 'pixtypes' ); ?></label>
    39                     <input type="text" name="<?php echo $field['id']; ?>[<?php echo $key ?>][location_url]"
    40                            value="<?php echo $pin['location_url']; ?>"/>
     38                        for="<?php echo esc_attr( $field['id'] ); ?>[<?php echo esc_attr( $key ); ?>][location_url]">#<?php echo esc_html( $key ) . ' ' . esc_html__( 'Location URL', 'pixtypes' ); ?></label>
     39                    <input type="text" name="<?php echo esc_attr( $field['id'] ); ?>[<?php echo esc_attr( $key ); ?>][location_url]"
     40                           value="<?php echo esc_attr( $pin['location_url'] ); ?>"/>
    4141                </fieldset>
    4242                <fieldset class="pin_name">
    4343                    <label
    44                         for="<?php echo $field['id']; ?>[<?php echo $key ?>][name]"><?php esc_html_e( 'Name', 'pixtypes' ); ?></label>
    45                     <input type="text" name="<?php echo $field['id']; ?>[<?php echo $key ?>][name]"
    46                            value="<?php echo $pin['name']; ?>"/>
     44                        for="<?php echo esc_attr( $field['id'] ); ?>[<?php echo esc_attr( $key ); ?>][name]"><?php esc_html_e( 'Name', 'pixtypes' ); ?></label>
     45                    <input type="text" name="<?php echo esc_attr( $field['id'] ); ?>[<?php echo esc_attr( $key ); ?>][name]"
     46                           value="<?php echo esc_attr( $pin['name'] ); ?>"/>
    4747                </fieldset>
    4848                <span class="pin_delete"></span>
     
    5454
    5555    <?php if ( isset( $field['desc'] ) && ! empty( $field['desc'] ) ) { ?>
    56         <span class="cmb_metabox_description"><?php echo $field['desc']; ?></span>
     56        <span class="cmb_metabox_description"><?php echo wp_kses_post( $field['desc'] ); ?></span>
    5757    <?php } ?>
    5858</div>
  • pixtypes/trunk/features/metaboxes/fields/image.php

    r1591155 r3469313  
    1212wp_localize_script( 'piximage', 'locals', array(
    1313    'ajax_url'      => admin_url( 'admin-ajax.php' ),
     14    'nonce'         => wp_create_nonce( 'pixtypes_gallery_preview' ),
    1415    'pixtypes_l18n' => array(
    1516        'setThumbnailImageTitle' => esc_html__( 'Choose Image', 'pixtypes' ),
     
    2021
    2122$class = empty( $field['class'] ) ? '' : $field['class']; ?>
    22 <div id="<?php echo $field['id']; ?>" class="piximage_field hidden <?php echo $class; ?>">
     23<div id="<?php echo esc_attr( $field['id'] ); ?>" class="piximage_field hidden <?php echo esc_attr( $class ); ?>">
    2324    <ul></ul>
    2425    <a class="open_piximage" href="#">
    25         <input type="hidden" name="<?php echo $field['id']; ?>" class="piximage_id"
    26                value="<?php echo '' !== $meta ? $meta : $field['std'] ?>"/>
     26        <input type="hidden" name="<?php echo esc_attr( $field['id'] ); ?>" class="piximage_id"
     27               value="<?php echo esc_attr( '' !== $meta ? $meta : $field['std'] ); ?>"/>
    2728        <div><i class="icon dashicons dashicons-images-alt2"></i>
    28             <span><?php echo empty ( $field['button_text'] ) ? esc_html__( 'Add Image', 'pixtypes' ) : $field['button_text']; ?></span>
     29            <span><?php echo empty ( $field['button_text'] ) ? esc_html__( 'Add Image', 'pixtypes' ) : esc_html( $field['button_text'] ); ?></span>
    2930        </div>
    3031        <span
    31             class="clear_image"><?php echo empty ( $field['clear_text'] ) ? esc_html__( 'Clear', 'pixtypes' ) : $field['clear_text']; ?></span>
     32            class="clear_image"><?php echo empty ( $field['clear_text'] ) ? esc_html__( 'Clear', 'pixtypes' ) : esc_html( $field['clear_text'] ); ?></span>
    3233    </a>
    3334</div>
  • pixtypes/trunk/features/metaboxes/fields/pix_builder.php

    r2124639 r3469313  
    55
    66    if( isset( $field['gridster_params'] ) ) {
    7         $gridster_params = ' data-params=\'' . json_encode( $field['gridster_params'] ) . '\'';
     7        $gridster_params = ' data-params=\'' . esc_attr( wp_json_encode( $field['gridster_params'] ) ) . '\'';
    88    }
    99
     
    2424    if ( $post_type !== 'page' ) {
    2525        echo '<style>
    26         .post-type-' . $post_type . ' #postdivrich {
     26        .post-type-' . esc_html( sanitize_html_class( $post_type ) ) . ' #postdivrich {
    2727            display: none !important;
    2828        }
     
    3030    }
    3131
    32     echo '<input type="hidden" name="', $field['id'], '" id="pix_builder" value="', '' !== $meta ? htmlspecialchars( $meta ) : $content, '" ' . $gridster_params . ' ' . ( $base64_decode ? 'data-base64_encoded="true"' : '' ) .' />'; ?>
     32    echo '<input type="hidden" name="', esc_attr( $field['id'] ), '" id="pix_builder" value="', '' !== $meta ? esc_attr( $meta ) : esc_attr( $content ), '" ' . $gridster_params . ' ' . ( $base64_decode ? 'data-base64_encoded="true"' : '' ) .' />'; ?>
    3333    <div class="pixbuilder-controls">
    3434        <button class="add_block button button-primary button-large"
     
    7878
    7979                                        if ( isset( $attach[0] ) && ! empty( $attach[0] ) ) {
    80                                             $content          = '<img class="image_preview" src="' . $attach[0] . '">';
    81                                             $controls_content = '<a class="open_media" href="#" class="wp-gallery" data-attachment_id="' . $block->content . '"><span>' . esc_html__( 'Set Image', 'pixtypes' ) . '</span></a>';
     80                                            $content          = '<img class="image_preview" src="' . esc_url( $attach[0] ) . '">';
     81                                            $controls_content = '<a class="open_media" href="#" class="wp-gallery" data-attachment_id="' . esc_attr( $block->content ) . '"><span>' . esc_html__( 'Set Image', 'pixtypes' ) . '</span></a>';
    8282                                        }
    8383                                    } else {
    8484                                        $content          = '<img class="image_preview">';
    85                                         $controls_content = '<a class="open_media" href="#" class="wp-gallery" data-attachment_id="' . $block->content . '"><span>' . esc_html__( 'Set Image', 'pixtypes' ) . '</pan></a>';
     85                                        $controls_content = '<a class="open_media" href="#" class="wp-gallery" data-attachment_id="' . esc_attr( $block->content ) . '"><span>' . esc_html__( 'Set Image', 'pixtypes' ) . '</pan></a>';
    8686                                    }
    8787                                }
     
    115115                            }
    116116                        } ?>
    117                         <li id="block_<?php echo $block->id ?>" class="block-type--<?php echo $block->type; ?> item"
    118                             data-type="<?php echo $block->type ?>" data-row="<?php echo $block->row ?>"
    119                             data-col="<?php echo $block->col ?>" data-sizex="<?php echo $block->size_x ?>"
    120                             data-sizey="<?php echo $block->size_y ?>">
     117                        <li id="block_<?php echo esc_attr( $block->id ); ?>" class="block-type--<?php echo esc_attr( $block->type ); ?> item"
     118                            data-type="<?php echo esc_attr( $block->type ); ?>" data-row="<?php echo esc_attr( $block->row ); ?>"
     119                            data-col="<?php echo esc_attr( $block->col ); ?>" data-sizex="<?php echo esc_attr( $block->size_x ); ?>"
     120                            data-sizey="<?php echo esc_attr( $block->size_y ); ?>">
    121121                            <div class="item__controls">
    122122                                <ul class="nav nav--controls">
     
    131131                                                        class="position__ui-cell top <?php echo 0 == intval($block->position['top']) ? '' : 'active'; ?>">
    132132                                                        <div class="position__ui-handle"
    133                                                              data-step="<?php echo $block->position['top']; ?>"><?php esc_html_e( 'top', 'pixtypes' ); ?></div>
     133                                                             data-step="<?php echo esc_attr( $block->position['top'] ); ?>"><?php esc_html_e( 'top', 'pixtypes' ); ?></div>
    134134                                                    </div>
    135135                                                </div>
     
    138138                                                        class="position__ui-cell left <?php echo 0 == intval($block->position['left']) ? '' : 'active'; ?>">
    139139                                                        <div class="position__ui-handle"
    140                                                              data-step="<?php echo $block->position['left']; ?>"><?php esc_html_e( 'left', 'pixtypes' ); ?></div>
    141                                                     </div>
    142                                                     <div class="position__ui-cell middle <?php echo $middle_status; ?>">
     140                                                             data-step="<?php echo esc_attr( $block->position['left'] ); ?>"><?php esc_html_e( 'left', 'pixtypes' ); ?></div>
     141                                                    </div>
     142                                                    <div class="position__ui-cell middle <?php echo esc_attr( $middle_status ); ?>">
    143143                                                        <div class="position__ui-handle">middle</div>
    144144                                                    </div>
     
    146146                                                        class="position__ui-cell right <?php echo 0 == intval($block->position['right']) ? '' : 'active'; ?>">
    147147                                                        <div class="position__ui-handle"
    148                                                              data-step="<?php echo $block->position['right']; ?>"><?php esc_html_e( 'right', 'pixtypes' ); ?></div>
     148                                                             data-step="<?php echo esc_attr( $block->position['right'] ); ?>"><?php esc_html_e( 'right', 'pixtypes' ); ?></div>
    149149                                                    </div>
    150150                                                </div>
     
    153153                                                        class="position__ui-cell bottom <?php echo 0 == intval($block->position['bottom']) ? '' : 'active'; ?>">
    154154                                                        <div class="position__ui-handle"
    155                                                              data-step="<?php echo $block->position['bottom']; ?>"><?php esc_html_e( 'bottom', 'pixtypes' ); ?></div>
     155                                                             data-step="<?php echo esc_attr( $block->position['bottom'] ); ?>"><?php esc_html_e( 'bottom', 'pixtypes' ); ?></div>
    156156                                                    </div>
    157157                                                </div>
     
    164164                                </ul>
    165165                            </div>
    166                             <div class="item__content block_content <?php echo $empty_class; ?>">
     166                            <div class="item__content block_content <?php echo esc_attr( $empty_class ); ?>">
    167167                                <?php echo $content ?>
    168168                            </div>
     
    175175    </div>
    176176</div>
    177 <?php add_action( 'admin_footer', 'my_admin_footer_function' );
    178 function my_admin_footer_function() { ?>
     177<?php add_action( 'admin_footer', 'pixtypes_admin_footer_function' );
     178function pixtypes_admin_footer_function() { ?>
    179179    <div class="pix_builder_editor_modal_container" style="display:none">
    180180        <div class="modal_wrapper">
  • pixtypes/trunk/features/metaboxes/fields/playlist.php

    r1591155 r3469313  
    1111wp_localize_script( 'pixplaylist', 'playlist_locals', array(
    1212    'ajax_url'      => admin_url( 'admin-ajax.php' ),
     13    'nonce'         => wp_create_nonce( 'pixtypes_playlist_preview' ),
    1314    'playlist_type' => $playlist_type,
    1415    'pixtypes_l18n' => array(
     
    2021    <ul></ul>
    2122    <a class="open_pixvideos" href="#">
    22         <input type="hidden" name="<?php echo $field['id'] ?>" id="pixplaylist" value="<?php echo '' !== $meta ? $meta : $field['std']; ?>"/>
     23        <input type="hidden" name="<?php echo esc_attr( $field['id'] ); ?>" id="pixplaylist" value="<?php echo esc_attr( '' !== $meta ? $meta : $field['std'] ); ?>"/>
    2324        <div><i class="icon dashicons dashicons-format-video"></i> <span><?php esc_html_e('Add Video', 'pixtypes' ); ?></span></div>
    2425        <span class="clear_gallery"><?php esc_html_e( 'Clear', 'pixtypes' ); ?></span>
  • pixtypes/trunk/features/metaboxes/fields/portfolio-gallery.php

    r1115891 r3469313  
    6565    }
    6666
    67     echo '<input type="hidden" name="'. $field['id'] .'" id="portfolio_gallery_val" />'; ?>
     67    echo '<input type="hidden" name="'. esc_attr( $field['id'] ) .'" id="portfolio_gallery_val" />'; ?>
    6868
    6969    <div id="wpgrade_portfolio_editor_modal" style="display: none">
  • pixtypes/trunk/features/metaboxes/init.php

    r2956824 r3469313  
    116116        global $pagenow;
    117117        if ( $upload && in_array( $pagenow, array( 'page.php', 'page-new.php', 'post.php', 'post-new.php' ) ) ) {
    118             add_action( 'admin_head', array( &$this, 'add_post_enctype' ) );
     118            add_action( 'admin_head', array( $this, 'add_post_enctype' ) );
    119119        }
    120120
     
    122122            $this->add();
    123123        } else {
    124             add_action( 'admin_menu', array( &$this, 'add' ) );
    125         }
    126 
    127         add_action( 'save_post', array( &$this, 'save' ) );
    128 
    129         add_action( 'admin_head', array( &$this, 'fold_display' ) );
    130 
    131         add_filter( 'cmb_show_on', array( &$this, 'add_for_id' ), 10, 2 );
    132         //add_filter( 'cmb_show_on', array( &$this, 'add_for_page_template' ), 10, 2 );
    133         //add_filter( 'cmb_show_on', array( &$this, 'add_for_specific_select_value' ), 10, 2 );
     124            add_action( 'admin_menu', array( $this, 'add' ) );
     125        }
     126
     127        add_action( 'save_post', array( $this, 'save' ) );
     128
     129        add_action( 'admin_head', array( $this, 'fold_display' ) );
     130
     131        add_filter( 'cmb_show_on', array( $this, 'add_for_id' ), 10, 2 );
     132        //add_filter( 'cmb_show_on', array( $this, 'add_for_page_template' ), 10, 2 );
     133        //add_filter( 'cmb_show_on', array( $this, 'add_for_specific_select_value' ), 10, 2 );
    134134
    135135        //add_filter('_wp_post_revision_field_post_content', array( $this, 'pixtypes_fix_builder_revisions_display'), 915, 4 );
     
    172172                    $this->_meta_box['id'],
    173173                    $this->_meta_box['title'],
    174                     array( &$this, 'show' ),
     174                    array( $this, 'show' ),
    175175                    $page,
    176176                    $this->_meta_box['context'],
     
    195195        // If we're showing it based on ID, get the current ID
    196196        if ( isset( $_GET['post'] ) ) {
    197             $post_id = $_GET['post'];
     197            $post_id = absint( $_GET['post'] );
    198198        } elseif ( isset( $_POST['post_ID'] ) ) {
    199             $post_id = $_POST['post_ID'];
     199            $post_id = absint( $_POST['post_ID'] );
    200200        }
    201201        if ( ! isset( $post_id ) ) {
     
    223223        // Get the current ID
    224224        if ( isset( $_GET['post'] ) ) {
    225             $post_id = $_GET['post'];
     225            $post_id = absint( $_GET['post'] );
    226226        } elseif ( isset( $_POST['post_ID'] ) ) {
    227             $post_id = $_POST['post_ID'];
     227            $post_id = absint( $_POST['post_ID'] );
    228228        }
    229229        if ( ! ( isset( $post_id ) || is_page() ) ) {
     
    254254        // Get the current ID
    255255        if ( isset( $_GET['post'] ) ) {
    256             $post_id = $_GET['post'];
     256            $post_id = absint( $_GET['post'] );
    257257        } elseif ( isset( $_POST['post_ID'] ) ) {
    258             $post_id = $_POST['post_ID'];
     258            $post_id = absint( $_POST['post_ID'] );
    259259        }
    260260
     
    369369
    370370        // Use nonce for verification
    371         echo '<input type="hidden" name="wp_meta_box_nonce" value="', wp_create_nonce( basename( __FILE__ ) ), '" />';
     371        echo '<input type="hidden" name="wp_meta_box_nonce" value="', wp_create_nonce( 'pixtypes_save_metabox' ), '" />';
    372372
    373373        // load assets only when we have a metabox on page
    374         cmb_enqueue_scripts();
     374        pixtypes_cmb_enqueue_scripts();
    375375
    376376        echo '<ul class="form-table cmb_metabox">';
     
    435435                        $on = $display_on['on'];
    436436
    437                         $requires .= 'data-when_key="' . $on['field'] . '"';
     437                        $requires .= 'data-when_key="' . esc_attr( $on['field'] ) . '"';
    438438
    439439                        if ( is_array( $on['value'] ) ) {
    440                             $requires .= 'data-has_value=\'' . json_encode( $on['value'] ) . '\'';
     440                            $requires .= 'data-has_value=\'' . esc_attr( wp_json_encode( $on['value'] ) ) . '\'';
    441441                        } else {
    442                             $requires .= 'data-has_value="' . $on['value'] . '"';
     442                            $requires .= 'data-has_value="' . esc_attr( $on['value'] ) . '"';
    443443                        }
    444444                    }
    445445                }
    446446
    447                 echo '<li class="' . $classes . '" ' . $requires . '>';
     447                echo '<li class="' . esc_attr( $classes ) . '" ' . $requires . '>';
    448448            }
    449449
     
    452452                if ( isset( $this->_meta_box['show_names'] ) && $this->_meta_box['show_names'] == true ) {
    453453                    if ( isset( $field['show_names'] ) && $field['show_names'] == true ) {
    454                         echo '<h3><label for="', $field['id'], '">', $field['name'], '</label></h3>';
     454                        echo '<h3><label for="', esc_attr( $field['id'] ), '">', esc_html( $field['name'] ), '</label></h3>';
    455455                    }
    456456                }
    457457            }
    458458            if ( ! empty($field['desc']) ) {
    459                 echo "<div>" . $field['desc'] . "</div>";
     459                echo "<div>" . wp_kses_post( $field['desc'] ) . "</div>";
    460460            }
    461461            echo '</div>';
     
    469469
    470470                case 'text':
    471                     echo '<input class="cmb_text" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta, '" />';
     471                    echo '<input class="cmb_text" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( $meta ), '" />';
    472472                    break;
    473473                case 'text_small':
    474                     echo '<input class="cmb_text cmb_text_small" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta, '" />';
     474                    echo '<input class="cmb_text cmb_text_small" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( $meta ), '" />';
    475475                    break;
    476476                case 'text_medium':
    477                     echo '<input class="cmb_text cmb_text_medium" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta, '" />';
     477                    echo '<input class="cmb_text cmb_text_medium" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( $meta ), '" />';
    478478                    break;
    479479
     
    483483                    if ( isset( $field['html_args'] ) && ! empty( $field['html_args'] ) ) {
    484484                        foreach ( $field['html_args'] as $key => $att ) {
    485                             $atts .= $key . '="' . $att . '" ';
     485                            $atts .= esc_attr( $key ) . '="' . esc_attr( $att ) . '" ';
    486486                        }
    487487                    } ?>
    488                     <input class="cmb_text_range" type="range" name="<?php echo $field['id']; ?>"
    489                            id="<?php echo $field['id'] ?>"
    490                            value="<?php echo '' !== $meta ? $meta : $field['std']; ?>" <?php echo $atts ?>
    491                            style="background-size: <?php echo 0 !== $meta ? $meta : $field['std']; ?>% 100%;"
    492                            oninput="<?php echo $field['id'] . '_output.value = ' . $field['id'] . '.value'; ?>"/>
    493                     <output name="<?php echo $field['id'] ?>_output" id="<?php echo $field['id']; ?>_output">
    494                         <?php echo '' !== $meta ? $meta : $field['std']; ?>
     488                    <input class="cmb_text_range" type="range" name="<?php echo esc_attr( $field['id'] ); ?>"
     489                           id="<?php echo esc_attr( $field['id'] ); ?>"
     490                           value="<?php echo esc_attr( '' !== $meta ? $meta : $field['std'] ); ?>" <?php echo $atts; ?>
     491                           style="background-size: <?php echo esc_attr( 0 !== $meta ? $meta : $field['std'] ); ?>% 100%;"
     492                           oninput="<?php echo esc_attr( $field['id'] . '_output.value = ' . $field['id'] . '.value' ); ?>"/>
     493                    <output name="<?php echo esc_attr( $field['id'] ); ?>_output" id="<?php echo esc_attr( $field['id'] ); ?>_output">
     494                        <?php echo esc_html( '' !== $meta ? $meta : $field['std'] ); ?>
    495495                    </output>
    496496                    <?php break;
    497497                case 'text_date':
    498                     echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? $meta : $field['std'], '" />';
     498                    echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( '' !== $meta ? $meta : $field['std'] ), '" />';
    499499                    break;
    500500                case 'text_date_timestamp':
    501                     echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? date( 'm\/d\/Y', $meta ) : $field['std'], '" />';
     501                    echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( '' !== $meta ? date( 'm\/d\/Y', $meta ) : $field['std'] ), '" />';
    502502                    break;
    503503
    504504                case 'text_datetime_timestamp':
    505                     echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', $field['id'], '[date]" id="', $field['id'], '_date" value="', '' !== $meta ? date( 'm\/d\/Y', $meta ) : $field['std'], '" />';
    506                     echo '<input class="cmb_timepicker text_time" type="text" name="', $field['id'], '[time]" id="', $field['id'], '_time" value="', '' !== $meta ? date( 'h:i A', $meta ) : $field['std'], '" />';
     505                    echo '<input class="cmb_text_small cmb_datepicker" type="text" name="', esc_attr( $field['id'] ), '[date]" id="', esc_attr( $field['id'] ), '_date" value="', esc_attr( '' !== $meta ? date( 'm\/d\/Y', $meta ) : $field['std'] ), '" />';
     506                    echo '<input class="cmb_timepicker text_time" type="text" name="', esc_attr( $field['id'] ), '[time]" id="', esc_attr( $field['id'] ), '_time" value="', esc_attr( '' !== $meta ? date( 'h:i A', $meta ) : $field['std'] ), '" />';
    507507                    break;
    508508                case 'text_time':
    509                     echo '<input class="cmb_timepicker text_time" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? $meta : $field['std'], '" />';
     509                    echo '<input class="cmb_timepicker text_time" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( '' !== $meta ? $meta : $field['std'] ), '" />';
    510510                    break;
    511511                case 'text_money':
    512                     echo '$ <input class="cmb_text_money" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? $meta : $field['std'], '" />';
     512                    echo '$ <input class="cmb_text_money" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( '' !== $meta ? $meta : $field['std'] ), '" />';
    513513                    break;
    514514                case 'colorpicker':
     
    523523                        $meta = "#";
    524524                    }
    525                     echo '<input class="cmb_colorpicker cmb_text_small" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta, '" />';
     525                    echo '<input class="cmb_colorpicker cmb_text_small" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( $meta ), '" />';
    526526                    break;
    527527                case 'textarea':
    528                     echo '<textarea class="cmb_textarea" name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="10">', $meta, '</textarea>';
     528                    echo '<textarea class="cmb_textarea" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" cols="60" rows="10">', esc_textarea( $meta ), '</textarea>';
    529529                    break;
    530530                case 'textarea_small':
    531                     echo '<textarea class="cmb_textarea" name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4">', $meta, '</textarea>';
     531                    echo '<textarea class="cmb_textarea" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" cols="60" rows="4">', esc_textarea( $meta ), '</textarea>';
    532532                    break;
    533533                case 'textarea_code':
    534534                    $rows = $cols = '';
    535535                    if( isset( $field['rows'] ) && ! empty( $field['rows'] ) ) {
    536                         $rows =  'rows="' . $field['rows'] . '"';
     536                        $rows =  'rows="' . esc_attr( $field['rows'] ) . '"';
    537537                    }
    538538
    539539                    if( isset( $field['cols'] ) && ! empty( $field['cols'] ) ) {
    540                         $cols = 'cols="' . $field['cols'] . '"';
     540                        $cols = 'cols="' . esc_attr( $field['cols'] ) . '"';
    541541                    } else {
    542542                        $cols = 'style="width: 100%"';
    543543                    }
    544544
    545                     echo '<textarea name="', $field['id'], '" id="', $field['id'], '" ' . $cols .' ' . $rows . ' class="cmb_textarea cmb_textarea_code">', $meta, '</textarea>';
     545                    echo '<textarea name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" ' . $cols .' ' . $rows . ' class="cmb_textarea cmb_textarea_code">', esc_textarea( $meta ), '</textarea>';
    546546                    break;
    547547                case 'select':
     
    552552
    553553                    echo '<div class="selector-wrapper dashicons-before dashicons-arrow-down-alt2">';
    554                     echo '<select name="', $field['id'], '" id="', $field['id'], '">';
     554                    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '">';
    555555
    556556                    foreach ( $field['options'] as $option ) {
     
    562562                            $option['value'] = 0;
    563563                        }
    564                         echo '<option value="', $option['value'], '"', $meta == $option['value'] ? ' selected="selected"' : '', '>', $option['name'], '</option>';
     564                        echo '<option value="', esc_attr( $option['value'] ), '"', $meta == $option['value'] ? ' selected="selected"' : '', '>', esc_html( $option['name'] ), '</option>';
    565565                    }
    566566                    echo '</select>';
     
    571571
    572572                    echo '<div class="selector-wrapper dashicons-before dashicons-arrow-down-alt2">';
    573                     echo '<select name="', $field['id'], '" id="', $field['id'], '">';
     573                    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '">';
    574574                    $args = array(
    575575                        'posts_per_page' => - 1,
     
    581581                    if ( ! empty( $cpt_posts ) ) {
    582582                        foreach ( $cpt_posts as $post ) {
    583                             echo '<option value="', $post->ID, '"', $meta == $post->ID ? ' selected="selected"' : '', '>', $post->post_title, '</option>';
     583                            echo '<option value="', esc_attr( $post->ID ), '"', $meta == $post->ID ? ' selected="selected"' : '', '>', esc_html( $post->post_title ), '</option>';
    584584                        }
    585585                    }
     
    590590                case 'select_cpt_term':
    591591                    echo '<div class="selector-wrapper dashicons-before dashicons-arrow-down-alt2">';
    592                     echo '<select name="', $field['id'], '" id="', $field['id'], '">';
     592                    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '">';
    593593                    $cpt_terms = get_terms( $field['taxonomy'], 'orderby=count&hide_empty=0' );
    594594                    if ( ! empty( $cpt_terms ) ) {
    595595                        foreach ( $cpt_terms as $term ) {
    596                             echo '<option value="', $term->slug, '"', $meta == $term->slug ? ' selected="selected"' : '', '>', $term->name, '</option>';
     596                            echo '<option value="', esc_attr( $term->slug ), '"', $meta == $term->slug ? ' selected="selected"' : '', '>', esc_html( $term->name ), '</option>';
    597597                        }
    598598                    }
     
    607607                    $i = 1;
    608608                    foreach ( $field['options'] as $option ) {
    609                         echo '<div class="cmb_radio_inline_option"><input type="radio" name="', $field['id'], '" id="', $field['id'], $i, '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', $field['id'], $i, '">', $option['name'], '</label></div>';
     609                        echo '<div class="cmb_radio_inline_option"><input type="radio" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] . $i ), '" value="', esc_attr( $option['value'] ), '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', esc_attr( $field['id'] . $i ), '">', esc_html( $option['name'] ), '</label></div>';
    610610                        $i ++;
    611611                    }
     
    619619                    $i = 1;
    620620                    foreach ( $field['options'] as $option ) {
    621                         echo '<li><input type="radio" name="', $field['id'], '" id="', $field['id'], $i, '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', $field['id'], $i, '">', $option['name'] . '</label></li>';
     621                        echo '<li><input type="radio" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] . $i ), '" value="', esc_attr( $option['value'] ), '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', esc_attr( $field['id'] . $i ), '">', esc_html( $option['name'] ) . '</label></li>';
    622622                        $i ++;
    623623                    }
     
    625625                    break;
    626626                case 'checkbox':
    627                     echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', ( $meta === 'on' ) ? ' checked="checked"' : '', ' />';
     627                    echo '<input type="checkbox" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '"', ( $meta === 'on' ) ? ' checked="checked"' : '', ' />';
    628628                    break;
    629629                case 'multicheck':
     
    637637                        // Append `[]` to the name to get multiple values
    638638                        // Use in_array() to check whether the current option should be checked
    639                         echo '<li><input type="checkbox" name="', $field['id'], '[]" id="', $field['id'], $i, '" value="', $value, '"', in_array( $value, $meta ) ? ' checked="checked"' : '', ' /><label for="', $field['id'], $i, '">', $name, '</label></li>';
     639                        echo '<li><input type="checkbox" name="', esc_attr( $field['id'] ), '[]" id="', esc_attr( $field['id'] . $i ), '" value="', esc_attr( $value ), '"', in_array( $value, $meta ) ? ' checked="checked"' : '', ' /><label for="', esc_attr( $field['id'] . $i ), '">', esc_html( $name ), '</label></li>';
    640640                        $i ++;
    641641                    }
     
    644644                case 'title':
    645645                    if ( isset( $field['value']) ) {
    646                         echo '<div class="cmb_metabox_title" id="', $field['id'], '">', $field['value'], '</div>';
     646                        echo '<div class="cmb_metabox_title" id="', esc_attr( $field['id'] ), '">', esc_html( $field['value'] ), '</div>';
    647647                    }
    648648                    break;
     
    653653
    654654                    echo '<div class="selector-wrapper dashicons-before dashicons-arrow-down-alt2">';
    655                     echo '<select name="', $field['id'], '" id="', $field['id'], '">';
     655                    echo '<select name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '">';
    656656                    $names = wp_get_object_terms( $post->ID, $field['taxonomy'] );
    657657                    $terms = get_terms( $field['taxonomy'], 'hide_empty=0' );
    658658                    foreach ( $terms as $term ) {
    659659                        if ( ! is_wp_error( $names ) && ! empty( $names ) && ! strcmp( $term->slug, $names[0]->slug ) ) {
    660                             echo '<option value="' . $term->slug . '" selected>' . $term->name . '</option>';
     660                            echo '<option value="' . esc_attr( $term->slug ) . '" selected>' . esc_html( $term->name ) . '</option>';
    661661                        } else {
    662                             echo '<option value="' . $term->slug . '  ', $meta == $term->slug ? $meta : ' ', '  ">' . $term->name . '</option>';
     662                            echo '<option value="' . esc_attr( $term->slug ) . '  ', $meta == $term->slug ? esc_attr( $meta ) : ' ', '  ">' . esc_html( $term->name ) . '</option>';
    663663                        }
    664664                    }
     
    672672                    foreach ( $terms as $term ) {
    673673                        if ( ! is_wp_error( $names ) && ! empty( $names ) && ! strcmp( $term->slug, $names[0]->slug ) ) {
    674                             echo '<li><input type="radio" name="', $field['id'], '" value="' . $term->slug . '" checked>' . $term->name . '</li>';
     674                            echo '<li><input type="radio" name="', esc_attr( $field['id'] ), '" value="' . esc_attr( $term->slug ) . '" checked>' . esc_html( $term->name ) . '</li>';
    675675                        } else {
    676                             echo '<li><input type="radio" name="', $field['id'], '" value="' . $term->slug . '  ', $meta == $term->slug ? $meta : ' ', '  ">' . $term->name . '</li>';
     676                            echo '<li><input type="radio" name="', esc_attr( $field['id'] ), '" value="' . esc_attr( $term->slug ) . '  ', $meta == $term->slug ? esc_attr( $meta ) : ' ', '  ">' . esc_html( $term->name ) . '</li>';
    677677                        }
    678678                    }
     
    684684                    $terms = get_terms( $field['taxonomy'], 'hide_empty=0' );
    685685                    foreach ( $terms as $term ) {
    686                         echo '<li><input type="checkbox" name="', $field['id'], '[]" id="', $field['id'], '" value="', $term->name, '"';
     686                        echo '<li><input type="checkbox" name="', esc_attr( $field['id'] ), '[]" id="', esc_attr( $field['id'] ), '" value="', esc_attr( $term->name ), '"';
    687687                        foreach ( $names as $name ) {
    688688                            if ( $term->slug == $name->slug ) {
     
    690690                            };
    691691                        }
    692                         echo ' /><label>', $term->name, '</label></li>';
     692                        echo ' /><label>', esc_html( $term->name ), '</label></li>';
    693693                    }
    694694                    echo '</ul>';
    695695                    break;
    696696                case 'file_list':
    697                     echo '<input class="cmb_upload_file" type="text" size="36" name="', $field['id'], '" value="" />';
     697                    echo '<input class="cmb_upload_file" type="text" size="36" name="', esc_attr( $field['id'] ), '" value="" />';
    698698                    echo '<input class="cmb_upload_button button" type="button" value="Upload File" />';
    699699                    $args        = array(
     
    720720                        $input_type_url = "text";
    721721                    }
    722                     echo '<input class="cmb_upload_file" type="' . $input_type_url . '" size="45" id="', $field['id'], '" name="', $field['id'], '" value="', $meta, '" />';
     722                    echo '<input class="cmb_upload_file" type="' . esc_attr( $input_type_url ) . '" size="45" id="', esc_attr( $field['id'] ), '" name="', esc_attr( $field['id'] ), '" value="', esc_attr( $meta ), '" />';
    723723                    echo '<input class="cmb_upload_button button" type="button" value="Upload File" />';
    724                     echo '<input class="cmb_upload_file_id" type="hidden" id="', $field['id'], '_id" name="', $field['id'], '_id" value="', get_post_meta( $post->ID, $field['id'] . "_id", true ), '" />';
    725                     echo '<div id="', $field['id'], '_status" class="cmb_media_status">';
     724                    echo '<input class="cmb_upload_file_id" type="hidden" id="', esc_attr( $field['id'] ), '_id" name="', esc_attr( $field['id'] ), '_id" value="', esc_attr( get_post_meta( $post->ID, $field['id'] . "_id", true ) ), '" />';
     725                    echo '<div id="', esc_attr( $field['id'] ), '_status" class="cmb_media_status">';
    726726                    if ( $meta != '' ) {
    727727                        $check_image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $meta );
    728728                        if ( $check_image ) {
    729729                            echo '<div class="img_status">';
    730                             echo '<img src="', $meta, '" alt="" />';
    731                             echo '<a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">Remove Image</a>';
     730                            echo '<img src="', esc_url( $meta ), '" alt="" />';
     731                            echo '<a href="#" class="cmb_remove_file_button" rel="', esc_attr( $field['id'] ), '">Remove Image</a>';
    732732                            echo '</div>';
    733733                        } else {
     
    736736                                $title = $parts[ $i ];
    737737                            }
    738                             echo 'File: <strong>', $title, '</strong>&nbsp;&nbsp;&nbsp; (<a href="', $meta, '" target="_blank" rel="external">Download</a> / <a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">Remove</a>)';
     738                            echo 'File: <strong>', esc_html( $title ), '</strong>&nbsp;&nbsp;&nbsp; (<a href="', esc_url( $meta ), '" target="_blank" rel="external">Download</a> / <a href="#" class="cmb_remove_file_button" rel="', esc_attr( $field['id'] ), '">Remove</a>)';
    739739                        }
    740740                    }
     
    747747                        $input_type_url = "text";
    748748                    }
    749                     echo '<input class="cmb_upload_file attachment" type="' . $input_type_url . '" size="45" id="', $field['id'], '" name="', $field['id'], '" value=\'', $meta, '\' />';
     749                    echo '<input class="cmb_upload_file attachment" type="' . esc_attr( $input_type_url ) . '" size="45" id="', esc_attr( $field['id'] ), '" name="', esc_attr( $field['id'] ), '" value=\'', esc_attr( $meta ), '\' />';
    750750                    echo '<input class="cmb_upload_button button" type="button" value="Upload File" />';
    751                     echo '<input class="cmb_upload_file_id" type="hidden" id="', $field['id'], '_id" name="', $field['id'], '_id" value="', get_post_meta( $post->ID, $field['id'] . "_id", true ), '" />';
    752                     echo '<div id="', $field['id'], '_status" class="cmb_media_status">';
     751                    echo '<input class="cmb_upload_file_id" type="hidden" id="', esc_attr( $field['id'] ), '_id" name="', esc_attr( $field['id'] ), '_id" value="', esc_attr( get_post_meta( $post->ID, $field['id'] . "_id", true ) ), '" />';
     752                    echo '<div id="', esc_attr( $field['id'] ), '_status" class="cmb_media_status">';
    753753                    if ( $meta != '' ) {
    754754                        $check_image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $meta );
     
    756756                            echo '<div class="img_status">';
    757757                            $meta_img = (array) json_decode( $meta );
    758                             echo '<img src="' . $meta_img["link"] . '" alt="" />';
    759                             echo '<a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">Remove Image</a>';
     758                            echo '<img src="' . esc_url( $meta_img["link"] ) . '" alt="" />';
     759                            echo '<a href="#" class="cmb_remove_file_button" rel="', esc_attr( $field['id'] ), '">Remove Image</a>';
    760760                            echo '</div>';
    761761                        } else {
     
    764764                                $title = $parts[ $i ];
    765765                            }
    766                             echo 'File: <strong>', $title, '</strong>&nbsp;&nbsp;&nbsp; (<a href="', $meta, '" target="_blank" rel="external">Download</a> / <a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">Remove</a>)';
     766                            echo 'File: <strong>', esc_html( $title ), '</strong>&nbsp;&nbsp;&nbsp; (<a href="', esc_url( $meta ), '" target="_blank" rel="external">Download</a> / <a href="#" class="cmb_remove_file_button" rel="', esc_attr( $field['id'] ), '">Remove</a>)';
    767767                        }
    768768                    }
     
    848848
    849849                case 'oembed':
    850                     echo '<input class="cmb_oembed" type="text" name="', $field['id'], '" id="', $field['id'], '" value="', '' !== $meta ? $meta : $field['std'], '" />';
     850                    echo '<input class="cmb_oembed" type="text" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] ), '" value="', esc_attr( '' !== $meta ? $meta : $field['std'] ), '" />';
    851851                    echo '<p class="cmb-spinner spinner"></p>';
    852                     echo '<div id="', $field['id'], '_status" class="cmb_media_status ui-helper-clearfix embed_wrap">';
     852                    echo '<div id="', esc_attr( $field['id'] ), '_status" class="cmb_media_status ui-helper-clearfix embed_wrap">';
    853853                    if ( $meta != '' ) {
    854854                        $check_embed = $GLOBALS['wp_embed']->run_shortcode( '[embed]' . esc_url( $meta ) . '[/embed]' );
     
    856856                            echo '<div class="embed_status">';
    857857                            echo $check_embed;
    858                             echo '<a href="#" class="cmb_remove_file_button" rel="', $field['id'], '">Remove Embed</a>';
     858                            echo '<a href="#" class="cmb_remove_file_button" rel="', esc_attr( $field['id'] ), '">Remove Embed</a>';
    859859                            echo '</div>';
    860860                        } else {
     
    872872                    $i = 1;
    873873                    foreach ( $field['options'] as $option ) {
    874                         echo '<li><input type="radio" name="', $field['id'], '" id="', $field['id'], $i, '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', $field['id'], $i, '">', '<span>' . $option['value'] . '</span>' . '</label></li>';
     874                        echo '<li><input type="radio" name="', esc_attr( $field['id'] ), '" id="', esc_attr( $field['id'] . $i ), '" value="', esc_attr( $option['value'] ), '"', $meta == $option['value'] ? ' checked="checked"' : '', ' /><label for="', esc_attr( $field['id'] . $i ), '">', '<span>' . esc_html( $option['value'] ) . '</span>' . '</label></li>';
    875875                        $i ++;
    876876                    }
     
    920920            (function ($) {
    921921                $(document).ready(function () {
    922                     var metabox = $('#<?php echo $this->_meta_box['id'];  ?>');
     922                    var metabox = $('#<?php echo esc_js( $this->_meta_box['id'] );  ?>');
    923923                    metabox.addClass('display_on')
    924924                        .attr('data-action', '<?php echo 'show'; ?>')
    925                         .attr('data-when_key', '<?php echo $display_on['on']['field']; ?>')
    926                         .attr('data-has_value', '<?php echo $display_on['on']['value']; ?>');
     925                        .attr('data-when_key', '<?php echo esc_js( $display_on['on']['field'] ); ?>')
     926                        .attr('data-has_value', '<?php echo esc_js( $display_on['on']['value'] ); ?>');
    927927                });
    928928            })(jQuery);
     
    937937
    938938        // verify nonce
    939         if ( ! isset( $_POST['wp_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['wp_meta_box_nonce'], basename( __FILE__ ) ) ) {
     939        if ( ! isset( $_POST['wp_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['wp_meta_box_nonce'], 'pixtypes_save_metabox' ) ) {
    940940            return $post_id;
    941941        }
     
    10531053 * Adding scripts and styles
    10541054 */
    1055 function cmb_register_scripts( $hook ) {
     1055function pixtypes_cmb_register_scripts( $hook ) {
    10561056
    10571057    global $pixtypes_plugin;
     
    11061106}
    11071107
    1108 add_action( 'admin_enqueue_scripts', 'cmb_register_scripts', 10 );
    1109 
    1110 function cmb_enqueue_scripts(){
     1108add_action( 'admin_enqueue_scripts', 'pixtypes_cmb_register_scripts', 10 );
     1109
     1110function pixtypes_cmb_enqueue_scripts(){
    11111111    wp_enqueue_script( 'cmb-timepicker' );
    11121112    wp_enqueue_script( 'cmb-scripts' );
     
    11141114}
    11151115
    1116 function cmb_editor_footer_scripts() {
    1117     if ( isset( $_GET['cmb_force_send'] ) && 'true' == $_GET['cmb_force_send'] ) {
    1118         $label = $_GET['cmb_send_label'];
     1116function pixtypes_cmb_editor_footer_scripts() {
     1117    if ( isset( $_GET['cmb_force_send'] ) && 'true' === $_GET['cmb_force_send'] ) {
     1118        $label = isset( $_GET['cmb_send_label'] ) ? sanitize_text_field( $_GET['cmb_send_label'] ) : '';
    11191119        if ( empty( $label ) ) {
    11201120            $label = esc_html__( 'Select File', 'pixtypes' );
     
    11221122        <script type="text/javascript">
    11231123            jQuery(function ($) {
    1124                 $('td.savesend input').val('<?php echo esc_html( $label , 'pixtypes' ); ?>');
     1124                $('td.savesend input').val(<?php echo wp_json_encode( $label ); ?>);
    11251125            });
    11261126        </script>
     
    11291129}
    11301130
    1131 add_action( 'admin_print_footer_scripts', 'cmb_editor_footer_scripts', 99 );
     1131add_action( 'admin_print_footer_scripts', 'pixtypes_cmb_editor_footer_scripts', 99 );
    11321132
    11331133// Force 'Insert into Post' button from Media Library
    1134 add_filter( 'get_media_item_args', 'cmb_force_send' );
    1135 function cmb_force_send( $args ) {
     1134add_filter( 'get_media_item_args', 'pixtypes_cmb_force_send' );
     1135function pixtypes_cmb_force_send( $args ) {
    11361136
    11371137    // if the Gallery tab is opened from a custom meta box field, add Insert Into Post button
     
    11841184}
    11851185
    1186 add_action( 'wp_ajax_cmb_oembed_handler', 'cmb_oembed_ajax_results' );
     1186add_action( 'wp_ajax_cmb_oembed_handler', 'pixtypes_cmb_oembed_ajax_results' );
    11871187/**
    11881188 * Handles our oEmbed ajax request
    11891189 */
    1190 function cmb_oembed_ajax_results() {
     1190function pixtypes_cmb_oembed_ajax_results() {
    11911191
    11921192    // verify our nonce
     
    12081208        // Post ID is needed to check for embeds
    12091209        if ( isset( $_REQUEST['post_id'] ) ) {
    1210             $GLOBALS['post'] = get_post( $_REQUEST['post_id'] );
     1210            $GLOBALS['post'] = get_post( absint( $_REQUEST['post_id'] ) );
    12111211        }
    12121212        // ping WordPress for an embed
     
    12171217        if ( $check_embed && $check_embed != $fallback ) {
    12181218            // Embed data
    1219             $return = '<div class="embed_status">' . $check_embed . '<a href="#" class="cmb_remove_file_button" rel="' . $_REQUEST['field_id'] . '">' . esc_html__( 'Remove Embed', 'pixtypes' ) . '</a></div>';
     1219            $return = '<div class="embed_status">' . $check_embed . '<a href="#" class="cmb_remove_file_button" rel="' . esc_attr( sanitize_text_field( $_REQUEST['field_id'] ) ) . '">' . esc_html__( 'Remove Embed', 'pixtypes' ) . '</a></div>';
    12201220            // set our response id
    12211221            $found = 'found';
     
    12391239
    12401240// create an ajax call which will return a preview to the current gallery
    1241 function ajax_pixgallery_preview() {
     1241function pixtypes_ajax_pixgallery_preview() {
     1242    check_ajax_referer( 'pixtypes_gallery_preview', 'nonce' );
     1243
     1244    if ( ! current_user_can( 'upload_files' ) ) {
     1245        wp_send_json_error( 'Unauthorized' );
     1246    }
     1247
    12421248    $result = array( 'success' => false, 'output' => '' );
    12431249
    1244     if ( isset( $_REQUEST['attachments_ids'] ) ) {
    1245         $ids = $_REQUEST['attachments_ids'];
    1246     }
     1250    $ids = isset( $_REQUEST['attachments_ids'] ) ? sanitize_text_field( $_REQUEST['attachments_ids'] ) : '';
     1251
    12471252    if ( empty( $ids ) ) {
    1248         echo json_encode( $result );
     1253        echo wp_json_encode( $result );
    12491254        exit;
    12501255    }
    12511256
    1252     $ids = rtrim( $ids, ',' );
    1253     $ids = explode( ',', $ids );
     1257    $ids = array_map( 'absint', explode( ',', rtrim( $ids, ',' ) ) );
     1258    $ids = array_filter( $ids );
    12541259
    12551260    $size = 'thumbnail';
     
    12611266    foreach ( $ids as $id ) {
    12621267        $attach = wp_get_attachment_image_src( $id, $size, false );
    1263 
    1264         $result["output"] .= '<li><img src="' . $attach[0] . '" /></li>';
     1268        if ( $attach ) {
     1269            $result["output"] .= '<li><img src="' . esc_url( $attach[0] ) . '" /></li>';
     1270        }
    12651271    }
    12661272    $result["success"] = true;
    1267     echo json_encode( $result );
     1273    echo wp_json_encode( $result );
    12681274    exit;
    12691275}
    12701276
    1271 add_action( 'wp_ajax_ajax_pixgallery_preview', 'ajax_pixgallery_preview' );
    1272 
    1273 function ajax_pixplaylist_preview() {
    1274 
    1275     if ( isset( $_REQUEST['attachments_ids'] ) ) {
    1276         $ids = $_REQUEST['attachments_ids'];
    1277     }
     1277add_action( 'wp_ajax_ajax_pixgallery_preview', 'pixtypes_ajax_pixgallery_preview' );
     1278
     1279function pixtypes_ajax_pixplaylist_preview() {
     1280    check_ajax_referer( 'pixtypes_playlist_preview', 'nonce' );
     1281
     1282    if ( ! current_user_can( 'upload_files' ) ) {
     1283        wp_send_json_error( 'Unauthorized' );
     1284    }
     1285
     1286    $ids = isset( $_REQUEST['attachments_ids'] ) ? sanitize_text_field( $_REQUEST['attachments_ids'] ) : '';
    12781287
    12791288    if ( empty( $ids ) ) {
     
    12821291    }
    12831292
    1284     $ids = explode( ',', $ids );
     1293    $ids = array_map( 'absint', explode( ',', $ids ) );
     1294    $ids = array_filter( $ids );
    12851295
    12861296    $result = '';
    12871297    foreach ( $ids as $id ) {
    1288         $result .= '<li><span class="dashicons dashicons-format-video"></span><span class="attachment_title">' . get_the_title( $id ) . '</span></li>';
     1298        $result .= '<li><span class="dashicons dashicons-format-video"></span><span class="attachment_title">' . esc_html( get_the_title( $id ) ) . '</span></li>';
    12891299    }
    12901300
     
    12931303}
    12941304
    1295 add_action( 'wp_ajax_pixplaylist_preview', 'ajax_pixplaylist_preview' );
     1305add_action( 'wp_ajax_pixplaylist_preview', 'pixtypes_ajax_pixplaylist_preview' );
    12961306
    12971307
  • pixtypes/trunk/features/metaboxes/js/pixgallery.js

    r2487861 r3469313  
    121121        if ( ids !== '' ) {
    122122            $.ajax({
    123                 type: "post", url: locals.ajax_url, data: {action: 'ajax_pixgallery_preview', attachments_ids: ids},
     123                type: "post", url: locals.ajax_url, data: {action: 'ajax_pixgallery_preview', attachments_ids: ids, nonce: locals.nonce},
    124124                beforeSend: function () {
    125125                    $('.open_pixgallery i').removeClass('dashicons-images-alt2');
  • pixtypes/trunk/features/metaboxes/js/piximage.js

    r2487861 r3469313  
    129129        if ( id != '' && id != '-1' ) {
    130130            $.ajax({
    131                 type: "post", url: locals.ajax_url, data: {action: 'ajax_pixgallery_preview', attachments_ids: id},
     131                type: "post", url: locals.ajax_url, data: {action: 'ajax_pixgallery_preview', attachments_ids: id, nonce: locals.nonce},
    132132                beforeSend: function () {
    133133                    $elem.find('.open_piximage i').removeClass('dashicons-images-alt2');
  • pixtypes/trunk/features/metaboxes/js/pixplaylist.js

    r2487861 r3469313  
    108108                data: {
    109109                    action: 'pixplaylist_preview',
    110                     attachments_ids: ids
     110                    attachments_ids: ids,
     111                    nonce: playlist_locals.nonce
    111112                },
    112113                success: function( response ) {
  • pixtypes/trunk/features/metaboxes/metaboxes.php

    r1745422 r3469313  
    1010
    1111
    12 function load_metaboxes_fromdb( $meta_boxes ) {
     12function pixtypes_load_metaboxes_fromdb( $meta_boxes ) {
    1313    // make sure we are in good working order
    1414    if ( empty( $meta_boxes ) ) {
     
    4040    return $meta_boxes;
    4141}
    42 add_filter( 'cmb_meta_boxes', 'load_metaboxes_fromdb', 1 );
     42add_filter( 'cmb_meta_boxes', 'pixtypes_load_metaboxes_fromdb', 1 );
    4343
    4444/**
     
    4949 * @return array
    5050 */
    51 function gather_metaboxes_dynamically( $meta_boxes ) {
     51function pixtypes_gather_metaboxes_dynamically( $meta_boxes ) {
    5252    // make sure we are in good working order
    5353    if ( empty( $meta_boxes ) ) {
     
    5757    return apply_filters( 'pixelgrade_filter_metaboxes', $meta_boxes );
    5858}
    59 add_filter( 'cmb_meta_boxes', 'gather_metaboxes_dynamically', 10 );
     59add_filter( 'cmb_meta_boxes', 'pixtypes_gather_metaboxes_dynamically', 10 );
    6060
    6161/*
    6262 * Initialize the metabox class.
    6363 */
    64 function cmb_initialize_cmb_meta_boxes() {
     64function pixtypes_cmb_initialize_meta_boxes() {
    6565
    6666    if ( ! class_exists( 'cmb_Meta_Box' ) ) {
     
    7272
    7373}
    74 add_action( 'init', 'cmb_initialize_cmb_meta_boxes', 9999 );
     74add_action( 'init', 'pixtypes_cmb_initialize_meta_boxes', 9999 );
  • pixtypes/trunk/pixtypes.php

    r2956824 r3469313  
    44 * Plugin URI: https://wordpress.org/plugins/pixtypes/
    55 * Description: Custom post types and meta-boxes needed by your themes.
    6  * Version: 1.4.16
     6 * Version: 2.0.0
    77 * Author: Pixelgrade
    88 * Author URI: https://pixelgrade.com
    99 * Author Email: [email protected]
    10  * Requires at least: 4.9.9
    11  * Tested up to: 6.3.0
     10 * Requires at least: 6.0
     11 * Tested up to: 6.7
     12 * Requires PHP: 7.4
    1213 * Text Domain: pixtypes
    1314 * License:     GPL-2.0 or later.
     
    2122}
    2223
    23 // ensure EXT is defined
    24 if ( ! defined( 'EXT' ) ) {
    25     define( 'EXT', '.php' );
     24// ensure PIXTYPES_EXT is defined
     25if ( ! defined( 'PIXTYPES_EXT' ) ) {
     26    define( 'PIXTYPES_EXT', '.php' );
    2627}
    2728
    28 require 'core/bootstrap' . EXT;
     29require 'core/bootstrap' . PIXTYPES_EXT;
    2930
    30 $config = include 'plugin-config' . EXT;
     31$config = include 'plugin-config' . PIXTYPES_EXT;
    3132// set textdomain
    3233pixtypes::settextdomain( $config['textdomain'] );
     
    3536// ----------------
    3637
    37 $defaults = include 'plugin-defaults' . EXT;
     38$defaults = include 'plugin-defaults' . PIXTYPES_EXT;
    3839
    3940$current_data = get_option( $config['settings-key'] );
     
    6162
    6263global $pixtypes_plugin;
    63 $pixtypes_plugin = PixTypesPlugin::get_instance( '1.4.15' );
     64$pixtypes_plugin = PixTypesPlugin::get_instance( '2.0.0' );
  • pixtypes/trunk/plugin-config.php

    r1591155 r3469313  
    33$basepath = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
    44
    5 $debug = false;
    6 if ( isset( $_GET['debug'] ) && $_GET['debug'] == 'true' ) {
    7     $debug = true;
    8 }
     5$debug = defined( 'WP_DEBUG' ) && WP_DEBUG;
    96
    107$options = get_option( 'pixtypes_settings' );
     
    3027    'fields' => array(
    3128        'hiddens'
    32         => include 'settings/hiddens' . EXT,
     29        => include 'settings/hiddens' . PIXTYPES_EXT,
    3330        'post_types'
    34         => include 'settings/post_types' . EXT,
     31        => include 'settings/post_types' . PIXTYPES_EXT,
    3532        'taxonomies'
    36         => include 'settings/taxonomies' . EXT,
     33        => include 'settings/taxonomies' . PIXTYPES_EXT,
    3734    ),
    3835
  • pixtypes/trunk/readme.txt

    r2956824 r3469313  
    22Contributors: pixelgrade, babbardel, vlad.olaru, razvanonofrei
    33Tags: custom, post-types, metadata, builder, gallery
    4 Requires at least: 4.9.9
    5 Tested up to: 6.3.0
    6 Requires PHP: 5.3.0
    7 Stable tag: 1.4.16
     4Requires at least: 6.0
     5Tested up to: 6.9.1
     6Requires PHP: 7.4
     7Stable tag: 2.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2424
    2525== Changelog ==
     26
     27= 2.0.0 =
     28* Security: Fixed Stored XSS vulnerability in HTML attribute rendering (HTMLTag class).
     29* Security: Fixed Reflected XSS via field_id parameter in oEmbed handler.
     30* Security: Fixed XSS via cmb_send_label using proper JS escaping (wp_json_encode).
     31* Security: Added nonce verification and capability checks to gallery AJAX preview handler.
     32* Security: Added nonce verification and capability checks to playlist AJAX preview handler.
     33* Security: Added capability check (manage_options) to theme settings cleanup AJAX handler.
     34* Security: Removed URL-controllable debug mode; now tied to WP_DEBUG constant.
     35* Security: Added output escaping throughout admin views and form templates.
     36* Security: Restricted POST input processing to expected fields only.
     37* Security: Sanitized all $_GET/$_POST/$_REQUEST superglobal usage with appropriate functions.
     38* Security: Updated nonce action strings to use specific identifiers.
     39* Improvement: Prefixed all global functions with pixtypes_ to prevent namespace collisions.
     40* Improvement: Removed deprecated &$this reference patterns for PHP 8 compatibility.
     41* Improvement: Updated minimum requirements to WordPress 6.0 and PHP 7.4.
     42* Improvement: Replaced EXT constant with PIXTYPES_EXT to avoid conflicts.
    2643
    2744= 1.4.16 =
  • pixtypes/trunk/views/admin.php

    r2895213 r3469313  
    1313 */
    1414
    15 $config = include pixtypes::pluginpath() . 'plugin-config' . EXT;
     15$config = include pixtypes::pluginpath() . 'plugin-config' . PIXTYPES_EXT;
    1616
    1717// invoke processor
     
    6262        <?php echo $f->endform() ?>
    6363
    64     <?php elseif ( $status['state'] == 'error' ): ?>
     64    <?php elseif ( 'error' === $status['state'] ): ?>
    6565
    6666        <h3><?php esc_html_e( 'Critical Error', 'pixtypes' ); ?></h3>
    6767
    68         <p><?php echo $status['message'] ?></p>
     68        <p><?php echo esc_html( $status['message'] ); ?></p>
    6969
    7070    <?php endif; ?>
     
    8989                        if ( isset( $options['themes'] ) && count( $options['themes'] ) > 1 ) {
    9090                            foreach ( $options['themes'] as $key => $theme ) {
    91                                 echo '<li><button class="button delete-action" type="submit" name="unset_pixtype" value="' . $key . '">' . esc_html__( 'Clean-up after', 'pixtypes' ) . ' ' . ucfirst( $key ) . '</button></li>';
     91                                echo '<li><button class="button delete-action" type="submit" name="unset_pixtype" value="' . esc_attr( $key ) . '">' . esc_html__( 'Clean-up after', 'pixtypes' ) . ' ' . esc_html( ucfirst( $key ) ) . '</button></li>';
    9292                            }
    9393                        } ?>
Note: See TracChangeset for help on using the changeset viewer.