WordPress.org

Plugin Directory

Changeset 740248


Ignore:
Timestamp:
07/13/13 10:30:44 (9 months ago)
Author:
eskapism
Message:

version 1.4

Location:
simple-fields
Files:
4 edited
29 copied

Legend:

Unmodified
Added
Removed
  • simple-fields/tags/1.4/inc-admin-options-manage.php

    r707484 r740248  
    55 */ 
    66if ("edit-post-type-defaults" == $action) { 
     7 
     8    global $wp_post_types; 
    79    $post_type = $_GET["post-type"]; 
    8     global $wp_post_types; 
    9     if (isset($wp_post_types[$post_type])) { 
     10 
     11    if ( isset($wp_post_types[$post_type]) ) { 
     12         
    1013        $selected_post_type = $wp_post_types[$post_type]; 
    1114        ?> 
     
    453456if ( ! $action ) { 
    454457 
    455  
    456458    do_action("simple_fields_options_print_nav_tabs", $subpage); 
    457459 
     
    465467        } 
    466468    } 
    467  
    468469 
    469470    /** 
     
    527528                            echo "<tr class='$row_class'>"; 
    528529                            echo "<td>"; 
    529                             echo "<a href='$editlink'><strong>" . esc_html( $oneFieldGroup["name"] ) . "</strong></a>"; 
     530                            echo "<a href='$editlink'><strong>" . esc_html( $this->get_string( "Field group name, " . $oneFieldGroup["slug"], $oneFieldGroup["name"] ) ) . "</strong></a>"; 
    530531                             
    531532                            ?><div class="row-actions"> 
     
    613614                    <tr class='<?php echo $row_class ?>'> 
    614615                        <td> 
    615                             <a href="<?php echo $edit_url ?>"><strong><?php echo esc_html( $one_post_connector["name"] ) ?></strong></a> 
     616                            <a href="<?php echo $edit_url ?>"><strong><?php echo esc_html( $this->get_string( "Post connector name, " . $one_post_connector["slug"], $one_post_connector["name"]) ) ?></strong></a> 
    616617                            <div class="row-actions"> 
    617618                                <span class="edit"><a href="<?php echo $edit_url ?>" title="<?php _e("Edit this item") ?>"><?php _e("Edit") ?></a></span> 
  • simple-fields/tags/1.4/readme.txt

    r728801 r740248  
    55Requires at least: 3.5.1 
    66Tested up to: 3.5.1 
    7 Stable tag: 1.3.3 
     7Stable tag: 1.4 
    88 
    99With Simple Fields you can add any kind of custom fields to your pages, posts and attachments. 
     
    144144 
    145145== Changelog == 
     146 
     147#### Version 1.4 
     148 
     149- Added support for [WPML](http://wpml.org/). Now the names and descriptions of field groups, their fields, and post connectors, and values of drop downs and radiobuttons can be translated using WPML. 
     150- Added a little teaser about [WordPress Web Agency Earth People](http://earthpeople.se/?utm_source=wordpress&utm_medium=readme&utm_campaign=simplefields), the company I work for. If you need any professional help with for example Simple Fields or WordPress in general then we might be the ones to talk to :) 
    146151 
    147152#### Version 1.3.4 
  • simple-fields/tags/1.4/simple_fields.php

    r728801 r740248  
    44Plugin URI: http://simple-fields.com 
    55Description: Add groups of textareas, input-fields, dropdowns, radiobuttons, checkboxes and files to your edit post screen. 
    6 Version: 1.3.4 
     6Version: 1.4 
    77Author: Pär Thernström 
    88Author URI: http://eskapism.se/ 
     
    4646    ; 
    4747 
     48    private 
     49 
     50        $wpml_context = "Simple Fields"; 
     51 
    4852 
    4953    /** 
     
    5357    function init() { 
    5458 
    55         define( "SIMPLE_FIELDS_VERSION", "1.3.4"); 
     59 
     60        define( "SIMPLE_FIELDS_VERSION", "1.4"); 
    5661        define( "SIMPLE_FIELDS_URL", plugins_url(basename(dirname(__FILE__))). "/"); 
    5762        define( "SIMPLE_FIELDS_NAME", "Simple Fields"); 
     
    121126 
    122127        // Options page 
     128        add_action("simple_fields_options_print_nav_tabs", array($this, "promote_ep_on_nav_tabs")); 
    123129        add_action("simple_fields_options_print_nav_tabs", array($this, "get_options_nav_tabs")); 
    124130 
     
    134140        */ 
    135141 
     142        // Setup things for WPML-support 
     143        add_action("init", array($this, "setup_wpml_support")); 
     144 
    136145        // Boot up 
    137146        do_action("simple_fields_init", $this); 
    138147 
    139148    } 
     149 
     150    /** 
     151     * Init support for WPML translations 
     152     */ 
     153    function setup_wpml_support() { 
     154 
     155        // If wpml is not active then don't do anything 
     156        if ( ! $this->is_wpml_active()) return; 
     157 
     158        // http://wpml.org/documentation/support/translation-for-texts-by-other-plugins-and-themes/ 
     159 
     160        // 1. Register the strings that need translation 
     161        // icl_register_string($context, $name, $value) 
     162        // run on settings screen, go through all fields and register string 
     163        add_action("simple_fields_settings_admin_head", array($this, "register_wpml_strings")); 
     164 
     165        // 2. Using the translation when displaying 
     166        // icl_t($context, $name, $value) 
     167 
     168    } 
     169 
     170 
     171 
     172    /** 
     173     * Make sure a field group has the correct format 
     174     * It can be wrong because prior to version ?.? the options 
     175     * for a field was not stored in the options array. but nowadays we 
     176     * assume it is. so..if it's not: fix that! 
     177     * 
     178     * @param array $fieldgroup Field group to normalize 
     179     * @return array $fieldgroup Normalized/fixed field group 
     180     */ 
     181    function normalize_fieldgroups( $field_groups ) { 
     182     
     183        // wierd, but i moved to code so this is the way it is..  
     184        foreach ( $field_groups as & $fieldgroup_by_reference ) { 
     185 
     186            // If field was not added with code then move all options to the options-array 
     187            if ( ! isset($fieldgroup_by_reference["added_with_code"]) || false === $fieldgroup_by_reference["added_with_code"] ) { 
     188             
     189                foreach ($fieldgroup_by_reference["fields"] as & $field_by_reference) { 
     190 
     191                    #if ( "drps" === $field_by_reference["slug"] ) { 
     192                         
     193                        // make sure field has an options-key that is an array 
     194                        if ( ! isset( $field_by_reference["options"] ) || ! is_array( $field_by_reference["options"] ) ) $field_by_reference["options"] = array(); 
     195 
     196                        foreach ( $field_by_reference as $field_key => $field_vals ) { 
     197                             
     198                            // if field has key with name 
     199                            // type_<textarea|post|taxonyterm|dropdown|whatever>_options 
     200                            // then move that info to the field[options]-array 
     201                            if ( 1 === preg_match('/type_([a-z]+)/', $field_key, $field_key_matches) ) { 
     202                                 
     203                                // $field_key_matches[1] = field type 
     204                                $field_key_type = $field_key_matches[1]; 
     205 
     206                                // make sure field type is key in options array 
     207                                if ( ! isset( $field_by_reference["options"][ $field_key_type ] ) || ! is_array( $field_by_reference["options"][ $field_key_type ] ) ) $field_by_reference["options"][ $field_key_type ] = array(); 
     208                                 
     209                                // move keys to options array 
     210                                // keys with name dropdown_num_, checkbox_num_, radiobutton_num_ need special treatment 
     211                                $values = array(); 
     212                                $values_index = 0; 
     213 
     214                                // check if checked by default exists 
     215                                $checked_by_default_num = false; 
     216                                if ( isset( $field_vals["checked_by_default_num"] ) ) { 
     217                                    $checked_by_default_num = $field_vals["checked_by_default_num"]; 
     218                                    if ( 1 === preg_match('/_num_([\d]+)/', $checked_by_default_num, $checked_num_matches ) ) { 
     219                                        $checked_by_default_num = (int) $checked_num_matches[1]; 
     220                                    } 
     221                                } 
     222 
     223                                foreach ( $field_vals as $field_vals_key => $field_vals_val ) { 
     224                                     
     225                                    if ( 1 === preg_match('/([a-z]+)_num_(\d+)/i', $field_vals_key, $matches) ) { 
     226 
     227                                        // $matches[1] = field type 
     228                                        // $matches[2] = field type num 
     229                                        #sf_d($field_vals_key, '$field_vals_key'); 
     230                                        #sf_d($field_vals_val, '$field_vals_val'); 
     231 
     232                                        $values[ $values_index ] = $field_vals_val; 
     233                                        $values[ $values_index ]["num"] = (int) $matches[2]; 
     234                                         
     235                                        if ( false !== $checked_by_default_num && $checked_by_default_num === $values[ $values_index ]["num"] ) { 
     236                                            $values[ $values_index ]["checked"] = true; 
     237                                            $field_by_reference["options"][ $field_key_type ]["checked_by_default_num"] = $field_key_type . "_num_" . $checked_by_default_num; 
     238                                        } 
     239 
     240                                        $values_index++; 
     241 
     242                                    } else { 
     243 
     244                                        // "regular" option key key 
     245                                        $field_by_reference["options"][ $field_key_type ][ $field_vals_key ] = $field_vals_val; 
     246                                         
     247                                    } 
     248 
     249                                    if ($values) { 
     250                                     
     251                                        $field_by_reference["options"][ $field_key_type ]["values"] = $values; 
     252                                     
     253                                    } 
     254 
     255                                     
     256                                } // foreach field vals 
     257                                 
     258                            } // if type_ 
     259 
     260                            // sf_d($field); 
     261 
     262                        } // foreach field key 
     263 
     264 
     265                    #} 
     266 
     267                } // foreach field 
     268 
     269 
     270            } // if not added with code 
     271 
     272        } 
     273 
     274        return $field_groups; 
     275 
     276    } // func 
     277 
     278    /** 
     279     * Register strings so they are translateable with WPML 
     280     */ 
     281    function register_wpml_strings() { 
     282         
     283        // Get all fieldgroups and fields 
     284        $field_groups = $this->get_field_groups(); 
     285 
     286        foreach ($field_groups as & $fieldgroup_by_reference) { 
     287                         
     288            // register name and description of each field group 
     289            icl_register_string($this->wpml_context, "Field group name, " . $fieldgroup_by_reference["slug"], $fieldgroup_by_reference["name"]); 
     290            icl_register_string($this->wpml_context, "Field group description, " . $fieldgroup_by_reference["slug"], $fieldgroup_by_reference["description"]); 
     291 
     292            // register name for each field 
     293            foreach ($fieldgroup_by_reference["fields"] as $field) { 
     294 
     295                icl_register_string($this->wpml_context, "Field name, " . $field["slug"], $field["name"]); 
     296                icl_register_string($this->wpml_context, "Field description, " . $field["slug"], $field["description"]); 
     297 
     298                // register names for dropdowns and radiobuttons 
     299                // several fields can have the same slug, if they are in different field groups 
     300                // how to solve that?  
     301                //  - can't prefix with field group, because they can be in several of those 
     302                //  - can't prefix with id because can be different between dev/prod/live-servers 
     303                // to much to worry about here, let's go with just the slug and then it's up to the 
     304                // user to not use a slug more than once. 
     305                if ( isset( $field["options"] ) && is_array( $field["options"] ) ) { 
     306 
     307                    if ( isset( $field["options"]["radiobuttons"]["values"] ) && is_array( $field["options"]["radiobuttons"]["values"] ) ) { 
     308     
     309                        foreach ( $field["options"]["radiobuttons"]["values"] as $one_radio_option_key => $one_radio_option_val) { 
     310                             
     311                            $string_name = "Field radiobuttons value, " . $field["slug"] . " " . "radiobutton_num_" . $one_radio_option_val["num"]; 
     312                            // sf_d($this->wpml_context);sf_d($string_name);sf_d($one_radio_option_val["value"]); 
     313                            icl_register_string($this->wpml_context, $string_name, $one_radio_option_val["value"]); 
     314 
     315                        } // foreach 
     316 
     317                    } // if radiobuttons 
     318                    if ( isset( $field["options"]["dropdown"]["values"] ) && is_array( $field["options"]["dropdown"]["values"] ) ) { 
     319     
     320                        foreach ( $field["options"]["dropdown"]["values"] as $one_dropdown_val) { 
     321                             
     322                            $string_name = "Field dropdown value, " . $field["slug"] . " " . "dropdown_num_" . $one_dropdown_val["num"]; 
     323                            // sf_d($string_name); 
     324                            icl_register_string($this->wpml_context, $string_name, $one_dropdown_val["value"]); 
     325 
     326                        } // foreach 
     327 
     328                    } // if dropdowns 
     329                 
     330                } // if options 
     331/* 
     332// @todo: make above for dropdowns too 
     333 
     334                } elseif ( isset( $field["type_dropdown_options"] ) && is_array( $field["type_radiobuttons_options"] ) ) { 
     335                     
     336                    foreach ( $field["type_radiobuttons_options"] as $one_radio_option_key => $one_radio_option_val) { 
     337 
     338                        // only values like radiobutton_num_2 are allowed 
     339                        if ( strpos($one_radio_option_key, "radiobutton_num_") === FALSE) continue; 
     340                        icl_register_string($this->wpml_context, "Field checkbox value, " . $field["slug"] . " " . $one_radio_option_key, $one_radio_option_val["value"]); 
     341 
     342                    } 
     343 
     344                } 
     345*/ 
     346 
     347            } // foreach 
     348 
     349        } // foreach field groups 
     350         
     351        // Get and register post connectors 
     352        $post_connectors = $this->get_post_connectors(); 
     353        foreach ($post_connectors as $connector) { 
     354            icl_register_string($this->wpml_context, "Post connector name, " . $connector["slug"], $connector["name"]); 
     355        } 
     356 
     357    } // func 
     358 
     359    /** 
     360     * Get maybe translated string 
     361     * If WPML is installed and activated then icl_t() is used on the string 
     362     * If WPML is not instaled, then it's just returned unmodified 
     363     * 
     364     * @param string $name Name to use in icl_t 
     365     * @param string $value Value to use in icl_t 
     366     */ 
     367    function get_string($name = "", $value = "") { 
     368 
     369        if ( $this->is_wpml_active() ) { 
     370            $value = icl_t($this->wpml_context, $name, $value); 
     371            // $value = "WPML: $value"; // debug to check that function actually runs 
     372            return $value; 
     373        } else { 
     374            return $value; 
     375        } 
     376 
     377    } 
     378 
    140379 
    141380    /** 
     
    189428        global $wpdb; 
    190429 
    191         $db_version = get_option("simple_fields_db_version"); 
    192  
    193         if ($db_version === FALSE) { 
     430        $db_version = (int) get_option("simple_fields_db_version"); 
     431         
     432        if ($db_version === 0) { 
    194433 
    195434            // 1 = the first version, nothing done during update 
    196             $db_version = 1; 
    197             update_option("simple_fields_db_version", 1); 
    198          
    199         } 
    200  
    201         // Do things depending on current version 
    202         // ...to come... 
     435            $new_db_version = 1; 
     436         
     437        } else if ( 1 === $db_version ) { 
     438 
     439            // if prev db version was 1 then clear cache so field group options get updated 
     440            $this->clear_caches(); 
     441            $new_db_version = 2; 
     442 
     443        } 
     444         
     445        if ( isset( $new_db_version ) ) { 
     446            update_option("simple_fields_db_version", $new_db_version); 
     447        } 
    203448         
    204449    } 
     
    496741        if ($post_id && is_array($fieldgroups)) { 
    497742     
    498             #echo "fieldgroups is:";sf_d($fieldgroups); 
    499  
    500743            // Delete all exisiting custom fields meta that are not part of the keep-list 
    501744            $post_meta = get_post_custom($post_id); 
     
    662905    } // save postdata 
    663906 
     907     
    664908    /** 
    665909     * adds a fieldgroup through ajax = also fetch defaults 
     
    739983 
    740984                // Options, common for all fields 
     985                $field_maybe_translated_name = $this->get_string( "Field name, " . $field["slug"], $field["name"] ); 
    741986                $description = ""; 
    742987                if ( ! empty( $field["description"] ) ) { 
    743                     $description = sprintf("<div class='simple-fields-metabox-field-description'>%s</div>", esc_html($field["description"])); 
     988                    $description = sprintf("<div class='simple-fields-metabox-field-description'>%s</div>", esc_html( $this->get_string("Field description, " . $field["slug"], $field["description"] ) ) ); 
    744989                } 
    745990 
     
    751996                // Output will be similar to this 
    752997                // <div class="simple-fields-metabox-field simple-fields-fieldgroups-field-1-1 simple-fields-fieldgroups-field-type-text" data-fieldgroup_id="1" data-field_id="1" data-num_in_set="0"> 
     998                 
    753999                ?> 
    7541000                <div class="simple-fields-metabox-field sf-cf <?php echo $field_class ?>"  
     
    7791025                        echo "<div class='simple-fields-metabox-field-second'>"; 
    7801026                        echo "<input $str_checked id='$field_unique_id' type='checkbox' name='$field_name' value='1' />"; 
    781                         echo "<label class='simple-fields-for-checkbox' for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1027                        echo "<label class='simple-fields-for-checkbox' for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    7821028                        echo "</div>"; 
    7831029         
     
    7851031         
    7861032                        echo "<div class='simple-fields-metabox-field-first'>"; 
    787                         echo "<label>" . $field["name"] . "</label>"; 
     1033                        echo "<label>" . $field_maybe_translated_name . "</label>"; 
    7881034                        echo $description; 
    7891035                        echo "</div>"; 
     
    8121058                                if ($saved_value == $one_radio_option_key) { $selected = " checked='checked' "; } 
    8131059                            } 
    814                                                      
     1060                             
     1061                            $radiobutton_maybe_translation_val = $this->get_string("Field radiobuttons value, " . $field["slug"] . " " . $one_radio_option_key, $one_radio_option_val_val ); 
     1062 
    8151063                            echo "<div class='simple-fields-metabox-field-radiobutton'>"; 
    8161064                            echo "  <input $selected name='$field_name' id='$radio_field_unique_id' type='radio' value='$one_radio_option_key' />"; 
    817                             echo "  <label for='$radio_field_unique_id' class='simple-fields-for-radiobutton'> " . $one_radio_option_val_val . "</label>"; 
     1065                            echo "  <label for='$radio_field_unique_id' class='simple-fields-for-radiobutton'> " . $radiobutton_maybe_translation_val . "</label>"; 
    8181066                            echo "</div>";                           
    8191067                             
     
    8261074 
    8271075                        echo "<div class='simple-fields-metabox-field-first'>"; 
    828                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1076                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    8291077                        echo $description; 
    8301078                        echo "</div>"; 
     
    8411089                            $field_size = 6; 
    8421090                        } 
     1091 
    8431092                        echo "<select id='$field_unique_id' name='$field_name_dropdown' $str_multiple size='$field_size' >"; 
     1093 
    8441094                        foreach ($field["type_dropdown_options"] as $one_option_internal_name => $one_option) { 
    8451095                             
     
    8471097                            if (strpos($one_option_internal_name, "dropdown_num_") === FALSE) continue; 
    8481098 
    849                             $dropdown_value_esc = esc_html($one_option["value"]); 
     1099                            #$dropdown_value_esc = esc_html( $one_option["value"] ); 
     1100 
     1101                            $option_name = $one_option["value"]; 
     1102                            $options_maybe_translation_name = $this->get_string("Field dropdown value, " . $field["slug"] . " " . $one_option_internal_name, $option_name ); 
     1103                            $dropdown_value_esc = esc_html( $options_maybe_translation_name ); 
     1104 
    8501105                            $selected = ""; 
    8511106 
     
    9061161 
    9071162                            echo "<div class='simple-fields-metabox-field-first'>"; 
    908                             echo "<label>{$field["name"]}</label>"; 
     1163                            echo "<label>{$field_maybe_translated_name}</label>"; 
    9091164                            echo $description; 
    9101165                            echo "</div>"; 
     
    9751230                         
    9761231                        echo "<div class='simple-fields-metabox-field-first'>"; 
    977                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1232                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    9781233                        echo $description; 
    9791234                        echo "</div>"; 
     
    11301385 
    11311386                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1132                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1387                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    11331388                        echo $description; 
    11341389                        echo "</div>"; 
     
    11431398 
    11441399                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1145                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1400                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    11461401                        echo $description; 
    11471402                        echo "</div>"; 
     
    11591414                         
    11601415                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1161                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1416                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    11621417                        echo $description; 
    11631418                        echo "</div>"; 
     
    11771432                        // var_dump($saved_value); 
    11781433                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1179                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1434                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    11801435                        echo $description; 
    11811436                        echo "</div>"; 
     
    12101465                        // @todo: kunna skicka in args här, t.ex. för orderby 
    12111466                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1212                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1467                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    12131468                        echo $description; 
    12141469                        echo "</div>"; 
     
    12621517 
    12631518                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1264                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1519                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    12651520                        echo $description; 
    12661521                        echo "</div>"; 
     
    12981553                        // echo "<pre>"; print_r($type_post_options); echo "</pre>"; 
    12991554                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1300                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1555                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    13011556                        echo $description; 
    13021557                        echo "</div>"; 
     
    13531608                            // Always output label and description, for consistency 
    13541609                            echo "<div class='simple-fields-metabox-field-first'>"; 
    1355                             echo "<label>" . $field["name"] . "</label>"; 
     1610                            echo "<label>" . $field_maybe_translated_name . "</label>"; 
    13561611                            echo $description; 
    13571612                            echo "</div>"; 
     
    14641719     
    14651720                            $meta_box_id = "simple_fields_connector_" . $field_group_to_add["id"]; 
    1466                             $meta_box_title = $field_group_to_add["name"]; 
     1721                            $meta_box_title = $this->get_string("Field group name, " . $field_group_to_add["slug"], $field_group_to_add["name"] ); 
    14671722                            $meta_box_context = $one_post_connector_field_group["context"]; 
    14681723                            $meta_box_priority = $one_post_connector_field_group["priority"]; 
     
    15261781      
    15271782        // show description 
    1528         if (!empty($current_field_group["description"])) { 
    1529             printf("<p class='%s'>%s</p>", "simple-fields-meta-box-field-group-description", esc_html($current_field_group["description"])); 
     1783        if ( ! empty($current_field_group["description"]) ) { 
     1784            printf("<p class='%s'>%s</p>", "simple-fields-meta-box-field-group-description", esc_html( $this->get_string("Field group description, " . $current_field_group["slug"], $current_field_group["description"]) ) ); 
    15301785        } 
    15311786        //echo "<pre>";print_r($current_field_group);echo "</pre>"; 
     
    15401795                    // sf_d($field_arr); 
    15411796                    printf('<div class="simple-fields-metabox-field-group-view-table-headline simple-fields-metabox-field-group-view-table-headline-count-%1$d">', $current_field_group["fields_count"]); 
    1542                     printf('<div class="simple-fields-field-group-view-table-headline-name">%1$s</div>', $field_arr["name"]); 
    1543                     printf('<div class="simple-fields-field-group-view-table-headline-description">%1$s</div>', $field_arr["description"]); 
     1797                    printf('<div class="simple-fields-field-group-view-table-headline-name">%1$s</div>', $this->get_string( "Field name, " . $field_arr["slug"], $field_arr["name"] ) ); 
     1798                    printf('<div class="simple-fields-field-group-view-table-headline-description">%1$s</div>', $this->get_string("Field description, " . $field_arr["slug"], $field_arr["description"] ) ); 
    15441799                    printf('</div>'); 
    15451800                } 
     
    18032058            } 
    18042059 
     2060            // normalize it so all info is available in the new funky way 
     2061            $field_groups = $this->normalize_fieldgroups( $field_groups ); 
     2062 
    18052063            wp_cache_set( 'simple_fields_'.$this->ns_key.'_groups', $field_groups, 'simple_fields' ); 
    18062064             
     
    18382096    /** 
    18392097     * Get a field group 
     2098     * 
     2099     * Example: 
     2100     * <code> 
     2101     * global $sf; 
     2102     * $my_field_group_id = 10; 
     2103     * $field_group_info = $sf->get_field_group( $my_field_group_id ); 
     2104     * sf_d( $field_group_info , '$field_group_info' ); 
     2105     * </code> 
     2106     * 
    18402107     * @param int $group_id 
    18412108     * @return array with field group or false if field group is not found 
     
    40884355 
    40894356    /** 
     4357     * Promote Earth People 
     4358     */ 
     4359    function promote_ep_on_nav_tabs() { 
     4360        ?> 
     4361        <style> 
     4362            .simple-fields-promote { 
     4363                float: right; 
     4364                background: #999; 
     4365                width: 375px; 
     4366                margin-top: -3.5em; 
     4367                padding: .5em; 
     4368                font-size: 12px; 
     4369                display: inline-block; 
     4370                vertical-align: center; 
     4371            } 
     4372             
     4373            .simple-fields-promote p { 
     4374                color: #eee; 
     4375                font-size: inherit; 
     4376                margin: 0 0 .25em 0; 
     4377            } 
     4378            .simple-fields-promote a { 
     4379                color: inherit; 
     4380            } 
     4381            .ep_logo { 
     4382                float: left; 
     4383            } 
     4384        </style> 
     4385        <div class="simple-fields-promote"> 
     4386 
     4387            <!-- <img src="http://d3m1jlakmz8guo.cloudfront.net/application/views/assets/img/earth_people.png"> --> 
     4388 
     4389            <p>This plugin is made by swedish web agency <a href="http://earthpeople.se/?utm_source=wordpress&utm_medium=plugin&utm_campaign=simplefields">Earth People</a>.</p> 
     4390            <p>We specialize in web development, user experience and design.</p> 
     4391            <p><a href="mailto:peder@earthpeople.se">Contact us</a> if you need a professional WordPress partner.</p> 
     4392         
     4393        </div> 
     4394        <?php 
     4395    } 
     4396 
     4397    /** 
    40904398     * Retrive a field by a string in the format <fieldgroup_slug>/<field_slug> 
    40914399     * used when fieldgroups and fields need to be passed as string 
     
    41124420    } // end get_field_by_fieldgroup_and_slug_string 
    41134421 
     4422    /** 
     4423     * Check if wpml is active 
     4424     * 
     4425     * @return bool 
     4426     */ 
     4427    public function is_wpml_active() { 
     4428         
     4429        global $sitepress;       
     4430        return ( isset( $sitepress ) && $sitepress instanceof SitePress ); 
     4431 
     4432    } 
     4433 
     4434 
    41144435} // end class 
    41154436 
  • simple-fields/tags/1.4/tests/SimpleFieldsTests/SimpleFieldsTest.php

    r707484 r740248  
    13781378        $this->assertEquals("_simple_fields_fieldGroupID_1_fieldID_2_numInSet_3", $key); 
    13791379 
     1380        // test that normalization of fields works 
     1381        $field_groups = unserialize('a:1:{i:19;a:12:{s:2:"id";i:19;s:3:"key";s:19:"wpml_radiosandstuff";s:4:"slug";s:19:"wpml_radiosandstuff";s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:6:"fields";a:4:{i:1;a:11:{s:4:"name";s:18:"Here is checkboxes";s:4:"slug";s:3:"cbs";s:11:"description";s:0:"";s:4:"type";s:8:"checkbox";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"1";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}}i:2;a:12:{s:4:"name";s:21:"Here is radio buttons";s:4:"slug";s:3:"rds";s:11:"description";s:0:"";s:4:"type";s:12:"radiobuttons";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_radiobuttons_options";a:4:{s:17:"radiobutton_num_2";a:2:{s:5:"value";s:13:"Radiobutton 1";s:7:"deleted";s:1:"0";}s:17:"radiobutton_num_3";a:2:{s:5:"value";s:14:"And the second";s:7:"deleted";s:1:"0";}s:22:"checked_by_default_num";s:17:"radiobutton_num_3";s:17:"radiobutton_num_4";a:2:{s:5:"value";s:17:"How about a third";s:7:"deleted";s:1:"0";}}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"2";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}}i:3;a:11:{s:4:"name";s:0:"";s:4:"slug";s:0:"";s:11:"description";s:0:"";s:4:"type";s:4:"text";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"3";s:7:"deleted";s:1:"1";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}}i:4;a:11:{s:4:"name";s:16:"Here is dropdown";s:4:"slug";s:4:"drps";s:11:"description";s:0:"";s:4:"type";s:8:"dropdown";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:4:{s:15:"enable_multiple";s:1:"0";s:14:"dropdown_num_2";a:2:{s:5:"value";s:10:"Dropdown 1";s:7:"deleted";s:1:"0";}s:14:"dropdown_num_3";a:2:{s:5:"value";s:21:"And a second dropdown";s:7:"deleted";s:1:"0";}s:14:"dropdown_num_4";a:2:{s:5:"value";s:29:"Dropdowns has third value too";s:7:"deleted";s:1:"0";}}s:2:"id";s:1:"4";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}}}s:14:"fields_by_slug";a:0:{}s:7:"deleted";b:0;s:8:"gui_view";s:4:"list";s:15:"added_with_code";b:0;s:12:"fields_count";i:3;}}'); 
     1382        $field_groups_normalized_expected = unserialize('a:1:{i:19;a:12:{s:2:"id";i:19;s:3:"key";s:19:"wpml_radiosandstuff";s:4:"slug";s:19:"wpml_radiosandstuff";s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:6:"fields";a:4:{i:1;a:12:{s:4:"name";s:18:"Here is checkboxes";s:4:"slug";s:3:"cbs";s:11:"description";s:0:"";s:4:"type";s:8:"checkbox";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"1";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}s:7:"options";a:4:{s:8:"textarea";a:1:{s:11:"size_height";s:7:"default";}s:4:"post";a:1:{s:20:"additional_arguments";s:0:"";}s:12:"taxonomyterm";a:1:{s:20:"additional_arguments";s:0:"";}s:8:"dropdown";a:1:{s:15:"enable_multiple";s:1:"0";}}}i:2;a:13:{s:4:"name";s:21:"Here is radio buttons";s:4:"slug";s:3:"rds";s:11:"description";s:0:"";s:4:"type";s:12:"radiobuttons";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_radiobuttons_options";a:4:{s:17:"radiobutton_num_2";a:2:{s:5:"value";s:13:"Radiobutton 1";s:7:"deleted";s:1:"0";}s:17:"radiobutton_num_3";a:2:{s:5:"value";s:14:"And the second";s:7:"deleted";s:1:"0";}s:22:"checked_by_default_num";s:17:"radiobutton_num_3";s:17:"radiobutton_num_4";a:2:{s:5:"value";s:17:"How about a third";s:7:"deleted";s:1:"0";}}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"2";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}s:7:"options";a:5:{s:8:"textarea";a:1:{s:11:"size_height";s:7:"default";}s:4:"post";a:1:{s:20:"additional_arguments";s:0:"";}s:12:"taxonomyterm";a:1:{s:20:"additional_arguments";s:0:"";}s:12:"radiobuttons";a:2:{s:6:"values";a:3:{i:0;a:3:{s:5:"value";s:13:"Radiobutton 1";s:7:"deleted";s:1:"0";s:3:"num";i:2;}i:1;a:4:{s:5:"value";s:14:"And the second";s:7:"deleted";s:1:"0";s:3:"num";i:3;s:7:"checked";b:1;}i:2;a:3:{s:5:"value";s:17:"How about a third";s:7:"deleted";s:1:"0";s:3:"num";i:4;}}s:22:"checked_by_default_num";s:17:"radiobutton_num_3";}s:8:"dropdown";a:1:{s:15:"enable_multiple";s:1:"0";}}}i:3;a:12:{s:4:"name";s:0:"";s:4:"slug";s:0:"";s:11:"description";s:0:"";s:4:"type";s:4:"text";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"3";s:7:"deleted";s:1:"1";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}s:7:"options";a:4:{s:8:"textarea";a:1:{s:11:"size_height";s:7:"default";}s:4:"post";a:1:{s:20:"additional_arguments";s:0:"";}s:12:"taxonomyterm";a:1:{s:20:"additional_arguments";s:0:"";}s:8:"dropdown";a:1:{s:15:"enable_multiple";s:1:"0";}}}i:4;a:12:{s:4:"name";s:16:"Here is dropdown";s:4:"slug";s:4:"drps";s:11:"description";s:0:"";s:4:"type";s:8:"dropdown";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:4:{s:15:"enable_multiple";s:1:"0";s:14:"dropdown_num_2";a:2:{s:5:"value";s:10:"Dropdown 1";s:7:"deleted";s:1:"0";}s:14:"dropdown_num_3";a:2:{s:5:"value";s:21:"And a second dropdown";s:7:"deleted";s:1:"0";}s:14:"dropdown_num_4";a:2:{s:5:"value";s:29:"Dropdowns has third value too";s:7:"deleted";s:1:"0";}}s:2:"id";s:1:"4";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}s:7:"options";a:4:{s:8:"textarea";a:1:{s:11:"size_height";s:7:"default";}s:4:"post";a:1:{s:20:"additional_arguments";s:0:"";}s:12:"taxonomyterm";a:1:{s:20:"additional_arguments";s:0:"";}s:8:"dropdown";a:2:{s:15:"enable_multiple";s:1:"0";s:6:"values";a:3:{i:0;a:3:{s:5:"value";s:10:"Dropdown 1";s:7:"deleted";s:1:"0";s:3:"num";i:2;}i:1;a:3:{s:5:"value";s:21:"And a second dropdown";s:7:"deleted";s:1:"0";s:3:"num";i:3;}i:2;a:3:{s:5:"value";s:29:"Dropdowns has third value too";s:7:"deleted";s:1:"0";s:3:"num";i:4;}}}}}}s:14:"fields_by_slug";a:0:{}s:7:"deleted";b:0;s:8:"gui_view";s:4:"list";s:15:"added_with_code";b:0;s:12:"fields_count";i:3;}}'); 
     1383        $field_groups_normalized = $this->sf->normalize_fieldgroups( $field_groups ); 
     1384        $this->assertEquals( $field_groups_normalized_expected, $field_groups_normalized); 
     1385 
    13801386    } 
    13811387 
  • simple-fields/trunk/inc-admin-options-manage.php

    r707484 r740248  
    55 */ 
    66if ("edit-post-type-defaults" == $action) { 
     7 
     8    global $wp_post_types; 
    79    $post_type = $_GET["post-type"]; 
    8     global $wp_post_types; 
    9     if (isset($wp_post_types[$post_type])) { 
     10 
     11    if ( isset($wp_post_types[$post_type]) ) { 
     12         
    1013        $selected_post_type = $wp_post_types[$post_type]; 
    1114        ?> 
     
    453456if ( ! $action ) { 
    454457 
    455  
    456458    do_action("simple_fields_options_print_nav_tabs", $subpage); 
    457459 
     
    465467        } 
    466468    } 
    467  
    468469 
    469470    /** 
     
    527528                            echo "<tr class='$row_class'>"; 
    528529                            echo "<td>"; 
    529                             echo "<a href='$editlink'><strong>" . esc_html( $oneFieldGroup["name"] ) . "</strong></a>"; 
     530                            echo "<a href='$editlink'><strong>" . esc_html( $this->get_string( "Field group name, " . $oneFieldGroup["slug"], $oneFieldGroup["name"] ) ) . "</strong></a>"; 
    530531                             
    531532                            ?><div class="row-actions"> 
     
    613614                    <tr class='<?php echo $row_class ?>'> 
    614615                        <td> 
    615                             <a href="<?php echo $edit_url ?>"><strong><?php echo esc_html( $one_post_connector["name"] ) ?></strong></a> 
     616                            <a href="<?php echo $edit_url ?>"><strong><?php echo esc_html( $this->get_string( "Post connector name, " . $one_post_connector["slug"], $one_post_connector["name"]) ) ?></strong></a> 
    616617                            <div class="row-actions"> 
    617618                                <span class="edit"><a href="<?php echo $edit_url ?>" title="<?php _e("Edit this item") ?>"><?php _e("Edit") ?></a></span> 
  • simple-fields/trunk/readme.txt

    r728801 r740248  
    55Requires at least: 3.5.1 
    66Tested up to: 3.5.1 
    7 Stable tag: 1.3.3 
     7Stable tag: 1.4 
    88 
    99With Simple Fields you can add any kind of custom fields to your pages, posts and attachments. 
     
    144144 
    145145== Changelog == 
     146 
     147#### Version 1.4 
     148 
     149- Added support for [WPML](http://wpml.org/). Now the names and descriptions of field groups, their fields, and post connectors, and values of drop downs and radiobuttons can be translated using WPML. 
     150- Added a little teaser about [WordPress Web Agency Earth People](http://earthpeople.se/?utm_source=wordpress&utm_medium=readme&utm_campaign=simplefields), the company I work for. If you need any professional help with for example Simple Fields or WordPress in general then we might be the ones to talk to :) 
    146151 
    147152#### Version 1.3.4 
  • simple-fields/trunk/simple_fields.php

    r728801 r740248  
    44Plugin URI: http://simple-fields.com 
    55Description: Add groups of textareas, input-fields, dropdowns, radiobuttons, checkboxes and files to your edit post screen. 
    6 Version: 1.3.4 
     6Version: 1.4 
    77Author: Pär Thernström 
    88Author URI: http://eskapism.se/ 
     
    4646    ; 
    4747 
     48    private 
     49 
     50        $wpml_context = "Simple Fields"; 
     51 
    4852 
    4953    /** 
     
    5357    function init() { 
    5458 
    55         define( "SIMPLE_FIELDS_VERSION", "1.3.4"); 
     59 
     60        define( "SIMPLE_FIELDS_VERSION", "1.4"); 
    5661        define( "SIMPLE_FIELDS_URL", plugins_url(basename(dirname(__FILE__))). "/"); 
    5762        define( "SIMPLE_FIELDS_NAME", "Simple Fields"); 
     
    121126 
    122127        // Options page 
     128        add_action("simple_fields_options_print_nav_tabs", array($this, "promote_ep_on_nav_tabs")); 
    123129        add_action("simple_fields_options_print_nav_tabs", array($this, "get_options_nav_tabs")); 
    124130 
     
    134140        */ 
    135141 
     142        // Setup things for WPML-support 
     143        add_action("init", array($this, "setup_wpml_support")); 
     144 
    136145        // Boot up 
    137146        do_action("simple_fields_init", $this); 
    138147 
    139148    } 
     149 
     150    /** 
     151     * Init support for WPML translations 
     152     */ 
     153    function setup_wpml_support() { 
     154 
     155        // If wpml is not active then don't do anything 
     156        if ( ! $this->is_wpml_active()) return; 
     157 
     158        // http://wpml.org/documentation/support/translation-for-texts-by-other-plugins-and-themes/ 
     159 
     160        // 1. Register the strings that need translation 
     161        // icl_register_string($context, $name, $value) 
     162        // run on settings screen, go through all fields and register string 
     163        add_action("simple_fields_settings_admin_head", array($this, "register_wpml_strings")); 
     164 
     165        // 2. Using the translation when displaying 
     166        // icl_t($context, $name, $value) 
     167 
     168    } 
     169 
     170 
     171 
     172    /** 
     173     * Make sure a field group has the correct format 
     174     * It can be wrong because prior to version ?.? the options 
     175     * for a field was not stored in the options array. but nowadays we 
     176     * assume it is. so..if it's not: fix that! 
     177     * 
     178     * @param array $fieldgroup Field group to normalize 
     179     * @return array $fieldgroup Normalized/fixed field group 
     180     */ 
     181    function normalize_fieldgroups( $field_groups ) { 
     182     
     183        // wierd, but i moved to code so this is the way it is..  
     184        foreach ( $field_groups as & $fieldgroup_by_reference ) { 
     185 
     186            // If field was not added with code then move all options to the options-array 
     187            if ( ! isset($fieldgroup_by_reference["added_with_code"]) || false === $fieldgroup_by_reference["added_with_code"] ) { 
     188             
     189                foreach ($fieldgroup_by_reference["fields"] as & $field_by_reference) { 
     190 
     191                    #if ( "drps" === $field_by_reference["slug"] ) { 
     192                         
     193                        // make sure field has an options-key that is an array 
     194                        if ( ! isset( $field_by_reference["options"] ) || ! is_array( $field_by_reference["options"] ) ) $field_by_reference["options"] = array(); 
     195 
     196                        foreach ( $field_by_reference as $field_key => $field_vals ) { 
     197                             
     198                            // if field has key with name 
     199                            // type_<textarea|post|taxonyterm|dropdown|whatever>_options 
     200                            // then move that info to the field[options]-array 
     201                            if ( 1 === preg_match('/type_([a-z]+)/', $field_key, $field_key_matches) ) { 
     202                                 
     203                                // $field_key_matches[1] = field type 
     204                                $field_key_type = $field_key_matches[1]; 
     205 
     206                                // make sure field type is key in options array 
     207                                if ( ! isset( $field_by_reference["options"][ $field_key_type ] ) || ! is_array( $field_by_reference["options"][ $field_key_type ] ) ) $field_by_reference["options"][ $field_key_type ] = array(); 
     208                                 
     209                                // move keys to options array 
     210                                // keys with name dropdown_num_, checkbox_num_, radiobutton_num_ need special treatment 
     211                                $values = array(); 
     212                                $values_index = 0; 
     213 
     214                                // check if checked by default exists 
     215                                $checked_by_default_num = false; 
     216                                if ( isset( $field_vals["checked_by_default_num"] ) ) { 
     217                                    $checked_by_default_num = $field_vals["checked_by_default_num"]; 
     218                                    if ( 1 === preg_match('/_num_([\d]+)/', $checked_by_default_num, $checked_num_matches ) ) { 
     219                                        $checked_by_default_num = (int) $checked_num_matches[1]; 
     220                                    } 
     221                                } 
     222 
     223                                foreach ( $field_vals as $field_vals_key => $field_vals_val ) { 
     224                                     
     225                                    if ( 1 === preg_match('/([a-z]+)_num_(\d+)/i', $field_vals_key, $matches) ) { 
     226 
     227                                        // $matches[1] = field type 
     228                                        // $matches[2] = field type num 
     229                                        #sf_d($field_vals_key, '$field_vals_key'); 
     230                                        #sf_d($field_vals_val, '$field_vals_val'); 
     231 
     232                                        $values[ $values_index ] = $field_vals_val; 
     233                                        $values[ $values_index ]["num"] = (int) $matches[2]; 
     234                                         
     235                                        if ( false !== $checked_by_default_num && $checked_by_default_num === $values[ $values_index ]["num"] ) { 
     236                                            $values[ $values_index ]["checked"] = true; 
     237                                            $field_by_reference["options"][ $field_key_type ]["checked_by_default_num"] = $field_key_type . "_num_" . $checked_by_default_num; 
     238                                        } 
     239 
     240                                        $values_index++; 
     241 
     242                                    } else { 
     243 
     244                                        // "regular" option key key 
     245                                        $field_by_reference["options"][ $field_key_type ][ $field_vals_key ] = $field_vals_val; 
     246                                         
     247                                    } 
     248 
     249                                    if ($values) { 
     250                                     
     251                                        $field_by_reference["options"][ $field_key_type ]["values"] = $values; 
     252                                     
     253                                    } 
     254 
     255                                     
     256                                } // foreach field vals 
     257                                 
     258                            } // if type_ 
     259 
     260                            // sf_d($field); 
     261 
     262                        } // foreach field key 
     263 
     264 
     265                    #} 
     266 
     267                } // foreach field 
     268 
     269 
     270            } // if not added with code 
     271 
     272        } 
     273 
     274        return $field_groups; 
     275 
     276    } // func 
     277 
     278    /** 
     279     * Register strings so they are translateable with WPML 
     280     */ 
     281    function register_wpml_strings() { 
     282         
     283        // Get all fieldgroups and fields 
     284        $field_groups = $this->get_field_groups(); 
     285 
     286        foreach ($field_groups as & $fieldgroup_by_reference) { 
     287                         
     288            // register name and description of each field group 
     289            icl_register_string($this->wpml_context, "Field group name, " . $fieldgroup_by_reference["slug"], $fieldgroup_by_reference["name"]); 
     290            icl_register_string($this->wpml_context, "Field group description, " . $fieldgroup_by_reference["slug"], $fieldgroup_by_reference["description"]); 
     291 
     292            // register name for each field 
     293            foreach ($fieldgroup_by_reference["fields"] as $field) { 
     294 
     295                icl_register_string($this->wpml_context, "Field name, " . $field["slug"], $field["name"]); 
     296                icl_register_string($this->wpml_context, "Field description, " . $field["slug"], $field["description"]); 
     297 
     298                // register names for dropdowns and radiobuttons 
     299                // several fields can have the same slug, if they are in different field groups 
     300                // how to solve that?  
     301                //  - can't prefix with field group, because they can be in several of those 
     302                //  - can't prefix with id because can be different between dev/prod/live-servers 
     303                // to much to worry about here, let's go with just the slug and then it's up to the 
     304                // user to not use a slug more than once. 
     305                if ( isset( $field["options"] ) && is_array( $field["options"] ) ) { 
     306 
     307                    if ( isset( $field["options"]["radiobuttons"]["values"] ) && is_array( $field["options"]["radiobuttons"]["values"] ) ) { 
     308     
     309                        foreach ( $field["options"]["radiobuttons"]["values"] as $one_radio_option_key => $one_radio_option_val) { 
     310                             
     311                            $string_name = "Field radiobuttons value, " . $field["slug"] . " " . "radiobutton_num_" . $one_radio_option_val["num"]; 
     312                            // sf_d($this->wpml_context);sf_d($string_name);sf_d($one_radio_option_val["value"]); 
     313                            icl_register_string($this->wpml_context, $string_name, $one_radio_option_val["value"]); 
     314 
     315                        } // foreach 
     316 
     317                    } // if radiobuttons 
     318                    if ( isset( $field["options"]["dropdown"]["values"] ) && is_array( $field["options"]["dropdown"]["values"] ) ) { 
     319     
     320                        foreach ( $field["options"]["dropdown"]["values"] as $one_dropdown_val) { 
     321                             
     322                            $string_name = "Field dropdown value, " . $field["slug"] . " " . "dropdown_num_" . $one_dropdown_val["num"]; 
     323                            // sf_d($string_name); 
     324                            icl_register_string($this->wpml_context, $string_name, $one_dropdown_val["value"]); 
     325 
     326                        } // foreach 
     327 
     328                    } // if dropdowns 
     329                 
     330                } // if options 
     331/* 
     332// @todo: make above for dropdowns too 
     333 
     334                } elseif ( isset( $field["type_dropdown_options"] ) && is_array( $field["type_radiobuttons_options"] ) ) { 
     335                     
     336                    foreach ( $field["type_radiobuttons_options"] as $one_radio_option_key => $one_radio_option_val) { 
     337 
     338                        // only values like radiobutton_num_2 are allowed 
     339                        if ( strpos($one_radio_option_key, "radiobutton_num_") === FALSE) continue; 
     340                        icl_register_string($this->wpml_context, "Field checkbox value, " . $field["slug"] . " " . $one_radio_option_key, $one_radio_option_val["value"]); 
     341 
     342                    } 
     343 
     344                } 
     345*/ 
     346 
     347            } // foreach 
     348 
     349        } // foreach field groups 
     350         
     351        // Get and register post connectors 
     352        $post_connectors = $this->get_post_connectors(); 
     353        foreach ($post_connectors as $connector) { 
     354            icl_register_string($this->wpml_context, "Post connector name, " . $connector["slug"], $connector["name"]); 
     355        } 
     356 
     357    } // func 
     358 
     359    /** 
     360     * Get maybe translated string 
     361     * If WPML is installed and activated then icl_t() is used on the string 
     362     * If WPML is not instaled, then it's just returned unmodified 
     363     * 
     364     * @param string $name Name to use in icl_t 
     365     * @param string $value Value to use in icl_t 
     366     */ 
     367    function get_string($name = "", $value = "") { 
     368 
     369        if ( $this->is_wpml_active() ) { 
     370            $value = icl_t($this->wpml_context, $name, $value); 
     371            // $value = "WPML: $value"; // debug to check that function actually runs 
     372            return $value; 
     373        } else { 
     374            return $value; 
     375        } 
     376 
     377    } 
     378 
    140379 
    141380    /** 
     
    189428        global $wpdb; 
    190429 
    191         $db_version = get_option("simple_fields_db_version"); 
    192  
    193         if ($db_version === FALSE) { 
     430        $db_version = (int) get_option("simple_fields_db_version"); 
     431         
     432        if ($db_version === 0) { 
    194433 
    195434            // 1 = the first version, nothing done during update 
    196             $db_version = 1; 
    197             update_option("simple_fields_db_version", 1); 
    198          
    199         } 
    200  
    201         // Do things depending on current version 
    202         // ...to come... 
     435            $new_db_version = 1; 
     436         
     437        } else if ( 1 === $db_version ) { 
     438 
     439            // if prev db version was 1 then clear cache so field group options get updated 
     440            $this->clear_caches(); 
     441            $new_db_version = 2; 
     442 
     443        } 
     444         
     445        if ( isset( $new_db_version ) ) { 
     446            update_option("simple_fields_db_version", $new_db_version); 
     447        } 
    203448         
    204449    } 
     
    496741        if ($post_id && is_array($fieldgroups)) { 
    497742     
    498             #echo "fieldgroups is:";sf_d($fieldgroups); 
    499  
    500743            // Delete all exisiting custom fields meta that are not part of the keep-list 
    501744            $post_meta = get_post_custom($post_id); 
     
    662905    } // save postdata 
    663906 
     907     
    664908    /** 
    665909     * adds a fieldgroup through ajax = also fetch defaults 
     
    739983 
    740984                // Options, common for all fields 
     985                $field_maybe_translated_name = $this->get_string( "Field name, " . $field["slug"], $field["name"] ); 
    741986                $description = ""; 
    742987                if ( ! empty( $field["description"] ) ) { 
    743                     $description = sprintf("<div class='simple-fields-metabox-field-description'>%s</div>", esc_html($field["description"])); 
     988                    $description = sprintf("<div class='simple-fields-metabox-field-description'>%s</div>", esc_html( $this->get_string("Field description, " . $field["slug"], $field["description"] ) ) ); 
    744989                } 
    745990 
     
    751996                // Output will be similar to this 
    752997                // <div class="simple-fields-metabox-field simple-fields-fieldgroups-field-1-1 simple-fields-fieldgroups-field-type-text" data-fieldgroup_id="1" data-field_id="1" data-num_in_set="0"> 
     998                 
    753999                ?> 
    7541000                <div class="simple-fields-metabox-field sf-cf <?php echo $field_class ?>"  
     
    7791025                        echo "<div class='simple-fields-metabox-field-second'>"; 
    7801026                        echo "<input $str_checked id='$field_unique_id' type='checkbox' name='$field_name' value='1' />"; 
    781                         echo "<label class='simple-fields-for-checkbox' for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1027                        echo "<label class='simple-fields-for-checkbox' for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    7821028                        echo "</div>"; 
    7831029         
     
    7851031         
    7861032                        echo "<div class='simple-fields-metabox-field-first'>"; 
    787                         echo "<label>" . $field["name"] . "</label>"; 
     1033                        echo "<label>" . $field_maybe_translated_name . "</label>"; 
    7881034                        echo $description; 
    7891035                        echo "</div>"; 
     
    8121058                                if ($saved_value == $one_radio_option_key) { $selected = " checked='checked' "; } 
    8131059                            } 
    814                                                      
     1060                             
     1061                            $radiobutton_maybe_translation_val = $this->get_string("Field radiobuttons value, " . $field["slug"] . " " . $one_radio_option_key, $one_radio_option_val_val ); 
     1062 
    8151063                            echo "<div class='simple-fields-metabox-field-radiobutton'>"; 
    8161064                            echo "  <input $selected name='$field_name' id='$radio_field_unique_id' type='radio' value='$one_radio_option_key' />"; 
    817                             echo "  <label for='$radio_field_unique_id' class='simple-fields-for-radiobutton'> " . $one_radio_option_val_val . "</label>"; 
     1065                            echo "  <label for='$radio_field_unique_id' class='simple-fields-for-radiobutton'> " . $radiobutton_maybe_translation_val . "</label>"; 
    8181066                            echo "</div>";                           
    8191067                             
     
    8261074 
    8271075                        echo "<div class='simple-fields-metabox-field-first'>"; 
    828                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1076                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    8291077                        echo $description; 
    8301078                        echo "</div>"; 
     
    8411089                            $field_size = 6; 
    8421090                        } 
     1091 
    8431092                        echo "<select id='$field_unique_id' name='$field_name_dropdown' $str_multiple size='$field_size' >"; 
     1093 
    8441094                        foreach ($field["type_dropdown_options"] as $one_option_internal_name => $one_option) { 
    8451095                             
     
    8471097                            if (strpos($one_option_internal_name, "dropdown_num_") === FALSE) continue; 
    8481098 
    849                             $dropdown_value_esc = esc_html($one_option["value"]); 
     1099                            #$dropdown_value_esc = esc_html( $one_option["value"] ); 
     1100 
     1101                            $option_name = $one_option["value"]; 
     1102                            $options_maybe_translation_name = $this->get_string("Field dropdown value, " . $field["slug"] . " " . $one_option_internal_name, $option_name ); 
     1103                            $dropdown_value_esc = esc_html( $options_maybe_translation_name ); 
     1104 
    8501105                            $selected = ""; 
    8511106 
     
    9061161 
    9071162                            echo "<div class='simple-fields-metabox-field-first'>"; 
    908                             echo "<label>{$field["name"]}</label>"; 
     1163                            echo "<label>{$field_maybe_translated_name}</label>"; 
    9091164                            echo $description; 
    9101165                            echo "</div>"; 
     
    9751230                         
    9761231                        echo "<div class='simple-fields-metabox-field-first'>"; 
    977                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1232                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    9781233                        echo $description; 
    9791234                        echo "</div>"; 
     
    11301385 
    11311386                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1132                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1387                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    11331388                        echo $description; 
    11341389                        echo "</div>"; 
     
    11431398 
    11441399                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1145                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1400                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    11461401                        echo $description; 
    11471402                        echo "</div>"; 
     
    11591414                         
    11601415                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1161                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1416                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    11621417                        echo $description; 
    11631418                        echo "</div>"; 
     
    11771432                        // var_dump($saved_value); 
    11781433                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1179                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1434                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    11801435                        echo $description; 
    11811436                        echo "</div>"; 
     
    12101465                        // @todo: kunna skicka in args här, t.ex. för orderby 
    12111466                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1212                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1467                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    12131468                        echo $description; 
    12141469                        echo "</div>"; 
     
    12621517 
    12631518                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1264                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1519                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    12651520                        echo $description; 
    12661521                        echo "</div>"; 
     
    12981553                        // echo "<pre>"; print_r($type_post_options); echo "</pre>"; 
    12991554                        echo "<div class='simple-fields-metabox-field-first'>"; 
    1300                         echo "<label for='$field_unique_id'> " . $field["name"] . "</label>"; 
     1555                        echo "<label for='$field_unique_id'> " . $field_maybe_translated_name . "</label>"; 
    13011556                        echo $description; 
    13021557                        echo "</div>"; 
     
    13531608                            // Always output label and description, for consistency 
    13541609                            echo "<div class='simple-fields-metabox-field-first'>"; 
    1355                             echo "<label>" . $field["name"] . "</label>"; 
     1610                            echo "<label>" . $field_maybe_translated_name . "</label>"; 
    13561611                            echo $description; 
    13571612                            echo "</div>"; 
     
    14641719     
    14651720                            $meta_box_id = "simple_fields_connector_" . $field_group_to_add["id"]; 
    1466                             $meta_box_title = $field_group_to_add["name"]; 
     1721                            $meta_box_title = $this->get_string("Field group name, " . $field_group_to_add["slug"], $field_group_to_add["name"] ); 
    14671722                            $meta_box_context = $one_post_connector_field_group["context"]; 
    14681723                            $meta_box_priority = $one_post_connector_field_group["priority"]; 
     
    15261781      
    15271782        // show description 
    1528         if (!empty($current_field_group["description"])) { 
    1529             printf("<p class='%s'>%s</p>", "simple-fields-meta-box-field-group-description", esc_html($current_field_group["description"])); 
     1783        if ( ! empty($current_field_group["description"]) ) { 
     1784            printf("<p class='%s'>%s</p>", "simple-fields-meta-box-field-group-description", esc_html( $this->get_string("Field group description, " . $current_field_group["slug"], $current_field_group["description"]) ) ); 
    15301785        } 
    15311786        //echo "<pre>";print_r($current_field_group);echo "</pre>"; 
     
    15401795                    // sf_d($field_arr); 
    15411796                    printf('<div class="simple-fields-metabox-field-group-view-table-headline simple-fields-metabox-field-group-view-table-headline-count-%1$d">', $current_field_group["fields_count"]); 
    1542                     printf('<div class="simple-fields-field-group-view-table-headline-name">%1$s</div>', $field_arr["name"]); 
    1543                     printf('<div class="simple-fields-field-group-view-table-headline-description">%1$s</div>', $field_arr["description"]); 
     1797                    printf('<div class="simple-fields-field-group-view-table-headline-name">%1$s</div>', $this->get_string( "Field name, " . $field_arr["slug"], $field_arr["name"] ) ); 
     1798                    printf('<div class="simple-fields-field-group-view-table-headline-description">%1$s</div>', $this->get_string("Field description, " . $field_arr["slug"], $field_arr["description"] ) ); 
    15441799                    printf('</div>'); 
    15451800                } 
     
    18032058            } 
    18042059 
     2060            // normalize it so all info is available in the new funky way 
     2061            $field_groups = $this->normalize_fieldgroups( $field_groups ); 
     2062 
    18052063            wp_cache_set( 'simple_fields_'.$this->ns_key.'_groups', $field_groups, 'simple_fields' ); 
    18062064             
     
    18382096    /** 
    18392097     * Get a field group 
     2098     * 
     2099     * Example: 
     2100     * <code> 
     2101     * global $sf; 
     2102     * $my_field_group_id = 10; 
     2103     * $field_group_info = $sf->get_field_group( $my_field_group_id ); 
     2104     * sf_d( $field_group_info , '$field_group_info' ); 
     2105     * </code> 
     2106     * 
    18402107     * @param int $group_id 
    18412108     * @return array with field group or false if field group is not found 
     
    40884355 
    40894356    /** 
     4357     * Promote Earth People 
     4358     */ 
     4359    function promote_ep_on_nav_tabs() { 
     4360        ?> 
     4361        <style> 
     4362            .simple-fields-promote { 
     4363                float: right; 
     4364                background: #999; 
     4365                width: 375px; 
     4366                margin-top: -3.5em; 
     4367                padding: .5em; 
     4368                font-size: 12px; 
     4369                display: inline-block; 
     4370                vertical-align: center; 
     4371            } 
     4372             
     4373            .simple-fields-promote p { 
     4374                color: #eee; 
     4375                font-size: inherit; 
     4376                margin: 0 0 .25em 0; 
     4377            } 
     4378            .simple-fields-promote a { 
     4379                color: inherit; 
     4380            } 
     4381            .ep_logo { 
     4382                float: left; 
     4383            } 
     4384        </style> 
     4385        <div class="simple-fields-promote"> 
     4386 
     4387            <!-- <img src="http://d3m1jlakmz8guo.cloudfront.net/application/views/assets/img/earth_people.png"> --> 
     4388 
     4389            <p>This plugin is made by swedish web agency <a href="http://earthpeople.se/?utm_source=wordpress&utm_medium=plugin&utm_campaign=simplefields">Earth People</a>.</p> 
     4390            <p>We specialize in web development, user experience and design.</p> 
     4391            <p><a href="mailto:peder@earthpeople.se">Contact us</a> if you need a professional WordPress partner.</p> 
     4392         
     4393        </div> 
     4394        <?php 
     4395    } 
     4396 
     4397    /** 
    40904398     * Retrive a field by a string in the format <fieldgroup_slug>/<field_slug> 
    40914399     * used when fieldgroups and fields need to be passed as string 
     
    41124420    } // end get_field_by_fieldgroup_and_slug_string 
    41134421 
     4422    /** 
     4423     * Check if wpml is active 
     4424     * 
     4425     * @return bool 
     4426     */ 
     4427    public function is_wpml_active() { 
     4428         
     4429        global $sitepress;       
     4430        return ( isset( $sitepress ) && $sitepress instanceof SitePress ); 
     4431 
     4432    } 
     4433 
     4434 
    41144435} // end class 
    41154436 
  • simple-fields/trunk/tests/SimpleFieldsTests/SimpleFieldsTest.php

    r707484 r740248  
    13781378        $this->assertEquals("_simple_fields_fieldGroupID_1_fieldID_2_numInSet_3", $key); 
    13791379 
     1380        // test that normalization of fields works 
     1381        $field_groups = unserialize('a:1:{i:19;a:12:{s:2:"id";i:19;s:3:"key";s:19:"wpml_radiosandstuff";s:4:"slug";s:19:"wpml_radiosandstuff";s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:6:"fields";a:4:{i:1;a:11:{s:4:"name";s:18:"Here is checkboxes";s:4:"slug";s:3:"cbs";s:11:"description";s:0:"";s:4:"type";s:8:"checkbox";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"1";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}}i:2;a:12:{s:4:"name";s:21:"Here is radio buttons";s:4:"slug";s:3:"rds";s:11:"description";s:0:"";s:4:"type";s:12:"radiobuttons";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_radiobuttons_options";a:4:{s:17:"radiobutton_num_2";a:2:{s:5:"value";s:13:"Radiobutton 1";s:7:"deleted";s:1:"0";}s:17:"radiobutton_num_3";a:2:{s:5:"value";s:14:"And the second";s:7:"deleted";s:1:"0";}s:22:"checked_by_default_num";s:17:"radiobutton_num_3";s:17:"radiobutton_num_4";a:2:{s:5:"value";s:17:"How about a third";s:7:"deleted";s:1:"0";}}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"2";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}}i:3;a:11:{s:4:"name";s:0:"";s:4:"slug";s:0:"";s:11:"description";s:0:"";s:4:"type";s:4:"text";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"3";s:7:"deleted";s:1:"1";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}}i:4;a:11:{s:4:"name";s:16:"Here is dropdown";s:4:"slug";s:4:"drps";s:11:"description";s:0:"";s:4:"type";s:8:"dropdown";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:4:{s:15:"enable_multiple";s:1:"0";s:14:"dropdown_num_2";a:2:{s:5:"value";s:10:"Dropdown 1";s:7:"deleted";s:1:"0";}s:14:"dropdown_num_3";a:2:{s:5:"value";s:21:"And a second dropdown";s:7:"deleted";s:1:"0";}s:14:"dropdown_num_4";a:2:{s:5:"value";s:29:"Dropdowns has third value too";s:7:"deleted";s:1:"0";}}s:2:"id";s:1:"4";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}}}s:14:"fields_by_slug";a:0:{}s:7:"deleted";b:0;s:8:"gui_view";s:4:"list";s:15:"added_with_code";b:0;s:12:"fields_count";i:3;}}'); 
     1382        $field_groups_normalized_expected = unserialize('a:1:{i:19;a:12:{s:2:"id";i:19;s:3:"key";s:19:"wpml_radiosandstuff";s:4:"slug";s:19:"wpml_radiosandstuff";s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:6:"fields";a:4:{i:1;a:12:{s:4:"name";s:18:"Here is checkboxes";s:4:"slug";s:3:"cbs";s:11:"description";s:0:"";s:4:"type";s:8:"checkbox";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"1";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}s:7:"options";a:4:{s:8:"textarea";a:1:{s:11:"size_height";s:7:"default";}s:4:"post";a:1:{s:20:"additional_arguments";s:0:"";}s:12:"taxonomyterm";a:1:{s:20:"additional_arguments";s:0:"";}s:8:"dropdown";a:1:{s:15:"enable_multiple";s:1:"0";}}}i:2;a:13:{s:4:"name";s:21:"Here is radio buttons";s:4:"slug";s:3:"rds";s:11:"description";s:0:"";s:4:"type";s:12:"radiobuttons";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_radiobuttons_options";a:4:{s:17:"radiobutton_num_2";a:2:{s:5:"value";s:13:"Radiobutton 1";s:7:"deleted";s:1:"0";}s:17:"radiobutton_num_3";a:2:{s:5:"value";s:14:"And the second";s:7:"deleted";s:1:"0";}s:22:"checked_by_default_num";s:17:"radiobutton_num_3";s:17:"radiobutton_num_4";a:2:{s:5:"value";s:17:"How about a third";s:7:"deleted";s:1:"0";}}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"2";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}s:7:"options";a:5:{s:8:"textarea";a:1:{s:11:"size_height";s:7:"default";}s:4:"post";a:1:{s:20:"additional_arguments";s:0:"";}s:12:"taxonomyterm";a:1:{s:20:"additional_arguments";s:0:"";}s:12:"radiobuttons";a:2:{s:6:"values";a:3:{i:0;a:3:{s:5:"value";s:13:"Radiobutton 1";s:7:"deleted";s:1:"0";s:3:"num";i:2;}i:1;a:4:{s:5:"value";s:14:"And the second";s:7:"deleted";s:1:"0";s:3:"num";i:3;s:7:"checked";b:1;}i:2;a:3:{s:5:"value";s:17:"How about a third";s:7:"deleted";s:1:"0";s:3:"num";i:4;}}s:22:"checked_by_default_num";s:17:"radiobutton_num_3";}s:8:"dropdown";a:1:{s:15:"enable_multiple";s:1:"0";}}}i:3;a:12:{s:4:"name";s:0:"";s:4:"slug";s:0:"";s:11:"description";s:0:"";s:4:"type";s:4:"text";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:1:{s:15:"enable_multiple";s:1:"0";}s:2:"id";s:1:"3";s:7:"deleted";s:1:"1";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}s:7:"options";a:4:{s:8:"textarea";a:1:{s:11:"size_height";s:7:"default";}s:4:"post";a:1:{s:20:"additional_arguments";s:0:"";}s:12:"taxonomyterm";a:1:{s:20:"additional_arguments";s:0:"";}s:8:"dropdown";a:1:{s:15:"enable_multiple";s:1:"0";}}}i:4;a:12:{s:4:"name";s:16:"Here is dropdown";s:4:"slug";s:4:"drps";s:11:"description";s:0:"";s:4:"type";s:8:"dropdown";s:21:"type_textarea_options";a:1:{s:11:"size_height";s:7:"default";}s:17:"type_post_options";a:1:{s:20:"additional_arguments";s:0:"";}s:25:"type_taxonomyterm_options";a:1:{s:20:"additional_arguments";s:0:"";}s:21:"type_dropdown_options";a:4:{s:15:"enable_multiple";s:1:"0";s:14:"dropdown_num_2";a:2:{s:5:"value";s:10:"Dropdown 1";s:7:"deleted";s:1:"0";}s:14:"dropdown_num_3";a:2:{s:5:"value";s:21:"And a second dropdown";s:7:"deleted";s:1:"0";}s:14:"dropdown_num_4";a:2:{s:5:"value";s:29:"Dropdowns has third value too";s:7:"deleted";s:1:"0";}}s:2:"id";s:1:"4";s:7:"deleted";s:1:"0";s:11:"field_group";a:6:{s:2:"id";i:19;s:4:"name";s:32:"Radiobuttons, checkbox, dropdown";s:4:"slug";s:19:"wpml_radiosandstuff";s:11:"description";s:0:"";s:10:"repeatable";b:0;s:12:"fields_count";i:3;}s:7:"options";a:4:{s:8:"textarea";a:1:{s:11:"size_height";s:7:"default";}s:4:"post";a:1:{s:20:"additional_arguments";s:0:"";}s:12:"taxonomyterm";a:1:{s:20:"additional_arguments";s:0:"";}s:8:"dropdown";a:2:{s:15:"enable_multiple";s:1:"0";s:6:"values";a:3:{i:0;a:3:{s:5:"value";s:10:"Dropdown 1";s:7:"deleted";s:1:"0";s:3:"num";i:2;}i:1;a:3:{s:5:"value";s:21:"And a second dropdown";s:7:"deleted";s:1:"0";s:3:"num";i:3;}i:2;a:3:{s:5:"value";s:29:"Dropdowns has third value too";s:7:"deleted";s:1:"0";s:3:"num";i:4;}}}}}}s:14:"fields_by_slug";a:0:{}s:7:"deleted";b:0;s:8:"gui_view";s:4:"list";s:15:"added_with_code";b:0;s:12:"fields_count";i:3;}}'); 
     1383        $field_groups_normalized = $this->sf->normalize_fieldgroups( $field_groups ); 
     1384        $this->assertEquals( $field_groups_normalized_expected, $field_groups_normalized); 
     1385 
    13801386    } 
    13811387 
Note: See TracChangeset for help on using the changeset viewer.