Plugin Directory

Changeset 1302055

Timestamp:
12/07/2015 10:40:32 AM (9 years ago)
Author:
jadpm
Message:

Fixes for the 1.8.11 release:

  • Add 'action' and other words to the list of reserved ones in Types.
  • Fix the menu management for WordPress 4.4 related to post type archives.
  • Fix fields translation management with WPML: field values are never translated. ALso, fix checking whether a field is set to be copied or not from the original language.
Location:
types/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • types/trunk/embedded/classes/class.wpcf-post-types.php

    r1187593 r1302055  
    2929    {
    3030        add_action('admin_init', array($this, 'admin_init'));
    31         add_action('admin_head-nav-menus.php', array($this, 'add_filters'));
    32         add_filter('wp_setup_nav_menu_item',  array( $this, 'setup_archive_item'));
    33         add_filter('wp_nav_menu_objects', array( $this, 'maybe_make_current'));
     31        global $wp_version;
     32        if ( version_compare( $wp_version, '4.4' ) < 0 ) {
     33            add_action('admin_head-nav-menus.php', array($this, 'add_filters'));
     34            add_filter('wp_setup_nav_menu_item',  array( $this, 'setup_archive_item'));
     35            add_filter('wp_nav_menu_objects', array( $this, 'maybe_make_current'));
     36        }
    3437    }
    3538    /**
     
    320323    public function add_archive_checkbox( $posts, $args, $post_type )
    321324    {
     325
     326
     327
     328
     329
     330
     331
     332
    322333        global $_nav_menu_placeholder, $wp_rewrite;
    323334        $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
     
    326337            'ID' => 0,
    327338            'object_id' => $_nav_menu_placeholder,
    328             'post_title' => $post_type['args']->labels->all_items,
     339            'post_title' => $post_type->labels->all_items,
    329340            'post_type' => 'nav_menu_item',
    330341            'post_excerpt' => '',
    331342            'post_content' => '',
    332343            'type' => 'post_type_archive',
    333             'object' => $post_type['args']->slug,
     344            'object' => $post_type->slug,
    334345        ) );
    335346
  • types/trunk/embedded/frontend.php

    r1222646 r1302055  
    245245        $params['field_value'] = addslashes( stripslashes( strval( $params['field_value'] ) ) );
    246246    }
    247 
    248     // Set values
    249     if ( is_array( $params['field_value'] ) ) {
    250         foreach ( $params['field_value'] as $f_key => $f_value ) {
    251             if ((isset($field['data']['repetitive'])) && ($field['data']['repetitive'])) {
    252                 //Repetitive fields, used meta ID for proper string translation unique identification
    253                 $params['field_value'] = wpcf_translate( 'field ' . $field['id'] . ' value '.$meta_id, $params['field_value'] );
    254             } else {
    255                 //Non-repetitive fields, use post ID
    256                 $params['field_value'] = wpcf_translate( 'field ' . $field['id'] . ' value '.$post->ID, $params['field_value'] );
    257             }
    258         }
    259     } else {
    260         if ((isset($field['data']['repetitive'])) && ($field['data']['repetitive'])) {
    261 
    262             //Repetitive fields, used meta ID for proper string translation unique identification
    263             $params['field_value'] = wpcf_translate( 'field ' . $field['id'] . ' value '.$meta_id, $params['field_value'] );
    264 
    265         } else {
    266             //Non-repetitive fields, use post ID
    267             $params['field_value'] = wpcf_translate( 'field ' . $field['id'] . ' value '.$post->ID, $params['field_value'] );
    268         }
    269     }
     247   
     248    // Note that $params['field_value'] does NOT need translating
     249    // When a variable string or label output needs translating we do it on 'wpcf_fields_type_' . $field['type'] . '_value_display' on a field type basis
    270250
    271251    $field['name'] = wpcf_translate( 'field ' . $field['id'] . ' name', $field['name'] );
  • types/trunk/embedded/includes/fields/checkbox.php

    r1181030 r1302055  
    2828 *
    2929 * @param type $field
     30
     31
    3032 */
    3133function wpcf_fields_checkbox_meta_box_form($field, $field_object)
     
    195197        // Show the translated value if we have one.
    196198        $field = wpcf_fields_get_field_by_slug( $params['field']['slug'], $option_name );
     199
     200
     201
    197202        $output = wpcf_translate( 'field ' . $field['id'] . ' checkbox value', $output );
    198203    } elseif ( $params['field']['data']['display'] == 'value'
     
    200205        if ( !empty( $params['field']['data']['display_value_selected'] ) ) {
    201206            $output = $params['field']['data']['display_value_selected'];
     207
     208
     209
    202210            $output = wpcf_translate( 'field ' . $params['field']['id'] . ' checkbox value selected',
    203211                    $output );
     
    206214        && !empty( $params['field']['data']['display_value_not_selected'] ) ) {
    207215        $output = $params['field']['data']['display_value_not_selected'];
     216
     217
     218
    208219        $output = wpcf_translate( 'field ' . $params['field']['id'] . ' checkbox value not selected', $output );
    209220    } else {
  • types/trunk/embedded/includes/fields/checkboxes.php

    r1181030 r1302055  
    2727 *
    2828 * @param type $field
     29
     30
    2931 */
    3032function wpcf_fields_checkboxes_meta_box_form( $field, $field_object ) {
     
    186188                    && !empty( $option['set_value'] ) && !empty( $value ) ) {
    187189                $value = $option['set_value'];
     190
     191
     192
    188193                $value = wpcf_translate( 'field ' . $params['field']['id'] . ' option ' . $name . ' value',
    189194                        $value );
     
    191196                if ( isset( $option['display_value_selected'] ) && !empty( $value ) ) {
    192197                    $value = $option['display_value_selected'];
     198
     199
     200
    193201                    $value = wpcf_translate( 'field ' . $params['field']['id'] . ' option ' . $name . ' display value selected',
    194202                            $value );
    195203                } else {
    196204                    $value = $option['display_value_not_selected'];
     205
     206
     207
    197208                    $value = wpcf_translate( 'field ' . $params['field']['id'] . ' option ' . $name . ' display value not selected',
    198209                            $value );
     
    261272                && $option['value'] != '__wpcf_unchecked' ) {
    262273            $output = $option['data']['set_value'];
     274
     275
     276
    263277            $output = wpcf_translate( 'field ' . $params['field']['id']
    264278                    . ' option ' . $option['key'] . ' value', $output );
     
    272286            if ( isset( $option['data']['display_value_selected'] ) ) {
    273287                $output = $option['data']['display_value_selected'];
     288
     289
     290
    274291                $output = wpcf_translate( 'field ' . $params['field']['id'] . ' option ' . $option['key'] . ' display value selected',
    275292                        $output );
     
    282299        } else if ( isset( $option['data']['display_value_not_selected'] ) ) {
    283300            $output = $option['data']['display_value_not_selected'];
     301
     302
     303
    284304            $output = wpcf_translate( 'field ' . $params['field']['id'] . ' option ' . $option['key'] . ' display value not selected',
    285305                    $output );
  • types/trunk/embedded/includes/fields/radio.php

    r1181030 r1302055  
    1919 *
    2020 * @param type $field
     21
     22
    2123 */
    2224function wpcf_fields_radio_meta_box_form( $field ) {
     
    163165            if ( isset( $option['value'] )
    164166                    && stripslashes( $option['value'] )  == stripslashes( $params['field_value'] ) ) {
    165                 $field_value = wpcf_translate( 'field ' . $params['field']['id'] . ' option '
    166                         . $option_key . ' title', $option['title'] );
     167                // We need to translate here because the stored value is on the original language
     168                // When updaing the value in the Field group, we might have problems
     169                // @wpmlhere
     170                $field_value = wpcf_translate( 'field ' . $params['field']['id'] . ' option ' . $option_key . ' title', $option['title'] );
     171                //$field_value = $option['title'];
    167172                if ( isset( $params['field']['data']['display'] )
    168173                        && $params['field']['data']['display'] != 'db'
    169174                        && !empty( $option['display_value'] ) ) {
    170                     $field_value = wpcf_translate( 'field ' . $params['field']['id'] . ' option '
    171                             . $option_key . ' display value',
    172                             $option['display_value'] );
     175                    // We need to translate here because the stored value is on the original language
     176                    // When updaing the value in the Field group, we might have problems
     177                    // @wpmlhere
     178                    $field_value = wpcf_translate( 'field ' . $params['field']['id'] . ' option ' . $option_key . ' display value', $option['display_value'] );
     179                    //$field_value = $option['display_value'];
    173180                }
    174181            }
  • types/trunk/embedded/includes/fields/select.php

    r762199 r1302055  
    1818 *
    1919 * @param type $field
     20
     21
    2022 */
    2123function wpcf_fields_select_meta_box_form($field) {
     
    7476            if (isset($option['value'])
    7577                    && $option['value'] == $params['field_value']) {
    76                 $field_value = wpcf_translate('field ' . $params['field']['id'] . ' option '
    77                         . $option_key . ' title', $option['title']);
     78                // We need to translate here because the stored value is on the original language
     79                // When updaing the value in the Field group, we might have problems
     80                // @wpmlhere
     81                $field_value = wpcf_translate('field ' . $params['field']['id'] . ' option ' . $option_key . ' title', $option['title']);
     82                //$field_value = $option['title'];
    7883            }
    7984        }
  • types/trunk/embedded/includes/wpml.php

    r1269117 r1302055  
    10291029function wpcf_wpml_field_is_copy( $field ) {
    10301030    if ( !defined( 'WPML_TM_VERSION' ) ) return false;
    1031     return isset( $field['wpml_action'] ) && $field['wpml_action'] === 1;
     1031    return isset( $field['wpml_action'] ) && === 1;
    10321032}
    10331033
     
    10401040function wpcf_wpml_field_is_translated( $field ) {
    10411041    if ( !defined( 'WPML_TM_VERSION' ) ) return false;
    1042     return isset( $field['wpml_action'] ) && $field['wpml_action'] === 2;
     1042    return isset( $field['wpml_action'] ) && === 2;
    10431043}
    10441044
  • types/trunk/wpcf.php

    r1302047 r1302055  
    231231{
    232232    $reserved = array(
     233
    233234        'attachment',
    234235        'attachment_id',
     
    240241        'category__and',
    241242        'category__in',
     243
    242244        'category__not_in',
    243         'category_name',
    244245        'comments_per_page',
    245246        'comments_popup',
     
    254255        'format',
    255256        'hour',
     257
    256258        'link_category',
    257259        'm',
    258260        'minute',
     261
    259262        'monthnum',
    260         'mode',
    261263        'more',
    262264        'name',
     
    275277        'perm',
    276278        'post',
     279
    277280        'post__in',
     281
    278282        'post__not_in',
    279         'post_format',
    280         'post_mime_type',
     283        'posts',
     284        'posts_per_archive_page',
     285        'posts_per_page',
    281286        'post_status',
    282287        'post_tag',
    283288        'post_type',
    284         'posts',
    285         'posts_per_archive_page',
    286         'posts_per_page',
    287289        'preview',
    288290        'robots',
     
    297299        'tag',
    298300        'tag__and',
     301
    299302        'tag__in',
    300303        'tag__not_in',
    301         'tag_id',
    302304        'tag_slug__and',
    303305        'tag_slug__in',
     
    310312        'withoutcomments',
    311313        'year',
    312         'lang',
    313 //        'comments',
    314 //        'blog',
    315 //        'files'
    316314    );
    317315
Note: See TracChangeset for help on using the changeset viewer.