Plugin Directory

Changeset 619694

Timestamp:
11/01/2012 01:48:55 AM (12 years ago)
Author:
logikal16
Message:

CFS 1.7.6

Location:
custom-field-suite/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • custom-field-suite/trunk/cfs.php

    r617367 r619694  
    33Plugin Name: Custom Field Suite
    44Plugin URI: https://uproot.us/
    5 Description: Really simple custom field management.
    6 Version: 1.7.5
     5Description: .
     6Version: 1.7.
    77Author: Matt Gibbs
    88Author URI: https://uproot.us/
     
    1111
    1212$cfs = new Cfs();
    13 $cfs->version = '1.7.5';
     13$cfs->version = '1.7.';
    1414
    1515class Cfs
     
    3737        $this->used_types = array();
    3838
     39
     40
     41
     42
    3943        // load the api
    40         include($this->dir . '/core/classes/api.php');
    4144        $this->api = new cfs_Api($this);
    4245
     
    7073    {
    7174        // perform upgrades
    72         include($this->dir . '/core/classes/upgrade.php');
    7375        $upgrade = new cfs_Upgrade($this->version);
    7476
     
    133135    function get_field_types()
    134136    {
    135         // include the parent field type
    136         include($this->dir . '/core/classes/field.php');
    137 
    138137        $field_types = array(
    139138            'text' => $this->dir . '/core/fields/text.php',
     
    312311    *-------------------------------------------------------------------------------------*/
    313312
    314     function get_reverse_related($post_id, $options = array(), $deprecated = array())
    315     {
    316         return $this->api->get_reverse_related($post_id, $options, $deprecated);
     313    function get_reverse_related($post_id, $options = array())
     314    {
     315        return $this->api->get_reverse_related($post_id, $options);
    317316    }
    318317
     
    532531            $ajax = new cfs_Ajax();
    533532
    534             if (method_exists($ajax, $ajax_method))
    535             {
    536                 $ajax->$ajax_method();
     533            if ('import' == $ajax_method)
     534            {
     535                $options = array(
     536                    'import_code' => json_decode(stripslashes($_POST['import_code'])),
     537                );
     538                echo $ajax->import($options);
     539            }
     540            elseif ('export' == $ajax_method)
     541            {
     542                echo json_encode($ajax->export($_POST));
     543            }
     544            elseif (method_exists($ajax, $ajax_method))
     545            {
     546                echo $ajax->$ajax_method($_POST);
    537547            }
    538548            exit;
  • custom-field-suite/trunk/core/actions/save_fields.php

    r601824 r619694  
    102102    if (!empty($cfs_rules[$type]))
    103103    {
     104
     105
     106
     107
     108
     109
    104110        $data[$type] = array(
    105111            'operator' => $cfs_rules['operator'][$type],
  • custom-field-suite/trunk/core/admin/meta_box_rules.php

    r604423 r619694  
    3737
    3838// Post IDs
    39 $sql = "
    40 SELECT ID, post_type, post_title
    41 FROM $wpdb->posts
    42 WHERE
    43     post_status IN ('publish', 'private') AND
    44     post_type NOT IN ('cfs', 'attachment', 'revision', 'nav_menu_item')
    45 ORDER BY post_type, post_title";
    46 $results = $wpdb->get_results($sql);
    47 
    48 foreach ($results as $result)
    49 {
    50     $post_ids[$result->ID] = "($result->post_type) $result->post_title";
     39$post_ids = array();
     40$rules_post_ids = '';
     41if (!empty($rules['post_ids']['values']))
     42{
     43    $rules_post_ids = implode(',', $rules['post_ids']['values']);
     44
     45    $sql = "
     46    SELECT ID, post_type, post_title
     47    FROM $wpdb->posts
     48    WHERE ID IN ($rules_post_ids)
     49    ORDER BY post_type, post_title";
     50    $results = $wpdb->get_results($sql);
     51    foreach ($results as $result)
     52    {
     53        $post_ids[] = array('id' => $result->ID, 'text' => "($result->post_type) $result->post_title");
     54    }
    5155}
    5256
     
    7882            placeholder: '<?php _e('Leave blank to skip this rule', 'cfs'); ?>'
    7983        });
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
    80113    });
    81114})(jQuery);
     
    165198        </td>
    166199        <td>
    167             <?php
    168                 $this->create_field(array(
    169                     'type' => 'select',
    170                     'input_class' => 'select2',
    171                     'input_name' => "cfs[rules][post_ids]",
    172                     'options' => array('multiple' => '1', 'choices' => $post_ids),
    173                     'value' => $rules['post_ids']['values'],
    174                 ));
    175             ?>
     200            <input type="hidden" name="cfs[rules][post_ids]" class="select2-ajax" value="<?php echo $rules_post_ids; ?>" style="width:99.95%" />
    176201        </td>
    177202    </tr>
  • custom-field-suite/trunk/core/admin/page_tools.php

    r617367 r619694  
    5555            });
    5656        });
    57 
    58         $('#button-sync').click(function() {
    59             var groups = $('#sync-field-groups').val();
    60             if (null != groups) {
    61                 $.post(ajaxurl, {
    62                     action: 'cfs_ajax_handler',
    63                     action_type: 'map_values',
    64                     field_groups: groups
    65                 },
    66                 function(response) {
    67                     $('#sync-message').html(response);
    68                 });
    69             }
    70         });
    7157    });
    7258})(jQuery);
     
    7864        <a class="nav-tab nav-tab-active" rel="export"><?php _e('Export', 'cfs'); ?></a>
    7965        <a class="nav-tab" rel="import"><?php _e('Import', 'cfs'); ?></a>
    80         <a class="nav-tab" rel="sync"><?php _e('Synchronize', 'cfs'); ?></a>
    8166        <a class="nav-tab" rel="debug"><?php _e('Debug', 'cfs'); ?></a>
    8267    </h2>
     
    134119        </div>
    135120
    136         <!-- Synchronize -->
    137 
    138         <div class="tab-content sync">
    139             <h2><?php _e('CFS will attempt to import custom field values.', 'cfs'); ?></h2>
    140             <table>
    141                 <tr>
    142                     <td style="width:300px; vertical-align:top">
    143                         <div>
    144                             <select id="sync-field-groups" style="width:300px; height:200px" multiple="multiple">
    145                                 <?php foreach ($results as $result) : ?>
    146                                 <option value="<?php echo $result->ID; ?>"><?php echo $result->post_title; ?></option>
    147                                 <?php endforeach; ?>
    148                             </select>
    149                         </div>
    150                         <div>
    151                             <input type="button" id="button-sync" class="button" value="<?php _e('Synchronize', 'cfs'); ?>" />
    152                         </div>
    153                     </td>
    154                     <td style="width:300px; vertical-align:top">
    155                         <div id="sync-message"></div>
    156                     </td>
    157                 </tr>
    158             </table>
    159         </div>
    160 
    161121        <!-- Debug Information -->
    162122
  • custom-field-suite/trunk/core/classes/ajax.php

    r617367 r619694  
    1212    *-------------------------------------------------------------------------------------*/
    1313
    14     public function search_posts()
    15     {
    16         global $wpdb;
    17 
    18 
     14    public function search_posts($options)
     15    {
     16        global $wpdb;
     17
     18        $keywords = $wpdb->escape($options['q']);
     19
     20        $sql = "
     21        SELECT ID, post_type, post_title
     22        FROM $wpdb->posts
     23        WHERE
     24            post_status IN ('publish', 'private') AND
     25            post_type NOT IN ('cfs', 'attachment', 'revision', 'nav_menu_item') AND
     26            post_title LIKE '%$keywords%'
     27        ORDER BY post_type, post_title
     28        LIMIT 10";
     29        $results = $wpdb->get_results($sql);
     30
     31        $output = array();
     32        foreach ($results as $result)
     33        {
     34            $output[] = array(
     35                'id' => $result->ID,
     36                'text' => "($result->post_type) $result->post_title"
     37            );
     38        }
     39        return json_encode($output);
    1940    }
    2041
     
    2950    *-------------------------------------------------------------------------------------*/
    3051
    31     public function export()
     52    public function export()
    3253    {
    3354        global $wpdb;
     
    3556        $post_ids = array();
    3657        $field_groups = array();
    37         foreach ($_POST['field_groups'] as $post_id)
     58        foreach ($['field_groups'] as $post_id)
    3859        {
    3960            $post_ids[] = (int) $post_id;
     
    6788        }
    6889
    69         echo json_encode($field_groups);
     90        ;
    7091    }
    7192
     
    80101    *-------------------------------------------------------------------------------------*/
    81102
    82     public function import()
    83     {
    84         global $wpdb;
    85 
    86         $code = json_decode(stripslashes($_POST['import_code']));
    87 
    88         if (!empty($code))
     103    public function import($options)
     104    {
     105        global $wpdb;
     106
     107        if (!empty($options['import_code']))
    89108        {
    90109            // Collect stats
     
    95114
    96115            // Loop through field groups
    97             foreach ($code as $group_id => $group)
     116            foreach ($ as $group_id => $group)
    98117            {
    99118                // Make sure this field group doesn't exist
     
    150169            }
    151170
     171
    152172            if (!empty($stats['imported']))
    153173            {
    154                 echo '<div>' . __('Imported', 'cfs') . ': ' . implode(', ', $stats['imported']) . '</div>';
     174                '<div>' . __('Imported', 'cfs') . ': ' . implode(', ', $stats['imported']) . '</div>';
    155175            }
    156176            if (!empty($stats['skipped']))
    157177            {
    158                 echo '<div>' . __('Skipped', 'cfs') . ': ' . implode(', ', $stats['skipped']) . '</div>';
    159             }
     178                $return .= '<div>' . __('Skipped', 'cfs') . ': ' . implode(', ', $stats['skipped']) . '</div>';
     179            }
     180            return $return;
    160181        }
    161182        else
    162183        {
    163             echo '<div>' . __('Nothing to import', 'cfs') . '</div>';
     184            '<div>' . __('Nothing to import', 'cfs') . '</div>';
    164185        }
    165186    }
     
    175196    *-------------------------------------------------------------------------------------*/
    176197
    177     public function map_values()
    178     {
    179         global $wpdb;
    180 
    181         if (isset($_POST['field_groups']))
    182         {
    183             $group_ids = (array) $_POST['field_groups'];
     198    public function map_values()
     199    {
     200        global $wpdb;
     201
     202        if (isset($['field_groups']))
     203        {
     204            $group_ids = (array) $['field_groups'];
    184205            foreach ($group_ids as $group_id)
    185206            {
     
    244265            }
    245266
    246             echo 'Sync successful';
     267            'Sync successful';
    247268        }
    248269        else
    249270        {
    250             echo '<div>' . __('No field groups selected', 'cfs') . '</div>';
     271            '<div>' . __('No field groups selected', 'cfs') . '</div>';
    251272        }
    252273    }
  • custom-field-suite/trunk/core/classes/api.php

    r614053 r619694  
    225225    *-------------------------------------------------------------------------------------*/
    226226
    227     public function get_reverse_related($post_id, $options = array(), $deprecated = array())
     227    public function get_reverse_related($post_id, $options = array())
    228228    {
    229229        global $wpdb;
    230 
    231         // Handle function signature change
    232         // ctype_digit returns FALSE for integer values between -128 and 255
    233         if (!is_numeric($post_id))
    234         {
    235             // old signature: $field_name, $post_id, $options
    236             $old_post_id = $options;
    237             $options = $deprecated;
    238             $options['field_name'] = $post_id;
    239             $post_id = $old_post_id;
    240 
    241             // Trigger a deprecated function signature error
    242             trigger_error('The function signature for $cfs->get_reverse_related has changed. Please see the documentation.');
    243         }
    244230
    245231        $where = "m.meta_value = '$post_id'";
  • custom-field-suite/trunk/readme.txt

    r617371 r619694  
    22Contributors: logikal16
    33Donate link: https://uproot.us/contributors/
    4 Tags: custom fields, custom field, fields, post meta, cck, wysiwyg, relationship, loop, file upload
     4Tags: custom fields, upload
    55Requires at least: 3.2
    66Tested up to: 3.5
    77Stable tag: trunk
     8
    89
    9 Really simple custom field management.
     10.
    1011
    1112== Description ==
    1213
    13 Create groups of custom fields, then choose which edit screens to appear on. Each field group has its own meta box, allowing for plenty of customization. CFS includes a lightweight API for displaying custom fields throughout your site.
     14Custom Field Suite (CFS) lets you create groups of custom fields, and assign edit screens for each field group to appear on. Then, simply add `$cfs->get('your_field')` into your templates to display custom field values throughout your site.
     15
     16= Why use Custom Field Suite? =
     17* CFS is super easy to use.
     18* CFS is stable. We test all changes before releasing a new version.
     19* CFS is fast and uses minimal server resources.
     20* CFS has [full documentation](https://uproot.us/custom-field-suite/documentation/) and [support forums](https://uproot.us/forums/).
     21* CFS works well with [Gravity Forms](https://uproot.us/how-to-save-gravity-forms-data-into-custom-field-suite/) by saving Gravity Forms entries as post items.
     22* CFS supports [adding your own field types](http://uproot.us/custom-field-suite/docs/custom-field-type/).
     23* [CFS is on GitHub!](https://github.com/logikal16/custom-field-suite/)
    1424
    1525**CFS is a fork of Advanced Custom Fields.** The main goals of this plugin are stability, performance, and avoiding feature bloat.
    1626
    17 = Why use Custom Field Suite? =
    18 * CFS is easy to use. You and your clients will LOVE it!
    19 * CFS is stable. We test all changes before releasing a new version.
    20 * CFS is fast and uses minimal server resources.
    21 * CFS has [full documentation](https://uproot.us/custom-field-suite/documentation/) and [support forums](https://uproot.us/forums/).
    22 * CFS works well with [Gravity Forms](https://uproot.us/how-to-save-gravity-forms-data-into-custom-field-suite/). It can save GF entries as post items.
    23 * CFS supports [adding your own field types](http://uproot.us/custom-field-suite/docs/custom-field-type/).
    24 * [We're on GitHub!](https://github.com/logikal16/custom-field-suite/)
    25 
    26 = Field Types =
    27 * [Text](https://uproot.us/docs/text/)
    28 * [Textarea](https://uproot.us/docs/textarea/)
    29 * [Wysiwyg Editor](https://uproot.us/docs/wysiwyg/)
    30 * [Date](https://uproot.us/docs/date/)
    31 * [Color](https://uproot.us/docs/color/)
    32 * [True / False](https://uproot.us/docs/true-false/)
    33 * [Select](https://uproot.us/docs/select/)
    34 * [File Upload](https://uproot.us/docs/file-upload/)
    35 * [User](https://uproot.us/docs/user/)
    36 * [Relationship](https://uproot.us/docs/relationship/)
    37 * [Loop](https://uproot.us/docs/loop/)
    38 
    39 = More Features =
     27= Features =
     28* Field types include [text](https://uproot.us/docs/text/), [textarea](https://uproot.us/docs/textarea/), [wysiwyg](https://uproot.us/docs/wysiwyg/), [date](https://uproot.us/docs/date/), [color](https://uproot.us/docs/color/), [select](https://uproot.us/docs/select/), [file upload](https://uproot.us/docs/file-upload/), [user](https://uproot.us/docs/user/), [relationship](https://uproot.us/docs/relationship/), and [loop](https://uproot.us/docs/loop/)
    4029* Field validation
    4130* Drag-and-drop field management
    42 * Loop fields support unlimited nesting!
     31* Loop fields support unlimited nesting
    4332* Placement Rules let you choose where each field group appears
    44 * Sync feature for importing meta values into existing field groups
    4533
    4634= Documentation and Support =
     
    6149
    6250== Changelog ==
     51
     52
     53
     54
     55
     56
    6357
    6458= 1.7.5 =
Note: See TracChangeset for help on using the changeset viewer.