Changeset 619694
- Timestamp:
- 11/01/2012 01:48:55 AM (12 years ago)
- Location:
- custom-field-suite/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
custom-field-suite/trunk/cfs.php
r617367 r619694 3 3 Plugin Name: Custom Field Suite 4 4 Plugin URI: https://uproot.us/ 5 Description: Really simple custom field management.6 Version: 1.7. 55 Description: . 6 Version: 1.7. 7 7 Author: Matt Gibbs 8 8 Author URI: https://uproot.us/ … … 11 11 12 12 $cfs = new Cfs(); 13 $cfs->version = '1.7. 5';13 $cfs->version = '1.7.'; 14 14 15 15 class Cfs … … 37 37 $this->used_types = array(); 38 38 39 40 41 42 39 43 // load the api 40 include($this->dir . '/core/classes/api.php');41 44 $this->api = new cfs_Api($this); 42 45 … … 70 73 { 71 74 // perform upgrades 72 include($this->dir . '/core/classes/upgrade.php');73 75 $upgrade = new cfs_Upgrade($this->version); 74 76 … … 133 135 function get_field_types() 134 136 { 135 // include the parent field type136 include($this->dir . '/core/classes/field.php');137 138 137 $field_types = array( 139 138 'text' => $this->dir . '/core/fields/text.php', … … 312 311 *-------------------------------------------------------------------------------------*/ 313 312 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); 317 316 } 318 317 … … 532 531 $ajax = new cfs_Ajax(); 533 532 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); 537 547 } 538 548 exit; -
custom-field-suite/trunk/core/actions/save_fields.php
r601824 r619694 102 102 if (!empty($cfs_rules[$type])) 103 103 { 104 105 106 107 108 109 104 110 $data[$type] = array( 105 111 'operator' => $cfs_rules['operator'][$type], -
custom-field-suite/trunk/core/admin/meta_box_rules.php
r604423 r619694 37 37 38 38 // 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 = ''; 41 if (!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 } 51 55 } 52 56 … … 78 82 placeholder: '<?php _e('Leave blank to skip this rule', 'cfs'); ?>' 79 83 }); 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 80 113 }); 81 114 })(jQuery); … … 165 198 </td> 166 199 <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%" /> 176 201 </td> 177 202 </tr> -
custom-field-suite/trunk/core/admin/page_tools.php
r617367 r619694 55 55 }); 56 56 }); 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: groups65 },66 function(response) {67 $('#sync-message').html(response);68 });69 }70 });71 57 }); 72 58 })(jQuery); … … 78 64 <a class="nav-tab nav-tab-active" rel="export"><?php _e('Export', 'cfs'); ?></a> 79 65 <a class="nav-tab" rel="import"><?php _e('Import', 'cfs'); ?></a> 80 <a class="nav-tab" rel="sync"><?php _e('Synchronize', 'cfs'); ?></a>81 66 <a class="nav-tab" rel="debug"><?php _e('Debug', 'cfs'); ?></a> 82 67 </h2> … … 134 119 </div> 135 120 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 161 121 <!-- Debug Information --> 162 122 -
custom-field-suite/trunk/core/classes/ajax.php
r617367 r619694 12 12 *-------------------------------------------------------------------------------------*/ 13 13 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); 19 40 } 20 41 … … 29 50 *-------------------------------------------------------------------------------------*/ 30 51 31 public function export( )52 public function export() 32 53 { 33 54 global $wpdb; … … 35 56 $post_ids = array(); 36 57 $field_groups = array(); 37 foreach ($ _POST['field_groups'] as $post_id)58 foreach ($['field_groups'] as $post_id) 38 59 { 39 60 $post_ids[] = (int) $post_id; … … 67 88 } 68 89 69 echo json_encode($field_groups);90 ; 70 91 } 71 92 … … 80 101 *-------------------------------------------------------------------------------------*/ 81 102 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'])) 89 108 { 90 109 // Collect stats … … 95 114 96 115 // Loop through field groups 97 foreach ($ codeas $group_id => $group)116 foreach ($ as $group_id => $group) 98 117 { 99 118 // Make sure this field group doesn't exist … … 150 169 } 151 170 171 152 172 if (!empty($stats['imported'])) 153 173 { 154 echo'<div>' . __('Imported', 'cfs') . ': ' . implode(', ', $stats['imported']) . '</div>';174 '<div>' . __('Imported', 'cfs') . ': ' . implode(', ', $stats['imported']) . '</div>'; 155 175 } 156 176 if (!empty($stats['skipped'])) 157 177 { 158 echo '<div>' . __('Skipped', 'cfs') . ': ' . implode(', ', $stats['skipped']) . '</div>'; 159 } 178 $return .= '<div>' . __('Skipped', 'cfs') . ': ' . implode(', ', $stats['skipped']) . '</div>'; 179 } 180 return $return; 160 181 } 161 182 else 162 183 { 163 echo'<div>' . __('Nothing to import', 'cfs') . '</div>';184 '<div>' . __('Nothing to import', 'cfs') . '</div>'; 164 185 } 165 186 } … … 175 196 *-------------------------------------------------------------------------------------*/ 176 197 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']; 184 205 foreach ($group_ids as $group_id) 185 206 { … … 244 265 } 245 266 246 echo'Sync successful';267 'Sync successful'; 247 268 } 248 269 else 249 270 { 250 echo'<div>' . __('No field groups selected', 'cfs') . '</div>';271 '<div>' . __('No field groups selected', 'cfs') . '</div>'; 251 272 } 252 273 } -
custom-field-suite/trunk/core/classes/api.php
r614053 r619694 225 225 *-------------------------------------------------------------------------------------*/ 226 226 227 public function get_reverse_related($post_id, $options = array() , $deprecated = array())227 public function get_reverse_related($post_id, $options = array()) 228 228 { 229 229 global $wpdb; 230 231 // Handle function signature change232 // ctype_digit returns FALSE for integer values between -128 and 255233 if (!is_numeric($post_id))234 {235 // old signature: $field_name, $post_id, $options236 $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 error242 trigger_error('The function signature for $cfs->get_reverse_related has changed. Please see the documentation.');243 }244 230 245 231 $where = "m.meta_value = '$post_id'"; -
custom-field-suite/trunk/readme.txt
r617371 r619694 2 2 Contributors: logikal16 3 3 Donate link: https://uproot.us/contributors/ 4 Tags: custom fields, custom field, fields, post meta, cck, wysiwyg, relationship, loop, fileupload4 Tags: custom fields, upload 5 5 Requires at least: 3.2 6 6 Tested up to: 3.5 7 7 Stable tag: trunk 8 8 9 9 Really simple custom field management.10 . 10 11 11 12 == Description == 12 13 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. 14 Custom 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/) 14 24 15 25 **CFS is a fork of Advanced Custom Fields.** The main goals of this plugin are stability, performance, and avoiding feature bloat. 16 26 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/) 40 29 * Field validation 41 30 * Drag-and-drop field management 42 * Loop fields support unlimited nesting !31 * Loop fields support unlimited nesting 43 32 * Placement Rules let you choose where each field group appears 44 * Sync feature for importing meta values into existing field groups45 33 46 34 = Documentation and Support = … … 61 49 62 50 == Changelog == 51 52 53 54 55 56 63 57 64 58 = 1.7.5 =
Note: See TracChangeset
for help on using the changeset viewer.