Plugin Directory

Changeset 1818773


Ignore:
Timestamp:
02/09/2018 07:55:15 AM (8 years ago)
Author:
themespond
Message:
  • Fix metabox in front_page, posts_page cannot saved
  • Improve dependency in customizer
Location:
tp-framework
Files:
174 added
8 edited

Legend:

Unmodified
Added
Removed
  • tp-framework/trunk/addons/importer/wordpress-importer/wordpress-importer.php

    r1734156 r1818773  
    3737if ( class_exists( 'WP_Importer' ) ) {
    3838
    39     class WP_Import extends WP_Importer
    40     {
     39    class WP_Import extends WP_Importer {
    4140
    4241        var $max_wxr_version = 1.2; // max. supported WXR version
     
    6867         * Manages the three separate stages of the WXR import process
    6968         */
    70         function dispatch()
    71         {
     69        function dispatch() {
    7270            $this->header();
    7371
    74             $step = empty( $_GET[ 'step' ] ) ? 0 : (int)$_GET[ 'step' ];
     72            $step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
    7573            switch ( $step ) {
    7674                case 0:
     
    8482                case 2:
    8583                    check_admin_referer( 'import-wordpress' );
    86                     $this->fetch_attachments = ( !empty( $_POST[ 'fetch_attachments' ] ) && $this->allow_fetch_attachments() );
    87                     $this->id = (int)$_POST[ 'import_id' ];
     84                    $this->fetch_attachments = (!empty( $_POST['fetch_attachments'] ) && $this->allow_fetch_attachments() );
     85                    $this->id = (int) $_POST['import_id'];
    8886                    $file = get_attached_file( $this->id );
    8987                    set_time_limit( 0 );
     
    10098         * @param string $file Path to the WXR file for importing
    10199         */
    102         function import( $file )
    103         {
     100        function import( $file ) {
    104101
    105102            add_filter( 'import_post_meta_key', array( $this, 'is_valid_meta_key' ) );
     
    130127         * @param string $file Path to the WXR file for importing
    131128         */
    132         function import_start( $file )
    133         {
     129        function import_start( $file ) {
    134130            if ( !is_file( $file ) ) {
    135131                echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '</strong><br />';
     
    148144            }
    149145
    150             $this->version = $import_data[ 'version' ];
     146            $this->version = $import_data['version'];
    151147            $this->get_authors_from_import( $import_data );
    152             $this->posts = $import_data[ 'posts' ];
    153             $this->terms = $import_data[ 'terms' ];
    154             $this->categories = $import_data[ 'categories' ];
    155             $this->tags = $import_data[ 'tags' ];
    156             $this->base_url = esc_url( $import_data[ 'base_url' ] );
     148            $this->posts = $import_data['posts'];
     149            $this->terms = $import_data['terms'];
     150            $this->categories = $import_data['categories'];
     151            $this->tags = $import_data['tags'];
     152            $this->base_url = esc_url( $import_data['base_url'] );
    157153
    158154            wp_defer_term_counting( true );
     
    165161         * Performs post-import cleanup of files and the cache
    166162         */
    167         function import_end()
    168         {
     163        function import_end() {
    169164            wp_import_cleanup( $this->id );
    170165
     
    190185         * @return bool False if error uploading or invalid file, true otherwise
    191186         */
    192         function handle_upload()
    193         {
     187        function handle_upload() {
    194188            $file = wp_import_handle_upload();
    195189
    196             if ( isset( $file[ 'error' ] ) ) {
     190            if ( isset( $file['error'] ) ) {
    197191                echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '</strong><br />';
    198                 echo esc_html( $file[ 'error' ] ) . '</p>';
     192                echo esc_html( $file['error'] ) . '</p>';
    199193                return false;
    200             } else if ( !file_exists( $file[ 'file' ] ) ) {
     194            } else if ( !file_exists( $file['file'] ) ) {
    201195                echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '</strong><br />';
    202                 printf( __( 'The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', 'wordpress-importer' ), esc_html( $file[ 'file' ] ) );
     196                printf( __( 'The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', 'wordpress-importer' ), esc_html( $file['file'] ) );
    203197                echo '</p>';
    204198                return false;
    205199            }
    206200
    207             $this->id = (int)$file[ 'id' ];
    208             $import_data = $this->parse( $file[ 'file' ] );
     201            $this->id = (int) $file['id'];
     202            $import_data = $this->parse( $file['file'] );
    209203            if ( is_wp_error( $import_data ) ) {
    210204                echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '</strong><br />';
     
    213207            }
    214208
    215             $this->version = $import_data[ 'version' ];
     209            $this->version = $import_data['version'];
    216210            if ( $this->version > $this->max_wxr_version ) {
    217211                echo '<div class="error"><p><strong>';
    218                 printf( __( 'This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', 'wordpress-importer' ), esc_html( $import_data[ 'version' ] ) );
     212                printf( __( 'This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', 'wordpress-importer' ), esc_html( $import_data['version'] ) );
    219213                echo '</strong></p></div>';
    220214            }
     
    233227         * @param array $import_data Data returned by a WXR parser
    234228         */
    235         function get_authors_from_import( $import_data )
    236         {
    237             if ( !empty( $import_data[ 'authors' ] ) ) {
    238                 $this->authors = $import_data[ 'authors' ];
     229        function get_authors_from_import( $import_data ) {
     230            if ( !empty( $import_data['authors'] ) ) {
     231                $this->authors = $import_data['authors'];
    239232                // no author information, grab it from the posts
    240233            } else {
    241                 foreach ( $import_data[ 'posts' ] as $post ) {
    242                     $login = sanitize_user( $post[ 'post_author' ], true );
     234                foreach ( $import_data['posts'] as $post ) {
     235                    $login = sanitize_user( $post['post_author'], true );
    243236                    if ( empty( $login ) ) {
    244                         printf( __( 'Failed to import author %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html( $post[ 'post_author' ] ) );
     237                        printf( __( 'Failed to import author %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html( $post['post_author'] ) );
    245238                        echo '<br />';
    246239                        continue;
    247240                    }
    248241
    249                     if ( !isset( $this->authors[ $login ] ) )
    250                         $this->authors[ $login ] = array(
    251                             'author_login'        => $login,
    252                             'author_display_name' => $post[ 'post_author' ]
     242                    if ( !isset( $this->authors[$login] ) )
     243                        $this->authors[$login] = array(
     244                            'author_login' => $login,
     245                            'author_display_name' => $post['post_author']
    253246                        );
    254247                }
     
    260253         * fetch attachments
    261254         */
    262         function import_options()
    263         {
     255        function import_options() {
    264256            $j = 0;
    265257            ?>
    266             <form action="<?php echo admin_url( 'admin.php?import=wordpress&amp;step=2' ); ?>" method="post">
    267                 <?php wp_nonce_field( 'import-wordpress' ); ?>
    268                 <input type="hidden" name="import_id" value="<?php echo $this->id; ?>"/>
    269 
    270                 <?php if ( !empty( $this->authors ) ) : ?>
    271                     <h3><?php _e( 'Assign Authors', 'wordpress-importer' ); ?></h3>
    272                     <p><?php _e( 'To make it easier for you to edit and save the imported content, you may want to reassign the author of the imported item to an existing user of this site. For example, you may want to import all the entries as <code>admin</code>s entries.', 'wordpress-importer' ); ?></p>
    273                     <?php if ( $this->allow_create_users() ) : ?>
    274                         <p><?php printf( __( 'If a new user is created by WordPress, a new password will be randomly generated and the new user&#8217;s role will be set as %s. Manually changing the new user&#8217;s details will be necessary.', 'wordpress-importer' ), esc_html( get_option( 'default_role' ) ) ); ?></p>
     258            <form action="<?php echo admin_url( 'admin.php?import=wordpress&amp;step=2' ); ?>" method="post">
     259            <?php wp_nonce_field( 'import-wordpress' ); ?>
     260                <input type="hidden" name="import_id" value="<?php echo $this->id; ?>"/>
     261
     262            <?php if ( !empty( $this->authors ) ) : ?>
     263                    <h3><?php _e( 'Assign Authors', 'wordpress-importer' ); ?></h3>
     264                    <p><?php _e( 'To make it easier for you to edit and save the imported content, you may want to reassign the author of the imported item to an existing user of this site. For example, you may want to import all the entries as <code>admin</code>s entries.', 'wordpress-importer' ); ?></p>
     265                <?php if ( $this->allow_create_users() ) : ?>
     266                        <p><?php printf( __( 'If a new user is created by WordPress, a new password will be randomly generated and the new user&#8217;s role will be set as %s. Manually changing the new user&#8217;s details will be necessary.', 'wordpress-importer' ), esc_html( get_option( 'default_role' ) ) ); ?></p>
    275267                    <?php endif; ?>
    276                     <ol id="authors">
    277                         <?php foreach ( $this->authors as $author ) : ?>
    278                             <li><?php $this->author_select( $j++, $author ); ?></li>
    279                         <?php endforeach; ?>
    280                     </ol>
     268                    <ol id="authors">
     269                    <?php foreach ( $this->authors as $author ) : ?>
     270                            <li><?php $this->author_select( $j++, $author ); ?></li>
     271                <?php endforeach; ?>
     272                    </ol>
    281273                <?php endif; ?>
    282274
    283275                <?php if ( $this->allow_fetch_attachments() ) : ?>
    284                     <h3><?php _e( 'Import Attachments', 'wordpress-importer' ); ?></h3>
    285                     <p>
    286                         <input type="checkbox" value="1" name="fetch_attachments" id="import-attachments"/>
    287                         <label for="import-attachments"><?php _e( 'Download and import file attachments', 'wordpress-importer' ); ?></label>
    288                     </p>
     276                    <h3><?php _e( 'Import Attachments', 'wordpress-importer' ); ?></h3>
     277                    <p>
     278                        <input type="checkbox" value="1" name="fetch_attachments" id="import-attachments"/>
     279                        <label for="import-attachments"><?php _e( 'Download and import file attachments', 'wordpress-importer' ); ?></label>
     280                    </p>
    289281                <?php endif; ?>
    290282
    291                 <p class="submit"><input type="submit" class="button"
    292                                         value="<?php esc_attr_e( 'Submit', 'wordpress-importer' ); ?>"/></p>
    293             </form>
     283                <p class="submit"><input type="submit" class="button"
     284                                        value="<?php esc_attr_e( 'Submit', 'wordpress-importer' ); ?>"/></p>
     285            </form>
    294286            <?php
    295287        }
     
    302294         * @param array $author Author information, e.g. login, display name, email
    303295         */
    304         function author_select( $n, $author )
    305         {
     296        function author_select( $n, $author ) {
    306297            _e( 'Import author:', 'wordpress-importer' );
    307             echo ' <strong>' . esc_html( $author[ 'author_display_name' ] );
     298            echo ' <strong>' . esc_html( $author['author_display_name'] );
    308299            if ( $this->version != '1.0' )
    309                 echo ' (' . esc_html( $author[ 'author_login' ] ) . ')';
     300                echo ' (' . esc_html( $author['author_login'] ) . ')';
    310301            echo '</strong><br />';
    311302
     
    320311                } else {
    321312                    _e( 'as a new user:', 'wordpress-importer' );
    322                     $value = esc_attr( sanitize_user( $author[ 'author_login' ], true ) );
     313                    $value = esc_attr( sanitize_user( $author['author_login'], true ) );
    323314                }
    324315
     
    331322                _e( 'or assign posts to an existing user:', 'wordpress-importer' );
    332323            wp_dropdown_users( array( 'name' => "user_map[$n]", 'multi' => true, 'show_option_all' => __( '- Select -', 'wordpress-importer' ) ) );
    333             echo '<input type="hidden" name="imported_authors[' . $n . ']" value="' . esc_attr( $author[ 'author_login' ] ) . '" />';
     324            echo '<input type="hidden" name="imported_authors[' . $n . ']" value="' . esc_attr( $author['author_login'] ) . '" />';
    334325
    335326            if ( $this->version != '1.0' )
     
    342333         * or falls back to the current user in case of error with either of the previous
    343334         */
    344         function get_author_mapping()
    345         {
    346             if ( !isset( $_POST[ 'imported_authors' ] ) )
     335        function get_author_mapping() {
     336            if ( !isset( $_POST['imported_authors'] ) )
    347337                return;
    348338
    349339            $create_users = $this->allow_create_users();
    350340
    351             foreach ( (array)$_POST[ 'imported_authors' ] as $i => $old_login ) {
     341            foreach ( (array) $_POST['imported_authors'] as $i => $old_login ) {
    352342                // Multisite adds strtolower to sanitize_user. Need to sanitize here to stop breakage in process_posts.
    353343                $santized_old_login = sanitize_user( $old_login, true );
    354                 $old_id = isset( $this->authors[ $old_login ][ 'author_id' ] ) ? intval( $this->authors[ $old_login ][ 'author_id' ] ) : false;
    355 
    356                 if ( !empty( $_POST[ 'user_map' ][ $i ] ) ) {
    357                     $user = get_userdata( intval( $_POST[ 'user_map' ][ $i ] ) );
     344                $old_id = isset( $this->authors[$old_login]['author_id'] ) ? intval( $this->authors[$old_login]['author_id'] ) : false;
     345
     346                if ( !empty( $_POST['user_map'][$i] ) ) {
     347                    $user = get_userdata( intval( $_POST['user_map'][$i] ) );
    358348                    if ( isset( $user->ID ) ) {
    359349                        if ( $old_id )
    360                             $this->processed_authors[ $old_id ] = $user->ID;
    361                         $this->author_mapping[ $santized_old_login ] = $user->ID;
     350                            $this->processed_authors[$old_id] = $user->ID;
     351                        $this->author_mapping[$santized_old_login] = $user->ID;
    362352                    }
    363353                } else if ( $create_users ) {
    364                     if ( !empty( $_POST[ 'user_new' ][ $i ] ) ) {
    365                         $user_id = wp_create_user( $_POST[ 'user_new' ][ $i ], wp_generate_password() );
     354                    if ( !empty( $_POST['user_new'][$i] ) ) {
     355                        $user_id = wp_create_user( $_POST['user_new'][$i], wp_generate_password() );
    366356                    } else if ( $this->version != '1.0' ) {
    367357                        $user_data = array(
    368                             'user_login'   => $old_login,
    369                             'user_pass'    => wp_generate_password(),
    370                             'user_email'   => isset( $this->authors[ $old_login ][ 'author_email' ] ) ? $this->authors[ $old_login ][ 'author_email' ] : '',
    371                             'display_name' => $this->authors[ $old_login ][ 'author_display_name' ],
    372                             'first_name'   => isset( $this->authors[ $old_login ][ 'author_first_name' ] ) ? $this->authors[ $old_login ][ 'author_first_name' ] : '',
    373                             'last_name'    => isset( $this->authors[ $old_login ][ 'author_last_name' ] ) ? $this->authors[ $old_login ][ 'author_last_name' ] : '',
     358                            'user_login' => $old_login,
     359                            'user_pass' => wp_generate_password(),
     360                            'user_email' => isset( $this->authors[$old_login]['author_email'] ) ? $this->authors[$old_login]['author_email'] : '',
     361                            'display_name' => $this->authors[$old_login]['author_display_name'],
     362                            'first_name' => isset( $this->authors[$old_login]['author_first_name'] ) ? $this->authors[$old_login]['author_first_name'] : '',
     363                            'last_name' => isset( $this->authors[$old_login]['author_last_name'] ) ? $this->authors[$old_login]['author_last_name'] : '',
    374364                        );
    375365                        $user_id = wp_insert_user( $user_data );
     
    378368                    if ( !is_wp_error( $user_id ) ) {
    379369                        if ( $old_id )
    380                             $this->processed_authors[ $old_id ] = $user_id;
    381                         $this->author_mapping[ $santized_old_login ] = $user_id;
     370                            $this->processed_authors[$old_id] = $user_id;
     371                        $this->author_mapping[$santized_old_login] = $user_id;
    382372                    } else {
    383                         printf( __( 'Failed to create new user for %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html( $this->authors[ $old_login ][ 'author_display_name' ] ) );
     373                        printf( __( 'Failed to create new user for %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html( $this->authors[$old_login]['author_display_name'] ) );
    384374                        if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG )
    385375                            echo ' ' . $user_id->get_error_message();
     
    389379
    390380                // failsafe: if the user_id was invalid, default to the current user
    391                 if ( !isset( $this->author_mapping[ $santized_old_login ] ) ) {
     381                if ( !isset( $this->author_mapping[$santized_old_login] ) ) {
    392382                    if ( $old_id )
    393                         $this->processed_authors[ $old_id ] = (int)get_current_user_id();
    394                     $this->author_mapping[ $santized_old_login ] = (int)get_current_user_id();
     383                        $this->processed_authors[$old_id] = (int) get_current_user_id();
     384                    $this->author_mapping[$santized_old_login] = (int) get_current_user_id();
    395385                }
    396386            }
     
    402392         * Doesn't create a new category if its slug already exists
    403393         */
    404         function process_categories()
    405         {
     394        function process_categories() {
    406395            $this->categories = apply_filters( 'wp_import_categories', $this->categories );
    407396
     
    411400            foreach ( $this->categories as $cat ) {
    412401                // if the category already exists leave it alone
    413                 $term_id = term_exists( $cat[ 'category_nicename' ], 'category' );
     402                $term_id = term_exists( $cat['category_nicename'], 'category' );
    414403                if ( $term_id ) {
    415404                    if ( is_array( $term_id ) )
    416                         $term_id = $term_id[ 'term_id' ];
    417                     if ( isset( $cat[ 'term_id' ] ) )
    418                         $this->processed_terms[ intval( $cat[ 'term_id' ] ) ] = (int)$term_id;
     405                        $term_id = $term_id['term_id'];
     406                    if ( isset( $cat['term_id'] ) )
     407                        $this->processed_terms[intval( $cat['term_id'] )] = (int) $term_id;
    419408                    continue;
    420409                }
    421410
    422                 $category_parent = empty( $cat[ 'category_parent' ] ) ? 0 : category_exists( $cat[ 'category_parent' ] );
    423                 $category_description = isset( $cat[ 'category_description' ] ) ? $cat[ 'category_description' ] : '';
     411                $category_parent = empty( $cat['category_parent'] ) ? 0 : category_exists( $cat['category_parent'] );
     412                $category_description = isset( $cat['category_description'] ) ? $cat['category_description'] : '';
    424413                $catarr = array(
    425                     'category_nicename'    => $cat[ 'category_nicename' ],
    426                     'category_parent'      => $category_parent,
    427                     'cat_name'             => $cat[ 'cat_name' ],
     414                    'category_nicename' => $cat['category_nicename'],
     415                    'category_parent' => $category_parent,
     416                    'cat_name' => $cat['cat_name'],
    428417                    'category_description' => $category_description
    429418                );
     
    432421                $id = wp_insert_category( $catarr );
    433422                if ( !is_wp_error( $id ) ) {
    434                     if ( isset( $cat[ 'term_id' ] ) )
    435                         $this->processed_terms[ intval( $cat[ 'term_id' ] ) ] = $id;
     423                    if ( isset( $cat['term_id'] ) )
     424                        $this->processed_terms[intval( $cat['term_id'] )] = $id;
    436425                } else {
    437                     printf( __( 'Failed to import category %s', 'wordpress-importer' ), esc_html( $cat[ 'category_nicename' ] ) );
     426                    printf( __( 'Failed to import category %s', 'wordpress-importer' ), esc_html( $cat['category_nicename'] ) );
    438427                    if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG )
    439428                        echo ': ' . $id->get_error_message();
     
    442431                }
    443432
    444                 $this->process_termmeta( $cat, $id[ 'term_id' ] );
     433                $this->process_termmeta( $cat, $id['term_id'] );
    445434            }
    446435
     
    453442         * Doesn't create a tag if its slug already exists
    454443         */
    455         function process_tags()
    456         {
     444        function process_tags() {
    457445            $this->tags = apply_filters( 'wp_import_tags', $this->tags );
    458446
     
    462450            foreach ( $this->tags as $tag ) {
    463451                // if the tag already exists leave it alone
    464                 $term_id = term_exists( $tag[ 'tag_slug' ], 'post_tag' );
     452                $term_id = term_exists( $tag['tag_slug'], 'post_tag' );
    465453                if ( $term_id ) {
    466454                    if ( is_array( $term_id ) )
    467                         $term_id = $term_id[ 'term_id' ];
    468                     if ( isset( $tag[ 'term_id' ] ) )
    469                         $this->processed_terms[ intval( $tag[ 'term_id' ] ) ] = (int)$term_id;
     455                        $term_id = $term_id['term_id'];
     456                    if ( isset( $tag['term_id'] ) )
     457                        $this->processed_terms[intval( $tag['term_id'] )] = (int) $term_id;
    470458                    continue;
    471459                }
    472460
    473461                $tag = wp_slash( $tag );
    474                 $tag_desc = isset( $tag[ 'tag_description' ] ) ? $tag[ 'tag_description' ] : '';
    475                 $tagarr = array( 'slug' => $tag[ 'tag_slug' ], 'description' => $tag_desc );
    476 
    477                 $id = wp_insert_term( $tag[ 'tag_name' ], 'post_tag', $tagarr );
     462                $tag_desc = isset( $tag['tag_description'] ) ? $tag['tag_description'] : '';
     463                $tagarr = array( 'slug' => $tag['tag_slug'], 'description' => $tag_desc );
     464
     465                $id = wp_insert_term( $tag['tag_name'], 'post_tag', $tagarr );
    478466                if ( !is_wp_error( $id ) ) {
    479                     if ( isset( $tag[ 'term_id' ] ) )
    480                         $this->processed_terms[ intval( $tag[ 'term_id' ] ) ] = $id[ 'term_id' ];
     467                    if ( isset( $tag['term_id'] ) )
     468                        $this->processed_terms[intval( $tag['term_id'] )] = $id['term_id'];
    481469                } else {
    482                     printf( __( 'Failed to import post tag %s', 'wordpress-importer' ), esc_html( $tag[ 'tag_name' ] ) );
     470                    printf( __( 'Failed to import post tag %s', 'wordpress-importer' ), esc_html( $tag['tag_name'] ) );
    483471                    if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG )
    484472                        echo ': ' . $id->get_error_message();
     
    487475                }
    488476
    489                 $this->process_termmeta( $tag, $id[ 'term_id' ] );
     477                $this->process_termmeta( $tag, $id['term_id'] );
    490478            }
    491479
     
    498486         * Doesn't create a term its slug already exists
    499487         */
    500         function process_terms()
    501         {
     488        function process_terms() {
    502489
    503490            global $wpdb;
     
    510497            foreach ( $this->terms as $term ) {
    511498                // if the term already exists in the correct taxonomy leave it alone
    512                 $term_id = term_exists( $term[ 'slug' ], $term[ 'term_taxonomy' ] );
     499                $term_id = term_exists( $term['slug'], $term['term_taxonomy'] );
    513500                if ( $term_id ) {
    514501                    if ( is_array( $term_id ) )
    515                         $term_id = $term_id[ 'term_id' ];
    516                     if ( isset( $term[ 'term_id' ] ) )
    517                         $this->processed_terms[ intval( $term[ 'term_id' ] ) ] = (int)$term_id;
     502                        $term_id = $term_id['term_id'];
     503                    if ( isset( $term['term_id'] ) )
     504                        $this->processed_terms[intval( $term['term_id'] )] = (int) $term_id;
    518505                    continue;
    519506                }
    520507
    521                 if ( empty( $term[ 'term_parent' ] ) ) {
     508                if ( empty( $term['term_parent'] ) ) {
    522509                    $parent = 0;
    523510                } else {
    524                     $parent = term_exists( $term[ 'term_parent' ], $term[ 'term_taxonomy' ] );
     511                    $parent = term_exists( $term['term_parent'], $term['term_taxonomy'] );
    525512                    if ( is_array( $parent ) )
    526                         $parent = $parent[ 'term_id' ];
     513                        $parent = $parent['term_id'];
    527514                }
    528515
     
    534521
    535522                    $termmeta = '';
    536                     if ( strstr( $term[ 'term_taxonomy' ], 'pa_' ) ) {
    537 
    538                         if ( !taxonomy_exists( $term[ 'term_taxonomy' ] ) ) {
    539                             $attribute_name = wc_sanitize_taxonomy_name( str_replace( 'pa_', '', $term[ 'term_taxonomy' ] ) );
     523                    if ( strstr( $term['term_taxonomy'], 'pa_' ) ) {
     524
     525                        if ( !taxonomy_exists( $term['term_taxonomy'] ) ) {
     526                            $attribute_name = wc_sanitize_taxonomy_name( str_replace( 'pa_', '', $term['term_taxonomy'] ) );
    540527
    541528                            // Create the taxonomy
    542529                            if ( !in_array( $attribute_name, wc_get_attribute_taxonomies() ) ) {
    543530                                $attribute = array(
    544                                     'attribute_label'   => $attribute_name,
    545                                     'attribute_name'    => $attribute_name,
    546                                     'attribute_type'    => 'select',
     531                                    'attribute_label' => $attribute_name,
     532                                    'attribute_name' => $attribute_name,
     533                                    'attribute_type' => 'select',
    547534                                    'attribute_orderby' => 'menu_order',
    548                                     'attribute_public'  => 0
     535                                    'attribute_public' => 0
    549536                                );
    550537                                $wpdb->insert( $wpdb->prefix . 'woocommerce_attribute_taxonomies', $attribute );
     
    554541                            // Register the taxonomy now so that the import works!
    555542                            register_taxonomy(
    556                                 $term[ 'term_taxonomy' ], apply_filters( 'woocommerce_taxonomy_objects_' . $term[ 'term_taxonomy' ], array( 'product' ) ), apply_filters( 'woocommerce_taxonomy_args_' . $term[ 'term_taxonomy' ], array(
    557                                     'hierarchical' => true,
    558                                     'show_ui'      => false,
    559                                     'query_var'    => true,
    560                                     'rewrite'      => false,
    561                                 ) )
     543                                    $term['term_taxonomy'], apply_filters( 'woocommerce_taxonomy_objects_' . $term['term_taxonomy'], array( 'product' ) ), apply_filters( 'woocommerce_taxonomy_args_' . $term['term_taxonomy'], array(
     544                                'hierarchical' => true,
     545                                'show_ui' => false,
     546                                'query_var' => true,
     547                                'rewrite' => false,
     548                                    ) )
    562549                            );
    563550
    564                             if ( isset( $term[ 'termmeta' ] ) ) {
    565                                 $termmeta = $term[ 'termmeta' ];
     551                            if ( isset( $term['termmeta'] ) ) {
     552                                $termmeta = $term['termmeta'];
    566553                            }
    567554                        }
     
    570557
    571558                $term = wp_slash( $term );
    572                 $description = isset( $term[ 'term_description' ] ) ? $term[ 'term_description' ] : '';
    573                 $termarr = array( 'slug' => $term[ 'slug' ], 'description' => $description, 'parent' => intval( $parent ) );
    574 
    575                 $id = wp_insert_term( $term[ 'term_name' ], $term[ 'term_taxonomy' ], $termarr );
     559                $description = isset( $term['term_description'] ) ? $term['term_description'] : '';
     560                $termarr = array( 'slug' => $term['slug'], 'description' => $description, 'parent' => intval( $parent ) );
     561
     562                $id = wp_insert_term( $term['term_name'], $term['term_taxonomy'], $termarr );
    576563
    577564
    578565                if ( !is_wp_error( $id ) ) {
    579566
    580                     if ( isset( $term[ 'term_id' ] ) ) {
    581                         $this->processed_terms[ intval( $term[ 'term_id' ] ) ] = $id[ 'term_id' ];
     567                    if ( isset( $term['term_id'] ) ) {
     568                        $this->processed_terms[intval( $term['term_id'] )] = $id['term_id'];
    582569
    583570                        // Add woocommerce attribute termmeta data
    584571                        if ( !empty( $termmeta ) && is_array( $termmeta ) ) {
    585572                            foreach ( $termmeta as $meta ) {
    586                                 add_term_meta( $id[ 'term_id' ], $meta[ 'key' ], $meta[ 'value' ], false );
     573                                add_term_meta( $id['term_id'], $meta['key'], $meta['value'], false );
    587574                            }
    588575                        }
    589576                    }
    590577                } else {
    591                     printf( __( 'Failed to import %s %s', 'wordpress-importer' ), esc_html( $term[ 'term_taxonomy' ] ), esc_html( $term[ 'term_name' ] ) );
     578                    printf( __( 'Failed to import %s %s', 'wordpress-importer' ), esc_html( $term['term_taxonomy'] ), esc_html( $term['term_name'] ) );
    592579                    if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG )
    593580                        echo ': ' . $id->get_error_message();
     
    596583                }
    597584
    598                 $this->process_termmeta( $term, $id[ 'term_id' ] );
     585                $this->process_termmeta( $term, $id['term_id'] );
    599586            }
    600587
     
    610597         * @param int $term_id ID of the newly created term.
    611598         */
    612         protected function process_termmeta( $term, $term_id )
    613         {
    614             if ( !isset( $term[ 'termmeta' ] ) ) {
    615                 $term[ 'termmeta' ] = array();
     599        protected function process_termmeta( $term, $term_id ) {
     600            if ( !isset( $term['termmeta'] ) ) {
     601                $term['termmeta'] = array();
    616602            }
    617603
     
    625611             * @param array $term Term data from the WXR import.
    626612             */
    627             $term[ 'termmeta' ] = apply_filters( 'wp_import_term_meta', $term[ 'termmeta' ], $term_id, $term );
    628 
    629             if ( empty( $term[ 'termmeta' ] ) ) {
     613            $term['termmeta'] = apply_filters( 'wp_import_term_meta', $term['termmeta'], $term_id, $term );
     614
     615            if ( empty( $term['termmeta'] ) ) {
    630616                return;
    631617            }
    632618
    633             foreach ( $term[ 'termmeta' ] as $meta ) {
     619            foreach ( $term['termmeta'] as $meta ) {
    634620                /**
    635621                 * Filters the meta key for an imported piece of term meta.
     
    641627                 * @param array $term Term data from the WXR import.
    642628                 */
    643                 $key = apply_filters( 'import_term_meta_key', $meta[ 'key' ], $term_id, $term );
     629                $key = apply_filters( 'import_term_meta_key', $meta['key'], $term_id, $term );
    644630                if ( !$key ) {
    645631                    continue;
     
    647633
    648634                // Export gets meta straight from the DB so could have a serialized string
    649                 $value = maybe_unserialize( $meta[ 'value' ] );
     635                $value = maybe_unserialize( $meta['value'] );
    650636
    651637                add_term_meta( $term_id, $key, $value );
     
    672658         * Note that new/updated terms, comments and meta are imported for the last of the above.
    673659         */
    674         function process_posts()
    675         {
     660        function process_posts() {
    676661            $this->posts = apply_filters( 'wp_import_posts', $this->posts );
    677662
     
    680665
    681666                // Break if filter hook 'wp_import_post_data_raw' return null.
    682                 if(empty($post)){
     667                if ( empty( $post ) ) {
    683668                    continue;
    684                 }
    685 
    686                 if (!post_type_exists( $post[ 'post_type' ] ) ) {
    687                     printf( __( 'Failed to import &#8220;%s&#8221;: Invalid post type %s', 'wordpress-importer' ), esc_html( $post[ 'post_title' ] ), esc_html( $post[ 'post_type' ] ) );
     669                }
     670
     671                if ( !post_type_exists( $post['post_type'] ) ) {
     672                    printf( __( 'Failed to import &#8220;%s&#8221;: Invalid post type %s', 'wordpress-importer' ), esc_html( $post['post_title'] ), esc_html( $post['post_type'] ) );
    688673                    echo '<br />';
    689674                    do_action( 'wp_import_post_exists', $post );
     
    691676                }
    692677
    693                 if ( isset( $this->processed_posts[ $post[ 'post_id' ] ] ) && !empty( $post[ 'post_id' ] ) )
     678                if ( isset( $this->processed_posts[$post['post_id']] ) && !empty( $post['post_id'] ) )
    694679                    continue;
    695680
    696                 if ( $post[ 'status' ] == 'auto-draft' )
     681                if ( $post['status'] == 'auto-draft' )
    697682                    continue;
    698683
    699                 if ( 'nav_menu_item' == $post[ 'post_type' ] ) {
     684                if ( 'nav_menu_item' == $post['post_type'] ) {
    700685                    $this->process_menu_item( $post );
    701686                    continue;
    702687                }
    703688
    704                 $post_type_object = get_post_type_object( $post[ 'post_type' ] );
    705 
    706                 $post_exists = post_exists( $post[ 'post_title' ], '', $post[ 'post_date' ] );
     689                $post_type_object = get_post_type_object( $post['post_type'] );
     690
     691                $post_exists = post_exists( $post['post_title'], '', $post['post_date'] );
    707692
    708693                /**
     
    720705                $post_exists = apply_filters( 'wp_import_existing_post', $post_exists, $post );
    721706
    722                 if ( $post_exists && get_post_type( $post_exists ) == $post[ 'post_type' ] ) {
    723                     printf( __( '%s &#8220;%s&#8221; already exists.', 'wordpress-importer' ), $post_type_object->labels->singular_name, esc_html( $post[ 'post_title' ] ) );
     707                if ( $post_exists && get_post_type( $post_exists ) == $post['post_type'] ) {
     708                    printf( __( '%s &#8220;%s&#8221; already exists.', 'wordpress-importer' ), $post_type_object->labels->singular_name, esc_html( $post['post_title'] ) );
    724709                    echo '<br />';
    725710                    $comment_post_ID = $post_id = $post_exists;
    726                     $this->processed_posts[ intval( $post[ 'post_id' ] ) ] = intval( $post_exists );
     711                    $this->processed_posts[intval( $post['post_id'] )] = intval( $post_exists );
    727712                } else {
    728                     $post_parent = (int)$post[ 'post_parent' ];
     713                    $post_parent = (int) $post['post_parent'];
    729714                    if ( $post_parent ) {
    730715                        // if we already know the parent, map it to the new local ID
    731                         if ( isset( $this->processed_posts[ $post_parent ] ) ) {
    732                             $post_parent = $this->processed_posts[ $post_parent ];
     716                        if ( isset( $this->processed_posts[$post_parent] ) ) {
     717                            $post_parent = $this->processed_posts[$post_parent];
    733718                            // otherwise record the parent for later
    734719                        } else {
    735                             $this->post_orphans[ intval( $post[ 'post_id' ] ) ] = $post_parent;
     720                            $this->post_orphans[intval( $post['post_id'] )] = $post_parent;
    736721                            $post_parent = 0;
    737722                        }
     
    739724
    740725                    // map the post author
    741                     $author = sanitize_user( $post[ 'post_author' ], true );
    742                     if ( isset( $this->author_mapping[ $author ] ) )
    743                         $author = $this->author_mapping[ $author ];
     726                    $author = sanitize_user( $post['post_author'], true );
     727                    if ( isset( $this->author_mapping[$author] ) )
     728                        $author = $this->author_mapping[$author];
    744729                    else
    745                         $author = (int)get_current_user_id();
     730                        $author = (int) get_current_user_id();
    746731
    747732                    $postdata = array(
    748                         'import_id'      => $post[ 'post_id' ],
    749                         'post_author'    => $author,
    750                         'post_date'      => $post[ 'post_date' ],
    751                         'post_date_gmt'  => $post[ 'post_date_gmt' ],
    752                         'post_content'   => $post[ 'post_content' ],
    753                         'post_excerpt'   => $post[ 'post_excerpt' ],
    754                         'post_title'     => $post[ 'post_title' ],
    755                         'post_status'    => $post[ 'status' ],
    756                         'post_name'      => $post[ 'post_name' ],
    757                         'comment_status' => $post[ 'comment_status' ],
    758                         'ping_status'    => $post[ 'ping_status' ],
    759                         'guid'           => $post[ 'guid' ],
    760                         'post_parent'    => $post_parent, 'menu_order' => $post[ 'menu_order' ],
    761                         'post_type'      => $post[ 'post_type' ],
    762                         'post_password'  => $post[ 'post_password' ]
     733                        'import_id' => $post['post_id'],
     734                        'post_author' => $author,
     735                        'post_date' => $post['post_date'],
     736                        'post_date_gmt' => $post['post_date_gmt'],
     737                        'post_content' => $post['post_content'],
     738                        'post_excerpt' => $post['post_excerpt'],
     739                        'post_title' => $post['post_title'],
     740                        'post_status' => $post['status'],
     741                        'post_name' => $post['post_name'],
     742                        'comment_status' => $post['comment_status'],
     743                        'ping_status' => $post['ping_status'],
     744                        'guid' => $post['guid'],
     745                        'post_parent' => $post_parent, 'menu_order' => $post['menu_order'],
     746                        'post_type' => $post['post_type'],
     747                        'post_password' => $post['post_password']
    763748                    );
    764749
    765                     $original_post_ID = $post[ 'post_id' ];
     750                    $original_post_ID = $post['post_id'];
    766751                    $postdata = apply_filters( 'wp_import_post_data_processed', $postdata, $post );
    767752
    768753                    $postdata = wp_slash( $postdata );
    769754
    770                     if ( 'attachment' == $postdata[ 'post_type' ] ) {
    771                         $remote_url = !empty( $post[ 'attachment_url' ] ) ? $post[ 'attachment_url' ] : $post[ 'guid' ];
     755                    if ( 'attachment' == $postdata['post_type'] ) {
     756                        $remote_url = !empty( $post['attachment_url'] ) ? $post['attachment_url'] : $post['guid'];
    772757
    773758                        // try to use _wp_attached file for upload folder placement to ensure the same location as the export site
    774759                        // e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload()
    775                         $postdata[ 'upload_date' ] = $post[ 'post_date' ];
    776                         if ( isset( $post[ 'postmeta' ] ) ) {
    777                             foreach ( $post[ 'postmeta' ] as $meta ) {
    778                                 if ( $meta[ 'key' ] == '_wp_attached_file' ) {
    779                                     if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta[ 'value' ], $matches ) )
    780                                         $postdata[ 'upload_date' ] = $matches[ 0 ];
     760                        $postdata['upload_date'] = $post['post_date'];
     761                        if ( isset( $post['postmeta'] ) ) {
     762                            foreach ( $post['postmeta'] as $meta ) {
     763                                if ( $meta['key'] == '_wp_attached_file' ) {
     764                                    if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches ) )
     765                                        $postdata['upload_date'] = $matches[0];
    781766                                    break;
    782767                                }
     
    791776
    792777                    if ( is_wp_error( $post_id ) ) {
    793                         printf( __( 'Failed to import %s &#8220;%s&#8221;', 'wordpress-importer' ), $post_type_object->labels->singular_name, esc_html( $post[ 'post_title' ] ) );
     778                        printf( __( 'Failed to import %s &#8220;%s&#8221;', 'wordpress-importer' ), $post_type_object->labels->singular_name, esc_html( $post['post_title'] ) );
    794779                        if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG )
    795780                            echo ': ' . $post_id->get_error_message();
     
    798783                    }
    799784
    800                     if ( $post[ 'is_sticky' ] == 1 )
     785                    if ( $post['is_sticky'] == 1 )
    801786                        stick_post( $post_id );
    802787                }
    803788
    804789                // map pre-import ID to local ID
    805                 $this->processed_posts[ intval( $post[ 'post_id' ] ) ] = (int)$post_id;
    806 
    807                 if ( !isset( $post[ 'terms' ] ) )
    808                     $post[ 'terms' ] = array();
    809 
    810                 $post[ 'terms' ] = apply_filters( 'wp_import_post_terms', $post[ 'terms' ], $post_id, $post );
     790                $this->processed_posts[intval( $post['post_id'] )] = (int) $post_id;
     791
     792                if ( !isset( $post['terms'] ) )
     793                    $post['terms'] = array();
     794
     795                $post['terms'] = apply_filters( 'wp_import_post_terms', $post['terms'], $post_id, $post );
    811796
    812797                // add categories, tags and other terms
    813                 if ( !empty( $post[ 'terms' ] ) ) {
     798                if ( !empty( $post['terms'] ) ) {
    814799                    $terms_to_set = array();
    815                     foreach ( $post[ 'terms' ] as $term ) {
     800                    foreach ( $post['terms'] as $term ) {
    816801                        // back compat with WXR 1.0 map 'tag' to 'post_tag'
    817                         $taxonomy = ( 'tag' == $term[ 'domain' ] ) ? 'post_tag' : $term[ 'domain' ];
    818                         $term_exists = term_exists( $term[ 'slug' ], $taxonomy );
    819                         $term_id = is_array( $term_exists ) ? $term_exists[ 'term_id' ] : $term_exists;
     802                        $taxonomy = ( 'tag' == $term['domain'] ) ? 'post_tag' : $term['domain'];
     803                        $term_exists = term_exists( $term['slug'], $taxonomy );
     804                        $term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;
    820805                        if ( !$term_id ) {
    821                             $t = wp_insert_term( $term[ 'name' ], $taxonomy, array( 'slug' => $term[ 'slug' ] ) );
     806                            $t = wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) );
    822807                            if ( !is_wp_error( $t ) ) {
    823                                 $term_id = $t[ 'term_id' ];
     808                                $term_id = $t['term_id'];
    824809                                do_action( 'wp_import_insert_term', $t, $term, $post_id, $post );
    825810                            } else {
    826                                 printf( __( 'Failed to import %s %s', 'wordpress-importer' ), esc_html( $taxonomy ), esc_html( $term[ 'name' ] ) );
     811                                printf( __( 'Failed to import %s %s', 'wordpress-importer' ), esc_html( $taxonomy ), esc_html( $term['name'] ) );
    827812                                if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG )
    828813                                    echo ': ' . $t->get_error_message();
     
    832817                            }
    833818                        }
    834                         $terms_to_set[ $taxonomy ][] = intval( $term_id );
     819                        $terms_to_set[$taxonomy][] = intval( $term_id );
    835820                    }
    836821
     
    839824                        do_action( 'wp_import_set_post_terms', $tt_ids, $ids, $tax, $post_id, $post );
    840825                    }
    841                     unset( $post[ 'terms' ], $terms_to_set );
    842                 }
    843 
    844                 if ( !isset( $post[ 'comments' ] ) )
    845                     $post[ 'comments' ] = array();
    846 
    847                 $post[ 'comments' ] = apply_filters( 'wp_import_post_comments', $post[ 'comments' ], $post_id, $post );
     826                    unset( $post['terms'], $terms_to_set );
     827                }
     828
     829                if ( !isset( $post['comments'] ) )
     830                    $post['comments'] = array();
     831
     832                $post['comments'] = apply_filters( 'wp_import_post_comments', $post['comments'], $post_id, $post );
    848833
    849834                // add/update comments
    850                 if ( !empty( $post[ 'comments' ] ) ) {
     835                if ( !empty( $post['comments'] ) ) {
    851836                    $num_comments = 0;
    852837                    $inserted_comments = array();
    853                     foreach ( $post[ 'comments' ] as $comment ) {
    854                         $comment_id = $comment[ 'comment_id' ];
    855                         $newcomments[ $comment_id ][ 'comment_post_ID' ] = $comment_post_ID;
    856                         $newcomments[ $comment_id ][ 'comment_author' ] = $comment[ 'comment_author' ];
    857                         $newcomments[ $comment_id ][ 'comment_author_email' ] = $comment[ 'comment_author_email' ];
    858                         $newcomments[ $comment_id ][ 'comment_author_IP' ] = $comment[ 'comment_author_IP' ];
    859                         $newcomments[ $comment_id ][ 'comment_author_url' ] = $comment[ 'comment_author_url' ];
    860                         $newcomments[ $comment_id ][ 'comment_date' ] = $comment[ 'comment_date' ];
    861                         $newcomments[ $comment_id ][ 'comment_date_gmt' ] = $comment[ 'comment_date_gmt' ];
    862                         $newcomments[ $comment_id ][ 'comment_content' ] = $comment[ 'comment_content' ];
    863                         $newcomments[ $comment_id ][ 'comment_approved' ] = $comment[ 'comment_approved' ];
    864                         $newcomments[ $comment_id ][ 'comment_type' ] = $comment[ 'comment_type' ];
    865                         $newcomments[ $comment_id ][ 'comment_parent' ] = $comment[ 'comment_parent' ];
    866                         $newcomments[ $comment_id ][ 'commentmeta' ] = isset( $comment[ 'commentmeta' ] ) ? $comment[ 'commentmeta' ] : array();
    867                         if ( isset( $this->processed_authors[ $comment[ 'comment_user_id' ] ] ) )
    868                             $newcomments[ $comment_id ][ 'user_id' ] = $this->processed_authors[ $comment[ 'comment_user_id' ] ];
     838                    foreach ( $post['comments'] as $comment ) {
     839                        $comment_id = $comment['comment_id'];
     840                        $newcomments[$comment_id]['comment_post_ID'] = $comment_post_ID;
     841                        $newcomments[$comment_id]['comment_author'] = $comment['comment_author'];
     842                        $newcomments[$comment_id]['comment_author_email'] = $comment['comment_author_email'];
     843                        $newcomments[$comment_id]['comment_author_IP'] = $comment['comment_author_IP'];
     844                        $newcomments[$comment_id]['comment_author_url'] = $comment['comment_author_url'];
     845                        $newcomments[$comment_id]['comment_date'] = $comment['comment_date'];
     846                        $newcomments[$comment_id]['comment_date_gmt'] = $comment['comment_date_gmt'];
     847                        $newcomments[$comment_id]['comment_content'] = $comment['comment_content'];
     848                        $newcomments[$comment_id]['comment_approved'] = $comment['comment_approved'];
     849                        $newcomments[$comment_id]['comment_type'] = $comment['comment_type'];
     850                        $newcomments[$comment_id]['comment_parent'] = $comment['comment_parent'];
     851                        $newcomments[$comment_id]['commentmeta'] = isset( $comment['commentmeta'] ) ? $comment['commentmeta'] : array();
     852                        if ( isset( $this->processed_authors[$comment['comment_user_id']] ) )
     853                            $newcomments[$comment_id]['user_id'] = $this->processed_authors[$comment['comment_user_id']];
    869854                    }
    870855                    ksort( $newcomments );
     
    872857                    foreach ( $newcomments as $key => $comment ) {
    873858                        // if this is a new post we can skip the comment_exists() check
    874                         if ( !$post_exists || !comment_exists( $comment[ 'comment_author' ], $comment[ 'comment_date' ] ) ) {
    875                             if ( isset( $inserted_comments[ $comment[ 'comment_parent' ] ] ) )
    876                                 $comment[ 'comment_parent' ] = $inserted_comments[ $comment[ 'comment_parent' ] ];
     859                        if ( !$post_exists || !comment_exists( $comment['comment_author'], $comment['comment_date'] ) ) {
     860                            if ( isset( $inserted_comments[$comment['comment_parent']] ) )
     861                                $comment['comment_parent'] = $inserted_comments[$comment['comment_parent']];
    877862                            $comment = wp_filter_comment( $comment );
    878                             $inserted_comments[ $key ] = wp_insert_comment( $comment );
    879                             do_action( 'wp_import_insert_comment', $inserted_comments[ $key ], $comment, $comment_post_ID, $post );
    880 
    881                             foreach ( $comment[ 'commentmeta' ] as $meta ) {
    882                                 $value = maybe_unserialize( $meta[ 'value' ] );
    883                                 add_comment_meta( $inserted_comments[ $key ], $meta[ 'key' ], $value );
     863                            $inserted_comments[$key] = wp_insert_comment( $comment );
     864                            do_action( 'wp_import_insert_comment', $inserted_comments[$key], $comment, $comment_post_ID, $post );
     865
     866                            foreach ( $comment['commentmeta'] as $meta ) {
     867                                $value = maybe_unserialize( $meta['value'] );
     868                                add_comment_meta( $inserted_comments[$key], $meta['key'], $value );
    884869                            }
    885870
     
    887872                        }
    888873                    }
    889                     unset( $newcomments, $inserted_comments, $post[ 'comments' ] );
    890                 }
    891 
    892                 if ( !isset( $post[ 'postmeta' ] ) )
    893                     $post[ 'postmeta' ] = array();
    894 
    895                 $post[ 'postmeta' ] = apply_filters( 'wp_import_post_meta', $post[ 'postmeta' ], $post_id, $post );
     874                    unset( $newcomments, $inserted_comments, $post['comments'] );
     875                }
     876
     877                if ( !isset( $post['postmeta'] ) )
     878                    $post['postmeta'] = array();
     879
     880                $post['postmeta'] = apply_filters( 'wp_import_post_meta', $post['postmeta'], $post_id, $post );
    896881
    897882                // add/update post meta
    898                 if ( !empty( $post[ 'postmeta' ] ) ) {
    899                     foreach ( $post[ 'postmeta' ] as $meta ) {
    900                         $key = apply_filters( 'import_post_meta_key', $meta[ 'key' ], $post_id, $post );
     883                if ( !empty( $post['postmeta'] ) ) {
     884                    foreach ( $post['postmeta'] as $meta ) {
     885                        $key = apply_filters( 'import_post_meta_key', $meta['key'], $post_id, $post );
    901886                        $value = false;
    902887
    903888                        if ( '_edit_last' == $key ) {
    904                             if ( isset( $this->processed_authors[ intval( $meta[ 'value' ] ) ] ) )
    905                                 $value = $this->processed_authors[ intval( $meta[ 'value' ] ) ];
     889                            if ( isset( $this->processed_authors[intval( $meta['value'] )] ) )
     890                                $value = $this->processed_authors[intval( $meta['value'] )];
    906891                            else
    907892                                $key = false;
     
    911896                            // export gets meta straight from the DB so could have a serialized string
    912897                            if ( !$value )
    913                                 $value = maybe_unserialize( $meta[ 'value' ] );
     898                                $value = maybe_unserialize( $meta['value'] );
    914899
    915900                            add_post_meta( $post_id, $key, $value );
     
    918903                            // if the post has a featured image, take note of this in case of remap
    919904                            if ( '_thumbnail_id' == $key )
    920                                 $this->featured_images[ $post_id ] = (int)$value;
     905                                $this->featured_images[$post_id] = (int) $value;
    921906                        }
    922907                    }
     
    937922         * @param array $item Menu item details from WXR file
    938923         */
    939         function process_menu_item( $item )
    940         {
     924        function process_menu_item( $item ) {
    941925            // skip draft, orphaned menu items
    942             if ( 'draft' == $item[ 'status' ] )
     926            if ( 'draft' == $item['status'] )
    943927                return;
    944928
    945929            $menu_slug = false;
    946             if ( isset( $item[ 'terms' ] ) ) {
     930            if ( isset( $item['terms'] ) ) {
    947931                // loop through terms, assume first nav_menu term is correct menu
    948                 foreach ( $item[ 'terms' ] as $term ) {
    949                     if ( 'nav_menu' == $term[ 'domain' ] ) {
    950                         $menu_slug = $term[ 'slug' ];
     932                foreach ( $item['terms'] as $term ) {
     933                    if ( 'nav_menu' == $term['domain'] ) {
     934                        $menu_slug = $term['slug'];
    951935                        break;
    952936                    }
     
    967951                return;
    968952            } else {
    969                 $menu_id = is_array( $menu_id ) ? $menu_id[ 'term_id' ] : $menu_id;
    970             }
    971 
    972             foreach ( $item[ 'postmeta' ] as $meta )
    973                 $$meta[ 'key' ] = $meta[ 'value' ];
    974 
    975             if ( 'taxonomy' == $_menu_item_type && isset( $this->processed_terms[ intval( $_menu_item_object_id ) ] ) ) {
    976                 $_menu_item_object_id = $this->processed_terms[ intval( $_menu_item_object_id ) ];
    977             } else if ( 'post_type' == $_menu_item_type && isset( $this->processed_posts[ intval( $_menu_item_object_id ) ] ) ) {
    978                 $_menu_item_object_id = $this->processed_posts[ intval( $_menu_item_object_id ) ];
     953                $menu_id = is_array( $menu_id ) ? $menu_id['term_id'] : $menu_id;
     954            }
     955
     956            $args = array();
     957            foreach ( $item['postmeta'] as $meta ) {
     958                $args[$meta['key']] = $meta['value'];
     959            }
     960           
     961            extract( $args );
     962           
     963            if(empty($_menu_item_type)){
     964                return;
     965            }
     966
     967            if ( 'taxonomy' == $_menu_item_type && isset( $this->processed_terms[intval( $_menu_item_object_id )] ) ) {
     968                $_menu_item_object_id = $this->processed_terms[intval( $_menu_item_object_id )];
     969            } else if ( 'post_type' == $_menu_item_type && isset( $this->processed_posts[intval( $_menu_item_object_id )] ) ) {
     970                $_menu_item_object_id = $this->processed_posts[intval( $_menu_item_object_id )];
    979971            } else if ( 'custom' != $_menu_item_type ) {
    980972                // associated object is missing or not imported yet, we'll retry later
     
    983975            }
    984976
    985             if ( isset( $this->processed_menu_items[ intval( $_menu_item_menu_item_parent ) ] ) ) {
    986                 $_menu_item_menu_item_parent = $this->processed_menu_items[ intval( $_menu_item_menu_item_parent ) ];
     977            if ( isset( $this->processed_menu_items[intval( $_menu_item_menu_item_parent )] ) ) {
     978                $_menu_item_menu_item_parent = $this->processed_menu_items[intval( $_menu_item_menu_item_parent )];
    987979            } else if ( $_menu_item_menu_item_parent ) {
    988                 $this->menu_item_orphans[ intval( $item[ 'post_id' ] ) ] = (int)$_menu_item_menu_item_parent;
     980                $this->menu_item_orphans[intval( $item['post_id'] )] = (int) $_menu_item_menu_item_parent;
    989981                $_menu_item_menu_item_parent = 0;
    990982            }
     
    996988
    997989            $args = array(
    998                 'menu-item-object-id'   => $_menu_item_object_id,
    999                 'menu-item-object'      => $_menu_item_object,
    1000                 'menu-item-parent-id'   => $_menu_item_menu_item_parent,
    1001                 'menu-item-position'    => intval( $item[ 'menu_order' ] ),
    1002                 'menu-item-type'        => $_menu_item_type,
    1003                 'menu-item-title'       => $item[ 'post_title' ],
    1004                 'menu-item-url'         => $_menu_item_url,
    1005                 'menu-item-description' => $item[ 'post_content' ],
    1006                 'menu-item-attr-title'  => $item[ 'post_excerpt' ],
    1007                 'menu-item-target'      => $_menu_item_target,
    1008                 'menu-item-classes'     => $_menu_item_classes,
    1009                 'menu-item-xfn'         => $_menu_item_xfn,
    1010                 'menu-item-status'      => $item[ 'status' ]
     990                'menu-item-object-id' => $_menu_item_object_id,
     991                'menu-item-object' => $_menu_item_object,
     992                'menu-item-parent-id' => $_menu_item_menu_item_parent,
     993                'menu-item-position' => intval( $item['menu_order'] ),
     994                'menu-item-type' => $_menu_item_type,
     995                'menu-item-title' => $item['post_title'],
     996                'menu-item-url' => $_menu_item_url,
     997                'menu-item-description' => $item['post_content'],
     998                'menu-item-attr-title' => $item['post_excerpt'],
     999                'menu-item-target' => $_menu_item_target,
     1000                'menu-item-classes' => $_menu_item_classes,
     1001                'menu-item-xfn' => $_menu_item_xfn,
     1002                'menu-item-status' => $item['status']
    10111003            );
    10121004
    10131005            $id = wp_update_nav_menu_item( $menu_id, 0, $args );
    10141006            if ( $id && !is_wp_error( $id ) )
    1015                 $this->processed_menu_items[ intval( $item[ 'post_id' ] ) ] = (int)$id;
     1007                $this->processed_menu_items[intval( $item['post_id'] )] = (int) $id;
    10161008        }
    10171009
     
    10231015         * @return int|WP_Error Post ID on success, WP_Error otherwise
    10241016         */
    1025         function process_attachment( $post, $url )
    1026         {
     1017        function process_attachment( $post, $url ) {
    10271018            if ( !$this->fetch_attachments )
    10281019                return new WP_Error( 'attachment_processing_error', __( 'Fetching attachments is not enabled', 'wordpress-importer' ) );
     
    10361027                return $upload;
    10371028
    1038             if ( $info = wp_check_filetype( $upload[ 'file' ] ) )
    1039                 $post[ 'post_mime_type' ] = $info[ 'type' ];
     1029            if ( $info = wp_check_filetype( $upload['file'] ) )
     1030                $post['post_mime_type'] = $info['type'];
    10401031            else
    10411032                return new WP_Error( 'attachment_processing_error', __( 'Invalid file type', 'wordpress-importer' ) );
    10421033
    1043             $post[ 'guid' ] = $upload[ 'url' ];
     1034            $post['guid'] = $upload['url'];
    10441035
    10451036            // as per wp-admin/includes/upload.php
    1046             $post_id = wp_insert_attachment( $post, $upload[ 'file' ] );
    1047             wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload[ 'file' ] ) );
     1037            $post_id = wp_insert_attachment( $post, $upload['file'] );
     1038            wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) );
    10481039
    10491040            // remap resized image URLs, works by stripping the extension and remapping the URL stub.
    1050             if ( preg_match( '!^image/!', $info[ 'type' ] ) ) {
     1041            if ( preg_match( '!^image/!', $info['type'] ) ) {
    10511042                $parts = pathinfo( $url );
    1052                 $name = basename( $parts[ 'basename' ], ".{$parts['extension']}" ); // PATHINFO_FILENAME in PHP 5.2
    1053 
    1054                 $parts_new = pathinfo( $upload[ 'url' ] );
    1055                 $name_new = basename( $parts_new[ 'basename' ], ".{$parts_new['extension']}" );
    1056 
    1057                 $this->url_remap[ $parts[ 'dirname' ] . '/' . $name ] = $parts_new[ 'dirname' ] . '/' . $name_new;
     1043                $name = basename( $parts['basename'], ".{$parts['extension']}" ); // PATHINFO_FILENAME in PHP 5.2
     1044
     1045                $parts_new = pathinfo( $upload['url'] );
     1046                $name_new = basename( $parts_new['basename'], ".{$parts_new['extension']}" );
     1047
     1048                $this->url_remap[$parts['dirname'] . '/' . $name] = $parts_new['dirname'] . '/' . $name_new;
    10581049            }
    10591050
     
    10681059         * @return array|WP_Error Local file location details on success, WP_Error otherwise
    10691060         */
    1070         function fetch_remote_file( $url, $post )
    1071         {
     1061        function fetch_remote_file( $url, $post ) {
    10721062            // extract the file name and extension from the url
    10731063            $file_name = basename( $url );
    10741064
    10751065            // get placeholder file in the upload dir with a unique, sanitized filename
    1076             $upload = wp_upload_bits( $file_name, 0, '', $post[ 'upload_date' ] );
    1077             if ( $upload[ 'error' ] )
    1078                 return new WP_Error( 'upload_dir_error', $upload[ 'error' ] );
     1066            $upload = wp_upload_bits( $file_name, 0, '', $post['upload_date'] );
     1067            if ( $upload['error'] )
     1068                return new WP_Error( 'upload_dir_error', $upload['error'] );
    10791069
    10801070            // fetch the remote url and write it to the placeholder file
    1081             $headers = tp_importer_get_http( $url, $upload[ 'file' ] );
     1071            $headers = tp_importer_get_http( $url, $upload['file'] );
    10821072
    10831073            // request failed
    10841074            if ( !$headers ) {
    1085                 @unlink( $upload[ 'file' ] );
     1075                @unlink( $upload['file'] );
    10861076                return new WP_Error( 'import_file_error', __( 'Remote server did not respond', 'wordpress-importer' ) );
    10871077            }
    10881078
    10891079            // make sure the fetch was successful
    1090             if ( $headers[ 'response' ] != '200' ) {
    1091                 @unlink( $upload[ 'file' ] );
    1092                 return new WP_Error( 'import_file_error', sprintf( __( 'Remote server returned error response %1$d %2$s', 'wordpress-importer' ), esc_html( $headers[ 'response' ] ), get_status_header_desc( $headers[ 'response' ] ) ) );
    1093             }
    1094 
    1095             $filesize = filesize( $upload[ 'file' ] );
    1096 
    1097             if ( isset( $headers[ 'content-length' ] ) && $filesize != $headers[ 'content-length' ] ) {
    1098                 @unlink( $upload[ 'file' ] );
     1080            if ( $headers['response'] != '200' ) {
     1081                @unlink( $upload['file'] );
     1082                return new WP_Error( 'import_file_error', sprintf( __( 'Remote server returned error response %1$d %2$s', 'wordpress-importer' ), esc_html( $headers['response'] ), get_status_header_desc( $headers['response'] ) ) );
     1083            }
     1084
     1085            $filesize = filesize( $upload['file'] );
     1086
     1087            if ( isset( $headers['content-length'] ) && $filesize != $headers['content-length'] ) {
     1088                @unlink( $upload['file'] );
    10991089                return new WP_Error( 'import_file_error', __( 'Remote file is incorrect size', 'wordpress-importer' ) );
    11001090            }
    11011091
    11021092            if ( 0 == $filesize ) {
    1103                 @unlink( $upload[ 'file' ] );
     1093                @unlink( $upload['file'] );
    11041094                return new WP_Error( 'import_file_error', __( 'Zero size file downloaded', 'wordpress-importer' ) );
    11051095            }
    11061096
    1107             $max_size = (int)$this->max_attachment_size();
     1097            $max_size = (int) $this->max_attachment_size();
    11081098            if ( !empty( $max_size ) && $filesize > $max_size ) {
    1109                 @unlink( $upload[ 'file' ] );
     1099                @unlink( $upload['file'] );
    11101100                return new WP_Error( 'import_file_error', sprintf( __( 'Remote file is too large, limit is %s', 'wordpress-importer' ), size_format( $max_size ) ) );
    11111101            }
    11121102
    11131103            // keep track of the old and new urls so we can substitute them later
    1114             $this->url_remap[ $url ] = $upload[ 'url' ];
    1115             $this->url_remap[ $post[ 'guid' ] ] = $upload[ 'url' ]; // r13735, really needed?
     1104            $this->url_remap[$url] = $upload['url'];
     1105            $this->url_remap[$post['guid']] = $upload['url']; // r13735, really needed?
    11161106            // keep track of the destination if the remote url is redirected somewhere else
    1117             if ( isset( $headers[ 'x-final-location' ] ) && $headers[ 'x-final-location' ] != $url )
    1118                 $this->url_remap[ $headers[ 'x-final-location' ] ] = $upload[ 'url' ];
     1107            if ( isset( $headers['x-final-location'] ) && $headers['x-final-location'] != $url )
     1108                $this->url_remap[$headers['x-final-location']] = $upload['url'];
    11191109
    11201110            return $upload;
     
    11281118         * the object (e.g. post) they represent in the menu
    11291119         */
    1130         function backfill_parents()
    1131         {
     1120        function backfill_parents() {
    11321121            global $wpdb;
    11331122
     
    11351124            foreach ( $this->post_orphans as $child_id => $parent_id ) {
    11361125                $local_child_id = $local_parent_id = false;
    1137                 if ( isset( $this->processed_posts[ $child_id ] ) )
    1138                     $local_child_id = $this->processed_posts[ $child_id ];
    1139                 if ( isset( $this->processed_posts[ $parent_id ] ) )
    1140                     $local_parent_id = $this->processed_posts[ $parent_id ];
     1126                if ( isset( $this->processed_posts[$child_id] ) )
     1127                    $local_child_id = $this->processed_posts[$child_id];
     1128                if ( isset( $this->processed_posts[$parent_id] ) )
     1129                    $local_parent_id = $this->processed_posts[$parent_id];
    11411130
    11421131                if ( $local_child_id && $local_parent_id )
     
    11521141            foreach ( $this->menu_item_orphans as $child_id => $parent_id ) {
    11531142                $local_child_id = $local_parent_id = 0;
    1154                 if ( isset( $this->processed_menu_items[ $child_id ] ) )
    1155                     $local_child_id = $this->processed_menu_items[ $child_id ];
    1156                 if ( isset( $this->processed_menu_items[ $parent_id ] ) )
    1157                     $local_parent_id = $this->processed_menu_items[ $parent_id ];
     1143                if ( isset( $this->processed_menu_items[$child_id] ) )
     1144                    $local_child_id = $this->processed_menu_items[$child_id];
     1145                if ( isset( $this->processed_menu_items[$parent_id] ) )
     1146                    $local_parent_id = $this->processed_menu_items[$parent_id];
    11581147
    11591148                if ( $local_child_id && $local_parent_id )
    1160                     update_post_meta( $local_child_id, '_menu_item_menu_item_parent', (int)$local_parent_id );
     1149                    update_post_meta( $local_child_id, '_menu_item_menu_item_parent', (int) $local_parent_id );
    11611150            }
    11621151        }
     
    11651154         * Use stored mapping information to update old attachment URLs
    11661155         */
    1167         function backfill_attachment_urls()
    1168         {
     1156        function backfill_attachment_urls() {
    11691157            global $wpdb;
    11701158            // make sure we do the longest urls first, in case one is a substring of another
     
    11821170         * Update _thumbnail_id meta to new, imported attachment IDs
    11831171         */
    1184         function remap_featured_images()
    1185         {
     1172        function remap_featured_images() {
    11861173            // cycle through posts that have a featured image
    11871174            foreach ( $this->featured_images as $post_id => $value ) {
    1188                 if ( isset( $this->processed_posts[ $value ] ) ) {
    1189                     $new_id = $this->processed_posts[ $value ];
     1175                if ( isset( $this->processed_posts[$value] ) ) {
     1176                    $new_id = $this->processed_posts[$value];
    11901177                    // only update if there's a difference
    11911178                    if ( $new_id != $value )
     
    12011188         * @return array Information gathered from the WXR file
    12021189         */
    1203         function parse( $file )
    1204         {
     1190        function parse( $file ) {
    12051191            $parser = new WXR_Parser();
    12061192            return $parser->parse( $file );
     
    12081194
    12091195        // Display import page title
    1210         function header()
    1211         {
     1196        function header() {
    12121197            echo '<div class="wrap">';
    12131198            screen_icon();
     
    12161201            $updates = get_plugin_updates();
    12171202            $basename = plugin_basename( __FILE__ );
    1218             if ( isset( $updates[ $basename ] ) ) {
    1219                 $update = $updates[ $basename ];
     1203            if ( isset( $updates[$basename] ) ) {
     1204                $update = $updates[$basename];
    12201205                echo '<div class="error"><p><strong>';
    12211206                printf( __( 'A new version of this importer is available. Please update to version %s to ensure compatibility with newer export files.', 'wordpress-importer' ), $update->update->new_version );
     
    12251210
    12261211        // Close div.wrap
    1227         function footer()
    1228         {
     1212        function footer() {
    12291213            echo '</div>';
    12301214        }
     
    12331217         * Display introductory text and file upload form
    12341218         */
    1235         function greet()
    1236         {
     1219        function greet() {
    12371220            echo '<div class="narrow">';
    12381221            echo '<p>' . __( 'Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import the posts, pages, comments, custom fields, categories, and tags into this site.', 'wordpress-importer' ) . '</p>';
     
    12481231         * @return string|bool The key if we do want to import, false if not
    12491232         */
    1250         function is_valid_meta_key( $key )
    1251         {
     1233        function is_valid_meta_key( $key ) {
    12521234            // skip attachment metadata since we'll regenerate it from scratch
    12531235            // skip _edit_lock as not relevant for import
     
    12631245         * @return bool True if creating users is allowed
    12641246         */
    1265         function allow_create_users()
    1266         {
     1247        function allow_create_users() {
    12671248            return apply_filters( 'import_allow_create_users', true );
    12681249        }
     
    12751256         * @return bool True if downloading attachments is allowed
    12761257         */
    1277         function allow_fetch_attachments()
    1278         {
     1258        function allow_fetch_attachments() {
    12791259            return apply_filters( 'import_allow_fetch_attachments', true );
    12801260        }
     
    12861266         * @return int Maximum attachment file size to import
    12871267         */
    1288         function max_attachment_size()
    1289         {
     1268        function max_attachment_size() {
    12901269            return apply_filters( 'import_attachment_size_limit', 0 );
    12911270        }
     
    12951274         * @return int 300
    12961275         */
    1297         function bump_request_timeout( $val )
    1298         {
     1276        function bump_request_timeout( $val ) {
    12991277            return 300;
    13001278        }
    13011279
    13021280        // return the difference in length between two strings
    1303         function cmpr_strlen( $a, $b )
    1304         {
     1281        function cmpr_strlen( $a, $b ) {
    13051282            return strlen( $b ) - strlen( $a );
    13061283        }
  • tp-framework/trunk/assets/js/customize-fields.js

    r1703500 r1818773  
    141141    wp.customize.bind('ready', function () {
    142142
     143
    143144        if (typeof tpfw_customizer_dependency == 'object') {
    144145
    145             $.each(tpfw_customizer_dependency, function (master, item) {
     146            $.each(tpfw_customizer_dependency, function (slave, masters) {
    146147
    147                 wp.customize(master, function (setting) {
     148                $.each(masters, function (key, value) {
     149                    masters['[data-customize-setting-link="' + key + '"]'] = value;
     150                    delete masters[key];
     151                });
     152               
     153                if ($('#customize-control-' + slave).length) {
     154                    $('#customize-control-' + slave).dependsOn(masters);
     155                }
    148156
    149                     $.each(item.elements, function (slave, value) {
    150 
    151                         wp.customize.control(slave, function (control) {
    152 
    153                             var visibility = function () {
    154 
    155                                 var _value = setting.get();
    156                                 if (item.type == 'checkbox_multiple' && typeof _value == 'string' && _value != '') {
    157                                     _value = _value.split(',');
    158                                 }
    159                                
    160                                 if (typeof value.values == 'object') {
    161 
    162                                     var flag = false;
    163 
    164                                     if (typeof _value != 'object') {
    165                                         if ($.inArray(_value, value.values) >= 0) {
    166                                             flag = true;
    167                                         }
    168                                     } else if (value.values.length == 1) {
    169                                         if ($.inArray(value.values[0], _value) >= 0) {
    170                                             flag = true;
    171                                         }
    172                                     } else {
    173 
    174                                         var arr = [];
    175                                         var arr1 = value.values;
    176                                         var arr2 = Object.values(_value);
    177                                         if (arr1.length < arr2.length) {
    178                                             arr1 = Object.values(_value);
    179                                             arr2 = value.values;
    180                                         }
    181 
    182                                         $.each(arr1, function (k, val) {
    183 
    184                                             if ($.inArray(val, arr2) == -1) {
    185                                                 arr.push(val);
    186                                             }
    187                                         });
    188                                         flag = arr.length == 0 ? true : false;
    189                                     }
    190 
    191                                     if (flag) {
    192                                         control.container.show();
    193                                     } else {
    194                                         control.container.hide();
    195                                     }
    196                                 }  else {
    197                                     if (_value == value.values) {
    198                                         control.container.show();
    199                                     } else {
    200                                         control.container.hide();
    201                                     }
    202                                 }
    203 
    204 
    205                             };
    206                             visibility();
    207                             setting.bind(visibility);
    208                         });
    209                     });
    210                 });
    211157            });
    212158        }
  • tp-framework/trunk/assets/js/customize-fields.min.js

    r1703500 r1818773  
    1 wp.customize.controlConstructor.tpfw_select=wp.customize.Control.extend({ready:function(){"use strict";var t,e=this,n=this.container.find("select"),i=n.data("multiple");i&&jQuery(n).selectize({plugins:["remove_button","drag_drop"]}),this.container.on("change","select",function(){t=jQuery(this).val(),i&&(t=_.extend({},jQuery(this).val())),e.setting.set(t)})}}),jQuery(function(t){"use strict";document.getElementsByClassName("tpfw-icon_picker").length&&t("#widgets-right .customize-control .tpfw-icon_picker:not(.child-field) select").fontIconPicker(),document.getElementsByClassName("tpfw-repeater").length&&t("#widgets-right .tpfw-repeater").tpfwRepeater(),document.getElementsByClassName("tpfw-map").length&&t("#widgets-right .tpfw-map").tpfwMap(),document.getElementsByClassName("tpfw-datetime").length&&t("#widgets-right .tpfw-datetime input").each(function(){var e=t(this).data();t(this).datetimepicker(e)}),document.getElementsByClassName("tpfw-link").length&&t("#widgets-right .customize-control .tpfw-link").tpfwLink(),t(".accordion-section").on("expanded",function(){t(this).find(".tpfw-map:not(.child-field)").length&&t(this).find(".tpfw-map:not(.child-field)").tpfwMap()}),document.getElementsByClassName("tpfw-typography").length&&t("#widgets-right .customize-control .tpfw-typography").tpfwTypography();var e=t("textarea.custom_code"),n=e[0];e.on("blur",function(){e.data("next-tab-blurs",!1)}),e.on("keydown",function(t){var i,o,a,s=9,c=27;return c===t.keyCode?void(e.data("next-tab-blurs")||(e.data("next-tab-blurs",!0),t.stopPropagation())):void(s!==t.keyCode||t.ctrlKey||t.altKey||t.shiftKey||e.data("next-tab-blurs")||(i=n.selectionStart,o=n.selectionEnd,a=n.value,i>=0&&(n.value=a.substring(0,i).concat("   ",a.substring(o)),e.selectionStart=n.selectionEnd=i+1),t.stopPropagation(),t.preventDefault()))}),document.getElementsByClassName("tpfw-autocomplete").length&&(t("#widgets-right .customize-control .tpfw-autocomplete:not(.child-field) select").tpfwAutocomplete(),t("#widgets-right").on("change",".customize-control .tpfw-autocomplete select",function(){t(this).closest("div").find(".tpfw_value").val(t(this).val()).trigger("change")}))}),function(t){wp.customize.bind("ready",function(){"object"==typeof tpfw_customizer_dependency&&t.each(tpfw_customizer_dependency,function(e,n){wp.customize(e,function(e){t.each(n.elements,function(i,o){wp.customize.control(i,function(i){var a=function(){var a=e.get();if("checkbox_multiple"==n.type&&"string"==typeof a&&""!=a&&(a=a.split(",")),"object"==typeof o.values){var s=!1;if("object"!=typeof a)t.inArray(a,o.values)>=0&&(s=!0);else if(1==o.values.length)t.inArray(o.values[0],a)>=0&&(s=!0);else{var c=[],l=o.values,r=Object.values(a);l.length<r.length&&(l=Object.values(a),r=o.values),t.each(l,function(e,n){-1==t.inArray(n,r)&&c.push(n)}),s=0==c.length?!0:!1}s?i.container.show():i.container.hide()}else a==o.values?i.container.show():i.container.hide()};a(),e.bind(a)})})})})})}(jQuery);
     1wp.customize.controlConstructor.tpfw_select=wp.customize.Control.extend({ready:function(){"use strict";var t,e=this,n=this.container.find("select"),o=n.data("multiple");o&&jQuery(n).selectize({plugins:["remove_button","drag_drop"]}),this.container.on("change","select",function(){t=jQuery(this).val(),o&&(t=_.extend({},jQuery(this).val())),e.setting.set(t)})}}),jQuery(function(t){"use strict";document.getElementsByClassName("tpfw-icon_picker").length&&t("#widgets-right .customize-control .tpfw-icon_picker:not(.child-field) select").fontIconPicker(),document.getElementsByClassName("tpfw-repeater").length&&t("#widgets-right .tpfw-repeater").tpfwRepeater(),document.getElementsByClassName("tpfw-map").length&&t("#widgets-right .tpfw-map").tpfwMap(),document.getElementsByClassName("tpfw-datetime").length&&t("#widgets-right .tpfw-datetime input").each(function(){var e=t(this).data();t(this).datetimepicker(e)}),document.getElementsByClassName("tpfw-link").length&&t("#widgets-right .customize-control .tpfw-link").tpfwLink(),t(".accordion-section").on("expanded",function(){t(this).find(".tpfw-map:not(.child-field)").length&&t(this).find(".tpfw-map:not(.child-field)").tpfwMap()}),document.getElementsByClassName("tpfw-typography").length&&t("#widgets-right .customize-control .tpfw-typography").tpfwTypography();var e=t("textarea.custom_code"),n=e[0];e.on("blur",function(){e.data("next-tab-blurs",!1)}),e.on("keydown",function(t){var o,i,c;27!==t.keyCode?9!==t.keyCode||t.ctrlKey||t.altKey||t.shiftKey||e.data("next-tab-blurs")||(o=n.selectionStart,i=n.selectionEnd,c=n.value,o>=0&&(n.value=c.substring(0,o).concat("\t",c.substring(i)),e.selectionStart=n.selectionEnd=o+1),t.stopPropagation(),t.preventDefault()):e.data("next-tab-blurs")||(e.data("next-tab-blurs",!0),t.stopPropagation())}),document.getElementsByClassName("tpfw-autocomplete").length&&(t("#widgets-right .customize-control .tpfw-autocomplete:not(.child-field) select").tpfwAutocomplete(),t("#widgets-right").on("change",".customize-control .tpfw-autocomplete select",function(){t(this).closest("div").find(".tpfw_value").val(t(this).val()).trigger("change")}))}),function(t){wp.customize.bind("ready",function(){"object"==typeof tpfw_customizer_dependency&&t.each(tpfw_customizer_dependency,function(e,n){t.each(n,function(t,e){n['[data-customize-setting-link="'+t+'"]']=e,delete n[t]}),t("#customize-control-"+e).length&&t("#customize-control-"+e).dependsOn(n)})})}(jQuery);
  • tp-framework/trunk/assets/vendors/dependency/dependency.js

    r1778449 r1818773  
    1515        this.qualifiers = f
    1616    };
     17
    1718    dependsOn.prototype.enabled = function (e) {
    1819        if (c(this.selector + "[disabled]").length > 0) {
     
    2728        return true
    2829    };
     30
    2931    dependsOn.prototype.checked = function (e) {
     32
    3033        if (this.$dependencyObj.attr("type") === "checkbox") {
    3134            if ((!this.$dependencyObj.is(":checked") && e) || (this.$dependencyObj.is(":checked") && !e)) {
     
    3740
    3841    dependsOn.prototype.values = function (value) {
    39 
     42       
    4043        var master_value = this.$dependencyObj.val(),
    4144                flag = false;
    42        
     45
    4346        if (this.$dependencyObj.attr('type') == 'checkbox') {
    4447            master_value = this.$dependencyObj.is(':checked') ? 1 : 0;
     48
    4549
    4650        } else if (this.$dependencyObj.data('type') == 'checkbox' && typeof master_value == 'string') {
     
    4852                master_value = master_value.split(',');
    4953            }
    50         }
    51 
    52 
    53         if (this.$dependencyObj.attr("type") === "radio") {
     54        } else if (this.$dependencyObj.attr("type") === "radio") {
    5455            master_value = this.$dependencyObj.filter(":checked").val();
    5556        }
     
    5859            value = [value];
    5960        }
    60 
     61       
    6162        for (var i = 0; i < value.length; i++) {
    6263
    63             if (typeof (master_value) === "array" || typeof (master_value) === "object") {
    64 
     64            if (typeof master_value == 'object') {
     65               
    6566                if (master_value.indexOf(value[i]) >= 0) {
    6667                    flag = true;
    6768                    break
    6869                }
     70               
    6971            } else {
     72             
    7073                if (value[i] == master_value) {
    7174                    flag = true;
     
    7477            }
    7578        }
     79     
    7680        return flag;
    7781    };
     
    113117        return false
    114118    };
     119
    115120    dependsOn.prototype.email = function (f) {
    116121        var e = /^[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/;
     
    133138            } else {
    134139                if (typeof (this.qualifiers[e] === "function")) {
     140
    135141                    return this.qualifiers[e](this.$dependencyObj.val())
    136142                }
     
    149155
    150156    a.prototype.doesQualify = function () {
     157
    151158        var f = this.dependencies.length,
    152159                g = 0,
     
    175182        this.init(g)
    176183    };
     184
    177185    b.prototype.init = function (e) {
    178186        this.addSet(e);
    179187        this.check(true)
    180188    };
     189
    181190    b.prototype.addSet = function (j) {
     191
    182192        var f = this,
    183193                e = 0,
     
    185195                i = 0,
    186196                g;
     197
    187198        this.dependencySets.push(new a(j));
    188199        e = this.dependencySets.length - 1;
    189200        h = this.dependencySets[e].dependencies.length;
    190201        for (i; i < h; i += 1) {
     202
    191203            g = this.dependencySets[e].dependencies[i];
    192             g.$dependencyObj.on("change", function () {
     204            g.$dependencyObj.on("change", function (e) {
    193205                f.check()
    194206            });
     207
    195208            if (g.$dependencyObj.attr("type") === "text") {
    196209                g.$dependencyObj.on("keypress", function (k) {
     
    200213                })
    201214            }
    202         }
    203     };
     215
     216        }
     217    };
     218
    204219    b.prototype.or = function (e) {
    205220        this.addSet(e);
     
    207222        return this
    208223    };
     224
    209225    b.prototype.enable = function (e) {
    210226        var h = this.$subject,
     
    222238        }
    223239        if (this.settings.hide) {
    224             f = this.$subject.closest('.tpfw_form_row');
     240            f = this.$subject.closest('.tpfw_form_row,.customize-control');
    225241
    226242            if (f.css("display") === "none") {
     
    258274        }
    259275        if (this.settings.hide) {
    260             f = this.$subject.closest('.tpfw_form_row');
     276            f = this.$subject.closest('.tpfw_form_row,.customize-control');
    261277            f.hide();
    262278        }
     
    277293    };
    278294    b.prototype.check = function (h) {
     295
    279296        var g = this.dependencySets.length,
    280297                f = 0,
    281298                e = false;
    282299        for (f; f < g; f += 1) {
     300
    283301            if (this.dependencySets[f].doesQualify()) {
    284302                e = true;
     
    286304            }
    287305        }
     306
    288307        if (e) {
    289308            this.enable(h)
  • tp-framework/trunk/assets/vendors/dependency/dependency.min.js

    r1778449 r1818773  
    1 !function(e){var t=function(t,s){this.selector=t,this.$dependencyObj=e(t),this.qualifiers=s};t.prototype.enabled=function(t){if(e(this.selector+"[disabled]").length>0){if(t)return!1}else if(!t)return!1;return!0},t.prototype.checked=function(e){return"checkbox"!==this.$dependencyObj.attr("type")||!(!this.$dependencyObj.is(":checked")&&e||this.$dependencyObj.is(":checked")&&!e)},t.prototype.values=function(e){var t=this.$dependencyObj.val(),s=!1;"checkbox"==this.$dependencyObj.attr("type")?t=this.$dependencyObj.is(":checked")?1:0:"checkbox"==this.$dependencyObj.data("type")&&"string"==typeof t&&""!=t&&(t=t.split(",")),"radio"===this.$dependencyObj.attr("type")&&(t=this.$dependencyObj.filter(":checked").val()),"string"!=typeof e&&"number"!=typeof e||(e=[e]);for(var n=0;n<e.length;n++)if("array"==typeof t||"object"==typeof t){if(t.indexOf(e[n])>=0){s=!0;break}}else if(e[n]==t){s=!0;break}return s},t.prototype.not=function(e){var t=this.$dependencyObj.val(),s=e.length,n=0;for(n;n<s;n+=1)if(e[n]===t)return!1;return!0},t.prototype.match=function(e){var t=this.$dependencyObj.val();return e.test(t)},t.prototype.contains=function(t){var s=this.$dependencyObj.val(),n=0;if("array"!=typeof s&&"object"!=typeof s)return this.values(t);for(n in t)if(-1!==e.inArray(t[n],s))return!0;return!1},t.prototype.email=function(e){var t=/^[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/;return this.match(t)===e},t.prototype.url=function(e){var t=/(((http|ftp|https):\/\/)|www\.)[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?\^=%&:\/~\+#!]*[\w\-\@?\^=%&\/~\+#])?/g;return this.match(t)===e},t.prototype.doesQualify=function(){var e=0;for(e in this.qualifiers)if(t.prototype.hasOwnProperty(e)&&"function"==typeof t.prototype[e]){if(!this[e](this.qualifiers[e]))return!1}else if(this.qualifiers[e],!0)return this.qualifiers[e](this.$dependencyObj.val());return!0};var s=function(e){var s=0;this.dependencies=[];for(s in e)this.dependencies.push(new t(s,e[s]))};s.prototype.doesQualify=function(){var e=this.dependencies.length,t=0,s=!0;for(t;t<e;t+=1)if(!this.dependencies[t].doesQualify()){s=!1;break}return s};var n=function(t,s,n){this.dependencySets=[],this.$subject=t,this.settings=e.extend({dependsOnisable:!1,hide:!0,dependsOnuration:200,onEnable:function(){},onDisable:function(){}},n),this.enableCallback=function(){},this.disableCallback=function(){},this.init(s)};n.prototype.init=function(e){this.addSet(e),this.check(!0)},n.prototype.addSet=function(e){var t,n=this,i=0,a=0,r=0;for(this.dependencySets.push(new s(e)),i=this.dependencySets.length-1,a=this.dependencySets[i].dependencies.length,r;r<a;r+=1)(t=this.dependencySets[i].dependencies[r]).$dependencyObj.on("change",function(){n.check()}),"text"===t.$dependencyObj.attr("type")&&t.$dependencyObj.on("keypress",function(e){e.which&&t.$dependencyObj.is(":focus")&&n.check()})},n.prototype.or=function(e){return this.addSet(e),this.check(!1),this},n.prototype.enable=function(){var t,s=this.$subject;this.$subject.attr("id");this.settings.hasOwnProperty("valueTarget")&&void 0!==this.settings.valueTarget?s=e(this.settings.valueTarget):"input"!==this.$subject[0].nodeName.toLowerCase()&&"textarea"!==this.$subject[0].nodeName.toLowerCase()&&"select"!==this.$subject[0].nodeName.toLowerCase()&&(s=this.$subject.find("input, textarea, select")),this.settings.disable&&this.$subject.removeAttr("disabled"),this.settings.hide&&"none"===(t=this.$subject.closest(".tpfw_form_row")).css("display")&&t.show(),this.settings.hasOwnProperty("valueOnEnable")&&void 0!==this.settings.valueOnEnable&&s.val(this.settings.valueOnEnable),this.settings.hasOwnProperty("checkOnEnable")&&(this.settings.checkOnEnable?s.attr("checked","checked"):s.removeAttr("checked")),this.settings.hasOwnProperty("toggleClass")&&void 0!==this.settings.toggleClass&&this.$subject.addClass(this.settings.toggleClass),this.settings.onEnable()},n.prototype.disable=function(){var t=this.$subject;this.$subject.attr("id");this.settings.hasOwnProperty("valueTarget")&&void 0!==this.settings.valueTarget?t=e(this.settings.valueTarget):"input"!==this.$subject[0].nodeName.toLowerCase()&&"textarea"!==this.$subject[0].nodeName.toLowerCase()&&"select"!==this.$subject[0].nodeName.toLowerCase()&&(t=this.$subject.find("input, textarea, select")),this.settings.disable&&this.$subject.attr("disabled","disabled"),this.settings.hide&&this.$subject.closest(".tpfw_form_row").hide(),this.settings.hasOwnProperty("valueOnDisable")&&void 0!==this.settings.valueOnDisable&&t.val(this.settings.valueOnDisable),this.settings.hasOwnProperty("checkOnDisable")&&(this.settings.checkOnDisable?t.attr("checked","checked"):t.removeAttr("checked")),this.settings.hasOwnProperty("toggleClass")&&void 0!==this.settings.toggleClass&&this.$subject.removeClass(this.settings.toggleClass),this.settings.onDisable()},n.prototype.check=function(e){var t=this.dependencySets.length,s=0,n=!1;for(s;s<t;s+=1)if(this.dependencySets[s].doesQualify()){n=!0;break}n?this.enable(e):this.disable(e)},e.fn.dependsOn=function(e,t){return new n(this,e,t)}}(jQuery);
     1!function(e){var t=function(t,s){this.selector=t,this.$dependencyObj=e(t),this.qualifiers=s};t.prototype.enabled=function(t){if(e(this.selector+"[disabled]").length>0){if(t)return!1}else if(!t)return!1;return!0},t.prototype.checked=function(e){return"checkbox"!==this.$dependencyObj.attr("type")||!(!this.$dependencyObj.is(":checked")&&e||this.$dependencyObj.is(":checked")&&!e)},t.prototype.values=function(e){var t=this.$dependencyObj.val(),s=!1;"checkbox"==this.$dependencyObj.attr("type")?t=this.$dependencyObj.is(":checked")?1:0:"checkbox"==this.$dependencyObj.data("type")&&"string"==typeof t?""!=t&&(t=t.split(",")):"radio"===this.$dependencyObj.attr("type")&&(t=this.$dependencyObj.filter(":checked").val()),"string"!=typeof e&&"number"!=typeof e||(e=[e]);for(var n=0;n<e.length;n++)if("object"==typeof t){if(t.indexOf(e[n])>=0){s=!0;break}}else if(e[n]==t){s=!0;break}return s},t.prototype.not=function(e){for(var t=this.$dependencyObj.val(),s=e.length,n=0;n<s;n+=1)if(e[n]===t)return!1;return!0},t.prototype.match=function(e){var t=this.$dependencyObj.val();return e.test(t)},t.prototype.contains=function(t){var s=this.$dependencyObj.val(),n=0;if("array"!=typeof s&&"object"!=typeof s)return this.values(t);for(n in t)if(-1!==e.inArray(t[n],s))return!0;return!1},t.prototype.email=function(e){return this.match(/^[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/)===e},t.prototype.url=function(e){return this.match(/(((http|ftp|https):\/\/)|www\.)[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?\^=%&:\/~\+#!]*[\w\-\@?\^=%&\/~\+#])?/g)===e},t.prototype.doesQualify=function(){var e=0;for(e in this.qualifiers){if(!t.prototype.hasOwnProperty(e)||"function"!=typeof t.prototype[e])return this.qualifiers[e],this.qualifiers[e](this.$dependencyObj.val());if(!this[e](this.qualifiers[e]))return!1}return!0};var s=function(e){var s=0;this.dependencies=[];for(s in e)this.dependencies.push(new t(s,e[s]))};s.prototype.doesQualify=function(){for(var e=this.dependencies.length,t=0,s=!0;t<e;t+=1)if(!this.dependencies[t].doesQualify()){s=!1;break}return s};var n=function(t,s,n){this.dependencySets=[],this.$subject=t,this.settings=e.extend({dependsOnisable:!1,hide:!0,dependsOnuration:200,onEnable:function(){},onDisable:function(){}},n),this.enableCallback=function(){},this.disableCallback=function(){},this.init(s)};n.prototype.init=function(e){this.addSet(e),this.check(!0)},n.prototype.addSet=function(e){var t,n,i,o=this,r=0;for(this.dependencySets.push(new s(e)),t=this.dependencySets.length-1,n=this.dependencySets[t].dependencies.length;r<n;r+=1)(i=this.dependencySets[t].dependencies[r]).$dependencyObj.on("change",function(e){o.check()}),"text"===i.$dependencyObj.attr("type")&&i.$dependencyObj.on("keypress",function(e){e.which&&i.$dependencyObj.is(":focus")&&o.check()})},n.prototype.or=function(e){return this.addSet(e),this.check(!1),this},n.prototype.enable=function(t){var s,n=this.$subject;this.$subject.attr("id");this.settings.hasOwnProperty("valueTarget")&&void 0!==this.settings.valueTarget?n=e(this.settings.valueTarget):"input"!==this.$subject[0].nodeName.toLowerCase()&&"textarea"!==this.$subject[0].nodeName.toLowerCase()&&"select"!==this.$subject[0].nodeName.toLowerCase()&&(n=this.$subject.find("input, textarea, select")),this.settings.disable&&this.$subject.removeAttr("disabled"),this.settings.hide&&"none"===(s=this.$subject.closest(".tpfw_form_row,.customize-control")).css("display")&&s.show(),this.settings.hasOwnProperty("valueOnEnable")&&void 0!==this.settings.valueOnEnable&&n.val(this.settings.valueOnEnable),this.settings.hasOwnProperty("checkOnEnable")&&(this.settings.checkOnEnable?n.attr("checked","checked"):n.removeAttr("checked")),this.settings.hasOwnProperty("toggleClass")&&void 0!==this.settings.toggleClass&&this.$subject.addClass(this.settings.toggleClass),this.settings.onEnable()},n.prototype.disable=function(t){var s=this.$subject;this.$subject.attr("id");this.settings.hasOwnProperty("valueTarget")&&void 0!==this.settings.valueTarget?s=e(this.settings.valueTarget):"input"!==this.$subject[0].nodeName.toLowerCase()&&"textarea"!==this.$subject[0].nodeName.toLowerCase()&&"select"!==this.$subject[0].nodeName.toLowerCase()&&(s=this.$subject.find("input, textarea, select")),this.settings.disable&&this.$subject.attr("disabled","disabled"),this.settings.hide&&this.$subject.closest(".tpfw_form_row,.customize-control").hide(),this.settings.hasOwnProperty("valueOnDisable")&&void 0!==this.settings.valueOnDisable&&s.val(this.settings.valueOnDisable),this.settings.hasOwnProperty("checkOnDisable")&&(this.settings.checkOnDisable?s.attr("checked","checked"):s.removeAttr("checked")),this.settings.hasOwnProperty("toggleClass")&&void 0!==this.settings.toggleClass&&this.$subject.removeClass(this.settings.toggleClass),this.settings.onDisable()},n.prototype.check=function(e){for(var t=this.dependencySets.length,s=0,n=!1;s<t;s+=1)if(this.dependencySets[s].doesQualify()){n=!0;break}n?this.enable(e):this.disable(e)},e.fn.dependsOn=function(e,t){return new n(this,e,t)}}(jQuery);
  • tp-framework/trunk/includes/class-tpfw-customizer.php

    r1675334 r1818773  
    4444                global $tpfw_customizer_dependency;
    4545
    46                 $key = key( $args['dependency'] );
    47 
    48                 if ( !isset( $tpfw_customizer_dependency[$key] ) ) {
    49                     $tpfw_customizer_dependency[$key] = array();
    50                    
    51                     $master = $wp_customize->get_control($key);
    52                     $multiple = !empty( $master->multiple) ? '_multiple' : '';
    53                     $tpfw_customizer_dependency[$key]['type'] = $master->type . $multiple;
     46                if ( !isset( $tpfw_customizer_dependency[$args['name']] ) ) {
     47                    $tpfw_customizer_dependency[$args['name']] = array();
    5448                }
    5549
    56                 $tpfw_customizer_dependency[$key]['elements'][$args['name']] = $args['dependency'][$key];
     50                $tpfw_customizer_dependency[$args['name']] = $args['dependency'];
    5751            }
    5852        }
     
    289283
    290284if ( !class_exists( 'Tpfw_Customize_Panel' ) ) {
    291    
     285
    292286    /**
    293287     * Tpfw_Customize_Panel Class
     
    347341         * Add section
    348342         *
    349          * @param Tpfw_Customize_Section|array $section Section Class or array settings
     343         * @param Tpfw_Customize_Section|array $args Section Class or array settings
    350344         */
    351345        public function add_section( $args = array() ) {
  • tp-framework/trunk/readme.txt

    r1809087 r1818773  
    55Requires at least: 4.5   
    66Tested up to: 4.9
    7 Stable tag: 1.0.12
     7Stable tag: 1.0.13
    88License: GPLv3   
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html   
     
    8383== Changelog ==
    8484
     85= 1.0.13 (February 31, 2018): =
     86* Fix metabox in front_page, posts_page cannot saved
     87* Improve dependency in customizer
     88
    8589= 1.0.12 (January 25, 2018): =
    8690* Fix metabox in front_page, posts_page cannot saved
  • tp-framework/trunk/tp-framework.php

    r1809087 r1818773  
    66  Description: Create Admin fields, metabox, widget, taxonomy, menu meta, customizer fields quickly and friendly.
    77  Author: themespond
    8   Version: 1.0.12
     8  Version: 1.0.13
    99  Author URI: https://themespond.com
    1010  Text Domain: tp-framework
     
    2222     * @var string
    2323     */
    24     public $version = '1.0.12';
     24    public $version = '1.0.13';
    2525
    2626    /**
     
    6868
    6969        add_action( 'plugins_loaded', array( $this, 'load_plugin_textdomain' ) );
    70 
    7170        add_action( 'customize_register', array( $this, 'customize_fields' ) );
    7271        add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_scripts' ) );
     
    319318                        wp_enqueue_style( 'wp-color-picker' );
    320319                        break;
    321                     case 'image_picker';
    322                     case 'upload';
     320                    case 'image_picker':
     321                    case 'upload':
    323322                        $localize['upload_invalid_mime'] = esc_html__( 'The selected file has an invalid mimetype in this field.', 'tp-framework' );
    324323                        wp_enqueue_media();
Note: See TracChangeset for help on using the changeset viewer.