Toolset Types – Custom Post Types, Custom Fields and Taxonomies - Version 1.6.6

Version Description

  • Fixed problem with shortcode "playlist" used in WYSIWYG field. http://wp-types.com/forums/topic/media-play-list-not-outputting-from-custom-wysiwyg-field-js-error/
  • Fixed empty title problem for filter "wpt_field_options" on user edit/add screen https://wp-types.com/forums/topic/populate-select-field-in-wpcf-um-group/
  • Added ability to create CPT without title and editor. https://wp-types.com/forums/topic/inaccurate-warning-message-when-creatingediting-a-cpt/
  • Added Skype field validation.
  • Fixed problem with loading custom CSS when user meta group is inactive or not assign to certain user role.
  • Added ability to add to menu link to archive of post type.
  • Added ability to setup meta box callback function. https://wp-types.com/forums/topic/add-support-for-meta_box_cb-in-custom-taxonomy/
  • Added ability to add HTML5 placeholder attribute for custom post fields.
  • Fixed problem with CPT labels. https://wp-types.com/forums/topic/after-save-cpts-cutom-labels-always-revert-to-default-label/
  • Added a filters to the post title as option text in the select dropdown for post parents. wpcf_pr_belongs_items for array of options and wpcf_pr_belongs_item for one option. https://wp-types.com/forums/topic/help-to-distinguish-duplicate-titles-in-post-relationship/
  • Added ability to choose custom fields to display it on custom posts admin list.
  • Fixed problem with saving parent data into child data. On parent edit screen.
  • Added check group name for Custom Fields and User Fields.
  • Fixed missing "Edit" button on group edit screen when we close custom logic form.
Download this release

Release Info

Developer iworks
Plugin Icon 128x128 Toolset Types – Custom Post Types, Custom Fields and Taxonomies
Version 1.6.6
Comparing to
See all releases

Code changes from version 1.6.5.1 to 1.6.6

Files changed (198) hide show
  1. admin.php +150 -80
  2. classes/class.wpcf-marketing-messages.php +21 -15
  3. classes/class.wpcf-marketing-tutorial.php +3 -3
  4. classes/class.wpcf-marketing.php +3 -3
  5. embedded/admin.php +32 -21
  6. embedded/bootstrap.php +10 -8
  7. embedded/classes/class.wpcf-post-types.php +234 -3
  8. embedded/classes/editor.php +2 -4
  9. embedded/classes/field.php +67 -61
  10. embedded/classes/fields.php +1 -1
  11. embedded/classes/forms.php +16 -8
  12. embedded/classes/loader.php +20 -17
  13. embedded/classes/path.php +1 -1
  14. embedded/classes/post-types/messages.php +1 -1
  15. embedded/classes/relationship.php +23 -12
  16. embedded/classes/relationship/form-child.php +16 -4
  17. embedded/classes/repeater.php +58 -55
  18. embedded/classes/usermeta_field.php +13 -15
  19. embedded/classes/usermeta_repeater.php +46 -43
  20. embedded/classes/validate.php +24 -1
  21. embedded/classes/validation-cakephp.php +23 -0
  22. embedded/common/changelog.txt +14 -1
  23. embedded/common/classes/class.toolset.promo.php +197 -0
  24. embedded/common/classes/forms.php +9 -7
  25. embedded/common/debug/debug-information.php +1 -1
  26. embedded/common/debug/functions_debug_information.php +20 -15
  27. embedded/common/expression-parser/js/parser.js +14 -14
  28. embedded/common/expression-parser/parser.php +15 -15
  29. embedded/common/functions.php +14 -80
  30. embedded/common/res/css/colorbox.css +88 -0
  31. embedded/common/res/css/toolset-promotion.css +155 -0
  32. embedded/common/res/images/toolset.promotion/full.jpg +0 -0
  33. embedded/common/res/images/toolset.promotion/icons.png +0 -0
  34. embedded/common/res/js/jquery.colorbox-min.js +7 -0
  35. embedded/common/res/js/toolset-promotion.js +47 -0
  36. embedded/common/toolset-forms/api.php +19 -17
  37. embedded/common/toolset-forms/bootstrap.php +164 -125
  38. embedded/common/toolset-forms/classes/class.audio.php +1 -1
  39. embedded/common/toolset-forms/classes/class.checkbox.php +1 -1
  40. embedded/common/toolset-forms/classes/class.checkboxes.php +1 -1
  41. embedded/common/toolset-forms/classes/class.colorpicker.php +22 -18
  42. embedded/common/toolset-forms/classes/class.conditional.php +5 -1
  43. embedded/common/toolset-forms/classes/class.credaudio.php +1 -1
  44. embedded/common/toolset-forms/classes/class.credfile.php +1 -1
  45. embedded/common/toolset-forms/classes/class.credimage.php +1 -1
  46. embedded/common/toolset-forms/classes/class.credvideo.php +1 -1
  47. embedded/common/toolset-forms/classes/class.date.php +17 -7
  48. embedded/common/toolset-forms/classes/class.date.scripts.php +9 -0
  49. embedded/common/toolset-forms/classes/class.eforms.php +7 -5
  50. embedded/common/toolset-forms/classes/class.field_factory.php +18 -4
  51. embedded/common/toolset-forms/classes/class.fieldconfig.php +1 -1
  52. embedded/common/toolset-forms/classes/class.file.php +36 -18
  53. embedded/common/toolset-forms/classes/class.form_factory.php +11 -5
  54. embedded/common/toolset-forms/classes/class.image.php +1 -1
  55. embedded/common/toolset-forms/classes/class.radios.php +12 -4
  56. embedded/common/toolset-forms/classes/class.recaptcha.php +1 -1
  57. embedded/common/toolset-forms/classes/class.repetitive.php +1 -1
  58. embedded/common/toolset-forms/classes/class.select.php +14 -5
  59. embedded/common/toolset-forms/classes/class.skype.php +31 -22
  60. embedded/common/toolset-forms/classes/class.submit.php +4 -4
  61. embedded/common/toolset-forms/classes/class.taxonomy.php +4 -29
  62. embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php +91 -104
  63. embedded/common/toolset-forms/classes/class.textarea.php +1 -1
  64. embedded/common/toolset-forms/classes/class.textfield.php +4 -6
  65. embedded/common/toolset-forms/classes/class.types.php +6 -3
  66. embedded/common/toolset-forms/classes/class.validation.php +8 -4
  67. embedded/common/toolset-forms/classes/class.video.php +1 -1
  68. embedded/common/toolset-forms/classes/class.wysiwyg.php +1 -1
  69. embedded/common/toolset-forms/css/wpt-toolset-frontend.css +7 -30
  70. embedded/common/toolset-forms/external/autocompleter.php +0 -53
  71. embedded/common/toolset-forms/js/conditional.js +122 -16
  72. embedded/common/toolset-forms/js/date.js +1 -1
  73. embedded/common/toolset-forms/js/file-wp35.js +98 -0
  74. embedded/common/toolset-forms/js/file.js +0 -68
  75. embedded/common/toolset-forms/js/jquery.autocomplete.js +0 -507
  76. embedded/common/toolset-forms/js/main.js +167 -150
  77. embedded/common/toolset-forms/js/repetitive.js +1 -1
  78. embedded/common/toolset-forms/js/skype.js +2 -2
  79. embedded/common/toolset-forms/js/validation.js +24 -17
  80. embedded/common/toolset-forms/lib/CakePHP-Validation.php +7 -8
  81. embedded/common/toolset-forms/readme.txt +11 -0
  82. embedded/common/toolset-forms/templates/metaform-item.php +26 -25
  83. embedded/common/toolset-forms/templates/metaform.php +1 -1
  84. embedded/common/toolset-forms/test.php +0 -36
  85. embedded/common/utility/css/notifications.css +41 -43
  86. embedded/common/utility/css/select2/select2.css +147 -54
  87. embedded/common/utility/img/icon-help-message.png +0 -0
  88. embedded/common/utility/js/keyboard.js +961 -0
  89. embedded/common/utility/js/keyboard.min.js +1 -0
  90. embedded/common/utility/js/select2.min.js +5 -4
  91. embedded/common/views/promote.php +0 -93
  92. embedded/common/views/res/img/views-32.png +0 -0
  93. embedded/common/visual-editor/editor-addon.class.php +62 -60
  94. embedded/common/visual-editor/res/js/icl_editor_addon_plugin.js +68 -33
  95. embedded/common/wplogger.php +6 -6
  96. embedded/frontend.php +64 -17
  97. embedded/functions.php +10 -47
  98. embedded/includes/ajax.php +166 -97
  99. embedded/includes/api.php +3 -2
  100. embedded/includes/classes/class.types.data.installer.php +268 -0
  101. embedded/includes/custom-taxonomies.php +19 -5
  102. embedded/includes/custom-types.php +65 -32
  103. embedded/includes/editor-support/post-relationship-editor-support.php +0 -4
  104. embedded/includes/examples/google_map.php +12 -0
  105. embedded/includes/fields-post.php +10 -14
  106. embedded/includes/fields.php +41 -30
  107. embedded/includes/fields/audio.php +1 -1
  108. embedded/includes/fields/checkbox.php +1 -1
  109. embedded/includes/fields/date.php +11 -11
  110. embedded/includes/fields/date/calendar.php +12 -6
  111. embedded/includes/fields/date/functions.php +13 -30
  112. embedded/includes/fields/embed.php +14 -11
  113. embedded/includes/fields/file.php +21 -84
  114. embedded/includes/fields/image.php +46 -72
  115. embedded/includes/fields/skype.php +9 -4
  116. embedded/includes/fields/textarea.php +1 -1
  117. embedded/includes/fields/video.php +11 -6
  118. embedded/includes/fields/wysiwyg.php +15 -5
  119. embedded/includes/import-export.php +55 -21
  120. embedded/includes/module-manager.php +11 -8
  121. embedded/includes/post-relationship.php +72 -20
  122. embedded/includes/relationship/child-table.php +6 -2
  123. embedded/includes/usermeta-add-user.php +1 -2
  124. embedded/includes/usermeta-post.php +1 -0
  125. embedded/includes/usermeta.php +6 -8
  126. embedded/includes/wpml.php +76 -68
  127. embedded/models/relationship.php +31 -29
  128. embedded/onthego-resources/loader.php +1 -2
  129. embedded/onthego-resources/onthego-styles/onthego-admin-styles.css +9 -0
  130. embedded/onthego-resources/onthego-styles/onthego-colors.css +1 -1
  131. embedded/onthego-resources/onthegosystems-icons/.fontcustom-manifest.json +32 -24
  132. embedded/onthego-resources/onthegosystems-icons/css/_onthegosystems-icons.scss +10 -6
  133. embedded/onthego-resources/onthegosystems-icons/css/onthegosystems-icons.css +10 -6
  134. embedded/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons-preview.html +37 -7
  135. embedded/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.woff +0 -0
  136. embedded/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.eot → onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.eot} +0 -0
  137. embedded/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.svg → onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.svg} +13 -7
  138. embedded/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.ttf → onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.ttf} +0 -0
  139. embedded/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.woff +0 -0
  140. embedded/onthego-resources/onthegosystems-icons/vectors/packager-logo.svg +14 -0
  141. embedded/onthego-resources/onthegosystems-icons/vectors/packager.svg +9 -0
  142. embedded/onthego-resources/onthegosystems-icons/vectors/{wpml logo.svg → wpml-logo.svg} +0 -0
  143. embedded/plugin.php +6 -6
  144. embedded/readme.txt +9 -0
  145. embedded/resources/css/basic.css +13 -2
  146. embedded/resources/css/colorbox.css +2 -2
  147. embedded/resources/css/dashicons.css +1 -1
  148. embedded/resources/css/usermeta.css +3 -3
  149. embedded/resources/js/basic.js +26 -17
  150. embedded/resources/js/fields-form.js +27 -13
  151. embedded/resources/js/fields-post.js +3 -1
  152. embedded/resources/js/post-relationship.js +9 -7
  153. embedded/usermeta-init.php +87 -79
  154. embedded/views/image.php +4 -2
  155. embedded/views/templates/editor-modal-checkbox.tpl.php +3 -3
  156. embedded/views/templates/editor-modal-checkboxes.tpl.php +3 -3
  157. embedded/views/templates/editor-modal-date.tpl.php +0 -4
  158. help.php +1 -1
  159. includes/ajax.php +62 -34
  160. includes/classes/class.wpcf.custom.fields.list.table.php +486 -0
  161. includes/classes/class.wpcf.custom.post.types.list.table.php +468 -0
  162. includes/classes/class.wpcf.custom.taxonomies.list.table.php +466 -0
  163. includes/classes/class.wpcf.user.fields.list.table.php +475 -0
  164. includes/common-functions.php +1 -1
  165. includes/conditional-display.php +16 -5
  166. includes/custom-taxonomies-form.php +77 -28
  167. includes/custom-types-form.php +72 -49
  168. includes/custom-types-taxonomies-list.php +40 -109
  169. includes/fields-control.php +58 -22
  170. includes/fields-form.php +185 -256
  171. includes/fields-list.php +20 -98
  172. includes/fields.php +157 -54
  173. includes/fields/checkbox.php +6 -0
  174. includes/fields/checkboxes.php +11 -5
  175. includes/fields/radio.php +10 -6
  176. includes/fields/select.php +8 -5
  177. includes/import-export.php +21 -15
  178. includes/migration.php +28 -33
  179. includes/post-relationship.php +191 -178
  180. includes/settings.php +2 -17
  181. includes/usermeta-control.php +61 -26
  182. includes/usermeta-form.php +163 -156
  183. includes/usermeta-list.php +18 -70
  184. includes/usermeta.php +49 -15
  185. marketing/helpful-links.php +9 -2
  186. plus/installer/changelog.txt +10 -3
  187. plus/installer/includes/deps-loader.class.php +0 -558
  188. plus/installer/includes/installer.class.php +300 -80
  189. plus/installer/installer.php +1 -2
  190. plus/installer/loader.php +10 -2
  191. plus/installer/res/css/admin.css +10 -0
  192. plus/installer/res/js/admin.js +22 -0
  193. plus/installer/res/js/iframeResizer.min.js +10 -10
  194. plus/types-access.php +5 -5
  195. plus/types-access/includes/admin-edit-access.php +27 -27
  196. readme.txt +30 -11
  197. resources/css/basic.css +0 -6
  198. resources/js/basic.js +1 -1
admin.php CHANGED
@@ -3,9 +3,9 @@
3
  *
4
  * Admin functions
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/admin.php $
7
- * $LastChangedDate: 2015-02-04 13:43:06 +0000 (Wed, 04 Feb 2015) $
8
- * $LastChangedRevision: 1082328 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
@@ -29,13 +29,19 @@ if ( defined( 'DOING_AJAX' ) ) {
29
  include_once WPCF_ABSPATH.'/classes/class.wpcf-marketing-messages.php';
30
  new WPCF_Types_Marketing_Messages();
31
 
 
 
 
 
 
 
 
32
  /**
33
  * admin_init hook.
34
  */
35
  function wpcf_admin_init_hook()
36
  {
37
  wp_register_style('wpcf-css-embedded', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION );
38
- wp_register_style('wpcf-css', WPCF_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
39
 
40
  wp_enqueue_style( 'wpcf-promo-tabs', WPCF_EMBEDDED_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION );
41
  wp_enqueue_style('toolset-dashicons');
@@ -59,38 +65,38 @@ function wpcf_admin_menu_hook()
59
 
60
  $subpages = array();
61
 
62
- // Custom types and tax
 
 
 
 
 
 
63
  $subpages['wpcf-ctt'] = array(
64
- 'page_title' => __( 'Custom Types and Taxonomies', 'wpcf' ),
65
- 'menu_title' => __( 'Types & Taxonomies', 'wpcf' ),
66
  'function' => 'wpcf_admin_menu_summary_ctt',
67
  );
68
 
69
  // Custom fields
70
  $subpages['wpcf-cf'] = array(
71
- 'page_title' => __( 'Custom Fields', 'wpcf' ),
72
  'menu_title' => __( 'Custom Fields', 'wpcf' ),
73
  'function' => 'wpcf_admin_menu_summary',
74
  );
75
 
76
  // Custom Fields Control
77
  $subpages['wpcf-custom-fields-control'] = array(
78
- 'page_title' => __( 'Custom Fields Control', 'wpcf' ),
79
  'menu_title' => __( 'Custom Fields Control', 'wpcf' ),
80
  'function' => 'wpcf_admin_menu_custom_fields_control',
81
  );
82
 
83
  // User Meta
84
  $subpages['wpcf-um'] = array(
85
- 'page_title' => __( 'User Fields', 'wpcf' ),
86
  'menu_title' => __( 'User Fields', 'wpcf' ),
87
  'function' => 'wpcf_usermeta_summary',
88
- 'load_hook' => 'wpcf_admin_menu_summary_hook',
89
  );
90
 
91
  // User Fields Control
92
  $subpages['wpcf-user-fields-control'] = array(
93
- 'page_title' => __( 'User Fields Control', 'wpcf' ),
94
  'menu_title' => __( 'User Fields Control', 'wpcf' ),
95
  'function' => 'wpcf_admin_menu_user_fields_control',
96
  );
@@ -100,19 +106,16 @@ function wpcf_admin_menu_hook()
100
 
101
  // Import/Export
102
  $subpages['wpcf-import-export'] = array(
103
- 'page_title' => __( 'Import/Export', 'wpcf' ),
104
  'menu_title' => __( 'Import/Export', 'wpcf' ),
105
  'function' => 'wpcf_admin_menu_import_export',
106
  );
107
 
108
  // Settings
109
  $subpages['wpcf-custom-settings'] = array(
110
- 'page_title' => __( 'Settings', 'wpcf' ),
111
  'menu_title' => __( 'Settings', 'wpcf' ),
112
  'function' => 'wpcf_admin_menu_settings',
113
  'submenu' => array(
114
  'wpcf-debug-information' => array(
115
- 'page_title' => __( 'Debug Information', 'wpcf' ),
116
  'menu_title' => __( 'Debug Information', 'wpcf' ),
117
  'function' => 'wpcf_admin_menu_debug_information',
118
  ),
@@ -190,6 +193,16 @@ function wpcf_admin_menu_debug_information()
190
  require_once WPCF_EMBEDDED_ABSPATH.'/common/debug/debug-information.php';
191
  }
192
 
 
 
 
 
 
 
 
 
 
 
193
  /**
194
  * Menu page hook.
195
  */
@@ -197,6 +210,7 @@ function wpcf_admin_menu_summary_hook()
197
  {
198
  do_action( 'wpcf_admin_page_init' );
199
  wpcf_admin_load_collapsible();
 
200
  }
201
 
202
  /**
@@ -204,16 +218,19 @@ function wpcf_admin_menu_summary_hook()
204
  */
205
  function wpcf_admin_menu_summary()
206
  {
207
- echo wpcf_add_admin_header( __( 'Custom Fields', 'wpcf' ) );
 
 
 
 
208
  require_once WPCF_INC_ABSPATH . '/fields.php';
209
  require_once WPCF_INC_ABSPATH . '/fields-list.php';
210
  $to_display = wpcf_admin_fields_get_fields();
211
  if ( !empty( $to_display ) ) {
212
- add_action( 'wpcf_groups_list_table_after',
213
- 'wpcf_admin_promotional_text' );
214
  }
215
  wpcf_admin_fields_list();
216
- echo wpcf_add_admin_footer();
217
  }
218
 
219
  /**
@@ -293,69 +310,84 @@ function wpcf_admin_menu_edit_fields()
293
  } else {
294
  $title = __( 'Add New Group', 'wpcf' );
295
  }
296
- echo wpcf_add_admin_header( $title );
297
  wpcf_wpml_warning();
298
  $form = wpcf_form( 'wpcf_form_fields' );
 
 
 
 
 
 
 
299
 
300
- ?>
301
- <script type="text/javascript">
302
- function wpcf_group_submit()
303
- {
304
- if (jQuery('#wpcf-group-name').val() == "<?php echo addslashes(__('Enter group title', 'wpcf')); ?>") {
305
- jQuery('#wpcf-group-name').val('');
306
- }
307
- if (jQuery('#wpcf-group-description').val() == "<?php echo addslashes(__('Enter a description for this group', 'wpcf')); ?>") {
308
- jQuery('#wpcf-group-description').val('');
309
- }
310
- jQuery('.wpcf-forms-set-legend').each(function () {
311
- if (jQuery(this).val() == "<?php echo addslashes(__('Enter field name', 'wpcf')); ?>") {
312
- jQuery(this).val('');
313
- }
314
- if (jQuery(this).next().val() == "<?php echo addslashes(__('Enter field slug', 'wpcf')); ?>") {
315
- jQuery(this).next().val('');
316
- }
317
- if (jQuery(this).next().next().val() == "<?php echo addslashes(__('Describe this field', 'wpcf')); ?>") {
318
- jQuery(this).next().next().val('');
319
- }
320
- });
321
- }
322
- </script>
323
-
324
- <br /><form method="post" action="" class="wpcf-fields-form wpcf-form-validate" onsubmit="wpcf_group_submit()">
325
- <?php echo $form->renderForm(); ?>
326
- </form>
327
- <?php
328
- echo wpcf_add_admin_footer();
329
  }
330
 
331
- /**
332
- * Menu page hook.
333
- */
334
- function wpcf_admin_menu_summary_ctt_hook()
335
  {
336
  do_action( 'wpcf_admin_page_init' );
337
- wp_enqueue_style( 'wpcf-promo-tabs', WPCF_RES_RELPATH . '/css/tabs.css',
338
- array(), WPCF_VERSION );
339
  wpcf_admin_load_collapsible();
340
  require_once WPCF_INC_ABSPATH . '/custom-types.php';
341
  require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
342
  require_once WPCF_INC_ABSPATH . '/custom-types-taxonomies-list.php';
343
  }
344
 
 
 
 
 
 
 
 
 
 
345
  /**
346
  * Menu page display.
347
  */
348
- function wpcf_admin_menu_summary_ctt()
349
  {
350
- echo wpcf_add_admin_header( __( 'Custom Post Types and Taxonomies', 'wpcf' ) );
 
 
 
 
351
  $to_display_posts = get_option( 'wpcf-custom-types', array() );
352
  $to_display_tax = get_option( 'wpcf-custom-taxonomies', array() );
353
  if ( !empty( $to_display_posts ) || !empty( $to_display_tax ) ) {
354
- add_action( 'wpcf_types_tax_list_table_after',
355
- 'wpcf_admin_promotional_text' );
356
  }
357
- wpcf_admin_ctt_list();
358
- echo wpcf_add_admin_footer();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
359
  }
360
 
361
  /**
@@ -402,14 +434,14 @@ function wpcf_admin_menu_edit_type()
402
  } else {
403
  $title = __( 'Add New Custom Post Type', 'wpcf' );
404
  }
405
- echo wpcf_add_admin_header( $title );
406
  wpcf_wpml_warning();
407
  $form = wpcf_form( 'wpcf_form_types' );
408
  echo '<br /><form method="post" action="" class="wpcf-types-form '
409
  . 'wpcf-form-validate">';
410
  echo $form->renderForm();
411
  echo '</form>';
412
- echo wpcf_add_admin_footer();
413
  }
414
 
415
  /**
@@ -451,14 +483,14 @@ function wpcf_admin_menu_edit_tax()
451
  } else {
452
  $title = __( 'Add New Taxonomy', 'wpcf' );
453
  }
454
- echo wpcf_add_admin_header( $title );
455
  wpcf_wpml_warning();
456
  $form = wpcf_form( 'wpcf_form_tax' );
457
  echo '<br /><form method="post" action="" class="wpcf-tax-form '
458
  . 'wpcf-form-validate">';
459
  echo $form->renderForm();
460
  echo '</form>';
461
- echo wpcf_add_admin_footer();
462
  }
463
 
464
  /**
@@ -481,12 +513,12 @@ function wpcf_admin_menu_import_export_hook()
481
  */
482
  function wpcf_admin_menu_import_export()
483
  {
484
- echo wpcf_add_admin_header( __( 'Import/Export', 'wpcf' ) );
485
  echo '<br /><form method="post" action="" class="wpcf-import-export-form '
486
  . 'wpcf-form-validate" enctype="multipart/form-data">';
487
  echo wpcf_form_simple( wpcf_admin_import_export_form() );
488
  echo '</form>';
489
- echo wpcf_add_admin_footer();
490
  }
491
 
492
  /**
@@ -505,7 +537,7 @@ function wpcf_admin_menu_custom_fields_control_hook()
505
  && wp_verify_nonce( $_REQUEST['_wpnonce'],
506
  'custom_fields_control_bulk' )
507
  && (isset( $_POST['action'] ) || isset( $_POST['action2'] )) && !empty( $_POST['fields'] ) ) {
508
- $action = $_POST['action'] == '-1' ? $_POST['action2'] : $_POST['action'];
509
  wpcf_admin_custom_fields_control_bulk_actions( $action );
510
  }
511
 
@@ -524,13 +556,13 @@ function wpcf_admin_menu_custom_fields_control_hook()
524
  function wpcf_admin_menu_custom_fields_control()
525
  {
526
  global $wpcf_control_table;
527
- echo wpcf_add_admin_header( __( 'Custom Fields Control', 'wpcf' ) );
528
  echo '<form method="post" action="" id="wpcf-custom-fields-control-form" class="wpcf-custom-fields-control-form '
529
  . 'wpcf-form-validate" enctype="multipart/form-data">';
530
  echo wpcf_admin_custom_fields_control_form( $wpcf_control_table );
531
  wp_nonce_field( 'custom_fields_control_bulk' );
532
  echo '</form>';
533
- echo wpcf_add_admin_footer();
534
  }
535
 
536
  /**
@@ -552,13 +584,13 @@ function wpcf_admin_menu_migration_hook()
552
  */
553
  function wpcf_admin_menu_migration()
554
  {
555
- echo wpcf_add_admin_header( __( 'Migration', 'wpcf' ) );
556
  echo '<br /><form method="post" action="" id="wpcf-migration-form" class="wpcf-migration-form '
557
  . 'wpcf-form-validate" enctype="multipart/form-data">';
558
  $form = wpcf_form( 'wpcf_form_migration' );
559
  echo $form->renderForm();
560
  echo '</form>';
561
- echo wpcf_add_admin_footer();
562
  }
563
 
564
  /**
@@ -583,7 +615,7 @@ function wpcf_admin_menu_settings()
583
  {
584
  $show_toolset_messages = !WPCF_Types_Marketing_Messages::check_register();
585
  ob_start();
586
- echo wpcf_add_admin_header( __( 'Settings', 'wpcf' ) );
587
 
588
  ?>
589
  <p style="font-weight: bold;"><?php
@@ -703,7 +735,7 @@ printf(
703
  </tbody>
704
  </table>
705
  <?php
706
- echo wpcf_add_admin_footer();
707
 
708
  echo ob_get_clean();
709
  }
@@ -715,12 +747,24 @@ printf(
715
  * @param string $icon_id Custom icon
716
  * @return string
717
  */
718
- function wpcf_add_admin_header($title)
719
  {
720
  echo '<div class="wrap">';
721
- printf('<h2>%s</h2>', $title );
 
 
 
 
 
 
 
 
 
 
 
 
722
  do_action( 'wpcf_admin_header' );
723
- do_action( 'wpcf_admin_header_' . $_GET['page'] );
724
  }
725
 
726
  /**
@@ -731,7 +775,8 @@ function wpcf_add_admin_header($title)
731
  */
732
  function wpcf_add_admin_footer()
733
  {
734
- do_action( 'wpcf_admin_footer_' . $_GET['page'] );
 
735
  do_action( 'wpcf_admin_footer' );
736
  echo '</div>';
737
  }
@@ -811,7 +856,7 @@ function wpcf_admin_widefat_table( $ID, $header, $rows = array(), $empty_message
811
  function wpcf_admin_tabs($tabs, $page, $default = '', $current = '')
812
  {
813
  if ( empty( $current ) && isset( $_GET['tab'] ) ) {
814
- $current = $_GET['tab'];
815
  } else {
816
  $current = $default;
817
  }
@@ -877,6 +922,7 @@ function wpcf_admin_plugin_help($hook, $page)
877
  $call = 'custom_fields';
878
  break;
879
 
 
880
  case 'wpcf-ctt':
881
  $call = 'custom_types_and_taxonomies';
882
  break;
@@ -1006,6 +1052,7 @@ function wpcf_admin_deactivate_content($type, $arg, $action = 'delete')
1006
  }
1007
  if ( array_key_exists( $arg, $data['supports'] ) ) {
1008
  unset( $custom[$post_type]['supports'][$arg] );
 
1009
  }
1010
  }
1011
  update_option( 'wpcf-custom-taxonomies', $custom );
@@ -1022,6 +1069,7 @@ function wpcf_admin_deactivate_content($type, $arg, $action = 'delete')
1022
  }
1023
  if ( array_key_exists( $arg, $data['taxonomies'] ) ) {
1024
  unset( $custom[$post_type]['taxonomies'][$arg] );
 
1025
  }
1026
  }
1027
  update_option( 'wpcf-custom-types', $custom );
@@ -1142,7 +1190,7 @@ function wpcf_admin_add_submenu_page($menu, $menu_slug = null, $menu_parent = 'w
1142
  */
1143
  $hook = add_submenu_page(
1144
  $menu_parent,
1145
- $menu['page_title'],
1146
  $menu['menu_title'],
1147
  $wpcf_capability,
1148
  $menu_slug,
@@ -1175,3 +1223,25 @@ function wpcf_admin_add_submenu_page($menu, $menu_slug = null, $menu_parent = 'w
1175
  return $hook;
1176
  }
1177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  *
4
  * Admin functions
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/admin.php $
7
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
8
+ * $LastChangedRevision: 1120400 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
29
  include_once WPCF_ABSPATH.'/classes/class.wpcf-marketing-messages.php';
30
  new WPCF_Types_Marketing_Messages();
31
 
32
+ /**
33
+ * last edit flag
34
+ */
35
+ if ( !defined('TOOLSET_EDIT_LAST' )){
36
+ define( 'TOOLSET_EDIT_LAST', '_toolset_edit_last');
37
+ }
38
+
39
  /**
40
  * admin_init hook.
41
  */
42
  function wpcf_admin_init_hook()
43
  {
44
  wp_register_style('wpcf-css-embedded', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION );
 
45
 
46
  wp_enqueue_style( 'wpcf-promo-tabs', WPCF_EMBEDDED_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION );
47
  wp_enqueue_style('toolset-dashicons');
65
 
66
  $subpages = array();
67
 
68
+ // Custom Post Types
69
+ $subpages['wpcf-cpt'] = array(
70
+ 'menu_title' => __( 'Custom Post Types', 'wpcf' ),
71
+ 'function' => 'wpcf_admin_menu_summary_cpt',
72
+ );
73
+
74
+ // Custom Taxonomies
75
  $subpages['wpcf-ctt'] = array(
76
+ 'menu_title' => __( 'Custom Taxonomies', 'wpcf' ),
 
77
  'function' => 'wpcf_admin_menu_summary_ctt',
78
  );
79
 
80
  // Custom fields
81
  $subpages['wpcf-cf'] = array(
 
82
  'menu_title' => __( 'Custom Fields', 'wpcf' ),
83
  'function' => 'wpcf_admin_menu_summary',
84
  );
85
 
86
  // Custom Fields Control
87
  $subpages['wpcf-custom-fields-control'] = array(
 
88
  'menu_title' => __( 'Custom Fields Control', 'wpcf' ),
89
  'function' => 'wpcf_admin_menu_custom_fields_control',
90
  );
91
 
92
  // User Meta
93
  $subpages['wpcf-um'] = array(
 
94
  'menu_title' => __( 'User Fields', 'wpcf' ),
95
  'function' => 'wpcf_usermeta_summary',
 
96
  );
97
 
98
  // User Fields Control
99
  $subpages['wpcf-user-fields-control'] = array(
 
100
  'menu_title' => __( 'User Fields Control', 'wpcf' ),
101
  'function' => 'wpcf_admin_menu_user_fields_control',
102
  );
106
 
107
  // Import/Export
108
  $subpages['wpcf-import-export'] = array(
 
109
  'menu_title' => __( 'Import/Export', 'wpcf' ),
110
  'function' => 'wpcf_admin_menu_import_export',
111
  );
112
 
113
  // Settings
114
  $subpages['wpcf-custom-settings'] = array(
 
115
  'menu_title' => __( 'Settings', 'wpcf' ),
116
  'function' => 'wpcf_admin_menu_settings',
117
  'submenu' => array(
118
  'wpcf-debug-information' => array(
 
119
  'menu_title' => __( 'Debug Information', 'wpcf' ),
120
  'function' => 'wpcf_admin_menu_debug_information',
121
  ),
193
  require_once WPCF_EMBEDDED_ABSPATH.'/common/debug/debug-information.php';
194
  }
195
 
196
+ /**
197
+ * Menu page hook.
198
+ */
199
+ function wpcf_usermeta_summary_hook()
200
+ {
201
+ do_action( 'wpcf_admin_page_init' );
202
+ wpcf_admin_load_collapsible();
203
+ wpcf_admin_page_add_options('uf', __( 'User Fields', 'wpcf' ));
204
+ }
205
+
206
  /**
207
  * Menu page hook.
208
  */
210
  {
211
  do_action( 'wpcf_admin_page_init' );
212
  wpcf_admin_load_collapsible();
213
+ wpcf_admin_page_add_options('cf', __( 'Custom Fields', 'wpcf' ));
214
  }
215
 
216
  /**
218
  */
219
  function wpcf_admin_menu_summary()
220
  {
221
+ wpcf_add_admin_header(
222
+ __( 'Custom Fields', 'wpcf' ),
223
+ array('page'=>'wpcf-edit'),
224
+ __('Add New Group', 'wpcf')
225
+ );
226
  require_once WPCF_INC_ABSPATH . '/fields.php';
227
  require_once WPCF_INC_ABSPATH . '/fields-list.php';
228
  $to_display = wpcf_admin_fields_get_fields();
229
  if ( !empty( $to_display ) ) {
230
+ add_action( 'wpcf_groups_list_table_after', 'wpcf_admin_promotional_text' );
 
231
  }
232
  wpcf_admin_fields_list();
233
+ wpcf_add_admin_footer();
234
  }
235
 
236
  /**
310
  } else {
311
  $title = __( 'Add New Group', 'wpcf' );
312
  }
313
+ wpcf_add_admin_header( $title );
314
  wpcf_wpml_warning();
315
  $form = wpcf_form( 'wpcf_form_fields' );
316
+ echo '<form method="post" action="" class="wpcf-fields-form wpcf-form-validate">';
317
+ echo '<div id="poststuff">';
318
+ echo $form->renderForm();
319
+ echo '</div>';
320
+ echo '</form>';
321
+ wpcf_add_admin_footer();
322
+ }
323
 
324
+ function wpcf_admin_page_add_options( $name, $label)
325
+ {
326
+ $option = 'per_page';
327
+ $args = array(
328
+ 'label' => $label,
329
+ 'default' => 10,
330
+ 'option' => sprintf('wpcf_%s_%s', $name, $option),
331
+ );
332
+ add_screen_option( $option, $args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  }
334
 
335
+ function wpcf_admin_menu_summary_cpt_ctt_hook()
 
 
 
336
  {
337
  do_action( 'wpcf_admin_page_init' );
338
+ wp_enqueue_style( 'wpcf-promo-tabs', WPCF_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION );
 
339
  wpcf_admin_load_collapsible();
340
  require_once WPCF_INC_ABSPATH . '/custom-types.php';
341
  require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
342
  require_once WPCF_INC_ABSPATH . '/custom-types-taxonomies-list.php';
343
  }
344
 
345
+ /**
346
+ * Menu page hook.
347
+ */
348
+ function wpcf_admin_menu_summary_cpt_hook()
349
+ {
350
+ wpcf_admin_menu_summary_cpt_ctt_hook();
351
+ wpcf_admin_page_add_options('cpt', __( 'Custom Post Types', 'wpcf' ));
352
+ }
353
+
354
  /**
355
  * Menu page display.
356
  */
357
+ function wpcf_admin_menu_summary_cpt()
358
  {
359
+ wpcf_add_admin_header(
360
+ __( 'Custom Post Types', 'wpcf' ),
361
+ array('page'=>'wpcf-edit-type'),
362
+ __('Add New Custom Post Type', 'wpcf')
363
+ );
364
  $to_display_posts = get_option( 'wpcf-custom-types', array() );
365
  $to_display_tax = get_option( 'wpcf-custom-taxonomies', array() );
366
  if ( !empty( $to_display_posts ) || !empty( $to_display_tax ) ) {
367
+ add_action( 'wpcf_types_tax_list_table_after', 'wpcf_admin_promotional_text' );
 
368
  }
369
+ wpcf_admin_custom_post_types_list();
370
+ wpcf_add_admin_footer();
371
+ }
372
+
373
+ /**
374
+ * Menu page hook.
375
+ */
376
+ function wpcf_admin_menu_summary_ctt_hook()
377
+ {
378
+ wpcf_admin_menu_summary_cpt_ctt_hook();
379
+ wpcf_admin_page_add_options('ctt', __( 'Custom Taxonomies', 'wpcf' ));
380
+ }
381
+
382
+ /**
383
+ * Menu page display.
384
+ */
385
+ function wpcf_admin_menu_summary_ctt()
386
+ {
387
+ wpcf_add_admin_header( __( 'Custom Taxonomies', 'wpcf' ), array('page' => 'wpcf-edit-tax') );
388
+ wpcf_admin_custom_taxonomies_list();
389
+ do_action('wpcf_types_tax_list_table_after');
390
+ wpcf_add_admin_footer();
391
  }
392
 
393
  /**
434
  } else {
435
  $title = __( 'Add New Custom Post Type', 'wpcf' );
436
  }
437
+ wpcf_add_admin_header( $title );
438
  wpcf_wpml_warning();
439
  $form = wpcf_form( 'wpcf_form_types' );
440
  echo '<br /><form method="post" action="" class="wpcf-types-form '
441
  . 'wpcf-form-validate">';
442
  echo $form->renderForm();
443
  echo '</form>';
444
+ wpcf_add_admin_footer();
445
  }
446
 
447
  /**
483
  } else {
484
  $title = __( 'Add New Taxonomy', 'wpcf' );
485
  }
486
+ wpcf_add_admin_header( $title );
487
  wpcf_wpml_warning();
488
  $form = wpcf_form( 'wpcf_form_tax' );
489
  echo '<br /><form method="post" action="" class="wpcf-tax-form '
490
  . 'wpcf-form-validate">';
491
  echo $form->renderForm();
492
  echo '</form>';
493
+ wpcf_add_admin_footer();
494
  }
495
 
496
  /**
513
  */
514
  function wpcf_admin_menu_import_export()
515
  {
516
+ wpcf_add_admin_header( __( 'Import/Export', 'wpcf' ) );
517
  echo '<br /><form method="post" action="" class="wpcf-import-export-form '
518
  . 'wpcf-form-validate" enctype="multipart/form-data">';
519
  echo wpcf_form_simple( wpcf_admin_import_export_form() );
520
  echo '</form>';
521
+ wpcf_add_admin_footer();
522
  }
523
 
524
  /**
537
  && wp_verify_nonce( $_REQUEST['_wpnonce'],
538
  'custom_fields_control_bulk' )
539
  && (isset( $_POST['action'] ) || isset( $_POST['action2'] )) && !empty( $_POST['fields'] ) ) {
540
+ $action = ( $_POST['action'] == '-1' ) ? sanitize_text_field( $_POST['action2'] ) : sanitize_text_field( $_POST['action'] );
541
  wpcf_admin_custom_fields_control_bulk_actions( $action );
542
  }
543
 
556
  function wpcf_admin_menu_custom_fields_control()
557
  {
558
  global $wpcf_control_table;
559
+ wpcf_add_admin_header( __( 'Custom Fields Control', 'wpcf' ) );
560
  echo '<form method="post" action="" id="wpcf-custom-fields-control-form" class="wpcf-custom-fields-control-form '
561
  . 'wpcf-form-validate" enctype="multipart/form-data">';
562
  echo wpcf_admin_custom_fields_control_form( $wpcf_control_table );
563
  wp_nonce_field( 'custom_fields_control_bulk' );
564
  echo '</form>';
565
+ wpcf_add_admin_footer();
566
  }
567
 
568
  /**
584
  */
585
  function wpcf_admin_menu_migration()
586
  {
587
+ wpcf_add_admin_header( __( 'Migration', 'wpcf' ) );
588
  echo '<br /><form method="post" action="" id="wpcf-migration-form" class="wpcf-migration-form '
589
  . 'wpcf-form-validate" enctype="multipart/form-data">';
590
  $form = wpcf_form( 'wpcf_form_migration' );
591
  echo $form->renderForm();
592
  echo '</form>';
593
+ wpcf_add_admin_footer();
594
  }
595
 
596
  /**
615
  {
616
  $show_toolset_messages = !WPCF_Types_Marketing_Messages::check_register();
617
  ob_start();
618
+ wpcf_add_admin_header( __( 'Settings', 'wpcf' ) );
619
 
620
  ?>
621
  <p style="font-weight: bold;"><?php
735
  </tbody>
736
  </table>
737
  <?php
738
+ wpcf_add_admin_footer();
739
 
740
  echo ob_get_clean();
741
  }
747
  * @param string $icon_id Custom icon
748
  * @return string
749
  */
750
+ function wpcf_add_admin_header($title, $add_new = false, $add_new_title = false)
751
  {
752
  echo '<div class="wrap">';
753
+ echo '<h2>', $title;
754
+ if ( !$add_new_title ) {
755
+ $add_new_title = __('Add New', 'wpcf');
756
+ }
757
+ if ( $add_new ) {
758
+ printf(
759
+ ' <a href="%s" class="add-new-h2">%s</a>',
760
+ add_query_arg( $add_new, admin_url('admin.php')),
761
+ $add_new_title
762
+ );
763
+ }
764
+ echo '</h2>';
765
+ $current_page = sanitize_text_field( $_GET['page'] );
766
  do_action( 'wpcf_admin_header' );
767
+ do_action( 'wpcf_admin_header_' . $current_page );
768
  }
769
 
770
  /**
775
  */
776
  function wpcf_add_admin_footer()
777
  {
778
+ $current_page = sanitize_text_field( $_GET['page'] );
779
+ do_action( 'wpcf_admin_footer_' . $current_page );
780
  do_action( 'wpcf_admin_footer' );
781
  echo '</div>';
782
  }
856
  function wpcf_admin_tabs($tabs, $page, $default = '', $current = '')
857
  {
858
  if ( empty( $current ) && isset( $_GET['tab'] ) ) {
859
+ $current = sanitize_text_field( $_GET['tab'] );
860
  } else {
861
  $current = $default;
862
  }
922
  $call = 'custom_fields';
923
  break;
924
 
925
+ case 'wpcf-cpt':
926
  case 'wpcf-ctt':
927
  $call = 'custom_types_and_taxonomies';
928
  break;
1052
  }
1053
  if ( array_key_exists( $arg, $data['supports'] ) ) {
1054
  unset( $custom[$post_type]['supports'][$arg] );
1055
+ $custom[$post_type][TOOLSET_EDIT_LAST] = time();
1056
  }
1057
  }
1058
  update_option( 'wpcf-custom-taxonomies', $custom );
1069
  }
1070
  if ( array_key_exists( $arg, $data['taxonomies'] ) ) {
1071
  unset( $custom[$post_type]['taxonomies'][$arg] );
1072
+ $custom[$post_type][TOOLSET_EDIT_LAST] = time();
1073
  }
1074
  }
1075
  update_option( 'wpcf-custom-types', $custom );
1190
  */
1191
  $hook = add_submenu_page(
1192
  $menu_parent,
1193
+ isset($menu['page_title'])? $menu['page_title']:$menu['menu_title'],
1194
  $menu['menu_title'],
1195
  $wpcf_capability,
1196
  $menu_slug,
1223
  return $hook;
1224
  }
1225
 
1226
+ /**
1227
+ * sort helper for tables
1228
+ */
1229
+ function wpcf_usort_reorder($a,$b)
1230
+ {
1231
+ $orderby = (!empty($_REQUEST['orderby'])) ? sanitize_text_field( $_REQUEST['orderby'] ) : 'title'; //If no sort, default to title
1232
+ $order = (!empty($_REQUEST['order'])) ? sanitize_text_field( $_REQUEST['order'] ) : 'asc'; //If no order, default to asc
1233
+ if ( ! in_array( $order, array( 'asc', 'desc' ) ) ) {
1234
+ $order = 'asc';
1235
+ }
1236
+ if ('title' == $orderby || !isset($a[$orderby])) {
1237
+ $orderby = 'slug';
1238
+ }
1239
+ $result = strcmp($a[$orderby], $b[$orderby]); //Determine sort order
1240
+ return ($order==='asc') ? $result : -$result; //Send final sort direction to usort
1241
+ }
1242
+
1243
+ add_filter('set-screen-option', 'wpcf_table_set_option', 10, 3);
1244
+ function wpcf_table_set_option($status, $option, $value)
1245
+ {
1246
+ return $value;
1247
+ }
classes/class.wpcf-marketing-messages.php CHANGED
@@ -3,9 +3,9 @@
3
  *
4
  * Types Marketing Class
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/classes/class.wpcf-marketing-messages.php $
7
- * $LastChangedDate: 2015-02-24 10:05:51 +0000 (Tue, 24 Feb 2015) $
8
- * $LastChangedRevision: 1097977 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
@@ -43,8 +43,7 @@ class WPCF_Types_Marketing_Messages extends WPCF_Types_Marketing
43
  return;
44
  }
45
  if ( self::check_register() ) {
46
-
47
- $this->state = 'disabled';
48
  }
49
  }
50
 
@@ -122,8 +121,9 @@ class WPCF_Types_Marketing_Messages extends WPCF_Types_Marketing
122
  && array_key_exists('wpcf-post-type', $_GET)
123
  ) {
124
  $types = get_option('wpcf-custom-types', array());
125
- if ( array_key_exists($_GET['wpcf-post-type'], $types ) ) {
126
- $text = preg_replace( '/PPP/', $types[$_GET['wpcf-post-type']]['labels']['name'], $text);
 
127
  }
128
  }
129
  break;
@@ -134,15 +134,18 @@ class WPCF_Types_Marketing_Messages extends WPCF_Types_Marketing
134
  && array_key_exists('wpcf-tax', $_GET)
135
  ) {
136
  $taxonomies = get_option('wpcf-custom-taxonomies', array());
137
- if ( array_key_exists($_GET['wpcf-tax'], $taxonomies) ) {
138
- $text = preg_replace( '/TTT/', $taxonomies[$_GET['wpcf-tax']]['labels']['name'], $text);
139
- if ( array_key_exists('supports', $taxonomies[$_GET['wpcf-tax']]) ) {
 
140
  $types = get_option('wpcf-custom-types', array());
141
- $post_type = array_keys($taxonomies[$_GET['wpcf-tax']]['supports']);
142
- $post_type = $post_type[array_rand($post_type)];
143
- $post_type = get_post_type_object($post_type);
144
- if ( $post_type ) {
145
- $text = preg_replace( '/PPP/', $post_type->labels->name, $text);
 
 
146
  }
147
  }
148
  }
@@ -218,6 +221,7 @@ class WPCF_Types_Marketing_Messages extends WPCF_Types_Marketing
218
  array_key_exists($this->option_name, $_POST)
219
  && array_key_exists($_POST[$this->option_name], $this->options)
220
  ) {
 
221
  if ( !add_option($this->option_name, $_POST[$this->option_name], '', 'no') ) {
222
  update_option($this->option_name, $_POST[$this->option_name]);
223
  }
@@ -306,6 +310,8 @@ class WPCF_Types_Marketing_Messages extends WPCF_Types_Marketing
306
  return;
307
  }
308
 
 
 
309
  public function update_toolset_messages()
310
  {
311
  $settings = wpcf_get_settings();
3
  *
4
  * Types Marketing Class
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/classes/class.wpcf-marketing-messages.php $
7
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
8
+ * $LastChangedRevision: 1120400 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
43
  return;
44
  }
45
  if ( self::check_register() ) {
46
+ $this->state = 'disabled';
 
47
  }
48
  }
49
 
121
  && array_key_exists('wpcf-post-type', $_GET)
122
  ) {
123
  $types = get_option('wpcf-custom-types', array());
124
+ $candidate_key = sanitize_text_field( $_GET['wpcf-post-type'] );
125
+ if ( array_key_exists($candidate_key, $types ) ) {
126
+ $text = preg_replace( '/PPP/', $types[$candidate_key]['labels']['name'], $text);
127
  }
128
  }
129
  break;
134
  && array_key_exists('wpcf-tax', $_GET)
135
  ) {
136
  $taxonomies = get_option('wpcf-custom-taxonomies', array());
137
+ $candidate_key = sanitize_text_field( $_GET['wpcf-tax'] );
138
+ if ( array_key_exists($candidate_key, $taxonomies) ) {
139
+ $text = preg_replace( '/TTT/', $taxonomies[$candidate_key]['labels']['name'], $text);
140
+ if ( array_key_exists('supports', $taxonomies[$candidate_key]) ) {
141
  $types = get_option('wpcf-custom-types', array());
142
+ $post_type = array_keys($taxonomies[$candidate_key]['supports']);
143
+ if ( !empty($post_type) ) {
144
+ $post_type = $post_type[array_rand($post_type)];
145
+ $post_type = get_post_type_object($post_type);
146
+ if ( $post_type ) {
147
+ $text = preg_replace( '/PPP/', $post_type->labels->name, $text);
148
+ }
149
  }
150
  }
151
  }
221
  array_key_exists($this->option_name, $_POST)
222
  && array_key_exists($_POST[$this->option_name], $this->options)
223
  ) {
224
+ // @todo we need to sanitize $_POST[$this->option_name]: is it a string, an array or what?
225
  if ( !add_option($this->option_name, $_POST[$this->option_name], '', 'no') ) {
226
  update_option($this->option_name, $_POST[$this->option_name]);
227
  }
310
  return;
311
  }
312
 
313
+ // @todo nonce ?
314
+ // @todo auth ?
315
  public function update_toolset_messages()
316
  {
317
  $settings = wpcf_get_settings();
classes/class.wpcf-marketing-tutorial.php CHANGED
@@ -3,9 +3,9 @@
3
  *
4
  * Types Tutorial Class
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/classes/class.wpcf-marketing-tutorial.php $
7
- * $LastChangedDate: 2015-02-24 10:05:51 +0000 (Tue, 24 Feb 2015) $
8
- * $LastChangedRevision: 1097977 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
3
  *
4
  * Types Tutorial Class
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/classes/class.wpcf-marketing-tutorial.php $
7
+ * $LastChangedDate: 2015-02-18 14:28:53 +0000 (Wed, 18 Feb 2015) $
8
+ * $LastChangedRevision: 1093394 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
classes/class.wpcf-marketing.php CHANGED
@@ -3,9 +3,9 @@
3
  *
4
  * Types Marketing Class
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/classes/class.wpcf-marketing.php $
7
- * $LastChangedDate: 2015-02-24 10:05:51 +0000 (Tue, 24 Feb 2015) $
8
- * $LastChangedRevision: 1097977 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
3
  *
4
  * Types Marketing Class
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/classes/class.wpcf-marketing.php $
7
+ * $LastChangedDate: 2015-02-18 14:28:53 +0000 (Wed, 18 Feb 2015) $
8
+ * $LastChangedRevision: 1093394 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
embedded/admin.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/admin.php $
5
- * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
6
- * $LastChangedRevision: 1069430 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -52,11 +52,8 @@ function wpcf_embedded_admin_init_hook() {
52
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/file.php';
53
  // Add types button
54
  add_filter( 'attachment_fields_to_edit', 'wpcf_fields_file_attachment_fields_to_edit_filter', PHP_INT_MAX, 2 );
55
- // Add JS
56
- add_action( 'admin_head', 'wpcf_fields_file_media_admin_head' );
57
  // Filter media TABs
58
- add_filter( 'media_upload_tabs',
59
- 'wpcf_fields_file_media_upload_tabs_filter' );
60
  }
61
 
62
  register_post_type( 'wp-types-group',
@@ -157,14 +154,15 @@ function wpcf_admin_fields_postfields_styles(){
157
 
158
  // $groups = wpcf_admin_fields_get_groups();
159
  $groups = wpcf_admin_post_get_post_groups_fields( wpcf_admin_get_edited_post() );
160
- echo '<style type="text/css">';
161
  if ( !empty( $groups ) ) {
 
162
  foreach ( $groups as $group ) {
163
  echo str_replace( "}", "}\n",
164
  wpcf_admin_get_groups_admin_styles_by_group( $group['id'] ) );
165
  }
 
166
  }
167
- echo '</style>';
168
  }
169
 
170
  /**
@@ -293,16 +291,17 @@ function wpcf_admin_validation_messages( $method = false, $sprintf = '' ) {
293
  'date' => __( 'Please enter a valid date', 'wpcf' ),
294
  'digits' => __( 'Please enter numeric data', 'wpcf' ),
295
  'number' => __( 'Please enter numeric data', 'wpcf' ),
296
- 'alphanumeric' => __( 'Letters, numbers, spaces or underscores only please',
297
- 'wpcf' ),
298
- 'nospecialchars' => __( 'Letters, numbers, spaces, underscores and dashes only please',
299
- 'wpcf' ),
300
- 'rewriteslug' => __( 'Letters, numbers, slashes, underscores and dashes only please',
301
- 'wpcf' ),
302
- 'negativeTimestamp' => __( 'Please enter a date after 1 January 1970.',
303
- 'wpcf' ),
304
- 'maxlength' => sprintf( __( 'Maximum of %s characters exceeded.', 'wpcf' ),
305
- strval( $sprintf ) ),
 
306
  );
307
  if ( $method ) {
308
  return isset( $messages[$method] ) ? $messages[$method] : '';
@@ -351,8 +350,20 @@ function wpcf_show_admin_messages() {
351
  * @param type $class
352
  * @return type
353
  */
354
- function wpcf_admin_message_store( $message, $class = 'updated',
355
- $keep_id = false ) {
 
 
 
 
 
 
 
 
 
 
 
 
356
  $messages = get_option( 'wpcf-messages', array() );
357
  $messages[get_current_user_id()][md5( $message )] = array(
358
  'message' => $message,
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/admin.php $
5
+ * $LastChangedDate: 2015-04-01 14:15:17 +0000 (Wed, 01 Apr 2015) $
6
+ * $LastChangedRevision: 1125405 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
52
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/file.php';
53
  // Add types button
54
  add_filter( 'attachment_fields_to_edit', 'wpcf_fields_file_attachment_fields_to_edit_filter', PHP_INT_MAX, 2 );
 
 
55
  // Filter media TABs
56
+ add_filter( 'media_upload_tabs', 'wpcf_fields_file_media_upload_tabs_filter' );
 
57
  }
58
 
59
  register_post_type( 'wp-types-group',
154
 
155
  // $groups = wpcf_admin_fields_get_groups();
156
  $groups = wpcf_admin_post_get_post_groups_fields( wpcf_admin_get_edited_post() );
157
+
158
  if ( !empty( $groups ) ) {
159
+ echo '<style type="text/css">';
160
  foreach ( $groups as $group ) {
161
  echo str_replace( "}", "}\n",
162
  wpcf_admin_get_groups_admin_styles_by_group( $group['id'] ) );
163
  }
164
+ echo '</style>';
165
  }
 
166
  }
167
 
168
  /**
291
  'date' => __( 'Please enter a valid date', 'wpcf' ),
292
  'digits' => __( 'Please enter numeric data', 'wpcf' ),
293
  'number' => __( 'Please enter numeric data', 'wpcf' ),
294
+ 'alphanumeric' => __( 'Letters, numbers, spaces or underscores only please', 'wpcf' ),
295
+ 'nospecialchars' => __( 'Letters, numbers, spaces, underscores and dashes only please', 'wpcf' ),
296
+ 'rewriteslug' => __( 'Letters, numbers, slashes, underscores and dashes only please', 'wpcf' ),
297
+ 'negativeTimestamp' => __( 'Please enter a date after 1 January 1970.', 'wpcf' ),
298
+ 'maxlength' => sprintf( __( 'Maximum of %s characters exceeded.', 'wpcf' ), strval( $sprintf ) ),
299
+ 'minlength' => sprintf( __( 'Minimum of %s characters exceeded.', 'wpcf' ), strval( $sprintf ) ),
300
+ /**
301
+ * see
302
+ * https://support.skype.com/en/faq/FA10858/what-is-a-skype-name-and-how-do-i-find-mine
303
+ */
304
+ 'skype' => __( 'Letters, numbers, dashes, underscores, commas and periods only please.', 'wpcf' ),
305
  );
306
  if ( $method ) {
307
  return isset( $messages[$method] ) ? $messages[$method] : '';
350
  * @param type $class
351
  * @return type
352
  */
353
+ function wpcf_admin_message_store( $message, $class = 'updated', $keep_id = false )
354
+ {
355
+ /**
356
+ * Allow to store or note
357
+ *
358
+ * Filter allow to turn off storing messages in Types
359
+ *
360
+ * @since 1.6.6
361
+ *
362
+ * @param boolean $var default value is true to show messages
363
+ */
364
+ if (!apply_filters('wpcf_admin_message_store', true) ) {
365
+ return;
366
+ }
367
  $messages = get_option( 'wpcf-messages', array() );
368
  $messages[get_current_user_id()][md5( $message )] = array(
369
  'message' => $message,
embedded/bootstrap.php CHANGED
@@ -7,9 +7,9 @@
7
  *
8
  * @since Types 1.2
9
  *
10
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/bootstrap.php $
11
- * $LastChangedDate: 2015-02-24 10:05:51 +0000 (Tue, 24 Feb 2015) $
12
- * $LastChangedRevision: 1097977 $
13
  * $LastChangedBy: iworks $
14
  *
15
  */
@@ -43,6 +43,12 @@ if ( !defined( 'TYPES_INIT_PRIORITY' ) ) {
43
  */
44
  add_action( 'init', 'wpcf_embedded_init', TYPES_INIT_PRIORITY );
45
 
 
 
 
 
 
 
46
  /*
47
  *
48
  *
@@ -131,7 +137,7 @@ function wpcf_embedded_init() {
131
  // Define necessary constants if plugin is not present
132
  // This ones are skipped if used as embedded code!
133
  if ( !defined( 'WPCF_VERSION' ) ) {
134
- define( 'WPCF_VERSION', '1.6.5.1' );
135
  define( 'WPCF_META_PREFIX', 'wpcf-' );
136
  }
137
 
@@ -314,10 +320,6 @@ function wpcf_embedded_init() {
314
  // Init loader
315
  WPCF_Loader::init();
316
 
317
- // Init custom types and taxonomies
318
- wpcf_init_custom_types_taxonomies();
319
-
320
-
321
  /*
322
  * TODO Check why we enabled this
323
  *
7
  *
8
  * @since Types 1.2
9
  *
10
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/bootstrap.php $
11
+ * $LastChangedDate: 2015-04-01 14:17:52 +0000 (Wed, 01 Apr 2015) $
12
+ * $LastChangedRevision: 1125409 $
13
  * $LastChangedBy: iworks $
14
  *
15
  */
43
  */
44
  add_action( 'init', 'wpcf_embedded_init', TYPES_INIT_PRIORITY );
45
 
46
+ /**
47
+ * register_post_type & register_taxonomy - must be with default pririty to
48
+ * handle defult taxonomies
49
+ */
50
+ add_action( 'init', 'wpcf_init_custom_types_taxonomies');
51
+
52
  /*
53
  *
54
  *
137
  // Define necessary constants if plugin is not present
138
  // This ones are skipped if used as embedded code!
139
  if ( !defined( 'WPCF_VERSION' ) ) {
140
+ define( 'WPCF_VERSION', '1.6.6' );
141
  define( 'WPCF_META_PREFIX', 'wpcf-' );
142
  }
143
 
320
  // Init loader
321
  WPCF_Loader::init();
322
 
 
 
 
 
323
  /*
324
  * TODO Check why we enabled this
325
  *
embedded/classes/class.wpcf-post-types.php CHANGED
@@ -3,9 +3,9 @@
3
  *
4
  * Post Types Class
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/classes/class.wpcf-post-types.php $
7
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
- * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
@@ -29,6 +29,237 @@ class WPCF_Post_Types
29
  var $settings;
30
  var $messages = null;
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  function set($post_type, $settings = null)
33
  {
34
  $data = get_post_type_object( $post_type );
3
  *
4
  * Post Types Class
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/classes/class.wpcf-post-types.php $
7
+ * $LastChangedDate: 2015-03-16 12:03:31 +0000 (Mon, 16 Mar 2015) $
8
+ * $LastChangedRevision: 1113864 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
29
  var $settings;
30
  var $messages = null;
31
 
32
+ function __construct()
33
+ {
34
+ add_action('admin_init', array($this, 'admin_init'));
35
+ add_action('admin_head-nav-menus.php', array($this, 'add_filters'));
36
+ add_filter('wp_setup_nav_menu_item', array( $this, 'setup_archive_item'));
37
+ add_filter('wp_nav_menu_objects', array( $this, 'maybe_make_current'));
38
+ }
39
+ /**
40
+ * Check has some custom fields to display.
41
+ *
42
+ * Check custom post type for custom fields to display on custom post edit
43
+ * screen.
44
+ *
45
+ * @since 1.6.6
46
+ * @access (for functions: only use if private)
47
+ *
48
+ * @return bool It has some fields?
49
+ */
50
+ private function check_has_custom_fields($data)
51
+ {
52
+ return
53
+ isset($data['custom_fields'])
54
+ && is_array($data['custom_fields'])
55
+ && !empty($data['custom_fields']);
56
+ }
57
+
58
+ /**
59
+ * Admin init.
60
+ *
61
+ * Admin init function used to add columns..
62
+ *
63
+ * @since 1.6.6
64
+ */
65
+ public function admin_init()
66
+ {
67
+ $custom_post_types = wpcf_get_active_custom_types();
68
+ foreach( $custom_post_types as $post_type => $data ) {
69
+ if ( $this->check_has_custom_fields($data)) {
70
+ $hook = sprintf('manage_edit-%s_columns', $post_type);
71
+ add_filter($hook, array($this, 'manage_posts_columns'));
72
+ $hook = sprintf('manage_%s_posts_custom_column', $post_type);
73
+ add_action($hook, array($this, 'manage_custom_columns'), 10, 2);
74
+ }
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Add custom fields as a columns.
80
+ *
81
+ * Add custom fields as a columns on custom post admin list
82
+ *
83
+ * @since 1.6.6
84
+ *
85
+ * @param array $columns Hashtable of columns;
86
+ * @return array Hashtable of columns;
87
+ */
88
+ public function manage_posts_columns($columns)
89
+ {
90
+ $screen = get_current_screen();
91
+ if ( !isset( $screen->post_type) ) {
92
+ return $columns;
93
+ }
94
+ $custom_post_types = wpcf_get_active_custom_types();
95
+ if(
96
+ !isset($custom_post_types[$screen->post_type])
97
+ || !$this->check_has_custom_fields($custom_post_types[$screen->post_type])
98
+ ) {
99
+ return $columns;
100
+ }
101
+ $fields = wpcf_admin_fields_get_fields();
102
+ ksort($fields);
103
+ foreach( $fields as $key => $data ) {
104
+ if ( !isset($data['meta_key']) ) {
105
+ continue;
106
+ }
107
+ if ( in_array($data['meta_key'], $custom_post_types[$screen->post_type]['custom_fields']) ) {
108
+ $columns[$data['meta_key']] = $data['name'];
109
+ }
110
+ }
111
+ return $columns;
112
+ }
113
+
114
+ /**
115
+ * Show value of custom field.
116
+ *
117
+ * Show value of custom field.
118
+ *
119
+ * @since 1.6.6
120
+ *
121
+ * @param string $column Column name,
122
+ * @param int $var Current post ID.
123
+ */
124
+ public function manage_custom_columns($column, $post_id)
125
+ {
126
+ $value = get_post_meta($post_id, $column, true);
127
+ if ( empty($value) ) {
128
+ return;
129
+ }
130
+ $field = wpcf_admin_fields_get_field_by_meta_key($column);
131
+ if ( isset( $field['type'] ) ) {
132
+ switch( $field['type'] ) {
133
+ case 'image':
134
+ $value = sprintf(
135
+ '<img src="%s" width="120" />',
136
+ $value
137
+ );
138
+ break;
139
+ case 'skype':
140
+ $value = isset($value['skypename'])? $value['skypename']:'';
141
+ break;
142
+ case 'date':
143
+ require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
144
+ $value = WPToolset_Field_Date::timetodate($value);
145
+ break;
146
+ }
147
+ }
148
+ if ( is_string($value ) ) {
149
+ echo $value;
150
+ }
151
+ }
152
+
153
+ /**
154
+ * Assign menu item the appropriate url
155
+ * @param object $menu_item
156
+ * @return object $menu_item
157
+ */
158
+ public function setup_archive_item( $menu_item ) {
159
+ if ( $menu_item->type !== 'post_type_archive' ) {
160
+ return $menu_item;
161
+ }
162
+ $post_type = $menu_item->object;
163
+ if (post_type_exists( $post_type )) {
164
+ $data = get_post_type_object( $post_type );
165
+ $menu_item->type_label = sprintf( __( 'Archive for %s', 'wpcf' ), $data->labels->name);
166
+ $menu_item->url = get_post_type_archive_link( $post_type );
167
+ }
168
+ return $menu_item;
169
+ }
170
+
171
+ public function add_filters()
172
+ {
173
+ $custom_post_types = wpcf_get_active_custom_types();
174
+ if ( empty($custom_post_types) ) {
175
+ return;
176
+ }
177
+ foreach ( $custom_post_types as $slug => $data ) {
178
+ add_filter( 'nav_menu_items_' . $slug, array( $this, 'add_archive_checkbox' ), null, 3 );
179
+ }
180
+ }
181
+
182
+ public function add_archive_checkbox( $posts, $args, $post_type )
183
+ {
184
+ global $_nav_menu_placeholder, $wp_rewrite;
185
+ $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
186
+
187
+ array_unshift( $posts, (object) array(
188
+ 'ID' => 0,
189
+ 'object_id' => $_nav_menu_placeholder,
190
+ 'post_title' => $post_type['args']->labels->all_items,
191
+ 'post_type' => 'nav_menu_item',
192
+ 'type' => 'post_type_archive',
193
+ 'object' => $post_type['args']->slug,
194
+ ) );
195
+
196
+ return $posts;
197
+ }
198
+
199
+ /**
200
+ * Make post type archive link 'current'
201
+ * @uses Post_Type_Archive_Links :: get_item_ancestors()
202
+ * @param array $items
203
+ * @return array $items
204
+ */
205
+ public function maybe_make_current( $items ) {
206
+ foreach ( $items as $item ) {
207
+ if ( 'post_type_archive' !== $item->type ) {
208
+ continue;
209
+ }
210
+ $post_type = $item->object;
211
+ if (
212
+ ! is_post_type_archive( $post_type )
213
+ AND ! is_singular( $post_type )
214
+ )
215
+ continue;
216
+
217
+ // Make item current
218
+ $item->current = true;
219
+ $item->classes[] = 'current-menu-item';
220
+
221
+ // Loop through ancestors and give them 'parent' or 'ancestor' class
222
+ $active_anc_item_ids = $this->get_item_ancestors( $item );
223
+ foreach ( $items as $key => $parent_item ) {
224
+ $classes = (array) $parent_item->classes;
225
+
226
+ // If menu item is the parent
227
+ if ( $parent_item->db_id == $item->menu_item_parent ) {
228
+ $classes[] = 'current-menu-parent';
229
+ $items[ $key ]->current_item_parent = true;
230
+ }
231
+
232
+ // If menu item is an ancestor
233
+ if ( in_array( intval( $parent_item->db_id ), $active_anc_item_ids ) ) {
234
+ $classes[] = 'current-menu-ancestor';
235
+ $items[ $key ]->current_item_ancestor = true;
236
+ }
237
+
238
+ $items[ $key ]->classes = array_unique( $classes );
239
+ }
240
+ }
241
+
242
+ return $items;
243
+ }
244
+
245
+ /**
246
+ * Get menu item's ancestors
247
+ * @param object $item
248
+ * @return array $active_anc_item_ids
249
+ */
250
+ public function get_item_ancestors( $item ) {
251
+ $anc_id = absint( $item->db_id );
252
+
253
+ $active_anc_item_ids = array();
254
+ while (
255
+ $anc_id = get_post_meta( $anc_id, '_menu_item_menu_item_parent', true )
256
+ AND ! in_array( $anc_id, $active_anc_item_ids )
257
+ )
258
+ $active_anc_item_ids[] = $anc_id;
259
+
260
+ return $active_anc_item_ids;
261
+ }
262
+
263
  function set($post_type, $settings = null)
264
  {
265
  $data = get_post_type_object( $post_type );
embedded/classes/editor.php CHANGED
@@ -284,8 +284,7 @@ class WPCF_Editor
284
  /*
285
  * Callback
286
  */
287
- $shortcode = call_user_func( $function, $_POST, $this->field,
288
- $this->_meta_type );
289
  } else {
290
  /*
291
  * Generic
@@ -305,8 +304,7 @@ class WPCF_Editor
305
  */
306
  $shortcode = preg_replace( '@</?script[^>]*>@im', '', wp_kses_post($shortcode) );
307
  // Add additional parameters if required
308
- $shortcode = $this->_add_parameters_to_shortcode( $shortcode,
309
- $_POST );
310
  // Insert shortcode
311
  echo '<script type="text/javascript">jQuery(function(){tedFrame.close(\''
312
  . $shortcode . '\', \'' . esc_js( $shortcode ) . '\');});</script>';
284
  /*
285
  * Callback
286
  */
287
+ $shortcode = call_user_func( $function, $_POST, $this->field, $this->_meta_type );
 
288
  } else {
289
  /*
290
  * Generic
304
  */
305
  $shortcode = preg_replace( '@</?script[^>]*>@im', '', wp_kses_post($shortcode) );
306
  // Add additional parameters if required
307
+ $shortcode = $this->_add_parameters_to_shortcode( $shortcode, $_POST );
 
308
  // Insert shortcode
309
  echo '<script type="text/javascript">jQuery(function(){tedFrame.close(\''
310
  . $shortcode . '\', \'' . esc_js( $shortcode ) . '\');});</script>';
embedded/classes/field.php CHANGED
@@ -2,37 +2,37 @@
2
  /*
3
  * Field class.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/classes/field.php $
6
- * $LastChangedDate: 2014-10-23 10:33:39 +0000 (Thu, 23 Oct 2014) $
7
- * $LastChangedRevision: 1012677 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
11
 
12
  /**
13
  * Base class.
14
- *
15
  * Fields are our core items and we'll use this class to sort them out a little.
16
  * Very useful, should be used to finish small tasks for field.
17
- *
18
  * Example:
19
- *
20
  * // Setup field
21
  * global $wpcf;
22
  * $my_field = new WPCF_Field();
23
  * $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
24
- *
25
  * // Use it
26
  * $my_field->save();
27
- *
28
  * // Generic instance can be found in global $wpcf.
29
  * global $wpcf;
30
  * $wpcf->field->set(...);
31
- *
32
  * !! BE CAREFUL !! not to disturb global instance if you suspect processing
33
  * current item is not finished. Core code sometimes use same instance over
34
  * few functions and places.
35
- *
36
  * @since Types 1.2
37
  * @package Types
38
  * @subpackage Classes
@@ -45,18 +45,18 @@ class WPCF_Field
45
 
46
  /**
47
  * Field structure
48
- *
49
  * This is actually a form array collected from files per specific field:
50
  * /embedded/includes/fields/$field_type.php
51
  * /includes/fields/$field_type.php
52
- *
53
  * @var type array
54
  */
55
  var $cf = array();
56
 
57
  /**
58
  * All Types created fields
59
- * @var type
60
  */
61
  var $fields = null;
62
 
@@ -68,9 +68,9 @@ class WPCF_Field
68
 
69
  /**
70
  * Field config.
71
- *
72
  * Use it to set default configuration.
73
- *
74
  * @var type array
75
  */
76
  var $config = array(
@@ -102,8 +102,8 @@ class WPCF_Field
102
 
103
  /**
104
  * Cache.DEPRECATED
105
- *
106
- * @var type
107
  */
108
  var $cache = array();
109
 
@@ -115,25 +115,25 @@ class WPCF_Field
115
 
116
  /**
117
  * Context in which class is called
118
- * @var type
119
  */
120
  var $context = 'group';
121
 
122
  /**
123
  * Invalid fields
124
- *
125
  * @todo Revise
126
- * @var type
127
  */
128
  var $invalid_fields = array();
129
 
130
  /**
131
- * ID
132
  */
133
  var $ID = '';
134
 
135
  /**
136
- * Unique ID
137
  */
138
  var $unique_id = '';
139
 
@@ -144,16 +144,16 @@ class WPCF_Field
144
 
145
  /**
146
  * Set current post and field.
147
- *
148
  * @param type $post
149
- * @param type $cf
150
  */
151
  function set( $post, $cf ) {
152
 
153
  global $wpcf;
154
 
155
  /*
156
- *
157
  * Check if $cf is string
158
  */
159
  if ( is_string( $cf ) ) {
@@ -218,8 +218,8 @@ class WPCF_Field
218
 
219
  /**
220
  * Set needed but not required form elements.
221
- *
222
- * @param string $cf
223
  */
224
  function _parse_cf_form_element( $cf ) {
225
  $p = array('#before' => '', '#after' => '', '#description' => '');
@@ -233,8 +233,9 @@ class WPCF_Field
233
 
234
  /**
235
  * Fetch and sort fields.
236
- *
237
- * @global type $wpdb
 
238
  */
239
  function _get_meta() {
240
  global $wpdb;
@@ -309,8 +310,8 @@ class WPCF_Field
309
 
310
  /**
311
  * Gets $_POST data.
312
- *
313
- * @return type
314
  */
315
  function get_submitted_data() {
316
  $posted = isset( $_POST['wpcf'][$this->cf['slug']] ) ? $_POST['wpcf'][$this->cf['slug']] : null;
@@ -320,12 +321,12 @@ class WPCF_Field
320
 
321
  /**
322
  * Save field.
323
- *
324
  * If $value is empty, $_POST will be checked.
325
  * 1.3.2 Reverted saving empty fields
326
  * removed - if ( !empty( $value ) || is_numeric( $value ) ) {
327
- *
328
- * @param type $value
329
  */
330
  function save( $value = null )
331
  {
@@ -394,9 +395,9 @@ class WPCF_Field
394
 
395
  /**
396
  * Apply filters to saved value.
397
- *
398
  * @param type $value
399
- * @return type
400
  */
401
  function _filter_save_value( $value )
402
  {
@@ -411,7 +412,7 @@ class WPCF_Field
411
  /**
412
  * Use these hooks to add future functionality.
413
  * Do not add any more code to core.
414
- *
415
  * @param type $field
416
  * @param type $value
417
  * @param type $meta_id
@@ -442,8 +443,8 @@ class WPCF_Field
442
 
443
  /**
444
  * Sets field config.
445
- *
446
- * @return type
447
  */
448
  function _get_config() {
449
  $this->_include_file_by_field_type($this->cf['type']);
@@ -456,7 +457,7 @@ class WPCF_Field
456
 
457
  /**
458
  * Discouraged usage.
459
- *
460
  * @return type
461
  */
462
  function _deprecated_inherited_allowed() {
@@ -471,8 +472,8 @@ class WPCF_Field
471
 
472
  /**
473
  * Sets field meta box form.
474
- *
475
- * @return type
476
  */
477
  function _get_meta_form( $meta_value = null, $meta_id = null, $wrap = true ) {
478
 
@@ -484,7 +485,7 @@ class WPCF_Field
484
 
485
  /*
486
  * Set value
487
- *
488
  * IMPORTANT
489
  * Here we set values for form elements
490
  */
@@ -506,10 +507,10 @@ class WPCF_Field
506
  }
507
 
508
  /*
509
- *
510
- *
511
- *
512
- *
513
  * Since Types 1.2
514
  * Avoid using parent (inherited) type
515
  * $this->config->inherited_field_type
@@ -549,7 +550,7 @@ class WPCF_Field
549
  $func = 'wpcf_fields_' . $this->cf['type'] . '_meta_box_form';
550
  if ( is_callable( $func ) ) {
551
  /*
552
- *
553
  * From Types 1.2 use complete form setup
554
  */
555
  $form_meta_box = call_user_func_array( 'wpcf_fields_'
@@ -576,7 +577,7 @@ class WPCF_Field
576
  foreach ( $form as $element_key => $element ) {
577
 
578
  /*
579
- *
580
  * Start using __ in keys to skip element
581
  */
582
  // Skip protected
@@ -696,10 +697,17 @@ class WPCF_Field
696
 
697
  /**
698
  * Use this function to add final filters to HTML output.
699
- *
700
- * @param type $output
701
  */
702
- function html( $html, $params ) {
 
 
 
 
 
 
 
703
  /**
704
  *
705
  * Exception when RAW = TRUE.
@@ -712,20 +720,18 @@ class WPCF_Field
712
  $html = htmlspecialchars( $html );
713
  }
714
  // Process shortcodes too
715
- // $shortcode = do_shortcode( $html );
716
  $html = do_shortcode( htmlspecialchars_decode( stripslashes( $html ) ) );
717
-
718
  return $html;
719
  }
720
 
721
  /**
722
  * Determines if field is created with Types.
723
- *
724
  * @param type $field_key
725
  */
726
  function is_under_control( $field_key ) {
727
  /*
728
- *
729
  * We force checking our meta prefix
730
  */
731
  $key = $this->__get_slug_no_prefix( $field_key );
@@ -734,7 +740,7 @@ class WPCF_Field
734
 
735
  /**
736
  * Return slug.
737
- *
738
  * @param type $meta_key
739
  * @return type
740
  */
@@ -745,14 +751,14 @@ class WPCF_Field
745
 
746
  /**
747
  * Returns altered element form name.
748
- *
749
  * Use $prefix to set name like:
750
  * wpcf_post_relationship[214][wpcf-my-checkbox]
751
- *
752
  * Or if multi array
753
  * wpcf_post_relationship[214][wpcf-my-date][datepicker]
754
  * wpcf_post_relationship[214][wpcf-my-date][hour]
755
- *
756
  * @param type $prefix
757
  * @param type $name
758
  * @return type
@@ -769,7 +775,7 @@ class WPCF_Field
769
  . $this->post->ID
770
  . '][' . $this->slug . ']';
771
  /*
772
- *
773
  * Multi array case
774
  */
775
  } else {
2
  /*
3
  * Field class.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/classes/field.php $
6
+ * $LastChangedDate: 2015-04-01 14:15:17 +0000 (Wed, 01 Apr 2015) $
7
+ * $LastChangedRevision: 1125405 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
11
 
12
  /**
13
  * Base class.
14
+ *
15
  * Fields are our core items and we'll use this class to sort them out a little.
16
  * Very useful, should be used to finish small tasks for field.
17
+ *
18
  * Example:
19
+ *
20
  * // Setup field
21
  * global $wpcf;
22
  * $my_field = new WPCF_Field();
23
  * $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
24
+ *
25
  * // Use it
26
  * $my_field->save();
27
+ *
28
  * // Generic instance can be found in global $wpcf.
29
  * global $wpcf;
30
  * $wpcf->field->set(...);
31
+ *
32
  * !! BE CAREFUL !! not to disturb global instance if you suspect processing
33
  * current item is not finished. Core code sometimes use same instance over
34
  * few functions and places.
35
+ *
36
  * @since Types 1.2
37
  * @package Types
38
  * @subpackage Classes
45
 
46
  /**
47
  * Field structure
48
+ *
49
  * This is actually a form array collected from files per specific field:
50
  * /embedded/includes/fields/$field_type.php
51
  * /includes/fields/$field_type.php
52
+ *
53
  * @var type array
54
  */
55
  var $cf = array();
56
 
57
  /**
58
  * All Types created fields
59
+ * @var type
60
  */
61
  var $fields = null;
62
 
68
 
69
  /**
70
  * Field config.
71
+ *
72
  * Use it to set default configuration.
73
+ *
74
  * @var type array
75
  */
76
  var $config = array(
102
 
103
  /**
104
  * Cache.DEPRECATED
105
+ *
106
+ * @var type
107
  */
108
  var $cache = array();
109
 
115
 
116
  /**
117
  * Context in which class is called
118
+ * @var type
119
  */
120
  var $context = 'group';
121
 
122
  /**
123
  * Invalid fields
124
+ *
125
  * @todo Revise
126
+ * @var type
127
  */
128
  var $invalid_fields = array();
129
 
130
  /**
131
+ * ID
132
  */
133
  var $ID = '';
134
 
135
  /**
136
+ * Unique ID
137
  */
138
  var $unique_id = '';
139
 
144
 
145
  /**
146
  * Set current post and field.
147
+ *
148
  * @param type $post
149
+ * @param type $cf
150
  */
151
  function set( $post, $cf ) {
152
 
153
  global $wpcf;
154
 
155
  /*
156
+ *
157
  * Check if $cf is string
158
  */
159
  if ( is_string( $cf ) ) {
218
 
219
  /**
220
  * Set needed but not required form elements.
221
+ *
222
+ * @param string $cf
223
  */
224
  function _parse_cf_form_element( $cf ) {
225
  $p = array('#before' => '', '#after' => '', '#description' => '');
233
 
234
  /**
235
  * Fetch and sort fields.
236
+ *
237
+ * @global object $wpdb
238
+ *
239
  */
240
  function _get_meta() {
241
  global $wpdb;
310
 
311
  /**
312
  * Gets $_POST data.
313
+ *
314
+ * @return type
315
  */
316
  function get_submitted_data() {
317
  $posted = isset( $_POST['wpcf'][$this->cf['slug']] ) ? $_POST['wpcf'][$this->cf['slug']] : null;
321
 
322
  /**
323
  * Save field.
324
+ *
325
  * If $value is empty, $_POST will be checked.
326
  * 1.3.2 Reverted saving empty fields
327
  * removed - if ( !empty( $value ) || is_numeric( $value ) ) {
328
+ *
329
+ * @param type $value
330
  */
331
  function save( $value = null )
332
  {
395
 
396
  /**
397
  * Apply filters to saved value.
398
+ *
399
  * @param type $value
400
+ * @return type
401
  */
402
  function _filter_save_value( $value )
403
  {
412
  /**
413
  * Use these hooks to add future functionality.
414
  * Do not add any more code to core.
415
+ *
416
  * @param type $field
417
  * @param type $value
418
  * @param type $meta_id
443
 
444
  /**
445
  * Sets field config.
446
+ *
447
+ * @return type
448
  */
449
  function _get_config() {
450
  $this->_include_file_by_field_type($this->cf['type']);
457
 
458
  /**
459
  * Discouraged usage.
460
+ *
461
  * @return type
462
  */
463
  function _deprecated_inherited_allowed() {
472
 
473
  /**
474
  * Sets field meta box form.
475
+ *
476
+ * @return type
477
  */
478
  function _get_meta_form( $meta_value = null, $meta_id = null, $wrap = true ) {
479
 
485
 
486
  /*
487
  * Set value
488
+ *
489
  * IMPORTANT
490
  * Here we set values for form elements
491
  */
507
  }
508
 
509
  /*
510
+ *
511
+ *
512
+ *
513
+ *
514
  * Since Types 1.2
515
  * Avoid using parent (inherited) type
516
  * $this->config->inherited_field_type
550
  $func = 'wpcf_fields_' . $this->cf['type'] . '_meta_box_form';
551
  if ( is_callable( $func ) ) {
552
  /*
553
+ *
554
  * From Types 1.2 use complete form setup
555
  */
556
  $form_meta_box = call_user_func_array( 'wpcf_fields_'
577
  foreach ( $form as $element_key => $element ) {
578
 
579
  /*
580
+ *
581
  * Start using __ in keys to skip element
582
  */
583
  // Skip protected
697
 
698
  /**
699
  * Use this function to add final filters to HTML output.
700
+ *
701
+ * @param type $output
702
  */
703
+ function html( $html, $params )
704
+ {
705
+ /**
706
+ * check input
707
+ */
708
+ if ( is_array($html) || is_object($html) ) {
709
+ return '';
710
+ }
711
  /**
712
  *
713
  * Exception when RAW = TRUE.
720
  $html = htmlspecialchars( $html );
721
  }
722
  // Process shortcodes too
 
723
  $html = do_shortcode( htmlspecialchars_decode( stripslashes( $html ) ) );
 
724
  return $html;
725
  }
726
 
727
  /**
728
  * Determines if field is created with Types.
729
+ *
730
  * @param type $field_key
731
  */
732
  function is_under_control( $field_key ) {
733
  /*
734
+ *
735
  * We force checking our meta prefix
736
  */
737
  $key = $this->__get_slug_no_prefix( $field_key );
740
 
741
  /**
742
  * Return slug.
743
+ *
744
  * @param type $meta_key
745
  * @return type
746
  */
751
 
752
  /**
753
  * Returns altered element form name.
754
+ *
755
  * Use $prefix to set name like:
756
  * wpcf_post_relationship[214][wpcf-my-checkbox]
757
+ *
758
  * Or if multi array
759
  * wpcf_post_relationship[214][wpcf-my-date][datepicker]
760
  * wpcf_post_relationship[214][wpcf-my-date][hour]
761
+ *
762
  * @param type $prefix
763
  * @param type $name
764
  * @return type
775
  . $this->post->ID
776
  . '][' . $this->slug . ']';
777
  /*
778
+ *
779
  * Multi array case
780
  */
781
  } else {
embedded/classes/fields.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Fields class.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/classes/fields.php $
6
  * $LastChangedDate: 2014-05-07 06:56:23 +0000 (Wed, 07 May 2014) $
7
  * $LastChangedRevision: 909470 $
8
  * $LastChangedBy: iworks $
2
  /**
3
  * Fields class.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/classes/fields.php $
6
  * $LastChangedDate: 2014-05-07 06:56:23 +0000 (Wed, 07 May 2014) $
7
  * $LastChangedRevision: 909470 $
8
  * $LastChangedBy: iworks $
embedded/classes/forms.php CHANGED
@@ -4,10 +4,10 @@
4
  *
5
  * Returns HTML formatted output for elements and handles form submission.
6
  *
7
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/classes/forms.php $
8
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
9
- * $LastChangedRevision: 970205 $
10
- * $LastChangedBy: brucepearson $
11
  *
12
  *
13
  * @version 1.0
@@ -125,8 +125,10 @@ class Enlimbo_Forms_Wpcf
125
  if ( empty( $id ) ) {
126
  $id = $this->_id;
127
  }
128
- return (isset( $_REQUEST['_wpnonce_wpcf'] )
129
- && wp_verify_nonce( $_REQUEST['_wpnonce_wpcf'], $id ));
 
 
130
  }
131
 
132
  /**
@@ -920,9 +922,15 @@ class Enlimbo_Forms_Wpcf
920
  array('textfield', 'textarea') ) ? '' : 0;
921
  }
922
 
 
 
 
 
 
 
 
923
  $parts = explode( '[', $name );
924
- $parts = array_map( create_function( '&$a', 'return trim($a, \']\');' ),
925
- $parts );
926
  if ( !isset( $_REQUEST[$parts[0]] ) ) {
927
  return in_array( $element['#type'], array('textfield', 'textarea') ) ? '' : 0;
928
  }
4
  *
5
  * Returns HTML formatted output for elements and handles form submission.
6
  *
7
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/classes/forms.php $
8
+ * $LastChangedDate: 2015-03-16 12:03:31 +0000 (Mon, 16 Mar 2015) $
9
+ * $LastChangedRevision: 1113864 $
10
+ * $LastChangedBy: iworks $
11
  *
12
  *
13
  * @version 1.0
125
  if ( empty( $id ) ) {
126
  $id = $this->_id;
127
  }
128
+ return (
129
+ isset( $_REQUEST['_wpnonce_wpcf'] )
130
+ && wp_verify_nonce( $_REQUEST['_wpnonce_wpcf'], $id )
131
+ );
132
  }
133
 
134
  /**
922
  array('textfield', 'textarea') ) ? '' : 0;
923
  }
924
 
925
+ if ( !function_exists('getSubmittedDataTrim')) {
926
+ function getSubmittedDataTrim($a)
927
+ {
928
+ return trim($a, ']');
929
+ }
930
+ }
931
+
932
  $parts = explode( '[', $name );
933
+ $parts = array_map( 'getSubmittedDataTrim', $parts );
 
934
  if ( !isset( $_REQUEST[$parts[0]] ) ) {
935
  return in_array( $element['#type'], array('textfield', 'textarea') ) ? '' : 0;
936
  }
embedded/classes/loader.php CHANGED
@@ -3,16 +3,16 @@
3
  *
4
  * Loader class
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/classes/loader.php $
7
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
- * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
12
 
13
  /**
14
  * Loader Class
15
- *
16
  * @since Types 1.2
17
  * @package Types
18
  * @subpackage Classes
@@ -25,7 +25,7 @@ class WPCF_Loader
25
 
26
  /**
27
  * Settings
28
- * @var array
29
  */
30
  private static $__settings = array();
31
 
@@ -38,11 +38,14 @@ class WPCF_Loader
38
  array('WPCF_Loader', 'renderJsSettings'), 5 );
39
  add_filter( 'the_posts', array('WPCF_Loader', 'wpcf_cache_complete_postmeta') );
40
  }
41
-
42
  /**
43
- * Cache the postmeta for posts returned by a WP_Query
44
- */
45
-
 
 
 
46
  public static function wpcf_cache_complete_postmeta( $posts ) {
47
  global $wpdb;
48
  if ( !$posts )
@@ -54,7 +57,7 @@ class WPCF_Loader
54
  $cache_key_looped_post = md5( 'post::_is_cached' . $post->ID );
55
  $cached_object = wp_cache_get( $cache_key_looped_post, $cache_group_ids );
56
  if ( false === $cached_object ) {
57
- $post_ids[] = $post->ID;
58
  wp_cache_add( $cache_key_looped_post, $post->ID, $cache_group_ids );
59
  }
60
  }
@@ -150,7 +153,7 @@ class WPCF_Loader
150
 
151
  /**
152
  * Returns HTML formatted output.
153
- *
154
  * @param string $view
155
  * @param mixed $data
156
  * @return string
@@ -171,7 +174,7 @@ class WPCF_Loader
171
 
172
  /**
173
  * Returns HTML formatted output.
174
- *
175
  * @param string $view
176
  * @param mixed $data
177
  * @return string
@@ -187,7 +190,7 @@ class WPCF_Loader
187
 
188
  /**
189
  * Returns HTML formatted output.
190
- *
191
  * @param string $template
192
  * @param mixed $data
193
  * @return string
@@ -208,7 +211,7 @@ class WPCF_Loader
208
 
209
  /**
210
  * Loads model.
211
- *
212
  * @param string $template
213
  * @param mixed $data
214
  * @return string
@@ -224,7 +227,7 @@ class WPCF_Loader
224
 
225
  /**
226
  * Loads class.
227
- *
228
  * @param string $template
229
  * @param mixed $data
230
  * @return string
@@ -240,7 +243,7 @@ class WPCF_Loader
240
 
241
  /**
242
  * Loads include.
243
- *
244
  * @param string $template
245
  * @param mixed $data
246
  * @return string
@@ -256,7 +259,7 @@ class WPCF_Loader
256
 
257
  /**
258
  * Adds JS settings.
259
- *
260
  * @staticvar array $settings
261
  * @param type $id
262
  * @param type $setting
3
  *
4
  * Loader class
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/classes/loader.php $
7
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
8
+ * $LastChangedRevision: 1120400 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
12
 
13
  /**
14
  * Loader Class
15
+ *
16
  * @since Types 1.2
17
  * @package Types
18
  * @subpackage Classes
25
 
26
  /**
27
  * Settings
28
+ * @var array
29
  */
30
  private static $__settings = array();
31
 
38
  array('WPCF_Loader', 'renderJsSettings'), 5 );
39
  add_filter( 'the_posts', array('WPCF_Loader', 'wpcf_cache_complete_postmeta') );
40
  }
41
+
42
  /**
43
+ * Cache the postmeta for posts returned by a WP_Query
44
+ *
45
+ * @global object $wpdb
46
+ *
47
+ */
48
+
49
  public static function wpcf_cache_complete_postmeta( $posts ) {
50
  global $wpdb;
51
  if ( !$posts )
57
  $cache_key_looped_post = md5( 'post::_is_cached' . $post->ID );
58
  $cached_object = wp_cache_get( $cache_key_looped_post, $cache_group_ids );
59
  if ( false === $cached_object ) {
60
+ $post_ids[] = intval( $post->ID );
61
  wp_cache_add( $cache_key_looped_post, $post->ID, $cache_group_ids );
62
  }
63
  }
153
 
154
  /**
155
  * Returns HTML formatted output.
156
+ *
157
  * @param string $view
158
  * @param mixed $data
159
  * @return string
174
 
175
  /**
176
  * Returns HTML formatted output.
177
+ *
178
  * @param string $view
179
  * @param mixed $data
180
  * @return string
190
 
191
  /**
192
  * Returns HTML formatted output.
193
+ *
194
  * @param string $template
195
  * @param mixed $data
196
  * @return string
211
 
212
  /**
213
  * Loads model.
214
+ *
215
  * @param string $template
216
  * @param mixed $data
217
  * @return string
227
 
228
  /**
229
  * Loads class.
230
+ *
231
  * @param string $template
232
  * @param mixed $data
233
  * @return string
243
 
244
  /**
245
  * Loads include.
246
+ *
247
  * @param string $template
248
  * @param mixed $data
249
  * @return string
259
 
260
  /**
261
  * Adds JS settings.
262
+ *
263
  * @staticvar array $settings
264
  * @param type $id
265
  * @param type $setting
embedded/classes/path.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * WPCF_Path
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/classes/path.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
2
  /**
3
  * WPCF_Path
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/classes/path.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
embedded/classes/post-types/messages.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Messages.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/classes/post-types/messages.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
2
  /*
3
  * Messages.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/classes/post-types/messages.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
embedded/classes/relationship.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Post relationship class.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/classes/relationship.php $
6
- * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
7
- * $LastChangedRevision: 1069430 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -201,8 +201,8 @@ class WPCF_Relationship
201
  /**
202
  * Bulk saving children.
203
  *
204
- * @param type $parent_id
205
- * @param type $children
206
  */
207
  function save_children($parent_id, $children)
208
  {
@@ -214,13 +214,13 @@ class WPCF_Relationship
214
  /**
215
  * Unified save child function.
216
  *
217
- * @param type $child_id
218
- * @param type $parent_id
 
 
219
  */
220
  function save_child( $parent_id, $child_id, $save_fields = array() )
221
  {
222
- global $wpdb;
223
-
224
  $parent = get_post( intval( $parent_id ) );
225
  $child = get_post( intval( $child_id ) );
226
  $post_data = array();
@@ -289,7 +289,18 @@ class WPCF_Relationship
289
  }
290
  unset($cf);
291
 
 
 
 
 
 
 
 
292
  $updated_id = wp_update_post( $post_data );
 
 
 
 
293
  if ( empty( $updated_id ) ) {
294
  return new WP_Error( 'relationship-update-post-failed', 'Updating post failed' );
295
  }
@@ -380,9 +391,9 @@ class WPCF_Relationship
380
  /**
381
  * Saves new child.
382
  *
383
- * @param type $parent_id
384
- * @param type $post_type
385
- * @return type
386
  */
387
  function add_new_child($parent_id, $post_type)
388
  {
2
  /*
3
  * Post relationship class.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/classes/relationship.php $
6
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
7
+ * $LastChangedRevision: 1120400 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
201
  /**
202
  * Bulk saving children.
203
  *
204
+ * @param int $parent_id
205
+ * @param array $children Array $child_id => $fields. For details about $fields see save_child().
206
  */
207
  function save_children($parent_id, $children)
208
  {
214
  /**
215
  * Unified save child function.
216
  *
217
+ * @param int $parent_id
218
+ * @param int $child_id
219
+ * @param array $save_fields
220
+ * @return bool|WP_Error
221
  */
222
  function save_child( $parent_id, $child_id, $save_fields = array() )
223
  {
 
 
224
  $parent = get_post( intval( $parent_id ) );
225
  $child = get_post( intval( $child_id ) );
226
  $post_data = array();
289
  }
290
  unset($cf);
291
 
292
+ /**
293
+ * avoid filters for children
294
+ * /
295
+ global $wp_filter;
296
+ $save_post = $wp_filter['save_post'];
297
+ $wp_filter['save_post'] = array();
298
+ */
299
  $updated_id = wp_update_post( $post_data );
300
+ /*
301
+ $wp_filter['save_post'] = $save_post;
302
+ */
303
+ unset($save_post);
304
  if ( empty( $updated_id ) ) {
305
  return new WP_Error( 'relationship-update-post-failed', 'Updating post failed' );
306
  }
391
  /**
392
  * Saves new child.
393
  *
394
+ * @param int $parent_id
395
+ * @param string $post_type
396
+ * @return int|WP_Error
397
  */
398
  function add_new_child($parent_id, $post_type)
399
  {
embedded/classes/relationship/form-child.php CHANGED
@@ -106,6 +106,18 @@ class WPCF_Relationship_Child_Form
106
  $this->__urlParams[$__param] = $_GET[$__param];
107
  }
108
  }
 
 
 
 
 
 
 
 
 
 
 
 
109
  $post_types = get_option( 'wpcf-custom-types', array() );
110
  if (
111
  array_key_exists($child_post_type, $post_types )
@@ -194,10 +206,10 @@ class WPCF_Relationship_Child_Form
194
  */
195
  $options = array(__( 'All', 'wpcf' ) => 'all', 5 => 5, 10 => 10, 15 => 15);
196
  // Add sorting
197
- $add_data = isset( $_GET['sort'] ) && isset( $_GET['field'] ) ? '&sort=' . strval( $_GET['sort'] ) . '&field='
198
- . strval( $_GET['field'] ) : '';
199
  if ( isset( $_GET['post_type_sort_parent'] ) ) {
200
- $add_data .= '&post_type_sort_parent=' . $_GET['post_type_sort_parent'];
201
  }
202
  $this->pagination_bottom = wpcf_form_simple( array(
203
  'pagination' => array(
@@ -690,7 +702,7 @@ class WPCF_Relationship_Child_Form
690
  // Sorting
691
  $dir = isset( $_GET['sort'] ) && $_GET['sort'] == 'ASC' ? 'DESC' : 'ASC';
692
  $dir_default = 'ASC';
693
- $sort_field = isset( $_GET['field'] ) ? $_GET['field'] : '';
694
 
695
  // Set values
696
  $post = $this->parent;
106
  $this->__urlParams[$__param] = $_GET[$__param];
107
  }
108
  }
109
+ /**
110
+ * build-in types
111
+ */
112
+ if ( in_array($child_post_type, array('page', 'post', 'attachment', 'revision', 'nav_menu_item') ) ) {
113
+ foreach( array_keys($this->child_supports) as $key ) {
114
+ $this->child_supports[$key] = post_type_supports($child_post_type, $key);
115
+ }
116
+ return;
117
+ }
118
+ /**
119
+ * custom post types
120
+ */
121
  $post_types = get_option( 'wpcf-custom-types', array() );
122
  if (
123
  array_key_exists($child_post_type, $post_types )
206
  */
207
  $options = array(__( 'All', 'wpcf' ) => 'all', 5 => 5, 10 => 10, 15 => 15);
208
  // Add sorting
209
+ $add_data = isset( $_GET['sort'] ) && isset( $_GET['field'] ) ? '&sort=' . sanitize_text_field( $_GET['sort'] ) . '&field='
210
+ . sanitize_text_field( $_GET['field'] ) : '';
211
  if ( isset( $_GET['post_type_sort_parent'] ) ) {
212
+ $add_data .= '&post_type_sort_parent=' . sanitize_text_field( $_GET['post_type_sort_parent'] );
213
  }
214
  $this->pagination_bottom = wpcf_form_simple( array(
215
  'pagination' => array(
702
  // Sorting
703
  $dir = isset( $_GET['sort'] ) && $_GET['sort'] == 'ASC' ? 'DESC' : 'ASC';
704
  $dir_default = 'ASC';
705
+ $sort_field = isset( $_GET['field'] ) ? sanitize_text_field( $_GET['field'] ) : '';
706
 
707
  // Set values
708
  $post = $this->parent;
embedded/classes/repeater.php CHANGED
@@ -1,29 +1,29 @@
1
  <?php
2
  /*
3
- *
4
- *
5
  * Repeater fields class.
6
  */
7
 
8
  /**
9
  * Repater class
10
- *
11
  * Very useful, should be used to finish small tasks for repeater field.
12
- *
13
  * Example:
14
- *
15
  * // Setup field
16
  * global $wpcf;
17
  * $my_field = new WPCF_Repeater();
18
  * $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
19
- *
20
  * // Use it
21
  * $my_field->save();
22
- *
23
  * Generic instance can be found in global $wpcf.
24
  * global $wpcf;
25
  * $wpcf->repeater->set(...);
26
- *
27
  * @since Types 1.2
28
  * @package Types
29
  * @subpackage Classes
@@ -36,30 +36,30 @@ class WPCF_Repeater extends WPCF_Field
36
 
37
  /**
38
  * Field order
39
- *
40
- * @var type
41
  */
42
  var $order;
43
 
44
  /**
45
  * Indexing
46
- *
47
  * Set counts when processing fields.
48
- *
49
- * @var type
50
  */
51
  var $index = 0;
52
 
53
  /**
54
  * Field title
55
- * @var type
56
  */
57
  var $title = '';
58
 
59
  /**
60
  * Field description.
61
- *
62
- * @var type
63
  */
64
  var $description = '';
65
 
@@ -73,9 +73,9 @@ class WPCF_Repeater extends WPCF_Field
73
 
74
  /**
75
  * Calls parent set func.
76
- *
77
  * @param type $post
78
- * @param type $field
79
  */
80
  function set( $post, $field ) {
81
  parent::set( $post, $field );
@@ -84,12 +84,12 @@ class WPCF_Repeater extends WPCF_Field
84
 
85
  /**
86
  * Save fields
87
- *
88
  * If $data empty, $_POST will be checked
89
- *
90
  * @global type $wpcf
91
  * @param type $data
92
- * @return boolean
93
  */
94
  function save( $data = null ) {
95
 
@@ -107,7 +107,7 @@ class WPCF_Repeater extends WPCF_Field
107
 
108
  // Set data
109
  if ( !empty( $data ) ) {
110
-
111
  do_action('wpcf_postmeta_before_add_repetitive', $this->post, $this->cf);
112
 
113
  // Insert new meta and collect all new mids
@@ -116,7 +116,7 @@ class WPCF_Repeater extends WPCF_Field
116
  foreach ( $data as $meta_value ) {
117
 
118
  /*
119
- *
120
  * Deprecated!
121
  */
122
  if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
@@ -142,7 +142,7 @@ class WPCF_Repeater extends WPCF_Field
142
  // Call insert post actions on each field
143
  $this->_action_save( $this->cf, $_meta_value, $mid, $meta_value );
144
  }
145
-
146
  do_action('wpcf_postmeta_after_add_repetitive', $this->post, $this->cf);
147
 
148
  // Save order
@@ -160,8 +160,8 @@ class WPCF_Repeater extends WPCF_Field
160
 
161
  /**
162
  * Fetch and sort fields.
163
- *
164
- * @global type $wpdb
165
  */
166
  function _get_meta() {
167
  global $wpdb;
@@ -169,7 +169,7 @@ class WPCF_Repeater extends WPCF_Field
169
  $cache_key = md5( 'repeater::_get_meta' . $this->post->ID . $this->slug );
170
  $cache_group = 'types_cache';
171
  $cached_object = wp_cache_get( $cache_key, $cache_group );
172
-
173
  if ( $this->use_cache ) {
174
  if ( false != $cached_object && is_array( $cached_object ) ) {
175
  return $cached_object;
@@ -181,10 +181,10 @@ class WPCF_Repeater extends WPCF_Field
181
  $ordered = array();
182
  $this->order = get_post_meta( $this->post->ID, $this->order_meta_name,
183
  true );
184
-
185
  $cache_key_field = md5( 'field::_get_meta' . $this->post->ID . $this->slug );
186
  $cached_object_field = wp_cache_get( $cache_key_field, $cache_group );
187
-
188
  if ( $this->use_cache ) {
189
  if ( false != $cached_object_field && is_array( $cached_object_field ) ) {// WordPress cache
190
  $r = $cached_object_field;
@@ -265,8 +265,8 @@ class WPCF_Repeater extends WPCF_Field
265
  }
266
 
267
  /**
268
- * Sets repetitive field form.
269
- *
270
  * @todo Make more distinction between $field_form and $form_field
271
  */
272
  function get_fields_form() {
@@ -315,8 +315,8 @@ class WPCF_Repeater extends WPCF_Field
315
 
316
  // Set style
317
  /*
318
- *
319
- *
320
  * Hide if field not passed check
321
  * TODO Move this to WPCF_Conditional
322
  */
@@ -328,17 +328,17 @@ class WPCF_Repeater extends WPCF_Field
328
  $css_cd = !$show ? 'display:none;' : '';
329
 
330
  /**
331
- *
332
- *
333
- *
334
- *
335
  * Set title and description
336
  * TODO See if can be improved getting main element
337
- *
338
  * Get first element and extract details
339
  * Pass emty string as value to avoid using meta as array
340
  */
341
- //
342
  $_c = array_values( parent::_get_meta_form( '' ) );
343
  array_shift( $_c );
344
  $_main_element = array_shift( $_c );
@@ -351,8 +351,8 @@ class WPCF_Repeater extends WPCF_Field
351
  }
352
 
353
  /*
354
- *
355
- *
356
  * Start wrapper
357
  */
358
  $form[$unique_id . '_repetitive_wrapper_open'] = array(
@@ -372,12 +372,12 @@ class WPCF_Repeater extends WPCF_Field
372
 
373
  // Set hidden mark field
374
  /*
375
- *
376
- *
377
- *
378
  * This actually marks field as repetitive
379
  * IMPORTANT!!! IF NOT marked field won't be saved at all!
380
- *
381
  * @see wpcf_admin_post_save_post_hook()
382
  */
383
  $form[$form_id . '_hidden_mark'] = array(
@@ -443,9 +443,9 @@ class WPCF_Repeater extends WPCF_Field
443
 
444
  /**
445
  * Sete repetitive form for single field.
446
- *
447
  * @param type $meta
448
- * @return string
449
  */
450
  function get_field_form( $meta_value = null, $meta_id = null ) {
451
 
@@ -456,8 +456,8 @@ class WPCF_Repeater extends WPCF_Field
456
  $key = 'wpcf_field_' . md5( maybe_serialize( $meta_value ) . $meta_id );
457
  }
458
  /*
459
- *
460
- *
461
  * TODO We prevented array because of some fails we had before.
462
  * Now it should work fine
463
  * Add debug log if meta_value['custom_order'] passed.
@@ -480,7 +480,7 @@ class WPCF_Repeater extends WPCF_Field
480
  $field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
481
 
482
  /*
483
- *
484
  * Apply filters to each form element.
485
  * Here we add specific properties
486
  * e.g. Skype alters fields.
@@ -489,7 +489,7 @@ class WPCF_Repeater extends WPCF_Field
489
  foreach ( $field_form as $k => $field ) {
490
 
491
  /*
492
- *
493
  * IMPORTANT
494
  * We change name to hold array
495
  */
@@ -579,7 +579,7 @@ class WPCF_Repeater extends WPCF_Field
579
  }
580
 
581
  /**
582
- * Set counting elements.
583
  */
584
  function _set_form_count() {
585
  if ( $this->index === 0 ) {
@@ -592,8 +592,11 @@ class WPCF_Repeater extends WPCF_Field
592
 
593
  /**
594
  * Deletes meta.
595
- *
596
- * @param type $meta_key
 
 
 
597
  */
598
  function delete( $meta_id ) {
599
  global $wpdb;
@@ -613,4 +616,4 @@ class WPCF_Repeater extends WPCF_Field
613
  return $r;
614
  }
615
 
616
- }
1
  <?php
2
  /*
3
+ *
4
+ *
5
  * Repeater fields class.
6
  */
7
 
8
  /**
9
  * Repater class
10
+ *
11
  * Very useful, should be used to finish small tasks for repeater field.
12
+ *
13
  * Example:
14
+ *
15
  * // Setup field
16
  * global $wpcf;
17
  * $my_field = new WPCF_Repeater();
18
  * $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
19
+ *
20
  * // Use it
21
  * $my_field->save();
22
+ *
23
  * Generic instance can be found in global $wpcf.
24
  * global $wpcf;
25
  * $wpcf->repeater->set(...);
26
+ *
27
  * @since Types 1.2
28
  * @package Types
29
  * @subpackage Classes
36
 
37
  /**
38
  * Field order
39
+ *
40
+ * @var type
41
  */
42
  var $order;
43
 
44
  /**
45
  * Indexing
46
+ *
47
  * Set counts when processing fields.
48
+ *
49
+ * @var type
50
  */
51
  var $index = 0;
52
 
53
  /**
54
  * Field title
55
+ * @var type
56
  */
57
  var $title = '';
58
 
59
  /**
60
  * Field description.
61
+ *
62
+ * @var type
63
  */
64
  var $description = '';
65
 
73
 
74
  /**
75
  * Calls parent set func.
76
+ *
77
  * @param type $post
78
+ * @param type $field
79
  */
80
  function set( $post, $field ) {
81
  parent::set( $post, $field );
84
 
85
  /**
86
  * Save fields
87
+ *
88
  * If $data empty, $_POST will be checked
89
+ *
90
  * @global type $wpcf
91
  * @param type $data
92
+ * @return boolean
93
  */
94
  function save( $data = null ) {
95
 
107
 
108
  // Set data
109
  if ( !empty( $data ) ) {
110
+
111
  do_action('wpcf_postmeta_before_add_repetitive', $this->post, $this->cf);
112
 
113
  // Insert new meta and collect all new mids
116
  foreach ( $data as $meta_value ) {
117
 
118
  /*
119
+ *
120
  * Deprecated!
121
  */
122
  if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
142
  // Call insert post actions on each field
143
  $this->_action_save( $this->cf, $_meta_value, $mid, $meta_value );
144
  }
145
+
146
  do_action('wpcf_postmeta_after_add_repetitive', $this->post, $this->cf);
147
 
148
  // Save order
160
 
161
  /**
162
  * Fetch and sort fields.
163
+ *
164
+ * @global object $wpdb
165
  */
166
  function _get_meta() {
167
  global $wpdb;
169
  $cache_key = md5( 'repeater::_get_meta' . $this->post->ID . $this->slug );
170
  $cache_group = 'types_cache';
171
  $cached_object = wp_cache_get( $cache_key, $cache_group );
172
+
173
  if ( $this->use_cache ) {
174
  if ( false != $cached_object && is_array( $cached_object ) ) {
175
  return $cached_object;
181
  $ordered = array();
182
  $this->order = get_post_meta( $this->post->ID, $this->order_meta_name,
183
  true );
184
+
185
  $cache_key_field = md5( 'field::_get_meta' . $this->post->ID . $this->slug );
186
  $cached_object_field = wp_cache_get( $cache_key_field, $cache_group );
187
+
188
  if ( $this->use_cache ) {
189
  if ( false != $cached_object_field && is_array( $cached_object_field ) ) {// WordPress cache
190
  $r = $cached_object_field;
265
  }
266
 
267
  /**
268
+ * Sets repetitive field form.
269
+ *
270
  * @todo Make more distinction between $field_form and $form_field
271
  */
272
  function get_fields_form() {
315
 
316
  // Set style
317
  /*
318
+ *
319
+ *
320
  * Hide if field not passed check
321
  * TODO Move this to WPCF_Conditional
322
  */
328
  $css_cd = !$show ? 'display:none;' : '';
329
 
330
  /**
331
+ *
332
+ *
333
+ *
334
+ *
335
  * Set title and description
336
  * TODO See if can be improved getting main element
337
+ *
338
  * Get first element and extract details
339
  * Pass emty string as value to avoid using meta as array
340
  */
341
+ //
342
  $_c = array_values( parent::_get_meta_form( '' ) );
343
  array_shift( $_c );
344
  $_main_element = array_shift( $_c );
351
  }
352
 
353
  /*
354
+ *
355
+ *
356
  * Start wrapper
357
  */
358
  $form[$unique_id . '_repetitive_wrapper_open'] = array(
372
 
373
  // Set hidden mark field
374
  /*
375
+ *
376
+ *
377
+ *
378
  * This actually marks field as repetitive
379
  * IMPORTANT!!! IF NOT marked field won't be saved at all!
380
+ *
381
  * @see wpcf_admin_post_save_post_hook()
382
  */
383
  $form[$form_id . '_hidden_mark'] = array(
443
 
444
  /**
445
  * Sete repetitive form for single field.
446
+ *
447
  * @param type $meta
448
+ * @return string
449
  */
450
  function get_field_form( $meta_value = null, $meta_id = null ) {
451
 
456
  $key = 'wpcf_field_' . md5( maybe_serialize( $meta_value ) . $meta_id );
457
  }
458
  /*
459
+ *
460
+ *
461
  * TODO We prevented array because of some fails we had before.
462
  * Now it should work fine
463
  * Add debug log if meta_value['custom_order'] passed.
480
  $field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
481
 
482
  /*
483
+ *
484
  * Apply filters to each form element.
485
  * Here we add specific properties
486
  * e.g. Skype alters fields.
489
  foreach ( $field_form as $k => $field ) {
490
 
491
  /*
492
+ *
493
  * IMPORTANT
494
  * We change name to hold array
495
  */
579
  }
580
 
581
  /**
582
+ * Set counting elements.
583
  */
584
  function _set_form_count() {
585
  if ( $this->index === 0 ) {
592
 
593
  /**
594
  * Deletes meta.
595
+ *
596
+ * @global object $wpdb
597
+ *
598
+ * @param type $meta_key
599
+ *
600
  */
601
  function delete( $meta_id ) {
602
  global $wpdb;
616
  return $r;
617
  }
618
 
619
+ }
embedded/classes/usermeta_field.php CHANGED
@@ -1,7 +1,5 @@
1
  <?php
2
  /*
3
- *
4
- *
5
  * Usermeta Field class extends Field.
6
  */
7
 
@@ -13,16 +11,16 @@ class WPCF_Usermeta_Field extends WPCF_Field
13
 
14
  /**
15
  * Set current post and field.
16
- *
17
  * @param type $post
18
- * @param type $cf
19
  */
20
  function set( $user_id, $cf ) {
21
 
22
  global $wpcf;
23
 
24
  /*
25
- *
26
  * Check if $cf is string
27
  */
28
  if ( is_string( $cf ) ) {
@@ -63,9 +61,9 @@ class WPCF_Usermeta_Field extends WPCF_Field
63
 
64
  /**
65
  * Save usermeta field.
66
- *
67
- *
68
- * @param type $value
69
  */
70
  function usermeta_save( $value = null ) {
71
 
@@ -74,8 +72,8 @@ class WPCF_Usermeta_Field extends WPCF_Field
74
  $value = $this->get_submitted_data();
75
  }
76
  /*
77
- *
78
- *
79
  * Since Types 1.2
80
  * We completely rewrite meta.
81
  * It has no impact on frontend and covers a lot of cases
@@ -105,17 +103,17 @@ class WPCF_Usermeta_Field extends WPCF_Field
105
 
106
  /**
107
  * Fetch and sort fields.
108
- *
109
- *
 
110
  */
111
  function _get_meta() {
112
  global $wpdb;
113
 
114
-
115
  $cache_key = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
116
  $cache_group = 'types_cache';
117
  $cached_object = wp_cache_get( $cache_key, $cache_group );
118
-
119
  if ( $this->use_cache ) {
120
  if ( false != $cached_object && is_array( $cached_object ) && isset( $cached_object[0] ) ) {// WordPress cache
121
  $r = $cached_object[0];
@@ -173,7 +171,7 @@ class WPCF_Usermeta_Field extends WPCF_Field
173
  $this->__meta = $meta;
174
 
175
  /*
176
- *
177
  * Apply filters
178
  * !!! IMPORTANT !!!
179
  * TODO Make this only place where field meta value is filtered
1
  <?php
2
  /*
 
 
3
  * Usermeta Field class extends Field.
4
  */
5
 
11
 
12
  /**
13
  * Set current post and field.
14
+ *
15
  * @param type $post
16
+ * @param type $cf
17
  */
18
  function set( $user_id, $cf ) {
19
 
20
  global $wpcf;
21
 
22
  /*
23
+ *
24
  * Check if $cf is string
25
  */
26
  if ( is_string( $cf ) ) {
61
 
62
  /**
63
  * Save usermeta field.
64
+ *
65
+ *
66
+ * @param type $value
67
  */
68
  function usermeta_save( $value = null ) {
69
 
72
  $value = $this->get_submitted_data();
73
  }
74
  /*
75
+ *
76
+ *
77
  * Since Types 1.2
78
  * We completely rewrite meta.
79
  * It has no impact on frontend and covers a lot of cases
103
 
104
  /**
105
  * Fetch and sort fields.
106
+ *
107
+ * @global object $wpdb
108
+ *
109
  */
110
  function _get_meta() {
111
  global $wpdb;
112
 
 
113
  $cache_key = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
114
  $cache_group = 'types_cache';
115
  $cached_object = wp_cache_get( $cache_key, $cache_group );
116
+
117
  if ( $this->use_cache ) {
118
  if ( false != $cached_object && is_array( $cached_object ) && isset( $cached_object[0] ) ) {// WordPress cache
119
  $r = $cached_object[0];
171
  $this->__meta = $meta;
172
 
173
  /*
174
+ *
175
  * Apply filters
176
  * !!! IMPORTANT !!!
177
  * TODO Make this only place where field meta value is filtered
embedded/classes/usermeta_repeater.php CHANGED
@@ -8,30 +8,30 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
8
 
9
  /**
10
  * Field order
11
- *
12
- * @var type
13
  */
14
  var $order;
15
 
16
  /**
17
  * Indexing
18
- *
19
  * Set counts when processing fields.
20
- *
21
- * @var type
22
  */
23
  var $index = 0;
24
 
25
  /**
26
  * Field title
27
- * @var type
28
  */
29
  var $title = '';
30
 
31
  /**
32
  * Field description.
33
- *
34
- * @var type
35
  */
36
  var $description = '';
37
 
@@ -45,9 +45,9 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
45
 
46
  /**
47
  * Calls parent set func.
48
- *
49
  * @param type $post
50
- * @param type $field
51
  */
52
  function set( $user_id, $field ) {
53
  parent::set( $user_id, $field );
@@ -56,12 +56,12 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
56
 
57
  /**
58
  * Save fields
59
- *
60
  * If $data empty, $_POST will be checked
61
- *
62
  * @global type $wpcf
63
  * @param type $data
64
- * @return boolean
65
  */
66
  function save( $data = null ) {
67
 
@@ -83,7 +83,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
83
  foreach ( $data as $meta_value ) {
84
 
85
  /*
86
- *
87
  * Deprecated!
88
  */
89
  if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
@@ -123,8 +123,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
123
 
124
  /**
125
  * Fetch and sort fields.
126
- *
127
- * @global type $wpdb
128
  */
129
  function _get_meta() {
130
  global $wpdb;
@@ -132,7 +132,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
132
  $cache_key = md5( 'usermetarepeater::_get_meta' . $this->currentUID . $this->slug );
133
  $cache_group = 'types_cache';
134
  $cached_object = wp_cache_get( $cache_key, $cache_group );
135
-
136
  if ( $this->use_cache ) {
137
  if ( false != $cached_object && is_array( $cached_object ) ) {
138
  return $cached_object;
@@ -146,10 +146,10 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
146
  $ordered = array();
147
  $this->order = get_user_meta( $this->currentUID, $this->order_meta_name,
148
  true );
149
-
150
  $cache_key_userfield = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
151
  $cached_object_userfield = wp_cache_get( $cache_key_userfield, $cache_group );
152
-
153
  if ( $this->use_cache ) {
154
  if ( false != $cached_object_userfield && is_array( $cached_object_userfield ) ) {// WordPress cache
155
  $r = $cached_object_userfield;
@@ -221,8 +221,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
221
  }
222
 
223
  /**
224
- * Sets repetitive field form.
225
- *
226
  * @todo Make more distinction between $field_form and $form_field
227
  */
228
  function get_fields_form( $is_profile = '' ) {
@@ -273,8 +273,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
273
 
274
  // Set style
275
  /*
276
- *
277
- *
278
  * Hide if field not passed check
279
  * TODO Move this to WPCF_Conditional
280
  */
@@ -286,17 +286,17 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
286
  $css_cd = !$show ? 'display:none;' : '';
287
 
288
  /**
289
- *
290
- *
291
- *
292
- *
293
  * Set title and description
294
  * TODO See if can be improved getting main element
295
- *
296
  * Get first element and extract details
297
  * Pass emty string as value to avoid using meta as array
298
  */
299
- //
300
  $_c = array_values( parent::_get_meta_form( '' ) );
301
  array_shift( $_c );
302
  $_main_element = array_shift( $_c );
@@ -319,8 +319,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
319
  );
320
 
321
  /*
322
- *
323
- *
324
  * Start wrapper
325
  */
326
  $form[$unique_id . '_repetitive_wrapper_open'] = array(
@@ -334,12 +334,12 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
334
 
335
  // Set hidden mark field
336
  /*
337
- *
338
- *
339
- *
340
  * This actually marks field as repetitive
341
  * IMPORTANT!!! IF NOT marked field won't be saved at all!
342
- *
343
  * @see wpcf_admin_post_save_post_hook()
344
  */
345
  $form[$form_id . '_hidden_mark'] = array(
@@ -406,9 +406,9 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
406
 
407
  /**
408
  * Sete repetitive form for single field.
409
- *
410
  * @param type $meta
411
- * @return string
412
  */
413
  function get_field_form( $meta_value = null, $meta_id = null ) {
414
 
@@ -435,7 +435,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
435
  $field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
436
 
437
  /*
438
- *
439
  * Apply filters to each form element.
440
  * Here we add specific properties
441
  * e.g. Skype alters fields.
@@ -444,7 +444,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
444
  foreach ( $field_form as $k => $field ) {
445
 
446
  /*
447
- *
448
  * IMPORTANT
449
  * We change name to hold array
450
  */
@@ -534,7 +534,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
534
  }
535
 
536
  /**
537
- * Set counting elements.
538
  */
539
  function _set_form_count() {
540
  if ( $this->index === 0 ) {
@@ -547,8 +547,11 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
547
 
548
  /**
549
  * Deletes meta.
550
- *
551
- * @param type $meta_key
 
 
 
552
  */
553
  function delete( $meta_id ) {
554
  global $wpdb;
@@ -568,4 +571,4 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
568
  return $r;
569
  }
570
 
571
- }
8
 
9
  /**
10
  * Field order
11
+ *
12
+ * @var type
13
  */
14
  var $order;
15
 
16
  /**
17
  * Indexing
18
+ *
19
  * Set counts when processing fields.
20
+ *
21
+ * @var type
22
  */
23
  var $index = 0;
24
 
25
  /**
26
  * Field title
27
+ * @var type
28
  */
29
  var $title = '';
30
 
31
  /**
32
  * Field description.
33
+ *
34
+ * @var type
35
  */
36
  var $description = '';
37
 
45
 
46
  /**
47
  * Calls parent set func.
48
+ *
49
  * @param type $post
50
+ * @param type $field
51
  */
52
  function set( $user_id, $field ) {
53
  parent::set( $user_id, $field );
56
 
57
  /**
58
  * Save fields
59
+ *
60
  * If $data empty, $_POST will be checked
61
+ *
62
  * @global type $wpcf
63
  * @param type $data
64
+ * @return boolean
65
  */
66
  function save( $data = null ) {
67
 
83
  foreach ( $data as $meta_value ) {
84
 
85
  /*
86
+ *
87
  * Deprecated!
88
  */
89
  if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
123
 
124
  /**
125
  * Fetch and sort fields.
126
+ *
127
+ * @global object $wpdb
128
  */
129
  function _get_meta() {
130
  global $wpdb;
132
  $cache_key = md5( 'usermetarepeater::_get_meta' . $this->currentUID . $this->slug );
133
  $cache_group = 'types_cache';
134
  $cached_object = wp_cache_get( $cache_key, $cache_group );
135
+
136
  if ( $this->use_cache ) {
137
  if ( false != $cached_object && is_array( $cached_object ) ) {
138
  return $cached_object;
146
  $ordered = array();
147
  $this->order = get_user_meta( $this->currentUID, $this->order_meta_name,
148
  true );
149
+
150
  $cache_key_userfield = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
151
  $cached_object_userfield = wp_cache_get( $cache_key_userfield, $cache_group );
152
+
153
  if ( $this->use_cache ) {
154
  if ( false != $cached_object_userfield && is_array( $cached_object_userfield ) ) {// WordPress cache
155
  $r = $cached_object_userfield;
221
  }
222
 
223
  /**
224
+ * Sets repetitive field form.
225
+ *
226
  * @todo Make more distinction between $field_form and $form_field
227
  */
228
  function get_fields_form( $is_profile = '' ) {
273
 
274
  // Set style
275
  /*
276
+ *
277
+ *
278
  * Hide if field not passed check
279
  * TODO Move this to WPCF_Conditional
280
  */
286
  $css_cd = !$show ? 'display:none;' : '';
287
 
288
  /**
289
+ *
290
+ *
291
+ *
292
+ *
293
  * Set title and description
294
  * TODO See if can be improved getting main element
295
+ *
296
  * Get first element and extract details
297
  * Pass emty string as value to avoid using meta as array
298
  */
299
+ //
300
  $_c = array_values( parent::_get_meta_form( '' ) );
301
  array_shift( $_c );
302
  $_main_element = array_shift( $_c );
319
  );
320
 
321
  /*
322
+ *
323
+ *
324
  * Start wrapper
325
  */
326
  $form[$unique_id . '_repetitive_wrapper_open'] = array(
334
 
335
  // Set hidden mark field
336
  /*
337
+ *
338
+ *
339
+ *
340
  * This actually marks field as repetitive
341
  * IMPORTANT!!! IF NOT marked field won't be saved at all!
342
+ *
343
  * @see wpcf_admin_post_save_post_hook()
344
  */
345
  $form[$form_id . '_hidden_mark'] = array(
406
 
407
  /**
408
  * Sete repetitive form for single field.
409
+ *
410
  * @param type $meta
411
+ * @return string
412
  */
413
  function get_field_form( $meta_value = null, $meta_id = null ) {
414
 
435
  $field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
436
 
437
  /*
438
+ *
439
  * Apply filters to each form element.
440
  * Here we add specific properties
441
  * e.g. Skype alters fields.
444
  foreach ( $field_form as $k => $field ) {
445
 
446
  /*
447
+ *
448
  * IMPORTANT
449
  * We change name to hold array
450
  */
534
  }
535
 
536
  /**
537
+ * Set counting elements.
538
  */
539
  function _set_form_count() {
540
  if ( $this->index === 0 ) {
547
 
548
  /**
549
  * Deletes meta.
550
+ *
551
+ * @global object $wpdb
552
+ *
553
+ * @param type $meta_key
554
+ *
555
  */
556
  function delete( $meta_id ) {
557
  global $wpdb;
571
  return $r;
572
  }
573
 
574
+ }
embedded/classes/validate.php CHANGED
@@ -388,6 +388,29 @@ class Wpcf_Validate
388
  return $form;
389
  }
390
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  public static function setForced( $element, $field, $data = array() )
392
  {
393
  $attributes = array();
@@ -432,4 +455,4 @@ class Wpcf_Validate
432
  return true;
433
  }
434
 
435
- }
388
  return $form;
389
  }
390
 
391
+ /**
392
+ * Returns form data.
393
+ *
394
+ * @param type $field
395
+ * @param type $data
396
+ * @return array
397
+ */
398
+ public static function skype_form( $field, $data = array() )
399
+ {
400
+ $form = array();
401
+ $form['skype-checkbox'] = array(
402
+ '#type' => 'checkbox',
403
+ '#title' => 'Skype',
404
+ '#name' => $field['#name'] . '[active]',
405
+ '#default_value' => isset( $data['active'] ) ? 1 : 0,
406
+ '#inline' => true,
407
+ '#suffix' => '<br />',
408
+ );
409
+ $form['skype-checkbox'] = self::setForced( $form['skype-checkbox'], $field, $data );
410
+ $form['skype-message'] = self::get_custom_message( $field, self::get_message( 'skype' ), $data );
411
+ return $form;
412
+ }
413
+
414
  public static function setForced( $element, $field, $data = array() )
415
  {
416
  $attributes = array();
455
  return true;
456
  }
457
 
458
+ }
embedded/classes/validation-cakephp.php CHANGED
@@ -195,6 +195,29 @@ class Wpcf_Cake_Validation
195
  return $return;
196
  }
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  /**
199
  * Checks that a string length is within s specified range.
200
  * Spaces are included in the character count.
195
  return $return;
196
  }
197
 
198
+ function skype( $check ) {
199
+ $_this = &Wpcf_Cake_Validation::getInstance();
200
+ $_this->__reset();
201
+ $_this->check = $check;
202
+
203
+ if ( is_array( $check ) ) {
204
+ $_this->_extract( $check );
205
+ }
206
+
207
+ if ( empty( $_this->check ) && $_this->check != '0' ) {
208
+ return false;
209
+ }
210
+ $_this->regex = '/^[a-zA-Z0-9\s\-\_]*$/mu';
211
+ $return = $_this->_check();
212
+
213
+ if ( !$return ) {
214
+ $_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}\s\-\_]+$/mu';
215
+ $return = $_this->_check();
216
+ }
217
+
218
+ return $return;
219
+ }
220
+
221
  /**
222
  * Checks that a string length is within s specified range.
223
  * Spaces are included in the character count.
embedded/common/changelog.txt CHANGED
@@ -1,3 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  -------------------------------------------------------------------------------------------------------------------
2
  Common 1.4 (Feb 2 2015)
3
  - Tagged for Views 1.7, Types 1.6.5, CRED 1.3.5 and Layouts 1.0 beta1
@@ -11,4 +24,4 @@ Common 1.3.1 (Dec 16 2014)
11
 
12
  -------------------------------------------------------------------------------------------------------------------
13
  Common 1.3 (Dec 15 2014)
14
- - Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
1
+
2
+
3
+ -------------------------------------------------------------------------------------------------------------------
4
+ Common 1.5 (Apr 1, 2015)
5
+ - Tagged for Types 1.6.6, Views 1.8, CRED 1.3.6 and Layouts 1.1.
6
+ - Fixed issue when there is more than one CRED form on a page with the same taxonomy.
7
+ - Fixed a little problem with edit skype button modal window - was too narrow.
8
+ - Fixed empty title problem for filter "wpt_field_options" on user edit/add screen.
9
+ https://wp-types.com/forums/topic/populate-select-field-in-wpcf-um-group/
10
+ - Added filter "toolset_editor_add_form_buttons" to disable Toolset buttons on the post editor.
11
+ - Added placeholder attributes to fields.
12
+ - Updated CakePHP validation URL method to allow new TLD's.
13
+
14
  -------------------------------------------------------------------------------------------------------------------
15
  Common 1.4 (Feb 2 2015)
16
  - Tagged for Views 1.7, Types 1.6.5, CRED 1.3.5 and Layouts 1.0 beta1
24
 
25
  -------------------------------------------------------------------------------------------------------------------
26
  Common 1.3 (Dec 15 2014)
27
+ - Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
embedded/common/classes/class.toolset.promo.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/classes/class.toolset.promo.php $
6
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
7
+ * $LastChangedRevision: 1120400 $
8
+ * $LastChangedBy: iworks $
9
+ *
10
+ */
11
+
12
+ if (!class_exists('Toolset_Promotion')) {
13
+
14
+ /**
15
+ * Class to show promotion message.
16
+ *
17
+ * @since 1.5
18
+ * @access public
19
+ */
20
+ class Toolset_Promotion
21
+ {
22
+ private $version = '1.0';
23
+
24
+ public function __construct()
25
+ {
26
+ add_action('admin_init', array($this, 'admin_init'));
27
+ add_action('admin_footer', array($this, 'admin_footer'));
28
+ add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
29
+ add_action('plugins_loaded', 'on_the_go_systems_branding_plugins_loaded');
30
+ }
31
+
32
+ /**
33
+ * Register script and styles
34
+ *
35
+ * Register script and styles for future usage.
36
+ *
37
+ * @since 1.5
38
+ *
39
+ */
40
+ public function admin_init()
41
+ {
42
+ wp_register_script(
43
+ 'toolset-colorbox',
44
+ plugins_url('/res/js/jquery.colorbox-min.js', dirname(__FILE__)),
45
+ array('jquery'),
46
+ '1.4.31'
47
+ );
48
+ wp_register_script(
49
+ __CLASS__,
50
+ plugins_url('/res/js/toolset-promotion.js', dirname(__FILE__)),
51
+ array('underscore', 'toolset-colorbox'),
52
+ $this->version,
53
+ true
54
+ );
55
+ wp_register_style(
56
+ 'toolset-colorbox',
57
+ plugins_url('/res/css/colorbox.css', dirname(__FILE__)),
58
+ false,
59
+ '1.4.31'
60
+ );
61
+ wp_register_style(
62
+ __CLASS__,
63
+ plugins_url('/res/css/toolset-promotion.css', dirname(__FILE__)),
64
+ array('toolset-colorbox', 'onthego-admin-styles'),
65
+ $this->version
66
+ );
67
+ }
68
+
69
+ /**
70
+ * Enqueue scripts & styles
71
+ *
72
+ * After check is a correct place, this function enqueue scripts & styles
73
+ * for toolset promotion box.
74
+ *
75
+ * @since 1.5
76
+ *
77
+ */
78
+ public function admin_enqueue_scripts()
79
+ {
80
+ if (!is_admin() || !function_exists('get_current_screen')) {
81
+ return;
82
+ }
83
+ /**
84
+ * List of admin page id
85
+ *
86
+ * Filter allow to add or change list of admin screen id for checking
87
+ * where we need enqueue toolset promotion assets.
88
+ *
89
+ * @since 1.5
90
+ *
91
+ * @param array $screen_ids List of admin page screen ids.
92
+ *
93
+ */
94
+ $screen_ids = apply_filters('toolset_promotion_screen_ids', array());
95
+ if (empty($screen_ids)) {
96
+ return;
97
+ }
98
+ $screen = get_current_screen();
99
+ if (!in_array($screen->id, $screen_ids)) {
100
+ return;
101
+ }
102
+ wp_enqueue_style(__CLASS__);
103
+ wp_enqueue_script(__CLASS__);
104
+ }
105
+
106
+ /**
107
+ * Print in footer
108
+ *
109
+ * Print nessary elemnt in admin footer
110
+ *
111
+ * @since 1.5
112
+ *
113
+ */
114
+ public function admin_footer()
115
+ {
116
+ $link_learn = $this->get_affiliate_link_string('http://wp-types.com/');
117
+ $link_button = $this->get_affiliate_link_string('http://wp-types.com/#buy-toolset');
118
+
119
+ ob_start();
120
+ ?>
121
+
122
+ <div class="ddl-dialogs-container">
123
+ <div id="js-buy-toolset-embedded-message-wrap"></div>
124
+ </div>
125
+ <script type="text/html" id="js-buy-toolset-embedded-message">
126
+ <div class="toolset-modal">
127
+ <h2><?php _e('Want to edit Views, CRED forms and Layouts? Get the full <em>Toolset</em> package!', 'wpcf'); ?></h2>
128
+
129
+ <div class="content">
130
+ <p class="full"><?php _e('The full <em>Toolset</em> package allows you to develop and customize themes without touching PHP. You will be able to:', 'wpcf'); ?></p>
131
+
132
+ <div class="icons">
133
+ <ul>
134
+ <li class="template"><?php _e('Create templates', 'wpcf'); ?></li>
135
+ <li class="layout"><?php _e('Design page layouts using drag-and-drop', 'wpcf'); ?></li>
136
+ <li class="toolset-search"><?php _e('Build parametric searches', 'wpcf'); ?></li>
137
+ </ul>
138
+ <ul>
139
+ <li class="list"><?php _e('Display lists of content', 'wpcf'); ?></li>
140
+ <li class="form"><?php _e('Create front-end content editing forms', 'wpcf'); ?></li>
141
+ <li class="more"><?php _e('and more…', 'wpcf'); ?></li>
142
+ </ul>
143
+ </div>
144
+
145
+ <p class="description"><?php _e('Once you buy the full Toolset, you will be able to edit Views, CRED forms and Layouts in your site, as well as build new ones.', 'wpcf'); ?></p>
146
+
147
+ <a href="<?php echo $link_button; ?>"
148
+ class="button"><?php _e('<em>Toolset</em> Package Options', 'wpcf'); ?></a>
149
+ <a href="<?php echo $link_learn; ?>"
150
+ class="learn"><?php _e('Learn more about <em>Toolset</em>', 'wpcf'); ?></a>
151
+
152
+ </div>
153
+ <span class="icon-toolset-logo"></span>
154
+ <span class="js-close-promotional-message"></span>
155
+ </div>
156
+ </script>
157
+ <?php
158
+ echo ob_get_clean();
159
+ }
160
+
161
+ private function get_affiliate_link_string($link)
162
+ {
163
+ if (function_exists('installer_ep_get_configuration') === false) {
164
+ return $link;
165
+ }
166
+
167
+ $info = installer_ep_get_configuration(wp_get_theme()->Name);
168
+
169
+ if (!isset($info['repositories']) &&
170
+ !isset($info['repositories']['toolset'])
171
+ ) {
172
+ return $link;
173
+
174
+ } else if (
175
+ isset($info['repositories']['toolset']['affiliate_id']) &&
176
+ isset($info['repositories']['toolset']['affiliate_key'])
177
+ ) {
178
+ $id = $info['repositories']['toolset']['affiliate_id'];
179
+ $key = $info['repositories']['toolset']['affiliate_key'];
180
+
181
+ $hash = explode( '#', $link );
182
+ if( count($hash) > 1 ){
183
+ $link = $hash[0];
184
+ $hash = "#" . $hash[1];
185
+ } else {
186
+ $hash = '';
187
+ }
188
+
189
+ return sprintf("%s?aid=%s&affiliate_key=%s%s", $link, $id, $key, $hash);
190
+ }
191
+
192
+ return $link;
193
+ }
194
+
195
+ }
196
+
197
+ }
embedded/common/classes/forms.php CHANGED
@@ -2,15 +2,15 @@
2
  /**
3
  * Returns HTML formatted output for elements and handles form submission.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/classes/forms.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  * @version 1.0
11
  */
12
- if (!class_exists('Enlimbo_Forms_Wpcf')) {
13
-
14
  class Enlimbo_Forms_Wpcf
15
  {
16
 
@@ -932,8 +932,10 @@ if (!class_exists('Enlimbo_Forms_Wpcf')) {
932
  }
933
 
934
  $parts = explode('[', $name);
935
- $parts = array_map(create_function('&$a', 'return trim($a, \']\');'),
936
- $parts);
 
 
937
  if (!isset($_REQUEST[$parts[0]])) {
938
  return in_array($element['#type'],
939
  array('textfield', 'textarea')) ? '' : 0;
2
  /**
3
  * Returns HTML formatted output for elements and handles form submission.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/classes/forms.php $
6
+ * $LastChangedDate: 2015-03-16 12:03:31 +0000 (Mon, 16 Mar 2015) $
7
+ * $LastChangedRevision: 1113864 $
8
  * $LastChangedBy: iworks $
9
  *
10
  * @version 1.0
11
  */
12
+ if (!class_exists('Enlimbo_Forms_Wpcf')) {
13
+
14
  class Enlimbo_Forms_Wpcf
15
  {
16
 
932
  }
933
 
934
  $parts = explode('[', $name);
935
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196173458/comments
936
+ //Security Fixing
937
+ //$parts = array_map(create function('&$a', 'return trim($a, \']\');'), $parts);
938
+ $parts = array_map("cred_mytrimfunction", $parts);
939
  if (!isset($_REQUEST[$parts[0]])) {
940
  return in_array($element['#type'],
941
  array('textfield', 'textarea')) ? '' : 0;
embedded/common/debug/debug-information.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  * produce debug information
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/debug/debug-information.php $
7
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
  * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
3
  /**
4
  * produce debug information
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/debug/debug-information.php $
7
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
  * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
embedded/common/debug/functions_debug_information.php CHANGED
@@ -2,9 +2,9 @@
2
  /**
3
  * produce debug information
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/debug/functions_debug_information.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -23,7 +23,7 @@ class ICL_Debug_Information
23
  if (empty($info)) {
24
  $info = array('core', 'plugins', 'theme', 'extra-debug');
25
  }
26
-
27
  $output = array();
28
  foreach ($info as $type) {
29
  switch ($type) {
@@ -42,12 +42,17 @@ class ICL_Debug_Information
42
  }
43
  }
44
  return $output;
45
- }
46
-
 
 
 
 
 
47
  function get_core_info() {
48
-
49
  global $wpdb;
50
-
51
  $core = array(
52
  'Wordpress' => array(
53
  'Multisite' => is_multisite() ? 'Yes' : 'No',
@@ -77,12 +82,12 @@ class ICL_Debug_Information
77
  }
78
 
79
  function get_plugins_info() {
80
-
81
  if ( ! function_exists( 'get_plugins' ) ) {
82
  $admin_includes_path = str_replace( site_url('/', 'admin'), ABSPATH, admin_url('includes/', 'admin') );
83
  require_once $admin_includes_path . 'plugin.php';
84
  }
85
-
86
  $plugins = get_plugins();
87
  $active_plugins = get_option('active_plugins');
88
  $active_plugins_info = array();
@@ -92,7 +97,7 @@ class ICL_Debug_Information
92
  $active_plugins_info[$plugin] = $plugins[$plugin];
93
  }
94
  }
95
-
96
  $mu_plugins = get_mu_plugins();
97
 
98
  $dropins = get_dropins();
@@ -102,12 +107,12 @@ class ICL_Debug_Information
102
  'mu_plugins' => $mu_plugins,
103
  'dropins' => $dropins,
104
  );
105
-
106
  return $output;
107
  }
108
-
109
  function get_theme_info() {
110
-
111
  if ( get_bloginfo( 'version' ) < '3.4' ) {
112
  $current_theme = get_theme_data( get_stylesheet_directory() . '/style.css' );
113
  $theme = $current_theme;
@@ -127,7 +132,7 @@ class ICL_Debug_Information
127
  'DomainPath' => $current_theme->DomainPath,
128
  );
129
  }
130
-
131
  return $theme;
132
  }
133
 
2
  /**
3
  * produce debug information
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/debug/functions_debug_information.php $
6
+ * $LastChangedDate: 2015-03-16 12:03:31 +0000 (Mon, 16 Mar 2015) $
7
+ * $LastChangedRevision: 1113864 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
23
  if (empty($info)) {
24
  $info = array('core', 'plugins', 'theme', 'extra-debug');
25
  }
26
+
27
  $output = array();
28
  foreach ($info as $type) {
29
  switch ($type) {
42
  }
43
  }
44
  return $output;
45
+ }
46
+
47
+ /**
48
+ *
49
+ * @global object $wpdb
50
+ *
51
+ */
52
  function get_core_info() {
53
+
54
  global $wpdb;
55
+
56
  $core = array(
57
  'Wordpress' => array(
58
  'Multisite' => is_multisite() ? 'Yes' : 'No',
82
  }
83
 
84
  function get_plugins_info() {
85
+
86
  if ( ! function_exists( 'get_plugins' ) ) {
87
  $admin_includes_path = str_replace( site_url('/', 'admin'), ABSPATH, admin_url('includes/', 'admin') );
88
  require_once $admin_includes_path . 'plugin.php';
89
  }
90
+
91
  $plugins = get_plugins();
92
  $active_plugins = get_option('active_plugins');
93
  $active_plugins_info = array();
97
  $active_plugins_info[$plugin] = $plugins[$plugin];
98
  }
99
  }
100
+
101
  $mu_plugins = get_mu_plugins();
102
 
103
  $dropins = get_dropins();
107
  'mu_plugins' => $mu_plugins,
108
  'dropins' => $dropins,
109
  );
110
+
111
  return $output;
112
  }
113
+
114
  function get_theme_info() {
115
+
116
  if ( get_bloginfo( 'version' ) < '3.4' ) {
117
  $current_theme = get_theme_data( get_stylesheet_directory() . '/style.css' );
118
  $theme = $current_theme;
132
  'DomainPath' => $current_theme->DomainPath,
133
  );
134
  }
135
+
136
  return $theme;
137
  }
138
 
embedded/common/expression-parser/js/parser.js CHANGED
@@ -1602,14 +1602,14 @@ window.ToolsetParser=window.ToolsetParser ||
1602
  if (varTmp != "RAND")
1603
  {
1604
  if (arrArgs.length < 1)
1605
- throw varTmp + " requires atleast one argument!";
1606
  else if (arrArgs.length > 1)
1607
  throw varTmp + " requires only one argument!";
1608
  }
1609
  else
1610
  {
1611
  if (arrArgs.length < 1)
1612
- throw varTmp + " requires atleast one argument!";
1613
  else if (arrArgs.length > 2)
1614
  throw varTmp + " requires at most two arguments!";
1615
  }
@@ -1687,7 +1687,7 @@ window.ToolsetParser=window.ToolsetParser ||
1687
  break;
1688
  case "STR" :
1689
  if (arrArgs.length < 1)
1690
- throw varTmp + " requires atleast one argument!";
1691
  else if (arrArgs.length > 2)
1692
  throw varTmp + " requires at most two arguments!";
1693
  varTerm = arrArgs[arrArgs.length-1];
@@ -1729,7 +1729,7 @@ window.ToolsetParser=window.ToolsetParser ||
1729
  if (arrArgs.length > 1)
1730
  throw varTmp + " requires only one argument!";
1731
  else if (arrArgs.length < 1)
1732
- throw varTmp + " requires atleast one argument!";
1733
  varTerm = arrArgs[0];
1734
  if (varTerm.isVariable)
1735
  {
@@ -1758,7 +1758,7 @@ window.ToolsetParser=window.ToolsetParser ||
1758
  break;
1759
  case "REGEX" :
1760
  if (arrArgs.length < 1)
1761
- throw varTmp + " requires atleast one argument!";
1762
  else if (arrArgs.length > 2)
1763
  throw varTmp + " requires at most two arguments!";
1764
 
@@ -1798,7 +1798,7 @@ window.ToolsetParser=window.ToolsetParser ||
1798
  case "NUM" :
1799
 
1800
  if (arrArgs.length < 1)
1801
- throw varTmp + " requires atleast one argument!";
1802
  else if (arrArgs.length > 1)
1803
  throw varTmp + " requires only one argument!";
1804
 
@@ -1841,7 +1841,7 @@ window.ToolsetParser=window.ToolsetParser ||
1841
  break;
1842
  case "LEN" :
1843
  if (arrArgs.length < 1)
1844
- throw varTmp + " requires atleast one argument!";
1845
  else if (arrArgs.length > 1)
1846
  throw varTmp + " requires only one argument!";
1847
 
@@ -1864,7 +1864,7 @@ window.ToolsetParser=window.ToolsetParser ||
1864
  break;
1865
  case "USER" :
1866
  if (arrArgs.length < 1)
1867
- throw varTmp + " requires atleast one argument!";
1868
  else if (arrArgs.length > 1)
1869
  throw varTmp + " requires only one argument!";
1870
 
@@ -1887,7 +1887,7 @@ window.ToolsetParser=window.ToolsetParser ||
1887
  break;
1888
  case "COOKIE" :
1889
  if (arrArgs.length < 1)
1890
- throw varTmp + " requires atleast one argument!";
1891
  else if (arrArgs.length > 1)
1892
  throw varTmp + " requires only one argument!";
1893
 
@@ -1912,7 +1912,7 @@ window.ToolsetParser=window.ToolsetParser ||
1912
  case "CONTAINS" :
1913
  // console.log( 'testing functions ', varTmp, arrArgs );
1914
  if (arrArgs.length < 2)
1915
- throw varTmp + " requires atleast two arguments!";
1916
  else if (arrArgs.length > 2)
1917
  throw varTmp + " requires only two arguments!";
1918
 
@@ -1955,7 +1955,7 @@ window.ToolsetParser=window.ToolsetParser ||
1955
  break;
1956
  case "DATE" :
1957
  if (arrArgs.length < 2)
1958
- throw varTmp + " requires atleast two arguments!";
1959
  else if (arrArgs.length > 2)
1960
  throw varTmp + " requires only two arguments!";
1961
 
@@ -2030,7 +2030,7 @@ window.ToolsetParser=window.ToolsetParser ||
2030
  case "LEFT" :
2031
  case "RIGHT" :
2032
  if (arrArgs.length < 2)
2033
- throw varTmp + " requires atleast two arguments!";
2034
  else if (arrArgs.length > 2)
2035
  throw varTmp + " requires only two arguments!";
2036
 
@@ -2073,7 +2073,7 @@ window.ToolsetParser=window.ToolsetParser ||
2073
  case "IIF" :
2074
 
2075
  if (arrArgs.length < 3)
2076
- throw varTmp + " requires atleast three arguments!";
2077
  else if (arrArgs.length > 3)
2078
  throw varTmp + " requires only three arguments!";
2079
 
@@ -2134,7 +2134,7 @@ window.ToolsetParser=window.ToolsetParser ||
2134
  case "MAX" :
2135
  case "MIN" :
2136
  if (arrArgs.length < 1)
2137
- throw varTmp + " requires atleast one operand!";
2138
 
2139
  var _arr=[];
2140
  intCntr = arrArgs.length;
1602
  if (varTmp != "RAND")
1603
  {
1604
  if (arrArgs.length < 1)
1605
+ throw varTmp + " requires at least one argument!";
1606
  else if (arrArgs.length > 1)
1607
  throw varTmp + " requires only one argument!";
1608
  }
1609
  else
1610
  {
1611
  if (arrArgs.length < 1)
1612
+ throw varTmp + " requires at least one argument!";
1613
  else if (arrArgs.length > 2)
1614
  throw varTmp + " requires at most two arguments!";
1615
  }
1687
  break;
1688
  case "STR" :
1689
  if (arrArgs.length < 1)
1690
+ throw varTmp + " requires at least one argument!";
1691
  else if (arrArgs.length > 2)
1692
  throw varTmp + " requires at most two arguments!";
1693
  varTerm = arrArgs[arrArgs.length-1];
1729
  if (arrArgs.length > 1)
1730
  throw varTmp + " requires only one argument!";
1731
  else if (arrArgs.length < 1)
1732
+ throw varTmp + " requires at least one argument!";
1733
  varTerm = arrArgs[0];
1734
  if (varTerm.isVariable)
1735
  {
1758
  break;
1759
  case "REGEX" :
1760
  if (arrArgs.length < 1)
1761
+ throw varTmp + " requires at least one argument!";
1762
  else if (arrArgs.length > 2)
1763
  throw varTmp + " requires at most two arguments!";
1764
 
1798
  case "NUM" :
1799
 
1800
  if (arrArgs.length < 1)
1801
+ throw varTmp + " requires at least one argument!";
1802
  else if (arrArgs.length > 1)
1803
  throw varTmp + " requires only one argument!";
1804
 
1841
  break;
1842
  case "LEN" :
1843
  if (arrArgs.length < 1)
1844
+ throw varTmp + " requires at least one argument!";
1845
  else if (arrArgs.length > 1)
1846
  throw varTmp + " requires only one argument!";
1847
 
1864
  break;
1865
  case "USER" :
1866
  if (arrArgs.length < 1)
1867
+ throw varTmp + " requires at least one argument!";
1868
  else if (arrArgs.length > 1)
1869
  throw varTmp + " requires only one argument!";
1870
 
1887
  break;
1888
  case "COOKIE" :
1889
  if (arrArgs.length < 1)
1890
+ throw varTmp + " requires at least one argument!";
1891
  else if (arrArgs.length > 1)
1892
  throw varTmp + " requires only one argument!";
1893
 
1912
  case "CONTAINS" :
1913
  // console.log( 'testing functions ', varTmp, arrArgs );
1914
  if (arrArgs.length < 2)
1915
+ throw varTmp + " requires at least two arguments!";
1916
  else if (arrArgs.length > 2)
1917
  throw varTmp + " requires only two arguments!";
1918
 
1955
  break;
1956
  case "DATE" :
1957
  if (arrArgs.length < 2)
1958
+ throw varTmp + " requires at least two arguments!";
1959
  else if (arrArgs.length > 2)
1960
  throw varTmp + " requires only two arguments!";
1961
 
2030
  case "LEFT" :
2031
  case "RIGHT" :
2032
  if (arrArgs.length < 2)
2033
+ throw varTmp + " requires at least two arguments!";
2034
  else if (arrArgs.length > 2)
2035
  throw varTmp + " requires only two arguments!";
2036
 
2073
  case "IIF" :
2074
 
2075
  if (arrArgs.length < 3)
2076
+ throw varTmp + " requires at least three arguments!";
2077
  else if (arrArgs.length > 3)
2078
  throw varTmp + " requires only three arguments!";
2079
 
2134
  case "MAX" :
2135
  case "MIN" :
2136
  if (arrArgs.length < 1)
2137
+ throw varTmp + " requires at least one operand!";
2138
 
2139
  var _arr=[];
2140
  intCntr = arrArgs.length;
embedded/common/expression-parser/parser.php CHANGED
@@ -1639,14 +1639,14 @@ class Toolset_Parser
1639
  if ($varTmp != "RAND")
1640
  {
1641
  if (count($arrArgs) < 1)
1642
- throw new Exception($varTmp . " requires atleast one argument!");
1643
  else if (count($arrArgs) > 1)
1644
  throw new Exception($varTmp . " requires only one argument!");
1645
  }
1646
  else
1647
  {
1648
  if (count($arrArgs) < 1)
1649
- throw new Exception($varTmp . " requires atleast one argument!");
1650
  else if (count($arrArgs) > 2)
1651
  throw new Exception($varTmp . " requires at most two arguments!");
1652
  }
@@ -1717,7 +1717,7 @@ class Toolset_Parser
1717
  break;
1718
  case "STR" :
1719
  if (count($arrArgs) < 1)
1720
- throw new Exception($varTmp . " requires atleast one argument!");
1721
  else if (count($arrArgs) > 2)
1722
  throw new Exception($varTmp . " requires at most two arguments!");
1723
  $varTerm = $arrArgs[count($arrArgs)-1];
@@ -1756,7 +1756,7 @@ class Toolset_Parser
1756
  if (count($arrArgs) > 1)
1757
  throw new Exception($varTmp . " requires only one argument!");
1758
  else if (count($arrArgs) < 1)
1759
- throw new Exception($varTmp . " requires atleast one argument!");
1760
  $varTerm = $arrArgs[0];
1761
  if ($varTerm->isVariable)
1762
  {
@@ -1791,7 +1791,7 @@ class Toolset_Parser
1791
  break;
1792
  case "REGEX" :
1793
  if (count($arrArgs) < 1)
1794
- throw new Exception($varTmp . " requires atleast one argument!");
1795
  else if (count($arrArgs) > 2)
1796
  throw new Exception($varTmp . " requires at most two arguments!");
1797
 
@@ -1828,7 +1828,7 @@ class Toolset_Parser
1828
  case "UCASE" :
1829
  case "NUM" :
1830
  if (count($arrArgs) < 1)
1831
- throw new Exception($varTmp . " requires atleast one argument!");
1832
  else if (count($arrArgs) > 1)
1833
  throw new Exception($varTmp . " requires only one argument!");
1834
 
@@ -1870,7 +1870,7 @@ class Toolset_Parser
1870
  break;
1871
  case "LEN" :
1872
  if (count($arrArgs) < 1)
1873
- throw new Exception($varTmp . " requires atleast one argument!");
1874
  else if (count($arrArgs) > 1)
1875
  throw new Exception($varTmp . " requires only one argument!");
1876
 
@@ -1895,7 +1895,7 @@ class Toolset_Parser
1895
  break;
1896
  case "USER" :
1897
  if (count($arrArgs) < 1)
1898
- throw new Exception($varTmp . " requires atleast one argument!");
1899
  else if (count($arrArgs) > 1)
1900
  throw new Exception($varTmp . " requires only one argument!");
1901
 
@@ -1917,7 +1917,7 @@ class Toolset_Parser
1917
  break;
1918
  case "COOKIE" :
1919
  if (count($arrArgs) < 1)
1920
- throw new Exception($varTmp . " requires atleast one argument!");
1921
  else if (count($arrArgs) > 1)
1922
  throw new Exception($varTmp . " requires only one argument!");
1923
 
@@ -1939,7 +1939,7 @@ class Toolset_Parser
1939
  break;
1940
  case "CONTAINS" :
1941
  if (count($arrArgs) < 2)
1942
- throw new Exception($varTmp . " requires atleast two arguments!");
1943
  else if (count($arrArgs) > 2)
1944
  throw new Exception($varTmp . " requires only two arguments!");
1945
 
@@ -1970,7 +1970,7 @@ class Toolset_Parser
1970
  break;
1971
  case "DATE" :
1972
  if (count($arrArgs) < 2)
1973
- throw new Exception($varTmp . " requires atleast two arguments!");
1974
  else if (count($arrArgs) > 2)
1975
  throw new Exception($varTmp . " requires only two arguments!");
1976
 
@@ -2010,7 +2010,7 @@ class Toolset_Parser
2010
  case "empty" :
2011
  case "EMPTY" :
2012
  if (count($arrArgs) < 1)
2013
- throw new Exception($varTmp . " requires atleast one argument!");
2014
  else if (count($arrArgs) > 1)
2015
  throw new Exception($varTmp . " requires only one arguments!");
2016
 
@@ -2041,7 +2041,7 @@ class Toolset_Parser
2041
  case "LEFT" :
2042
  case "RIGHT" :
2043
  if (count($arrArgs) < 2)
2044
- throw new Exception($varTmp . " requires atleast two arguments!");
2045
  else if (count($arrArgs) > 2)
2046
  throw new Exception($varTmp . " requires only two arguments!");
2047
 
@@ -2082,7 +2082,7 @@ class Toolset_Parser
2082
  case "MID" :
2083
  case "IIF" :
2084
  if (count($arrArgs) < 3)
2085
- throw new Exception($varTmp . " requires atleast three arguments!");
2086
  else if (count($arrArgs) > 3)
2087
  throw new Exception($varTmp . " requires only three arguments!");
2088
 
@@ -2132,7 +2132,7 @@ class Toolset_Parser
2132
  case "MAX" :
2133
  case "MIN" :
2134
  if (count($arrArgs) < 1)
2135
- throw new Exception($varTmp . " requires atleast one operand!");
2136
 
2137
  $_arr=array();
2138
  $intCntr = count($arrArgs);
1639
  if ($varTmp != "RAND")
1640
  {
1641
  if (count($arrArgs) < 1)
1642
+ throw new Exception($varTmp . " requires at least one argument!");
1643
  else if (count($arrArgs) > 1)
1644
  throw new Exception($varTmp . " requires only one argument!");
1645
  }
1646
  else
1647
  {
1648
  if (count($arrArgs) < 1)
1649
+ throw new Exception($varTmp . " requires at least one argument!");
1650
  else if (count($arrArgs) > 2)
1651
  throw new Exception($varTmp . " requires at most two arguments!");
1652
  }
1717
  break;
1718
  case "STR" :
1719
  if (count($arrArgs) < 1)
1720
+ throw new Exception($varTmp . " requires at least one argument!");
1721
  else if (count($arrArgs) > 2)
1722
  throw new Exception($varTmp . " requires at most two arguments!");
1723
  $varTerm = $arrArgs[count($arrArgs)-1];
1756
  if (count($arrArgs) > 1)
1757
  throw new Exception($varTmp . " requires only one argument!");
1758
  else if (count($arrArgs) < 1)
1759
+ throw new Exception($varTmp . " requires at least one argument!");
1760
  $varTerm = $arrArgs[0];
1761
  if ($varTerm->isVariable)
1762
  {
1791
  break;
1792
  case "REGEX" :
1793
  if (count($arrArgs) < 1)
1794
+ throw new Exception($varTmp . " requires at least one argument!");
1795
  else if (count($arrArgs) > 2)
1796
  throw new Exception($varTmp . " requires at most two arguments!");
1797
 
1828
  case "UCASE" :
1829
  case "NUM" :
1830
  if (count($arrArgs) < 1)
1831
+ throw new Exception($varTmp . " requires at least one argument!");
1832
  else if (count($arrArgs) > 1)
1833
  throw new Exception($varTmp . " requires only one argument!");
1834
 
1870
  break;
1871
  case "LEN" :
1872
  if (count($arrArgs) < 1)
1873
+ throw new Exception($varTmp . " requires at least one argument!");
1874
  else if (count($arrArgs) > 1)
1875
  throw new Exception($varTmp . " requires only one argument!");
1876
 
1895
  break;
1896
  case "USER" :
1897
  if (count($arrArgs) < 1)
1898
+ throw new Exception($varTmp . " requires at least one argument!");
1899
  else if (count($arrArgs) > 1)
1900
  throw new Exception($varTmp . " requires only one argument!");
1901
 
1917
  break;
1918
  case "COOKIE" :
1919
  if (count($arrArgs) < 1)
1920
+ throw new Exception($varTmp . " requires at least one argument!");
1921
  else if (count($arrArgs) > 1)
1922
  throw new Exception($varTmp . " requires only one argument!");
1923
 
1939
  break;
1940
  case "CONTAINS" :
1941
  if (count($arrArgs) < 2)
1942
+ throw new Exception($varTmp . " requires at least two arguments!");
1943
  else if (count($arrArgs) > 2)
1944
  throw new Exception($varTmp . " requires only two arguments!");
1945
 
1970
  break;
1971
  case "DATE" :
1972
  if (count($arrArgs) < 2)
1973
+ throw new Exception($varTmp . " requires at least two arguments!");
1974
  else if (count($arrArgs) > 2)
1975
  throw new Exception($varTmp . " requires only two arguments!");
1976
 
2010
  case "empty" :
2011
  case "EMPTY" :
2012
  if (count($arrArgs) < 1)
2013
+ throw new Exception($varTmp . " requires at least one argument!");
2014
  else if (count($arrArgs) > 1)
2015
  throw new Exception($varTmp . " requires only one arguments!");
2016
 
2041
  case "LEFT" :
2042
  case "RIGHT" :
2043
  if (count($arrArgs) < 2)
2044
+ throw new Exception($varTmp . " requires at least two arguments!");
2045
  else if (count($arrArgs) > 2)
2046
  throw new Exception($varTmp . " requires only two arguments!");
2047
 
2082
  case "MID" :
2083
  case "IIF" :
2084
  if (count($arrArgs) < 3)
2085
+ throw new Exception($varTmp . " requires at least three arguments!");
2086
  else if (count($arrArgs) > 3)
2087
  throw new Exception($varTmp . " requires only three arguments!");
2088
 
2132
  case "MAX" :
2133
  case "MIN" :
2134
  if (count($arrArgs) < 1)
2135
+ throw new Exception($varTmp . " requires at least one operand!");
2136
 
2137
  $_arr=array();
2138
  $intCntr = count($arrArgs);
embedded/common/functions.php CHANGED
@@ -149,6 +149,8 @@ function wpv_condition( $atts, $post_to_check = null ) {
149
 
150
  add_filter( 'wpv-extra-condition-filters', 'wpv_add_time_functions' );
151
  $evaluate = apply_filters( 'wpv-extra-condition-filters', $evaluate );
 
 
152
 
153
  // evaluate empty() statements for variables
154
  if ( $has_post ) {
@@ -165,8 +167,8 @@ function wpv_condition( $atts, $post_to_check = null ) {
165
  || ( is_array( $match_var ) && empty( $match_var ) ) ) {
166
  $is_empty = '1=1';
167
  }
168
-
169
  $evaluate = str_replace( $matches[0][$i], $is_empty, $evaluate );
 
170
  }
171
  }
172
  }
@@ -185,10 +187,9 @@ function wpv_condition( $atts, $post_to_check = null ) {
185
  if ( strpos( $string, '$' ) === 0 ) {
186
  $variable_name = substr( $string, 1 ); // omit dollar sign
187
  if ( isset( $atts[$variable_name] ) ) {
188
- $string = get_post_meta( $post->ID, $atts[$variable_name],
189
- true );
190
- $evaluate = str_replace( $matches[1][$i],
191
- "'" . $string . "'", $evaluate );
192
  }
193
  }
194
  }
@@ -246,11 +247,10 @@ function wpv_condition( $atts, $post_to_check = null ) {
246
  $evaluate = str_replace( $matches[0][$i], '1=0', $evaluate );
247
  }
248
  } else {
249
- $evaluate = str_replace( $matches[1][$i], $first_string,
250
- $evaluate );
251
- $evaluate = str_replace( $matches[5][$i], $second_string,
252
- $evaluate );
253
  }
 
254
  }
255
  }
256
 
@@ -261,10 +261,10 @@ function wpv_condition( $atts, $post_to_check = null ) {
261
  for ( $i = 0; $i < $strings_count; $i++ ) {
262
  $string = $matches[1][$i];
263
  // remove single quotes from string literals to get value only
264
- $string = (strpos( $string, '\'' ) === 0) ? substr( $string, 1,
265
- strlen( $string ) - 2 ) : $string;
266
  if ( is_numeric( $string ) ) {
267
  $evaluate = str_replace( $matches[1][$i], $string, $evaluate );
 
268
  }
269
  }
270
  }
@@ -292,6 +292,7 @@ function wpv_condition( $atts, $post_to_check = null ) {
292
  $meta = "0";
293
  }
294
  $evaluate = str_replace( '$' . $match, $meta, $evaluate );
 
295
  }
296
  }
297
  }
@@ -487,7 +488,7 @@ class WPV_wpcf_switch_post_from_attr_id
487
  $this->found = true;
488
 
489
  // save original post
490
- $this->post = isset( $post ) ? clone $post : null;
491
  if ( $authordata ) {
492
  $this->authordata = clone $authordata;
493
  } else {
@@ -509,7 +510,7 @@ class WPV_wpcf_switch_post_from_attr_id
509
  global $post, $authordata, $id;
510
 
511
  // restore the global post values.
512
- $post = isset( $this->post ) ? clone $this->post : null;
513
  if ( $this->authordata ) {
514
  $authordata = clone $this->authordata;
515
  } else {
@@ -615,70 +616,3 @@ function wpv_dismiss_message_ajax() {
615
  die( 'ajax' );
616
  }
617
 
618
- // disable the admin messages for now. They are causing problems.
619
- //add_action('admin_head', 'wpv_show_admin_messages');
620
-
621
- /**
622
- * Shows stored admin messages.
623
- */
624
- function wpv_show_admin_messages() {
625
- $messages = get_option( 'wpv-messages', array() );
626
- $dismissed_messages = get_option( 'wpv-dismissed-messages', array() );
627
- foreach ( $messages as $message_id => $message ) {
628
- if ( array_key_exists( $message_id, $dismissed_messages ) ) {
629
- unset( $messages[$message_id] );
630
- continue;
631
- }
632
- // update the nonce
633
- $text = $message['message'];
634
- $nonce = preg_match_all( "/_wpnonce=[^']+/", $text, $matches );
635
-
636
- if ( $nonce ) {
637
- $text = str_replace( $matches[0][0],
638
- '_wpnonce=' . wp_create_nonce( 'dismiss_message' ), $text );
639
- }
640
-
641
- wpv_admin_message( $message_id, $text, $message['class'] );
642
- if ( $show_once ) {
643
- unset( $messages[$message_id] );
644
- }
645
- }
646
- update_option( 'wpv-messages', $messages );
647
- }
648
-
649
- /**
650
- * Stores admin messages.
651
- *
652
- * @param type $message_id
653
- * @param type $message
654
- * @param type $show_once
655
- * @param type $class
656
- */
657
- function wpv_admin_message_store( $message_id, $message, $show_once = true,
658
- $class = 'updated' ) {
659
- $messages = get_option( 'wpv-messages', array() );
660
- $messages[strval( $message_id )] = array(
661
- 'message' => strval( $message ),
662
- 'class' => strval( $class ),
663
- 'show_once' => $show_once,
664
- );
665
- update_option( 'wpv-messages', $messages );
666
- }
667
-
668
- /**
669
- * Shows admin message.
670
- *
671
- * @param type $message_id
672
- * @param type $message
673
- * @param type $class
674
- */
675
- function wpv_admin_message( $message_id, $message, $class = 'updated' ) {
676
- if ( apply_filters( 'wpv-show-message', true, $message_id ) ) {
677
- add_action( 'admin_notices',
678
- create_function( '$a=1, $message_id=\'' . strval( $message_id )
679
- . '\', $class=\'' . strval( $class )
680
- . '\', $message=\''
681
- . htmlentities( strval( $message ), ENT_QUOTES ) . '\'',
682
- '$screen = get_current_screen(); if (!$screen->is_network) echo "<div class=\"message $class\" id=\"wpv-message-$message_id\"><p>" . html_entity_decode($message, ENT_QUOTES) . "</p></div>";' ) );
683
- }
684
- }
149
 
150
  add_filter( 'wpv-extra-condition-filters', 'wpv_add_time_functions' );
151
  $evaluate = apply_filters( 'wpv-extra-condition-filters', $evaluate );
152
+
153
+ $logging_string .= "; After extra conditions: " . $evaluate;
154
 
155
  // evaluate empty() statements for variables
156
  if ( $has_post ) {
167
  || ( is_array( $match_var ) && empty( $match_var ) ) ) {
168
  $is_empty = '1=1';
169
  }
 
170
  $evaluate = str_replace( $matches[0][$i], $is_empty, $evaluate );
171
+ $logging_string .= "; After empty: " . $evaluate;
172
  }
173
  }
174
  }
187
  if ( strpos( $string, '$' ) === 0 ) {
188
  $variable_name = substr( $string, 1 ); // omit dollar sign
189
  if ( isset( $atts[$variable_name] ) ) {
190
+ $string = get_post_meta( $post->ID, $atts[$variable_name], true );
191
+ $evaluate = str_replace( $matches[1][$i], "'" . $string . "'", $evaluate );
192
+ $logging_string .= "; After variables I: " . $evaluate;
 
193
  }
194
  }
195
  }
247
  $evaluate = str_replace( $matches[0][$i], '1=0', $evaluate );
248
  }
249
  } else {
250
+ $evaluate = str_replace( $matches[1][$i], $first_string, $evaluate );
251
+ $evaluate = str_replace( $matches[5][$i], $second_string, $evaluate );
 
 
252
  }
253
+ $logging_string .= "; After variables II: " . $evaluate;
254
  }
255
  }
256
 
261
  for ( $i = 0; $i < $strings_count; $i++ ) {
262
  $string = $matches[1][$i];
263
  // remove single quotes from string literals to get value only
264
+ $string = (strpos( $string, '\'' ) === 0) ? substr( $string, 1, strlen( $string ) - 2 ) : $string;
 
265
  if ( is_numeric( $string ) ) {
266
  $evaluate = str_replace( $matches[1][$i], $string, $evaluate );
267
+ $logging_string .= "; After variables III: " . $evaluate;
268
  }
269
  }
270
  }
292
  $meta = "0";
293
  }
294
  $evaluate = str_replace( '$' . $match, $meta, $evaluate );
295
+ $logging_string .= "; After variables IV: " . $evaluate;
296
  }
297
  }
298
  }
488
  $this->found = true;
489
 
490
  // save original post
491
+ $this->post = ( isset( $post ) && ( $post instanceof WP_Post ) ) ? clone $post : null;
492
  if ( $authordata ) {
493
  $this->authordata = clone $authordata;
494
  } else {
510
  global $post, $authordata, $id;
511
 
512
  // restore the global post values.
513
+ $post = ( isset( $this->post ) && ( $this->post instanceof WP_Post ) ) ? clone $this->post : null;
514
  if ( $this->authordata ) {
515
  $authordata = clone $this->authordata;
516
  } else {
616
  die( 'ajax' );
617
  }
618
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
embedded/common/res/css/colorbox.css ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* -------- */
2
+ /* Colorbox */
3
+ /* -------- */
4
+
5
+ /* This file contains styles for default Colorbox elements only */
6
+ /* TODO: This file can be removed, we can load it from common */
7
+
8
+ body.disable-scrollbar {
9
+ overflow: hidden;
10
+ }
11
+
12
+ #colorbox,
13
+ #cboxOverlay,
14
+ #cboxWrapper {
15
+ position:absolute;
16
+ top:0;
17
+ left:0;
18
+ z-index:10000;
19
+ /* overflow:hidden;*/
20
+ }
21
+
22
+ #cboxOverlay {
23
+ position:fixed;
24
+ width:100%;
25
+ max-width: 100%;
26
+ height:100%;
27
+ background: #000;
28
+ }
29
+ #cboxMiddleLeft,
30
+ #cboxBottomLeft {
31
+ clear:left;
32
+ }
33
+ #cboxContent {
34
+ position:relative;
35
+ }
36
+ #cboxLoadedContent {
37
+ overflow:visible!important;
38
+ -webkit-overflow-scrolling: touch;
39
+ }
40
+ #cboxTitle {
41
+ margin:0;
42
+ }
43
+ #cboxLoadingOverlay,
44
+ #cboxLoadingGraphic {
45
+ position:absolute;
46
+ top:0;
47
+ left:0;
48
+ width:100%;
49
+ height:100%;
50
+ }
51
+ #cboxPrevious,
52
+ #cboxNext,
53
+ #cboxClose,
54
+ #cboxSlideshow {
55
+ cursor:pointer;
56
+ }
57
+ .cboxPhoto {
58
+ display:block;
59
+ float:left;
60
+ margin:auto;
61
+ max-width:none;
62
+ border:0;
63
+ -ms-interpolation-mode:bicubic;
64
+ }
65
+ .cboxIframe {
66
+ display:block;
67
+ width:100%;
68
+ height:100%;
69
+ border:0;
70
+ }
71
+ #colorbox,
72
+ #cboxContent,
73
+ #cboxLoadedContent {
74
+ -webkit-box-sizing:content-box;
75
+ -moz-box-sizing:content-box;
76
+ box-sizing:content-box;
77
+ }
78
+
79
+ .cboxIE #cboxTopLeft,
80
+ .cboxIE #cboxTopCenter,
81
+ .cboxIE #cboxTopRight,
82
+ .cboxIE #cboxBottomLeft,
83
+ .cboxIE #cboxBottomCenter,
84
+ .cboxIE #cboxBottomRight,
85
+ .cboxIE #cboxMiddleLeft,
86
+ .cboxIE #cboxMiddleRight {
87
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
88
+ }
embedded/common/res/css/toolset-promotion.css ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ .toolset-modal
3
+ {
4
+ font-family: "Open Sans";
5
+ font-size: 15px;
6
+ width: 550px;
7
+ background-color: #fff;
8
+ padding: 45px 0 42px 0;
9
+ position: relative;
10
+
11
+ -webkit-box-shadow: 5px 5px 15px 0px rgba(50, 50, 50, 0.38);
12
+ -moz-box-shadow: 5px 5px 15px 0px rgba(50, 50, 50, 0.38);
13
+ box-shadow: 5px 5px 15px 0px rgba(50, 50, 50, 0.38);
14
+
15
+ }
16
+
17
+ .toolset-modal h2
18
+ {
19
+ color: #fff;
20
+ position: relative;
21
+ background-color: #333;
22
+ padding: 15px 30px;
23
+ font-size: 24px;
24
+ line-height: 30px;
25
+ font-weight: 300;
26
+ margin: 0;
27
+ }
28
+
29
+ .toolset-modal .icon-toolset-logo
30
+ {
31
+ color: #f05a28;
32
+ position: absolute;
33
+ top: 6px;
34
+ left: 23px;
35
+ font-size: 53px;
36
+ }
37
+
38
+ .toolset-modal ul:before
39
+ {
40
+ content: "";
41
+ display: table;
42
+ }
43
+
44
+ .toolset-modal .content
45
+ {
46
+ padding: 0 28px;
47
+ }
48
+
49
+ .toolset-modal ul
50
+ {
51
+ display: table-row;
52
+ }
53
+
54
+ .toolset-modal li:first-child
55
+ {
56
+ min-width: 75px;
57
+ }
58
+
59
+ .toolset-modal li:last-child
60
+ {
61
+ padding-right: 0;
62
+ min-width: 115px;
63
+ }
64
+
65
+ .toolset-modal li
66
+ ,.js-close-promotional-message
67
+ {
68
+ background: transparent url(../images/toolset.promotion/icons.png) no-repeat;
69
+ }
70
+
71
+ .toolset-modal li
72
+ {
73
+ display: table-cell;
74
+ font-size: 13px;
75
+ font-weight: 700;
76
+ height: 52px;
77
+ padding: 0 20px 0 38px;
78
+ }
79
+
80
+
81
+ .toolset-modal li.layout{background-position: 0 -65px}
82
+ .toolset-modal li.toolset-search{background-position: 0 -130px}
83
+ .toolset-modal li.list {background-position: 0 -195px}
84
+ .toolset-modal li.form {background-position: 0 -260px}
85
+ .toolset-modal li.more {background-position: 0 -325px}
86
+
87
+ .toolset-modal .full img
88
+ {
89
+ padding-bottom: 19px;
90
+ }
91
+
92
+ .toolset-modal .full
93
+ {
94
+ background: transparent url(../images/toolset.promotion/full.jpg) no-repeat;
95
+ padding-left: 298px;
96
+ min-height: 165px;
97
+ font-size: 15px;
98
+ margin-bottom: 0;
99
+ }
100
+
101
+ .toolset-modal .icons
102
+ {
103
+ border: 1px solid #777;
104
+ border-width: 1px 0;
105
+ padding-top: 18px;
106
+ }
107
+
108
+ .toolset-modal .description
109
+ {
110
+ font-size: 13px;
111
+ color: #4d4d4d;
112
+ margin: 30px 0;
113
+ }
114
+
115
+ .toolset-modal em
116
+ {
117
+ font-weight: 600;
118
+ }
119
+
120
+ .toolset-modal .button
121
+ {
122
+ padding: 10px 15px;
123
+ background-color: #f05a28;
124
+ color: #fff;
125
+ text-decoration: none;
126
+ margin-top: -10px;
127
+ height: auto;
128
+ font-size: 18px;
129
+ line-height: 1em;
130
+ }
131
+
132
+ .toolset-modal .learn
133
+ {
134
+ font-size: 15px;
135
+ color: #f05a28;
136
+ display: inline-block;
137
+ margin-left: 20px;
138
+ }
139
+
140
+ .ddl-dialogs-container
141
+ {
142
+ display: none;
143
+ }
144
+
145
+ .js-close-promotional-message
146
+ {
147
+ background-position: 0 -480px;
148
+ cursor: pointer;
149
+ display: block;
150
+ height: 20px;
151
+ position: absolute;
152
+ right: -10px;
153
+ top: -10px;
154
+ width: 20px;
155
+ }
embedded/common/res/images/toolset.promotion/full.jpg ADDED
Binary file
embedded/common/res/images/toolset.promotion/icons.png ADDED
Binary file
embedded/common/res/js/jquery.colorbox-min.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ /*!
2
+ Colorbox v1.4.31 - 2013-09-25
3
+ jQuery lightbox and modal window plugin
4
+ (c) 2013 Jack Moore - http://www.jacklmoore.com/colorbox
5
+ license: http://www.opensource.org/licenses/mit-license.php
6
+ */
7
+ (function(e,t,i){function o(i,o,n){var r=t.createElement(i);return o&&(r.id=Z+o),n&&(r.style.cssText=n),e(r)}function n(){return i.innerHeight?i.innerHeight:e(i).height()}function r(e){var t=k.length,i=(z+e)%t;return 0>i?t+i:i}function h(e,t){return Math.round((/%/.test(e)?("x"===t?E.width():n())/100:1)*parseInt(e,10))}function s(e,t){return e.photo||e.photoRegex.test(t)}function l(e,t){return e.retinaUrl&&i.devicePixelRatio>1?t.replace(e.photoRegex,e.retinaSuffix):t}function a(e){"contains"in g[0]&&!g[0].contains(e.target)&&(e.stopPropagation(),g.focus())}function d(){var t,i=e.data(N,Y);null==i?(B=e.extend({},X),console&&console.log&&console.log("Error: cboxElement missing settings object")):B=e.extend({},i);for(t in B)e.isFunction(B[t])&&"on"!==t.slice(0,2)&&(B[t]=B[t].call(N));B.rel=B.rel||N.rel||e(N).data("rel")||"nofollow",B.href=B.href||e(N).attr("href"),B.title=B.title||N.title,"string"==typeof B.href&&(B.href=e.trim(B.href))}function c(i,o){e(t).trigger(i),st.trigger(i),e.isFunction(o)&&o.call(N)}function u(i){q||(N=i,d(),k=e(N),z=0,"nofollow"!==B.rel&&(k=e("."+et).filter(function(){var t,i=e.data(this,Y);return i&&(t=e(this).data("rel")||i.rel||this.rel),t===B.rel}),z=k.index(N),-1===z&&(k=k.add(N),z=k.length-1)),w.css({opacity:parseFloat(B.opacity),cursor:B.overlayClose?"pointer":"auto",visibility:"visible"}).show(),J&&g.add(w).removeClass(J),B.className&&g.add(w).addClass(B.className),J=B.className,B.closeButton?K.html(B.close).appendTo(y):K.appendTo("<div/>"),U||(U=$=!0,g.css({visibility:"hidden",display:"block"}),H=o(lt,"LoadedContent","width:0; height:0; overflow:hidden"),y.css({width:"",height:""}).append(H),O=x.height()+C.height()+y.outerHeight(!0)-y.height(),_=b.width()+T.width()+y.outerWidth(!0)-y.width(),D=H.outerHeight(!0),A=H.outerWidth(!0),B.w=h(B.initialWidth,"x"),B.h=h(B.initialHeight,"y"),H.css({width:"",height:B.h}),Q.position(),c(tt,B.onOpen),P.add(L).hide(),g.focus(),B.trapFocus&&t.addEventListener&&(t.addEventListener("focus",a,!0),st.one(rt,function(){t.removeEventListener("focus",a,!0)})),B.returnFocus&&st.one(rt,function(){e(N).focus()})),m())}function f(){!g&&t.body&&(V=!1,E=e(i),g=o(lt).attr({id:Y,"class":e.support.opacity===!1?Z+"IE":"",role:"dialog",tabindex:"-1"}).hide(),w=o(lt,"Overlay").hide(),F=e([o(lt,"LoadingOverlay")[0],o(lt,"LoadingGraphic")[0]]),v=o(lt,"Wrapper"),y=o(lt,"Content").append(L=o(lt,"Title"),S=o(lt,"Current"),I=e('<button type="button"/>').attr({id:Z+"Previous"}),R=e('<button type="button"/>').attr({id:Z+"Next"}),M=o("button","Slideshow"),F),K=e('<button type="button"/>').attr({id:Z+"Close"}),v.append(o(lt).append(o(lt,"TopLeft"),x=o(lt,"TopCenter"),o(lt,"TopRight")),o(lt,!1,"clear:left").append(b=o(lt,"MiddleLeft"),y,T=o(lt,"MiddleRight")),o(lt,!1,"clear:left").append(o(lt,"BottomLeft"),C=o(lt,"BottomCenter"),o(lt,"BottomRight"))).find("div div").css({"float":"left"}),W=o(lt,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),P=R.add(I).add(S).add(M),e(t.body).append(w,g.append(v,W)))}function p(){function i(e){e.which>1||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey||(e.preventDefault(),u(this))}return g?(V||(V=!0,R.click(function(){Q.next()}),I.click(function(){Q.prev()}),K.click(function(){Q.close()}),w.click(function(){B.overlayClose&&Q.close()}),e(t).bind("keydown."+Z,function(e){var t=e.keyCode;U&&B.escKey&&27===t&&(e.preventDefault(),Q.close()),U&&B.arrowKey&&k[1]&&!e.altKey&&(37===t?(e.preventDefault(),I.click()):39===t&&(e.preventDefault(),R.click()))}),e.isFunction(e.fn.on)?e(t).on("click."+Z,"."+et,i):e("."+et).live("click."+Z,i)),!0):!1}function m(){var n,r,a,u=Q.prep,f=++at;$=!0,j=!1,N=k[z],d(),c(ht),c(it,B.onLoad),B.h=B.height?h(B.height,"y")-D-O:B.innerHeight&&h(B.innerHeight,"y"),B.w=B.width?h(B.width,"x")-A-_:B.innerWidth&&h(B.innerWidth,"x"),B.mw=B.w,B.mh=B.h,B.maxWidth&&(B.mw=h(B.maxWidth,"x")-A-_,B.mw=B.w&&B.w<B.mw?B.w:B.mw),B.maxHeight&&(B.mh=h(B.maxHeight,"y")-D-O,B.mh=B.h&&B.h<B.mh?B.h:B.mh),n=B.href,G=setTimeout(function(){F.show()},100),B.inline?(a=o(lt).hide().insertBefore(e(n)[0]),st.one(ht,function(){a.replaceWith(H.children())}),u(e(n))):B.iframe?u(" "):B.html?u(B.html):s(B,n)?(n=l(B,n),j=t.createElement("img"),e(j).addClass(Z+"Photo").bind("error",function(){B.title=!1,u(o(lt,"Error").html(B.imgError))}).one("load",function(){var t;f===at&&(e.each(["alt","longdesc","aria-describedby"],function(t,i){var o=e(N).attr(i)||e(N).attr("data-"+i);o&&j.setAttribute(i,o)}),B.retinaImage&&i.devicePixelRatio>1&&(j.height=j.height/i.devicePixelRatio,j.width=j.width/i.devicePixelRatio),B.scalePhotos&&(r=function(){j.height-=j.height*t,j.width-=j.width*t},B.mw&&j.width>B.mw&&(t=(j.width-B.mw)/j.width,r()),B.mh&&j.height>B.mh&&(t=(j.height-B.mh)/j.height,r())),B.h&&(j.style.marginTop=Math.max(B.mh-j.height,0)/2+"px"),k[1]&&(B.loop||k[z+1])&&(j.style.cursor="pointer",j.onclick=function(){Q.next()}),j.style.width=j.width+"px",j.style.height=j.height+"px",setTimeout(function(){u(j)},1))}),setTimeout(function(){j.src=n},1)):n&&W.load(n,B.data,function(t,i){f===at&&u("error"===i?o(lt,"Error").html(B.xhrError):e(this).contents())})}var w,g,v,y,x,b,T,C,k,E,H,W,F,L,S,M,R,I,K,P,B,O,_,D,A,N,z,j,U,$,q,G,Q,J,V,X={html:!1,photo:!1,iframe:!1,inline:!1,transition:"elastic",speed:300,fadeOut:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,className:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:void 0,closeButton:!0,fastIframe:!0,open:!1,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",photoRegex:/\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i,retinaImage:!1,retinaUrl:!1,retinaSuffix:"@2x.$1",current:"image {current} of {total}",previous:"previous",next:"next",close:"close",xhrError:"This content failed to load.",imgError:"This image failed to load.",returnFocus:!0,trapFocus:!0,onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1},Y="colorbox",Z="cbox",et=Z+"Element",tt=Z+"_open",it=Z+"_load",ot=Z+"_complete",nt=Z+"_cleanup",rt=Z+"_closed",ht=Z+"_purge",st=e("<a/>"),lt="div",at=0,dt={},ct=function(){function e(){clearTimeout(h)}function t(){(B.loop||k[z+1])&&(e(),h=setTimeout(Q.next,B.slideshowSpeed))}function i(){M.html(B.slideshowStop).unbind(l).one(l,o),st.bind(ot,t).bind(it,e),g.removeClass(s+"off").addClass(s+"on")}function o(){e(),st.unbind(ot,t).unbind(it,e),M.html(B.slideshowStart).unbind(l).one(l,function(){Q.next(),i()}),g.removeClass(s+"on").addClass(s+"off")}function n(){r=!1,M.hide(),e(),st.unbind(ot,t).unbind(it,e),g.removeClass(s+"off "+s+"on")}var r,h,s=Z+"Slideshow_",l="click."+Z;return function(){r?B.slideshow||(st.unbind(nt,n),n()):B.slideshow&&k[1]&&(r=!0,st.one(nt,n),B.slideshowAuto?i():o(),M.show())}}();e.colorbox||(e(f),Q=e.fn[Y]=e[Y]=function(t,i){var o=this;if(t=t||{},f(),p()){if(e.isFunction(o))o=e("<a/>"),t.open=!0;else if(!o[0])return o;i&&(t.onComplete=i),o.each(function(){e.data(this,Y,e.extend({},e.data(this,Y)||X,t))}).addClass(et),(e.isFunction(t.open)&&t.open.call(o)||t.open)&&u(o[0])}return o},Q.position=function(t,i){function o(){x[0].style.width=C[0].style.width=y[0].style.width=parseInt(g[0].style.width,10)-_+"px",y[0].style.height=b[0].style.height=T[0].style.height=parseInt(g[0].style.height,10)-O+"px"}var r,s,l,a=0,d=0,c=g.offset();if(E.unbind("resize."+Z),g.css({top:-9e4,left:-9e4}),s=E.scrollTop(),l=E.scrollLeft(),B.fixed?(c.top-=s,c.left-=l,g.css({position:"fixed"})):(a=s,d=l,g.css({position:"absolute"})),d+=B.right!==!1?Math.max(E.width()-B.w-A-_-h(B.right,"x"),0):B.left!==!1?h(B.left,"x"):Math.round(Math.max(E.width()-B.w-A-_,0)/2),a+=B.bottom!==!1?Math.max(n()-B.h-D-O-h(B.bottom,"y"),0):B.top!==!1?h(B.top,"y"):Math.round(Math.max(n()-B.h-D-O,0)/2),g.css({top:c.top,left:c.left,visibility:"visible"}),v[0].style.width=v[0].style.height="9999px",r={width:B.w+A+_,height:B.h+D+O,top:a,left:d},t){var u=0;e.each(r,function(e){return r[e]!==dt[e]?(u=t,void 0):void 0}),t=u}dt=r,t||g.css(r),g.dequeue().animate(r,{duration:t||0,complete:function(){o(),$=!1,v[0].style.width=B.w+A+_+"px",v[0].style.height=B.h+D+O+"px",B.reposition&&setTimeout(function(){E.bind("resize."+Z,Q.position)},1),i&&i()},step:o})},Q.resize=function(e){var t;U&&(e=e||{},e.width&&(B.w=h(e.width,"x")-A-_),e.innerWidth&&(B.w=h(e.innerWidth,"x")),H.css({width:B.w}),e.height&&(B.h=h(e.height,"y")-D-O),e.innerHeight&&(B.h=h(e.innerHeight,"y")),e.innerHeight||e.height||(t=H.scrollTop(),H.css({height:"auto"}),B.h=H.height()),H.css({height:B.h}),t&&H.scrollTop(t),Q.position("none"===B.transition?0:B.speed))},Q.prep=function(i){function n(){return B.w=B.w||H.width(),B.w=B.mw&&B.mw<B.w?B.mw:B.w,B.w}function h(){return B.h=B.h||H.height(),B.h=B.mh&&B.mh<B.h?B.mh:B.h,B.h}if(U){var a,d="none"===B.transition?0:B.speed;H.empty().remove(),H=o(lt,"LoadedContent").append(i),H.hide().appendTo(W.show()).css({width:n(),overflow:B.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(y),W.hide(),e(j).css({"float":"none"}),a=function(){function i(){e.support.opacity===!1&&g[0].style.removeAttribute("filter")}var n,h,a=k.length,u="frameBorder",f="allowTransparency";U&&(h=function(){clearTimeout(G),F.hide(),c(ot,B.onComplete)},L.html(B.title).add(H).show(),a>1?("string"==typeof B.current&&S.html(B.current.replace("{current}",z+1).replace("{total}",a)).show(),R[B.loop||a-1>z?"show":"hide"]().html(B.next),I[B.loop||z?"show":"hide"]().html(B.previous),ct(),B.preloading&&e.each([r(-1),r(1)],function(){var i,o,n=k[this],r=e.data(n,Y);r&&r.href?(i=r.href,e.isFunction(i)&&(i=i.call(n))):i=e(n).attr("href"),i&&s(r,i)&&(i=l(r,i),o=t.createElement("img"),o.src=i)})):P.hide(),B.iframe?(n=o("iframe")[0],u in n&&(n[u]=0),f in n&&(n[f]="true"),B.scrolling||(n.scrolling="no"),e(n).attr({src:B.href,name:(new Date).getTime(),"class":Z+"Iframe",allowFullScreen:!0,webkitAllowFullScreen:!0,mozallowfullscreen:!0}).one("load",h).appendTo(H),st.one(ht,function(){n.src="//about:blank"}),B.fastIframe&&e(n).trigger("load")):h(),"fade"===B.transition?g.fadeTo(d,1,i):i())},"fade"===B.transition?g.fadeTo(d,0,function(){Q.position(0,a)}):Q.position(d,a)}},Q.next=function(){!$&&k[1]&&(B.loop||k[z+1])&&(z=r(1),u(k[z]))},Q.prev=function(){!$&&k[1]&&(B.loop||z)&&(z=r(-1),u(k[z]))},Q.close=function(){U&&!q&&(q=!0,U=!1,c(nt,B.onCleanup),E.unbind("."+Z),w.fadeTo(B.fadeOut||0,0),g.stop().fadeTo(B.fadeOut||0,0,function(){g.add(w).css({opacity:1,cursor:"auto"}).hide(),c(ht),H.empty().remove(),setTimeout(function(){q=!1,c(rt,B.onClosed)},1)}))},Q.remove=function(){g&&(g.stop(),e.colorbox.close(),g.stop().remove(),w.remove(),q=!1,g=null,e("."+et).removeData(Y).removeClass(et),e(t).unbind("click."+Z))},Q.element=function(){return e(N)},Q.settings=X)})(jQuery,document,window);
embedded/common/res/js/toolset-promotion.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var Toolset_Promotion = Toolset_Promotion || {};
2
+
3
+ Toolset_Promotion = function($){
4
+ var self = this;
5
+
6
+ self.init = function(){
7
+ self.toolset_open_promotional_message();
8
+ };
9
+
10
+ self.toolset_open_promotional_message = function(){
11
+ var $el = $('.js-open-promotional-message')
12
+ , template = $('#js-buy-toolset-embedded-message').html()
13
+ , $container = $('#js-buy-toolset-embedded-message-wrap');
14
+
15
+ $container.html( _.template( template ) );
16
+
17
+ $(document).on('click', $el.selector, function(event){
18
+ event.preventDefault();
19
+ $.colorbox({
20
+ href: $container.selector,
21
+ inline: true,
22
+ open: true,
23
+ closeButton: false,
24
+ fixed: true,
25
+ top: false,
26
+ width:'554px',
27
+ onComplete: function() {
28
+
29
+ },
30
+ onCleanup: function() {
31
+
32
+ },
33
+ opacity: .2
34
+ });
35
+ })
36
+ $('.js-close-promotional-message').on('click', function(){
37
+ $.colorbox.close();
38
+ });
39
+ };
40
+
41
+ self.init();
42
+
43
+ };
44
+
45
+ ;(function($){
46
+ var toolset_promotion_message = new Toolset_Promotion($);
47
+ }(jQuery));
embedded/common/toolset-forms/api.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/api.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -66,21 +66,23 @@ function wptoolset_timetodate( $timestamp, $format = null ){
66
  global $wptoolset_forms;
67
  return $wptoolset_forms->timetodate( $timestamp, $format );
68
  }
69
- /**
70
- * wptoolset_esc_like
71
- *
72
- * In WordPress 4.0, like_escape() was deprecated, due to incorrect
73
- * documentation and improper sanitization leading to a history of misuse
74
- * To maintain compatibility with versions of WP before 4.0, we duplicate the
75
- * logic of the replacement, wpdb::esc_like()
76
- *
77
- * @see wpdb::esc_like() for more details on proper use.
78
- *
79
- * @param string $text The raw text to be escaped.
80
- * @return string Text in the form of a LIKE phrase. Not SQL safe. Run through
81
- * wpdb::prepare() before use.
82
- */
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  function wptoolset_esc_like( $like )
85
  {
86
  global $wpdb;
2
 
3
  /**
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/api.php $
6
+ * $LastChangedDate: 2015-03-16 12:03:31 +0000 (Mon, 16 Mar 2015) $
7
+ * $LastChangedRevision: 1113864 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
66
  global $wptoolset_forms;
67
  return $wptoolset_forms->timetodate( $timestamp, $format );
68
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ /**
71
+ * wptoolset_esc_like
72
+ *
73
+ * In WordPress 4.0, like_escape() was deprecated, due to incorrect
74
+ * documentation and improper sanitization leading to a history of misuse
75
+ * To maintain compatibility with versions of WP before 4.0, we duplicate the
76
+ * logic of the replacement, wpdb::esc_like()
77
+ *
78
+ * @see wpdb::esc_like() for more details on proper use.
79
+ *
80
+ * @global object $wpdb
81
+ *
82
+ * @param string $text The raw text to be escaped.
83
+ * @return string Text in the form of a LIKE phrase. Not SQL safe. Run through
84
+ * wpdb::prepare() before use.
85
+ */
86
  function wptoolset_esc_like( $like )
87
  {
88
  global $wpdb;
embedded/common/toolset-forms/bootstrap.php CHANGED
@@ -2,77 +2,74 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/bootstrap.php $
6
- * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
7
- * $LastChangedRevision: 1069430 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
11
-
12
  require_once 'api.php';
13
 
14
- define( 'WPTOOLSET_FORMS_VERSION', '0.1.1' );
15
- define( 'WPTOOLSET_FORMS_ABSPATH', dirname( __FILE__ ) );
16
 
17
  /**
18
  * check we are as a embedded?
19
  */
20
- if ( defined('WPCF_RUNNING_EMBEDDED' ) && WPCF_RUNNING_EMBEDDED ) {
21
- define( 'WPTOOLSET_FORMS_RELPATH', wpcf_get_file_url( __FILE__, false ) );
22
  }
23
  /**
24
  * setup WPTOOLSET_FORMS_RELPATH for plugin
25
  */
26
- if ( !defined( 'WPTOOLSET_FORMS_RELPATH' ) ) {
27
- define( 'WPTOOLSET_FORMS_RELPATH', plugins_url( '', __FILE__ ) );
28
  }
29
- if ( !defined( 'WPTOOLSET_COMMON_PATH' ) ) {
30
- define( 'WPTOOLSET_COMMON_PATH', plugin_dir_path( __FILE__ ) );
31
  }
32
 
33
- class WPToolset_Forms_Bootstrap
34
- {
35
 
36
  private $__forms;
37
 
38
- public final function __construct()
39
- {
40
  // Custom conditinal AJAX check
41
- add_action( 'wp_ajax_wptoolset_custom_conditional',
42
- array($this, 'ajaxCustomConditional') );
43
 
44
  // Date conditinal AJAX check
45
- add_action( 'wp_ajax_wptoolset_conditional',
46
- array($this, 'ajaxConditional') );
47
 
48
  // Date extended localization AJAX callback
49
- add_action( 'wp_ajax_wpt_localize_extended_date', array( $this, 'wpt_localize_extended_date' ) );
50
- add_action( 'wp_ajax_nopriv_wpt_localize_extended_date', array( $this, 'wpt_localize_extended_date' ) );
 
 
 
 
51
 
52
  // File media popup
53
- if ( (isset( $_GET['context'] ) && $_GET['context'] == 'wpt-fields-media-insert') || (isset( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'],
54
- 'context=wpt-fields-media-insert' ) !== false)
55
  ) {
56
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.file.php';
57
- add_action( 'init', array('WPToolset_Field_File', 'mediaPopup') );
58
  }
59
- add_filter('sanitize_file_name', array( $this, 'sanitize_file_name' ) );
60
 
61
- add_filter( 'wptoolset_filter_wptoolset_repdrag_image', array( $this, 'set_default_repdrag_image' ), 10, 1 );
62
  /**
63
  * common class for calendar
64
  */
65
- require_once WPTOOLSET_FORMS_ABSPATH.'/classes/class.date.scripts.php';
66
  new WPToolset_Field_Date_Scripts();
67
 
68
- add_action('pre_get_posts', array($this,'pre_get_posts'));
69
  }
70
 
71
  // returns HTML
72
- public function field($form_id, $config, $value)
73
- {
74
- $form = $this->form( $form_id, array() );
75
- return $form->metaform( $config, $config['name'], $value );
76
  }
77
 
78
  // returns HTML
@@ -81,129 +78,172 @@ class WPToolset_Forms_Bootstrap
81
  // return $form->editform( $config );
82
  // }
83
 
84
- public function form( $form_id, $config = array() )
85
- {
86
- if ( isset( $this->__forms[$form_id] ) ) {
87
  return $this->__forms[$form_id];
88
  }
89
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.form_factory.php';
90
- return $this->__forms[$form_id] = new FormFactory( $form_id, $config );
91
  }
92
 
93
- public function validate_field($form_id, $config, $value)
94
- {
95
- if ( empty( $config['validation'] ) ) {
96
  return true;
97
  }
98
- $form = $this->form( $form_id, array() );
99
- return $form->validateField( $config, $value );
100
  }
101
 
102
- public function ajaxCustomConditional()
103
- {
104
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
105
  WPToolset_Forms_Conditional::ajaxCustomConditional();
106
  }
107
 
108
- public function checkConditional($config)
109
- {
110
- if ( empty( $config['conditional'] ) ) {
111
  return true;
112
  }
113
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
114
- return WPToolset_Forms_Conditional::evaluate( $config['conditional'] );
115
  }
116
 
117
- public function addConditional($form_id, $config)
118
- {
119
- $this->form( $form_id )->addConditional( $config );
120
  }
121
 
122
- public function ajaxConditional()
123
- {
124
  $data = $_POST['conditions'];
125
  $data['values'] = $_POST['values'];
126
- echo $this->checkConditional( array('conditional' => $data) );
127
  die();
128
  }
129
 
130
- public function wpt_localize_extended_date()
131
- {
132
- $date_format = $_POST['date-format'];
 
 
 
 
 
 
133
  if ($date_format == '') {
134
  $date_format = get_option('date_format');
135
  }
136
- $date = $_POST['date'];
137
  $date = adodb_mktime(0, 0, 0, substr($date, 2, 2), substr($date, 0, 2), substr($date, 4, 4));
138
  $date_format = str_replace('\\\\', '\\', $date_format);
139
- echo json_encode(array('display' => adodb_date($date_format, $date),'timestamp' => $date));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  die();
141
  }
142
 
143
- public function filterTypesField($field, $post_id = null, $_post_wpcf = array())
144
- {
145
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.types.php';
146
- return WPToolset_Types::filterField( $field, $post_id, $_post_wpcf);
147
  }
148
 
149
- public function addFieldFilters($type)
150
- {
151
- if ( $class = $this->form( 'generic' )->loadFieldClass( $type ) ) {
152
- call_user_func( array($class, 'addFilters') );
153
- call_user_func( array($class, 'addActions') );
154
  }
155
  }
156
 
157
- public function getConditionalData($form_id)
158
- {
159
- return $this->form( $form_id )->getConditionalClass()->getData();
160
  }
161
 
162
- public function strtotime($date, $format = null)
163
- {
164
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
165
- return WPToolset_Field_Date::strtotime( $date, $format );
166
  }
167
 
168
- public function timetodate($timestamp, $format = null)
169
- {
170
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
171
- return WPToolset_Field_Date::timetodate( $timestamp, $format );
172
  }
173
 
174
- public function sanitize_file_name($filename)
175
- {
176
  /**
177
  * replace german special characters
178
  */
179
- $de_from = array('ä','ö','ü','ß','Ä','Ö','Ü');
180
- $de_to = array('ae','oe','ue','ss','Ae','Oe','Ue');
181
  $filename = str_replace($de_from, $de_to, $filename);
182
  /**
183
  * replace polish special characters
184
  */
185
- $pl_from = array( 'ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż', 'Ą', 'Ć', 'Ę', 'Ł', 'Ń', 'Ó', 'Ś', 'Ź', 'Ż' );
186
- $pl_to = array( 'a', 'c', 'e', 'l', 'n', 'o', 's', 'z', 'z', 'A', 'C', 'E', 'L', 'N', 'O', 'S', 'Z', 'Z' );
187
  $filename = str_replace($pl_from, $pl_to, $filename);
188
  /**
189
  * remove special characters
190
  */
191
- $filename = preg_replace( '/[^A-Za-z0-9\._@]/', '-', $filename);
192
- $filename = preg_replace( '/%20/', '-', $filename);
193
  return $filename;
194
  }
195
 
196
- public function set_default_repdrag_image($image)
197
- {
198
  return WPTOOLSET_FORMS_RELPATH . '/images/move.png';
199
  }
200
 
201
  /**
202
  * add custom post type to query when they use category or tags taxonomy.
203
  */
204
- public function pre_get_posts($query)
205
- {
206
- if ( is_admin() ) {
207
  return;
208
  }
209
  /**
@@ -212,58 +252,57 @@ class WPToolset_Forms_Bootstrap
212
  if (!$query->is_main_query()) {
213
  return;
214
  }
215
-
216
- /**
217
- * check terms
218
- */
219
- if( $query->is_tax() )
220
- $term = get_queried_object();
221
-
222
- if ( empty($term) ) {
223
- return;
224
- }
225
- /**
226
- * check Types CPT
227
- */
228
- $types_cpt = get_option( 'wpcf-custom-types');
229
  if (!is_array($types_cpt) || empty($types_cpt)) {
230
  return;
231
  }
 
232
  /**
233
- * add cpt
234
  */
235
- foreach($types_cpt as $cpt_slug => $cpt) {
236
- if (array_key_exists('taxonomies', $cpt) && is_array($cpt['taxonomies'])) {
237
- foreach($cpt['taxonomies'] as $tax_slug => $value) {
238
- if (
239
- isset($term->taxonomy)
240
- && $term->taxonomy == $tax_slug
241
- && $value
242
- ) {
243
- $cpt_to_add[] = $cpt_slug;
244
  }
245
  }
246
  }
247
  }
248
  /**
249
- * change query if some CPT use this
250
  */
251
- if (empty($cpt_to_add)) {
252
- return;
 
 
 
 
 
 
 
 
253
  }
254
  /**
255
- * remeber if is empty, then is post
256
  */
257
- $current_types = $query->get('post_type');
258
- if(empty($current_types)) {
259
- $cpt_to_add[] = 'post';
260
- } else if ( is_array($current_types) ) {
261
- $cpt_to_add = array_merge($current_types, $cpt_to_add);
262
- } else {
263
- $cpt_to_add[] = $current_types;
 
 
 
 
264
  }
265
- $query->set('post_type', $cpt_to_add);
266
  }
 
267
  }
268
 
269
  $GLOBALS['wptoolset_forms'] = new WPToolset_Forms_Bootstrap();
2
 
3
  /**
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/bootstrap.php $
6
+ * $LastChangedDate: 2015-04-01 14:15:17 +0000 (Wed, 01 Apr 2015) $
7
+ * $LastChangedRevision: 1125405 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
 
11
  require_once 'api.php';
12
 
13
+ define('WPTOOLSET_FORMS_VERSION', '0.1.1');
14
+ define('WPTOOLSET_FORMS_ABSPATH', dirname(__FILE__));
15
 
16
  /**
17
  * check we are as a embedded?
18
  */
19
+ if (defined('WPCF_RUNNING_EMBEDDED') && WPCF_RUNNING_EMBEDDED) {
20
+ define('WPTOOLSET_FORMS_RELPATH', wpcf_get_file_url(__FILE__, false));
21
  }
22
  /**
23
  * setup WPTOOLSET_FORMS_RELPATH for plugin
24
  */
25
+ if (!defined('WPTOOLSET_FORMS_RELPATH')) {
26
+ define('WPTOOLSET_FORMS_RELPATH', plugins_url('', __FILE__));
27
  }
28
+ if (!defined('WPTOOLSET_COMMON_PATH')) {
29
+ define('WPTOOLSET_COMMON_PATH', plugin_dir_path(__FILE__));
30
  }
31
 
32
+ class WPToolset_Forms_Bootstrap {
 
33
 
34
  private $__forms;
35
 
36
+ public final function __construct() {
 
37
  // Custom conditinal AJAX check
38
+ add_action('wp_ajax_wptoolset_custom_conditional', array($this, 'ajaxCustomConditional'));
 
39
 
40
  // Date conditinal AJAX check
41
+ add_action('wp_ajax_wptoolset_conditional', array($this, 'ajaxConditional'));
 
42
 
43
  // Date extended localization AJAX callback
44
+ add_action('wp_ajax_wpt_localize_extended_date', array($this, 'wpt_localize_extended_date'));
45
+ add_action('wp_ajax_nopriv_wpt_localize_extended_date', array($this, 'wpt_localize_extended_date'));
46
+
47
+ // Taxonomy term suggest AJAX callback
48
+ add_action('wp_ajax_wpt_suggest_taxonomy_term', array($this, 'wpt_suggest_taxonomy_term'));
49
+ add_action('wp_ajax_nopriv_wpt_suggest_taxonomy_term', array($this, 'wpt_suggest_taxonomy_term'));
50
 
51
  // File media popup
52
+ if ((isset($_GET['context']) && $_GET['context'] == 'wpt-fields-media-insert') || (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'context=wpt-fields-media-insert') !== false)
 
53
  ) {
54
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.file.php';
55
+ add_action('init', array('WPToolset_Field_File', 'mediaPopup'));
56
  }
57
+ add_filter('sanitize_file_name', array($this, 'sanitize_file_name'));
58
 
59
+ add_filter('wptoolset_filter_wptoolset_repdrag_image', array($this, 'set_default_repdrag_image'), 10, 1);
60
  /**
61
  * common class for calendar
62
  */
63
+ require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.scripts.php';
64
  new WPToolset_Field_Date_Scripts();
65
 
66
+ add_action('pre_get_posts', array($this, 'pre_get_posts'));
67
  }
68
 
69
  // returns HTML
70
+ public function field($form_id, $config, $value) {
71
+ $form = $this->form($form_id, array());
72
+ return $form->metaform($config, $config['name'], $value);
 
73
  }
74
 
75
  // returns HTML
78
  // return $form->editform( $config );
79
  // }
80
 
81
+ public function form($form_id, $config = array()) {
82
+ if (isset($this->__forms[$form_id])) {
 
83
  return $this->__forms[$form_id];
84
  }
85
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.form_factory.php';
86
+ return $this->__forms[$form_id] = new FormFactory($form_id, $config);
87
  }
88
 
89
+ public function validate_field($form_id, $config, $value) {
90
+ if (empty($config['validation'])) {
 
91
  return true;
92
  }
93
+ $form = $this->form($form_id, array());
94
+ return $form->validateField($config, $value);
95
  }
96
 
97
+ public function ajaxCustomConditional() {
 
98
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
99
  WPToolset_Forms_Conditional::ajaxCustomConditional();
100
  }
101
 
102
+ public function checkConditional($config) {
103
+ if (empty($config['conditional'])) {
 
104
  return true;
105
  }
106
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
107
+ return WPToolset_Forms_Conditional::evaluate($config['conditional']);
108
  }
109
 
110
+ public function addConditional($form_id, $config) {
111
+ $this->form($form_id)->addConditional($config);
 
112
  }
113
 
114
+ public function ajaxConditional() {
 
115
  $data = $_POST['conditions'];
116
  $data['values'] = $_POST['values'];
117
+ echo $this->checkConditional(array('conditional' => $data));
118
  die();
119
  }
120
 
121
+ public function wpt_localize_extended_date() {
122
+ if (!isset($_POST['date'])) {
123
+ die();
124
+ }
125
+ $date = $_POST['date'];
126
+ $date_format = '';
127
+ if (isset($_POST['date-format'])) {
128
+ $date_format = $_POST['date-format'];
129
+ }
130
  if ($date_format == '') {
131
  $date_format = get_option('date_format');
132
  }
 
133
  $date = adodb_mktime(0, 0, 0, substr($date, 2, 2), substr($date, 0, 2), substr($date, 4, 4));
134
  $date_format = str_replace('\\\\', '\\', $date_format);
135
+ echo json_encode(array('display' => adodb_date($date_format, $date), 'timestamp' => $date));
136
+ die();
137
+ }
138
+
139
+ /**
140
+ * wpt_suggest_taxonomy_term
141
+ *
142
+ * Renders the suggestions when adding new flat taxonomy terms on a CRED form
143
+ *
144
+ * Needs a non-empty q attribute and can take an optional non-empty taxonomy attribute on the $_REQUEST
145
+ *
146
+ * @since 1.5.0
147
+ */
148
+ public function wpt_suggest_taxonomy_term() {
149
+ if (
150
+ !isset($_REQUEST['q']) || $_REQUEST['q'] == ''
151
+ ) {
152
+ die();
153
+ }
154
+ global $wpdb;
155
+ $values_to_prepare = array();
156
+ if (function_exists("wpv_esc_like")) {
157
+ $term_name = '%' . wpv_esc_like($_REQUEST['q']) . '%';
158
+ } else {
159
+ if (function_exists("cred_wrap_esc_like")) {
160
+ $term_name = '%' . cred_wrap_esc_like($_REQUEST['q']) . '%';
161
+ }
162
+ }
163
+ $values_to_prepare[] = $term_name;
164
+
165
+ $tax_join = "";
166
+ $tax_where = "";
167
+ if (
168
+ isset($_REQUEST['taxonomy']) && $_REQUEST['taxonomy'] != ''
169
+ ) {
170
+ $tax_join = " JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id ";
171
+ $tax_where = " AND tt.taxonomy = %s ";
172
+ $values_to_prepare[] = $_REQUEST['taxonomy'];
173
+ }
174
+ //
175
+ $results = $wpdb->get_results(
176
+ $wpdb->prepare(
177
+ "SELECT name FROM {$wpdb->terms} t {$tax_join}
178
+ WHERE t.name LIKE %s
179
+ {$tax_where}
180
+ ORDER BY name DESC
181
+ LIMIT 5", $values_to_prepare
182
+ )
183
+ );
184
+ foreach ($results as $row) {
185
+ echo $row->name . "\n";
186
+ }
187
+
188
  die();
189
  }
190
 
191
+ public function filterTypesField($field, $post_id = null, $_post_wpcf = array()) {
 
192
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.types.php';
193
+ return WPToolset_Types::filterField($field, $post_id, $_post_wpcf);
194
  }
195
 
196
+ public function addFieldFilters($type) {
197
+ if ($class = $this->form('generic')->loadFieldClass($type)) {
198
+ call_user_func(array($class, 'addFilters'));
199
+ call_user_func(array($class, 'addActions'));
 
200
  }
201
  }
202
 
203
+ public function getConditionalData($form_id) {
204
+ return $this->form($form_id)->getConditionalClass()->getData();
 
205
  }
206
 
207
+ public function strtotime($date, $format = null) {
 
208
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
209
+ return WPToolset_Field_Date::strtotime($date, $format);
210
  }
211
 
212
+ public function timetodate($timestamp, $format = null) {
 
213
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
214
+ return WPToolset_Field_Date::timetodate($timestamp, $format);
215
  }
216
 
217
+ public function sanitize_file_name($filename) {
 
218
  /**
219
  * replace german special characters
220
  */
221
+ $de_from = array('ä', 'ö', 'ü', 'ß', 'Ä', 'Ö', 'Ü');
222
+ $de_to = array('ae', 'oe', 'ue', 'ss', 'Ae', 'Oe', 'Ue');
223
  $filename = str_replace($de_from, $de_to, $filename);
224
  /**
225
  * replace polish special characters
226
  */
227
+ $pl_from = array('ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż', 'Ą', 'Ć', 'Ę', 'Ł', 'Ń', 'Ó', 'Ś', 'Ź', 'Ż');
228
+ $pl_to = array('a', 'c', 'e', 'l', 'n', 'o', 's', 'z', 'z', 'A', 'C', 'E', 'L', 'N', 'O', 'S', 'Z', 'Z');
229
  $filename = str_replace($pl_from, $pl_to, $filename);
230
  /**
231
  * remove special characters
232
  */
233
+ $filename = preg_replace('/[^A-Za-z0-9\._@]/', '-', $filename);
234
+ $filename = preg_replace('/%20/', '-', $filename);
235
  return $filename;
236
  }
237
 
238
+ public function set_default_repdrag_image($image) {
 
239
  return WPTOOLSET_FORMS_RELPATH . '/images/move.png';
240
  }
241
 
242
  /**
243
  * add custom post type to query when they use category or tags taxonomy.
244
  */
245
+ public function pre_get_posts($query) {
246
+ if (is_admin()) {
 
247
  return;
248
  }
249
  /**
252
  if (!$query->is_main_query()) {
253
  return;
254
  }
255
+ $types_cpt = get_option('wpcf-custom-types');
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  if (!is_array($types_cpt) || empty($types_cpt)) {
257
  return;
258
  }
259
+ $cpt_to_add = array();
260
  /**
261
+ * check category
262
  */
263
+ if (is_category()) {
264
+ foreach ($types_cpt as $cpt_slug => $cpt) {
265
+ if (array_key_exists('taxonomies', $cpt) && is_array($cpt['taxonomies'])) {
266
+ foreach ($cpt['taxonomies'] as $tax_slug => $value) {
267
+ if ('category' == $tax_slug && $value) {
268
+ $cpt_to_add[] = $cpt_slug;
269
+ }
 
 
270
  }
271
  }
272
  }
273
  }
274
  /**
275
+ * check tags
276
  */
277
+ if (is_tag()) {
278
+ foreach ($types_cpt as $cpt_slug => $cpt) {
279
+ if (array_key_exists('taxonomies', $cpt) && is_array($cpt['taxonomies'])) {
280
+ foreach ($cpt['taxonomies'] as $tax_slug => $value) {
281
+ if ('post_tag' == $tax_slug && $value) {
282
+ $cpt_to_add[] = $cpt_slug;
283
+ }
284
+ }
285
+ }
286
+ }
287
  }
288
  /**
289
+ * change query if some CPT use this
290
  */
291
+ if (!empty($cpt_to_add)) {
292
+ /**
293
+ * remeber if is empty, then is post
294
+ */
295
+ $current_types = $query->get('post_type');
296
+ if (empty($current_types)) {
297
+ $cpt_to_add[] = 'post';
298
+ } else {
299
+ $cpt_to_add = array_merge($current_types, $cpt_to_add);
300
+ }
301
+ $query->set('post_type', $cpt_to_add);
302
  }
303
+ return;
304
  }
305
+
306
  }
307
 
308
  $GLOBALS['wptoolset_forms'] = new WPToolset_Forms_Bootstrap();
embedded/common/toolset-forms/classes/class.audio.php CHANGED
@@ -6,7 +6,7 @@ require_once 'class.file.php';
6
  *
7
  * @author Srdjan
8
  *
9
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.audio.php $
10
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
11
  * $LastChangedRevision: 1027712 $
12
  * $LastChangedBy: iworks $
6
  *
7
  * @author Srdjan
8
  *
9
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.audio.php $
10
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
11
  * $LastChangedRevision: 1027712 $
12
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.checkbox.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.checkbox.php $
5
  * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
6
  * $LastChangedRevision: 1069430 $
7
  * $LastChangedBy: iworks $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.checkbox.php $
5
  * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
6
  * $LastChangedRevision: 1069430 $
7
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.checkboxes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author Srdjan
6
  *
7
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.checkboxes.php $
8
  * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
9
  * $LastChangedRevision: 1069430 $
10
  * $LastChangedBy: iworks $
4
  *
5
  * @author Srdjan
6
  *
7
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.checkboxes.php $
8
  * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
9
  * $LastChangedRevision: 1069430 $
10
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.colorpicker.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.colorpicker.php $
5
- * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
6
- * $LastChangedRevision: 1069430 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -18,8 +18,7 @@ class WPToolset_Field_Colorpicker extends FieldFactory
18
  {
19
  public function init()
20
  {
21
-
22
- if ( !is_admin() ) {
23
  wp_enqueue_style( 'wp-color-picker' );
24
  wp_enqueue_script(
25
  'iris',
@@ -38,31 +37,30 @@ class WPToolset_Field_Colorpicker extends FieldFactory
38
  $colorpicker_l10n = array(
39
  'clear' => __( 'Clear' ),
40
  'defaultString' => __( 'Default', 'wpv-views' ),
41
- 'pick' => __( 'Select Color', 'wpv-views' )
42
  );
43
  wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n );
44
  }
45
- wp_register_script(
46
  'wptoolset-field-colorpicker',
47
  WPTOOLSET_FORMS_RELPATH . '/js/colorpicker.js',
48
  array('iris'),
49
  WPTOOLSET_FORMS_VERSION,
50
  true
51
  );
52
- wp_enqueue_script( 'wptoolset-field-colorpicker' );
53
-
54
- }
55
 
56
  static public function registerScripts()
57
  {
58
-
59
  }
60
 
61
  public function enqueueScripts()
62
  {
63
-
64
  }
65
-
66
  public function addTypeValidation($validation) {
67
  $validation['hexadecimal'] = array(
68
  'args' => array(
@@ -78,17 +76,23 @@ class WPToolset_Field_Colorpicker extends FieldFactory
78
  $validation = $this->getValidationData();
79
  $validation = $this->addTypeValidation($validation);
80
  $this->setValidationData($validation);
81
-
82
- $classes = array();
83
- $classes[] = 'js-wpt-colorpicker';
 
 
 
 
 
 
84
  $form = array();
85
  $form['name'] = array(
86
  '#type' => 'textfield',
87
  '#title' => $this->getTitle(),
88
- '#description' => $this->getDescription(),
89
  '#value' => $this->getValue(),
90
  '#name' => $this->getName(),
91
- '#attributes' => array('class' => implode(' ', $classes )),
92
  '#validate' => $validation,
93
  '#after' => '',
94
  '#repetitive' => $this->isRepetitive(),
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.colorpicker.php $
5
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
6
+ * $LastChangedRevision: 1120400 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
18
  {
19
  public function init()
20
  {
21
+ if ( !is_admin() ) {
 
22
  wp_enqueue_style( 'wp-color-picker' );
23
  wp_enqueue_script(
24
  'iris',
37
  $colorpicker_l10n = array(
38
  'clear' => __( 'Clear' ),
39
  'defaultString' => __( 'Default', 'wpv-views' ),
40
+ 'pick' => __( 'Select', 'wpv-views' )." Color"
41
  );
42
  wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n );
43
  }
44
+ wp_register_script(
45
  'wptoolset-field-colorpicker',
46
  WPTOOLSET_FORMS_RELPATH . '/js/colorpicker.js',
47
  array('iris'),
48
  WPTOOLSET_FORMS_VERSION,
49
  true
50
  );
51
+ wp_enqueue_script( 'wptoolset-field-colorpicker' );
52
+ $this->set_placeholder_as_attribute();
53
+ }
54
 
55
  static public function registerScripts()
56
  {
 
57
  }
58
 
59
  public function enqueueScripts()
60
  {
61
+
62
  }
63
+
64
  public function addTypeValidation($validation) {
65
  $validation['hexadecimal'] = array(
66
  'args' => array(
76
  $validation = $this->getValidationData();
77
  $validation = $this->addTypeValidation($validation);
78
  $this->setValidationData($validation);
79
+
80
+ $attributes = $this->getAttr();
81
+ if ( isset($attributes['class'] ) ) {
82
+ $attributes['class'] .= ' ';
83
+ } else {
84
+ $attributes['class'] = '';
85
+ }
86
+ $attributes['class'] = 'js-wpt-colorpicker';
87
+
88
  $form = array();
89
  $form['name'] = array(
90
  '#type' => 'textfield',
91
  '#title' => $this->getTitle(),
92
+ '#description' => $this->getDescription(),
93
  '#value' => $this->getValue(),
94
  '#name' => $this->getName(),
95
+ '#attributes' => $attributes,
96
  '#validate' => $validation,
97
  '#after' => '',
98
  '#repetitive' => $this->isRepetitive(),
embedded/common/toolset-forms/classes/class.conditional.php CHANGED
@@ -493,7 +493,11 @@ if (!class_exists('WPV_Handle_Users_Functions')) {
493
  return false;
494
  }
495
 
496
- private static function get_info() {
 
 
 
 
497
  global $current_user;
498
 
499
  get_currentuserinfo();
493
  return false;
494
  }
495
 
496
+ private static function get_info()
497
+ {
498
+ if (!is_user_logged_in()) {
499
+ return false;
500
+ }
501
  global $current_user;
502
 
503
  get_currentuserinfo();
embedded/common/toolset-forms/classes/class.credaudio.php CHANGED
@@ -7,7 +7,7 @@ require_once 'class.audio.php';
7
  *
8
  * @author Srdjan
9
  *
10
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.credaudio.php $
11
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
12
  * $LastChangedRevision: 1027712 $
13
  * $LastChangedBy: iworks $
7
  *
8
  * @author Srdjan
9
  *
10
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.credaudio.php $
11
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
12
  * $LastChangedRevision: 1027712 $
13
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.credfile.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.credfile.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.credfile.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.credimage.php CHANGED
@@ -7,7 +7,7 @@ require_once 'class.image.php';
7
  *
8
  * @author Srdjan
9
  *
10
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.credimage.php $
11
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
12
  * $LastChangedRevision: 1027712 $
13
  * $LastChangedBy: iworks $
7
  *
8
  * @author Srdjan
9
  *
10
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.credimage.php $
11
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
12
  * $LastChangedRevision: 1027712 $
13
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.credvideo.php CHANGED
@@ -7,7 +7,7 @@ require_once 'class.video.php';
7
  *
8
  * @author Srdjan
9
  *
10
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.credvideo.php $
11
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
12
  * $LastChangedRevision: 1027712 $
13
  * $LastChangedBy: iworks $
7
  *
8
  * @author Srdjan
9
  *
10
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.credvideo.php $
11
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
12
  * $LastChangedRevision: 1027712 $
13
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.date.php CHANGED
@@ -17,6 +17,7 @@ class WPToolset_Field_Date extends FieldFactory
17
 
18
  public function init()
19
  {
 
20
  }
21
 
22
  public static function registerScripts()
@@ -29,8 +30,9 @@ class WPToolset_Field_Date extends FieldFactory
29
 
30
  public static function addFilters()
31
  {
32
- if (has_filter('wptoolset_validation_value_date', array('WPToolset_Field_Date', 'filterValidationValue')))
33
  return;
 
34
  // Filter validation
35
  add_filter('wptoolset_validation_value_date', array('WPToolset_Field_Date', 'filterValidationValue'));
36
  add_filter('wptoolset_validation_rule_js', array('WPToolset_Field_Date', 'filterValidationRuleJs'));
@@ -122,9 +124,9 @@ class WPToolset_Field_Date extends FieldFactory
122
 
123
  $attr_visible = array(
124
  'class' => $def_class,
125
- 'style' => 'display:inline;width:150px;position:relative;z-index:20;',
126
  'readonly' => 'readonly',
127
- 'title' => esc_attr(__('Select date', 'wpv-views'))
128
  );
129
  $attr_hidden = array('class' => $def_class_aux, 'data-ts' => $timestamp, 'data-wpt-type' => 'date');
130
 
@@ -137,7 +139,7 @@ class WPToolset_Field_Date extends FieldFactory
137
  '#title' => $title,
138
  '#description' => $this->getDescription(),
139
  '#attributes' => $attr_visible,
140
- '#name' => '',
141
  '#value' => $datepicker,
142
  '#inline' => true,
143
  );
@@ -192,7 +194,7 @@ class WPToolset_Field_Date extends FieldFactory
192
  '#default_value' => $hour,
193
  '#name' => $this->getName() . '[hour]',
194
  '#inline' => true,
195
- '#attributes' => array('title' => esc_attr(__('Select hour', 'wpv-views'))),
196
  );
197
  if (!empty($attributes_hour_minute)) {
198
  $hour_element['#attributes'] = $attributes_hour_minute;
@@ -228,12 +230,14 @@ class WPToolset_Field_Date extends FieldFactory
228
  '#inline' => true,
229
  '#markup' => sprintf(
230
  '<input type="button" class="button button-secondary js-wpt-date-clear wpt-date-clear" value="%s" %s/>',
231
- esc_attr(__('Clear date', 'wpv-views')),
232
  /**
233
  * show button if array is empty or timestamp in array is
234
  * empty
235
  */
236
- empty($time_value) || ( array_key_exists('timestamp', $time_value) && empty($time_value['timestamp']))? 'style="display:none" ':''
 
 
237
  ),
238
  );
239
  return $form;
@@ -269,6 +273,12 @@ class WPToolset_Field_Date extends FieldFactory
269
 
270
  public static function filterValidationValue($value)
271
  {
 
 
 
 
 
 
272
  if (isset($value['datepicker'])) {
273
  return $value['datepicker'];
274
  }
17
 
18
  public function init()
19
  {
20
+ $this->set_placeholder_as_attribute();
21
  }
22
 
23
  public static function registerScripts()
30
 
31
  public static function addFilters()
32
  {
33
+ if (has_filter('wptoolset_validation_value_date', array('WPToolset_Field_Date', 'filterValidationValue'))) {
34
  return;
35
+ }
36
  // Filter validation
37
  add_filter('wptoolset_validation_value_date', array('WPToolset_Field_Date', 'filterValidationValue'));
38
  add_filter('wptoolset_validation_rule_js', array('WPToolset_Field_Date', 'filterValidationRuleJs'));
124
 
125
  $attr_visible = array(
126
  'class' => $def_class,
127
+ 'style' => 'display:inline;width:150px;position:relative;',
128
  'readonly' => 'readonly',
129
+ 'title' => esc_attr(__('Select', 'wpv-views'))." Date"
130
  );
131
  $attr_hidden = array('class' => $def_class_aux, 'data-ts' => $timestamp, 'data-wpt-type' => 'date');
132
 
139
  '#title' => $title,
140
  '#description' => $this->getDescription(),
141
  '#attributes' => $attr_visible,
142
+ '#name' => $this->getName() . '[display-only]',
143
  '#value' => $datepicker,
144
  '#inline' => true,
145
  );
194
  '#default_value' => $hour,
195
  '#name' => $this->getName() . '[hour]',
196
  '#inline' => true,
197
+ '#attributes' => array('title' => esc_attr(__('Select', 'wpv-views'))." Date"),
198
  );
199
  if (!empty($attributes_hour_minute)) {
200
  $hour_element['#attributes'] = $attributes_hour_minute;
230
  '#inline' => true,
231
  '#markup' => sprintf(
232
  '<input type="button" class="button button-secondary js-wpt-date-clear wpt-date-clear" value="%s" %s/>',
233
+ esc_attr(__('Clear', 'wpv-views'))." Date",
234
  /**
235
  * show button if array is empty or timestamp in array is
236
  * empty
237
  */
238
+ empty($time_value) ||
239
+ (isset($time_value['timestamp']) &&
240
+ empty($time_value['timestamp']))? 'style="display:none" ':''
241
  ),
242
  );
243
  return $form;
273
 
274
  public static function filterValidationValue($value)
275
  {
276
+ /**
277
+ * validate fimestamp range is possible
278
+ */
279
+ if (isset($value['timestamp'])) {
280
+ return $value['timestamp'];
281
+ }
282
  if (isset($value['datepicker'])) {
283
  return $value['datepicker'];
284
  }
embedded/common/toolset-forms/classes/class.date.scripts.php CHANGED
@@ -46,6 +46,15 @@ class WPToolset_Field_Date_Scripts
46
 
47
  public function date_enqueue_scripts()
48
  {
 
 
 
 
 
 
 
 
 
49
  /**
50
  * styles
51
  */
46
 
47
  public function date_enqueue_scripts()
48
  {
49
+ /**
50
+ * prevent load scripts on custom field group edit screen
51
+ */
52
+ if ( is_admin() ) {
53
+ $screen = get_current_screen();
54
+ if ( 'types_page_wpcf-edit' == $screen->id ) {
55
+ return;
56
+ }
57
+ }
58
  /**
59
  * styles
60
  */
embedded/common/toolset-forms/classes/class.eforms.php CHANGED
@@ -28,9 +28,9 @@
28
  * @link http://enlimbo.net/forms
29
  * @author srdjan <srdjan@enlimbo.net>
30
  *
31
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.eforms.php $
32
- * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
33
- * $LastChangedRevision: 1069430 $
34
  * $LastChangedBy: iworks $
35
  *
36
  */
@@ -101,7 +101,6 @@ class Enlimbo_Forms {
101
  $cred_cred_settings = get_option('cred_cred_settings');
102
  if (is_array($cred_cred_settings)) {
103
  $this->form_settings['use_bootstrap'] = array_key_exists('use_bootstrap', $cred_cred_settings) && $cred_cred_settings['use_bootstrap'];
104
- ;
105
  }
106
  }
107
  }
@@ -1117,7 +1116,10 @@ class Enlimbo_Forms {
1117
  }
1118
 
1119
  $parts = explode('[', $name);
1120
- $parts = array_map(create_function('&$a', 'return trim($a, \']\');'), $parts);
 
 
 
1121
  if (!isset($_REQUEST[$parts[0]])) {
1122
  return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
1123
  }
28
  * @link http://enlimbo.net/forms
29
  * @author srdjan <srdjan@enlimbo.net>
30
  *
31
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.eforms.php $
32
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
33
+ * $LastChangedRevision: 1120400 $
34
  * $LastChangedBy: iworks $
35
  *
36
  */
101
  $cred_cred_settings = get_option('cred_cred_settings');
102
  if (is_array($cred_cred_settings)) {
103
  $this->form_settings['use_bootstrap'] = array_key_exists('use_bootstrap', $cred_cred_settings) && $cred_cred_settings['use_bootstrap'];
 
104
  }
105
  }
106
  }
1116
  }
1117
 
1118
  $parts = explode('[', $name);
1119
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196173458/comments
1120
+ //Security Fixing
1121
+ //$parts = array_map(create function('&$a', 'return trim($a, \']\');'), $parts);
1122
+ $parts = array_map("cred_mytrimfunction", $parts);
1123
  if (!isset($_REQUEST[$parts[0]])) {
1124
  return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
1125
  }
embedded/common/toolset-forms/classes/class.field_factory.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.field_factory.php $
6
- * $LastChangedDate: 2014-10-23 10:33:39 +0000 (Thu, 23 Oct 2014) $
7
- * $LastChangedRevision: 1012677 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -28,6 +28,17 @@ abstract class FieldFactory extends FieldAbstract
28
  {
29
  $cred_cred_settings = get_option( 'cred_cred_settings' );
30
  $this->_use_bootstrap = is_array($cred_cred_settings) && array_key_exists( 'use_bootstrap', $cred_cred_settings ) && $cred_cred_settings['use_bootstrap'];
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
 
33
  public function set_metaform($metaform)
@@ -82,8 +93,11 @@ abstract class FieldFactory extends FieldAbstract
82
  return $value;
83
  }
84
 
85
- public function getTitle()
86
  {
 
 
 
87
  return $this->_data['title'];
88
  }
89
 
2
 
3
  /**
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.field_factory.php $
6
+ * $LastChangedDate: 2015-03-02 10:49:00 +0000 (Mon, 02 Mar 2015) $
7
+ * $LastChangedRevision: 1103173 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
28
  {
29
  $cred_cred_settings = get_option( 'cred_cred_settings' );
30
  $this->_use_bootstrap = is_array($cred_cred_settings) && array_key_exists( 'use_bootstrap', $cred_cred_settings ) && $cred_cred_settings['use_bootstrap'];
31
+ $this->set_placeholder_as_attribute();
32
+ }
33
+
34
+ public function set_placeholder_as_attribute()
35
+ {
36
+ if ( !isset($this->_data['attribute']) ) {
37
+ $this->_data['attribute'] = array();
38
+ }
39
+ if ( isset($this->_data['placeholder']) && !empty($this->_data['placeholder'])) {
40
+ $this->_data['attribute']['placeholder'] = htmlentities(stripcslashes($this->_data['placeholder']));
41
+ }
42
  }
43
 
44
  public function set_metaform($metaform)
93
  return $value;
94
  }
95
 
96
+ public function getTitle($_title = false)
97
  {
98
+ if ( $_title && empty($this->_data['title']) && isset($this->_data['_title']) ) {
99
+ return $this->_data['_title'];
100
+ }
101
  return $this->_data['title'];
102
  }
103
 
embedded/common/toolset-forms/classes/class.fieldconfig.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.fieldconfig.php $
6
  * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
7
  * $LastChangedRevision: 1069430 $
8
  * $LastChangedBy: iworks $
2
 
3
  /**
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.fieldconfig.php $
6
  * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
7
  * $LastChangedRevision: 1069430 $
8
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.file.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.file.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -22,38 +22,55 @@ class WPToolset_Field_File extends WPToolset_Field_Textfield
22
 
23
  public function init() {
24
  WPToolset_Field_File::file_enqueue_scripts();
 
25
  }
26
 
27
- public static function file_enqueue_scripts() {
28
- wp_register_script( 'wptoolset-field-file',
29
- WPTOOLSET_FORMS_RELPATH . '/js/file.js', array('jquery'),
30
- WPTOOLSET_FORMS_VERSION, true );
31
-
 
 
 
 
32
  if ( !wp_script_is( 'wptoolset-field-file', 'enqueued' ) ) {
33
- wp_enqueue_script( 'wptoolset-field-file' );
34
- add_thickbox();
 
 
35
  global $post;
36
  $for_post = (!empty( $post->ID ) ? 'post_id=' . $post->ID . '&' : '');
37
- $js_data = array('title' => esc_js( __( 'Select file', 'wpv-views' ) ), 'for_post' => $for_post, 'adminurl' => admin_url());
38
  wp_localize_script( 'wptoolset-field-file', 'wptFileData', $js_data );
39
  }
40
  }
41
 
42
  public function enqueueStyles() {
43
-
44
  }
45
 
 
 
 
 
 
46
  public function metaform() {
47
  $value = $this->getValue();
48
  $type = $this->getType();
49
  $translated_type = '';
50
  $form = array();
51
  $preview = '';
52
-
53
  // Get attachment by guid
54
  if ( !empty( $value ) ) {
55
  global $wpdb;
56
- $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s", $value ) );
 
 
 
 
 
57
  }
58
 
59
  // Set preview
@@ -102,6 +119,7 @@ class WPToolset_Field_File extends WPToolset_Field_Textfield
102
  '#suffix' => '&nbsp;' . $button,
103
  '#validate' => $this->getValidationData(),
104
  '#repetitive' => $this->isRepetitive(),
 
105
  );
106
 
107
  $form[] = array(
@@ -128,10 +146,10 @@ class WPToolset_Field_File extends WPToolset_Field_Textfield
128
 
129
  /**
130
  * Adds column to media item table.
131
- *
132
  * @param type $form_fields
133
  * @param type $post
134
- * @return type
135
  */
136
  public static function attachmentFieldsToEditFilter( $form_fields, $post ) {
137
  // Reset form
@@ -152,9 +170,9 @@ class WPToolset_Field_File extends WPToolset_Field_Textfield
152
 
153
  /**
154
  * Filters media TABs.
155
- *
156
  * @param type $tabs
157
- * @return type
158
  */
159
  public static function mediaUploadTabsFilter( $tabs ) {
160
  unset( $tabs['type_url'] );
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.file.php $
5
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
6
+ * $LastChangedRevision: 1120400 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
22
 
23
  public function init() {
24
  WPToolset_Field_File::file_enqueue_scripts();
25
+ $this->set_placeholder_as_attribute();
26
  }
27
 
28
+ public static function file_enqueue_scripts(){
29
+ wp_register_script(
30
+ 'wptoolset-field-file',
31
+ WPTOOLSET_FORMS_RELPATH . '/js/file-wp35.js',
32
+ array('jquery', 'jquery-masonry'),
33
+ WPTOOLSET_FORMS_VERSION,
34
+ true
35
+ );
36
+
37
  if ( !wp_script_is( 'wptoolset-field-file', 'enqueued' ) ) {
38
+ wp_enqueue_script( 'wptoolset-field-file' );
39
+ wp_enqueue_media();
40
+
41
+ // add_thickbox();
42
  global $post;
43
  $for_post = (!empty( $post->ID ) ? 'post_id=' . $post->ID . '&' : '');
44
+ $js_data = array('title' => esc_js( __( 'Select', 'wpv-views' ) )." File", 'for_post' => $for_post, 'adminurl' => admin_url());
45
  wp_localize_script( 'wptoolset-field-file', 'wptFileData', $js_data );
46
  }
47
  }
48
 
49
  public function enqueueStyles() {
50
+
51
  }
52
 
53
+ /**
54
+ *
55
+ * @global object $wpdb
56
+ *
57
+ */
58
  public function metaform() {
59
  $value = $this->getValue();
60
  $type = $this->getType();
61
  $translated_type = '';
62
  $form = array();
63
  $preview = '';
64
+
65
  // Get attachment by guid
66
  if ( !empty( $value ) ) {
67
  global $wpdb;
68
+ $attachment_id = $wpdb->get_var(
69
+ $wpdb->prepare(
70
+ "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s",
71
+ $value
72
+ )
73
+ );
74
  }
75
 
76
  // Set preview
119
  '#suffix' => '&nbsp;' . $button,
120
  '#validate' => $this->getValidationData(),
121
  '#repetitive' => $this->isRepetitive(),
122
+ '#attributes' => $this->getAttr(),
123
  );
124
 
125
  $form[] = array(
146
 
147
  /**
148
  * Adds column to media item table.
149
+ *
150
  * @param type $form_fields
151
  * @param type $post
152
+ * @return type
153
  */
154
  public static function attachmentFieldsToEditFilter( $form_fields, $post ) {
155
  // Reset form
170
 
171
  /**
172
  * Filters media TABs.
173
+ *
174
  * @param type $tabs
175
+ * @return type
176
  */
177
  public static function mediaUploadTabsFilter( $tabs ) {
178
  unset( $tabs['type_url'] );
embedded/common/toolset-forms/classes/class.form_factory.php CHANGED
@@ -10,9 +10,9 @@ define( "CLASS_NAME_PREFIX", "WPToolset_Field_" );
10
  * Creation Form Class
11
  * @author onTheGo System
12
  *
13
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.form_factory.php $
14
- * $LastChangedDate: 2015-01-28 06:42:34 +0000 (Wed, 28 Jan 2015) $
15
- * $LastChangedRevision: 1077234 $
16
  * $LastChangedBy: iworks $
17
  *
18
  *
@@ -37,8 +37,12 @@ class FormFactory extends FormAbstract
37
 
38
  wp_register_script( 'wptoolset-forms',
39
  WPTOOLSET_FORMS_RELPATH . '/js/main.js',
40
- array('jquery', 'underscore'), WPTOOLSET_FORMS_VERSION, false );
41
  wp_enqueue_script( 'wptoolset-forms' );
 
 
 
 
42
 
43
  if ( is_admin() ) {
44
  wp_register_style( 'wptoolset-forms-admin',
@@ -238,8 +242,10 @@ class FormFactory extends FormAbstract
238
  if ( current_user_can('manage_options') ) {
239
  $htmlArray[] = sprintf(
240
  '<div id="message" class="error"><p>%s</p><p>%s</p></div>',
 
 
241
  sprintf(
242
- __('There is a problem with render <strong>%s (%s)</strong> field.', 'wpv-views'),
243
  $_cfg['title'],
244
  $_cfg['type']
245
  ),
10
  * Creation Form Class
11
  * @author onTheGo System
12
  *
13
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.form_factory.php $
14
+ * $LastChangedDate: 2015-04-01 14:15:17 +0000 (Wed, 01 Apr 2015) $
15
+ * $LastChangedRevision: 1125405 $
16
  * $LastChangedBy: iworks $
17
  *
18
  *
37
 
38
  wp_register_script( 'wptoolset-forms',
39
  WPTOOLSET_FORMS_RELPATH . '/js/main.js',
40
+ array('jquery', 'underscore', 'suggest'), WPTOOLSET_FORMS_VERSION, false );
41
  wp_enqueue_script( 'wptoolset-forms' );
42
+ $wptoolset_forms_localization = array(
43
+ 'ajaxurl' => admin_url( 'admin-ajax.php', null )
44
+ );
45
+ wp_localize_script( 'wptoolset-forms', 'wptoolset_forms_local', $wptoolset_forms_localization );
46
 
47
  if ( is_admin() ) {
48
  wp_register_style( 'wptoolset-forms-admin',
242
  if ( current_user_can('manage_options') ) {
243
  $htmlArray[] = sprintf(
244
  '<div id="message" class="error"><p>%s</p><p>%s</p></div>',
245
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196628627/comments#310360880
246
+ //changed render to rendering
247
  sprintf(
248
+ __('There is a problem rendering field <strong>%s (%s)</strong>.', 'wpv-views'),
249
  $_cfg['title'],
250
  $_cfg['type']
251
  ),
embedded/common/toolset-forms/classes/class.image.php CHANGED
@@ -6,7 +6,7 @@ require_once 'class.file.php';
6
  *
7
  * @author Srdjan
8
  *
9
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.image.php $
10
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
11
  * $LastChangedRevision: 1027712 $
12
  * $LastChangedBy: iworks $
6
  *
7
  * @author Srdjan
8
  *
9
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.image.php $
10
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
11
  * $LastChangedRevision: 1027712 $
12
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.radios.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.radios.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -64,7 +64,15 @@ class WPToolset_Field_Radios extends FieldFactory
64
  */
65
  $options[] = $one_option_data;
66
  }
67
- $options = apply_filters( 'wpt_field_options', $options, $this->getTitle(), 'select' );
 
 
 
 
 
 
 
 
68
  /**
69
  * default_value
70
  */
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.radios.php $
5
+ * $LastChangedDate: 2015-02-18 14:28:53 +0000 (Wed, 18 Feb 2015) $
6
+ * $LastChangedRevision: 1093394 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
64
  */
65
  $options[] = $one_option_data;
66
  }
67
+ /**
68
+ * for user fields we reset title and description to avoid double
69
+ * display
70
+ */
71
+ $title = $this->getTitle();
72
+ if ( empty($title) ) {
73
+ $title = $this->getTitle(true);
74
+ }
75
+ $options = apply_filters( 'wpt_field_options', $options, $title, 'select' );
76
  /**
77
  * default_value
78
  */
embedded/common/toolset-forms/classes/class.recaptcha.php CHANGED
@@ -43,7 +43,7 @@ class WPToolset_Field_Recaptcha extends WPToolset_Field_Textfield
43
  $capture = '';
44
  if ($this->pubkey || !is_admin()) {
45
  try {
46
- $capture = recaptcha_get_html($this->pubkey);
47
  } catch(Exception $e ) {
48
  //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188424989/comments
49
  if ( current_user_can( 'manage_options' ) ) {
43
  $capture = '';
44
  if ($this->pubkey || !is_admin()) {
45
  try {
46
+ $capture = recaptcha_get_html($this->pubkey,null,is_ssl());
47
  } catch(Exception $e ) {
48
  //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188424989/comments
49
  if ( current_user_can( 'manage_options' ) ) {
embedded/common/toolset-forms/classes/class.repetitive.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Repetitive controller
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.repetitive.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
2
  /*
3
  * Repetitive controller
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.repetitive.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.select.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.select.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -43,14 +43,23 @@ class WPToolset_Field_Select extends FieldFactory
43
  $options[] = $one_option_data;
44
  }
45
  }
46
- $options = apply_filters( 'wpt_field_options', $options, $this->getTitle(), 'select' );
 
 
 
 
 
 
 
 
 
47
  /**
48
  * default_value
49
  */
50
  if ( !empty( $value ) || $value == '0' ) {
51
  $data['default_value'] = $value;
52
  }
53
-
54
  $is_multiselect = array_key_exists('multiple', $attributes) && 'multiple' == $attributes['multiple'];
55
  $default_value = isset( $data['default_value'] ) ? $data['default_value'] : null;
56
  //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/189219391/comments
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.select.php $
5
+ * $LastChangedDate: 2015-02-18 14:28:53 +0000 (Wed, 18 Feb 2015) $
6
+ * $LastChangedRevision: 1093394 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
43
  $options[] = $one_option_data;
44
  }
45
  }
46
+
47
+ /**
48
+ * for user fields we reset title and description to avoid double
49
+ * display
50
+ */
51
+ $title = $this->getTitle();
52
+ if ( empty($title) ) {
53
+ $title = $this->getTitle(true);
54
+ }
55
+ $options = apply_filters( 'wpt_field_options', $options, $title, 'select' );
56
  /**
57
  * default_value
58
  */
59
  if ( !empty( $value ) || $value == '0' ) {
60
  $data['default_value'] = $value;
61
  }
62
+
63
  $is_multiselect = array_key_exists('multiple', $attributes) && 'multiple' == $attributes['multiple'];
64
  $default_value = isset( $data['default_value'] ) ? $data['default_value'] : null;
65
  //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/189219391/comments
embedded/common/toolset-forms/classes/class.skype.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.skype.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -14,29 +14,38 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
14
 
15
  protected $_defaults = array('skypename' => '', 'button_style' => 'btn2');
16
 
17
- public function init(){
18
-
19
- add_action( 'admin_footer', array($this, 'editButtonTemplate') );
20
  add_action( 'wp_footer', array($this, 'editButtonTemplate') );
21
-
22
- wp_register_script( 'wptoolset-field-skype',
23
- WPTOOLSET_FORMS_RELPATH . '/js/skype.js', array('jquery'),
24
- WPTOOLSET_FORMS_VERSION, true );
 
 
 
 
25
  wp_enqueue_script( 'wptoolset-field-skype' );
26
  add_thickbox();
27
  $translation = array('title' => esc_js( __( 'Edit Skype button', 'wpv-views' ) ) );
28
- wp_localize_script( 'wptoolset-field-skype', 'wptSkypeData',
29
- $translation );
30
-
31
  }
32
 
33
  public function enqueueStyles() {
34
-
35
  }
36
 
37
  public function metaform() {
38
  $value = wp_parse_args( $this->getValue(), $this->_defaults );
39
- $def_class='js-wpt-skypename js-wpt-cond-trigger';// What is this js-wpt-cond-trigger classname for?
 
 
 
 
 
 
40
  $form = array();
41
  $form[] = array(
42
  '#type' => 'textfield',
@@ -46,7 +55,7 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
46
  '#attributes' => array(),
47
  '#value' => $value['skypename'],
48
  '#validate' => $this->getValidationData(),
49
- '#attributes' => array('class' => $def_class), // Mark to be checked as conditional
50
  '#repetitive' => $this->isRepetitive(),
51
  );
52
  $form['style'] = array(
@@ -63,7 +72,7 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
63
  $button_element = array(
64
  '#name' => '',
65
  '#type' => 'button',
66
- '#value' => esc_attr( __( 'Edit Skype button', 'wpv-views' ) ),
67
  '#attributes' => array('class' => 'js-wpt-skype-edit-button button button-small button-secondary'),
68
  );
69
  /*
@@ -102,7 +111,7 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
102
  }
103
 
104
  public function editform( $config = null ) {
105
-
106
  }
107
 
108
  public function mediaEditor(){
@@ -111,11 +120,11 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
111
 
112
  /**
113
  * Returns HTML formatted skype button.
114
- *
115
  * @param type $skypename
116
  * @param type $template
117
  * @param type $class
118
- * @return type
119
  */
120
  function getButton( $skypename, $template = '', $class = false ) {
121
 
@@ -179,10 +188,10 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
179
 
180
  /**
181
  * Returns HTML formatted skype button image.
182
- *
183
  * @param type $skypename
184
  * @param type $template
185
- * @return type
186
  */
187
  public function getButtonImage( $skypename = '', $template = '', $class = '' ) {
188
 
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.skype.php $
5
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
6
+ * $LastChangedRevision: 1120400 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
14
 
15
  protected $_defaults = array('skypename' => '', 'button_style' => 'btn2');
16
 
17
+ public function init()
18
+ {
19
+ add_action( 'admin_footer', array($this, 'editButtonTemplate') );
20
  add_action( 'wp_footer', array($this, 'editButtonTemplate') );
21
+
22
+ wp_register_script(
23
+ 'wptoolset-field-skype',
24
+ WPTOOLSET_FORMS_RELPATH . '/js/skype.js',
25
+ array('jquery'),
26
+ WPTOOLSET_FORMS_VERSION,
27
+ true
28
+ );
29
  wp_enqueue_script( 'wptoolset-field-skype' );
30
  add_thickbox();
31
  $translation = array('title' => esc_js( __( 'Edit Skype button', 'wpv-views' ) ) );
32
+ wp_localize_script( 'wptoolset-field-skype', 'wptSkypeData', $translation );
33
+ $this->set_placeholder_as_attribute();
 
34
  }
35
 
36
  public function enqueueStyles() {
37
+
38
  }
39
 
40
  public function metaform() {
41
  $value = wp_parse_args( $this->getValue(), $this->_defaults );
42
+ $attributes = $this->getAttr();
43
+ if ( isset($attributes['class'] ) ) {
44
+ $attributes['class'] .= ' ';
45
+ } else {
46
+ $attributes['class'] = '';
47
+ }
48
+ $attributes['class'] = 'js-wpt-skypename js-wpt-cond-trigger';// What is this js-wpt-cond-trigger classname for?
49
  $form = array();
50
  $form[] = array(
51
  '#type' => 'textfield',
55
  '#attributes' => array(),
56
  '#value' => $value['skypename'],
57
  '#validate' => $this->getValidationData(),
58
+ '#attributes' => $attributes,
59
  '#repetitive' => $this->isRepetitive(),
60
  );
61
  $form['style'] = array(
72
  $button_element = array(
73
  '#name' => '',
74
  '#type' => 'button',
75
+ '#value' => esc_attr( __( 'Edit', 'wpv-views' ) )." Skype button",
76
  '#attributes' => array('class' => 'js-wpt-skype-edit-button button button-small button-secondary'),
77
  );
78
  /*
111
  }
112
 
113
  public function editform( $config = null ) {
114
+
115
  }
116
 
117
  public function mediaEditor(){
120
 
121
  /**
122
  * Returns HTML formatted skype button.
123
+ *
124
  * @param type $skypename
125
  * @param type $template
126
  * @param type $class
127
+ * @return type
128
  */
129
  function getButton( $skypename, $template = '', $class = false ) {
130
 
188
 
189
  /**
190
  * Returns HTML formatted skype button image.
191
+ *
192
  * @param type $skypename
193
  * @param type $template
194
+ * @return type
195
  */
196
  public function getButtonImage( $skypename = '', $template = '', $class = '' ) {
197
 
embedded/common/toolset-forms/classes/class.submit.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.submit.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -22,7 +22,7 @@ class WPToolset_Field_Submit extends WPToolset_Field_Textfield
22
  '#title' => $this->getTitle(),
23
  '#description' => $this->getDescription(),
24
  '#name' => $this->getName(),
25
- '#value' => $this->getValue(),
26
  '#validate' => $this->getValidationData(),
27
  '#attributes' => array(
28
  'class' => '',
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.submit.php $
5
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
6
+ * $LastChangedRevision: 1120400 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
22
  '#title' => $this->getTitle(),
23
  '#description' => $this->getDescription(),
24
  '#name' => $this->getName(),
25
+ '#value' => esc_attr(__($this->getValue(), 'wpv-views')),
26
  '#validate' => $this->getValidationData(),
27
  '#attributes' => array(
28
  'class' => '',
embedded/common/toolset-forms/classes/class.taxonomy.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.taxonomy.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -26,40 +26,15 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield
26
  $this->objValues[$term->slug] = $term;
27
  $i++;
28
  }
29
-
30
- wp_register_script( 'wptoolset-jquery-autocompleter',
31
- WPTOOLSET_FORMS_RELPATH . '/js/jquery.autocomplete.js',
32
- array('jquery'), WPTOOLSET_FORMS_VERSION, true );
33
-
34
- wp_register_style('wptoolset-autocompleter', WPTOOLSET_FORMS_RELPATH.'/css/autocompleter.css');
35
- wp_enqueue_script('wptoolset-jquery-autocompleter');
36
  add_action( 'wp_footer', array($this, 'javascript_autocompleter') );
37
  }
38
 
39
  public function javascript_autocompleter() {
40
- $autosubmit = 'function onSelectItem(row)
41
- {
42
- jQuery("input#'.$this->getName().'").focus();
43
- }';
44
- $extra = '
45
- function formatItem(row) {
46
- return row[0];
47
- }
48
- function formatItem2(row) {
49
- if(row.length == 3){
50
- var attr = "attr=\"" + row[2] + "\"";
51
- } else {
52
- attr = "";
53
- }
54
- return "<span "+attr+">" + row[1] + " matches</span>" + row[0];
55
- }';
56
- $results = 1;
57
  echo '<script type="text/javascript">
58
  jQuery(document).ready(function() {
59
  initTaxonomies("'. $this->values .'", "'.$this->getName().'", "'.WPTOOLSET_FORMS_RELPATH.'", "'.$this->_nameField.'");
60
  });
61
- '.$autosubmit.'
62
- '.$extra.'
63
  </script>';
64
  }
65
 
2
 
3
  /**
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.taxonomy.php $
6
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
7
+ * $LastChangedRevision: 1120400 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
26
  $this->objValues[$term->slug] = $term;
27
  $i++;
28
  }
29
+
 
 
 
 
 
 
30
  add_action( 'wp_footer', array($this, 'javascript_autocompleter') );
31
  }
32
 
33
  public function javascript_autocompleter() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  echo '<script type="text/javascript">
35
  jQuery(document).ready(function() {
36
  initTaxonomies("'. $this->values .'", "'.$this->getName().'", "'.WPTOOLSET_FORMS_RELPATH.'", "'.$this->_nameField.'");
37
  });
 
 
38
  </script>';
39
  }
40
 
embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php CHANGED
@@ -1,25 +1,24 @@
1
  <?php
 
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
10
-
11
  include_once 'class.textfield.php';
12
 
13
- class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
14
- {
15
  protected $child;
16
  protected $names;
17
  protected $values = array();
18
  protected $valuesId = array();
19
  protected $objValues;
20
 
21
- public function init()
22
- {
23
  global $post;
24
 
25
  $this->objValues = array();
@@ -32,17 +31,17 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
32
  }
33
  }
34
 
35
- $all = $this->buildTerms(get_terms($this->getName(),array('hide_empty'=>0,'fields'=>'all')));
36
 
37
 
38
 
39
- $childs=array();
40
- $names=array();
41
  foreach ($all as $term) {
42
- $names[$term['term_id']]=$term['name'];
43
  if (!isset($childs[$term['parent']]) || !is_array($childs[$term['parent']]))
44
- $childs[$term['parent']]=array();
45
- $childs[$term['parent']][]=$term['term_id'];
46
  }
47
 
48
  // ksort($childs);
@@ -51,24 +50,23 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
51
  $this->names = $names;
52
  }
53
 
54
- public function enqueueScripts()
55
- {
56
  }
57
 
58
- public function enqueueStyles()
59
- {
60
  }
61
 
62
- public function metaform()
63
- {
64
- $use_bootstrap = array_key_exists( 'use_bootstrap', $this->_data ) && $this->_data['use_bootstrap'];
65
  $attributes = $this->getAttr();
66
- $taxname = $this->getName();
67
  $res = '';
68
  $metaform = array();
69
  $build_what = '';
70
 
71
- if ( array_key_exists( 'display', $this->_data ) && 'select' == $this->_data['display'] ) {
72
  $metaform = $this->buildSelect();
73
  $build_what = 'select';
74
  } else {
@@ -77,14 +75,13 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
77
  $build_what = 'checkboxes';
78
  }
79
 
80
- /**
81
- * TODO
82
- *
83
- * Use this to get the taxonomy labels for the "Add new" event
84
- *
85
- * $taxobject = get_taxonomy( $taxname );
86
- */
87
-
88
  /**
89
  * "Add new" button
90
  */
@@ -92,49 +89,47 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
92
  '#type' => 'button',
93
  '#title' => '',
94
  '#description' => '',
95
- '#name' => "btn_".$taxname,
96
- '#value' => apply_filters('toolset_button_add_new_text', esc_attr( $attributes['add_new_text'] )),
97
  '#attributes' => array(
98
  'style' => 'display:none;',
99
  'data-taxonomy' => $taxname,
100
  'data-build_what' => $build_what,
101
  'data-after-selector' => 'js-wpt-hierarchical-taxonomy-add-new-' . $taxname,
102
- 'data-open' => apply_filters('toolset_button_add_new_text', esc_attr( $attributes['add_new_text'] )),
103
- 'data-close' => apply_filters('toolset_button_cancel_text', esc_attr( __( 'Cancel', 'wpv-views' ) )),// TODO adjust the button value depending on open/close action
104
- 'class' => $use_bootstrap? 'btn btn-default wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide' : 'wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide',
105
  ),
106
-
107
  '#validate' => $this->getValidationData(),
108
  );
109
 
110
  // Input for new taxonomy
111
 
112
- if ( $use_bootstrap ) {
113
- $container = '<div style="display:none" class="form-group wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new-' . $taxname . '" data-taxonomy="' . $taxname . '">';
114
- } else {
115
- $container = '<div style="display:none" class="wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new-' . $taxname . '" data-taxonomy="' . $taxname . '">';
116
- }
117
 
118
- /**
119
- * The textfield input
120
- */
121
  $metaform[] = array(
122
  '#type' => 'textfield',
123
  '#title' => '',
124
  '#description' => '',
125
- '#name' => "new_tax_text_".$taxname,
126
  '#value' => '',
127
  '#attributes' => array(
128
  'data-taxonomy' => $taxname,
129
- 'data-taxtype' => 'hierarchical',
130
- 'class' => $use_bootstrap ? 'inline wpt-new-taxonomy-title js-wpt-new-taxonomy-title' : 'wpt-new-taxonomy-title js-wpt-new-taxonomy-title',
131
  ),
132
  '#validate' => $this->getValidationData(),
133
  '#before' => $container,
134
-
135
  );
136
 
137
- /**
138
  * The select for parent
139
  */
140
  $metaform[] = array(
@@ -146,13 +141,12 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
146
  )),
147
  '#default_value' => 0,
148
  '#description' => '',
149
- '#name' => "new_tax_select_".$taxname,
150
  '#attributes' => array(
151
  'data-parent-text' => $attributes['parent_text'],
152
  'data-taxonomy' => $taxname,
153
  'class' => 'js-taxonomy-parent wpt-taxonomy-parent'
154
  ),
155
-
156
  '#validate' => $this->getValidationData(),
157
  );
158
 
@@ -163,39 +157,35 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
163
  '#type' => 'button',
164
  '#title' => '',
165
  '#description' => '',
166
- '#name' => "new_tax_button_".$taxname,
167
- '#value' => apply_filters('toolset_button_add_text', esc_attr( $attributes['add_text'] )),
168
  '#attributes' => array(
169
  'data-taxonomy' => $taxname,
170
  'data-build_what' => $build_what,
171
- 'class' => $use_bootstrap ? 'btn btn-default wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new' : 'wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new',
172
  ),
173
-
174
  '#validate' => $this->getValidationData(),
175
- '#after' => '</div>',
176
  );
177
 
178
  return $metaform;
179
-
180
  }
181
 
182
- private function buildTerms($obj_terms)
183
- {
184
- $tax_terms=array();
185
  foreach ($obj_terms as $term) {
186
- $tax_terms[]=array(
187
- 'name'=>$term->name,
188
- 'count'=>$term->count,
189
- 'parent'=>$term->parent,
190
- 'term_taxonomy_id'=>$term->term_taxonomy_id,
191
- 'term_id'=>$term->term_id
192
  );
193
  }
194
  return $tax_terms;
195
  }
196
 
197
- private function buildSelect()
198
- {
199
  $attributes = $this->getAttr();
200
 
201
  $multiple = !isset($attributes['single_select']) || !$attributes['single_select'];
@@ -203,9 +193,8 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
203
  $curr_options = $this->getOptions();
204
  $values = $this->valuesId;
205
  $options = array();
206
- if( $curr_options )
207
- {
208
- foreach ($curr_options as $name=>$data) {
209
  $option = array(
210
  '#value' => $name,
211
  '#title' => $data['value'],
@@ -223,7 +212,7 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
223
  * default_value
224
  */
225
  $default_value = null;
226
- if ( count( $this->valuesId) ) {
227
  $default_value = $this->valuesId[0];
228
  }
229
  /**
@@ -236,7 +225,7 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
236
  '#description' => $this->getDescription(),
237
  '#name' => $this->getName() . '[]',
238
  '#options' => $options,
239
- '#default_value' => isset( $data['default_value'] ) && !empty( $data['default_value'] ) ? $data['default_value'] : $default_value,
240
  '#validate' => $this->getValidationData(),
241
  '#class' => 'form-inline',
242
  '#repetitive' => $this->isRepetitive(),
@@ -258,18 +247,17 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
258
  return $form;
259
  }
260
 
261
- private function getOptions($index = 0, $level = 0, $parent = -1)
262
- {
263
- if ( !isset($this->childs[$index]) || empty( $this->childs[$index] ) ) {
264
  return;
265
  }
266
  $options = array();
267
 
268
- foreach( $this->childs[$index] as $one ) {
269
- $options[$one] = array('value' => sprintf('%s%s', str_repeat('&nbsp;', 2*$level ), $this->names[$one]),
270
- 'parent' => $parent);
271
- if ( isset($this->childs[$one]) && count($this->childs[$one])) {
272
- foreach( $this->getOptions( $one, $level + 1, $one ) as $id => $data ) {
273
  $options[$id] = $data;
274
  }
275
  }
@@ -277,24 +265,23 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
277
  return $options;
278
  }
279
 
280
- private function buildCheckboxes( $index, &$childs, &$names, &$metaform, $level = 0, $parent = -1 )
281
- {
282
  if (isset($childs[$index])) {
283
- $level_count = count( $childs[$index] );
284
- foreach ( $childs[$index] as $tkey => $tid ) {
285
  $name = $names[$tid];
286
  /**
287
  * check for "checked"
288
  */
289
  $default_value = false;
290
- if ( isset( $this->valuesId ) && is_array( $this->valuesId ) && !empty($this->valuesId)) {
291
- $default_value = in_array( $tid, $this->valuesId );
292
- } else if ( is_array( $this->getValue() ) ) {
293
- $default_value = in_array( $tid, $this->getValue() );
294
  }
295
  $clases = array();
296
- $clases[] = 'tax-'.sanitize_title($names[$tid]);
297
- $clases[] = 'tax-'.$this->_data['name'].'-'.$tid;
298
  /**
299
  * filter: cred_checkboxes_class
300
  * @param array $clases current array of classes
@@ -303,17 +290,17 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
303
  *
304
  * @return array
305
  */
306
- $clases = apply_filters( 'cred_item_li_class', $clases, array( 'id' => $tid, 'name' => $name ), 'taxonomyhierarchical' );
307
 
308
  $item = array(
309
  '#type' => 'checkbox',
310
  '#title' => $names[$tid],
311
  '#description' => '',
312
- '#name' => $this->getName()."[]",
313
  '#value' => $tid,
314
  '#default_value' => $default_value,
315
  '#validate' => $this->getValidationData(),
316
- '#before' => sprintf( '<li class="%s">', implode( ' ', $clases )),
317
  '#after' => '</li>',
318
  '#attributes' => array(
319
  'data-parent' => $parent
@@ -321,34 +308,34 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
321
  '#pattern' => '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>',
322
  );
323
 
324
- if ( $tkey == 0 ) {
325
  if ($level > 0) {
326
- $item['#before'] = '<li class="tax-children-of-'.$parent.'"><ul class="wpt-form-set-children wpt-form-set-children-level-' . $level . '" data-level="' . $level . '">'.$item['#before'];
327
- } else {
328
- $item['#before'] = '<ul class="wpt-form-set wpt-form-set-checkboxes wpt-form-set-checkboxes-' . $this->getName() . '" data-level="0">'.$item['#before'];
329
  }
330
  }
331
- if ( $tkey == ( $level_count - 1 ) ) {
332
  $item['#after'] = '</li>';
333
  }
334
 
335
  $metaform[] = $item;
336
 
337
- if ( isset( $childs[$tid] ) ) {
338
- $metaform = $this->buildCheckboxes( $tid, $childs, $names, $metaform, $level + 1, $tid );
339
  }
340
-
341
  }
342
  }
343
 
344
  if (count($metaform)) {
345
  if ($level == 0) {
346
  $metaform[count($metaform) - 1]['#after'] .= '</ul>';
347
- } else {
348
  $metaform[count($metaform) - 1]['#after'] .= '</ul></li>';
349
  }
350
  }
351
 
352
  return $metaform;
353
  }
 
354
  }
1
  <?php
2
+
3
  /**
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php $
6
+ * $LastChangedDate: 2015-03-16 12:03:31 +0000 (Mon, 16 Mar 2015) $
7
+ * $LastChangedRevision: 1113864 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
 
11
  include_once 'class.textfield.php';
12
 
13
+ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
14
+
15
  protected $child;
16
  protected $names;
17
  protected $values = array();
18
  protected $valuesId = array();
19
  protected $objValues;
20
 
21
+ public function init() {
 
22
  global $post;
23
 
24
  $this->objValues = array();
31
  }
32
  }
33
 
34
+ $all = $this->buildTerms(get_terms($this->getName(), array('hide_empty' => 0, 'fields' => 'all')));
35
 
36
 
37
 
38
+ $childs = array();
39
+ $names = array();
40
  foreach ($all as $term) {
41
+ $names[$term['term_id']] = $term['name'];
42
  if (!isset($childs[$term['parent']]) || !is_array($childs[$term['parent']]))
43
+ $childs[$term['parent']] = array();
44
+ $childs[$term['parent']][] = $term['term_id'];
45
  }
46
 
47
  // ksort($childs);
50
  $this->names = $names;
51
  }
52
 
53
+ public function enqueueScripts() {
54
+
55
  }
56
 
57
+ public function enqueueStyles() {
58
+
59
  }
60
 
61
+ public function metaform() {
62
+ $use_bootstrap = array_key_exists('use_bootstrap', $this->_data) && $this->_data['use_bootstrap'];
 
63
  $attributes = $this->getAttr();
64
+ $taxname = $this->getName();
65
  $res = '';
66
  $metaform = array();
67
  $build_what = '';
68
 
69
+ if (array_key_exists('display', $this->_data) && 'select' == $this->_data['display']) {
70
  $metaform = $this->buildSelect();
71
  $build_what = 'select';
72
  } else {
75
  $build_what = 'checkboxes';
76
  }
77
 
78
+ /**
79
+ * TODO
80
+ *
81
+ * Use this to get the taxonomy labels for the "Add new" event
82
+ *
83
+ * $taxobject = get_taxonomy( $taxname );
84
+ */
 
85
  /**
86
  * "Add new" button
87
  */
89
  '#type' => 'button',
90
  '#title' => '',
91
  '#description' => '',
92
+ '#name' => "btn_" . $taxname,
93
+ '#value' => apply_filters('toolset_button_add_new_text', esc_attr($attributes['add_new_text'])),
94
  '#attributes' => array(
95
  'style' => 'display:none;',
96
  'data-taxonomy' => $taxname,
97
  'data-build_what' => $build_what,
98
  'data-after-selector' => 'js-wpt-hierarchical-taxonomy-add-new-' . $taxname,
99
+ 'data-open' => apply_filters('toolset_button_add_new_text', esc_attr($attributes['add_new_text'])),
100
+ 'data-close' => apply_filters('toolset_button_cancel_text', esc_attr(__('Cancel', 'wpv-views'))), // TODO adjust the button value depending on open/close action
101
+ 'class' => $use_bootstrap ? 'btn btn-default wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide' : 'wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide',
102
  ),
 
103
  '#validate' => $this->getValidationData(),
104
  );
105
 
106
  // Input for new taxonomy
107
 
108
+ if ($use_bootstrap) {
109
+ $container = '<div style="display:none" class="form-group wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new-' . $taxname . '" data-taxonomy="' . $taxname . '">';
110
+ } else {
111
+ $container = '<div style="display:none" class="wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new-' . $taxname . '" data-taxonomy="' . $taxname . '">';
112
+ }
113
 
114
+ /**
115
+ * The textfield input
116
+ */
117
  $metaform[] = array(
118
  '#type' => 'textfield',
119
  '#title' => '',
120
  '#description' => '',
121
+ '#name' => "new_tax_text_" . $taxname,
122
  '#value' => '',
123
  '#attributes' => array(
124
  'data-taxonomy' => $taxname,
125
+ 'data-taxtype' => 'hierarchical',
126
+ 'class' => $use_bootstrap ? 'inline wpt-new-taxonomy-title js-wpt-new-taxonomy-title' : 'wpt-new-taxonomy-title js-wpt-new-taxonomy-title',
127
  ),
128
  '#validate' => $this->getValidationData(),
129
  '#before' => $container,
 
130
  );
131
 
132
+ /**
133
  * The select for parent
134
  */
135
  $metaform[] = array(
141
  )),
142
  '#default_value' => 0,
143
  '#description' => '',
144
+ '#name' => "new_tax_select_" . $taxname,
145
  '#attributes' => array(
146
  'data-parent-text' => $attributes['parent_text'],
147
  'data-taxonomy' => $taxname,
148
  'class' => 'js-taxonomy-parent wpt-taxonomy-parent'
149
  ),
 
150
  '#validate' => $this->getValidationData(),
151
  );
152
 
157
  '#type' => 'button',
158
  '#title' => '',
159
  '#description' => '',
160
+ '#name' => "new_tax_button_" . $taxname,
161
+ '#value' => apply_filters('toolset_button_add_text', esc_attr($attributes['add_text'])),
162
  '#attributes' => array(
163
  'data-taxonomy' => $taxname,
164
  'data-build_what' => $build_what,
165
+ 'class' => $use_bootstrap ? 'btn btn-default wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new' : 'wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new',
166
  ),
 
167
  '#validate' => $this->getValidationData(),
168
+ '#after' => '</div>',
169
  );
170
 
171
  return $metaform;
 
172
  }
173
 
174
+ private function buildTerms($obj_terms) {
175
+ $tax_terms = array();
 
176
  foreach ($obj_terms as $term) {
177
+ $tax_terms[] = array(
178
+ 'name' => $term->name,
179
+ 'count' => $term->count,
180
+ 'parent' => $term->parent,
181
+ 'term_taxonomy_id' => $term->term_taxonomy_id,
182
+ 'term_id' => $term->term_id
183
  );
184
  }
185
  return $tax_terms;
186
  }
187
 
188
+ private function buildSelect() {
 
189
  $attributes = $this->getAttr();
190
 
191
  $multiple = !isset($attributes['single_select']) || !$attributes['single_select'];
193
  $curr_options = $this->getOptions();
194
  $values = $this->valuesId;
195
  $options = array();
196
+ if ($curr_options) {
197
+ foreach ($curr_options as $name => $data) {
 
198
  $option = array(
199
  '#value' => $name,
200
  '#title' => $data['value'],
212
  * default_value
213
  */
214
  $default_value = null;
215
+ if (count($this->valuesId)) {
216
  $default_value = $this->valuesId[0];
217
  }
218
  /**
225
  '#description' => $this->getDescription(),
226
  '#name' => $this->getName() . '[]',
227
  '#options' => $options,
228
+ '#default_value' => isset($data['default_value']) && !empty($data['default_value']) ? $data['default_value'] : $default_value,
229
  '#validate' => $this->getValidationData(),
230
  '#class' => 'form-inline',
231
  '#repetitive' => $this->isRepetitive(),
247
  return $form;
248
  }
249
 
250
+ private function getOptions($index = 0, $level = 0, $parent = -1) {
251
+ if (!isset($this->childs[$index]) || empty($this->childs[$index])) {
 
252
  return;
253
  }
254
  $options = array();
255
 
256
+ foreach ($this->childs[$index] as $one) {
257
+ $options[$one] = array('value' => sprintf('%s%s', str_repeat('&nbsp;', 2 * $level), $this->names[$one]),
258
+ 'parent' => $parent);
259
+ if (isset($this->childs[$one]) && count($this->childs[$one])) {
260
+ foreach ($this->getOptions($one, $level + 1, $one) as $id => $data) {
261
  $options[$id] = $data;
262
  }
263
  }
265
  return $options;
266
  }
267
 
268
+ private function buildCheckboxes($index, &$childs, &$names, &$metaform, $level = 0, $parent = -1) {
 
269
  if (isset($childs[$index])) {
270
+ $level_count = count($childs[$index]);
271
+ foreach ($childs[$index] as $tkey => $tid) {
272
  $name = $names[$tid];
273
  /**
274
  * check for "checked"
275
  */
276
  $default_value = false;
277
+ if (isset($this->valuesId) && is_array($this->valuesId) && !empty($this->valuesId)) {
278
+ $default_value = in_array($tid, $this->valuesId);
279
+ } else if (is_array($this->getValue())) {
280
+ $default_value = in_array($tid, $this->getValue());
281
  }
282
  $clases = array();
283
+ $clases[] = 'tax-' . sanitize_title($names[$tid]);
284
+ $clases[] = 'tax-' . $this->_data['name'] . '-' . $tid;
285
  /**
286
  * filter: cred_checkboxes_class
287
  * @param array $clases current array of classes
290
  *
291
  * @return array
292
  */
293
+ $clases = apply_filters('cred_item_li_class', $clases, array('id' => $tid, 'name' => $name), 'taxonomyhierarchical');
294
 
295
  $item = array(
296
  '#type' => 'checkbox',
297
  '#title' => $names[$tid],
298
  '#description' => '',
299
+ '#name' => $this->getName() . "[]",
300
  '#value' => $tid,
301
  '#default_value' => $default_value,
302
  '#validate' => $this->getValidationData(),
303
+ '#before' => sprintf('<li class="%s">', implode(' ', $clases)),
304
  '#after' => '</li>',
305
  '#attributes' => array(
306
  'data-parent' => $parent
308
  '#pattern' => '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>',
309
  );
310
 
311
+ if ($tkey == 0) {
312
  if ($level > 0) {
313
+ $item['#before'] = '<li class="tax-children-of-' . $parent . '"><ul class="wpt-form-set-children wpt-form-set-children-level-' . $level . '" data-level="' . $level . '">' . $item['#before'];
314
+ } else {
315
+ $item['#before'] = '<ul class="wpt-form-set wpt-form-set-checkboxes wpt-form-set-checkboxes-' . $this->getName() . '" data-level="0">' . $item['#before'];
316
  }
317
  }
318
+ if ($tkey == ( $level_count - 1 )) {
319
  $item['#after'] = '</li>';
320
  }
321
 
322
  $metaform[] = $item;
323
 
324
+ if (isset($childs[$tid])) {
325
+ $metaform = $this->buildCheckboxes($tid, $childs, $names, $metaform, $level + 1, $tid);
326
  }
 
327
  }
328
  }
329
 
330
  if (count($metaform)) {
331
  if ($level == 0) {
332
  $metaform[count($metaform) - 1]['#after'] .= '</ul>';
333
+ } else {
334
  $metaform[count($metaform) - 1]['#after'] .= '</ul></li>';
335
  }
336
  }
337
 
338
  return $metaform;
339
  }
340
+
341
  }
embedded/common/toolset-forms/classes/class.textarea.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.textarea.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.textarea.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.textfield.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.textfield.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -22,8 +22,6 @@ class WPToolset_Field_Textfield extends FieldFactory
22
  {
23
  public function metaform()
24
  {
25
- $attributes = $this->getAttr();
26
-
27
  $metaform = array();
28
  $metaform[] = array(
29
  '#type' => 'textfield',
@@ -33,7 +31,7 @@ class WPToolset_Field_Textfield extends FieldFactory
33
  '#value' => $this->getValue(),
34
  '#validate' => $this->getValidationData(),
35
  '#repetitive' => $this->isRepetitive(),
36
- '#attributes' => $attributes,
37
  'wpml_action' => $this->getWPMLAction(),
38
  );
39
  return $metaform;
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.textfield.php $
5
+ * $LastChangedDate: 2015-03-02 10:49:00 +0000 (Mon, 02 Mar 2015) $
6
+ * $LastChangedRevision: 1103173 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
22
  {
23
  public function metaform()
24
  {
 
 
25
  $metaform = array();
26
  $metaform[] = array(
27
  '#type' => 'textfield',
31
  '#value' => $this->getValue(),
32
  '#validate' => $this->getValidationData(),
33
  '#repetitive' => $this->isRepetitive(),
34
+ '#attributes' => $this->getAttr(),
35
  'wpml_action' => $this->getWPMLAction(),
36
  );
37
  return $metaform;
embedded/common/toolset-forms/classes/class.types.php CHANGED
@@ -2,9 +2,9 @@
2
  /**
3
  * Types fields specific
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.types.php $
6
- * $LastChangedDate: 2014-10-23 10:33:39 +0000 (Thu, 23 Oct 2014) $
7
- * $LastChangedRevision: 1012677 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -68,6 +68,7 @@ class WPToolset_Types
68
  *
69
  * Main settings that are returned.
70
  */
 
71
  $_field = array(
72
  'id' => $prefix . $field['id'] . $suffix, // Used as main ID (raw date wpt-id), used to connect conditional relations
73
  'meta_key' => $prefix . $field['id'], // Used by Types (meta key of field saved to DB)
@@ -82,6 +83,7 @@ class WPToolset_Types
82
  'repetitive' => self::isRepetitive( $field ), // Is repetitive?
83
  'validation' => self::filterValidation( $field ), // Validation settings
84
  'conditional' => self::filterConditional( $field, $post_id, $_post_wpcf ), // Conditional settings
 
85
  );
86
 
87
  /* Specific field settings
@@ -140,6 +142,7 @@ class WPToolset_Types
140
  if ( $field['type'] == 'radio' ) {
141
  $_field['type'] = 'radios';
142
  }
 
143
  return $cache[$cache_key] = $_field;
144
  }
145
 
2
  /**
3
  * Types fields specific
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.types.php $
6
+ * $LastChangedDate: 2015-03-02 10:49:00 +0000 (Mon, 02 Mar 2015) $
7
+ * $LastChangedRevision: 1103173 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
68
  *
69
  * Main settings that are returned.
70
  */
71
+
72
  $_field = array(
73
  'id' => $prefix . $field['id'] . $suffix, // Used as main ID (raw date wpt-id), used to connect conditional relations
74
  'meta_key' => $prefix . $field['id'], // Used by Types (meta key of field saved to DB)
83
  'repetitive' => self::isRepetitive( $field ), // Is repetitive?
84
  'validation' => self::filterValidation( $field ), // Validation settings
85
  'conditional' => self::filterConditional( $field, $post_id, $_post_wpcf ), // Conditional settings
86
+ 'placeholder' => isset($field['data']) && isset($field['data']['placeholder'])? $field['data']['placeholder']:null, // HTML5 placeholder
87
  );
88
 
89
  /* Specific field settings
142
  if ( $field['type'] == 'radio' ) {
143
  $_field['type'] = 'radios';
144
  }
145
+
146
  return $cache[$cache_key] = $_field;
147
  }
148
 
embedded/common/toolset-forms/classes/class.validation.php CHANGED
@@ -132,16 +132,15 @@ class WPToolset_Forms_Validation
132
  * @return \WP_Error|boolean
133
  * @throws Exception
134
  */
135
- public function validateField( $field ) {
136
- $value = apply_filters( 'wptoolset_validation_value_' . $field->getType(),
137
- $field->getValue() );
138
  $rules = $this->_parseRules( $field->getValidationData(), $value );
139
  // If not required but empty - skip
140
  if ( !isset( $rules['required'] )
141
  && ( is_null( $value ) || $value === false || $value === '' ) ) {
142
  return true;
143
  }
144
-
145
  try {
146
  $errors = array();
147
  foreach ( $rules as $rule => $args ) {
@@ -189,6 +188,11 @@ class WPToolset_Forms_Validation
189
  public function validate( $rule, $args ) {
190
  $validator = $this->_cake();
191
  $rule = $this->_map_rule_js_to_php( $rule );
 
 
 
 
 
192
  if ( is_callable( array($validator, $rule) ) ) {
193
  return call_user_func_array( array($validator, $rule), $args );
194
  }
132
  * @return \WP_Error|boolean
133
  * @throws Exception
134
  */
135
+ public function validateField( $field ) {
136
+ $value = apply_filters( 'wptoolset_validation_value_' . $field->getType(), $field->getValue() );
 
137
  $rules = $this->_parseRules( $field->getValidationData(), $value );
138
  // If not required but empty - skip
139
  if ( !isset( $rules['required'] )
140
  && ( is_null( $value ) || $value === false || $value === '' ) ) {
141
  return true;
142
  }
143
+
144
  try {
145
  $errors = array();
146
  foreach ( $rules as $rule => $args ) {
188
  public function validate( $rule, $args ) {
189
  $validator = $this->_cake();
190
  $rule = $this->_map_rule_js_to_php( $rule );
191
+
192
+ if ( 'skype' == $rule ) {
193
+ return $validator->custom($args[0]['skypename'], '/^([a-zA-Z0-9\,\.\-\_]+)$/');
194
+ }
195
+
196
  if ( is_callable( array($validator, $rule) ) ) {
197
  return call_user_func_array( array($validator, $rule), $args );
198
  }
embedded/common/toolset-forms/classes/class.video.php CHANGED
@@ -6,7 +6,7 @@ require_once 'class.file.php';
6
  *
7
  * @author Srdjan
8
  *
9
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.video.php $
10
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
11
  * $LastChangedRevision: 1027712 $
12
  * $LastChangedBy: iworks $
6
  *
7
  * @author Srdjan
8
  *
9
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.video.php $
10
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
11
  * $LastChangedRevision: 1027712 $
12
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/classes/class.wysiwyg.php CHANGED
@@ -6,7 +6,7 @@ require_once 'class.textarea.php';
6
  *
7
  * @author Srdjan
8
  *
9
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/classes/class.wysiwyg.php $
10
  * $LastChangedDate: 2014-10-29 15:57:36 +0000 (Wed, 29 Oct 2014) $
11
  * $LastChangedRevision: 1016002 $
12
  * $LastChangedBy: iworks $
6
  *
7
  * @author Srdjan
8
  *
9
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/classes/class.wysiwyg.php $
10
  * $LastChangedDate: 2014-10-29 15:57:36 +0000 (Wed, 29 Oct 2014) $
11
  * $LastChangedRevision: 1016002 $
12
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/css/wpt-toolset-frontend.css CHANGED
@@ -285,34 +285,17 @@ img.wpt-credfile-preview-upload {
285
  }
286
 
287
  /* Autocomplete */
288
- .ac_results {
 
 
 
 
289
  padding: 0px;
290
- border: 1px solid WindowFrame;
291
  background-color: Window;
292
  overflow: hidden;
293
  }
294
 
295
- .ac_results ul {
296
- width: 100%;
297
- list-style-position: outside;
298
- list-style: none;
299
- padding: 0;
300
- margin: 0;
301
- }
302
-
303
- .ac_results iframe {
304
- display:none;/*sorry for IE5*/
305
- display/**/:block;/*sorry for IE5*/
306
- position:absolute;
307
- top:0;
308
- left:0;
309
- z-index:-1;
310
- filter:mask();
311
- width:3000px;
312
- height:3000px;
313
- }
314
-
315
- .ac_results li {
316
  margin: 0px;
317
  padding: 2px 5px;
318
  cursor: pointer;
@@ -323,13 +306,7 @@ img.wpt-credfile-preview-upload {
323
  overflow: hidden;
324
  }
325
 
326
- /* changes for matches */
327
- .ac_results li span{
328
- float: right;
329
- padding-right: 10px;
330
- }
331
-
332
- .ac_over {
333
  background-color: Highlight;
334
  color: HighlightText;
335
  }
285
  }
286
 
287
  /* Autocomplete */
288
+ .wpt-suggest-taxonomy-term {
289
+ position: absolute;
290
+ display: none;
291
+ min-width: 100px;
292
+ outline: solid #ccc 1px;
293
  padding: 0px;
 
294
  background-color: Window;
295
  overflow: hidden;
296
  }
297
 
298
+ .wpt-suggest-taxonomy-term li {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  margin: 0px;
300
  padding: 2px 5px;
301
  cursor: pointer;
306
  overflow: hidden;
307
  }
308
 
309
+ .wpt-suggest-taxonomy-term-select {
 
 
 
 
 
 
310
  background-color: Highlight;
311
  color: HighlightText;
312
  }
embedded/common/toolset-forms/external/autocompleter.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/external/autocompleter.php $
5
- * $LastChangedDate: 2014-05-29 08:44:10 +0000 (Thu, 29 May 2014) $
6
- * $LastChangedRevision: 922956 $
7
- * $LastChangedBy: iworks $
8
- *
9
- */
10
-
11
- $path = dirname(__FILE__);
12
- $file = '/wp-config.php';
13
- while ( !is_file( $path.$file) ) {
14
- $path = dirname($path);
15
- }
16
- require_once $path.$file;
17
- function autocompleter()
18
- {
19
- $results = 1;
20
- $wpdb =& $GLOBALS['wpdb'];
21
- $search = @$wpdb->escape($_GET['q']);
22
- if(strlen($search)){
23
- switch($results){
24
- case 1: //Tags and categories
25
- $words = $wpdb->get_results("SELECT concat( name, '|', sum( count ) ) name, sum( count ) cnt FROM ".$wpdb->prefix."terms t, ".$wpdb->prefix."term_taxonomy tt WHERE t.term_id = tt.term_id AND name LIKE '$search%' GROUP BY t.term_id ORDER BY cnt DESC");
26
- break;
27
- case 2: //Only tags
28
- $words = $wpdb->get_results("SELECT concat( name, '|', sum( count ) ) name, sum( count ) cnt FROM ".$wpdb->prefix."terms t, ".$wpdb->prefix."term_taxonomy tt WHERE t.term_id = tt.term_id AND tt.taxonomy='post_tag' AND name LIKE '$search%' GROUP BY t.term_id ORDER BY cnt DESC");
29
- break;
30
- case 3: //Only categories
31
- $words = $wpdb->get_results("SELECT concat( name, '|', sum( count ) ) name, sum( count ) cnt FROM ".$wpdb->prefix."terms t, ".$wpdb->prefix."term_taxonomy tt WHERE t.term_id = tt.term_id AND tt.taxonomy='category' AND name LIKE '$search%' GROUP BY t.term_id ORDER BY cnt DESC");
32
- break;
33
- case 4: //Posts and pages titles
34
- $words = $wpdb->get_results("SELECT concat( post_title, '|', 1 ) name, 1 cnt, ID FROM ".$wpdb->prefix."posts t WHERE post_status='publish' and (post_type='post' OR post_type='page') and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
35
- break;
36
- case 5: //Posts titles
37
- $words = $wpdb->get_results("SELECT concat( post_title, '|', 1 ) name, 1 cnt, ID FROM ".$wpdb->prefix."posts t WHERE post_status='publish' and (post_type='post') and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
38
- break;
39
- case 6: //Pages titles
40
- $words = $wpdb->get_results("SELECT concat( post_title, '|', 1 ) name, 1 cnt, ID FROM ".$wpdb->prefix."posts t WHERE post_status='publish' and (post_type='page') and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
41
- break;
42
- }
43
- foreach ($words as $word){
44
- if($results > 3)
45
- echo $word->name."|".get_permalink($word->ID)."\n";
46
- else
47
- echo $word->name."\n";
48
- }
49
- }
50
- }
51
- if($_GET['q']){
52
- autocompleter();
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
embedded/common/toolset-forms/js/conditional.js CHANGED
@@ -1,10 +1,10 @@
1
  /**
2
  * @see WPToolset_Forms_Conditional (classes/conditional.php)
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/js/conditional.js $
5
- * $LastChangedDate: 2015-02-10 17:10:42 +0000 (Tue, 10 Feb 2015) $
6
- * $LastChangedRevision: 1086547 $
7
- * $LastChangedBy: AmirHelzer $ Riccardo
8
  *
9
  */
10
  var wptCondTriggers = {}
@@ -147,13 +147,13 @@ var wptCond = (function ($) {
147
  console.log('radio', radio);
148
  }
149
  break;
150
- case 'select':
151
  option = $('[name="' + $trigger.attr('name') + '"] option:selected', formID);
152
  // If no option was selected, the value should be empty
153
  val = '';
154
  if (wptCondDebug) {
155
  console.log('option', option);
156
- }
157
  if (option.length == 1) {
158
  if ('undefined' == typeof (option.data('types-value'))) {
159
  val = option.val();
@@ -168,7 +168,7 @@ var wptCond = (function ($) {
168
  } else {
169
  val.push($(this).data('types-value'));
170
  }
171
- });
172
  }
173
  break;
174
  case 'checkbox':
@@ -525,12 +525,14 @@ var wptCond = (function ($) {
525
 
526
  //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193595717/comments
527
  //group issue on select
528
- if ($trigger.is('select')) {
529
- $("#" + $trigger.attr('id') + " > option").each(function () {
530
- //console.log(value + " " + this.text + ' ' + this.value + ' ' + $(this).data('typesValue'));
531
- if ($(this).data('typesValue') && $(this).data('typesValue') == value || this.text==value || value==this.value)
532
- value = this.text;
533
- });
 
 
534
  }
535
  //#####################################################################################
536
 
@@ -597,6 +599,9 @@ var wptCond = (function ($) {
597
  });
598
 
599
  var result = false;
 
 
 
600
 
601
  try {
602
  var parser = new ToolsetParser.Expression(expression);
@@ -606,8 +611,101 @@ var wptCond = (function ($) {
606
  catch (e) {
607
  console.info("Error in Tokenizer", e, expression, " there may be an error in your expression syntax");
608
  }
 
 
 
 
 
 
 
 
 
 
 
609
 
610
- _showHide(result, _getAffected(field, formID));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
611
 
612
  });
613
  wptCallbacks.conditionalCheck.fire(formID);
@@ -616,9 +714,11 @@ var wptCond = (function ($) {
616
  function _showHide(show, $el)
617
  {
618
  //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193353994/comments#302703480
619
- if (jQuery('.wpt-form-error').length) {
 
 
620
  jQuery('.wpt-form-error').hide();
621
- }
622
 
623
  if (wptCondDebug) {
624
  console.info('_showHide');
@@ -636,6 +736,10 @@ var wptCond = (function ($) {
636
  }
637
 
638
  if (show) {
 
 
 
 
639
  $el.addClass('wpt-conditional-visible').removeClass('wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore');
640
  switch (effectmode) {
641
  case 'fade-slide':
@@ -661,6 +765,7 @@ var wptCond = (function ($) {
661
  $el.show();
662
  break;
663
  }
 
664
  } else {
665
  $el.addClass('wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore').removeClass('wpt-conditional-visible');
666
  switch (effectmode) {
@@ -687,6 +792,7 @@ var wptCond = (function ($) {
687
  $el.hide();
688
  break;
689
  }
 
690
  }
691
  }
692
 
1
  /**
2
  * @see WPToolset_Forms_Conditional (classes/conditional.php)
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/js/conditional.js $
5
+ * $LastChangedDate: 2015-04-01 14:15:17 +0000 (Wed, 01 Apr 2015) $
6
+ * $LastChangedRevision: 1125405 $
7
+ * $LastChangedBy: iworks $ Riccardo
8
  *
9
  */
10
  var wptCondTriggers = {}
147
  console.log('radio', radio);
148
  }
149
  break;
150
+ case 'select':
151
  option = $('[name="' + $trigger.attr('name') + '"] option:selected', formID);
152
  // If no option was selected, the value should be empty
153
  val = '';
154
  if (wptCondDebug) {
155
  console.log('option', option);
156
+ }
157
  if (option.length == 1) {
158
  if ('undefined' == typeof (option.data('types-value'))) {
159
  val = option.val();
168
  } else {
169
  val.push($(this).data('types-value'));
170
  }
171
+ });
172
  }
173
  break;
174
  case 'checkbox':
525
 
526
  //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193595717/comments
527
  //group issue on select
528
+ if (false) {
529
+ if ($trigger.is('select') && !$trigger.attr('multiple')) {
530
+ $("#" + $trigger.attr('id') + " > option").each(function () {
531
+ //console.log(value + " " + this.text + ' ' + this.value + ' ' + $(this).data('typesValue'));
532
+ if ($(this).data('typesValue') && $(this).data('typesValue') == value || this.text==value || value==this.value)
533
+ value = this.text;
534
+ });
535
+ }
536
  }
537
  //#####################################################################################
538
 
599
  });
600
 
601
  var result = false;
602
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196173370/comments#309696464
603
+ //Added a new check using text element on select
604
+ var result2 = false;
605
 
606
  try {
607
  var parser = new ToolsetParser.Expression(expression);
611
  catch (e) {
612
  console.info("Error in Tokenizer", e, expression, " there may be an error in your expression syntax");
613
  }
614
+
615
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196173370/comments#309696464
616
+ //Added a new check using text element on select
617
+ // Get the values and update the expression.
618
+ _.each(c.triggers, function (t) {
619
+ var $trigger = _getTrigger(t, formID),
620
+ value = _getTriggerValue($trigger, formID),
621
+ is_array = $trigger.length > 1 ? true : false;
622
+ if (wptCondDebug) {
623
+ console.log("The value is ", value, " for element: ", t, $trigger);
624
+ }
625
 
626
+ //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193595717/comments
627
+ //group issue on select
628
+ if ($trigger.is('select') && !$trigger.attr('multiple')) {
629
+ $("#" + $trigger.attr('id') + " > option").each(function () {
630
+ //console.log(value + " " + this.text + ' ' + this.value + ' ' + $(this).data('typesValue'));
631
+ if ($(this).data('typesValue') && $(this).data('typesValue') == value || this.text==value || value==this.value)
632
+ value = this.text;
633
+ });
634
+ }
635
+ //#####################################################################################
636
+
637
+ if (typeof value != 'undefined') {
638
+
639
+ // make it a string by wrapping in quotes if
640
+ // 1. the value is an empty string
641
+ // 2. or it's not a number
642
+
643
+ // if the trigger is an array, eg checkboxes
644
+ // then convert value to ARRAY(...)
645
+
646
+
647
+ if (is_array === true) {
648
+
649
+ var val_array = '';
650
+
651
+ if (wptCondDebug) {
652
+ console.log();
653
+ }
654
+
655
+ if (value instanceof Array) {
656
+ for (var i = 0; i < value.length; i++) {
657
+ var val = value[i];
658
+ if (val === '' || isNaN(val)) {
659
+ val = '\'' + val + '\'';
660
+ }
661
+
662
+ if (val_array == '') {
663
+ val_array = val;
664
+ } else {
665
+ val_array += ',' + val;
666
+ }
667
+ }
668
+ } else {
669
+ if (isNaN(value)) {
670
+ value = '\'' + value + '\'';
671
+ }
672
+ val_array = value;
673
+ }
674
+
675
+ value = 'ARRAY(' + val_array + ')';
676
+
677
+ }
678
+ else
679
+ {
680
+ if (value === '' || isNaN(value)) {
681
+ value = '\'' + value + '\'';
682
+ }
683
+ }
684
+
685
+ // First replace the $(field_name) format
686
+ var replace = new RegExp('\\$\\(' + t + '\\)', 'g');
687
+
688
+ expression = expression.replace(replace, value);
689
+
690
+ // next replace the $field_name format
691
+ var replace_old = new RegExp('\\$' + t, 'g');
692
+
693
+ expression = expression.replace(replace_old, value);
694
+
695
+ }
696
+
697
+ });
698
+
699
+ try {
700
+ var parser = new ToolsetParser.Expression(expression);
701
+ parser.parse();
702
+ result2 = parser.eval();
703
+ }
704
+ catch (e) {
705
+ console.info("Error in Tokenizer", e, expression, " there may be an error in your expression syntax");
706
+ }
707
+
708
+ _showHide(result||result2, _getAffected(field, formID));
709
 
710
  });
711
  wptCallbacks.conditionalCheck.fire(formID);
714
  function _showHide(show, $el)
715
  {
716
  //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193353994/comments#302703480
717
+
718
+ //TODO: check this cause side effect
719
+ /*if (jQuery('.wpt-form-error').length) {
720
  jQuery('.wpt-form-error').hide();
721
+ }*/
722
 
723
  if (wptCondDebug) {
724
  console.info('_showHide');
736
  }
737
 
738
  if (show) {
739
+ if ( $el.hasClass('wpt-date') && 'object' == typeof wptDate) {
740
+ $('.js-wpt-date', $el).removeAttr('disabled');
741
+ wptDate.init('body');
742
+ }
743
  $el.addClass('wpt-conditional-visible').removeClass('wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore');
744
  switch (effectmode) {
745
  case 'fade-slide':
765
  $el.show();
766
  break;
767
  }
768
+ $($el).find('input, textarea, button, select').prop("disabled", false);
769
  } else {
770
  $el.addClass('wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore').removeClass('wpt-conditional-visible');
771
  switch (effectmode) {
792
  $el.hide();
793
  break;
794
  }
795
+ $($el).find('input, textarea, button, select').attr('disabled','disabled');
796
  }
797
  }
798
 
embedded/common/toolset-forms/js/date.js CHANGED
@@ -107,7 +107,7 @@ var wptDate = (function ($) {
107
  yearRange: wptDateData.yearMin + ':' + wptDateData.yearMax,
108
  beforeShow: function(input) {
109
  $(input).css({
110
- zIndex: 999999
111
  })
112
  }
113
  });
107
  yearRange: wptDateData.yearMin + ':' + wptDateData.yearMax,
108
  beforeShow: function(input) {
109
  $(input).css({
110
+ zIndex: 159999 // media library has z-index 160000
111
  })
112
  }
113
  });
embedded/common/toolset-forms/js/file-wp35.js ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ * $HeadURL: https://www.onthegosystems.com/misc_svn/common/trunk/toolset-forms/js/file-wp35.js $
4
+ * $LastChangedDate: 2015-02-18 12:50:24 +0100 (Wed, 18 Feb 2015) $
5
+ * $LastChangedRevision: 31718 $
6
+ * $LastChangedBy: marcin $
7
+ *
8
+ */
9
+ var wptFile = (function($, w) {
10
+ var frame = [];
11
+ var $item, $parent, $preview;
12
+
13
+ function init() {
14
+ // Fetch available headers and apply jQuery.masonry
15
+ // once the images have loaded.
16
+ var $headers = $('.available-headers');
17
+
18
+ $headers.imagesLoaded( function() {
19
+ $headers.masonry({
20
+ itemSelector: '.default-header',
21
+ isRTL: !! ( 'undefined' != typeof isRtl && isRtl )
22
+ });
23
+ });
24
+ /*
25
+ $('.js-wpt-field').on('click', 'a.js-wpt-file-upload', function() {
26
+ if ( $(this).data('attched-thickbox') ) {
27
+ return;
28
+ }
29
+ return wptFile.open(this, true);
30
+ });
31
+ */
32
+ // Build the choose from library frame.
33
+ $('.js-wpt-field').on('click', 'a.js-wpt-file-upload', function( event ) {
34
+ var $el = $(this);
35
+ var $type = $el.data('wpt-type');
36
+ var $id = $el.parent().attr('id');
37
+ event.preventDefault();
38
+
39
+ // If the media frame already exists, reopen it.
40
+ if ( frame[$id] ) {
41
+ frame[$id].open();
42
+ return;
43
+ }
44
+
45
+ // Create the media frame.
46
+ frame[$id] = wp.media.frames.customHeader = wp.media({
47
+ // Set the title of the modal.
48
+ title: $el.html(),
49
+
50
+ // Tell the modal to show only images.
51
+ library: {
52
+ type: 'file' == $type? null:$type
53
+ },
54
+
55
+ // Customize the submit button.
56
+ button: {
57
+ // Set the text of the button.
58
+ text: $el.data('update'),
59
+ // Tell the button not to close the modal, since we're
60
+ // going to refresh the page when the image is selected.
61
+ close: false
62
+ }
63
+ });
64
+
65
+ // When an image is selected, run a callback.
66
+ frame[$id].on( 'select', function() {
67
+ // Grab the selected attachment.
68
+ var attachment = frame[$id].state().get('selection').first();
69
+ var $parent = $el.parent();
70
+ switch( $type ) {
71
+ case 'image':
72
+ $('.textfield', $parent).val(attachment.attributes.sizes.full.url);
73
+ if ( 0 == $('.wpt-file-preview img', $parent.parent()).length) {
74
+ $('.wpt-file-preview', $parent.parent()).append('<img src="">');
75
+ }
76
+ if ( 'undefined' != typeof attachment.attributes.sizes.thumbnail ) {
77
+ $('.wpt-file-preview img', $parent.parent()).attr('src', attachment.attributes.sizes.thumbnail.url);
78
+ } else {
79
+ $('.wpt-file-preview img', $parent.parent()).attr('src', attachment.attributes.sizes.full.url);
80
+ }
81
+ break;
82
+ default:
83
+ $('.textfield', $parent).val(attachment.attributes.url);
84
+ break;
85
+ }
86
+ frame[$id].close();
87
+ });
88
+
89
+ frame[$id].open();
90
+ });
91
+ }
92
+ return {
93
+ init: init,
94
+ };
95
+ })(jQuery);
96
+
97
+ jQuery(document).ready(wptFile.init);
98
+
embedded/common/toolset-forms/js/file.js DELETED
@@ -1,68 +0,0 @@
1
- /**
2
- *
3
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/js/file.js $
4
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
5
- * $LastChangedRevision: 970205 $
6
- * $LastChangedBy: brucepearson $
7
- *
8
- */
9
- var wptFile = (function($, w) {
10
- var $item, $parent, $preview;
11
- function init() {
12
- $('.js-wpt-field').on('click', 'a.js-wpt-file-upload', function() {
13
- if ( $(this).data('attched-thickbox') ) {
14
- return;
15
- }
16
- return wptFile.open(this, true);
17
- });
18
- }
19
- function initRow(row) {
20
- $('.js-wpt-field', row).on('click', 'a.js-wpt-file-upload', function() {
21
- $(this).data('attched-thickbox', true );
22
- return wptFile.open(this, true);
23
- });
24
- }
25
- function mediaInsert(url, type) {
26
- $(':input', $item).first().val(url);
27
- if (type == 'image') {
28
- $preview.html('<img src="' + url + '" />');
29
- } else {
30
- $preview.html('');
31
- }
32
- tb_remove();
33
- }
34
- function mediaInsertTrigger(guid, type) {
35
- window.parent.wptFile.mediaInsert(guid, type);
36
- window.parent.jQuery('#TB_closeWindowButton').trigger('click');
37
- }
38
- function open(el)
39
- {
40
- height = $('body').height()-20;
41
- if ( 800 < height ) {
42
- height = 800;
43
- }
44
- width = $('body').width()-20;
45
- if ( 670 < width ) {
46
- width = 670;
47
- }
48
- $item = $(el).parents('.js-wpt-field-item');
49
- $parent = $item.parents('.js-wpt-field');
50
- $preview = $('.js-wpt-file-preview', $item);
51
- type = 'file';
52
- if ( $(el).data('wpt-type') ) {
53
- type = $(el).data('wpt-type');
54
- }
55
- tb_show(wptFileData.title, wptFileData.adminurl + 'media-upload.php?' + wptFileData.for_post + 'type='+type+'&context=wpt-fields-media-insert&wpt[id]=' + $parent.data('wpt-id') + '&wpt[type]=' + $parent.data('wpt-type') + '&TB_iframe=true&width='+width+'&height='+height);
56
- return false;
57
- }
58
- return {
59
- init: init,
60
- initRow: initRow,
61
- open: open,
62
- mediaInsert: mediaInsert,
63
- mediaInsertTrigger: mediaInsertTrigger
64
- };
65
- })(jQuery);
66
-
67
- jQuery(document).ready(wptFile.init);
68
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
embedded/common/toolset-forms/js/jquery.autocomplete.js DELETED
@@ -1,507 +0,0 @@
1
- /*
2
- original jQuery plugin by http://www.pengoworks.com/workshop/jquery/autocomplete.htm
3
- just replaced $ with jQuery in order to be complaint with other JavaScript libraries.
4
- */
5
-
6
- jQuery.autocomplete = function(input, options) {
7
- // Create a link to self
8
- var me = this;
9
-
10
- // Create jQuery object for input element
11
- var $input = jQuery(input).attr("autocomplete", "off");
12
-
13
- // Apply inputClass if necessary
14
- if (options.inputClass) $input.addClass(options.inputClass);
15
-
16
- // Create results
17
- var results = document.createElement("div");
18
- // Create jQuery object for results
19
- var $results = jQuery(results);
20
- $results.hide().addClass(options.resultsClass).css("position", "absolute");
21
- if( options.width > 0 ) $results.css("width", options.width);
22
-
23
- // Add to body element
24
- jQuery("body").append(results);
25
-
26
- input.autocompleter = me;
27
-
28
- var timeout = null;
29
- var prev = "";
30
- var active = -1;
31
- var cache = {};
32
- var keyb = false;
33
- var hasFocus = false;
34
- var lastKeyPressCode = null;
35
-
36
- // flush cache
37
- function flushCache(){
38
- cache = {};
39
- cache.data = {};
40
- cache.length = 0;
41
- };
42
-
43
- // flush cache
44
- flushCache();
45
-
46
- // if there is a data array supplied
47
- if( options.data != null ){
48
- var sFirstChar = "", stMatchSets = {}, row = [];
49
-
50
- // no url was specified, we need to adjust the cache length to make sure it fits the local data store
51
- if( typeof options.url != "string" ) options.cacheLength = 1;
52
-
53
- // loop through the array and create a lookup structure
54
- for( var i=0; i < options.data.length; i++ ){
55
- // if row is a string, make an array otherwise just reference the array
56
- row = ((typeof options.data[i] == "string") ? [options.data[i]] : options.data[i]);
57
-
58
- // if the length is zero, don't add to list
59
- if( row[0].length > 0 ){
60
- // get the first character
61
- sFirstChar = row[0].substring(0, 1).toLowerCase();
62
- // if no lookup array for this character exists, look it up now
63
- if( !stMatchSets[sFirstChar] ) stMatchSets[sFirstChar] = [];
64
- // if the match is a string
65
- stMatchSets[sFirstChar].push(row);
66
- }
67
- }
68
-
69
- // add the data items to the cache
70
- for( var k in stMatchSets ){
71
- // increase the cache size
72
- options.cacheLength++;
73
- // add to the cache
74
- addToCache(k, stMatchSets[k]);
75
- }
76
- }
77
-
78
- $input
79
- .keydown(function(e) {
80
- // track last key pressed
81
- lastKeyPressCode = e.keyCode;
82
- switch(e.keyCode) {
83
- case 38: // up
84
- e.preventDefault();
85
- moveSelect(-1);
86
- break;
87
- case 40: // down
88
- e.preventDefault();
89
- moveSelect(1);
90
- break;
91
- case 9: // tab
92
- case 13: // return
93
- if( selectCurrent() ){
94
- // make sure to blur off the current field
95
- $input.get(0).blur();
96
- e.preventDefault();
97
- }
98
- break;
99
- default:
100
- active = -1;
101
- if (timeout) clearTimeout(timeout);
102
- timeout = setTimeout(function(){onChange();}, options.delay);
103
- break;
104
- }
105
- })
106
- .focus(function(){
107
- // track whether the field has focus, we shouldn't process any results if the field no longer has focus
108
- hasFocus = true;
109
- })
110
- .blur(function() {
111
- // track whether the field has focus
112
- hasFocus = false;
113
- hideResults();
114
- });
115
-
116
- hideResultsNow();
117
-
118
- function onChange() {
119
- // ignore if the following keys are pressed: [del] [shift] [capslock]
120
- if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ) return $results.hide();
121
- var v = $input.val();
122
- if (v == prev) return;
123
- prev = v;
124
- if (v.length >= options.minChars) {
125
- $input.addClass(options.loadingClass);
126
- requestData(v);
127
- } else {
128
- $input.removeClass(options.loadingClass);
129
- $results.hide();
130
- }
131
- };
132
-
133
- function moveSelect(step) {
134
-
135
- var lis = jQuery("li", results);
136
- if (!lis) return;
137
-
138
- active += step;
139
-
140
- if (active < 0) {
141
- active = 0;
142
- } else if (active >= lis.size()) {
143
- active = lis.size() - 1;
144
- }
145
-
146
- lis.removeClass("ac_over");
147
-
148
- jQuery(lis[active]).addClass("ac_over");
149
-
150
- // Weird behaviour in IE
151
- // if (lis[active] && lis[active].scrollIntoView) {
152
- // lis[active].scrollIntoView(false);
153
- // }
154
-
155
- };
156
-
157
- function selectCurrent() {
158
- var li = jQuery("li.ac_over", results)[0];
159
- if (!li) {
160
- var $li = jQuery("li", results);
161
- if (options.selectOnly) {
162
- if ($li.length == 1) li = $li[0];
163
- } else if (options.selectFirst) {
164
- li = $li[0];
165
- }
166
- }
167
- if (li) {
168
- selectItem(li);
169
- return true;
170
- } else {
171
- return false;
172
- }
173
- };
174
-
175
- function selectItem(li) {
176
- if (!li) {
177
- li = document.createElement("li");
178
- li.extra = [];
179
- li.selectValue = "";
180
- }
181
- var v = jQuery.trim(li.selectValue ? li.selectValue : li.innerHTML);
182
- input.lastSelected = v;
183
- prev = v;
184
- $results.html("");
185
- $input.val(v);
186
- hideResultsNow();
187
- if (options.onItemSelect) setTimeout(function() { options.onItemSelect(li) }, 1);
188
- };
189
-
190
- // selects a portion of the input string
191
- function createSelection(start, end){
192
- // get a reference to the input element
193
- var field = $input.get(0);
194
- if( field.createTextRange ){
195
- var selRange = field.createTextRange();
196
- selRange.collapse(true);
197
- selRange.moveStart("character", start);
198
- selRange.moveEnd("character", end);
199
- selRange.select();
200
- } else if( field.setSelectionRange ){
201
- field.setSelectionRange(start, end);
202
- } else {
203
- if( field.selectionStart ){
204
- field.selectionStart = start;
205
- field.selectionEnd = end;
206
- }
207
- }
208
- field.focus();
209
- };
210
-
211
- // fills in the input box w/the first match (assumed to be the best match)
212
- function autoFill(sValue){
213
- // if the last user key pressed was backspace, don't autofill
214
- if( lastKeyPressCode != 8 ){
215
- // fill in the value (keep the case the user has typed)
216
- $input.val($input.val() + sValue.substring(prev.length));
217
- // select the portion of the value not typed by the user (so the next character will erase)
218
- createSelection(prev.length, sValue.length);
219
- }
220
- };
221
-
222
- function showResults() {
223
- // get the position of the input field right now (in case the DOM is shifted)
224
- var pos = findPos(input);
225
- // either use the specified width, or autocalculate based on form element
226
- var iWidth = (options.width > 0) ? options.width : $input.width();
227
- // reposition
228
- $results.css({
229
- width: parseInt(iWidth) + "px",
230
- top: (pos.y + input.offsetHeight + 28) + "px",
231
- left: pos.x + "px"
232
- }).show();
233
- };
234
-
235
- function hideResults() {
236
- if (timeout) clearTimeout(timeout);
237
- timeout = setTimeout(hideResultsNow, 200);
238
- };
239
-
240
- function hideResultsNow() {
241
- if (timeout) clearTimeout(timeout);
242
- $input.removeClass(options.loadingClass);
243
- if ($results.is(":visible")) {
244
- $results.hide();
245
- }
246
- if (options.mustMatch) {
247
- var v = $input.val();
248
- if (v != input.lastSelected) {
249
- selectItem(null);
250
- }
251
- }
252
- };
253
-
254
- function receiveData(q, data) {
255
- if (data) {
256
- $input.removeClass(options.loadingClass);
257
- results.innerHTML = "";
258
-
259
- // if the field no longer has focus or if there are no matches, do not display the drop down
260
- if( !hasFocus || data.length == 0 ) return hideResultsNow();
261
-
262
- if (jQuery.browser.msie) {
263
- // we put a styled iframe behind the calendar so HTML SELECT elements don't show through
264
- $results.append(document.createElement('iframe'));
265
- }
266
- results.appendChild(dataToDom(data));
267
- // autofill in the complete box w/the first match as long as the user hasn't entered in more data
268
- if( options.autoFill && ($input.val().toLowerCase() == q.toLowerCase()) ) autoFill(data[0][0]);
269
- showResults();
270
- } else {
271
- hideResultsNow();
272
- }
273
- };
274
-
275
- function parseData(data) {
276
- if (!data) return null;
277
- var parsed = [];
278
- var rows = data.split(options.lineSeparator);
279
- for (var i=0; i < rows.length; i++) {
280
- var row = jQuery.trim(rows[i]);
281
- if (row) {
282
- parsed[parsed.length] = row.split(options.cellSeparator);
283
- }
284
- }
285
- return parsed;
286
- };
287
-
288
- function dataToDom(data) {
289
- var ul = document.createElement("ul");
290
- var num = data.length;
291
-
292
- // limited results to a max number
293
- if( (options.maxItemsToShow > 0) && (options.maxItemsToShow < num) ) num = options.maxItemsToShow;
294
-
295
- for (var i=0; i < num; i++) {
296
- var row = data[i];
297
- if (!row) continue;
298
- var li = document.createElement("li");
299
- if (options.formatItem) {
300
- li.innerHTML = options.formatItem(row, i, num);
301
- li.selectValue = row[0];
302
- } else {
303
- li.innerHTML = row[0];
304
- li.selectValue = row[0];
305
- }
306
- var extra = null;
307
- if (row.length > 1) {
308
- extra = [];
309
- for (var j=1; j < row.length; j++) {
310
- extra[extra.length] = row[j];
311
- }
312
- }
313
- li.extra = extra;
314
- ul.appendChild(li);
315
- jQuery(li).hover(
316
- function() { jQuery("li", ul).removeClass("ac_over"); jQuery(this).addClass("ac_over"); active = jQuery("li", ul).indexOf(jQuery(this).get(0)); },
317
- function() { jQuery(this).removeClass("ac_over"); }
318
- ).click(function(e) { e.preventDefault(); e.stopPropagation(); selectItem(this) });
319
- }
320
- return ul;
321
- };
322
-
323
- function requestData(q) {
324
- if (!options.matchCase) q = q.toLowerCase();
325
- var data = options.cacheLength ? loadFromCache(q) : null;
326
- // recieve the cached data
327
- if (data) {
328
- receiveData(q, data);
329
- // if an AJAX url has been supplied, try loading the data now
330
- } else if( (typeof options.url == "string") && (options.url.length > 0) ){
331
- jQuery.get(makeUrl(q), function(data) {
332
- data = parseData(data);
333
- addToCache(q, data);
334
- receiveData(q, data);
335
- });
336
- // if there's been no data found, remove the loading class
337
- } else {
338
- $input.removeClass(options.loadingClass);
339
- }
340
- };
341
-
342
- function makeUrl(q) {
343
- var url = options.url + "?q=" + encodeURI(q);
344
- for (var i in options.extraParams) {
345
- url += "&" + i + "=" + encodeURI(options.extraParams[i]);
346
- }
347
- return url;
348
- };
349
-
350
- function loadFromCache(q) {
351
- if (!q) return null;
352
- if (cache.data[q]) return cache.data[q];
353
- if (options.matchSubset) {
354
- for (var i = q.length - 1; i >= options.minChars; i--) {
355
- var qs = q.substr(0, i);
356
- var c = cache.data[qs];
357
- if (c) {
358
- var csub = [];
359
- for (var j = 0; j < c.length; j++) {
360
- var x = c[j];
361
- var x0 = x[0];
362
- if (matchSubset(x0, q)) {
363
- csub[csub.length] = x;
364
- }
365
- }
366
- return csub;
367
- }
368
- }
369
- }
370
- return null;
371
- };
372
-
373
- function matchSubset(s, sub) {
374
- if (!options.matchCase) s = s.toLowerCase();
375
- var i = s.indexOf(sub);
376
- if (i == -1) return false;
377
- return i == 0 || options.matchContains;
378
- };
379
-
380
- this.flushCache = function() {
381
- flushCache();
382
- };
383
-
384
- this.setExtraParams = function(p) {
385
- options.extraParams = p;
386
- };
387
-
388
- this.findValue = function(){
389
- var q = $input.val();
390
-
391
- if (!options.matchCase) q = q.toLowerCase();
392
- var data = options.cacheLength ? loadFromCache(q) : null;
393
- if (data) {
394
- findValueCallback(q, data);
395
- } else if( (typeof options.url == "string") && (options.url.length > 0) ){
396
- jQuery.get(makeUrl(q), function(data) {
397
- data = parseData(data)
398
- addToCache(q, data);
399
- findValueCallback(q, data);
400
- });
401
- } else {
402
- // no matches
403
- findValueCallback(q, null);
404
- }
405
- }
406
-
407
- function findValueCallback(q, data){
408
- if (data) $input.removeClass(options.loadingClass);
409
-
410
- var num = (data) ? data.length : 0;
411
- var li = null;
412
-
413
- for (var i=0; i < num; i++) {
414
- var row = data[i];
415
-
416
- if( row[0].toLowerCase() == q.toLowerCase() ){
417
- li = document.createElement("li");
418
- if (options.formatItem) {
419
- li.innerHTML = options.formatItem(row, i, num);
420
- li.selectValue = row[0];
421
- } else {
422
- li.innerHTML = row[0];
423
- li.selectValue = row[0];
424
- }
425
- var extra = null;
426
- if( row.length > 1 ){
427
- extra = [];
428
- for (var j=1; j < row.length; j++) {
429
- extra[extra.length] = row[j];
430
- }
431
- }
432
- li.extra = extra;
433
- }
434
- }
435
-
436
- if( options.onFindValue ) setTimeout(function() { options.onFindValue(li) }, 1);
437
- }
438
-
439
- function addToCache(q, data) {
440
- if (!data || !q || !options.cacheLength) return;
441
- if (!cache.length || cache.length > options.cacheLength) {
442
- flushCache();
443
- cache.length++;
444
- } else if (!cache[q]) {
445
- cache.length++;
446
- }
447
- cache.data[q] = data;
448
- };
449
-
450
- function findPos(obj) {
451
- var curleft = obj.offsetLeft || 0;
452
- var curtop = obj.offsetTop || 0;
453
- while (obj = obj.offsetParent) {
454
- curleft += obj.offsetLeft
455
- curtop += obj.offsetTop
456
- }
457
- return {x:curleft,y:curtop};
458
- }
459
- }
460
-
461
- jQuery.fn.autocomplete = function(url, options, data) {
462
- // Make sure options exists
463
- options = options || {};
464
- // Set url as option
465
- options.url = url;
466
- // set some bulk local data
467
- options.data = ((typeof data == "object") && (data.constructor == Array)) ? data : null;
468
-
469
- // Set default values for required options
470
- options.inputClass = options.inputClass || "ac_input";
471
- options.resultsClass = options.resultsClass || "ac_results";
472
- options.lineSeparator = options.lineSeparator || "\n";
473
- options.cellSeparator = options.cellSeparator || "|";
474
- options.minChars = options.minChars || 1;
475
- options.delay = options.delay || 400;
476
- options.matchCase = options.matchCase || 0;
477
- options.matchSubset = options.matchSubset || 1;
478
- options.matchContains = options.matchContains || 0;
479
- options.cacheLength = options.cacheLength || 1;
480
- options.mustMatch = options.mustMatch || 0;
481
- options.extraParams = options.extraParams || {};
482
- options.loadingClass = options.loadingClass || "ac_loading";
483
- options.selectFirst = options.selectFirst || false;
484
- options.selectOnly = options.selectOnly || false;
485
- options.maxItemsToShow = options.maxItemsToShow || -1;
486
- options.autoFill = options.autoFill || false;
487
- options.width = parseInt(options.width, 10) || 0;
488
-
489
- this.each(function() {
490
- var input = this;
491
- new jQuery.autocomplete(input, options);
492
- });
493
-
494
- // Don't break the chain
495
- return this;
496
- }
497
-
498
- jQuery.fn.autocompleteArray = function(data, options) {
499
- return this.autocomplete(null, options, data);
500
- }
501
-
502
- jQuery.fn.indexOf = function(e){
503
- for( var i=0; i<this.length; i++ ){
504
- if( this[i] == e ) return i;
505
- }
506
- return -1;
507
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
embedded/common/toolset-forms/js/main.js CHANGED
@@ -8,9 +8,9 @@ wptCallbacks.removeRepetitive = jQuery.Callbacks('unique');
8
  wptCallbacks.conditionalCheck = jQuery.Callbacks('unique');
9
  wptCallbacks.reset = jQuery.Callbacks('unique');
10
 
11
- jQuery(document).ready(function() {
12
  if (typeof wptValidation !== 'undefined') {
13
- wptCallbacks.validationInit.add(function() {
14
  wptValidation.init();
15
  });
16
  }
@@ -22,9 +22,11 @@ jQuery(document).ready(function() {
22
  /**
23
  * check taxonmies on submitted forms
24
  */
25
- jQuery('.cred-taxonomy', jQuery('form.is_submitted')).each(function(){
26
  parent = jQuery(this);
27
- setTimeout( function(){jQuery('input.wpt-taxonomy-add-new', parent).click();}, 50);
 
 
28
  });
29
  });
30
 
@@ -42,8 +44,8 @@ function apply_filters(name, val) {
42
  if (typeof wptFilters[name] === 'undefined')
43
  return val;
44
  var args = _.rest(_.toArray(arguments));
45
- _.each(wptFilters[name], function(funcs, priority) {
46
- _.each(funcs, function($callback) {
47
  var _args = args.slice(0, $callback[1]);
48
  args[0] = $callback[0].apply(null, _args);
49
  });
@@ -57,8 +59,8 @@ function do_action(name) {
57
  if (typeof wptFilters[name] === 'undefined')
58
  return false;
59
  var args = _.rest(_.toArray(arguments));
60
- _.each(wptFilters[name], function(funcs, priority) {
61
- _.each(funcs, function($callback) {
62
  var _args = args.slice(0, $callback[1]);
63
  $callback[0].apply(null, _args);
64
  });
@@ -75,19 +77,20 @@ function showHideMostPopularButton(taxonomy, form)
75
  var $taxonomy_box = jQuery('.shmpt-' + taxonomy, form);
76
  var $tag_list = $taxonomy_box.find('.js-wpt-taxonomy-popular-add');
77
 
78
- if( !$button.hasClass('js-wpt-taxonomy-popular-show-hide') ) return true;
 
79
 
80
- if( $tag_list.length > 0 )
81
  {
82
  $button.show();
83
  return true;
84
- }else{
85
  $button.hide();
86
  return false;
87
  }
88
  }
89
 
90
- jQuery(document).on('click', '.js-wpt-taxonomy-popular-show-hide', function() {
91
  showHideMostPopularTaxonomy(this);
92
  });
93
 
@@ -95,20 +98,20 @@ function showHideMostPopularTaxonomy(el)
95
  {
96
  var taxonomy = jQuery(el).data('taxonomy');
97
  var form = jQuery(el).closest('form');
98
- jQuery('.shmpt-'+taxonomy, form).toggle();
99
  var curr = jQuery(el).val();
100
- if (curr==jQuery(el).data('show-popular-text')) {
101
  jQuery(el).val(jQuery(el).data('hide-popular-text'), form).addClass('btn-cancel');
102
  } else {
103
  jQuery(el).val(jQuery(el).data('show-popular-text'), form).removeClass('btn-cancel');
104
  }
105
  }
106
 
107
- jQuery(document).on('click', '.js-wpt-taxonomy-popular-add', function() {
108
  var thiz = jQuery(this);
109
- var taxonomy = thiz.data( 'taxonomy' );
110
- var slug = thiz.data( 'slug' );
111
- var _name = thiz.data( 'name' );
112
  addTaxonomy(_name, taxonomy, this);
113
  return false;
114
  });
@@ -116,79 +119,82 @@ jQuery(document).on('click', '.js-wpt-taxonomy-popular-add', function() {
116
  function addTaxonomy(slug, taxonomy, el)
117
  {
118
  var form = jQuery(el).closest('form');
119
- var curr = jQuery('input[name=tmp_'+taxonomy+']', form).val().trim();
120
- if (''==curr) {
121
- jQuery('input[name=tmp_'+taxonomy+']', form).val(slug);
122
  setTaxonomy(taxonomy, el);
123
  } else {
124
- if (curr.indexOf( slug )==-1) {
125
- jQuery('input[name=tmp_'+taxonomy+']', form).val(curr+','+slug);
126
  setTaxonomy(taxonomy, el);
127
  }
128
  }
129
- jQuery('input[name=tmp_'+taxonomy+']', form).val('');
130
  }
131
 
132
- jQuery(document).on('click', '.js-wpt-taxonomy-add-new', function() {
133
- var thiz = jQuery(this),
134
- taxonomy = thiz.data( 'taxonomy' );
135
- setTaxonomy(taxonomy, this);
136
  });
137
 
138
- jQuery(document).on('keypress', '.js-wpt-new-taxonomy-title', function(e) {
139
- if( 13 === e.keyCode ) {
140
- e.preventDefault();
141
- var thiz = jQuery(this),
142
- taxonomy = thiz.data( 'taxonomy' ),
143
- taxtype = thiz.data( 'taxtype' );
144
- if ( taxtype == 'hierarchical' ) {
145
- toolsetForms.cred_tax.add_taxonomy( taxonomy, this );
146
- } else {
147
- setTaxonomy(taxonomy, this);
148
- }
149
- }
150
- });
151
 
152
  function setTaxonomy(taxonomy, el)
153
  {
154
  var form = jQuery(el).closest('form');
155
- var tmp_tax = jQuery('input[name=tmp_'+taxonomy+']', form).val();
156
- if (tmp_tax.trim()=='') return;
157
- var tax = jQuery('input[name='+taxonomy+']', form).val();
 
158
  var arr = tax.split(',');
159
- if (jQuery.inArray(tmp_tax, arr)!==-1) return;
160
- var toadd = (tax=='') ? tmp_tax : tax+','+tmp_tax;
161
- jQuery('input[name='+taxonomy+']', form).val(toadd);
162
- jQuery('input[name=tmp_'+taxonomy+']', form).val('');
 
163
  updateTaxonomies(taxonomy, form);
164
  }
165
 
166
  function updateTaxonomies(taxonomy, form)
167
  {
168
- var taxonomies = jQuery('input[name='+taxonomy+']', form).val();
169
- jQuery('div.tagchecklist-'+taxonomy, form).html('');
170
- if (!taxonomies||(taxonomies&&taxonomies.trim()=='')) return;
 
171
  var toshow = taxonomies.split(',');
172
  var str = '';
173
- for (var i=0;i<toshow.length;i++) {
174
  var sh = toshow[i].trim();
175
- str += '<span><a href="#" class=\'ntdelbutton\' data-wpcf-i=\''+i+'\' id=\'post_tag-check-num-'+i+'\'>X</a>&nbsp;'+sh+'</span>';
176
  }
177
- jQuery('div.tagchecklist-'+taxonomy, form).html(str);
178
- jQuery('div.tagchecklist-'+taxonomy+' a', form).bind('click', function() {
179
- jQuery('input[name='+taxonomy+']', form).val('');
180
  del = jQuery(this).data('wpcf-i');
181
  var values = '';
182
- for(i=0;i<toshow.length;i++ ) {
183
- if ( del == i ) {
184
  continue;
185
  }
186
- if ( values ) {
187
  values += ',';
188
  }
189
  values += toshow[i];
190
  }
191
- jQuery('input[name='+taxonomy+']', form).val(values) ;
192
  updateTaxonomies(taxonomy, form);
193
 
194
  return false;
@@ -198,23 +204,21 @@ function updateTaxonomies(taxonomy, form)
198
 
199
  function initTaxonomies(values, taxonomy, url, fieldId)
200
  {
201
- form = jQuery('#'+fieldId.replace(/_field_\d+$/, '' ) ).closest('form');
202
- jQuery('div.tagchecklist-'+taxonomy).html(values);
203
- jQuery('input[name='+taxonomy+']').val(values);
 
204
  updateTaxonomies(taxonomy, form);
205
- jQuery('input[name=tmp_'+taxonomy+']').autocomplete (
206
- url+'/external/autocompleter.php',
207
- {
208
- delay:10,
209
- minChars:2,
210
- matchSubset:1,
211
- matchContains:1,
212
- cacheLength:10,
213
- formatItem:formatItem,
214
- onItemSelect:onSelectItem,
215
- autoFill:true
216
- }
217
- );
218
  }
219
 
220
  toolsetForms.CRED_taxonomy = function () {
@@ -236,11 +240,11 @@ toolsetForms.CRED_taxonomy = function () {
236
  }
237
 
238
  self._fill_parent_drop_down = function () {
239
- jQuery('select.js-taxonomy-parent').each ( function () {
240
  var select = jQuery(this);
241
 
242
  // remove all the options
243
- jQuery(this).find('option').each (function () {
244
  if (jQuery(this).val() != '-1') {
245
  jQuery(this).remove();
246
  }
@@ -249,19 +253,19 @@ toolsetForms.CRED_taxonomy = function () {
249
  var taxonomy = jQuery(this).data('taxonomy');
250
 
251
  // Copy all the checkbox values if it's checkbox mode
252
- jQuery('input[name="' + taxonomy + '\[\]"]').each (function () {
253
  var id = jQuery(this).attr('id');
254
  var label = jQuery(this).next('label');
255
  var level = jQuery(this).closest('ul').data('level');
256
  var prefix = '';
257
- if ( level ) {
258
  prefix = "\xA0\xA0" + Array(level).join("\xA0\xA0");
259
  }
260
  select.append('<option value="' + jQuery(this).val() + '">' + prefix + label.text() + '</option>');
261
  })
262
 
263
  // Copy all the select option values if it's select mode
264
- jQuery('select[name="' + taxonomy + '\[\]"]').find('option').each (function () {
265
  var id = jQuery(this).val();
266
  var text = jQuery(this).text();
267
  select.append('<option value="' + id + '">' + text + '</option>');
@@ -276,6 +280,9 @@ toolsetForms.CRED_taxonomy = function () {
276
  // replace the taxonomy button placeholders with the actual buttons.
277
  jQuery('.js-taxonomy-button-placeholder').each(function () {
278
  var placeholder = jQuery(this);
 
 
 
279
  var taxonomy = jQuery(this).data('taxonomy');
280
  var form = jQuery(this).closest('form');
281
  var buttons = jQuery('[name="sh_' + taxonomy + '"],[name="btn_' + taxonomy + '"]', form);
@@ -286,11 +293,15 @@ toolsetForms.CRED_taxonomy = function () {
286
  buttons.each(function () {
287
  var button = jQuery(this, form);
288
 
289
- button.detach();
 
 
 
 
290
  placeholder.replaceWith(button);
291
 
292
  if (button.hasClass('js-wpt-taxonomy-popular-show-hide')) {
293
- if( showHideMostPopularButton(taxonomy, form) ) {
294
  button.show();
295
  }
296
  } else {
@@ -301,56 +312,56 @@ toolsetForms.CRED_taxonomy = function () {
301
  //Responsible of the issue https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188673095/comments
302
  //changed selector
303
  //var selector = button.data('after-selector');
304
- selectors.push( button.data('after-selector') )
305
  if (typeof selector !== 'undefined' && selector.length) {
306
  var position = button;
307
- jQuery('.' + selectors[0]).detach();
308
- jQuery('.' + selectors[0]).insertAfter(button);
309
- position = jQuery('.' + selectors[0]);
310
- selectors.pop();
311
  }
312
  })
313
  }
314
  });
315
  }
316
 
317
- jQuery(document).on('click', '.js-wpt-hierarchical-taxonomy-add-new-show-hide', function() {
318
- if ( jQuery(this).val() == jQuery(this).data('close') ) {
319
  jQuery(this).val(jQuery(this).data('open')).removeClass('btn-cancel');
320
  } else {
321
  jQuery(this).val(jQuery(this).data('close')).addClass('btn-cancel');
322
  }
323
- var thiz = jQuery(this), taxonomy = thiz.data( 'taxonomy' );
324
- self.add_new_show_hide( taxonomy, this );
325
  });
326
 
327
- self.add_new_show_hide = function ( taxonomy, button ) {
328
  var form = jQuery(button).closest('form');
329
  jQuery('.js-wpt-hierarchical-taxonomy-add-new-' + taxonomy, form).toggle();
330
- self.hide_parent_button_if_no_terms( taxonomy, button );
331
  }
332
 
333
- jQuery(document).on('click', '.js-wpt-hierarchical-taxonomy-add-new', function() {
334
- var thiz = jQuery(this),
335
- taxonomy = thiz.data( 'taxonomy' );
336
- self.add_taxonomy( taxonomy, this );
337
  });
338
  /*
339
- jQuery(document).on('keypress', '.js-wpt-new-taxonomy-title', function(e) {
340
- if( 13 === e.keyCode ) {
341
- e.preventDefault();
342
- var thiz = jQuery(this),
343
- taxonomy = thiz.data( 'taxonomy' );
344
- self.add_taxonomy( taxonomy, this );
345
- }
346
- });
347
- */
348
 
349
- self.terms_exist = function( taxonomy, button )
350
  {
351
  var form = jQuery(button).closest('form');
352
  var build_what = jQuery(button).data('build_what'), parent = jQuery('[name="new_tax_select_' + taxonomy + '"]', form).val();
353
- if ( build_what === 'checkboxes' ){
354
  var first_checkbox = jQuery('input[name="' + taxonomy + '\[\]"][data-parent="' + parent + '"]:first', form);
355
  return first_checkbox.length > 0;
356
  } else {
@@ -362,22 +373,22 @@ toolsetForms.CRED_taxonomy = function () {
362
  };
363
 
364
  self._add_new_flag = [];
365
- self.hide_parent_button_if_no_terms = function( taxonomy, button )
366
  {
367
  var form = jQuery(button).closest('form');
368
  var form_id = form.attr('id');
369
- if ('undefined' == typeof self._add_new_flag[form_id] ) {
370
  self._add_new_flag[form_id] = '';
371
  }
372
  self._add_new_flag[form_id] = !self._add_new_flag[form_id];
373
- if( self._add_new_flag[form_id] === false ) {
374
  jQuery('[name="new_tax_select_' + taxonomy + '"]', form).hide();
375
  } else {
376
  jQuery('[name="new_tax_select_' + taxonomy + '"]', form).show();
377
  }
378
  };
379
 
380
- self.add_taxonomy = function ( taxonomy, button )
381
  {
382
  var form = jQuery(button).closest('form');
383
  var new_taxonomy = jQuery('[name="new_tax_text_' + taxonomy + '"]', form).val();
@@ -390,7 +401,7 @@ toolsetForms.CRED_taxonomy = function () {
390
 
391
  // make sure we don't already have a taxonomy with the same name.
392
  var exists = false;
393
- jQuery('input[name="' + taxonomy + '\[\]"]').each (function () {
394
  var id = jQuery(this).attr('id');
395
  var label = jQuery('label[for="' + id + '"]', form);
396
 
@@ -400,7 +411,7 @@ toolsetForms.CRED_taxonomy = function () {
400
  }
401
  });
402
 
403
- jQuery('select[name="' + taxonomy + '\[\]"]', form).find('option').each (function () {
404
  if (new_taxonomy == jQuery(this).text()) {
405
  exists = true;
406
  self._flash_it(jQuery(this));
@@ -413,43 +424,43 @@ toolsetForms.CRED_taxonomy = function () {
413
  }
414
 
415
  var parent = jQuery('[name="new_tax_select_' + taxonomy + '"]', form).val(),
416
- add_position = null,
417
- add_before = true,
418
- div_fields_wrap = jQuery('div[data-item_name="taxonomyhierarchical-'+taxonomy+'"]', form),
419
- level = 0;
420
 
421
- if ( build_what === 'checkboxes' ){
422
  //Fix add new leaf
423
  //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188589136/comments
424
- jQuery('div[data-item_name="taxonomyhierarchical-'+taxonomy+'"] li input[type=checkbox]', form).each(function() {
425
- if (this.value==parent || this.value==new_taxonomy) {
426
- div_fields_wrap = jQuery(this).parent();
427
- }
428
  });
429
  //#########################################################################################
430
 
431
  var new_checkbox = '<li><input data-parent="' + parent + '" class="wpt-form-checkbox form-checkbox checkbox" type="checkbox" name="' + taxonomy + '[]" checked="checked" value="' + new_taxonomy + '"></input><label>' + new_taxonomy + '</label></li>';
432
- // find the first checkbox sharing parent
433
  var first_checkbox = jQuery('input[name="' + taxonomy + '\[\]"][data-parent="' + parent + '"]:first', form);
434
  if (first_checkbox.length == 0) {
435
  // there are no existing brothers
436
- // so we need to compose the ul wrapper and append to the parent li
437
- //add_position = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]').closest('li');
438
- level = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]', form).closest('ul').data( 'level' );
439
- level++;
440
  new_checkbox = '<ul class="wpt-form-set-children" data-level="' + level + '">' + new_checkbox + '</ul>';
441
- //first_checkbox = ;
442
  //add_before = false;
443
  //add_position = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]').closest('li');
444
- jQuery(new_checkbox).appendTo( div_fields_wrap );
445
  } else {
446
  // there are brothers
447
- // so we need to insert before all of them
448
- add_position = first_checkbox.closest('li');
449
- jQuery(new_checkbox).insertBefore(add_position);
450
  }
451
  jQuery('[name="new_tax_select_' + taxonomy + '"]', form).show();
452
- } else if( build_what === 'select' ) {
453
  // Select control
454
 
455
  jQuery('select[name="' + taxonomy + '\[\]"]').show();
@@ -533,20 +544,26 @@ toolsetForms.cred_tax = new toolsetForms.CRED_taxonomy();
533
 
534
  //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188725294/comments
535
  //removed return key press
536
- jQuery(function(){
537
- var keyStop = {
538
- 8: ":not(input:text, textarea, input:file, input:password)", // stop backspace = back
539
- 13: "input:text, input:password", // stop enter = submit
540
-
541
- end: null
542
- };
543
- jQuery(document).bind("keydown", function(event){
544
- var selector = keyStop[event.which];
545
-
546
- if(selector !== undefined && jQuery(event.target).is(selector)) {
547
- event.preventDefault(); //stop event
548
- }
549
- return true;
550
- });
 
 
 
 
 
 
551
  });
552
 
8
  wptCallbacks.conditionalCheck = jQuery.Callbacks('unique');
9
  wptCallbacks.reset = jQuery.Callbacks('unique');
10
 
11
+ jQuery(document).ready(function () {
12
  if (typeof wptValidation !== 'undefined') {
13
+ wptCallbacks.validationInit.add(function () {
14
  wptValidation.init();
15
  });
16
  }
22
  /**
23
  * check taxonmies on submitted forms
24
  */
25
+ jQuery('.cred-taxonomy', jQuery('form.is_submitted')).each(function () {
26
  parent = jQuery(this);
27
+ setTimeout(function () {
28
+ jQuery('input.wpt-taxonomy-add-new', parent).click();
29
+ }, 50);
30
  });
31
  });
32
 
44
  if (typeof wptFilters[name] === 'undefined')
45
  return val;
46
  var args = _.rest(_.toArray(arguments));
47
+ _.each(wptFilters[name], function (funcs, priority) {
48
+ _.each(funcs, function ($callback) {
49
  var _args = args.slice(0, $callback[1]);
50
  args[0] = $callback[0].apply(null, _args);
51
  });
59
  if (typeof wptFilters[name] === 'undefined')
60
  return false;
61
  var args = _.rest(_.toArray(arguments));
62
+ _.each(wptFilters[name], function (funcs, priority) {
63
+ _.each(funcs, function ($callback) {
64
  var _args = args.slice(0, $callback[1]);
65
  $callback[0].apply(null, _args);
66
  });
77
  var $taxonomy_box = jQuery('.shmpt-' + taxonomy, form);
78
  var $tag_list = $taxonomy_box.find('.js-wpt-taxonomy-popular-add');
79
 
80
+ if (!$button.hasClass('js-wpt-taxonomy-popular-show-hide'))
81
+ return true;
82
 
83
+ if ($tag_list.length > 0)
84
  {
85
  $button.show();
86
  return true;
87
+ } else {
88
  $button.hide();
89
  return false;
90
  }
91
  }
92
 
93
+ jQuery(document).on('click', '.js-wpt-taxonomy-popular-show-hide', function () {
94
  showHideMostPopularTaxonomy(this);
95
  });
96
 
98
  {
99
  var taxonomy = jQuery(el).data('taxonomy');
100
  var form = jQuery(el).closest('form');
101
+ jQuery('.shmpt-' + taxonomy, form).toggle();
102
  var curr = jQuery(el).val();
103
+ if (curr == jQuery(el).data('show-popular-text')) {
104
  jQuery(el).val(jQuery(el).data('hide-popular-text'), form).addClass('btn-cancel');
105
  } else {
106
  jQuery(el).val(jQuery(el).data('show-popular-text'), form).removeClass('btn-cancel');
107
  }
108
  }
109
 
110
+ jQuery(document).on('click', '.js-wpt-taxonomy-popular-add', function () {
111
  var thiz = jQuery(this);
112
+ var taxonomy = thiz.data('taxonomy');
113
+ var slug = thiz.data('slug');
114
+ var _name = thiz.data('name');
115
  addTaxonomy(_name, taxonomy, this);
116
  return false;
117
  });
119
  function addTaxonomy(slug, taxonomy, el)
120
  {
121
  var form = jQuery(el).closest('form');
122
+ var curr = jQuery('input[name=tmp_' + taxonomy + ']', form).val().trim();
123
+ if ('' == curr) {
124
+ jQuery('input[name=tmp_' + taxonomy + ']', form).val(slug);
125
  setTaxonomy(taxonomy, el);
126
  } else {
127
+ if (curr.indexOf(slug) == -1) {
128
+ jQuery('input[name=tmp_' + taxonomy + ']', form).val(curr + ',' + slug);
129
  setTaxonomy(taxonomy, el);
130
  }
131
  }
132
+ jQuery('input[name=tmp_' + taxonomy + ']', form).val('');
133
  }
134
 
135
+ jQuery(document).on('click', '.js-wpt-taxonomy-add-new', function () {
136
+ var thiz = jQuery(this),
137
+ taxonomy = thiz.data('taxonomy');
138
+ setTaxonomy(taxonomy, this);
139
  });
140
 
141
+ jQuery(document).on('keypress', '.js-wpt-new-taxonomy-title', function (e) {
142
+ if (13 === e.keyCode) {
143
+ e.preventDefault();
144
+ var thiz = jQuery(this),
145
+ taxonomy = thiz.data('taxonomy'),
146
+ taxtype = thiz.data('taxtype');
147
+ if (taxtype == 'hierarchical') {
148
+ toolsetForms.cred_tax.add_taxonomy(taxonomy, this);
149
+ } else {
150
+ setTaxonomy(taxonomy, this);
151
+ }
152
+ }
153
+ });
154
 
155
  function setTaxonomy(taxonomy, el)
156
  {
157
  var form = jQuery(el).closest('form');
158
+ var tmp_tax = jQuery('input[name=tmp_' + taxonomy + ']', form).val();
159
+ if (tmp_tax.trim() == '')
160
+ return;
161
+ var tax = jQuery('input[name=' + taxonomy + ']', form).val();
162
  var arr = tax.split(',');
163
+ if (jQuery.inArray(tmp_tax, arr) !== -1)
164
+ return;
165
+ var toadd = (tax == '') ? tmp_tax : tax + ',' + tmp_tax;
166
+ jQuery('input[name=' + taxonomy + ']', form).val(toadd);
167
+ jQuery('input[name=tmp_' + taxonomy + ']', form).val('');
168
  updateTaxonomies(taxonomy, form);
169
  }
170
 
171
  function updateTaxonomies(taxonomy, form)
172
  {
173
+ var taxonomies = jQuery('input[name=' + taxonomy + ']', form).val();
174
+ jQuery('div.tagchecklist-' + taxonomy, form).html('');
175
+ if (!taxonomies || (taxonomies && taxonomies.trim() == ''))
176
+ return;
177
  var toshow = taxonomies.split(',');
178
  var str = '';
179
+ for (var i = 0; i < toshow.length; i++) {
180
  var sh = toshow[i].trim();
181
+ str += '<span><a href="#" class=\'ntdelbutton\' data-wpcf-i=\'' + i + '\' id=\'post_tag-check-num-' + i + '\'>X</a>&nbsp;' + sh + '</span>';
182
  }
183
+ jQuery('div.tagchecklist-' + taxonomy, form).html(str);
184
+ jQuery('div.tagchecklist-' + taxonomy + ' a', form).bind('click', function () {
185
+ jQuery('input[name=' + taxonomy + ']', form).val('');
186
  del = jQuery(this).data('wpcf-i');
187
  var values = '';
188
+ for (i = 0; i < toshow.length; i++) {
189
+ if (del == i) {
190
  continue;
191
  }
192
+ if (values) {
193
  values += ',';
194
  }
195
  values += toshow[i];
196
  }
197
+ jQuery('input[name=' + taxonomy + ']', form).val(values);
198
  updateTaxonomies(taxonomy, form);
199
 
200
  return false;
204
 
205
  function initTaxonomies(values, taxonomy, url, fieldId)
206
  {
207
+ form = jQuery('#' + fieldId.replace(/_field_\d+$/, '')).closest('form');
208
+ jQuery('div.tagchecklist-' + taxonomy).html(values);
209
+
210
+ jQuery('input[name=' + taxonomy + ']').val(values);
211
  updateTaxonomies(taxonomy, form);
212
+ jQuery('input[name=tmp_' + taxonomy + ']').suggest(
213
+ wptoolset_forms_local.ajaxurl + '?action=wpt_suggest_taxonomy_term&taxonomy=' + taxonomy ,
214
+ {
215
+ resultsClass: 'wpt-suggest-taxonomy-term',
216
+ selectClass: 'wpt-suggest-taxonomy-term-select'
217
+ }
218
+ );
219
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/195723133/comments#308689055
220
+ if (jQuery('input[name=tmp_' + taxonomy + ']').val() != "")
221
+ jQuery("input[name='new_tax_button_" + taxonomy + "']").trigger("click");
 
 
 
222
  }
223
 
224
  toolsetForms.CRED_taxonomy = function () {
240
  }
241
 
242
  self._fill_parent_drop_down = function () {
243
+ jQuery('select.js-taxonomy-parent').each(function () {
244
  var select = jQuery(this);
245
 
246
  // remove all the options
247
+ jQuery(this).find('option').each(function () {
248
  if (jQuery(this).val() != '-1') {
249
  jQuery(this).remove();
250
  }
253
  var taxonomy = jQuery(this).data('taxonomy');
254
 
255
  // Copy all the checkbox values if it's checkbox mode
256
+ jQuery('input[name="' + taxonomy + '\[\]"]').each(function () {
257
  var id = jQuery(this).attr('id');
258
  var label = jQuery(this).next('label');
259
  var level = jQuery(this).closest('ul').data('level');
260
  var prefix = '';
261
+ if (level) {
262
  prefix = "\xA0\xA0" + Array(level).join("\xA0\xA0");
263
  }
264
  select.append('<option value="' + jQuery(this).val() + '">' + prefix + label.text() + '</option>');
265
  })
266
 
267
  // Copy all the select option values if it's select mode
268
+ jQuery('select[name="' + taxonomy + '\[\]"]').find('option').each(function () {
269
  var id = jQuery(this).val();
270
  var text = jQuery(this).text();
271
  select.append('<option value="' + id + '">' + text + '</option>');
280
  // replace the taxonomy button placeholders with the actual buttons.
281
  jQuery('.js-taxonomy-button-placeholder').each(function () {
282
  var placeholder = jQuery(this);
283
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/195150507/comments
284
+ var label = jQuery(this).attr('data-label');
285
+ //###########################################################################################
286
  var taxonomy = jQuery(this).data('taxonomy');
287
  var form = jQuery(this).closest('form');
288
  var buttons = jQuery('[name="sh_' + taxonomy + '"],[name="btn_' + taxonomy + '"]', form);
293
  buttons.each(function () {
294
  var button = jQuery(this, form);
295
 
296
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/195150507/comments
297
+ if (label)
298
+ button.val(label);
299
+ //##########################################################################################
300
+
301
  placeholder.replaceWith(button);
302
 
303
  if (button.hasClass('js-wpt-taxonomy-popular-show-hide')) {
304
+ if (showHideMostPopularButton(taxonomy, form)) {
305
  button.show();
306
  }
307
  } else {
312
  //Responsible of the issue https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188673095/comments
313
  //changed selector
314
  //var selector = button.data('after-selector');
315
+ selectors.push(button.data('after-selector'))
316
  if (typeof selector !== 'undefined' && selector.length) {
317
  var position = button;
318
+ jQuery('.' + selectors[0]).detach();
319
+ jQuery('.' + selectors[0]).insertAfter(button);
320
+ position = jQuery('.' + selectors[0]);
321
+ selectors.pop();
322
  }
323
  })
324
  }
325
  });
326
  }
327
 
328
+ jQuery(document).on('click', '.js-wpt-hierarchical-taxonomy-add-new-show-hide', function () {
329
+ if (jQuery(this).val() == jQuery(this).data('close')) {
330
  jQuery(this).val(jQuery(this).data('open')).removeClass('btn-cancel');
331
  } else {
332
  jQuery(this).val(jQuery(this).data('close')).addClass('btn-cancel');
333
  }
334
+ var thiz = jQuery(this), taxonomy = thiz.data('taxonomy');
335
+ self.add_new_show_hide(taxonomy, this);
336
  });
337
 
338
+ self.add_new_show_hide = function (taxonomy, button) {
339
  var form = jQuery(button).closest('form');
340
  jQuery('.js-wpt-hierarchical-taxonomy-add-new-' + taxonomy, form).toggle();
341
+ self.hide_parent_button_if_no_terms(taxonomy, button);
342
  }
343
 
344
+ jQuery(document).on('click', '.js-wpt-hierarchical-taxonomy-add-new', function () {
345
+ var thiz = jQuery(this),
346
+ taxonomy = thiz.data('taxonomy');
347
+ self.add_taxonomy(taxonomy, this);
348
  });
349
  /*
350
+ jQuery(document).on('keypress', '.js-wpt-new-taxonomy-title', function(e) {
351
+ if( 13 === e.keyCode ) {
352
+ e.preventDefault();
353
+ var thiz = jQuery(this),
354
+ taxonomy = thiz.data( 'taxonomy' );
355
+ self.add_taxonomy( taxonomy, this );
356
+ }
357
+ });
358
+ */
359
 
360
+ self.terms_exist = function (taxonomy, button)
361
  {
362
  var form = jQuery(button).closest('form');
363
  var build_what = jQuery(button).data('build_what'), parent = jQuery('[name="new_tax_select_' + taxonomy + '"]', form).val();
364
+ if (build_what === 'checkboxes') {
365
  var first_checkbox = jQuery('input[name="' + taxonomy + '\[\]"][data-parent="' + parent + '"]:first', form);
366
  return first_checkbox.length > 0;
367
  } else {
373
  };
374
 
375
  self._add_new_flag = [];
376
+ self.hide_parent_button_if_no_terms = function (taxonomy, button)
377
  {
378
  var form = jQuery(button).closest('form');
379
  var form_id = form.attr('id');
380
+ if ('undefined' == typeof self._add_new_flag[form_id]) {
381
  self._add_new_flag[form_id] = '';
382
  }
383
  self._add_new_flag[form_id] = !self._add_new_flag[form_id];
384
+ if (self._add_new_flag[form_id] === false) {
385
  jQuery('[name="new_tax_select_' + taxonomy + '"]', form).hide();
386
  } else {
387
  jQuery('[name="new_tax_select_' + taxonomy + '"]', form).show();
388
  }
389
  };
390
 
391
+ self.add_taxonomy = function (taxonomy, button)
392
  {
393
  var form = jQuery(button).closest('form');
394
  var new_taxonomy = jQuery('[name="new_tax_text_' + taxonomy + '"]', form).val();
401
 
402
  // make sure we don't already have a taxonomy with the same name.
403
  var exists = false;
404
+ jQuery('input[name="' + taxonomy + '\[\]"]').each(function () {
405
  var id = jQuery(this).attr('id');
406
  var label = jQuery('label[for="' + id + '"]', form);
407
 
411
  }
412
  });
413
 
414
+ jQuery('select[name="' + taxonomy + '\[\]"]', form).find('option').each(function () {
415
  if (new_taxonomy == jQuery(this).text()) {
416
  exists = true;
417
  self._flash_it(jQuery(this));
424
  }
425
 
426
  var parent = jQuery('[name="new_tax_select_' + taxonomy + '"]', form).val(),
427
+ add_position = null,
428
+ add_before = true,
429
+ div_fields_wrap = jQuery('div[data-item_name="taxonomyhierarchical-' + taxonomy + '"]', form),
430
+ level = 0;
431
 
432
+ if (build_what === 'checkboxes') {
433
  //Fix add new leaf
434
  //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188589136/comments
435
+ jQuery('div[data-item_name="taxonomyhierarchical-' + taxonomy + '"] li input[type=checkbox]', form).each(function () {
436
+ if (this.value == parent || this.value == new_taxonomy) {
437
+ div_fields_wrap = jQuery(this).parent();
438
+ }
439
  });
440
  //#########################################################################################
441
 
442
  var new_checkbox = '<li><input data-parent="' + parent + '" class="wpt-form-checkbox form-checkbox checkbox" type="checkbox" name="' + taxonomy + '[]" checked="checked" value="' + new_taxonomy + '"></input><label>' + new_taxonomy + '</label></li>';
443
+ // find the first checkbox sharing parent
444
  var first_checkbox = jQuery('input[name="' + taxonomy + '\[\]"][data-parent="' + parent + '"]:first', form);
445
  if (first_checkbox.length == 0) {
446
  // there are no existing brothers
447
+ // so we need to compose the ul wrapper and append to the parent li
448
+ //add_position = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]').closest('li');
449
+ level = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]', form).closest('ul').data('level');
450
+ level++;
451
  new_checkbox = '<ul class="wpt-form-set-children" data-level="' + level + '">' + new_checkbox + '</ul>';
452
+ //first_checkbox = ;
453
  //add_before = false;
454
  //add_position = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]').closest('li');
455
+ jQuery(new_checkbox).appendTo(div_fields_wrap);
456
  } else {
457
  // there are brothers
458
+ // so we need to insert before all of them
459
+ add_position = first_checkbox.closest('li');
460
+ jQuery(new_checkbox).insertBefore(add_position);
461
  }
462
  jQuery('[name="new_tax_select_' + taxonomy + '"]', form).show();
463
+ } else if (build_what === 'select') {
464
  // Select control
465
 
466
  jQuery('select[name="' + taxonomy + '\[\]"]').show();
544
 
545
  //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188725294/comments
546
  //removed return key press
547
+ jQuery(function () {
548
+ var keyStop = {
549
+ 8: ":not(input:text, textarea, input:file, input:password)", // stop backspace = back
550
+ 13: "input:text, input:password", // stop enter = submit
551
+
552
+ end: null
553
+ };
554
+ jQuery(document).bind("keydown", function (event) {
555
+ var thiz_selector = keyStop[event.which],
556
+ thiz_target = jQuery(event.target);
557
+
558
+ if (
559
+ thiz_target.closest( "form.cred-form" ).length
560
+ && thiz_selector !== undefined
561
+ && thiz_target.is(thiz_selector)
562
+ ) {
563
+ event.preventDefault(); //stop event
564
+ }
565
+
566
+ return true;
567
+ });
568
  });
569
 
embedded/common/toolset-forms/js/repetitive.js CHANGED
@@ -1,7 +1,7 @@
1
  /*
2
  * Repetitive JS.
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/js/repetitive.js $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
1
  /*
2
  * Repetitive JS.
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/js/repetitive.js $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/js/skype.js CHANGED
@@ -11,7 +11,7 @@ var wptSkype = (function($) {
11
  $('.js-wpt-skypename-popup', $popup).val($skypename.val());
12
  $('[name="wpt-skypestyle-popup"][value="' + $style.val() + '"]', $popup)
13
  .attr('checked', true);
14
- tb_show(wptSkypeData.title, "#TB_inline?inlineId=tpl-wpt-skype-edit-button", "");
15
  });
16
  $('#wpt-skype-edit-button-popup').on('click', '.js-wpt-close-thickbox', function() {
17
  $skypename.val($('.js-wpt-skypename-popup', $popup).val());
@@ -26,4 +26,4 @@ var wptSkype = (function($) {
26
  };
27
  })(jQuery);
28
 
29
- jQuery(document).ready(wptSkype.init);
11
  $('.js-wpt-skypename-popup', $popup).val($skypename.val());
12
  $('[name="wpt-skypestyle-popup"][value="' + $style.val() + '"]', $popup)
13
  .attr('checked', true);
14
+ tb_show(wptSkypeData.title, "#TB_inline?inlineId=tpl-wpt-skype-edit-button&height=500&width=600", "");
15
  });
16
  $('#wpt-skype-edit-button-popup').on('click', '.js-wpt-close-thickbox', function() {
17
  $skypename.val($('.js-wpt-skypename-popup', $popup).val());
26
  };
27
  })(jQuery);
28
 
29
+ jQuery(document).ready(wptSkype.init);
embedded/common/toolset-forms/js/validation.js CHANGED
@@ -7,9 +7,9 @@
7
  *
8
  * @see class WPToolset_Validation
9
  *
10
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/js/validation.js $
11
- * $LastChangedDate: 2015-01-28 06:42:34 +0000 (Wed, 28 Jan 2015) $
12
- * $LastChangedRevision: 1077234 $
13
  * $LastChangedBy: iworks $
14
  *
15
  */
@@ -17,33 +17,40 @@
17
 
18
  var wptValidationForms = [];
19
  var wptValidation = (function($) {
20
- function init() {
21
  /**
22
  * add extension to validator method
23
  */
24
  $.validator.addMethod("extension", function(value, element, param) {
25
  param = typeof param === "string" ? param.replace(/,/g, "|") : param;
26
  return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
27
- });
28
-
29
  /**
30
  * add hexadecimal to validator method
31
  */
32
- $.validator.addMethod("hexadecimal", function(value, element, param) {
33
- return value=="" || /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(value);
34
  });
35
-
 
 
 
 
 
 
 
36
  /**
37
  * add extension to validator method require
38
  */
39
- $.validator.addMethod("required", function(value, element, param) {
40
  // check if dependency is met
41
  if ( !this.depend(param, element) )
42
  return "dependency-mismatch";
43
-
44
  switch( element.nodeName.toLowerCase() ) {
45
- case 'select':
46
- var val = $(element).val();
47
  //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/189231348/comments
48
  // we have data-types-value that in select contains the exactly value
49
  $(element).find('option').each(function(index, option){
@@ -55,11 +62,11 @@ var wptValidation = (function($) {
55
  });
56
  //#########################################################################
57
  return val && $.trim(val).length > 0;
58
- case 'input':
59
  // if (jQuery(element).hasClass("hasDatepicker")) {
60
  // element = jQuery(element).siblings( 'input[type="hidden"]' );
61
  // value = element.val();
62
- // element = element[0];
63
  // console.log(value+" -> "+this.getLength(value, element));
64
  // return this.getLength(value, element) > 0;
65
  // }
@@ -74,7 +81,7 @@ var wptValidation = (function($) {
74
  return $.trim(value).length > 0;
75
  }
76
  });
77
-
78
  /**
79
  * Add validation method for datepicker adodb_xxx format for date fields
80
  */
@@ -164,7 +171,7 @@ var wptValidation = (function($) {
164
  var _rule = {messages: {}};
165
  _rule[rule] = value.args;
166
  if (value.message !== 'undefined') {
167
- _rule.messages[rule] = value.message;
168
  }
169
  element.rules('add', _rule);
170
  element.addClass('js-wpt-validate');
7
  *
8
  * @see class WPToolset_Validation
9
  *
10
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/js/validation.js $
11
+ * $LastChangedDate: 2015-04-01 14:15:17 +0000 (Wed, 01 Apr 2015) $
12
+ * $LastChangedRevision: 1125405 $
13
  * $LastChangedBy: iworks $
14
  *
15
  */
17
 
18
  var wptValidationForms = [];
19
  var wptValidation = (function($) {
20
+ function init() {
21
  /**
22
  * add extension to validator method
23
  */
24
  $.validator.addMethod("extension", function(value, element, param) {
25
  param = typeof param === "string" ? param.replace(/,/g, "|") : param;
26
  return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
27
+ });
28
+
29
  /**
30
  * add hexadecimal to validator method
31
  */
32
+ $.validator.addMethod("hexadecimal", function(value, element, param) {
33
+ return value=="" || /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(value);
34
  });
35
+
36
+ /**
37
+ * add skype to validator method
38
+ */
39
+ $.validator.addMethod("skype", function(value, element, param) {
40
+ return value=="" || /^([a-z0-9\.\_\,\-\#]+)$/i.test(value);
41
+ });
42
+
43
  /**
44
  * add extension to validator method require
45
  */
46
+ $.validator.addMethod("required", function(value, element, param) {
47
  // check if dependency is met
48
  if ( !this.depend(param, element) )
49
  return "dependency-mismatch";
50
+
51
  switch( element.nodeName.toLowerCase() ) {
52
+ case 'select':
53
+ var val = $(element).val();
54
  //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/189231348/comments
55
  // we have data-types-value that in select contains the exactly value
56
  $(element).find('option').each(function(index, option){
62
  });
63
  //#########################################################################
64
  return val && $.trim(val).length > 0;
65
+ case 'input':
66
  // if (jQuery(element).hasClass("hasDatepicker")) {
67
  // element = jQuery(element).siblings( 'input[type="hidden"]' );
68
  // value = element.val();
69
+ // element = element[0];
70
  // console.log(value+" -> "+this.getLength(value, element));
71
  // return this.getLength(value, element) > 0;
72
  // }
81
  return $.trim(value).length > 0;
82
  }
83
  });
84
+
85
  /**
86
  * Add validation method for datepicker adodb_xxx format for date fields
87
  */
171
  var _rule = {messages: {}};
172
  _rule[rule] = value.args;
173
  if (value.message !== 'undefined') {
174
+ _rule.messages[rule] = value.message;
175
  }
176
  element.rules('add', _rule);
177
  element.addClass('js-wpt-validate');
embedded/common/toolset-forms/lib/CakePHP-Validation.php CHANGED
@@ -55,7 +55,7 @@ class WPToolset_Cake_Validation {
55
  * @access private
56
  */
57
  var $__pattern = array(
58
- 'hostname' => '(?:[a-z0-9][-a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)'
59
  );
60
 
61
  /**
@@ -950,13 +950,12 @@ class WPToolset_Cake_Validation {
950
  $_this = &WPToolset_Cake_Validation::getInstance();
951
  $_this->__populateIp();
952
  $_this->check = $check;
953
- $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))';
954
- $_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
955
- '(?:' . $_this->__pattern['IPv4'] . '|\[' . $_this->__pattern['IPv6'] . '\]|' . $_this->__pattern['hostname'] . ')' .
956
- '(?::[1-9][0-9]{0,4})?' .
957
- '(?:\/?|\/' . $validChars . '*)?' .
958
- '(?:\?' . $validChars . '*)?' .
959
- '(?:#' . $validChars . '*)?$/iu';
960
  return $_this->_check();
961
  }
962
 
55
  * @access private
56
  */
57
  var $__pattern = array(
58
+ 'hostname' => '(?:[_\p{L}0-9][-_\p{L}0-9]*\.)*(?:[\p{L}0-9][-\p{L}0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,})'
59
  );
60
 
61
  /**
950
  $_this = &WPToolset_Cake_Validation::getInstance();
951
  $_this->__populateIp();
952
  $_this->check = $check;
953
+ $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9\p{L}\p{N}]|(%[0-9a-f]{2}))';
954
+ $_this->regex = '/^(?:(?:https?|ftps?|sftp|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
955
+ '(?:' . $_this->__pattern['IPv4'] . '|\[' . $_this->__pattern['IPv6'] . '\]|' . $_this->__pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' .
956
+ '(?:\/?|\/' . $validChars . '*)?' .
957
+ '(?:\?' . $validChars . '*)?' .
958
+ '(?:#' . $validChars . '*)?$/iu';
 
959
  return $_this->_check();
960
  }
961
 
embedded/common/toolset-forms/readme.txt CHANGED
@@ -30,6 +30,17 @@ function my_toolset_valid_image_extentions($valid_extensions)
30
 
31
  = Changelog =
32
 
 
 
 
 
 
 
 
 
 
 
 
33
  2014-12-29
34
 
35
  - fixed display CPT in CT
30
 
31
  = Changelog =
32
 
33
+ 2015-03-25
34
+
35
+ - Fixed missing warning for date type field.
36
+ https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196695908/comments
37
+
38
+ 2015-02-06
39
+
40
+ - Fixed empty object in WPV_Handle_Users_Functions class when user is
41
+ not logged always return false.
42
+ https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/194981023/comments
43
+
44
  2014-12-29
45
 
46
  - fixed display CPT in CT
embedded/common/toolset-forms/templates/metaform-item.php CHANGED
@@ -1,39 +1,40 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/templates/metaform-item.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
10
- if ( is_admin() ) {
11
- ?>
12
- <div class="js-wpt-field-item wpt-field-item">
13
- <?php echo $out; ?>
14
- <?php if ( @$cfg['repetitive'] ): ?>
15
- <div class="wpt-repctl">
16
- <div class="js-wpt-repdrag wpt-repdrag">&nbsp;</div>
17
- <a class="js-wpt-repdelete button button-small" data-wpt-type="<?php echo $cfg['type']; ?>" data-wpt-id="<?php echo $cfg['id']; ?>"><?php apply_filters( 'toolset_button_delete_repetition_text', printf(__('Delete %s', 'wpv-views'), strtolower( $cfg['title'])), $cfg); ?></a>
18
- </div>
19
- <?php endif; ?>
20
- </div>
21
- <?php
22
  } else {
23
  $toolset_repdrag_image = '';
24
- $button_extra_classnames = '';
25
- if ( $cfg['repetitive'] ) {
26
- $toolset_repdrag_image = apply_filters( 'wptoolset_filter_wptoolset_repdrag_image', $toolset_repdrag_image );
27
  echo '<div class="wpt-repctl">';
28
- echo '<span class="js-wpt-repdrag wpt-repdrag"><img class="wpv-repdrag-image" src="' . $toolset_repdrag_image . '" /></span>';
29
  }
30
  echo $out;
31
- if ( $cfg['repetitive'] ) {
32
- if ( array_key_exists( 'use_bootstrap', $cfg ) && $cfg['use_bootstrap'] ) {
33
- $button_extra_classnames = ' btn btn-default btn-sm';
34
- }
35
- echo '<input type="button" href="#" class="js-wpt-repdelete wpt-repdelete' . $button_extra_classnames . '" value="';
36
- echo apply_filters( 'toolset_button_delete_repetition_text', esc_attr( sprintf( __( 'Delete %s repetition', 'wpv-views' ), $cfg['title'] ) ), $cfg );
 
37
  echo '" />';
38
  echo '</div>';
39
  }
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/templates/metaform-item.php $
5
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
6
+ * $LastChangedRevision: 1120400 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
10
+ if (is_admin()) {
11
+ ?>
12
+ <div class="js-wpt-field-item wpt-field-item">
13
+ <?php echo $out; ?>
14
+ <?php if (@$cfg['repetitive']): ?>
15
+ <div class="wpt-repctl">
16
+ <div class="js-wpt-repdrag wpt-repdrag">&nbsp;</div>
17
+ <a class="js-wpt-repdelete button button-small" data-wpt-type="<?php echo $cfg['type']; ?>" data-wpt-id="<?php echo $cfg['id']; ?>"><?php apply_filters('toolset_button_delete_repetition_text', printf(__('Delete %s', 'wpv-views'), strtolower($cfg['title'])), $cfg); ?></a>
18
+ </div>
19
+ <?php endif; ?>
20
+ </div>
21
+ <?php
22
  } else {
23
  $toolset_repdrag_image = '';
24
+ $button_extra_classnames = '';
25
+ if ($cfg['repetitive']) {
26
+ $toolset_repdrag_image = apply_filters('wptoolset_filter_wptoolset_repdrag_image', $toolset_repdrag_image);
27
  echo '<div class="wpt-repctl">';
28
+ echo '<span class="js-wpt-repdrag wpt-repdrag"><img class="wpv-repdrag-image" src="' . $toolset_repdrag_image . '" /></span>';
29
  }
30
  echo $out;
31
+ if ($cfg['repetitive']) {
32
+ if (array_key_exists('use_bootstrap', $cfg) && $cfg['use_bootstrap']) {
33
+ $button_extra_classnames = ' btn btn-default btn-sm';
34
+ }
35
+ $str = sprintf('%s repetition', $cfg['title']);
36
+ echo '<input type="button" href="#" class="js-wpt-repdelete wpt-repdelete' . $button_extra_classnames . '" value="';
37
+ echo apply_filters('toolset_button_delete_repetition_text', esc_attr(__('Delete', 'wpv-views')) . " " . esc_attr($str), $cfg);
38
  echo '" />';
39
  echo '</div>';
40
  }
embedded/common/toolset-forms/templates/metaform.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/common/toolset-forms/templates/metaform.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/common/toolset-forms/templates/metaform.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
embedded/common/toolset-forms/test.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
- add_action( 'admin_init', '_wptoolset_forms_test_fields' );
3
- add_action( 'admin_init', '_wptoolset_forms_test_form' );
4
- add_action( 'edit_form_after_editor', '_wptoolset_forms_test_fields_render' );
5
- add_action( 'admin_footer', '_wptoolset_forms_test_form_render' );
6
-
7
- function _wptoolset_forms_test_fields() {
8
- global $_html_test;
9
- $fields = types_get_fields(); //debug($fields);
10
- foreach ( $fields as $field ) {
11
- $config = wptoolset_forms_types_filter_field( $field, 'testme' );
12
- $_html_test .= wptoolset_form_field( 'post', $config );
13
- }
14
- }
15
-
16
- function _wptoolset_forms_test_form() {
17
- global $_html_test_2;
18
- $form = wptoolset_form( 'types-form' );
19
- $fields = types_get_fields(); //debug($fields);
20
- foreach ( $fields as $field ) {
21
- $config = wptoolset_forms_types_filter_field( $field, 'testme' );
22
- $form->addField( $config );
23
- }
24
- $form->addSubmit();
25
- $_html_test_2 = $form->createForm( 'types-form' );
26
- }
27
-
28
- function _wptoolset_forms_test_fields_render() {
29
- global $_html_test; //debug($_html_test);
30
- echo '<h2>'.__('Test group of elements', 'wpv-views').'</h2>' . $_html_test;
31
- }
32
-
33
- function _wptoolset_forms_test_form_render() {
34
- global $_html_test_2;
35
- echo '<h2>'.__('Test form', 'wpv-views').'</h2>' . $_html_test_2;
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
embedded/common/utility/css/notifications.css CHANGED
@@ -81,16 +81,10 @@ span.toolset-alert {
81
 
82
  /* Explanation messages */
83
  .toolset-help {
84
- min-height: 140px;
85
- border-color: #d2e9e7;
86
- background: #f6fafa;
87
- background: -moz-linear-gradient(top, #f6fafa 0%, #eff6f6 100%);
88
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f6fafa), color-stop(100%,#eff6f6));
89
- background: -webkit-linear-gradient(top, #f6fafa 0%,#eff6f6 100%);
90
- background: -o-linear-gradient(top, #f6fafa 0%,#eff6f6 100%);
91
- background: -ms-linear-gradient(top, #f6fafa 0%,#eff6f6 100%);
92
- background: linear-gradient(to bottom, #f6fafa 0%,#eff6f6 100%);
93
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6fafa', endColorstr='#eff6f6',GradientType=0 );
94
  }
95
 
96
  .js-show-toolset-message {
@@ -98,9 +92,12 @@ span.toolset-alert {
98
  }
99
 
100
  .toolset-help-content {
101
- padding: 15px 160px 15px 15px;
102
- min-height: 105px;
 
 
103
  color: #4f4f4f;
 
104
  }
105
 
106
  .toolset-help-content a {
@@ -129,49 +126,46 @@ span.toolset-alert {
129
  }
130
  .toolset-help-content .btn {
131
  margin: 0 10px 0 0;
132
- padding: 0 10px;
133
  border: 0;
134
- border-radius: 15px;
135
  background: #11a99b;
136
  color: #fff;
137
  text-decoration: none;
138
  text-shadow: none;
139
  font-weight: bold;
140
  }
 
 
 
 
141
 
142
  .toolset-help-content .toolset-help-content-toolbar {
143
- margin: 20px 0 0 0;
144
  }
145
 
146
  .toolset-help-sidebar {
147
  position: absolute;
148
- top: 0;
149
- right: 0;
150
- bottom: 0;
151
- width: 145px;
152
- border-left: 1px solid #d2e9e7;
153
- background: -moz-linear-gradient(top, #e5f4f3 0%, #dff1f0 100%);
154
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e5f4f3), color-stop(100%,#dff1f0));
155
- background: -webkit-linear-gradient(top, #e5f4f3 0%,#dff1f0 100%);
156
- background: -o-linear-gradient(top, #e5f4f3 0%,#dff1f0 100%);
157
- background: -ms-linear-gradient(top, #e5f4f3 0%,#dff1f0 100%);
158
- background: linear-gradient(to bottom, #e5f4f3 0%,#dff1f0 100%);
159
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5f4f3', endColorstr='#dff1f0',GradientType=0 );
160
  }
161
  .toolset-help-sidebar-ico {
162
- margin: 20px auto 0 auto;
163
- width: 93px;
164
- height: 83px;
165
- background: url('../img/icon-help-message.png') center center no-repeat;
166
- vertical-align: middle;
167
  }
168
 
169
  .toolset-help-footer {
170
  position: relative;
171
  z-index: 1;
172
  padding: 5px;
173
- border-top: 1px solid #d2e9e7;
174
- background: #dff1f0;
175
  text-align: right;
176
  }
177
 
@@ -180,20 +174,24 @@ span.toolset-alert {
180
  }
181
 
182
 
183
- .toolset-help .icon-remove-sign {
 
184
  position: absolute;
185
- top: -10px;
186
- right: -8px;
187
- /*color: #333;
188
- font-size: 22px;*/
189
- color: #d54e21;
 
 
190
  font-size: 16px;
191
- opacity: .6;
192
  cursor: pointer;
193
  }
194
 
195
- .toolset-help .icon-remove-sign:hover {
196
- opacity: 1;
 
 
197
  }
198
 
199
  .toolset-help code {
81
 
82
  /* Explanation messages */
83
  .toolset-help {
84
+ display: table;
85
+ width: 100%;
86
+ background: #fff;
87
+ border: none;
 
 
 
 
 
 
88
  }
89
 
90
  .js-show-toolset-message {
92
  }
93
 
94
  .toolset-help-content {
95
+ display: table-cell;
96
+ vertical-align: middle;
97
+ padding: 25px 25px 15px 180px;
98
+ height: 135px;
99
  color: #4f4f4f;
100
+ border: solid 1px #cdcdcd;
101
  }
102
 
103
  .toolset-help-content a {
126
  }
127
  .toolset-help-content .btn {
128
  margin: 0 10px 0 0;
129
+ padding: 4px 10px;
130
  border: 0;
131
+ border-radius: 4px;
132
  background: #11a99b;
133
  color: #fff;
134
  text-decoration: none;
135
  text-shadow: none;
136
  font-weight: bold;
137
  }
138
+
139
+ .toolset-help-content .btn:hover {
140
+ background: #008C7D;
141
+ }
142
 
143
  .toolset-help-content .toolset-help-content-toolbar {
144
+ margin: 20px 0 10px 0;
145
  }
146
 
147
  .toolset-help-sidebar {
148
  position: absolute;
149
+ top: 1px;
150
+ left: 1px;
151
+ bottom: 1px;
152
+ width: 144px;
153
+ display: table-cell;
154
+ text-align: center;
155
+ vertical-align: middle;
156
+ background: url('../img/icon-help-message.png') center center no-repeat #333;
157
+ box-shadow: inset 0 0 15px #111;
 
 
 
158
  }
159
  .toolset-help-sidebar-ico {
160
+
 
 
 
 
161
  }
162
 
163
  .toolset-help-footer {
164
  position: relative;
165
  z-index: 1;
166
  padding: 5px;
167
+ border-top: 1px solid #cdcdcd;
168
+ background: #fff;
169
  text-align: right;
170
  }
171
 
174
  }
175
 
176
 
177
+ .toolset-help .icon-remove-sign,
178
+ .toolset-help .icon-remove {
179
  position: absolute;
180
+ top: 0;
181
+ right: 0;
182
+ color: #999;
183
+ opacity: 1;
184
+ background: #fff;
185
+ border: solid 1px #cdcdcd;
186
+ padding: 2px 4px;
187
  font-size: 16px;
 
188
  cursor: pointer;
189
  }
190
 
191
+ .toolset-help .icon-remove-sign:hover,
192
+ .toolset-help .icon-remove:hover {
193
+ background: #b94a48;
194
+ color: #fff;
195
  }
196
 
197
  .toolset-help code {
embedded/common/utility/css/select2/select2.css CHANGED
@@ -1,5 +1,5 @@
1
  /*
2
- Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
3
  */
4
  .select2-container {
5
  margin: 0;
@@ -18,7 +18,6 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
18
  /*
19
  Force border-box so that % widths fit the parent
20
  container without overlap because of margin/padding.
21
-
22
  More Info : http://www.quirksmode.org/css/box.html
23
  */
24
  -webkit-box-sizing: border-box; /* webkit */
@@ -33,12 +32,14 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
33
  overflow: hidden;
34
  position: relative;
35
 
36
- border: 1px solid #ddd;
37
  white-space: nowrap;
38
  line-height: 26px;
39
- color: #474747;
40
  text-decoration: none;
41
 
 
 
42
  background-clip: padding-box;
43
 
44
  -webkit-touch-callout: none;
@@ -47,23 +48,28 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
47
  -ms-user-select: none;
48
  user-select: none;
49
 
50
- /* background-color: #fff;
51
  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff));
52
  background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
53
  background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
54
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
55
- background-image: linear-gradient(top, #fff 0%, #eee 50%);*/
 
 
 
 
56
  }
57
 
58
  .select2-container.select2-drop-above .select2-choice {
59
- border-bottom-color: #ddd;
60
- /*border-radius: 0 0 4px 4px;*/
 
61
 
62
- /* background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff));
63
  background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
64
  background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
65
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
66
- background-image: linear-gradient(top, #eee 0%, #fff 90%);*/
67
  }
68
 
69
  .select2-container.select2-allowclear .select2-choice .select2-chosen {
@@ -76,7 +82,15 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
76
  overflow: hidden;
77
 
78
  white-space: nowrap;
 
79
  text-overflow: ellipsis;
 
 
 
 
 
 
 
80
  }
81
 
82
  .select2-container .select2-choice abbr {
@@ -141,15 +155,6 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
141
  box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
142
  }
143
 
144
- .select2-drop-auto-width {
145
- border-top: 1px solid #aaa;
146
- width: auto;
147
- }
148
-
149
- .select2-drop-auto-width .select2-search {
150
- padding-top: 4px;
151
- }
152
-
153
  .select2-drop.select2-drop-above {
154
  margin-top: 1px;
155
  border-top: 1px solid #aaa;
@@ -162,12 +167,21 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
162
  }
163
 
164
  .select2-drop-active {
165
- border: 1px solid #999;
166
  border-top: none;
167
  }
168
 
169
  .select2-drop.select2-drop-above.select2-drop-active {
170
- border-top: 1px solid #999;
 
 
 
 
 
 
 
 
 
171
  }
172
 
173
  .select2-container .select2-choice .select2-arrow {
@@ -178,8 +192,8 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
178
  right: 0;
179
  top: 0;
180
 
181
- border-left: 1px solid #ddd;
182
- /*border-radius: 0 4px 4px 0;*/
183
 
184
  background-clip: padding-box;
185
 
@@ -188,7 +202,16 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
188
  background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
189
  background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
190
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
191
- background-image: linear-gradient(top, #ccc 0%, #eee 60%);
 
 
 
 
 
 
 
 
 
192
  }
193
 
194
  .select2-container .select2-choice .select2-arrow b {
@@ -198,6 +221,10 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
198
  background: url('select2.png') no-repeat 0 1px;
199
  }
200
 
 
 
 
 
201
  .select2-search {
202
  display: inline-block;
203
  width: 100%;
@@ -233,7 +260,17 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
233
  background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
234
  background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
235
  background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
236
- background: url('select2.png') no-repeat 100% -22px, linear-gradient(top, #fff 85%, #eee 99%);
 
 
 
 
 
 
 
 
 
 
237
  }
238
 
239
  .select2-drop.select2-drop-above .select2-search input {
@@ -245,12 +282,12 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
245
  background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
246
  background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
247
  background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
248
- background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(top, #fff 85%, #eee 99%);
249
  }
250
 
251
  .select2-container-active .select2-choice,
252
  .select2-container-active .select2-choices {
253
- border: 1px solid #999;
254
  outline: none;
255
 
256
  -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
@@ -265,24 +302,24 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
265
  border-bottom-left-radius: 0;
266
  border-bottom-right-radius: 0;
267
 
268
- background-color: #fff;
269
- /* background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee));
270
  background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
271
  background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
272
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
273
- background-image: linear-gradient(top, #fff 0%, #eee 50%);*/
274
  }
275
 
276
  .select2-dropdown-open.select2-drop-above .select2-choice,
277
  .select2-dropdown-open.select2-drop-above .select2-choices {
278
- border: 1px solid #999;
279
  border-top-color: transparent;
280
 
281
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee));
282
  background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
283
  background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
284
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
285
- background-image: linear-gradient(bottom, #fff 0%, #eee 50%);
286
  }
287
 
288
  .select2-dropdown-open .select2-choice .select2-arrow {
@@ -290,10 +327,29 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
290
  border-left: none;
291
  filter: none;
292
  }
 
 
 
 
293
  .select2-dropdown-open .select2-choice .select2-arrow b {
294
  background-position: -18px 1px;
295
  }
296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  /* results */
298
  .select2-results {
299
  max-height: 200px;
@@ -305,19 +361,16 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
305
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
306
  }
307
 
 
 
 
 
 
308
  .select2-results ul.select2-result-sub {
309
  margin: 0;
310
  padding-left: 0;
311
  }
312
 
313
- .select2-results ul.select2-result-sub > li .select2-result-label { padding-left: 20px }
314
- .select2-results ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 40px }
315
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 60px }
316
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 80px }
317
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 100px }
318
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 110px }
319
- .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 120px }
320
-
321
  .select2-results li {
322
  list-style: none;
323
  display: list-item;
@@ -342,6 +395,14 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
342
  user-select: none;
343
  }
344
 
 
 
 
 
 
 
 
 
345
  .select2-results .select2-highlighted {
346
  background: #3875d7;
347
  color: #fff;
@@ -361,12 +422,13 @@ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
361
  color: #000;
362
  }
363
 
364
-
365
  .select2-results .select2-no-results,
366
  .select2-results .select2-searching,
 
367
  .select2-results .select2-selection-limit {
368
  background: #f4f4f4;
369
  display: list-item;
 
370
  }
371
 
372
  /*
@@ -392,6 +454,10 @@ disabled look for disabled choices in the results dropdown
392
  background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%;
393
  }
394
 
 
 
 
 
395
  .select2-more-results {
396
  background: #f4f4f4;
397
  display: list-item;
@@ -423,7 +489,7 @@ disabled look for disabled choices in the results dropdown
423
  height: auto !important;
424
  height: 1%;
425
  margin: 0;
426
- padding: 0;
427
  position: relative;
428
 
429
  border: 1px solid #aaa;
@@ -434,7 +500,11 @@ disabled look for disabled choices in the results dropdown
434
  background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
435
  background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
436
  background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
437
- background-image: linear-gradient(top, #eee 1%, #fff 15%);
 
 
 
 
438
  }
439
 
440
  .select2-locked {
@@ -446,7 +516,7 @@ disabled look for disabled choices in the results dropdown
446
  }
447
 
448
  .select2-container-multi.select2-container-active .select2-choices {
449
- border: 1px solid #999;
450
  outline: none;
451
 
452
  -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
@@ -456,6 +526,10 @@ disabled look for disabled choices in the results dropdown
456
  float: left;
457
  list-style: none;
458
  }
 
 
 
 
459
  .select2-container-multi .select2-choices .select2-search-field {
460
  margin: 0;
461
  padding: 0;
@@ -512,7 +586,12 @@ disabled look for disabled choices in the results dropdown
512
  background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
513
  background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
514
  background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
515
- background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
 
 
 
 
 
516
  }
517
  .select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
518
  cursor: default;
@@ -533,11 +612,20 @@ disabled look for disabled choices in the results dropdown
533
  outline: none;
534
  background: url('select2.png') right top no-repeat;
535
  }
 
 
 
 
536
 
537
  .select2-container-multi .select2-search-choice-close {
538
  left: 3px;
539
  }
540
 
 
 
 
 
 
541
  .select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
542
  background-position: right -11px;
543
  }
@@ -597,15 +685,20 @@ disabled look for disabled choices in the results dropdown
597
  height: 100px;
598
  overflow: scroll;
599
  }
 
600
  /* Retina-ize icons */
601
 
602
- @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) {
603
- .select2-search input, .select2-search-choice-close, .select2-container .select2-choice abbr, .select2-container .select2-choice .select2-arrow b {
604
- background-image: url('select2x2.png') !important;
605
- background-repeat: no-repeat !important;
606
- background-size: 60px 40px !important;
607
- }
608
- .select2-search input {
609
- background-position: 100% -21px !important;
610
- }
 
 
 
 
611
  }
1
  /*
2
+ Version: 3.5.2 Timestamp: Sat Nov 1 14:43:36 EDT 2014
3
  */
4
  .select2-container {
5
  margin: 0;
18
  /*
19
  Force border-box so that % widths fit the parent
20
  container without overlap because of margin/padding.
 
21
  More Info : http://www.quirksmode.org/css/box.html
22
  */
23
  -webkit-box-sizing: border-box; /* webkit */
32
  overflow: hidden;
33
  position: relative;
34
 
35
+ border: 1px solid #aaa;
36
  white-space: nowrap;
37
  line-height: 26px;
38
+ color: #444;
39
  text-decoration: none;
40
 
41
+ border-radius: 4px;
42
+
43
  background-clip: padding-box;
44
 
45
  -webkit-touch-callout: none;
48
  -ms-user-select: none;
49
  user-select: none;
50
 
51
+ background-color: #fff;
52
  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff));
53
  background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
54
  background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
55
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
56
+ background-image: linear-gradient(to top, #eee 0%, #fff 50%);
57
+ }
58
+
59
+ html[dir="rtl"] .select2-container .select2-choice {
60
+ padding: 0 8px 0 0;
61
  }
62
 
63
  .select2-container.select2-drop-above .select2-choice {
64
+ border-bottom-color: #aaa;
65
+
66
+ border-radius: 0 0 4px 4px;
67
 
68
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff));
69
  background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
70
  background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
71
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
72
+ background-image: linear-gradient(to bottom, #eee 0%, #fff 90%);
73
  }
74
 
75
  .select2-container.select2-allowclear .select2-choice .select2-chosen {
82
  overflow: hidden;
83
 
84
  white-space: nowrap;
85
+
86
  text-overflow: ellipsis;
87
+ float: none;
88
+ width: auto;
89
+ }
90
+
91
+ html[dir="rtl"] .select2-container .select2-choice > .select2-chosen {
92
+ margin-left: 26px;
93
+ margin-right: 0;
94
  }
95
 
96
  .select2-container .select2-choice abbr {
155
  box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
156
  }
157
 
 
 
 
 
 
 
 
 
 
158
  .select2-drop.select2-drop-above {
159
  margin-top: 1px;
160
  border-top: 1px solid #aaa;
167
  }
168
 
169
  .select2-drop-active {
170
+ border: 1px solid #5897fb;
171
  border-top: none;
172
  }
173
 
174
  .select2-drop.select2-drop-above.select2-drop-active {
175
+ border-top: 1px solid #5897fb;
176
+ }
177
+
178
+ .select2-drop-auto-width {
179
+ border-top: 1px solid #aaa;
180
+ width: auto;
181
+ }
182
+
183
+ .select2-drop-auto-width .select2-search {
184
+ padding-top: 4px;
185
  }
186
 
187
  .select2-container .select2-choice .select2-arrow {
192
  right: 0;
193
  top: 0;
194
 
195
+ border-left: 1px solid #aaa;
196
+ border-radius: 0 4px 4px 0;
197
 
198
  background-clip: padding-box;
199
 
202
  background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
203
  background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
204
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
205
+ background-image: linear-gradient(to top, #ccc 0%, #eee 60%);
206
+ }
207
+
208
+ html[dir="rtl"] .select2-container .select2-choice .select2-arrow {
209
+ left: 0;
210
+ right: auto;
211
+
212
+ border-left: none;
213
+ border-right: 1px solid #aaa;
214
+ border-radius: 4px 0 0 4px;
215
  }
216
 
217
  .select2-container .select2-choice .select2-arrow b {
221
  background: url('select2.png') no-repeat 0 1px;
222
  }
223
 
224
+ html[dir="rtl"] .select2-container .select2-choice .select2-arrow b {
225
+ background-position: 2px 1px;
226
+ }
227
+
228
  .select2-search {
229
  display: inline-block;
230
  width: 100%;
260
  background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
261
  background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
262
  background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
263
+ background: url('select2.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
264
+ }
265
+
266
+ html[dir="rtl"] .select2-search input {
267
+ padding: 4px 5px 4px 20px;
268
+
269
+ background: #fff url('select2.png') no-repeat -37px -22px;
270
+ background: url('select2.png') no-repeat -37px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
271
+ background: url('select2.png') no-repeat -37px -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
272
+ background: url('select2.png') no-repeat -37px -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
273
+ background: url('select2.png') no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
274
  }
275
 
276
  .select2-drop.select2-drop-above .select2-search input {
282
  background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
283
  background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
284
  background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
285
+ background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
286
  }
287
 
288
  .select2-container-active .select2-choice,
289
  .select2-container-active .select2-choices {
290
+ border: 1px solid #5897fb;
291
  outline: none;
292
 
293
  -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
302
  border-bottom-left-radius: 0;
303
  border-bottom-right-radius: 0;
304
 
305
+ background-color: #eee;
306
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee));
307
  background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
308
  background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
309
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
310
+ background-image: linear-gradient(to top, #fff 0%, #eee 50%);
311
  }
312
 
313
  .select2-dropdown-open.select2-drop-above .select2-choice,
314
  .select2-dropdown-open.select2-drop-above .select2-choices {
315
+ border: 1px solid #5897fb;
316
  border-top-color: transparent;
317
 
318
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee));
319
  background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
320
  background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
321
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
322
+ background-image: linear-gradient(to bottom, #fff 0%, #eee 50%);
323
  }
324
 
325
  .select2-dropdown-open .select2-choice .select2-arrow {
327
  border-left: none;
328
  filter: none;
329
  }
330
+ html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow {
331
+ border-right: none;
332
+ }
333
+
334
  .select2-dropdown-open .select2-choice .select2-arrow b {
335
  background-position: -18px 1px;
336
  }
337
 
338
+ html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow b {
339
+ background-position: -16px 1px;
340
+ }
341
+
342
+ .select2-hidden-accessible {
343
+ border: 0;
344
+ clip: rect(0 0 0 0);
345
+ height: 1px;
346
+ margin: -1px;
347
+ overflow: hidden;
348
+ padding: 0;
349
+ position: absolute;
350
+ width: 1px;
351
+ }
352
+
353
  /* results */
354
  .select2-results {
355
  max-height: 200px;
361
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
362
  }
363
 
364
+ html[dir="rtl"] .select2-results {
365
+ padding: 0 4px 0 0;
366
+ margin: 4px 0 4px 4px;
367
+ }
368
+
369
  .select2-results ul.select2-result-sub {
370
  margin: 0;
371
  padding-left: 0;
372
  }
373
 
 
 
 
 
 
 
 
 
374
  .select2-results li {
375
  list-style: none;
376
  display: list-item;
395
  user-select: none;
396
  }
397
 
398
+ .select2-results-dept-1 .select2-result-label { padding-left: 20px }
399
+ .select2-results-dept-2 .select2-result-label { padding-left: 40px }
400
+ .select2-results-dept-3 .select2-result-label { padding-left: 60px }
401
+ .select2-results-dept-4 .select2-result-label { padding-left: 80px }
402
+ .select2-results-dept-5 .select2-result-label { padding-left: 100px }
403
+ .select2-results-dept-6 .select2-result-label { padding-left: 110px }
404
+ .select2-results-dept-7 .select2-result-label { padding-left: 120px }
405
+
406
  .select2-results .select2-highlighted {
407
  background: #3875d7;
408
  color: #fff;
422
  color: #000;
423
  }
424
 
 
425
  .select2-results .select2-no-results,
426
  .select2-results .select2-searching,
427
+ .select2-results .select2-ajax-error,
428
  .select2-results .select2-selection-limit {
429
  background: #f4f4f4;
430
  display: list-item;
431
+ padding-left: 5px;
432
  }
433
 
434
  /*
454
  background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%;
455
  }
456
 
457
+ .select2-results .select2-ajax-error {
458
+ background: rgba(255, 50, 50, .2);
459
+ }
460
+
461
  .select2-more-results {
462
  background: #f4f4f4;
463
  display: list-item;
489
  height: auto !important;
490
  height: 1%;
491
  margin: 0;
492
+ padding: 0 5px 0 0;
493
  position: relative;
494
 
495
  border: 1px solid #aaa;
500
  background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
501
  background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
502
  background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
503
+ background-image: linear-gradient(to bottom, #eee 1%, #fff 15%);
504
+ }
505
+
506
+ html[dir="rtl"] .select2-container-multi .select2-choices {
507
+ padding: 0 0 0 5px;
508
  }
509
 
510
  .select2-locked {
516
  }
517
 
518
  .select2-container-multi.select2-container-active .select2-choices {
519
+ border: 1px solid #5897fb;
520
  outline: none;
521
 
522
  -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
526
  float: left;
527
  list-style: none;
528
  }
529
+ html[dir="rtl"] .select2-container-multi .select2-choices li
530
+ {
531
+ float: right;
532
+ }
533
  .select2-container-multi .select2-choices .select2-search-field {
534
  margin: 0;
535
  padding: 0;
586
  background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
587
  background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
588
  background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
589
+ background-image: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
590
+ }
591
+ html[dir="rtl"] .select2-container-multi .select2-choices .select2-search-choice
592
+ {
593
+ margin: 3px 5px 3px 0;
594
+ padding: 3px 18px 3px 5px;
595
  }
596
  .select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
597
  cursor: default;
612
  outline: none;
613
  background: url('select2.png') right top no-repeat;
614
  }
615
+ html[dir="rtl"] .select2-search-choice-close {
616
+ right: auto;
617
+ left: 3px;
618
+ }
619
 
620
  .select2-container-multi .select2-search-choice-close {
621
  left: 3px;
622
  }
623
 
624
+ html[dir="rtl"] .select2-container-multi .select2-search-choice-close {
625
+ left: auto;
626
+ right: 2px;
627
+ }
628
+
629
  .select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
630
  background-position: right -11px;
631
  }
685
  height: 100px;
686
  overflow: scroll;
687
  }
688
+
689
  /* Retina-ize icons */
690
 
691
+ @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 2dppx) {
692
+ .select2-search input,
693
+ .select2-search-choice-close,
694
+ .select2-container .select2-choice abbr,
695
+ .select2-container .select2-choice .select2-arrow b {
696
+ background-image: url('select2x2.png') !important;
697
+ background-repeat: no-repeat !important;
698
+ background-size: 60px 40px !important;
699
+ }
700
+
701
+ .select2-search input {
702
+ background-position: 100% -21px !important;
703
+ }
704
  }
embedded/common/utility/img/icon-help-message.png CHANGED
Binary file
embedded/common/utility/js/keyboard.js ADDED
@@ -0,0 +1,961 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Title: KeyboardJS
3
+ * Version: v0.4.1
4
+ * Description: KeyboardJS is a flexible and easy to use keyboard binding
5
+ * library.
6
+ * Author: Robert Hurst.
7
+ *
8
+ * Copyright 2011, Robert William Hurst
9
+ * Licenced under the BSD License.
10
+ * See https://raw.github.com/RobertWHurst/KeyboardJS/master/license.txt
11
+ */
12
+ (function(context, factory) {
13
+
14
+ //INDEXOF POLLYFILL
15
+ [].indexOf||(Array.prototype.indexOf=function(a,b,c){for(c=this.length,b=(c+~~b)%c;b<c&&(!(b in this)||this[b]!==a);b++);return b^c?b:-1;});
16
+
17
+ //AMD
18
+ if(typeof define === 'function' && define.amd) { define(constructAMD); }
19
+
20
+ //CommonJS
21
+ else if(typeof module !== 'undefined') {constructCommonJS()}
22
+
23
+ //GLOBAL
24
+ else { constructGlobal(); }
25
+
26
+ /**
27
+ * Construct AMD version of the library
28
+ */
29
+ function constructAMD() {
30
+
31
+ //create a library instance
32
+ return init(context);
33
+
34
+ //spawns a library instance
35
+ function init(context) {
36
+ var library;
37
+ library = factory(context, 'amd');
38
+ library.fork = init;
39
+ return library;
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Construct CommonJS version of the library
45
+ */
46
+ function constructCommonJS() {
47
+
48
+ //create a library instance
49
+ module.exports = init(context);
50
+
51
+ return;
52
+
53
+ //spawns a library instance
54
+ function init(context) {
55
+ var library;
56
+ library = factory(context, 'CommonJS');
57
+ library.fork = init;
58
+ return library;
59
+
60
+ }
61
+
62
+ }
63
+
64
+ /**
65
+ * Construct a Global version of the library
66
+ */
67
+ function constructGlobal() {
68
+ var library;
69
+
70
+ //create a library instance
71
+ library = init(context);
72
+
73
+ //spawns a library instance
74
+ function init(context) {
75
+ var library, namespaces = [], previousValues = {};
76
+
77
+ library = factory(context, 'global');
78
+ library.fork = init;
79
+ library.noConflict = noConflict;
80
+ library.noConflict('KeyboardJS', 'k');
81
+ return library;
82
+
83
+ //sets library namespaces
84
+ function noConflict( ) {
85
+ var args, nI, newNamespaces;
86
+
87
+ newNamespaces = Array.prototype.slice.apply(arguments);
88
+
89
+ for(nI = 0; nI < namespaces.length; nI += 1) {
90
+ if(typeof previousValues[namespaces[nI]] === 'undefined') {
91
+ delete context[namespaces[nI]];
92
+ } else {
93
+ context[namespaces[nI]] = previousValues[namespaces[nI]];
94
+ }
95
+ }
96
+
97
+ previousValues = {};
98
+
99
+ for(nI = 0; nI < newNamespaces.length; nI += 1) {
100
+ if(typeof newNamespaces[nI] !== 'string') {
101
+ throw new Error('Cannot replace namespaces. All new namespaces must be strings.');
102
+ }
103
+ previousValues[newNamespaces[nI]] = context[newNamespaces[nI]];
104
+ context[newNamespaces[nI]] = library;
105
+ }
106
+
107
+ namespaces = newNamespaces;
108
+
109
+ return namespaces;
110
+ }
111
+ }
112
+ }
113
+
114
+ })(this, function(targetWindow, env) {
115
+ var KeyboardJS = {}, locales = {}, locale, map, macros, activeKeys = [], bindings = [], activeBindings = [],
116
+ activeMacros = [], aI, usLocale;
117
+ targetWindow = targetWindow || window;
118
+
119
+ ///////////////////////
120
+ // DEFAULT US LOCALE //
121
+ ///////////////////////
122
+
123
+ //define US locale
124
+ //If you create a new locale please submit it as a pull request or post
125
+ // it in the issue tracker at
126
+ // http://github.com/RobertWhurst/KeyboardJS/issues/
127
+ usLocale = {
128
+ "map": {
129
+
130
+ //general
131
+ "3": ["cancel"],
132
+ "8": ["backspace"],
133
+ "9": ["tab"],
134
+ "12": ["clear"],
135
+ "13": ["enter"],
136
+ "16": ["shift"],
137
+ "17": ["ctrl"],
138
+ "18": ["alt", "menu"],
139
+ "19": ["pause", "break"],
140
+ "20": ["capslock"],
141
+ "27": ["escape", "esc"],
142
+ "32": ["space", "spacebar"],
143
+ "33": ["pageup"],
144
+ "34": ["pagedown"],
145
+ "35": ["end"],
146
+ "36": ["home"],
147
+ "37": ["left"],
148
+ "38": ["up"],
149
+ "39": ["right"],
150
+ "40": ["down"],
151
+ "41": ["select"],
152
+ "42": ["printscreen"],
153
+ "43": ["execute"],
154
+ "44": ["snapshot"],
155
+ "45": ["insert", "ins"],
156
+ "46": ["delete", "del"],
157
+ "47": ["help"],
158
+ "91": ["command", "windows", "win", "super", "leftcommand", "leftwindows", "leftwin", "leftsuper"],
159
+ "92": ["command", "windows", "win", "super", "rightcommand", "rightwindows", "rightwin", "rightsuper"],
160
+ "145": ["scrolllock", "scroll"],
161
+ "186": ["semicolon", ";"],
162
+ "187": ["equal", "equalsign", "="],
163
+ "188": ["comma", ","],
164
+ "189": ["dash", "-"],
165
+ "190": ["period", "."],
166
+ "191": ["slash", "forwardslash", "/"],
167
+ "192": ["graveaccent", "`"],
168
+ "219": ["openbracket", "["],
169
+ "220": ["backslash", "\\"],
170
+ "221": ["closebracket", "]"],
171
+ "222": ["apostrophe", "'"],
172
+
173
+ //0-9
174
+ "48": ["zero", "0"],
175
+ "49": ["one", "1"],
176
+ "50": ["two", "2"],
177
+ "51": ["three", "3"],
178
+ "52": ["four", "4"],
179
+ "53": ["five", "5"],
180
+ "54": ["six", "6"],
181
+ "55": ["seven", "7"],
182
+ "56": ["eight", "8"],
183
+ "57": ["nine", "9"],
184
+
185
+ //numpad
186
+ "96": ["numzero", "num0"],
187
+ "97": ["numone", "num1"],
188
+ "98": ["numtwo", "num2"],
189
+ "99": ["numthree", "num3"],
190
+ "100": ["numfour", "num4"],
191
+ "101": ["numfive", "num5"],
192
+ "102": ["numsix", "num6"],
193
+ "103": ["numseven", "num7"],
194
+ "104": ["numeight", "num8"],
195
+ "105": ["numnine", "num9"],
196
+ "106": ["nummultiply", "num*"],
197
+ "107": ["numadd", "num+"],
198
+ "108": ["numenter"],
199
+ "109": ["numsubtract", "num-"],
200
+ "110": ["numdecimal", "num."],
201
+ "111": ["numdivide", "num/"],
202
+ "144": ["numlock", "num"],
203
+
204
+ //function keys
205
+ "112": ["f1"],
206
+ "113": ["f2"],
207
+ "114": ["f3"],
208
+ "115": ["f4"],
209
+ "116": ["f5"],
210
+ "117": ["f6"],
211
+ "118": ["f7"],
212
+ "119": ["f8"],
213
+ "120": ["f9"],
214
+ "121": ["f10"],
215
+ "122": ["f11"],
216
+ "123": ["f12"]
217
+ },
218
+ "macros": [
219
+
220
+ //secondary key symbols
221
+ ['shift + `', ["tilde", "~"]],
222
+ ['shift + 1', ["exclamation", "exclamationpoint", "!"]],
223
+ ['shift + 2', ["at", "@"]],
224
+ ['shift + 3', ["number", "#"]],
225
+ ['shift + 4', ["dollar", "dollars", "dollarsign", "$"]],
226
+ ['shift + 5', ["percent", "%"]],
227
+ ['shift + 6', ["caret", "^"]],
228
+ ['shift + 7', ["ampersand", "and", "&"]],
229
+ ['shift + 8', ["asterisk", "*"]],
230
+ ['shift + 9', ["openparen", "("]],
231
+ ['shift + 0', ["closeparen", ")"]],
232
+ ['shift + -', ["underscore", "_"]],
233
+ ['shift + =', ["plus", "+"]],
234
+ ['shift + (', ["opencurlybrace", "opencurlybracket", "{"]],
235
+ ['shift + )', ["closecurlybrace", "closecurlybracket", "}"]],
236
+ ['shift + \\', ["verticalbar", "|"]],
237
+ ['shift + ;', ["colon", ":"]],
238
+ ['shift + \'', ["quotationmark", "\""]],
239
+ ['shift + !,', ["openanglebracket", "<"]],
240
+ ['shift + .', ["closeanglebracket", ">"]],
241
+ ['shift + /', ["questionmark", "?"]]
242
+ ]
243
+ };
244
+ //a-z and A-Z
245
+ for (aI = 65; aI <= 90; aI += 1) {
246
+ usLocale.map[aI] = String.fromCharCode(aI + 32);
247
+ usLocale.macros.push(['shift + ' + String.fromCharCode(aI + 32) + ', capslock + ' + String.fromCharCode(aI + 32), [String.fromCharCode(aI)]]);
248
+ }
249
+ registerLocale('us', usLocale);
250
+ getSetLocale('us');
251
+
252
+
253
+ //////////
254
+ // INIT //
255
+ //////////
256
+
257
+ //enable the library
258
+ enable();
259
+
260
+
261
+ /////////
262
+ // API //
263
+ /////////
264
+
265
+ //assemble the library and return it
266
+ KeyboardJS.enable = enable;
267
+ KeyboardJS.disable = disable;
268
+ KeyboardJS.activeKeys = getActiveKeys;
269
+ KeyboardJS.releaseKey = removeActiveKey;
270
+ KeyboardJS.pressKey = addActiveKey;
271
+ KeyboardJS.on = createBinding;
272
+ KeyboardJS.clear = removeBindingByKeyCombo;
273
+ KeyboardJS.clear.key = removeBindingByKeyName;
274
+ KeyboardJS.locale = getSetLocale;
275
+ KeyboardJS.locale.register = registerLocale;
276
+ KeyboardJS.macro = createMacro;
277
+ KeyboardJS.macro.remove = removeMacro;
278
+ KeyboardJS.key = {};
279
+ KeyboardJS.key.name = getKeyName;
280
+ KeyboardJS.key.code = getKeyCode;
281
+ KeyboardJS.combo = {};
282
+ KeyboardJS.combo.active = isSatisfiedCombo;
283
+ KeyboardJS.combo.parse = parseKeyCombo;
284
+ KeyboardJS.combo.stringify = stringifyKeyCombo;
285
+ return KeyboardJS;
286
+
287
+
288
+ //////////////////////
289
+ // INSTANCE METHODS //
290
+ //////////////////////
291
+
292
+ /**
293
+ * Enables KeyboardJS
294
+ */
295
+ function enable() {
296
+ if(targetWindow.addEventListener) {
297
+ targetWindow.document.addEventListener('keydown', keydown, false);
298
+ targetWindow.document.addEventListener('keyup', keyup, false);
299
+ targetWindow.addEventListener('blur', reset, false);
300
+ targetWindow.addEventListener('webkitfullscreenchange', reset, false);
301
+ targetWindow.addEventListener('mozfullscreenchange', reset, false);
302
+ } else if(targetWindow.attachEvent) {
303
+ targetWindow.document.attachEvent('onkeydown', keydown);
304
+ targetWindow.document.attachEvent('onkeyup', keyup);
305
+ targetWindow.attachEvent('onblur', reset);
306
+ }
307
+ }
308
+
309
+ /**
310
+ * Exits all active bindings and disables KeyboardJS
311
+ */
312
+ function disable() {
313
+ reset();
314
+ if(targetWindow.removeEventListener) {
315
+ targetWindow.document.removeEventListener('keydown', keydown, false);
316
+ targetWindow.document.removeEventListener('keyup', keyup, false);
317
+ targetWindow.removeEventListener('blur', reset, false);
318
+ targetWindow.removeEventListener('webkitfullscreenchange', reset, false);
319
+ targetWindow.removeEventListener('mozfullscreenchange', reset, false);
320
+ } else if(targetWindow.detachEvent) {
321
+ targetWindow.document.detachEvent('onkeydown', keydown);
322
+ targetWindow.document.detachEvent('onkeyup', keyup);
323
+ targetWindow.detachEvent('onblur', reset);
324
+ }
325
+ }
326
+
327
+
328
+ ////////////////////
329
+ // EVENT HANDLERS //
330
+ ////////////////////
331
+
332
+ /**
333
+ * Exits all active bindings. Optionally passes an event to all binding
334
+ * handlers.
335
+ * @param {KeyboardEvent} event [Optional]
336
+ */
337
+ function reset(event) {
338
+ activeKeys = [];
339
+ pruneMacros();
340
+ pruneBindings(event);
341
+ }
342
+
343
+ /**
344
+ * Key down event handler.
345
+ * @param {KeyboardEvent} event
346
+ */
347
+ function keydown(event) {
348
+ var keyNames, keyName, kI;
349
+ keyNames = getKeyName(event.keyCode);
350
+ if(keyNames.length < 1) { return; }
351
+ event.isRepeat = false;
352
+ for(kI = 0; kI < keyNames.length; kI += 1) {
353
+ keyName = keyNames[kI];
354
+ if (getActiveKeys().indexOf(keyName) != -1)
355
+ event.isRepeat = true;
356
+ addActiveKey(keyName);
357
+ }
358
+ executeMacros();
359
+ executeBindings(event);
360
+ }
361
+
362
+ /**
363
+ * Key up event handler.
364
+ * @param {KeyboardEvent} event
365
+ */
366
+ function keyup(event) {
367
+ var keyNames, kI;
368
+ keyNames = getKeyName(event.keyCode);
369
+ if(keyNames.length < 1) { return; }
370
+ for(kI = 0; kI < keyNames.length; kI += 1) {
371
+ removeActiveKey(keyNames[kI]);
372
+ }
373
+ pruneMacros();
374
+ pruneBindings(event);
375
+ }
376
+
377
+ /**
378
+ * Accepts a key code and returns the key names defined by the current
379
+ * locale.
380
+ * @param {Number} keyCode
381
+ * @return {Array} keyNames An array of key names defined for the key
382
+ * code as defined by the current locale.
383
+ */
384
+ function getKeyName(keyCode) {
385
+ return map[keyCode] || [];
386
+ }
387
+
388
+ /**
389
+ * Accepts a key name and returns the key code defined by the current
390
+ * locale.
391
+ * @param {Number} keyName
392
+ * @return {Number|false}
393
+ */
394
+ function getKeyCode(keyName) {
395
+ var keyCode;
396
+ for(keyCode in map) {
397
+ if(!map.hasOwnProperty(keyCode)) { continue; }
398
+ if(map[keyCode].indexOf(keyName) > -1) { return keyCode; }
399
+ }
400
+ return false;
401
+ }
402
+
403
+
404
+ ////////////
405
+ // MACROS //
406
+ ////////////
407
+
408
+ /**
409
+ * Accepts a key combo and an array of key names to inject once the key
410
+ * combo is satisfied.
411
+ * @param {String} combo
412
+ * @param {Array} injectedKeys
413
+ */
414
+ function createMacro(combo, injectedKeys) {
415
+ if(typeof combo !== 'string' && (typeof combo !== 'object' || typeof combo.push !== 'function')) {
416
+ throw new Error("Cannot create macro. The combo must be a string or array.");
417
+ }
418
+ if(typeof injectedKeys !== 'object' || typeof injectedKeys.push !== 'function') {
419
+ throw new Error("Cannot create macro. The injectedKeys must be an array.");
420
+ }
421
+ macros.push([combo, injectedKeys]);
422
+ }
423
+
424
+ /**
425
+ * Accepts a key combo and clears any and all macros bound to that key
426
+ * combo.
427
+ * @param {String} combo
428
+ */
429
+ function removeMacro(combo) {
430
+ var macro;
431
+ if(typeof combo !== 'string' && (typeof combo !== 'object' || typeof combo.push !== 'function')) { throw new Error("Cannot remove macro. The combo must be a string or array."); }
432
+ for(mI = 0; mI < macros.length; mI += 1) {
433
+ macro = macros[mI];
434
+ if(compareCombos(combo, macro[0])) {
435
+ removeActiveKey(macro[1]);
436
+ macros.splice(mI, 1);
437
+ break;
438
+ }
439
+ }
440
+ }
441
+
442
+ /**
443
+ * Executes macros against the active keys. Each macro's key combo is
444
+ * checked and if found to be satisfied, the macro's key names are injected
445
+ * into active keys.
446
+ */
447
+ function executeMacros() {
448
+ var mI, combo, kI;
449
+ for(mI = 0; mI < macros.length; mI += 1) {
450
+ combo = parseKeyCombo(macros[mI][0]);
451
+ if(activeMacros.indexOf(macros[mI]) === -1 && isSatisfiedCombo(combo)) {
452
+ activeMacros.push(macros[mI]);
453
+ for(kI = 0; kI < macros[mI][1].length; kI += 1) {
454
+ addActiveKey(macros[mI][1][kI]);
455
+ }
456
+ }
457
+ }
458
+ }
459
+
460
+ /**
461
+ * Prunes active macros. Checks each active macro's key combo and if found
462
+ * to no longer to be satisfied, each of the macro's key names are removed
463
+ * from active keys.
464
+ */
465
+ function pruneMacros() {
466
+ var mI, combo, kI;
467
+ for(mI = 0; mI < activeMacros.length; mI += 1) {
468
+ combo = parseKeyCombo(activeMacros[mI][0]);
469
+ if(isSatisfiedCombo(combo) === false) {
470
+ for(kI = 0; kI < activeMacros[mI][1].length; kI += 1) {
471
+ removeActiveKey(activeMacros[mI][1][kI]);
472
+ }
473
+ activeMacros.splice(mI, 1);
474
+ mI -= 1;
475
+ }
476
+ }
477
+ }
478
+
479
+
480
+ //////////////
481
+ // BINDINGS //
482
+ //////////////
483
+
484
+ /**
485
+ * Creates a binding object, and, if provided, binds a key down hander and
486
+ * a key up handler. Returns a binding object that emits keyup and
487
+ * keydown events.
488
+ * @param {String} keyCombo
489
+ * @param {Function} keyDownCallback [Optional]
490
+ * @param {Function} keyUpCallback [Optional]
491
+ * @return {Object} binding
492
+ */
493
+ function createBinding(keyCombo, keyDownCallback, keyUpCallback) {
494
+ var api = {}, binding, subBindings = [], bindingApi = {}, kI,
495
+ subCombo;
496
+
497
+ //break the combo down into a combo array
498
+ if(typeof keyCombo === 'string') {
499
+ keyCombo = parseKeyCombo(keyCombo);
500
+ }
501
+
502
+ //bind each sub combo contained within the combo string
503
+ for(kI = 0; kI < keyCombo.length; kI += 1) {
504
+ binding = {};
505
+
506
+ //stringify the combo again
507
+ subCombo = stringifyKeyCombo([keyCombo[kI]]);
508
+
509
+ //validate the sub combo
510
+ if(typeof subCombo !== 'string') { throw new Error('Failed to bind key combo. The key combo must be string.'); }
511
+
512
+ //create the binding
513
+ binding.keyCombo = subCombo;
514
+ binding.keyDownCallback = [];
515
+ binding.keyUpCallback = [];
516
+
517
+ //inject the key down and key up callbacks if given
518
+ if(keyDownCallback) { binding.keyDownCallback.push(keyDownCallback); }
519
+ if(keyUpCallback) { binding.keyUpCallback.push(keyUpCallback); }
520
+
521
+ //stash the new binding
522
+ bindings.push(binding);
523
+ subBindings.push(binding);
524
+ }
525
+
526
+ //build the binding api
527
+ api.clear = clear;
528
+ api.on = on;
529
+ return api;
530
+
531
+ /**
532
+ * Clears the binding
533
+ */
534
+ function clear() {
535
+ var bI;
536
+ for(bI = 0; bI < subBindings.length; bI += 1) {
537
+ bindings.splice(bindings.indexOf(subBindings[bI]), 1);
538
+ }
539
+ }
540
+
541
+ /**
542
+ * Accepts an event name. and any number of callbacks. When the event is
543
+ * emitted, all callbacks are executed. Available events are key up and
544
+ * key down.
545
+ * @param {String} eventName
546
+ * @return {Object} subBinding
547
+ */
548
+ function on(eventName ) {
549
+ var api = {}, callbacks, cI, bI;
550
+
551
+ //validate event name
552
+ if(typeof eventName !== 'string') { throw new Error('Cannot bind callback. The event name must be a string.'); }
553
+ if(eventName !== 'keyup' && eventName !== 'keydown') { throw new Error('Cannot bind callback. The event name must be a "keyup" or "keydown".'); }
554
+
555
+ //gather the callbacks
556
+ callbacks = Array.prototype.slice.apply(arguments, [1]);
557
+
558
+ //stash each the new binding
559
+ for(cI = 0; cI < callbacks.length; cI += 1) {
560
+ if(typeof callbacks[cI] === 'function') {
561
+ if(eventName === 'keyup') {
562
+ for(bI = 0; bI < subBindings.length; bI += 1) {
563
+ subBindings[bI].keyUpCallback.push(callbacks[cI]);
564
+ }
565
+ } else if(eventName === 'keydown') {
566
+ for(bI = 0; bI < subBindings.length; bI += 1) {
567
+ subBindings[bI].keyDownCallback.push(callbacks[cI]);
568
+ }
569
+ }
570
+ }
571
+ }
572
+
573
+ //construct and return the sub binding api
574
+ api.clear = clear;
575
+ return api;
576
+
577
+ /**
578
+ * Clears the binding
579
+ */
580
+ function clear() {
581
+ var cI, bI;
582
+ for(cI = 0; cI < callbacks.length; cI += 1) {
583
+ if(typeof callbacks[cI] === 'function') {
584
+ if(eventName === 'keyup') {
585
+ for(bI = 0; bI < subBindings.length; bI += 1) {
586
+ subBindings[bI].keyUpCallback.splice(subBindings[bI].keyUpCallback.indexOf(callbacks[cI]), 1);
587
+ }
588
+ } else {
589
+ for(bI = 0; bI < subBindings.length; bI += 1) {
590
+ subBindings[bI].keyDownCallback.splice(subBindings[bI].keyDownCallback.indexOf(callbacks[cI]), 1);
591
+ }
592
+ }
593
+ }
594
+ }
595
+ }
596
+ }
597
+ }
598
+
599
+ /**
600
+ * Clears all binding attached to a given key combo. Key name order does not
601
+ * matter as long as the key combos equate.
602
+ * @param {String} keyCombo
603
+ */
604
+ function removeBindingByKeyCombo(keyCombo) {
605
+ var bI, binding, keyName;
606
+ for(bI = 0; bI < bindings.length; bI += 1) {
607
+ binding = bindings[bI];
608
+ if(compareCombos(keyCombo, binding.keyCombo)) {
609
+ bindings.splice(bI, 1); bI -= 1;
610
+ }
611
+ }
612
+ }
613
+
614
+ /**
615
+ * Clears all binding attached to key combos containing a given key name.
616
+ * @param {String} keyName
617
+ */
618
+ function removeBindingByKeyName(keyName) {
619
+ var bI, kI, binding;
620
+ if(keyName) {
621
+ for(bI = 0; bI < bindings.length; bI += 1) {
622
+ binding = bindings[bI];
623
+ for(kI = 0; kI < binding.keyCombo.length; kI += 1) {
624
+ if(binding.keyCombo[kI].indexOf(keyName) > -1) {
625
+ bindings.splice(bI, 1); bI -= 1;
626
+ break;
627
+ }
628
+ }
629
+ }
630
+ } else {
631
+ bindings = [];
632
+ }
633
+ }
634
+
635
+ /**
636
+ * Executes bindings that are active. Only allows the keys to be used once
637
+ * as to prevent binding overlap.
638
+ * @param {KeyboardEvent} event The keyboard event.
639
+ */
640
+ function executeBindings(event) {
641
+ var bI, sBI, binding, bindingKeys, remainingKeys, cI, killEventBubble, kI, bindingKeysSatisfied,
642
+ index, sortedBindings = [], bindingWeight;
643
+
644
+ remainingKeys = [].concat(activeKeys);
645
+ for(bI = 0; bI < bindings.length; bI += 1) {
646
+ bindingWeight = extractComboKeys(bindings[bI].keyCombo).length;
647
+ if(!sortedBindings[bindingWeight]) { sortedBindings[bindingWeight] = []; }
648
+ sortedBindings[bindingWeight].push(bindings[bI]);
649
+ }
650
+ for(sBI = sortedBindings.length - 1; sBI >= 0; sBI -= 1) {
651
+ if(!sortedBindings[sBI]) { continue; }
652
+ for(bI = 0; bI < sortedBindings[sBI].length; bI += 1) {
653
+ binding = sortedBindings[sBI][bI];
654
+ bindingKeys = extractComboKeys(binding.keyCombo);
655
+ bindingKeysSatisfied = true;
656
+ for(kI = 0; kI < bindingKeys.length; kI += 1) {
657
+ if(remainingKeys.indexOf(bindingKeys[kI]) === -1) {
658
+ bindingKeysSatisfied = false;
659
+ break;
660
+ }
661
+ }
662
+ if(bindingKeysSatisfied && isSatisfiedCombo(binding.keyCombo)) {
663
+ activeBindings.push(binding);
664
+ for(kI = 0; kI < bindingKeys.length; kI += 1) {
665
+ index = remainingKeys.indexOf(bindingKeys[kI]);
666
+ if(index > -1) {
667
+ remainingKeys.splice(index, 1);
668
+ kI -= 1;
669
+ }
670
+ }
671
+ for(cI = 0; cI < binding.keyDownCallback.length; cI += 1) {
672
+ if (binding.keyDownCallback[cI](event, getActiveKeys(), binding.keyCombo) === false) {
673
+ killEventBubble = true;
674
+ }
675
+ }
676
+ if(killEventBubble === true) {
677
+ event.preventDefault();
678
+ event.stopPropagation();
679
+ }
680
+ }
681
+ }
682
+ }
683
+ }
684
+
685
+ /**
686
+ * Removes bindings that are no longer satisfied by the active keys. Also
687
+ * fires the key up callbacks.
688
+ * @param {KeyboardEvent} event
689
+ */
690
+ function pruneBindings(event) {
691
+ var bI, cI, binding, killEventBubble;
692
+ for(bI = 0; bI < activeBindings.length; bI += 1) {
693
+ binding = activeBindings[bI];
694
+ if(isSatisfiedCombo(binding.keyCombo) === false) {
695
+ for(cI = 0; cI < binding.keyUpCallback.length; cI += 1) {
696
+ if (binding.keyUpCallback[cI](event, getActiveKeys(), binding.keyCombo) === false) {
697
+ killEventBubble = true;
698
+ }
699
+ }
700
+ if(killEventBubble === true) {
701
+ event.preventDefault();
702
+ event.stopPropagation();
703
+ }
704
+ activeBindings.splice(bI, 1);
705
+ bI -= 1;
706
+ }
707
+ }
708
+ }
709
+
710
+
711
+ ///////////////////
712
+ // COMBO STRINGS //
713
+ ///////////////////
714
+
715
+ /**
716
+ * Compares two key combos returning true when they are functionally
717
+ * equivalent.
718
+ * @param {String} keyComboArrayA keyCombo A key combo string or array.
719
+ * @param {String} keyComboArrayB keyCombo A key combo string or array.
720
+ * @return {Boolean}
721
+ */
722
+ function compareCombos(keyComboArrayA, keyComboArrayB) {
723
+ var cI, sI, kI;
724
+ keyComboArrayA = parseKeyCombo(keyComboArrayA);
725
+ keyComboArrayB = parseKeyCombo(keyComboArrayB);
726
+ if(keyComboArrayA.length !== keyComboArrayB.length) { return false; }
727
+ for(cI = 0; cI < keyComboArrayA.length; cI += 1) {
728
+ if(keyComboArrayA[cI].length !== keyComboArrayB[cI].length) { return false; }
729
+ for(sI = 0; sI < keyComboArrayA[cI].length; sI += 1) {
730
+ if(keyComboArrayA[cI][sI].length !== keyComboArrayB[cI][sI].length) { return false; }
731
+ for(kI = 0; kI < keyComboArrayA[cI][sI].length; kI += 1) {
732
+ if(keyComboArrayB[cI][sI].indexOf(keyComboArrayA[cI][sI][kI]) === -1) { return false; }
733
+ }
734
+ }
735
+ }
736
+ return true;
737
+ }
738
+
739
+ /**
740
+ * Checks to see if a key combo string or key array is satisfied by the
741
+ * currently active keys. It does not take into account spent keys.
742
+ * @param {String} keyCombo A key combo string or array.
743
+ * @return {Boolean}
744
+ */
745
+ function isSatisfiedCombo(keyCombo) {
746
+ var cI, sI, stage, kI, stageOffset = 0, index, comboMatches;
747
+ keyCombo = parseKeyCombo(keyCombo);
748
+ for(cI = 0; cI < keyCombo.length; cI += 1) {
749
+ comboMatches = true;
750
+ stageOffset = 0;
751
+ for(sI = 0; sI < keyCombo[cI].length; sI += 1) {
752
+ stage = [].concat(keyCombo[cI][sI]);
753
+ for(kI = stageOffset; kI < activeKeys.length; kI += 1) {
754
+ index = stage.indexOf(activeKeys[kI]);
755
+ if(index > -1) {
756
+ stage.splice(index, 1);
757
+ stageOffset = kI;
758
+ }
759
+ }
760
+ if(stage.length !== 0) { comboMatches = false; break; }
761
+ }
762
+ if(comboMatches) { return true; }
763
+ }
764
+ return false;
765
+ }
766
+
767
+ /**
768
+ * Accepts a key combo array or string and returns a flat array containing all keys referenced by
769
+ * the key combo.
770
+ * @param {String} keyCombo A key combo string or array.
771
+ * @return {Array}
772
+ */
773
+ function extractComboKeys(keyCombo) {
774
+ var cI, sI, kI, keys = [];
775
+ keyCombo = parseKeyCombo(keyCombo);
776
+ for(cI = 0; cI < keyCombo.length; cI += 1) {
777
+ for(sI = 0; sI < keyCombo[cI].length; sI += 1) {
778
+ keys = keys.concat(keyCombo[cI][sI]);
779
+ }
780
+ }
781
+ return keys;
782
+ }
783
+
784
+ /**
785
+ * Parses a key combo string into a 3 dimensional array.
786
+ * - Level 1 - sub combos.
787
+ * - Level 2 - combo stages. A stage is a set of key name pairs that must
788
+ * be satisfied in the order they are defined.
789
+ * - Level 3 - each key name to the stage.
790
+ * @param {String|Array} keyCombo A key combo string.
791
+ * @return {Array}
792
+ */
793
+ function parseKeyCombo(keyCombo) {
794
+ var s = keyCombo, i = 0, op = 0, ws = false, nc = false, combos = [], combo = [], stage = [], key = '';
795
+
796
+ if(typeof keyCombo === 'object' && typeof keyCombo.push === 'function') { return keyCombo; }
797
+ if(typeof keyCombo !== 'string') { throw new Error('Cannot parse "keyCombo" because its type is "' + (typeof keyCombo) + '". It must be a "string".'); }
798
+
799
+ //remove leading whitespace
800
+ while(s.charAt(i) === ' ') { i += 1; }
801
+ while(true) {
802
+ if(s.charAt(i) === ' ') {
803
+ //white space & next combo op
804
+ while(s.charAt(i) === ' ') { i += 1; }
805
+ ws = true;
806
+ } else if(s.charAt(i) === ',') {
807
+ if(op || nc) { throw new Error('Failed to parse key combo. Unexpected , at character index ' + i + '.'); }
808
+ nc = true;
809
+ i += 1;
810
+ } else if(s.charAt(i) === '+') {
811
+ //next key
812
+ if(key.length) { stage.push(key); key = ''; }
813
+ if(op || nc) { throw new Error('Failed to parse key combo. Unexpected + at character index ' + i + '.'); }
814
+ op = true;
815
+ i += 1;
816
+ } else if(s.charAt(i) === '>') {
817
+ //next stage op
818
+ if(key.length) { stage.push(key); key = ''; }
819
+ if(stage.length) { combo.push(stage); stage = []; }
820
+ if(op || nc) { throw new Error('Failed to parse key combo. Unexpected > at character index ' + i + '.'); }
821
+ op = true;
822
+ i += 1;
823
+ } else if(i < s.length - 1 && s.charAt(i) === '!' && (s.charAt(i + 1) === '>' || s.charAt(i + 1) === ',' || s.charAt(i + 1) === '+')) {
824
+ key += s.charAt(i + 1);
825
+ op = false;
826
+ ws = false;
827
+ nc = false;
828
+ i += 2;
829
+ } else if(i < s.length && s.charAt(i) !== '+' && s.charAt(i) !== '>' && s.charAt(i) !== ',' && s.charAt(i) !== ' ') {
830
+ //end combo
831
+ if(op === false && ws === true || nc === true) {
832
+ if(key.length) { stage.push(key); key = ''; }
833
+ if(stage.length) { combo.push(stage); stage = []; }
834
+ if(combo.length) { combos.push(combo); combo = []; }
835
+ }
836
+ op = false;
837
+ ws = false;
838
+ nc = false;
839
+ //key
840
+ while(i < s.length && s.charAt(i) !== '+' && s.charAt(i) !== '>' && s.charAt(i) !== ',' && s.charAt(i) !== ' ') {
841
+ key += s.charAt(i);
842
+ i += 1;
843
+ }
844
+ } else {
845
+ //unknown char
846
+ i += 1;
847
+ continue;
848
+ }
849
+ //end of combos string
850
+ if(i >= s.length) {
851
+ if(key.length) { stage.push(key); key = ''; }
852
+ if(stage.length) { combo.push(stage); stage = []; }
853
+ if(combo.length) { combos.push(combo); combo = []; }
854
+ break;
855
+ }
856
+ }
857
+ return combos;
858
+ }
859
+
860
+ /**
861
+ * Stringifys a key combo.
862
+ * @param {Array|String} keyComboArray A key combo array. If a key
863
+ * combo string is given it will be returned.
864
+ * @return {String}
865
+ */
866
+ function stringifyKeyCombo(keyComboArray) {
867
+ var cI, ccI, output = [];
868
+ if(typeof keyComboArray === 'string') { return keyComboArray; }
869
+ if(typeof keyComboArray !== 'object' || typeof keyComboArray.push !== 'function') { throw new Error('Cannot stringify key combo.'); }
870
+ for(cI = 0; cI < keyComboArray.length; cI += 1) {
871
+ output[cI] = [];
872
+ for(ccI = 0; ccI < keyComboArray[cI].length; ccI += 1) {
873
+ output[cI][ccI] = keyComboArray[cI][ccI].join(' + ');
874
+ }
875
+ output[cI] = output[cI].join(' > ');
876
+ }
877
+ return output.join(' ');
878
+ }
879
+
880
+
881
+ /////////////////
882
+ // ACTIVE KEYS //
883
+ /////////////////
884
+
885
+ /**
886
+ * Returns the a copy of the active keys array.
887
+ * @return {Array}
888
+ */
889
+ function getActiveKeys() {
890
+ return [].concat(activeKeys);
891
+ }
892
+
893
+ /**
894
+ * Adds a key to the active keys array, but only if it has not already been
895
+ * added.
896
+ * @param {String} keyName The key name string.
897
+ */
898
+ function addActiveKey(keyName) {
899
+ if(keyName.match(/\s/)) { throw new Error('Cannot add key name ' + keyName + ' to active keys because it contains whitespace.'); }
900
+ if(activeKeys.indexOf(keyName) > -1) { return; }
901
+ activeKeys.push(keyName);
902
+ }
903
+
904
+ /**
905
+ * Removes a key from the active keys array.
906
+ * @param {String} keyNames The key name string.
907
+ */
908
+ function removeActiveKey(keyName) {
909
+ var keyCode = getKeyCode(keyName);
910
+ if(keyCode === '91' || keyCode === '92') { activeKeys = []; } //remove all key on release of super.
911
+ else { activeKeys.splice(activeKeys.indexOf(keyName), 1); }
912
+ }
913
+
914
+
915
+ /////////////
916
+ // LOCALES //
917
+ /////////////
918
+
919
+ /**
920
+ * Registers a new locale. This is useful if you would like to add support for a new keyboard layout. It could also be useful for
921
+ * alternative key names. For example if you program games you could create a locale for your key mappings. Instead of key 65 mapped
922
+ * to 'a' you could map it to 'jump'.
923
+ * @param {String} localeName The name of the new locale.
924
+ * @param {Object} localeMap The locale map.
925
+ */
926
+ function registerLocale(localeName, localeMap) {
927
+
928
+ //validate arguments
929
+ if(typeof localeName !== 'string') { throw new Error('Cannot register new locale. The locale name must be a string.'); }
930
+ if(typeof localeMap !== 'object') { throw new Error('Cannot register ' + localeName + ' locale. The locale map must be an object.'); }
931
+ if(typeof localeMap.map !== 'object') { throw new Error('Cannot register ' + localeName + ' locale. The locale map is invalid.'); }
932
+
933
+ //stash the locale
934
+ if(!localeMap.macros) { localeMap.macros = []; }
935
+ locales[localeName] = localeMap;
936
+ }
937
+
938
+ /**
939
+ * Swaps the current locale.
940
+ * @param {String} localeName The locale to activate.
941
+ * @return {Object}
942
+ */
943
+ function getSetLocale(localeName) {
944
+
945
+ //if a new locale is given then set it
946
+ if(localeName) {
947
+ if(typeof localeName !== 'string') { throw new Error('Cannot set locale. The locale name must be a string.'); }
948
+ if(!locales[localeName]) { throw new Error('Cannot set locale to ' + localeName + ' because it does not exist. If you would like to submit a ' + localeName + ' locale map for KeyboardJS please submit it at https://github.com/RobertWHurst/KeyboardJS/issues.'); }
949
+
950
+ //set the current map and macros
951
+ map = locales[localeName].map;
952
+ macros = locales[localeName].macros;
953
+
954
+ //set the current locale
955
+ locale = localeName;
956
+ }
957
+
958
+ //return the current locale
959
+ return locale;
960
+ }
961
+ });
embedded/common/utility/js/keyboard.min.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(e,b){[].indexOf||(Array.prototype.indexOf=function(g,f,h){for(h=this.length,f=(h+~~f)%h;f<h&&(!(f in this)||this[f]!==g);f++){}return f^h?f:-1});if(typeof define==="function"&&define.amd){define(a)}else{if(typeof module!=="undefined"){d()}else{c()}}function a(){return f(e);function f(h){var g;g=b(h,"amd");g.fork=f;return g}}function d(){module.exports=f(e);return;function f(h){var g;g=b(h,"CommonJS");g.fork=f;return g}}function c(){var f;f=g(e);function g(k){var j,l=[],h={};j=b(k,"global");j.fork=g;j.noConflict=i;j.noConflict("KeyboardJS","k");return j;function i(){var o,n,m;m=Array.prototype.slice.apply(arguments);for(n=0;n<l.length;n+=1){if(typeof h[l[n]]==="undefined"){delete k[l[n]]}else{k[l[n]]=h[l[n]]}}h={};for(n=0;n<m.length;n+=1){if(typeof m[n]!=="string"){throw new Error("Cannot replace namespaces. All new namespaces must be strings.")}h[m[n]]=k[m[n]];k[m[n]]=j}l=m;return l}}}})(this,function(H,e){var i={},w={},o,u,B,l=[],K=[],n=[],M=[],v,m;H=H||window;m={map:{"3":["cancel"],"8":["backspace"],"9":["tab"],"12":["clear"],"13":["enter"],"16":["shift"],"17":["ctrl"],"18":["alt","menu"],"19":["pause","break"],"20":["capslock"],"27":["escape","esc"],"32":["space","spacebar"],"33":["pageup"],"34":["pagedown"],"35":["end"],"36":["home"],"37":["left"],"38":["up"],"39":["right"],"40":["down"],"41":["select"],"42":["printscreen"],"43":["execute"],"44":["snapshot"],"45":["insert","ins"],"46":["delete","del"],"47":["help"],"91":["command","windows","win","super","leftcommand","leftwindows","leftwin","leftsuper"],"92":["command","windows","win","super","rightcommand","rightwindows","rightwin","rightsuper"],"145":["scrolllock","scroll"],"186":["semicolon",";"],"187":["equal","equalsign","="],"188":["comma",","],"189":["dash","-"],"190":["period","."],"191":["slash","forwardslash","/"],"192":["graveaccent","`"],"219":["openbracket","["],"220":["backslash","\\"],"221":["closebracket","]"],"222":["apostrophe","'"],"48":["zero","0"],"49":["one","1"],"50":["two","2"],"51":["three","3"],"52":["four","4"],"53":["five","5"],"54":["six","6"],"55":["seven","7"],"56":["eight","8"],"57":["nine","9"],"96":["numzero","num0"],"97":["numone","num1"],"98":["numtwo","num2"],"99":["numthree","num3"],"100":["numfour","num4"],"101":["numfive","num5"],"102":["numsix","num6"],"103":["numseven","num7"],"104":["numeight","num8"],"105":["numnine","num9"],"106":["nummultiply","num*"],"107":["numadd","num+"],"108":["numenter"],"109":["numsubtract","num-"],"110":["numdecimal","num."],"111":["numdivide","num/"],"144":["numlock","num"],"112":["f1"],"113":["f2"],"114":["f3"],"115":["f4"],"116":["f5"],"117":["f6"],"118":["f7"],"119":["f8"],"120":["f9"],"121":["f10"],"122":["f11"],"123":["f12"]},macros:[["shift + `",["tilde","~"]],["shift + 1",["exclamation","exclamationpoint","!"]],["shift + 2",["at","@"]],["shift + 3",["number","#"]],["shift + 4",["dollar","dollars","dollarsign","$"]],["shift + 5",["percent","%"]],["shift + 6",["caret","^"]],["shift + 7",["ampersand","and","&"]],["shift + 8",["asterisk","*"]],["shift + 9",["openparen","("]],["shift + 0",["closeparen",")"]],["shift + -",["underscore","_"]],["shift + =",["plus","+"]],["shift + (",["opencurlybrace","opencurlybracket","{"]],["shift + )",["closecurlybrace","closecurlybracket","}"]],["shift + \\",["verticalbar","|"]],["shift + ;",["colon",":"]],["shift + '",["quotationmark",'"']],["shift + !,",["openanglebracket","<"]],["shift + .",["closeanglebracket",">"]],["shift + /",["questionmark","?"]]]};for(v=65;v<=90;v+=1){m.map[v]=String.fromCharCode(v+32);m.macros.push(["shift + "+String.fromCharCode(v+32)+", capslock + "+String.fromCharCode(v+32),[String.fromCharCode(v)]])}C("us",m);g("us");f();i.enable=f;i.disable=d;i.activeKeys=L;i.releaseKey=k;i.pressKey=J;i.on=t;i.clear=A;i.clear.key=c;i.locale=g;i.locale.register=C;i.macro=G;i.macro.remove=h;i.key={};i.key.name=I;i.key.code=z;i.combo={};i.combo.active=a;i.combo.parse=q;i.combo.stringify=y;return i;function f(){if(H.addEventListener){H.document.addEventListener("keydown",p,false);H.document.addEventListener("keyup",F,false);H.addEventListener("blur",E,false);H.addEventListener("webkitfullscreenchange",E,false);H.addEventListener("mozfullscreenchange",E,false)}else{if(H.attachEvent){H.document.attachEvent("onkeydown",p);H.document.attachEvent("onkeyup",F);H.attachEvent("onblur",E)}}}function d(){E();if(H.removeEventListener){H.document.removeEventListener("keydown",p,false);H.document.removeEventListener("keyup",F,false);H.removeEventListener("blur",E,false);H.removeEventListener("webkitfullscreenchange",E,false);H.removeEventListener("mozfullscreenchange",E,false)}else{if(H.detachEvent){H.document.detachEvent("onkeydown",p);H.document.detachEvent("onkeyup",F);H.detachEvent("onblur",E)}}}function E(N){l=[];r();j(N)}function p(O){var Q,N,P;Q=I(O.keyCode);if(Q.length<1){return}O.isRepeat=false;for(P=0;P<Q.length;P+=1){N=Q[P];if(L().indexOf(N)!=-1){O.isRepeat=true}J(N)}s();b(O)}function F(N){var P,O;P=I(N.keyCode);if(P.length<1){return}for(O=0;O<P.length;O+=1){k(P[O])}r();j(N)}function I(N){return u[N]||[]}function z(N){var O;for(O in u){if(!u.hasOwnProperty(O)){continue}if(u[O].indexOf(N)>-1){return O}}return false}function G(O,N){if(typeof O!=="string"&&(typeof O!=="object"||typeof O.push!=="function")){throw new Error("Cannot create macro. The combo must be a string or array.")}if(typeof N!=="object"||typeof N.push!=="function"){throw new Error("Cannot create macro. The injectedKeys must be an array.")}B.push([O,N])}function h(O){var N;if(typeof O!=="string"&&(typeof O!=="object"||typeof O.push!=="function")){throw new Error("Cannot remove macro. The combo must be a string or array.")}for(mI=0;mI<B.length;mI+=1){N=B[mI];if(D(O,N[0])){k(N[1]);B.splice(mI,1);break}}}function s(){var N,P,O;for(N=0;N<B.length;N+=1){P=q(B[N][0]);if(M.indexOf(B[N])===-1&&a(P)){M.push(B[N]);for(O=0;O<B[N][1].length;O+=1){J(B[N][1][O])}}}}function r(){var N,P,O;for(N=0;N<M.length;N+=1){P=q(M[N][0]);if(a(P)===false){for(O=0;O<M[N][1].length;O+=1){k(M[N][1][O])}M.splice(N,1);N-=1}}}function t(V,X,O){var R={},U,N=[],Q={},T,W;if(typeof V==="string"){V=q(V)}for(T=0;T<V.length;T+=1){U={};W=y([V[T]]);if(typeof W!=="string"){throw new Error("Failed to bind key combo. The key combo must be string.")}U.keyCombo=W;U.keyDownCallback=[];U.keyUpCallback=[];if(X){U.keyDownCallback.push(X)}if(O){U.keyUpCallback.push(O)}K.push(U);N.push(U)}R.clear=P;R.on=S;return R;function P(){var Y;for(Y=0;Y<N.length;Y+=1){K.splice(K.indexOf(N[Y]),1)}}function S(aa){var ac={},ad,ab,Z;if(typeof aa!=="string"){throw new Error("Cannot bind callback. The event name must be a string.")}if(aa!=="keyup"&&aa!=="keydown"){throw new Error('Cannot bind callback. The event name must be a "keyup" or "keydown".')}ad=Array.prototype.slice.apply(arguments,[1]);for(ab=0;ab<ad.length;ab+=1){if(typeof ad[ab]==="function"){if(aa==="keyup"){for(Z=0;Z<N.length;Z+=1){N[Z].keyUpCallback.push(ad[ab])}}else{if(aa==="keydown"){for(Z=0;Z<N.length;Z+=1){N[Z].keyDownCallback.push(ad[ab])}}}}}ac.clear=Y;return ac;function Y(){var af,ae;for(af=0;af<ad.length;af+=1){if(typeof ad[af]==="function"){if(aa==="keyup"){for(ae=0;ae<N.length;ae+=1){N[ae].keyUpCallback.splice(N[ae].keyUpCallback.indexOf(ad[af]),1)}}else{for(ae=0;ae<N.length;ae+=1){N[ae].keyDownCallback.splice(N[ae].keyDownCallback.indexOf(ad[af]),1)}}}}}}}function A(Q){var N,P,O;for(N=0;N<K.length;N+=1){P=K[N];if(D(Q,P.keyCombo)){K.splice(N,1);N-=1}}}function c(O){var N,P,Q;if(O){for(N=0;N<K.length;N+=1){Q=K[N];for(P=0;P<Q.keyCombo.length;P+=1){if(Q.keyCombo[P].indexOf(O)>-1){K.splice(N,1);N-=1;break}}}}else{K=[]}}function b(O){var V,X,U,N,Z,Q,R,T,Y,S,P=[],W;Z=[].concat(l);for(V=0;V<K.length;V+=1){W=x(K[V].keyCombo).length;if(!P[W]){P[W]=[]}P[W].push(K[V])}for(X=P.length-1;X>=0;X-=1){if(!P[X]){continue}for(V=0;V<P[X].length;V+=1){U=P[X][V];N=x(U.keyCombo);Y=true;for(T=0;T<N.length;T+=1){if(Z.indexOf(N[T])===-1){Y=false;break}}if(Y&&a(U.keyCombo)){n.push(U);for(T=0;T<N.length;T+=1){S=Z.indexOf(N[T]);if(S>-1){Z.splice(S,1);T-=1}}for(Q=0;Q<U.keyDownCallback.length;Q+=1){if(U.keyDownCallback[Q](O,L(),U.keyCombo)===false){R=true}}if(R===true){O.preventDefault();O.stopPropagation()}}}}}function j(Q){var N,P,R,O;for(N=0;N<n.length;N+=1){R=n[N];if(a(R.keyCombo)===false){for(P=0;P<R.keyUpCallback.length;P+=1){if(R.keyUpCallback[P](Q,L(),R.keyCombo)===false){O=true}}if(O===true){Q.preventDefault();Q.stopPropagation()}n.splice(N,1);N-=1}}}function D(Q,P){var O,N,R;Q=q(Q);P=q(P);if(Q.length!==P.length){return false}for(O=0;O<Q.length;O+=1){if(Q[O].length!==P[O].length){return false}for(N=0;N<Q[O].length;N+=1){if(Q[O][N].length!==P[O][N].length){return false}for(R=0;R<Q[O][N].length;R+=1){if(P[O][N].indexOf(Q[O][N][R])===-1){return false}}}}return true}function a(U){var R,O,Q,T,S=0,P,N;U=q(U);for(R=0;R<U.length;R+=1){N=true;S=0;for(O=0;O<U[R].length;O+=1){Q=[].concat(U[R][O]);for(T=S;T<l.length;T+=1){P=Q.indexOf(l[T]);if(P>-1){Q.splice(P,1);S=T}}if(Q.length!==0){N=false;break}}if(N){return true}}return false}function x(R){var O,N,Q,P=[];R=q(R);for(O=0;O<R.length;O+=1){for(N=0;N<R[O].length;N+=1){P=P.concat(R[O][N])}}return P}function q(T){var V=T,P=0,Q=0,S=false,O=false,W=[],N=[],R=[],U="";if(typeof T==="object"&&typeof T.push==="function"){return T}if(typeof T!=="string"){throw new Error('Cannot parse "keyCombo" because its type is "'+(typeof T)+'". It must be a "string".')}while(V.charAt(P)===" "){P+=1}while(true){if(V.charAt(P)===" "){while(V.charAt(P)===" "){P+=1}S=true}else{if(V.charAt(P)===","){if(Q||O){throw new Error("Failed to parse key combo. Unexpected , at character index "+P+".")}O=true;P+=1}else{if(V.charAt(P)==="+"){if(U.length){R.push(U);U=""}if(Q||O){throw new Error("Failed to parse key combo. Unexpected + at character index "+P+".")}Q=true;P+=1}else{if(V.charAt(P)===">"){if(U.length){R.push(U);U=""}if(R.length){N.push(R);R=[]}if(Q||O){throw new Error("Failed to parse key combo. Unexpected > at character index "+P+".")}Q=true;P+=1}else{if(P<V.length-1&&V.charAt(P)==="!"&&(V.charAt(P+1)===">"||V.charAt(P+1)===","||V.charAt(P+1)==="+")){U+=V.charAt(P+1);Q=false;S=false;O=false;P+=2}else{if(P<V.length&&V.charAt(P)!=="+"&&V.charAt(P)!==">"&&V.charAt(P)!==","&&V.charAt(P)!==" "){if(Q===false&&S===true||O===true){if(U.length){R.push(U);U=""}if(R.length){N.push(R);R=[]}if(N.length){W.push(N);N=[]}}Q=false;S=false;O=false;while(P<V.length&&V.charAt(P)!=="+"&&V.charAt(P)!==">"&&V.charAt(P)!==","&&V.charAt(P)!==" "){U+=V.charAt(P);P+=1}}else{P+=1;continue}}}}}}if(P>=V.length){if(U.length){R.push(U);U=""}if(R.length){N.push(R);R=[]}if(N.length){W.push(N);N=[]}break}}return W}function y(N){var Q,P,O=[];if(typeof N==="string"){return N}if(typeof N!=="object"||typeof N.push!=="function"){throw new Error("Cannot stringify key combo.")}for(Q=0;Q<N.length;Q+=1){O[Q]=[];for(P=0;P<N[Q].length;P+=1){O[Q][P]=N[Q][P].join(" + ")}O[Q]=O[Q].join(" > ")}return O.join(" ")}function L(){return[].concat(l)}function J(N){if(N.match(/\s/)){throw new Error("Cannot add key name "+N+" to active keys because it contains whitespace.")}if(l.indexOf(N)>-1){return}l.push(N)}function k(N){var O=z(N);if(O==="91"||O==="92"){l=[]}else{l.splice(l.indexOf(N),1)}}function C(O,N){if(typeof O!=="string"){throw new Error("Cannot register new locale. The locale name must be a string.")}if(typeof N!=="object"){throw new Error("Cannot register "+O+" locale. The locale map must be an object.")}if(typeof N.map!=="object"){throw new Error("Cannot register "+O+" locale. The locale map is invalid.")}if(!N.macros){N.macros=[]}w[O]=N}function g(N){if(N){if(typeof N!=="string"){throw new Error("Cannot set locale. The locale name must be a string.")}if(!w[N]){throw new Error("Cannot set locale to "+N+" because it does not exist. If you would like to submit a "+N+" locale map for KeyboardJS please submit it at https://github.com/RobertWHurst/KeyboardJS/issues.")}u=w[N].map;B=w[N].macros;o=N}return o}});
embedded/common/utility/js/select2.min.js CHANGED
@@ -1,7 +1,7 @@
1
  /*
2
- Copyright 2012 Igor Vaynberg
3
 
4
- Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
5
 
6
  This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
7
  General Public License version 2 (the "GPL License"). You may choose either license to govern your
@@ -18,5 +18,6 @@ or the GPL Licesnse is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CO
18
  either express or implied. See the Apache License and the GPL License for the specific language governing
19
  permissions and limitations under the Apache License and the GPL License.
20
  */
21
- !function(a){"undefined"==typeof a.fn.each2&&a.extend(a.fn,{each2:function(b){for(var c=a([0]),d=-1,e=this.length;++d<e&&(c.context=c[0]=this[d])&&b.call(c[0],d,c)!==!1;);return this}})}(jQuery),function(a,b){"use strict";function n(a){var b,c,d,e;if(!a||a.length<1)return a;for(b="",c=0,d=a.length;d>c;c++)e=a.charAt(c),b+=m[e]||e;return b}function o(a,b){for(var c=0,d=b.length;d>c;c+=1)if(q(a,b[c]))return c;return-1}function p(){var b=a(l);b.appendTo("body");var c={width:b.width()-b[0].clientWidth,height:b.height()-b[0].clientHeight};return b.remove(),c}function q(a,c){return a===c?!0:a===b||c===b?!1:null===a||null===c?!1:a.constructor===String?a+""==c+"":c.constructor===String?c+""==a+"":!1}function r(b,c){var d,e,f;if(null===b||b.length<1)return[];for(d=b.split(c),e=0,f=d.length;f>e;e+=1)d[e]=a.trim(d[e]);return d}function s(a){return a.outerWidth(!1)-a.width()}function t(c){var d="keyup-change-value";c.on("keydown",function(){a.data(c,d)===b&&a.data(c,d,c.val())}),c.on("keyup",function(){var e=a.data(c,d);e!==b&&c.val()!==e&&(a.removeData(c,d),c.trigger("keyup-change"))})}function u(c){c.on("mousemove",function(c){var d=i;(d===b||d.x!==c.pageX||d.y!==c.pageY)&&a(c.target).trigger("mousemove-filtered",c)})}function v(a,c,d){d=d||b;var e;return function(){var b=arguments;window.clearTimeout(e),e=window.setTimeout(function(){c.apply(d,b)},a)}}function w(a){var c,b=!1;return function(){return b===!1&&(c=a(),b=!0),c}}function x(a,b){var c=v(a,function(a){b.trigger("scroll-debounced",a)});b.on("scroll",function(a){o(a.target,b.get())>=0&&c(a)})}function y(a){a[0]!==document.activeElement&&window.setTimeout(function(){var d,b=a[0],c=a.val().length;a.focus(),a.is(":visible")&&b===document.activeElement&&(b.setSelectionRange?b.setSelectionRange(c,c):b.createTextRange&&(d=b.createTextRange(),d.collapse(!1),d.select()))},0)}function z(b){b=a(b)[0];var c=0,d=0;if("selectionStart"in b)c=b.selectionStart,d=b.selectionEnd-c;else if("selection"in document){b.focus();var e=document.selection.createRange();d=document.selection.createRange().text.length,e.moveStart("character",-b.value.length),c=e.text.length-d}return{offset:c,length:d}}function A(a){a.preventDefault(),a.stopPropagation()}function B(a){a.preventDefault(),a.stopImmediatePropagation()}function C(b){if(!h){var c=b[0].currentStyle||window.getComputedStyle(b[0],null);h=a(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:c.fontSize,fontFamily:c.fontFamily,fontStyle:c.fontStyle,fontWeight:c.fontWeight,letterSpacing:c.letterSpacing,textTransform:c.textTransform,whiteSpace:"nowrap"}),h.attr("class","select2-sizer"),a("body").append(h)}return h.text(b.val()),h.width()}function D(b,c,d){var e,g,f=[];e=b.attr("class"),e&&(e=""+e,a(e.split(" ")).each2(function(){0===this.indexOf("select2-")&&f.push(this)})),e=c.attr("class"),e&&(e=""+e,a(e.split(" ")).each2(function(){0!==this.indexOf("select2-")&&(g=d(this),g&&f.push(g))})),b.attr("class",f.join(" "))}function E(a,b,c,d){var e=n(a.toUpperCase()).indexOf(n(b.toUpperCase())),f=b.length;return 0>e?(c.push(d(a)),void 0):(c.push(d(a.substring(0,e))),c.push("<span class='select2-match'>"),c.push(d(a.substring(e,e+f))),c.push("</span>"),c.push(d(a.substring(e+f,a.length))),void 0)}function F(a){var b={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})}function G(c){var d,e=null,f=c.quietMillis||100,g=c.url,h=this;return function(i){window.clearTimeout(d),d=window.setTimeout(function(){var d=c.data,f=g,j=c.transport||a.fn.select2.ajaxDefaults.transport,k={type:c.type||"GET",cache:c.cache||!1,jsonpCallback:c.jsonpCallback||b,dataType:c.dataType||"json"},l=a.extend({},a.fn.select2.ajaxDefaults.params,k);d=d?d.call(h,i.term,i.page,i.context):null,f="function"==typeof f?f.call(h,i.term,i.page,i.context):f,e&&e.abort(),c.params&&(a.isFunction(c.params)?a.extend(l,c.params.call(h)):a.extend(l,c.params)),a.extend(l,{url:f,dataType:c.dataType,data:d,success:function(a){var b=c.results(a,i.page);i.callback(b)}}),e=j.call(h,l)},f)}}function H(b){var d,e,c=b,f=function(a){return""+a.text};a.isArray(c)&&(e=c,c={results:e}),a.isFunction(c)===!1&&(e=c,c=function(){return e});var g=c();return g.text&&(f=g.text,a.isFunction(f)||(d=g.text,f=function(a){return a[d]})),function(b){var g,d=b.term,e={results:[]};return""===d?(b.callback(c()),void 0):(g=function(c,e){var h,i;if(c=c[0],c.children){h={};for(i in c)c.hasOwnProperty(i)&&(h[i]=c[i]);h.children=[],a(c.children).each2(function(a,b){g(b,h.children)}),(h.children.length||b.matcher(d,f(h),c))&&e.push(h)}else b.matcher(d,f(c),c)&&e.push(c)},a(c().results).each2(function(a,b){g(b,e.results)}),b.callback(e),void 0)}}function I(c){var d=a.isFunction(c);return function(e){var f=e.term,g={results:[]};a(d?c():c).each(function(){var a=this.text!==b,c=a?this.text:this;(""===f||e.matcher(f,c))&&g.results.push(a?this:{id:this,text:this})}),e.callback(g)}}function J(b,c){if(a.isFunction(b))return!0;if(!b)return!1;throw new Error(c+" must be a function or a falsy value")}function K(b){return a.isFunction(b)?b():b}function L(b){var c=0;return a.each(b,function(a,b){b.children?c+=L(b.children):c++}),c}function M(a,c,d,e){var h,i,j,k,l,f=a,g=!1;if(!e.createSearchChoice||!e.tokenSeparators||e.tokenSeparators.length<1)return b;for(;;){for(i=-1,j=0,k=e.tokenSeparators.length;k>j&&(l=e.tokenSeparators[j],i=a.indexOf(l),!(i>=0));j++);if(0>i)break;if(h=a.substring(0,i),a=a.substring(i+l.length),h.length>0&&(h=e.createSearchChoice.call(this,h,c),h!==b&&null!==h&&e.id(h)!==b&&null!==e.id(h))){for(g=!1,j=0,k=c.length;k>j;j++)if(q(e.id(h),e.id(c[j]))){g=!0;break}g||d(h)}}return f!==a?a:void 0}function N(b,c){var d=function(){};return d.prototype=new b,d.prototype.constructor=d,d.prototype.parent=b.prototype,d.prototype=a.extend(d.prototype,c),d}if(window.Select2===b){var c,d,e,f,g,h,j,k,i={x:0,y:0},c={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(a){switch(a=a.which?a.which:a){case c.LEFT:case c.RIGHT:case c.UP:case c.DOWN:return!0}return!1},isControl:function(a){var b=a.which;switch(b){case c.SHIFT:case c.CTRL:case c.ALT:return!0}return a.metaKey?!0:!1},isFunctionKey:function(a){return a=a.which?a.which:a,a>=112&&123>=a}},l="<div class='select2-measure-scrollbar'></div>",m={"\u24b6":"A","\uff21":"A","\xc0":"A","\xc1":"A","\xc2":"A","\u1ea6":"A","\u1ea4":"A","\u1eaa":"A","\u1ea8":"A","\xc3":"A","\u0100":"A","\u0102":"A","\u1eb0":"A","\u1eae":"A","\u1eb4":"A","\u1eb2":"A","\u0226":"A","\u01e0":"A","\xc4":"A","\u01de":"A","\u1ea2":"A","\xc5":"A","\u01fa":"A","\u01cd":"A","\u0200":"A","\u0202":"A","\u1ea0":"A","\u1eac":"A","\u1eb6":"A","\u1e00":"A","\u0104":"A","\u023a":"A","\u2c6f":"A","\ua732":"AA","\xc6":"AE","\u01fc":"AE","\u01e2":"AE","\ua734":"AO","\ua736":"AU","\ua738":"AV","\ua73a":"AV","\ua73c":"AY","\u24b7":"B","\uff22":"B","\u1e02":"B","\u1e04":"B","\u1e06":"B","\u0243":"B","\u0182":"B","\u0181":"B","\u24b8":"C","\uff23":"C","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\xc7":"C","\u1e08":"C","\u0187":"C","\u023b":"C","\ua73e":"C","\u24b9":"D","\uff24":"D","\u1e0a":"D","\u010e":"D","\u1e0c":"D","\u1e10":"D","\u1e12":"D","\u1e0e":"D","\u0110":"D","\u018b":"D","\u018a":"D","\u0189":"D","\ua779":"D","\u01f1":"DZ","\u01c4":"DZ","\u01f2":"Dz","\u01c5":"Dz","\u24ba":"E","\uff25":"E","\xc8":"E","\xc9":"E","\xca":"E","\u1ec0":"E","\u1ebe":"E","\u1ec4":"E","\u1ec2":"E","\u1ebc":"E","\u0112":"E","\u1e14":"E","\u1e16":"E","\u0114":"E","\u0116":"E","\xcb":"E","\u1eba":"E","\u011a":"E","\u0204":"E","\u0206":"E","\u1eb8":"E","\u1ec6":"E","\u0228":"E","\u1e1c":"E","\u0118":"E","\u1e18":"E","\u1e1a":"E","\u0190":"E","\u018e":"E","\u24bb":"F","\uff26":"F","\u1e1e":"F","\u0191":"F","\ua77b":"F","\u24bc":"G","\uff27":"G","\u01f4":"G","\u011c":"G","\u1e20":"G","\u011e":"G","\u0120":"G","\u01e6":"G","\u0122":"G","\u01e4":"G","\u0193":"G","\ua7a0":"G","\ua77d":"G","\ua77e":"G","\u24bd":"H","\uff28":"H","\u0124":"H","\u1e22":"H","\u1e26":"H","\u021e":"H","\u1e24":"H","\u1e28":"H","\u1e2a":"H","\u0126":"H","\u2c67":"H","\u2c75":"H","\ua78d":"H","\u24be":"I","\uff29":"I","\xcc":"I","\xcd":"I","\xce":"I","\u0128":"I","\u012a":"I","\u012c":"I","\u0130":"I","\xcf":"I","\u1e2e":"I","\u1ec8":"I","\u01cf":"I","\u0208":"I","\u020a":"I","\u1eca":"I","\u012e":"I","\u1e2c":"I","\u0197":"I","\u24bf":"J","\uff2a":"J","\u0134":"J","\u0248":"J","\u24c0":"K","\uff2b":"K","\u1e30":"K","\u01e8":"K","\u1e32":"K","\u0136":"K","\u1e34":"K","\u0198":"K","\u2c69":"K","\ua740":"K","\ua742":"K","\ua744":"K","\ua7a2":"K","\u24c1":"L","\uff2c":"L","\u013f":"L","\u0139":"L","\u013d":"L","\u1e36":"L","\u1e38":"L","\u013b":"L","\u1e3c":"L","\u1e3a":"L","\u0141":"L","\u023d":"L","\u2c62":"L","\u2c60":"L","\ua748":"L","\ua746":"L","\ua780":"L","\u01c7":"LJ","\u01c8":"Lj","\u24c2":"M","\uff2d":"M","\u1e3e":"M","\u1e40":"M","\u1e42":"M","\u2c6e":"M","\u019c":"M","\u24c3":"N","\uff2e":"N","\u01f8":"N","\u0143":"N","\xd1":"N","\u1e44":"N","\u0147":"N","\u1e46":"N","\u0145":"N","\u1e4a":"N","\u1e48":"N","\u0220":"N","\u019d":"N","\ua790":"N","\ua7a4":"N","\u01ca":"NJ","\u01cb":"Nj","\u24c4":"O","\uff2f":"O","\xd2":"O","\xd3":"O","\xd4":"O","\u1ed2":"O","\u1ed0":"O","\u1ed6":"O","\u1ed4":"O","\xd5":"O","\u1e4c":"O","\u022c":"O","\u1e4e":"O","\u014c":"O","\u1e50":"O","\u1e52":"O","\u014e":"O","\u022e":"O","\u0230":"O","\xd6":"O","\u022a":"O","\u1ece":"O","\u0150":"O","\u01d1":"O","\u020c":"O","\u020e":"O","\u01a0":"O","\u1edc":"O","\u1eda":"O","\u1ee0":"O","\u1ede":"O","\u1ee2":"O","\u1ecc":"O","\u1ed8":"O","\u01ea":"O","\u01ec":"O","\xd8":"O","\u01fe":"O","\u0186":"O","\u019f":"O","\ua74a":"O","\ua74c":"O","\u01a2":"OI","\ua74e":"OO","\u0222":"OU","\u24c5":"P","\uff30":"P","\u1e54":"P","\u1e56":"P","\u01a4":"P","\u2c63":"P","\ua750":"P","\ua752":"P","\ua754":"P","\u24c6":"Q","\uff31":"Q","\ua756":"Q","\ua758":"Q","\u024a":"Q","\u24c7":"R","\uff32":"R","\u0154":"R","\u1e58":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1e5a":"R","\u1e5c":"R","\u0156":"R","\u1e5e":"R","\u024c":"R","\u2c64":"R","\ua75a":"R","\ua7a6":"R","\ua782":"R","\u24c8":"S","\uff33":"S","\u1e9e":"S","\u015a":"S","\u1e64":"S","\u015c":"S","\u1e60":"S","\u0160":"S","\u1e66":"S","\u1e62":"S","\u1e68":"S","\u0218":"S","\u015e":"S","\u2c7e":"S","\ua7a8":"S","\ua784":"S","\u24c9":"T","\uff34":"T","\u1e6a":"T","\u0164":"T","\u1e6c":"T","\u021a":"T","\u0162":"T","\u1e70":"T","\u1e6e":"T","\u0166":"T","\u01ac":"T","\u01ae":"T","\u023e":"T","\ua786":"T","\ua728":"TZ","\u24ca":"U","\uff35":"U","\xd9":"U","\xda":"U","\xdb":"U","\u0168":"U","\u1e78":"U","\u016a":"U","\u1e7a":"U","\u016c":"U","\xdc":"U","\u01db":"U","\u01d7":"U","\u01d5":"U","\u01d9":"U","\u1ee6":"U","\u016e":"U","\u0170":"U","\u01d3":"U","\u0214":"U","\u0216":"U","\u01af":"U","\u1eea":"U","\u1ee8":"U","\u1eee":"U","\u1eec":"U","\u1ef0":"U","\u1ee4":"U","\u1e72":"U","\u0172":"U","\u1e76":"U","\u1e74":"U","\u0244":"U","\u24cb":"V","\uff36":"V","\u1e7c":"V","\u1e7e":"V","\u01b2":"V","\ua75e":"V","\u0245":"V","\ua760":"VY","\u24cc":"W","\uff37":"W","\u1e80":"W","\u1e82":"W","\u0174":"W","\u1e86":"W","\u1e84":"W","\u1e88":"W","\u2c72":"W","\u24cd":"X","\uff38":"X","\u1e8a":"X","\u1e8c":"X","\u24ce":"Y","\uff39":"Y","\u1ef2":"Y","\xdd":"Y","\u0176":"Y","\u1ef8":"Y","\u0232":"Y","\u1e8e":"Y","\u0178":"Y","\u1ef6":"Y","\u1ef4":"Y","\u01b3":"Y","\u024e":"Y","\u1efe":"Y","\u24cf":"Z","\uff3a":"Z","\u0179":"Z","\u1e90":"Z","\u017b":"Z","\u017d":"Z","\u1e92":"Z","\u1e94":"Z","\u01b5":"Z","\u0224":"Z","\u2c7f":"Z","\u2c6b":"Z","\ua762":"Z","\u24d0":"a","\uff41":"a","\u1e9a":"a","\xe0":"a","\xe1":"a","\xe2":"a","\u1ea7":"a","\u1ea5":"a","\u1eab":"a","\u1ea9":"a","\xe3":"a","\u0101":"a","\u0103":"a","\u1eb1":"a","\u1eaf":"a","\u1eb5":"a","\u1eb3":"a","\u0227":"a","\u01e1":"a","\xe4":"a","\u01df":"a","\u1ea3":"a","\xe5":"a","\u01fb":"a","\u01ce":"a","\u0201":"a","\u0203":"a","\u1ea1":"a","\u1ead":"a","\u1eb7":"a","\u1e01":"a","\u0105":"a","\u2c65":"a","\u0250":"a","\ua733":"aa","\xe6":"ae","\u01fd":"ae","\u01e3":"ae","\ua735":"ao","\ua737":"au","\ua739":"av","\ua73b":"av","\ua73d":"ay","\u24d1":"b","\uff42":"b","\u1e03":"b","\u1e05":"b","\u1e07":"b","\u0180":"b","\u0183":"b","\u0253":"b","\u24d2":"c","\uff43":"c","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\xe7":"c","\u1e09":"c","\u0188":"c","\u023c":"c","\ua73f":"c","\u2184":"c","\u24d3":"d","\uff44":"d","\u1e0b":"d","\u010f":"d","\u1e0d":"d","\u1e11":"d","\u1e13":"d","\u1e0f":"d","\u0111":"d","\u018c":"d","\u0256":"d","\u0257":"d","\ua77a":"d","\u01f3":"dz","\u01c6":"dz","\u24d4":"e","\uff45":"e","\xe8":"e","\xe9":"e","\xea":"e","\u1ec1":"e","\u1ebf":"e","\u1ec5":"e","\u1ec3":"e","\u1ebd":"e","\u0113":"e","\u1e15":"e","\u1e17":"e","\u0115":"e","\u0117":"e","\xeb":"e","\u1ebb":"e","\u011b":"e","\u0205":"e","\u0207":"e","\u1eb9":"e","\u1ec7":"e","\u0229":"e","\u1e1d":"e","\u0119":"e","\u1e19":"e","\u1e1b":"e","\u0247":"e","\u025b":"e","\u01dd":"e","\u24d5":"f","\uff46":"f","\u1e1f":"f","\u0192":"f","\ua77c":"f","\u24d6":"g","\uff47":"g","\u01f5":"g","\u011d":"g","\u1e21":"g","\u011f":"g","\u0121":"g","\u01e7":"g","\u0123":"g","\u01e5":"g","\u0260":"g","\ua7a1":"g","\u1d79":"g","\ua77f":"g","\u24d7":"h","\uff48":"h","\u0125":"h","\u1e23":"h","\u1e27":"h","\u021f":"h","\u1e25":"h","\u1e29":"h","\u1e2b":"h","\u1e96":"h","\u0127":"h","\u2c68":"h","\u2c76":"h","\u0265":"h","\u0195":"hv","\u24d8":"i","\uff49":"i","\xec":"i","\xed":"i","\xee":"i","\u0129":"i","\u012b":"i","\u012d":"i","\xef":"i","\u1e2f":"i","\u1ec9":"i","\u01d0":"i","\u0209":"i","\u020b":"i","\u1ecb":"i","\u012f":"i","\u1e2d":"i","\u0268":"i","\u0131":"i","\u24d9":"j","\uff4a":"j","\u0135":"j","\u01f0":"j","\u0249":"j","\u24da":"k","\uff4b":"k","\u1e31":"k","\u01e9":"k","\u1e33":"k","\u0137":"k","\u1e35":"k","\u0199":"k","\u2c6a":"k","\ua741":"k","\ua743":"k","\ua745":"k","\ua7a3":"k","\u24db":"l","\uff4c":"l","\u0140":"l","\u013a":"l","\u013e":"l","\u1e37":"l","\u1e39":"l","\u013c":"l","\u1e3d":"l","\u1e3b":"l","\u017f":"l","\u0142":"l","\u019a":"l","\u026b":"l","\u2c61":"l","\ua749":"l","\ua781":"l","\ua747":"l","\u01c9":"lj","\u24dc":"m","\uff4d":"m","\u1e3f":"m","\u1e41":"m","\u1e43":"m","\u0271":"m","\u026f":"m","\u24dd":"n","\uff4e":"n","\u01f9":"n","\u0144":"n","\xf1":"n","\u1e45":"n","\u0148":"n","\u1e47":"n","\u0146":"n","\u1e4b":"n","\u1e49":"n","\u019e":"n","\u0272":"n","\u0149":"n","\ua791":"n","\ua7a5":"n","\u01cc":"nj","\u24de":"o","\uff4f":"o","\xf2":"o","\xf3":"o","\xf4":"o","\u1ed3":"o","\u1ed1":"o","\u1ed7":"o","\u1ed5":"o","\xf5":"o","\u1e4d":"o","\u022d":"o","\u1e4f":"o","\u014d":"o","\u1e51":"o","\u1e53":"o","\u014f":"o","\u022f":"o","\u0231":"o","\xf6":"o","\u022b":"o","\u1ecf":"o","\u0151":"o","\u01d2":"o","\u020d":"o","\u020f":"o","\u01a1":"o","\u1edd":"o","\u1edb":"o","\u1ee1":"o","\u1edf":"o","\u1ee3":"o","\u1ecd":"o","\u1ed9":"o","\u01eb":"o","\u01ed":"o","\xf8":"o","\u01ff":"o","\u0254":"o","\ua74b":"o","\ua74d":"o","\u0275":"o","\u01a3":"oi","\u0223":"ou","\ua74f":"oo","\u24df":"p","\uff50":"p","\u1e55":"p","\u1e57":"p","\u01a5":"p","\u1d7d":"p","\ua751":"p","\ua753":"p","\ua755":"p","\u24e0":"q","\uff51":"q","\u024b":"q","\ua757":"q","\ua759":"q","\u24e1":"r","\uff52":"r","\u0155":"r","\u1e59":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1e5b":"r","\u1e5d":"r","\u0157":"r","\u1e5f":"r","\u024d":"r","\u027d":"r","\ua75b":"r","\ua7a7":"r","\ua783":"r","\u24e2":"s","\uff53":"s","\xdf":"s","\u015b":"s","\u1e65":"s","\u015d":"s","\u1e61":"s","\u0161":"s","\u1e67":"s","\u1e63":"s","\u1e69":"s","\u0219":"s","\u015f":"s","\u023f":"s","\ua7a9":"s","\ua785":"s","\u1e9b":"s","\u24e3":"t","\uff54":"t","\u1e6b":"t","\u1e97":"t","\u0165":"t","\u1e6d":"t","\u021b":"t","\u0163":"t","\u1e71":"t","\u1e6f":"t","\u0167":"t","\u01ad":"t","\u0288":"t","\u2c66":"t","\ua787":"t","\ua729":"tz","\u24e4":"u","\uff55":"u","\xf9":"u","\xfa":"u","\xfb":"u","\u0169":"u","\u1e79":"u","\u016b":"u","\u1e7b":"u","\u016d":"u","\xfc":"u","\u01dc":"u","\u01d8":"u","\u01d6":"u","\u01da":"u","\u1ee7":"u","\u016f":"u","\u0171":"u","\u01d4":"u","\u0215":"u","\u0217":"u","\u01b0":"u","\u1eeb":"u","\u1ee9":"u","\u1eef":"u","\u1eed":"u","\u1ef1":"u","\u1ee5":"u","\u1e73":"u","\u0173":"u","\u1e77":"u","\u1e75":"u","\u0289":"u","\u24e5":"v","\uff56":"v","\u1e7d":"v","\u1e7f":"v","\u028b":"v","\ua75f":"v","\u028c":"v","\ua761":"vy","\u24e6":"w","\uff57":"w","\u1e81":"w","\u1e83":"w","\u0175":"w","\u1e87":"w","\u1e85":"w","\u1e98":"w","\u1e89":"w","\u2c73":"w","\u24e7":"x","\uff58":"x","\u1e8b":"x","\u1e8d":"x","\u24e8":"y","\uff59":"y","\u1ef3":"y","\xfd":"y","\u0177":"y","\u1ef9":"y","\u0233":"y","\u1e8f":"y","\xff":"y","\u1ef7":"y","\u1e99":"y","\u1ef5":"y","\u01b4":"y","\u024f":"y","\u1eff":"y","\u24e9":"z","\uff5a":"z","\u017a":"z","\u1e91":"z","\u017c":"z","\u017e":"z","\u1e93":"z","\u1e95":"z","\u01b6":"z","\u0225":"z","\u0240":"z","\u2c6c":"z","\ua763":"z"};j=a(document),g=function(){var a=1;return function(){return a++}}(),j.on("mousemove",function(a){i.x=a.pageX,i.y=a.pageY}),d=N(Object,{bind:function(a){var b=this;return function(){a.apply(b,arguments)}},init:function(c){var d,e,f=".select2-results";this.opts=c=this.prepareOpts(c),this.id=c.id,c.element.data("select2")!==b&&null!==c.element.data("select2")&&c.element.data("select2").destroy(),this.container=this.createContainer(),this.containerId="s2id_"+(c.element.attr("id")||"autogen"+g()),this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.body=w(function(){return c.element.closest("body")}),D(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.attr("style",c.element.attr("style")),this.container.css(K(c.containerCss)),this.container.addClass(K(c.containerCssClass)),this.elementTabIndex=this.opts.element.attr("tabindex"),this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",A),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),D(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(K(c.dropdownCssClass)),this.dropdown.data("select2",this),this.dropdown.on("click",A),this.results=d=this.container.find(f),this.search=e=this.container.find("input.select2-input"),this.queryCount=0,this.resultsPage=0,this.context=null,this.initContainer(),this.container.on("click",A),u(this.results),this.dropdown.on("mousemove-filtered touchstart touchmove touchend",f,this.bind(this.highlightUnderEvent)),x(80,this.results),this.dropdown.on("scroll-debounced",f,this.bind(this.loadMoreIfNeeded)),a(this.container).on("change",".select2-input",function(a){a.stopPropagation()}),a(this.dropdown).on("change",".select2-input",function(a){a.stopPropagation()}),a.fn.mousewheel&&d.mousewheel(function(a,b,c,e){var f=d.scrollTop();e>0&&0>=f-e?(d.scrollTop(0),A(a)):0>e&&d.get(0).scrollHeight-d.scrollTop()+e<=d.height()&&(d.scrollTop(d.get(0).scrollHeight-d.height()),A(a))}),t(e),e.on("keyup-change input paste",this.bind(this.updateResults)),e.on("focus",function(){e.addClass("select2-focused")}),e.on("blur",function(){e.removeClass("select2-focused")}),this.dropdown.on("mouseup",f,this.bind(function(b){a(b.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(b),this.selectHighlighted(b))})),this.dropdown.on("click mouseup mousedown",function(a){a.stopPropagation()}),a.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==c.maximumInputLength&&this.search.attr("maxlength",c.maximumInputLength);var h=c.element.prop("disabled");h===b&&(h=!1),this.enable(!h);var i=c.element.prop("readonly");i===b&&(i=!1),this.readonly(i),k=k||p(),this.autofocus=c.element.prop("autofocus"),c.element.prop("autofocus",!1),this.autofocus&&this.focus(),this.nextSearchTerm=b},destroy:function(){var a=this.opts.element,c=a.data("select2");this.close(),this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),c!==b&&(c.container.remove(),c.dropdown.remove(),a.removeClass("select2-offscreen").removeData("select2").off(".select2").prop("autofocus",this.autofocus||!1),this.elementTabIndex?a.attr({tabindex:this.elementTabIndex}):a.removeAttr("tabindex"),a.show())},optionToData:function(a){return a.is("option")?{id:a.prop("value"),text:a.text(),element:a.get(),css:a.attr("class"),disabled:a.prop("disabled"),locked:q(a.attr("locked"),"locked")||q(a.data("locked"),!0)}:a.is("optgroup")?{text:a.attr("label"),children:[],element:a.get(),css:a.attr("class")}:void 0},prepareOpts:function(c){var d,e,f,g,h=this;if(d=c.element,"select"===d.get(0).tagName.toLowerCase()&&(this.select=e=c.element),e&&a.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in c)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}),c=a.extend({},{populateResults:function(d,e,f){var g,i=this.opts.id;g=function(d,e,j){var k,l,m,n,o,p,q,r,s,t;for(d=c.sortResults(d,e,f),k=0,l=d.length;l>k;k+=1)m=d[k],o=m.disabled===!0,n=!o&&i(m)!==b,p=m.children&&m.children.length>0,q=a("<li></li>"),q.addClass("select2-results-dept-"+j),q.addClass("select2-result"),q.addClass(n?"select2-result-selectable":"select2-result-unselectable"),o&&q.addClass("select2-disabled"),p&&q.addClass("select2-result-with-children"),q.addClass(h.opts.formatResultCssClass(m)),r=a(document.createElement("div")),r.addClass("select2-result-label"),t=c.formatResult(m,r,f,h.opts.escapeMarkup),t!==b&&r.html(t),q.append(r),p&&(s=a("<ul></ul>"),s.addClass("select2-result-sub"),g(m.children,s,j+1),q.append(s)),q.data("select2-data",m),e.append(q)},g(e,d,0)}},a.fn.select2.defaults,c),"function"!=typeof c.id&&(f=c.id,c.id=function(a){return a[f]}),a.isArray(c.element.data("select2Tags"))){if("tags"in c)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+c.element.attr("id");c.tags=c.element.data("select2Tags")}if(e?(c.query=this.bind(function(a){var f,g,i,c={results:[],more:!1},e=a.term;i=function(b,c){var d;b.is("option")?a.matcher(e,b.text(),b)&&c.push(h.optionToData(b)):b.is("optgroup")&&(d=h.optionToData(b),b.children().each2(function(a,b){i(b,d.children)}),d.children.length>0&&c.push(d))},f=d.children(),this.getPlaceholder()!==b&&f.length>0&&(g=this.getPlaceholderOption(),g&&(f=f.not(g))),f.each2(function(a,b){i(b,c.results)}),a.callback(c)}),c.id=function(a){return a.id},c.formatResultCssClass=function(a){return a.css}):"query"in c||("ajax"in c?(g=c.element.data("ajax-url"),g&&g.length>0&&(c.ajax.url=g),c.query=G.call(c.element,c.ajax)):"data"in c?c.query=H(c.data):"tags"in c&&(c.query=I(c.tags),c.createSearchChoice===b&&(c.createSearchChoice=function(b){return{id:a.trim(b),text:a.trim(b)}}),c.initSelection===b&&(c.initSelection=function(b,d){var e=[];a(r(b.val(),c.separator)).each(function(){var b={id:this,text:this},d=c.tags;a.isFunction(d)&&(d=d()),a(d).each(function(){return q(this.id,b.id)?(b=this,!1):void 0}),e.push(b)}),d(e)}))),"function"!=typeof c.query)throw"query function not defined for Select2 "+c.element.attr("id");return c},monitorSource:function(){var c,d,a=this.opts.element;a.on("change.select2",this.bind(function(){this.opts.element.data("select2-change-triggered")!==!0&&this.initSelection()})),c=this.bind(function(){var c=a.prop("disabled");c===b&&(c=!1),this.enable(!c);var d=a.prop("readonly");d===b&&(d=!1),this.readonly(d),D(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.addClass(K(this.opts.containerCssClass)),D(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(K(this.opts.dropdownCssClass))}),a.on("propertychange.select2",c),this.mutationCallback===b&&(this.mutationCallback=function(a){a.forEach(c)}),d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,d!==b&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new d(this.mutationCallback),this.propertyObserver.observe(a.get(0),{attributes:!0,subtree:!1}))},triggerSelect:function(b){var c=a.Event("select2-selecting",{val:this.id(b),object:b});return this.opts.element.trigger(c),!c.isDefaultPrevented()},triggerChange:function(b){b=b||{},b=a.extend({},b,{type:"change",val:this.val()}),this.opts.element.data("select2-change-triggered",!0),this.opts.element.trigger(b),this.opts.element.data("select2-change-triggered",!1),this.opts.element.click(),this.opts.blurOnChange&&this.opts.element.blur()},isInterfaceEnabled:function(){return this.enabledInterface===!0},enableInterface:function(){var a=this._enabled&&!this._readonly,b=!a;return a===this.enabledInterface?!1:(this.container.toggleClass("select2-container-disabled",b),this.close(),this.enabledInterface=a,!0)},enable:function(a){a===b&&(a=!0),this._enabled!==a&&(this._enabled=a,this.opts.element.prop("disabled",!a),this.enableInterface())},disable:function(){this.enable(!1)},readonly:function(a){return a===b&&(a=!1),this._readonly===a?!1:(this._readonly=a,this.opts.element.prop("readonly",a),this.enableInterface(),!0)},opened:function(){return this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var t,u,v,w,x,b=this.dropdown,c=this.container.offset(),d=this.container.outerHeight(!1),e=this.container.outerWidth(!1),f=b.outerHeight(!1),g=a(window),h=g.width(),i=g.height(),j=g.scrollLeft()+h,l=g.scrollTop()+i,m=c.top+d,n=c.left,o=l>=m+f,p=c.top-f>=this.body().scrollTop(),q=b.outerWidth(!1),r=j>=n+q,s=b.hasClass("select2-drop-above");s?(u=!0,!p&&o&&(v=!0,u=!1)):(u=!1,!o&&p&&(v=!0,u=!0)),v&&(b.hide(),c=this.container.offset(),d=this.container.outerHeight(!1),e=this.container.outerWidth(!1),f=b.outerHeight(!1),j=g.scrollLeft()+h,l=g.scrollTop()+i,m=c.top+d,n=c.left,q=b.outerWidth(!1),r=j>=n+q,b.show()),this.opts.dropdownAutoWidth?(x=a(".select2-results",b)[0],b.addClass("select2-drop-auto-width"),b.css("width",""),q=b.outerWidth(!1)+(x.scrollHeight===x.clientHeight?0:k.width),q>e?e=q:q=e,r=j>=n+q):this.container.removeClass("select2-drop-auto-width"),"static"!==this.body().css("position")&&(t=this.body().offset(),m-=t.top,n-=t.left),r||(n=c.left+e-q),w={left:n,width:e},u?(w.bottom=i-c.top,w.top="auto",this.container.addClass("select2-drop-above"),b.addClass("select2-drop-above")):(w.top=m,w.bottom="auto",this.container.removeClass("select2-drop-above"),b.removeClass("select2-drop-above")),w=a.extend(w,K(this.opts.dropdownCss)),b.css(w)},shouldOpen:function(){var b;return this.opened()?!1:this._enabled===!1||this._readonly===!0?!1:(b=a.Event("select2-opening"),this.opts.element.trigger(b),!b.isDefaultPrevented())},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above")},open:function(){return this.shouldOpen()?(this.opening(),!0):!1},opening:function(){var f,b=this.containerId,c="scroll."+b,d="resize."+b,e="orientationchange."+b;this.container.addClass("select2-dropdown-open").addClass("select2-container-active"),this.clearDropdownAlignmentPreference(),this.dropdown[0]!==this.body().children().last()[0]&&this.dropdown.detach().appendTo(this.body()),f=a("#select2-drop-mask"),0==f.length&&(f=a(document.createElement("div")),f.attr("id","select2-drop-mask").attr("class","select2-drop-mask"),f.hide(),f.appendTo(this.body()),f.on("mousedown touchstart click",function(b){var d,c=a("#select2-drop");c.length>0&&(d=c.data("select2"),d.opts.selectOnBlur&&d.selectHighlighted({noFocus:!0}),d.close({focus:!0}),b.preventDefault(),b.stopPropagation())})),this.dropdown.prev()[0]!==f[0]&&this.dropdown.before(f),a("#select2-drop").removeAttr("id"),this.dropdown.attr("id","select2-drop"),f.show(),this.positionDropdown(),this.dropdown.show(),this.positionDropdown(),this.dropdown.addClass("select2-drop-active");var g=this;this.container.parents().add(window).each(function(){a(this).on(d+" "+c+" "+e,function(){g.positionDropdown()})})},close:function(){if(this.opened()){var b=this.containerId,c="scroll."+b,d="resize."+b,e="orientationchange."+b;this.container.parents().add(window).each(function(){a(this).off(c).off(d).off(e)}),this.clearDropdownAlignmentPreference(),a("#select2-drop-mask").hide(),this.dropdown.removeAttr("id"),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active"),this.results.empty(),this.clearSearch(),this.search.removeClass("select2-active"),this.opts.element.trigger(a.Event("select2-close"))}},externalSearch:function(a){this.open(),this.search.val(a),this.updateResults(!1)},clearSearch:function(){},getMaximumSelectionSize:function(){return K(this.opts.maximumSelectionSize)},ensureHighlightVisible:function(){var c,d,e,f,g,h,i,b=this.results;if(d=this.highlight(),!(0>d)){if(0==d)return b.scrollTop(0),void 0;c=this.findHighlightableChoices().find(".select2-result-label"),e=a(c[d]),f=e.offset().top+e.outerHeight(!0),d===c.length-1&&(i=b.find("li.select2-more-results"),i.length>0&&(f=i.offset().top+i.outerHeight(!0))),g=b.offset().top+b.outerHeight(!0),f>g&&b.scrollTop(b.scrollTop()+(f-g)),h=e.offset().top-b.offset().top,0>h&&"none"!=e.css("display")&&b.scrollTop(b.scrollTop()+h)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled, .select2-selected)")},moveHighlight:function(b){for(var c=this.findHighlightableChoices(),d=this.highlight();d>-1&&d<c.length;){d+=b;var e=a(c[d]);if(e.hasClass("select2-result-selectable")&&!e.hasClass("select2-disabled")&&!e.hasClass("select2-selected")){this.highlight(d);break}}},highlight:function(b){var d,e,c=this.findHighlightableChoices();return 0===arguments.length?o(c.filter(".select2-highlighted")[0],c.get()):(b>=c.length&&(b=c.length-1),0>b&&(b=0),this.removeHighlight(),d=a(c[b]),d.addClass("select2-highlighted"),this.ensureHighlightVisible(),e=d.data("select2-data"),e&&this.opts.element.trigger({type:"select2-highlight",val:this.id(e),choice:e}),void 0)},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(b){var c=a(b.target).closest(".select2-result-selectable");if(c.length>0&&!c.is(".select2-highlighted")){var d=this.findHighlightableChoices();this.highlight(d.index(c))}else 0==c.length&&this.removeHighlight()},loadMoreIfNeeded:function(){var c,a=this.results,b=a.find("li.select2-more-results"),d=this.resultsPage+1,e=this,f=this.search.val(),g=this.context;0!==b.length&&(c=b.offset().top-a.offset().top-a.height(),c<=this.opts.loadMorePadding&&(b.addClass("select2-active"),this.opts.query({element:this.opts.element,term:f,page:d,context:g,matcher:this.opts.matcher,callback:this.bind(function(c){e.opened()&&(e.opts.populateResults.call(this,a,c.results,{term:f,page:d,context:g}),e.postprocessResults(c,!1,!1),c.more===!0?(b.detach().appendTo(a).text(e.opts.formatLoadMore(d+1)),window.setTimeout(function(){e.loadMoreIfNeeded()},10)):b.remove(),e.positionDropdown(),e.resultsPage=d,e.context=c.context,this.opts.element.trigger({type:"select2-loaded",items:c}))})})))},tokenize:function(){},updateResults:function(c){function m(){d.removeClass("select2-active"),h.positionDropdown()}function n(a){e.html(a),m()}var g,i,l,d=this.search,e=this.results,f=this.opts,h=this,j=d.val(),k=a.data(this.container,"select2-last-term");if((c===!0||!k||!q(j,k))&&(a.data(this.container,"select2-last-term",j),c===!0||this.showSearchInput!==!1&&this.opened())){l=++this.queryCount;var o=this.getMaximumSelectionSize();if(o>=1&&(g=this.data(),a.isArray(g)&&g.length>=o&&J(f.formatSelectionTooBig,"formatSelectionTooBig")))return n("<li class='select2-selection-limit'>"+f.formatSelectionTooBig(o)+"</li>"),void 0;if(d.val().length<f.minimumInputLength)return J(f.formatInputTooShort,"formatInputTooShort")?n("<li class='select2-no-results'>"+f.formatInputTooShort(d.val(),f.minimumInputLength)+"</li>"):n(""),c&&this.showSearch&&this.showSearch(!0),void 0;
22
- if(f.maximumInputLength&&d.val().length>f.maximumInputLength)return J(f.formatInputTooLong,"formatInputTooLong")?n("<li class='select2-no-results'>"+f.formatInputTooLong(d.val(),f.maximumInputLength)+"</li>"):n(""),void 0;f.formatSearching&&0===this.findHighlightableChoices().length&&n("<li class='select2-searching'>"+f.formatSearching()+"</li>"),d.addClass("select2-active"),this.removeHighlight(),i=this.tokenize(),i!=b&&null!=i&&d.val(i),this.resultsPage=1,f.query({element:f.element,term:d.val(),page:this.resultsPage,context:null,matcher:f.matcher,callback:this.bind(function(g){var i;if(l==this.queryCount){if(!this.opened())return this.search.removeClass("select2-active"),void 0;if(this.context=g.context===b?null:g.context,this.opts.createSearchChoice&&""!==d.val()&&(i=this.opts.createSearchChoice.call(h,d.val(),g.results),i!==b&&null!==i&&h.id(i)!==b&&null!==h.id(i)&&0===a(g.results).filter(function(){return q(h.id(this),h.id(i))}).length&&g.results.unshift(i)),0===g.results.length&&J(f.formatNoMatches,"formatNoMatches"))return n("<li class='select2-no-results'>"+f.formatNoMatches(d.val())+"</li>"),void 0;e.empty(),h.opts.populateResults.call(this,e,g.results,{term:d.val(),page:this.resultsPage,context:null}),g.more===!0&&J(f.formatLoadMore,"formatLoadMore")&&(e.append("<li class='select2-more-results'>"+h.opts.escapeMarkup(f.formatLoadMore(this.resultsPage))+"</li>"),window.setTimeout(function(){h.loadMoreIfNeeded()},10)),this.postprocessResults(g,c),m(),this.opts.element.trigger({type:"select2-loaded",items:g})}})})}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),this.close(),this.container.removeClass("select2-container-active"),this.search[0]===document.activeElement&&this.search.blur(),this.clearSearch(),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){y(this.search)},selectHighlighted:function(a){var b=this.highlight(),c=this.results.find(".select2-highlighted"),d=c.closest(".select2-result").data("select2-data");d?(this.highlight(b),this.onSelect(d,a)):a&&a.noFocus&&this.close()},getPlaceholder:function(){var a;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((a=this.getPlaceholderOption())!==b?a.text():b)},getPlaceholderOption:function(){if(this.select){var a=this.select.children("option").first();if(this.opts.placeholderOption!==b)return"first"===this.opts.placeholderOption&&a||"function"==typeof this.opts.placeholderOption&&this.opts.placeholderOption(this.select);if(""===a.text()&&""===a.val())return a}},initContainerWidth:function(){function c(){var c,d,e,f,g,h;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){if(c=this.opts.element.attr("style"),c!==b)for(d=c.split(";"),f=0,g=d.length;g>f;f+=1)if(h=d[f].replace(/\s/g,""),e=h.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i),null!==e&&e.length>=1)return e[1];return"resolve"===this.opts.width?(c=this.opts.element.css("width"),c.indexOf("%")>0?c:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px"):null}return a.isFunction(this.opts.width)?this.opts.width():this.opts.width}var d=c.call(this);null!==d&&this.container.css("width",d)}}),e=N(d,{createContainer:function(){var b=a(document.createElement("div")).attr({"class":"select2-container"}).html(["<a href='javascript:void(0)' onclick='return false;' class='select2-choice' tabindex='-1'>"," <span class='select2-chosen'>&nbsp;</span><abbr class='select2-search-choice-close'></abbr>"," <span class='select2-arrow'><b></b></span>","</a>","<input class='select2-focusser select2-offscreen' type='text'/>","<div class='select2-drop select2-display-none'>"," <div class='select2-search'>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'/>"," </div>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return b},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var c,d,e;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),this.showSearchInput!==!1&&this.search.val(this.focusser.val()),this.search.focus(),c=this.search.get(0),c.createTextRange?(d=c.createTextRange(),d.collapse(!1),d.select()):c.setSelectionRange&&(e=this.search.val().length,c.setSelectionRange(e,e)),""===this.search.val()&&this.nextSearchTerm!=b&&(this.search.val(this.nextSearchTerm),this.search.select()),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger(a.Event("select2-open"))},close:function(a){this.opened()&&(this.parent.close.apply(this,arguments),a=a||{focus:!0},this.focusser.removeAttr("disabled"),a.focus&&this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.removeAttr("disabled"),this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.removeAttr("disabled"),this.focusser.focus()},destroy:function(){a("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments)},initContainer:function(){var b,d=this.container,e=this.dropdown;this.opts.minimumResultsForSearch<0?this.showSearch(!1):this.showSearch(!0),this.selection=b=d.find(".select2-choice"),this.focusser=d.find(".select2-focusser"),this.focusser.attr("id","s2id_autogen"+g()),a("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.focusser.attr("id")),this.focusser.attr("tabindex",this.elementTabIndex),this.search.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()){if(a.which===c.PAGE_UP||a.which===c.PAGE_DOWN)return A(a),void 0;switch(a.which){case c.UP:case c.DOWN:return this.moveHighlight(a.which===c.UP?-1:1),A(a),void 0;case c.ENTER:return this.selectHighlighted(),A(a),void 0;case c.TAB:return this.selectHighlighted({noFocus:!0}),void 0;case c.ESC:return this.cancel(a),A(a),void 0}}})),this.search.on("blur",this.bind(function(){document.activeElement===this.body().get(0)&&window.setTimeout(this.bind(function(){this.search.focus()}),0)})),this.focusser.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()&&a.which!==c.TAB&&!c.isControl(a)&&!c.isFunctionKey(a)&&a.which!==c.ESC){if(this.opts.openOnEnter===!1&&a.which===c.ENTER)return A(a),void 0;if(a.which==c.DOWN||a.which==c.UP||a.which==c.ENTER&&this.opts.openOnEnter){if(a.altKey||a.ctrlKey||a.shiftKey||a.metaKey)return;return this.open(),A(a),void 0}return a.which==c.DELETE||a.which==c.BACKSPACE?(this.opts.allowClear&&this.clear(),A(a),void 0):void 0}})),t(this.focusser),this.focusser.on("keyup-change input",this.bind(function(a){if(this.opts.minimumResultsForSearch>=0){if(a.stopPropagation(),this.opened())return;this.open()}})),b.on("mousedown","abbr",this.bind(function(a){this.isInterfaceEnabled()&&(this.clear(),B(a),this.close(),this.selection.focus())})),b.on("mousedown",this.bind(function(b){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),A(b)})),e.on("mousedown",this.bind(function(){this.search.focus()})),b.on("focus",this.bind(function(a){A(a)})),this.focusser.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger(a.Event("select2-blur")))})),this.search.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.setPlaceholder()},clear:function(b){var c=this.selection.data("select2-data");if(c){var d=a.Event("select2-clearing");if(this.opts.element.trigger(d),d.isDefaultPrevented())return;var e=this.getPlaceholderOption();this.opts.element.val(e?e.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),b!==!1&&(this.opts.element.trigger({type:"select2-removed",val:this.id(c),choice:c}),this.triggerChange({removed:c}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection(null),this.close(),this.setPlaceholder();else{var c=this;this.opts.initSelection.call(null,this.opts.element,function(a){a!==b&&null!==a&&(c.updateSelection(a),c.close(),c.setPlaceholder())})}},isPlaceholderOptionSelected:function(){var a;return this.getPlaceholder()?(a=this.getPlaceholderOption())!==b&&a.prop("selected")||""===this.opts.element.val()||this.opts.element.val()===b||null===this.opts.element.val():!1},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=a.find("option").filter(function(){return this.selected});b(c.optionToData(d))}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=c.val(),f=null;b.query({matcher:function(a,c,d){var g=q(e,b.id(d));return g&&(f=d),g},callback:a.isFunction(d)?function(){d(f)}:a.noop})}),b},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===b?b:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var a=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&a!==b){if(this.select&&this.getPlaceholderOption()===b)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(a)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(a,b,c){var d=0,e=this;if(this.findHighlightableChoices().each2(function(a,b){return q(e.id(b.data("select2-data")),e.opts.element.val())?(d=a,!1):void 0}),c!==!1&&(b===!0&&d>=0?this.highlight(d):this.highlight(0)),b===!0){var g=this.opts.minimumResultsForSearch;g>=0&&this.showSearch(L(a.results)>=g)}},showSearch:function(b){this.showSearchInput!==b&&(this.showSearchInput=b,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!b),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!b),a(this.dropdown,this.container).toggleClass("select2-with-searchbox",b))},onSelect:function(a,b){if(this.triggerSelect(a)){var c=this.opts.element.val(),d=this.data();this.opts.element.val(this.id(a)),this.updateSelection(a),this.opts.element.trigger({type:"select2-selected",val:this.id(a),choice:a}),this.nextSearchTerm=this.opts.nextSearchTerm(a,this.search.val()),this.close(),b&&b.noFocus||this.focusser.focus(),q(c,this.id(a))||this.triggerChange({added:a,removed:d})}},updateSelection:function(a){var d,e,c=this.selection.find(".select2-chosen");this.selection.data("select2-data",a),c.empty(),null!==a&&(d=this.opts.formatSelection(a,c,this.opts.escapeMarkup)),d!==b&&c.append(d),e=this.opts.formatSelectionCssClass(a,c),e!==b&&c.addClass(e),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==b&&this.container.addClass("select2-allowclear")},val:function(){var a,c=!1,d=null,e=this,f=this.data();if(0===arguments.length)return this.opts.element.val();if(a=arguments[0],arguments.length>1&&(c=arguments[1]),this.select)this.select.val(a).find("option").filter(function(){return this.selected}).each2(function(a,b){return d=e.optionToData(b),!1}),this.updateSelection(d),this.setPlaceholder(),c&&this.triggerChange({added:d,removed:f});else{if(!a&&0!==a)return this.clear(c),void 0;if(this.opts.initSelection===b)throw new Error("cannot call val() if initSelection() is not defined");this.opts.element.val(a),this.opts.initSelection(this.opts.element,function(a){e.opts.element.val(a?e.id(a):""),e.updateSelection(a),e.setPlaceholder(),c&&e.triggerChange({added:a,removed:f})})}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(a){var c,d=!1;return 0===arguments.length?(c=this.selection.data("select2-data"),c==b&&(c=null),c):(arguments.length>1&&(d=arguments[1]),a?(c=this.data(),this.opts.element.val(a?this.id(a):""),this.updateSelection(a),d&&this.triggerChange({added:a,removed:c})):this.clear(d),void 0)}}),f=N(d,{createContainer:function(){var b=a(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>"," <li class='select2-search-field'>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>"," </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return b},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=[];a.find("option").filter(function(){return this.selected}).each2(function(a,b){d.push(c.optionToData(b))}),b(d)}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=r(c.val(),b.separator),f=[];b.query({matcher:function(c,d,g){var h=a.grep(e,function(a){return q(a,b.id(g))}).length;return h&&f.push(g),h},callback:a.isFunction(d)?function(){for(var a=[],c=0;c<e.length;c++)for(var g=e[c],h=0;h<f.length;h++){var i=f[h];if(q(g,b.id(i))){a.push(i),f.splice(h,1);break}}d(a)}:a.noop})}),b},selectChoice:function(a){var b=this.container.find(".select2-search-choice-focus");b.length&&a&&a[0]==b[0]||(b.length&&this.opts.element.trigger("choice-deselected",b),b.removeClass("select2-search-choice-focus"),a&&a.length&&(this.close(),a.addClass("select2-search-choice-focus"),this.opts.element.trigger("choice-selected",a)))},destroy:function(){a("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments)},initContainer:function(){var d,b=".select2-choices";this.searchContainer=this.container.find(".select2-search-field"),this.selection=d=this.container.find(b);var e=this;this.selection.on("click",".select2-search-choice:not(.select2-locked)",function(){e.search[0].focus(),e.selectChoice(a(this))}),this.search.attr("id","s2id_autogen"+g()),a("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.search.attr("id")),this.search.on("input paste",this.bind(function(){this.isInterfaceEnabled()&&(this.opened()||this.open())})),this.search.attr("tabindex",this.elementTabIndex),this.keydowns=0,this.search.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()){++this.keydowns;var b=d.find(".select2-search-choice-focus"),e=b.prev(".select2-search-choice:not(.select2-locked)"),f=b.next(".select2-search-choice:not(.select2-locked)"),g=z(this.search);if(b.length&&(a.which==c.LEFT||a.which==c.RIGHT||a.which==c.BACKSPACE||a.which==c.DELETE||a.which==c.ENTER)){var h=b;return a.which==c.LEFT&&e.length?h=e:a.which==c.RIGHT?h=f.length?f:null:a.which===c.BACKSPACE?(this.unselect(b.first()),this.search.width(10),h=e.length?e:f):a.which==c.DELETE?(this.unselect(b.first()),this.search.width(10),h=f.length?f:null):a.which==c.ENTER&&(h=null),this.selectChoice(h),A(a),h&&h.length||this.open(),void 0}if((a.which===c.BACKSPACE&&1==this.keydowns||a.which==c.LEFT)&&0==g.offset&&!g.length)return this.selectChoice(d.find(".select2-search-choice:not(.select2-locked)").last()),A(a),void 0;if(this.selectChoice(null),this.opened())switch(a.which){case c.UP:case c.DOWN:return this.moveHighlight(a.which===c.UP?-1:1),A(a),void 0;case c.ENTER:return this.selectHighlighted(),A(a),void 0;case c.TAB:return this.selectHighlighted({noFocus:!0}),this.close(),void 0;case c.ESC:return this.cancel(a),A(a),void 0}if(a.which!==c.TAB&&!c.isControl(a)&&!c.isFunctionKey(a)&&a.which!==c.BACKSPACE&&a.which!==c.ESC){if(a.which===c.ENTER){if(this.opts.openOnEnter===!1)return;if(a.altKey||a.ctrlKey||a.shiftKey||a.metaKey)return}this.open(),(a.which===c.PAGE_UP||a.which===c.PAGE_DOWN)&&A(a),a.which===c.ENTER&&A(a)}}})),this.search.on("keyup",this.bind(function(){this.keydowns=0,this.resizeSearch()})),this.search.on("blur",this.bind(function(b){this.container.removeClass("select2-container-active"),this.search.removeClass("select2-focused"),this.selectChoice(null),this.opened()||this.clearSearch(),b.stopImmediatePropagation(),this.opts.element.trigger(a.Event("select2-blur"))})),this.container.on("click",b,this.bind(function(b){this.isInterfaceEnabled()&&(a(b.target).closest(".select2-search-choice").length>0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.open(),this.focusSearch(),b.preventDefault()))})),this.container.on("focus",b,this.bind(function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var c=this;this.opts.initSelection.call(null,this.opts.element,function(a){a!==b&&null!==a&&(c.updateSelection(a),c.close(),c.clearSearch())})}},clearSearch:function(){var a=this.getPlaceholder(),c=this.getMaxSearchWidth();a!==b&&0===this.getVal().length&&this.search.hasClass("select2-focused")===!1?(this.search.val(a).addClass("select2-default"),this.search.width(c>0?c:this.container.css("width"))):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),this.updateResults(!0),this.search.focus(),this.opts.element.trigger(a.Event("select2-open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(b){var c=[],d=[],e=this;a(b).each(function(){o(e.id(this),c)<0&&(c.push(e.id(this)),d.push(this))}),b=d,this.selection.find(".select2-search-choice").remove(),a(b).each(function(){e.addSelectedChoice(this)}),e.postprocessResults()},tokenize:function(){var a=this.search.val();a=this.opts.tokenizer.call(this,a,this.data(),this.bind(this.onSelect),this.opts),null!=a&&a!=b&&(this.search.val(a),a.length>0&&this.open())},onSelect:function(a,b){this.triggerSelect(a)&&(this.addSelectedChoice(a),this.opts.element.trigger({type:"selected",val:this.id(a),choice:a}),(this.select||!this.opts.closeOnSelect)&&this.postprocessResults(a,!1,this.opts.closeOnSelect===!0),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()&&this.updateResults(!0),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:a}),b&&b.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(c){var j,k,d=!c.locked,e=a("<li class='select2-search-choice'> <div></div> <a href='#' onclick='return false;' class='select2-search-choice-close' tabindex='-1'></a></li>"),f=a("<li class='select2-search-choice select2-locked'><div></div></li>"),g=d?e:f,h=this.id(c),i=this.getVal();j=this.opts.formatSelection(c,g.find("div"),this.opts.escapeMarkup),j!=b&&g.find("div").replaceWith("<div>"+j+"</div>"),k=this.opts.formatSelectionCssClass(c,g.find("div")),k!=b&&g.addClass(k),d&&g.find(".select2-search-choice-close").on("mousedown",A).on("click dblclick",this.bind(function(b){this.isInterfaceEnabled()&&(a(b.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(a(b.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),this.close(),this.focusSearch()})).dequeue(),A(b))})).on("focus",this.bind(function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),g.data("select2-data",c),g.insertBefore(this.searchContainer),i.push(h),this.setVal(i)},unselect:function(b){var d,e,c=this.getVal();if(b=b.closest(".select2-search-choice"),0===b.length)throw"Invalid argument: "+b+". Must be .select2-search-choice";if(d=b.data("select2-data")){for(;(e=o(this.id(d),c))>=0;)c.splice(e,1),this.setVal(c),this.select&&this.postprocessResults();var f=a.Event("select2-removing");f.val=this.id(d),f.choice=d,this.opts.element.trigger(f),f.isDefaultPrevented()||(b.remove(),this.opts.element.trigger({type:"select2-removed",val:this.id(d),choice:d}),this.triggerChange({removed:d}))}},postprocessResults:function(a,b,c){var d=this.getVal(),e=this.results.find(".select2-result"),f=this.results.find(".select2-result-with-children"),g=this;e.each2(function(a,b){var c=g.id(b.data("select2-data"));o(c,d)>=0&&(b.addClass("select2-selected"),b.find(".select2-result-selectable").addClass("select2-selected"))}),f.each2(function(a,b){b.is(".select2-result-selectable")||0!==b.find(".select2-result-selectable:not(.select2-selected)").length||b.addClass("select2-selected")}),-1==this.highlight()&&c!==!1&&g.highlight(0),!this.opts.createSearchChoice&&!e.filter(".select2-result:not(.select2-selected)").length>0&&(!a||a&&!a.more&&0===this.results.find(".select2-no-results").length)&&J(g.opts.formatNoMatches,"formatNoMatches")&&this.results.append("<li class='select2-no-results'>"+g.opts.formatNoMatches(g.search.val())+"</li>")},getMaxSearchWidth:function(){return this.selection.width()-s(this.search)},resizeSearch:function(){var a,b,c,d,e,f=s(this.search);a=C(this.search)+10,b=this.search.offset().left,c=this.selection.width(),d=this.selection.offset().left,e=c-(b-d)-f,a>e&&(e=c-f),40>e&&(e=c-f),0>=e&&(e=a),this.search.width(Math.floor(e))},getVal:function(){var a;return this.select?(a=this.select.val(),null===a?[]:a):(a=this.opts.element.val(),r(a,this.opts.separator))},setVal:function(b){var c;this.select?this.select.val(b):(c=[],a(b).each(function(){o(this,c)<0&&c.push(this)}),this.opts.element.val(0===c.length?"":c.join(this.opts.separator)))},buildChangeDetails:function(a,b){for(var b=b.slice(0),a=a.slice(0),c=0;c<b.length;c++)for(var d=0;d<a.length;d++)q(this.opts.id(b[c]),this.opts.id(a[d]))&&(b.splice(c,1),c>0&&c--,a.splice(d,1),d--);return{added:b,removed:a}},val:function(c,d){var e,f=this;if(0===arguments.length)return this.getVal();if(e=this.data(),e.length||(e=[]),!c&&0!==c)return this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),d&&this.triggerChange({added:this.data(),removed:e}),void 0;if(this.setVal(c),this.select)this.opts.initSelection(this.select,this.bind(this.updateSelection)),d&&this.triggerChange(this.buildChangeDetails(e,this.data()));else{if(this.opts.initSelection===b)throw new Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(b){var c=a.map(b,f.id);f.setVal(c),f.updateSelection(b),f.clearSearch(),d&&f.triggerChange(f.buildChangeDetails(e,f.data()))})}this.clearSearch()},onSortStart:function(){if(this.select)throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var b=[],c=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){b.push(c.opts.id(a(this).data("select2-data")))}),this.setVal(b),this.triggerChange()},data:function(b,c){var e,f,d=this;return 0===arguments.length?this.selection.find(".select2-search-choice").map(function(){return a(this).data("select2-data")}).get():(f=this.data(),b||(b=[]),e=a.map(b,function(a){return d.opts.id(a)}),this.setVal(e),this.updateSelection(b),this.clearSearch(),c&&this.triggerChange(this.buildChangeDetails(f,this.data())),void 0)}}),a.fn.select2=function(){var d,g,h,i,j,c=Array.prototype.slice.call(arguments,0),k=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],l=["opened","isFocused","container","dropdown"],m=["val","data"],n={search:"externalSearch"};return this.each(function(){if(0===c.length||"object"==typeof c[0])d=0===c.length?{}:a.extend({},c[0]),d.element=a(this),"select"===d.element.get(0).tagName.toLowerCase()?j=d.element.prop("multiple"):(j=d.multiple||!1,"tags"in d&&(d.multiple=j=!0)),g=j?new f:new e,g.init(d);else{if("string"!=typeof c[0])throw"Invalid arguments to select2 plugin: "+c;if(o(c[0],k)<0)throw"Unknown method: "+c[0];if(i=b,g=a(this).data("select2"),g===b)return;if(h=c[0],"container"===h?i=g.container:"dropdown"===h?i=g.dropdown:(n[h]&&(h=n[h]),i=g[h].apply(g,c.slice(1))),o(c[0],l)>=0||o(c[0],m)&&1==c.length)return!1}}),i===b?this:i},a.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(a,b,c,d){var e=[];return E(a.text,c.term,e,d),e.join("")},formatSelection:function(a,c,d){return a?d(a.text):b},sortResults:function(a){return a},formatResultCssClass:function(){return b},formatSelectionCssClass:function(){return b},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(a,b){var c=b-a.length;return"Please enter "+c+" more character"+(1==c?"":"s")},formatInputTooLong:function(a,b){var c=a.length-b;return"Please delete "+c+" character"+(1==c?"":"s")},formatSelectionTooBig:function(a){return"You can only select "+a+" item"+(1==a?"":"s")},formatLoadMore:function(){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(a){return a.id},matcher:function(a,b){return n(""+b).toUpperCase().indexOf(n(""+a).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:M,escapeMarkup:F,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(a){return a},adaptDropdownCssClass:function(){return null},nextSearchTerm:function(){return b}},a.fn.select2.ajaxDefaults={transport:a.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:G,local:H,tags:I},util:{debounce:v,markMatch:E,escapeMarkup:F,stripDiacritics:n},"class":{"abstract":d,single:e,multi:f}}}}(jQuery);
 
1
  /*
2
+ Copyright 2014 Igor Vaynberg
3
 
4
+ Version: 3.5.2 Timestamp: Sat Nov 1 14:43:36 EDT 2014
5
 
6
  This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
7
  General Public License version 2 (the "GPL License"). You may choose either license to govern your
18
  either express or implied. See the Apache License and the GPL License for the specific language governing
19
  permissions and limitations under the Apache License and the GPL License.
20
  */
21
+ !function(a){"undefined"==typeof a.fn.each2&&a.extend(a.fn,{each2:function(b){for(var c=a([0]),d=-1,e=this.length;++d<e&&(c.context=c[0]=this[d])&&b.call(c[0],d,c)!==!1;);return this}})}(jQuery),function(a,b){"use strict";function n(b){var c=a(document.createTextNode(""));b.before(c),c.before(b),c.remove()}function o(a){function b(a){return m[a]||a}return a.replace(/[^\u0000-\u007E]/g,b)}function p(a,b){for(var c=0,d=b.length;d>c;c+=1)if(r(a,b[c]))return c;return-1}function q(){var b=a(l);b.appendTo(document.body);var c={width:b.width()-b[0].clientWidth,height:b.height()-b[0].clientHeight};return b.remove(),c}function r(a,c){return a===c?!0:a===b||c===b?!1:null===a||null===c?!1:a.constructor===String?a+""==c+"":c.constructor===String?c+""==a+"":!1}function s(a,b,c){var d,e,f;if(null===a||a.length<1)return[];for(d=a.split(b),e=0,f=d.length;f>e;e+=1)d[e]=c(d[e]);return d}function t(a){return a.outerWidth(!1)-a.width()}function u(c){var d="keyup-change-value";c.on("keydown",function(){a.data(c,d)===b&&a.data(c,d,c.val())}),c.on("keyup",function(){var e=a.data(c,d);e!==b&&c.val()!==e&&(a.removeData(c,d),c.trigger("keyup-change"))})}function v(c){c.on("mousemove",function(c){var d=h;(d===b||d.x!==c.pageX||d.y!==c.pageY)&&a(c.target).trigger("mousemove-filtered",c)})}function w(a,c,d){d=d||b;var e;return function(){var b=arguments;window.clearTimeout(e),e=window.setTimeout(function(){c.apply(d,b)},a)}}function x(a,b){var c=w(a,function(a){b.trigger("scroll-debounced",a)});b.on("scroll",function(a){p(a.target,b.get())>=0&&c(a)})}function y(a){a[0]!==document.activeElement&&window.setTimeout(function(){var d,b=a[0],c=a.val().length;a.focus();var e=b.offsetWidth>0||b.offsetHeight>0;e&&b===document.activeElement&&(b.setSelectionRange?b.setSelectionRange(c,c):b.createTextRange&&(d=b.createTextRange(),d.collapse(!1),d.select()))},0)}function z(b){b=a(b)[0];var c=0,d=0;if("selectionStart"in b)c=b.selectionStart,d=b.selectionEnd-c;else if("selection"in document){b.focus();var e=document.selection.createRange();d=document.selection.createRange().text.length,e.moveStart("character",-b.value.length),c=e.text.length-d}return{offset:c,length:d}}function A(a){a.preventDefault(),a.stopPropagation()}function B(a){a.preventDefault(),a.stopImmediatePropagation()}function C(b){if(!g){var c=b[0].currentStyle||window.getComputedStyle(b[0],null);g=a(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:c.fontSize,fontFamily:c.fontFamily,fontStyle:c.fontStyle,fontWeight:c.fontWeight,letterSpacing:c.letterSpacing,textTransform:c.textTransform,whiteSpace:"nowrap"}),g.attr("class","select2-sizer"),a(document.body).append(g)}return g.text(b.val()),g.width()}function D(b,c,d){var e,g,f=[];e=a.trim(b.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each2(function(){0===this.indexOf("select2-")&&f.push(this)})),e=a.trim(c.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each2(function(){0!==this.indexOf("select2-")&&(g=d(this),g&&f.push(g))})),b.attr("class",f.join(" "))}function E(a,b,c,d){var e=o(a.toUpperCase()).indexOf(o(b.toUpperCase())),f=b.length;return 0>e?(c.push(d(a)),void 0):(c.push(d(a.substring(0,e))),c.push("<span class='select2-match'>"),c.push(d(a.substring(e,e+f))),c.push("</span>"),c.push(d(a.substring(e+f,a.length))),void 0)}function F(a){var b={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})}function G(c){var d,e=null,f=c.quietMillis||100,g=c.url,h=this;return function(i){window.clearTimeout(d),d=window.setTimeout(function(){var d=c.data,f=g,j=c.transport||a.fn.select2.ajaxDefaults.transport,k={type:c.type||"GET",cache:c.cache||!1,jsonpCallback:c.jsonpCallback||b,dataType:c.dataType||"json"},l=a.extend({},a.fn.select2.ajaxDefaults.params,k);d=d?d.call(h,i.term,i.page,i.context):null,f="function"==typeof f?f.call(h,i.term,i.page,i.context):f,e&&"function"==typeof e.abort&&e.abort(),c.params&&(a.isFunction(c.params)?a.extend(l,c.params.call(h)):a.extend(l,c.params)),a.extend(l,{url:f,dataType:c.dataType,data:d,success:function(a){var b=c.results(a,i.page,i);i.callback(b)},error:function(a,b,c){var d={hasError:!0,jqXHR:a,textStatus:b,errorThrown:c};i.callback(d)}}),e=j.call(h,l)},f)}}function H(b){var d,e,c=b,f=function(a){return""+a.text};a.isArray(c)&&(e=c,c={results:e}),a.isFunction(c)===!1&&(e=c,c=function(){return e});var g=c();return g.text&&(f=g.text,a.isFunction(f)||(d=g.text,f=function(a){return a[d]})),function(b){var g,d=b.term,e={results:[]};return""===d?(b.callback(c()),void 0):(g=function(c,e){var h,i;if(c=c[0],c.children){h={};for(i in c)c.hasOwnProperty(i)&&(h[i]=c[i]);h.children=[],a(c.children).each2(function(a,b){g(b,h.children)}),(h.children.length||b.matcher(d,f(h),c))&&e.push(h)}else b.matcher(d,f(c),c)&&e.push(c)},a(c().results).each2(function(a,b){g(b,e.results)}),b.callback(e),void 0)}}function I(c){var d=a.isFunction(c);return function(e){var f=e.term,g={results:[]},h=d?c(e):c;a.isArray(h)&&(a(h).each(function(){var a=this.text!==b,c=a?this.text:this;(""===f||e.matcher(f,c))&&g.results.push(a?this:{id:this,text:this})}),e.callback(g))}}function J(b,c){if(a.isFunction(b))return!0;if(!b)return!1;if("string"==typeof b)return!0;throw new Error(c+" must be a string, function, or falsy value")}function K(b,c){if(a.isFunction(b)){var d=Array.prototype.slice.call(arguments,2);return b.apply(c,d)}return b}function L(b){var c=0;return a.each(b,function(a,b){b.children?c+=L(b.children):c++}),c}function M(a,c,d,e){var h,i,j,k,l,f=a,g=!1;if(!e.createSearchChoice||!e.tokenSeparators||e.tokenSeparators.length<1)return b;for(;;){for(i=-1,j=0,k=e.tokenSeparators.length;k>j&&(l=e.tokenSeparators[j],i=a.indexOf(l),!(i>=0));j++);if(0>i)break;if(h=a.substring(0,i),a=a.substring(i+l.length),h.length>0&&(h=e.createSearchChoice.call(this,h,c),h!==b&&null!==h&&e.id(h)!==b&&null!==e.id(h))){for(g=!1,j=0,k=c.length;k>j;j++)if(r(e.id(h),e.id(c[j]))){g=!0;break}g||d(h)}}return f!==a?a:void 0}function N(){var b=this;a.each(arguments,function(a,c){b[c].remove(),b[c]=null})}function O(b,c){var d=function(){};return d.prototype=new b,d.prototype.constructor=d,d.prototype.parent=b.prototype,d.prototype=a.extend(d.prototype,c),d}if(window.Select2===b){var c,d,e,f,g,i,j,h={x:0,y:0},k={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(a){switch(a=a.which?a.which:a){case k.LEFT:case k.RIGHT:case k.UP:case k.DOWN:return!0}return!1},isControl:function(a){var b=a.which;switch(b){case k.SHIFT:case k.CTRL:case k.ALT:return!0}return a.metaKey?!0:!1},isFunctionKey:function(a){return a=a.which?a.which:a,a>=112&&123>=a}},l="<div class='select2-measure-scrollbar'></div>",m={"\u24b6":"A","\uff21":"A","\xc0":"A","\xc1":"A","\xc2":"A","\u1ea6":"A","\u1ea4":"A","\u1eaa":"A","\u1ea8":"A","\xc3":"A","\u0100":"A","\u0102":"A","\u1eb0":"A","\u1eae":"A","\u1eb4":"A","\u1eb2":"A","\u0226":"A","\u01e0":"A","\xc4":"A","\u01de":"A","\u1ea2":"A","\xc5":"A","\u01fa":"A","\u01cd":"A","\u0200":"A","\u0202":"A","\u1ea0":"A","\u1eac":"A","\u1eb6":"A","\u1e00":"A","\u0104":"A","\u023a":"A","\u2c6f":"A","\ua732":"AA","\xc6":"AE","\u01fc":"AE","\u01e2":"AE","\ua734":"AO","\ua736":"AU","\ua738":"AV","\ua73a":"AV","\ua73c":"AY","\u24b7":"B","\uff22":"B","\u1e02":"B","\u1e04":"B","\u1e06":"B","\u0243":"B","\u0182":"B","\u0181":"B","\u24b8":"C","\uff23":"C","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\xc7":"C","\u1e08":"C","\u0187":"C","\u023b":"C","\ua73e":"C","\u24b9":"D","\uff24":"D","\u1e0a":"D","\u010e":"D","\u1e0c":"D","\u1e10":"D","\u1e12":"D","\u1e0e":"D","\u0110":"D","\u018b":"D","\u018a":"D","\u0189":"D","\ua779":"D","\u01f1":"DZ","\u01c4":"DZ","\u01f2":"Dz","\u01c5":"Dz","\u24ba":"E","\uff25":"E","\xc8":"E","\xc9":"E","\xca":"E","\u1ec0":"E","\u1ebe":"E","\u1ec4":"E","\u1ec2":"E","\u1ebc":"E","\u0112":"E","\u1e14":"E","\u1e16":"E","\u0114":"E","\u0116":"E","\xcb":"E","\u1eba":"E","\u011a":"E","\u0204":"E","\u0206":"E","\u1eb8":"E","\u1ec6":"E","\u0228":"E","\u1e1c":"E","\u0118":"E","\u1e18":"E","\u1e1a":"E","\u0190":"E","\u018e":"E","\u24bb":"F","\uff26":"F","\u1e1e":"F","\u0191":"F","\ua77b":"F","\u24bc":"G","\uff27":"G","\u01f4":"G","\u011c":"G","\u1e20":"G","\u011e":"G","\u0120":"G","\u01e6":"G","\u0122":"G","\u01e4":"G","\u0193":"G","\ua7a0":"G","\ua77d":"G","\ua77e":"G","\u24bd":"H","\uff28":"H","\u0124":"H","\u1e22":"H","\u1e26":"H","\u021e":"H","\u1e24":"H","\u1e28":"H","\u1e2a":"H","\u0126":"H","\u2c67":"H","\u2c75":"H","\ua78d":"H","\u24be":"I","\uff29":"I","\xcc":"I","\xcd":"I","\xce":"I","\u0128":"I","\u012a":"I","\u012c":"I","\u0130":"I","\xcf":"I","\u1e2e":"I","\u1ec8":"I","\u01cf":"I","\u0208":"I","\u020a":"I","\u1eca":"I","\u012e":"I","\u1e2c":"I","\u0197":"I","\u24bf":"J","\uff2a":"J","\u0134":"J","\u0248":"J","\u24c0":"K","\uff2b":"K","\u1e30":"K","\u01e8":"K","\u1e32":"K","\u0136":"K","\u1e34":"K","\u0198":"K","\u2c69":"K","\ua740":"K","\ua742":"K","\ua744":"K","\ua7a2":"K","\u24c1":"L","\uff2c":"L","\u013f":"L","\u0139":"L","\u013d":"L","\u1e36":"L","\u1e38":"L","\u013b":"L","\u1e3c":"L","\u1e3a":"L","\u0141":"L","\u023d":"L","\u2c62":"L","\u2c60":"L","\ua748":"L","\ua746":"L","\ua780":"L","\u01c7":"LJ","\u01c8":"Lj","\u24c2":"M","\uff2d":"M","\u1e3e":"M","\u1e40":"M","\u1e42":"M","\u2c6e":"M","\u019c":"M","\u24c3":"N","\uff2e":"N","\u01f8":"N","\u0143":"N","\xd1":"N","\u1e44":"N","\u0147":"N","\u1e46":"N","\u0145":"N","\u1e4a":"N","\u1e48":"N","\u0220":"N","\u019d":"N","\ua790":"N","\ua7a4":"N","\u01ca":"NJ","\u01cb":"Nj","\u24c4":"O","\uff2f":"O","\xd2":"O","\xd3":"O","\xd4":"O","\u1ed2":"O","\u1ed0":"O","\u1ed6":"O","\u1ed4":"O","\xd5":"O","\u1e4c":"O","\u022c":"O","\u1e4e":"O","\u014c":"O","\u1e50":"O","\u1e52":"O","\u014e":"O","\u022e":"O","\u0230":"O","\xd6":"O","\u022a":"O","\u1ece":"O","\u0150":"O","\u01d1":"O","\u020c":"O","\u020e":"O","\u01a0":"O","\u1edc":"O","\u1eda":"O","\u1ee0":"O","\u1ede":"O","\u1ee2":"O","\u1ecc":"O","\u1ed8":"O","\u01ea":"O","\u01ec":"O","\xd8":"O","\u01fe":"O","\u0186":"O","\u019f":"O","\ua74a":"O","\ua74c":"O","\u01a2":"OI","\ua74e":"OO","\u0222":"OU","\u24c5":"P","\uff30":"P","\u1e54":"P","\u1e56":"P","\u01a4":"P","\u2c63":"P","\ua750":"P","\ua752":"P","\ua754":"P","\u24c6":"Q","\uff31":"Q","\ua756":"Q","\ua758":"Q","\u024a":"Q","\u24c7":"R","\uff32":"R","\u0154":"R","\u1e58":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1e5a":"R","\u1e5c":"R","\u0156":"R","\u1e5e":"R","\u024c":"R","\u2c64":"R","\ua75a":"R","\ua7a6":"R","\ua782":"R","\u24c8":"S","\uff33":"S","\u1e9e":"S","\u015a":"S","\u1e64":"S","\u015c":"S","\u1e60":"S","\u0160":"S","\u1e66":"S","\u1e62":"S","\u1e68":"S","\u0218":"S","\u015e":"S","\u2c7e":"S","\ua7a8":"S","\ua784":"S","\u24c9":"T","\uff34":"T","\u1e6a":"T","\u0164":"T","\u1e6c":"T","\u021a":"T","\u0162":"T","\u1e70":"T","\u1e6e":"T","\u0166":"T","\u01ac":"T","\u01ae":"T","\u023e":"T","\ua786":"T","\ua728":"TZ","\u24ca":"U","\uff35":"U","\xd9":"U","\xda":"U","\xdb":"U","\u0168":"U","\u1e78":"U","\u016a":"U","\u1e7a":"U","\u016c":"U","\xdc":"U","\u01db":"U","\u01d7":"U","\u01d5":"U","\u01d9":"U","\u1ee6":"U","\u016e":"U","\u0170":"U","\u01d3":"U","\u0214":"U","\u0216":"U","\u01af":"U","\u1eea":"U","\u1ee8":"U","\u1eee":"U","\u1eec":"U","\u1ef0":"U","\u1ee4":"U","\u1e72":"U","\u0172":"U","\u1e76":"U","\u1e74":"U","\u0244":"U","\u24cb":"V","\uff36":"V","\u1e7c":"V","\u1e7e":"V","\u01b2":"V","\ua75e":"V","\u0245":"V","\ua760":"VY","\u24cc":"W","\uff37":"W","\u1e80":"W","\u1e82":"W","\u0174":"W","\u1e86":"W","\u1e84":"W","\u1e88":"W","\u2c72":"W","\u24cd":"X","\uff38":"X","\u1e8a":"X","\u1e8c":"X","\u24ce":"Y","\uff39":"Y","\u1ef2":"Y","\xdd":"Y","\u0176":"Y","\u1ef8":"Y","\u0232":"Y","\u1e8e":"Y","\u0178":"Y","\u1ef6":"Y","\u1ef4":"Y","\u01b3":"Y","\u024e":"Y","\u1efe":"Y","\u24cf":"Z","\uff3a":"Z","\u0179":"Z","\u1e90":"Z","\u017b":"Z","\u017d":"Z","\u1e92":"Z","\u1e94":"Z","\u01b5":"Z","\u0224":"Z","\u2c7f":"Z","\u2c6b":"Z","\ua762":"Z","\u24d0":"a","\uff41":"a","\u1e9a":"a","\xe0":"a","\xe1":"a","\xe2":"a","\u1ea7":"a","\u1ea5":"a","\u1eab":"a","\u1ea9":"a","\xe3":"a","\u0101":"a","\u0103":"a","\u1eb1":"a","\u1eaf":"a","\u1eb5":"a","\u1eb3":"a","\u0227":"a","\u01e1":"a","\xe4":"a","\u01df":"a","\u1ea3":"a","\xe5":"a","\u01fb":"a","\u01ce":"a","\u0201":"a","\u0203":"a","\u1ea1":"a","\u1ead":"a","\u1eb7":"a","\u1e01":"a","\u0105":"a","\u2c65":"a","\u0250":"a","\ua733":"aa","\xe6":"ae","\u01fd":"ae","\u01e3":"ae","\ua735":"ao","\ua737":"au","\ua739":"av","\ua73b":"av","\ua73d":"ay","\u24d1":"b","\uff42":"b","\u1e03":"b","\u1e05":"b","\u1e07":"b","\u0180":"b","\u0183":"b","\u0253":"b","\u24d2":"c","\uff43":"c","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\xe7":"c","\u1e09":"c","\u0188":"c","\u023c":"c","\ua73f":"c","\u2184":"c","\u24d3":"d","\uff44":"d","\u1e0b":"d","\u010f":"d","\u1e0d":"d","\u1e11":"d","\u1e13":"d","\u1e0f":"d","\u0111":"d","\u018c":"d","\u0256":"d","\u0257":"d","\ua77a":"d","\u01f3":"dz","\u01c6":"dz","\u24d4":"e","\uff45":"e","\xe8":"e","\xe9":"e","\xea":"e","\u1ec1":"e","\u1ebf":"e","\u1ec5":"e","\u1ec3":"e","\u1ebd":"e","\u0113":"e","\u1e15":"e","\u1e17":"e","\u0115":"e","\u0117":"e","\xeb":"e","\u1ebb":"e","\u011b":"e","\u0205":"e","\u0207":"e","\u1eb9":"e","\u1ec7":"e","\u0229":"e","\u1e1d":"e","\u0119":"e","\u1e19":"e","\u1e1b":"e","\u0247":"e","\u025b":"e","\u01dd":"e","\u24d5":"f","\uff46":"f","\u1e1f":"f","\u0192":"f","\ua77c":"f","\u24d6":"g","\uff47":"g","\u01f5":"g","\u011d":"g","\u1e21":"g","\u011f":"g","\u0121":"g","\u01e7":"g","\u0123":"g","\u01e5":"g","\u0260":"g","\ua7a1":"g","\u1d79":"g","\ua77f":"g","\u24d7":"h","\uff48":"h","\u0125":"h","\u1e23":"h","\u1e27":"h","\u021f":"h","\u1e25":"h","\u1e29":"h","\u1e2b":"h","\u1e96":"h","\u0127":"h","\u2c68":"h","\u2c76":"h","\u0265":"h","\u0195":"hv","\u24d8":"i","\uff49":"i","\xec":"i","\xed":"i","\xee":"i","\u0129":"i","\u012b":"i","\u012d":"i","\xef":"i","\u1e2f":"i","\u1ec9":"i","\u01d0":"i","\u0209":"i","\u020b":"i","\u1ecb":"i","\u012f":"i","\u1e2d":"i","\u0268":"i","\u0131":"i","\u24d9":"j","\uff4a":"j","\u0135":"j","\u01f0":"j","\u0249":"j","\u24da":"k","\uff4b":"k","\u1e31":"k","\u01e9":"k","\u1e33":"k","\u0137":"k","\u1e35":"k","\u0199":"k","\u2c6a":"k","\ua741":"k","\ua743":"k","\ua745":"k","\ua7a3":"k","\u24db":"l","\uff4c":"l","\u0140":"l","\u013a":"l","\u013e":"l","\u1e37":"l","\u1e39":"l","\u013c":"l","\u1e3d":"l","\u1e3b":"l","\u017f":"l","\u0142":"l","\u019a":"l","\u026b":"l","\u2c61":"l","\ua749":"l","\ua781":"l","\ua747":"l","\u01c9":"lj","\u24dc":"m","\uff4d":"m","\u1e3f":"m","\u1e41":"m","\u1e43":"m","\u0271":"m","\u026f":"m","\u24dd":"n","\uff4e":"n","\u01f9":"n","\u0144":"n","\xf1":"n","\u1e45":"n","\u0148":"n","\u1e47":"n","\u0146":"n","\u1e4b":"n","\u1e49":"n","\u019e":"n","\u0272":"n","\u0149":"n","\ua791":"n","\ua7a5":"n","\u01cc":"nj","\u24de":"o","\uff4f":"o","\xf2":"o","\xf3":"o","\xf4":"o","\u1ed3":"o","\u1ed1":"o","\u1ed7":"o","\u1ed5":"o","\xf5":"o","\u1e4d":"o","\u022d":"o","\u1e4f":"o","\u014d":"o","\u1e51":"o","\u1e53":"o","\u014f":"o","\u022f":"o","\u0231":"o","\xf6":"o","\u022b":"o","\u1ecf":"o","\u0151":"o","\u01d2":"o","\u020d":"o","\u020f":"o","\u01a1":"o","\u1edd":"o","\u1edb":"o","\u1ee1":"o","\u1edf":"o","\u1ee3":"o","\u1ecd":"o","\u1ed9":"o","\u01eb":"o","\u01ed":"o","\xf8":"o","\u01ff":"o","\u0254":"o","\ua74b":"o","\ua74d":"o","\u0275":"o","\u01a3":"oi","\u0223":"ou","\ua74f":"oo","\u24df":"p","\uff50":"p","\u1e55":"p","\u1e57":"p","\u01a5":"p","\u1d7d":"p","\ua751":"p","\ua753":"p","\ua755":"p","\u24e0":"q","\uff51":"q","\u024b":"q","\ua757":"q","\ua759":"q","\u24e1":"r","\uff52":"r","\u0155":"r","\u1e59":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1e5b":"r","\u1e5d":"r","\u0157":"r","\u1e5f":"r","\u024d":"r","\u027d":"r","\ua75b":"r","\ua7a7":"r","\ua783":"r","\u24e2":"s","\uff53":"s","\xdf":"s","\u015b":"s","\u1e65":"s","\u015d":"s","\u1e61":"s","\u0161":"s","\u1e67":"s","\u1e63":"s","\u1e69":"s","\u0219":"s","\u015f":"s","\u023f":"s","\ua7a9":"s","\ua785":"s","\u1e9b":"s","\u24e3":"t","\uff54":"t","\u1e6b":"t","\u1e97":"t","\u0165":"t","\u1e6d":"t","\u021b":"t","\u0163":"t","\u1e71":"t","\u1e6f":"t","\u0167":"t","\u01ad":"t","\u0288":"t","\u2c66":"t","\ua787":"t","\ua729":"tz","\u24e4":"u","\uff55":"u","\xf9":"u","\xfa":"u","\xfb":"u","\u0169":"u","\u1e79":"u","\u016b":"u","\u1e7b":"u","\u016d":"u","\xfc":"u","\u01dc":"u","\u01d8":"u","\u01d6":"u","\u01da":"u","\u1ee7":"u","\u016f":"u","\u0171":"u","\u01d4":"u","\u0215":"u","\u0217":"u","\u01b0":"u","\u1eeb":"u","\u1ee9":"u","\u1eef":"u","\u1eed":"u","\u1ef1":"u","\u1ee5":"u","\u1e73":"u","\u0173":"u","\u1e77":"u","\u1e75":"u","\u0289":"u","\u24e5":"v","\uff56":"v","\u1e7d":"v","\u1e7f":"v","\u028b":"v","\ua75f":"v","\u028c":"v","\ua761":"vy","\u24e6":"w","\uff57":"w","\u1e81":"w","\u1e83":"w","\u0175":"w","\u1e87":"w","\u1e85":"w","\u1e98":"w","\u1e89":"w","\u2c73":"w","\u24e7":"x","\uff58":"x","\u1e8b":"x","\u1e8d":"x","\u24e8":"y","\uff59":"y","\u1ef3":"y","\xfd":"y","\u0177":"y","\u1ef9":"y","\u0233":"y","\u1e8f":"y","\xff":"y","\u1ef7":"y","\u1e99":"y","\u1ef5":"y","\u01b4":"y","\u024f":"y","\u1eff":"y","\u24e9":"z","\uff5a":"z","\u017a":"z","\u1e91":"z","\u017c":"z","\u017e":"z","\u1e93":"z","\u1e95":"z","\u01b6":"z","\u0225":"z","\u0240":"z","\u2c6c":"z","\ua763":"z","\u0386":"\u0391","\u0388":"\u0395","\u0389":"\u0397","\u038a":"\u0399","\u03aa":"\u0399","\u038c":"\u039f","\u038e":"\u03a5","\u03ab":"\u03a5","\u038f":"\u03a9","\u03ac":"\u03b1","\u03ad":"\u03b5","\u03ae":"\u03b7","\u03af":"\u03b9","\u03ca":"\u03b9","\u0390":"\u03b9","\u03cc":"\u03bf","\u03cd":"\u03c5","\u03cb":"\u03c5","\u03b0":"\u03c5","\u03c9":"\u03c9","\u03c2":"\u03c3"};i=a(document),f=function(){var a=1;return function(){return a++}}(),c=O(Object,{bind:function(a){var b=this;return function(){a.apply(b,arguments)}},init:function(c){var d,e,g=".select2-results";this.opts=c=this.prepareOpts(c),this.id=c.id,c.element.data("select2")!==b&&null!==c.element.data("select2")&&c.element.data("select2").destroy(),this.container=this.createContainer(),this.liveRegion=a(".select2-hidden-accessible"),0==this.liveRegion.length&&(this.liveRegion=a("<span>",{role:"status","aria-live":"polite"}).addClass("select2-hidden-accessible").appendTo(document.body)),this.containerId="s2id_"+(c.element.attr("id")||"autogen"+f()),this.containerEventName=this.containerId.replace(/([.])/g,"_").replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.container.attr("title",c.element.attr("title")),this.body=a(document.body),D(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.attr("style",c.element.attr("style")),this.container.css(K(c.containerCss,this.opts.element)),this.container.addClass(K(c.containerCssClass,this.opts.element)),this.elementTabIndex=this.opts.element.attr("tabindex"),this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",A),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),D(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(K(c.dropdownCssClass,this.opts.element)),this.dropdown.data("select2",this),this.dropdown.on("click",A),this.results=d=this.container.find(g),this.search=e=this.container.find("input.select2-input"),this.queryCount=0,this.resultsPage=0,this.context=null,this.initContainer(),this.container.on("click",A),v(this.results),this.dropdown.on("mousemove-filtered",g,this.bind(this.highlightUnderEvent)),this.dropdown.on("touchstart touchmove touchend",g,this.bind(function(a){this._touchEvent=!0,this.highlightUnderEvent(a)})),this.dropdown.on("touchmove",g,this.bind(this.touchMoved)),this.dropdown.on("touchstart touchend",g,this.bind(this.clearTouchMoved)),this.dropdown.on("click",this.bind(function(){this._touchEvent&&(this._touchEvent=!1,this.selectHighlighted())})),x(80,this.results),this.dropdown.on("scroll-debounced",g,this.bind(this.loadMoreIfNeeded)),a(this.container).on("change",".select2-input",function(a){a.stopPropagation()}),a(this.dropdown).on("change",".select2-input",function(a){a.stopPropagation()}),a.fn.mousewheel&&d.mousewheel(function(a,b,c,e){var f=d.scrollTop();e>0&&0>=f-e?(d.scrollTop(0),A(a)):0>e&&d.get(0).scrollHeight-d.scrollTop()+e<=d.height()&&(d.scrollTop(d.get(0).scrollHeight-d.height()),A(a))}),u(e),e.on("keyup-change input paste",this.bind(this.updateResults)),e.on("focus",function(){e.addClass("select2-focused")}),e.on("blur",function(){e.removeClass("select2-focused")}),this.dropdown.on("mouseup",g,this.bind(function(b){a(b.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(b),this.selectHighlighted(b))})),this.dropdown.on("click mouseup mousedown touchstart touchend focusin",function(a){a.stopPropagation()}),this.nextSearchTerm=b,a.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==c.maximumInputLength&&this.search.attr("maxlength",c.maximumInputLength);var h=c.element.prop("disabled");h===b&&(h=!1),this.enable(!h);var i=c.element.prop("readonly");i===b&&(i=!1),this.readonly(i),j=j||q(),this.autofocus=c.element.prop("autofocus"),c.element.prop("autofocus",!1),this.autofocus&&this.focus(),this.search.attr("placeholder",c.searchInputPlaceholder)},destroy:function(){var a=this.opts.element,c=a.data("select2"),d=this;this.close(),a.length&&a[0].detachEvent&&d._sync&&a.each(function(){d._sync&&this.detachEvent("onpropertychange",d._sync)}),this.propertyObserver&&(this.propertyObserver.disconnect(),this.propertyObserver=null),this._sync=null,c!==b&&(c.container.remove(),c.liveRegion.remove(),c.dropdown.remove(),a.show().removeData("select2").off(".select2").prop("autofocus",this.autofocus||!1),this.elementTabIndex?a.attr({tabindex:this.elementTabIndex}):a.removeAttr("tabindex"),a.show()),N.call(this,"container","liveRegion","dropdown","results","search")},optionToData:function(a){return a.is("option")?{id:a.prop("value"),text:a.text(),element:a.get(),css:a.attr("class"),disabled:a.prop("disabled"),locked:r(a.attr("locked"),"locked")||r(a.data("locked"),!0)}:a.is("optgroup")?{text:a.attr("label"),children:[],element:a.get(),css:a.attr("class")}:void 0},prepareOpts:function(c){var d,e,g,h,i=this;if(d=c.element,"select"===d.get(0).tagName.toLowerCase()&&(this.select=e=c.element),e&&a.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in c)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}),c=a.extend({},{populateResults:function(d,e,g){var h,j=this.opts.id,k=this.liveRegion;h=function(d,e,l){var m,n,o,p,q,r,s,t,u,v;d=c.sortResults(d,e,g);var w=[];for(m=0,n=d.length;n>m;m+=1)o=d[m],q=o.disabled===!0,p=!q&&j(o)!==b,r=o.children&&o.children.length>0,s=a("<li></li>"),s.addClass("select2-results-dept-"+l),s.addClass("select2-result"),s.addClass(p?"select2-result-selectable":"select2-result-unselectable"),q&&s.addClass("select2-disabled"),r&&s.addClass("select2-result-with-children"),s.addClass(i.opts.formatResultCssClass(o)),s.attr("role","presentation"),t=a(document.createElement("div")),t.addClass("select2-result-label"),t.attr("id","select2-result-label-"+f()),t.attr("role","option"),v=c.formatResult(o,t,g,i.opts.escapeMarkup),v!==b&&(t.html(v),s.append(t)),r&&(u=a("<ul></ul>"),u.addClass("select2-result-sub"),h(o.children,u,l+1),s.append(u)),s.data("select2-data",o),w.push(s[0]);e.append(w),k.text(c.formatMatches(d.length))},h(e,d,0)}},a.fn.select2.defaults,c),"function"!=typeof c.id&&(g=c.id,c.id=function(a){return a[g]}),a.isArray(c.element.data("select2Tags"))){if("tags"in c)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+c.element.attr("id");c.tags=c.element.data("select2Tags")}if(e?(c.query=this.bind(function(a){var f,g,h,c={results:[],more:!1},e=a.term;h=function(b,c){var d;b.is("option")?a.matcher(e,b.text(),b)&&c.push(i.optionToData(b)):b.is("optgroup")&&(d=i.optionToData(b),b.children().each2(function(a,b){h(b,d.children)}),d.children.length>0&&c.push(d))},f=d.children(),this.getPlaceholder()!==b&&f.length>0&&(g=this.getPlaceholderOption(),g&&(f=f.not(g))),f.each2(function(a,b){h(b,c.results)}),a.callback(c)}),c.id=function(a){return a.id}):"query"in c||("ajax"in c?(h=c.element.data("ajax-url"),h&&h.length>0&&(c.ajax.url=h),c.query=G.call(c.element,c.ajax)):"data"in c?c.query=H(c.data):"tags"in c&&(c.query=I(c.tags),c.createSearchChoice===b&&(c.createSearchChoice=function(b){return{id:a.trim(b),text:a.trim(b)}}),c.initSelection===b&&(c.initSelection=function(b,d){var e=[];a(s(b.val(),c.separator,c.transformVal)).each(function(){var b={id:this,text:this},d=c.tags;a.isFunction(d)&&(d=d()),a(d).each(function(){return r(this.id,b.id)?(b=this,!1):void 0}),e.push(b)}),d(e)}))),"function"!=typeof c.query)throw"query function not defined for Select2 "+c.element.attr("id");if("top"===c.createSearchChoicePosition)c.createSearchChoicePosition=function(a,b){a.unshift(b)};else if("bottom"===c.createSearchChoicePosition)c.createSearchChoicePosition=function(a,b){a.push(b)};else if("function"!=typeof c.createSearchChoicePosition)throw"invalid createSearchChoicePosition option must be 'top', 'bottom' or a custom function";return c},monitorSource:function(){var d,c=this.opts.element,e=this;c.on("change.select2",this.bind(function(){this.opts.element.data("select2-change-triggered")!==!0&&this.initSelection()})),this._sync=this.bind(function(){var a=c.prop("disabled");a===b&&(a=!1),this.enable(!a);var d=c.prop("readonly");d===b&&(d=!1),this.readonly(d),this.container&&(D(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.addClass(K(this.opts.containerCssClass,this.opts.element))),this.dropdown&&(D(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(K(this.opts.dropdownCssClass,this.opts.element)))}),c.length&&c[0].attachEvent&&c.each(function(){this.attachEvent("onpropertychange",e._sync)}),d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,d!==b&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new d(function(b){a.each(b,e._sync)}),this.propertyObserver.observe(c.get(0),{attributes:!0,subtree:!1}))},triggerSelect:function(b){var c=a.Event("select2-selecting",{val:this.id(b),object:b,choice:b});return this.opts.element.trigger(c),!c.isDefaultPrevented()},triggerChange:function(b){b=b||{},b=a.extend({},b,{type:"change",val:this.val()}),this.opts.element.data("select2-change-triggered",!0),this.opts.element.trigger(b),this.opts.element.data("select2-change-triggered",!1),this.opts.element.click(),this.opts.blurOnChange&&this.opts.element.blur()},isInterfaceEnabled:function(){return this.enabledInterface===!0},enableInterface:function(){var a=this._enabled&&!this._readonly,b=!a;return a===this.enabledInterface?!1:(this.container.toggleClass("select2-container-disabled",b),this.close(),this.enabledInterface=a,!0)},enable:function(a){a===b&&(a=!0),this._enabled!==a&&(this._enabled=a,this.opts.element.prop("disabled",!a),this.enableInterface())},disable:function(){this.enable(!1)},readonly:function(a){a===b&&(a=!1),this._readonly!==a&&(this._readonly=a,this.opts.element.prop("readonly",a),this.enableInterface())},opened:function(){return this.container?this.container.hasClass("select2-dropdown-open"):!1},positionDropdown:function(){var v,w,x,y,z,b=this.dropdown,c=this.container,d=c.offset(),e=c.outerHeight(!1),f=c.outerWidth(!1),g=b.outerHeight(!1),h=a(window),i=h.width(),k=h.height(),l=h.scrollLeft()+i,m=h.scrollTop()+k,n=d.top+e,o=d.left,p=m>=n+g,q=d.top-g>=h.scrollTop(),r=b.outerWidth(!1),s=function(){return l>=o+r},t=function(){return d.left+l+c.outerWidth(!1)>r},u=b.hasClass("select2-drop-above");u?(w=!0,!q&&p&&(x=!0,w=!1)):(w=!1,!p&&q&&(x=!0,w=!0)),x&&(b.hide(),d=this.container.offset(),e=this.container.outerHeight(!1),f=this.container.outerWidth(!1),g=b.outerHeight(!1),l=h.scrollLeft()+i,m=h.scrollTop()+k,n=d.top+e,o=d.left,r=b.outerWidth(!1),b.show(),this.focusSearch()),this.opts.dropdownAutoWidth?(z=a(".select2-results",b)[0],b.addClass("select2-drop-auto-width"),b.css("width",""),r=b.outerWidth(!1)+(z.scrollHeight===z.clientHeight?0:j.width),r>f?f=r:r=f,g=b.outerHeight(!1)):this.container.removeClass("select2-drop-auto-width"),"static"!==this.body.css("position")&&(v=this.body.offset(),n-=v.top,o-=v.left),!s()&&t()&&(o=d.left+this.container.outerWidth(!1)-r),y={left:o,width:f},w?(y.top=d.top-g,y.bottom="auto",this.container.addClass("select2-drop-above"),b.addClass("select2-drop-above")):(y.top=n,y.bottom="auto",this.container.removeClass("select2-drop-above"),b.removeClass("select2-drop-above")),y=a.extend(y,K(this.opts.dropdownCss,this.opts.element)),b.css(y)},shouldOpen:function(){var b;return this.opened()?!1:this._enabled===!1||this._readonly===!0?!1:(b=a.Event("select2-opening"),this.opts.element.trigger(b),!b.isDefaultPrevented())},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above")},open:function(){return this.shouldOpen()?(this.opening(),i.on("mousemove.select2Event",function(a){h.x=a.pageX,h.y=a.pageY}),!0):!1},opening:function(){var f,b=this.containerEventName,c="scroll."+b,d="resize."+b,e="orientationchange."+b;this.container.addClass("select2-dropdown-open").addClass("select2-container-active"),this.clearDropdownAlignmentPreference(),this.dropdown[0]!==this.body.children().last()[0]&&this.dropdown.detach().appendTo(this.body),f=a("#select2-drop-mask"),0===f.length&&(f=a(document.createElement("div")),f.attr("id","select2-drop-mask").attr("class","select2-drop-mask"),f.hide(),f.appendTo(this.body),f.on("mousedown touchstart click",function(b){n(f);var d,c=a("#select2-drop");c.length>0&&(d=c.data("select2"),d.opts.selectOnBlur&&d.selectHighlighted({noFocus:!0}),d.close(),b.preventDefault(),b.stopPropagation())})),this.dropdown.prev()[0]!==f[0]&&this.dropdown.before(f),a("#select2-drop").removeAttr("id"),this.dropdown.attr("id","select2-drop"),f.show(),this.positionDropdown(),this.dropdown.show(),this.positionDropdown(),this.dropdown.addClass("select2-drop-active");var g=this;this.container.parents().add(window).each(function(){a(this).on(d+" "+c+" "+e,function(){g.opened()&&g.positionDropdown()})})},close:function(){if(this.opened()){var b=this.containerEventName,c="scroll."+b,d="resize."+b,e="orientationchange."+b;this.container.parents().add(window).each(function(){a(this).off(c).off(d).off(e)}),this.clearDropdownAlignmentPreference(),a("#select2-drop-mask").hide(),this.dropdown.removeAttr("id"),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active"),this.results.empty(),i.off("mousemove.select2Event"),this.clearSearch(),this.search.removeClass("select2-active"),this.opts.element.trigger(a.Event("select2-close"))}},externalSearch:function(a){this.open(),this.search.val(a),this.updateResults(!1)},clearSearch:function(){},getMaximumSelectionSize:function(){return K(this.opts.maximumSelectionSize,this.opts.element)},ensureHighlightVisible:function(){var c,d,e,f,g,h,i,j,b=this.results;if(d=this.highlight(),!(0>d)){if(0==d)return b.scrollTop(0),void 0;c=this.findHighlightableChoices().find(".select2-result-label"),e=a(c[d]),j=(e.offset()||{}).top||0,f=j+e.outerHeight(!0),d===c.length-1&&(i=b.find("li.select2-more-results"),i.length>0&&(f=i.offset().top+i.outerHeight(!0))),g=b.offset().top+b.outerHeight(!1),f>g&&b.scrollTop(b.scrollTop()+(f-g)),h=j-b.offset().top,0>h&&"none"!=e.css("display")&&b.scrollTop(b.scrollTop()+h)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)")},moveHighlight:function(b){for(var c=this.findHighlightableChoices(),d=this.highlight();d>-1&&d<c.length;){d+=b;
22
+ var e=a(c[d]);if(e.hasClass("select2-result-selectable")&&!e.hasClass("select2-disabled")&&!e.hasClass("select2-selected")){this.highlight(d);break}}},highlight:function(b){var d,e,c=this.findHighlightableChoices();return 0===arguments.length?p(c.filter(".select2-highlighted")[0],c.get()):(b>=c.length&&(b=c.length-1),0>b&&(b=0),this.removeHighlight(),d=a(c[b]),d.addClass("select2-highlighted"),this.search.attr("aria-activedescendant",d.find(".select2-result-label").attr("id")),this.ensureHighlightVisible(),this.liveRegion.text(d.text()),e=d.data("select2-data"),e&&this.opts.element.trigger({type:"select2-highlight",val:this.id(e),choice:e}),void 0)},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},touchMoved:function(){this._touchMoved=!0},clearTouchMoved:function(){this._touchMoved=!1},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(b){var c=a(b.target).closest(".select2-result-selectable");if(c.length>0&&!c.is(".select2-highlighted")){var d=this.findHighlightableChoices();this.highlight(d.index(c))}else 0==c.length&&this.removeHighlight()},loadMoreIfNeeded:function(){var c,a=this.results,b=a.find("li.select2-more-results"),d=this.resultsPage+1,e=this,f=this.search.val(),g=this.context;0!==b.length&&(c=b.offset().top-a.offset().top-a.height(),c<=this.opts.loadMorePadding&&(b.addClass("select2-active"),this.opts.query({element:this.opts.element,term:f,page:d,context:g,matcher:this.opts.matcher,callback:this.bind(function(c){e.opened()&&(e.opts.populateResults.call(this,a,c.results,{term:f,page:d,context:g}),e.postprocessResults(c,!1,!1),c.more===!0?(b.detach().appendTo(a).html(e.opts.escapeMarkup(K(e.opts.formatLoadMore,e.opts.element,d+1))),window.setTimeout(function(){e.loadMoreIfNeeded()},10)):b.remove(),e.positionDropdown(),e.resultsPage=d,e.context=c.context,this.opts.element.trigger({type:"select2-loaded",items:c}))})})))},tokenize:function(){},updateResults:function(c){function m(){d.removeClass("select2-active"),h.positionDropdown(),e.find(".select2-no-results,.select2-selection-limit,.select2-searching").length?h.liveRegion.text(e.text()):h.liveRegion.text(h.opts.formatMatches(e.find('.select2-result-selectable:not(".select2-selected")').length))}function n(a){e.html(a),m()}var g,i,l,d=this.search,e=this.results,f=this.opts,h=this,j=d.val(),k=a.data(this.container,"select2-last-term");if((c===!0||!k||!r(j,k))&&(a.data(this.container,"select2-last-term",j),c===!0||this.showSearchInput!==!1&&this.opened())){l=++this.queryCount;var o=this.getMaximumSelectionSize();if(o>=1&&(g=this.data(),a.isArray(g)&&g.length>=o&&J(f.formatSelectionTooBig,"formatSelectionTooBig")))return n("<li class='select2-selection-limit'>"+K(f.formatSelectionTooBig,f.element,o)+"</li>"),void 0;if(d.val().length<f.minimumInputLength)return J(f.formatInputTooShort,"formatInputTooShort")?n("<li class='select2-no-results'>"+K(f.formatInputTooShort,f.element,d.val(),f.minimumInputLength)+"</li>"):n(""),c&&this.showSearch&&this.showSearch(!0),void 0;if(f.maximumInputLength&&d.val().length>f.maximumInputLength)return J(f.formatInputTooLong,"formatInputTooLong")?n("<li class='select2-no-results'>"+K(f.formatInputTooLong,f.element,d.val(),f.maximumInputLength)+"</li>"):n(""),void 0;f.formatSearching&&0===this.findHighlightableChoices().length&&n("<li class='select2-searching'>"+K(f.formatSearching,f.element)+"</li>"),d.addClass("select2-active"),this.removeHighlight(),i=this.tokenize(),i!=b&&null!=i&&d.val(i),this.resultsPage=1,f.query({element:f.element,term:d.val(),page:this.resultsPage,context:null,matcher:f.matcher,callback:this.bind(function(g){var i;if(l==this.queryCount){if(!this.opened())return this.search.removeClass("select2-active"),void 0;if(g.hasError!==b&&J(f.formatAjaxError,"formatAjaxError"))return n("<li class='select2-ajax-error'>"+K(f.formatAjaxError,f.element,g.jqXHR,g.textStatus,g.errorThrown)+"</li>"),void 0;if(this.context=g.context===b?null:g.context,this.opts.createSearchChoice&&""!==d.val()&&(i=this.opts.createSearchChoice.call(h,d.val(),g.results),i!==b&&null!==i&&h.id(i)!==b&&null!==h.id(i)&&0===a(g.results).filter(function(){return r(h.id(this),h.id(i))}).length&&this.opts.createSearchChoicePosition(g.results,i)),0===g.results.length&&J(f.formatNoMatches,"formatNoMatches"))return n("<li class='select2-no-results'>"+K(f.formatNoMatches,f.element,d.val())+"</li>"),void 0;e.empty(),h.opts.populateResults.call(this,e,g.results,{term:d.val(),page:this.resultsPage,context:null}),g.more===!0&&J(f.formatLoadMore,"formatLoadMore")&&(e.append("<li class='select2-more-results'>"+f.escapeMarkup(K(f.formatLoadMore,f.element,this.resultsPage))+"</li>"),window.setTimeout(function(){h.loadMoreIfNeeded()},10)),this.postprocessResults(g,c),m(),this.opts.element.trigger({type:"select2-loaded",items:g})}})})}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),this.close(),this.container.removeClass("select2-container-active"),this.search[0]===document.activeElement&&this.search.blur(),this.clearSearch(),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){y(this.search)},selectHighlighted:function(a){if(this._touchMoved)return this.clearTouchMoved(),void 0;var b=this.highlight(),c=this.results.find(".select2-highlighted"),d=c.closest(".select2-result").data("select2-data");d?(this.highlight(b),this.onSelect(d,a)):a&&a.noFocus&&this.close()},getPlaceholder:function(){var a;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((a=this.getPlaceholderOption())!==b?a.text():b)},getPlaceholderOption:function(){if(this.select){var c=this.select.children("option").first();if(this.opts.placeholderOption!==b)return"first"===this.opts.placeholderOption&&c||"function"==typeof this.opts.placeholderOption&&this.opts.placeholderOption(this.select);if(""===a.trim(c.text())&&""===c.val())return c}},initContainerWidth:function(){function c(){var c,d,e,f,g,h;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){if(c=this.opts.element.attr("style"),c!==b)for(d=c.split(";"),f=0,g=d.length;g>f;f+=1)if(h=d[f].replace(/\s/g,""),e=h.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i),null!==e&&e.length>=1)return e[1];return"resolve"===this.opts.width?(c=this.opts.element.css("width"),c.indexOf("%")>0?c:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px"):null}return a.isFunction(this.opts.width)?this.opts.width():this.opts.width}var d=c.call(this);null!==d&&this.container.css("width",d)}}),d=O(c,{createContainer:function(){var b=a(document.createElement("div")).attr({"class":"select2-container"}).html(["<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>"," <span class='select2-chosen'>&#160;</span><abbr class='select2-search-choice-close'></abbr>"," <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>","</a>","<label for='' class='select2-offscreen'></label>","<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />","<div class='select2-drop select2-display-none'>"," <div class='select2-search'>"," <label for='' class='select2-offscreen'></label>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'"," aria-autocomplete='list' />"," </div>"," <ul class='select2-results' role='listbox'>"," </ul>","</div>"].join(""));return b},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var c,d,e;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),this.showSearchInput!==!1&&this.search.val(this.focusser.val()),this.opts.shouldFocusInput(this)&&(this.search.focus(),c=this.search.get(0),c.createTextRange?(d=c.createTextRange(),d.collapse(!1),d.select()):c.setSelectionRange&&(e=this.search.val().length,c.setSelectionRange(e,e))),""===this.search.val()&&this.nextSearchTerm!=b&&(this.search.val(this.nextSearchTerm),this.search.select()),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger(a.Event("select2-open"))},close:function(){this.opened()&&(this.parent.close.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus()},destroy:function(){a("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments),N.call(this,"selection","focusser")},initContainer:function(){var b,g,c=this.container,d=this.dropdown,e=f();this.opts.minimumResultsForSearch<0?this.showSearch(!1):this.showSearch(!0),this.selection=b=c.find(".select2-choice"),this.focusser=c.find(".select2-focusser"),b.find(".select2-chosen").attr("id","select2-chosen-"+e),this.focusser.attr("aria-labelledby","select2-chosen-"+e),this.results.attr("id","select2-results-"+e),this.search.attr("aria-owns","select2-results-"+e),this.focusser.attr("id","s2id_autogen"+e),g=a("label[for='"+this.opts.element.attr("id")+"']"),this.opts.element.focus(this.bind(function(){this.focus()})),this.focusser.prev().text(g.text()).attr("for",this.focusser.attr("id"));var h=this.opts.element.attr("title");this.opts.element.attr("title",h||g.text()),this.focusser.attr("tabindex",this.elementTabIndex),this.search.attr("id",this.focusser.attr("id")+"_search"),this.search.prev().text(a("label[for='"+this.focusser.attr("id")+"']").text()).attr("for",this.search.attr("id")),this.search.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()&&229!=a.keyCode){if(a.which===k.PAGE_UP||a.which===k.PAGE_DOWN)return A(a),void 0;switch(a.which){case k.UP:case k.DOWN:return this.moveHighlight(a.which===k.UP?-1:1),A(a),void 0;case k.ENTER:return this.selectHighlighted(),A(a),void 0;case k.TAB:return this.selectHighlighted({noFocus:!0}),void 0;case k.ESC:return this.cancel(a),A(a),void 0}}})),this.search.on("blur",this.bind(function(){document.activeElement===this.body.get(0)&&window.setTimeout(this.bind(function(){this.opened()&&this.search.focus()}),0)})),this.focusser.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()&&a.which!==k.TAB&&!k.isControl(a)&&!k.isFunctionKey(a)&&a.which!==k.ESC){if(this.opts.openOnEnter===!1&&a.which===k.ENTER)return A(a),void 0;if(a.which==k.DOWN||a.which==k.UP||a.which==k.ENTER&&this.opts.openOnEnter){if(a.altKey||a.ctrlKey||a.shiftKey||a.metaKey)return;return this.open(),A(a),void 0}return a.which==k.DELETE||a.which==k.BACKSPACE?(this.opts.allowClear&&this.clear(),A(a),void 0):void 0}})),u(this.focusser),this.focusser.on("keyup-change input",this.bind(function(a){if(this.opts.minimumResultsForSearch>=0){if(a.stopPropagation(),this.opened())return;this.open()}})),b.on("mousedown touchstart","abbr",this.bind(function(a){this.isInterfaceEnabled()&&(this.clear(),B(a),this.close(),this.selection&&this.selection.focus())})),b.on("mousedown touchstart",this.bind(function(c){n(b),this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),A(c)})),d.on("mousedown touchstart",this.bind(function(){this.opts.shouldFocusInput(this)&&this.search.focus()})),b.on("focus",this.bind(function(a){A(a)})),this.focusser.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger(a.Event("select2-blur")))})),this.search.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.opts.element.hide(),this.setPlaceholder()},clear:function(b){var c=this.selection.data("select2-data");if(c){var d=a.Event("select2-clearing");if(this.opts.element.trigger(d),d.isDefaultPrevented())return;var e=this.getPlaceholderOption();this.opts.element.val(e?e.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),b!==!1&&(this.opts.element.trigger({type:"select2-removed",val:this.id(c),choice:c}),this.triggerChange({removed:c}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection(null),this.close(),this.setPlaceholder();else{var c=this;this.opts.initSelection.call(null,this.opts.element,function(a){a!==b&&null!==a&&(c.updateSelection(a),c.close(),c.setPlaceholder(),c.nextSearchTerm=c.opts.nextSearchTerm(a,c.search.val()))})}},isPlaceholderOptionSelected:function(){var a;return this.getPlaceholder()===b?!1:(a=this.getPlaceholderOption())!==b&&a.prop("selected")||""===this.opts.element.val()||this.opts.element.val()===b||null===this.opts.element.val()},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=a.find("option").filter(function(){return this.selected&&!this.disabled});b(c.optionToData(d))}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=c.val(),f=null;b.query({matcher:function(a,c,d){var g=r(e,b.id(d));return g&&(f=d),g},callback:a.isFunction(d)?function(){d(f)}:a.noop})}),b},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===b?b:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var a=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&a!==b){if(this.select&&this.getPlaceholderOption()===b)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(a)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(a,b,c){var d=0,e=this;if(this.findHighlightableChoices().each2(function(a,b){return r(e.id(b.data("select2-data")),e.opts.element.val())?(d=a,!1):void 0}),c!==!1&&(b===!0&&d>=0?this.highlight(d):this.highlight(0)),b===!0){var g=this.opts.minimumResultsForSearch;g>=0&&this.showSearch(L(a.results)>=g)}},showSearch:function(b){this.showSearchInput!==b&&(this.showSearchInput=b,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!b),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!b),a(this.dropdown,this.container).toggleClass("select2-with-searchbox",b))},onSelect:function(a,b){if(this.triggerSelect(a)){var c=this.opts.element.val(),d=this.data();this.opts.element.val(this.id(a)),this.updateSelection(a),this.opts.element.trigger({type:"select2-selected",val:this.id(a),choice:a}),this.nextSearchTerm=this.opts.nextSearchTerm(a,this.search.val()),this.close(),b&&b.noFocus||!this.opts.shouldFocusInput(this)||this.focusser.focus(),r(c,this.id(a))||this.triggerChange({added:a,removed:d})}},updateSelection:function(a){var d,e,c=this.selection.find(".select2-chosen");this.selection.data("select2-data",a),c.empty(),null!==a&&(d=this.opts.formatSelection(a,c,this.opts.escapeMarkup)),d!==b&&c.append(d),e=this.opts.formatSelectionCssClass(a,c),e!==b&&c.addClass(e),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==b&&this.container.addClass("select2-allowclear")},val:function(){var a,c=!1,d=null,e=this,f=this.data();if(0===arguments.length)return this.opts.element.val();if(a=arguments[0],arguments.length>1&&(c=arguments[1]),this.select)this.select.val(a).find("option").filter(function(){return this.selected}).each2(function(a,b){return d=e.optionToData(b),!1}),this.updateSelection(d),this.setPlaceholder(),c&&this.triggerChange({added:d,removed:f});else{if(!a&&0!==a)return this.clear(c),void 0;if(this.opts.initSelection===b)throw new Error("cannot call val() if initSelection() is not defined");this.opts.element.val(a),this.opts.initSelection(this.opts.element,function(a){e.opts.element.val(a?e.id(a):""),e.updateSelection(a),e.setPlaceholder(),c&&e.triggerChange({added:a,removed:f})})}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(a){var c,d=!1;return 0===arguments.length?(c=this.selection.data("select2-data"),c==b&&(c=null),c):(arguments.length>1&&(d=arguments[1]),a?(c=this.data(),this.opts.element.val(a?this.id(a):""),this.updateSelection(a),d&&this.triggerChange({added:a,removed:c})):this.clear(d),void 0)}}),e=O(c,{createContainer:function(){var b=a(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>"," <li class='select2-search-field'>"," <label for='' class='select2-offscreen'></label>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>"," </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return b},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=[];a.find("option").filter(function(){return this.selected&&!this.disabled}).each2(function(a,b){d.push(c.optionToData(b))}),b(d)}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=s(c.val(),b.separator,b.transformVal),f=[];b.query({matcher:function(c,d,g){var h=a.grep(e,function(a){return r(a,b.id(g))}).length;return h&&f.push(g),h},callback:a.isFunction(d)?function(){for(var a=[],c=0;c<e.length;c++)for(var g=e[c],h=0;h<f.length;h++){var i=f[h];if(r(g,b.id(i))){a.push(i),f.splice(h,1);break}}d(a)}:a.noop})}),b},selectChoice:function(a){var b=this.container.find(".select2-search-choice-focus");b.length&&a&&a[0]==b[0]||(b.length&&this.opts.element.trigger("choice-deselected",b),b.removeClass("select2-search-choice-focus"),a&&a.length&&(this.close(),a.addClass("select2-search-choice-focus"),this.opts.element.trigger("choice-selected",a)))},destroy:function(){a("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments),N.call(this,"searchContainer","selection")},initContainer:function(){var c,b=".select2-choices";this.searchContainer=this.container.find(".select2-search-field"),this.selection=c=this.container.find(b);var d=this;this.selection.on("click",".select2-container:not(.select2-container-disabled) .select2-search-choice:not(.select2-locked)",function(){d.search[0].focus(),d.selectChoice(a(this))}),this.search.attr("id","s2id_autogen"+f()),this.search.prev().text(a("label[for='"+this.opts.element.attr("id")+"']").text()).attr("for",this.search.attr("id")),this.opts.element.focus(this.bind(function(){this.focus()})),this.search.on("input paste",this.bind(function(){this.search.attr("placeholder")&&0==this.search.val().length||this.isInterfaceEnabled()&&(this.opened()||this.open())})),this.search.attr("tabindex",this.elementTabIndex),this.keydowns=0,this.search.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()){++this.keydowns;var b=c.find(".select2-search-choice-focus"),d=b.prev(".select2-search-choice:not(.select2-locked)"),e=b.next(".select2-search-choice:not(.select2-locked)"),f=z(this.search);if(b.length&&(a.which==k.LEFT||a.which==k.RIGHT||a.which==k.BACKSPACE||a.which==k.DELETE||a.which==k.ENTER)){var g=b;return a.which==k.LEFT&&d.length?g=d:a.which==k.RIGHT?g=e.length?e:null:a.which===k.BACKSPACE?this.unselect(b.first())&&(this.search.width(10),g=d.length?d:e):a.which==k.DELETE?this.unselect(b.first())&&(this.search.width(10),g=e.length?e:null):a.which==k.ENTER&&(g=null),this.selectChoice(g),A(a),g&&g.length||this.open(),void 0}if((a.which===k.BACKSPACE&&1==this.keydowns||a.which==k.LEFT)&&0==f.offset&&!f.length)return this.selectChoice(c.find(".select2-search-choice:not(.select2-locked)").last()),A(a),void 0;if(this.selectChoice(null),this.opened())switch(a.which){case k.UP:case k.DOWN:return this.moveHighlight(a.which===k.UP?-1:1),A(a),void 0;case k.ENTER:return this.selectHighlighted(),A(a),void 0;case k.TAB:return this.selectHighlighted({noFocus:!0}),this.close(),void 0;case k.ESC:return this.cancel(a),A(a),void 0}if(a.which!==k.TAB&&!k.isControl(a)&&!k.isFunctionKey(a)&&a.which!==k.BACKSPACE&&a.which!==k.ESC){if(a.which===k.ENTER){if(this.opts.openOnEnter===!1)return;if(a.altKey||a.ctrlKey||a.shiftKey||a.metaKey)return}this.open(),(a.which===k.PAGE_UP||a.which===k.PAGE_DOWN)&&A(a),a.which===k.ENTER&&A(a)}}})),this.search.on("keyup",this.bind(function(){this.keydowns=0,this.resizeSearch()})),this.search.on("blur",this.bind(function(b){this.container.removeClass("select2-container-active"),this.search.removeClass("select2-focused"),this.selectChoice(null),this.opened()||this.clearSearch(),b.stopImmediatePropagation(),this.opts.element.trigger(a.Event("select2-blur"))})),this.container.on("click",b,this.bind(function(b){this.isInterfaceEnabled()&&(a(b.target).closest(".select2-search-choice").length>0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.open(),this.focusSearch(),b.preventDefault()))})),this.container.on("focus",b,this.bind(function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.opts.element.hide(),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var c=this;this.opts.initSelection.call(null,this.opts.element,function(a){a!==b&&null!==a&&(c.updateSelection(a),c.close(),c.clearSearch())})}},clearSearch:function(){var a=this.getPlaceholder(),c=this.getMaxSearchWidth();a!==b&&0===this.getVal().length&&this.search.hasClass("select2-focused")===!1?(this.search.val(a).addClass("select2-default"),this.search.width(c>0?c:this.container.css("width"))):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),""===this.search.val()&&this.nextSearchTerm!=b&&(this.search.val(this.nextSearchTerm),this.search.select()),this.updateResults(!0),this.opts.shouldFocusInput(this)&&this.search.focus(),this.opts.element.trigger(a.Event("select2-open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(b){var c=[],d=[],e=this;a(b).each(function(){p(e.id(this),c)<0&&(c.push(e.id(this)),d.push(this))}),b=d,this.selection.find(".select2-search-choice").remove(),a(b).each(function(){e.addSelectedChoice(this)}),e.postprocessResults()},tokenize:function(){var a=this.search.val();a=this.opts.tokenizer.call(this,a,this.data(),this.bind(this.onSelect),this.opts),null!=a&&a!=b&&(this.search.val(a),a.length>0&&this.open())},onSelect:function(a,c){this.triggerSelect(a)&&""!==a.text&&(this.addSelectedChoice(a),this.opts.element.trigger({type:"selected",val:this.id(a),choice:a}),this.nextSearchTerm=this.opts.nextSearchTerm(a,this.search.val()),this.clearSearch(),this.updateResults(),(this.select||!this.opts.closeOnSelect)&&this.postprocessResults(a,!1,this.opts.closeOnSelect===!0),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()?this.updateResults(!0):this.nextSearchTerm!=b&&(this.search.val(this.nextSearchTerm),this.updateResults(),this.search.select()),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:a}),c&&c.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(c){var j,k,d=!c.locked,e=a("<li class='select2-search-choice'> <div></div> <a href='#' class='select2-search-choice-close' tabindex='-1'></a></li>"),f=a("<li class='select2-search-choice select2-locked'><div></div></li>"),g=d?e:f,h=this.id(c),i=this.getVal();j=this.opts.formatSelection(c,g.find("div"),this.opts.escapeMarkup),j!=b&&g.find("div").replaceWith(a("<div></div>").html(j)),k=this.opts.formatSelectionCssClass(c,g.find("div")),k!=b&&g.addClass(k),d&&g.find(".select2-search-choice-close").on("mousedown",A).on("click dblclick",this.bind(function(b){this.isInterfaceEnabled()&&(this.unselect(a(b.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),A(b),this.close(),this.focusSearch())})).on("focus",this.bind(function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),g.data("select2-data",c),g.insertBefore(this.searchContainer),i.push(h),this.setVal(i)},unselect:function(b){var d,e,c=this.getVal();if(b=b.closest(".select2-search-choice"),0===b.length)throw"Invalid argument: "+b+". Must be .select2-search-choice";if(d=b.data("select2-data")){var f=a.Event("select2-removing");if(f.val=this.id(d),f.choice=d,this.opts.element.trigger(f),f.isDefaultPrevented())return!1;for(;(e=p(this.id(d),c))>=0;)c.splice(e,1),this.setVal(c),this.select&&this.postprocessResults();return b.remove(),this.opts.element.trigger({type:"select2-removed",val:this.id(d),choice:d}),this.triggerChange({removed:d}),!0}},postprocessResults:function(a,b,c){var d=this.getVal(),e=this.results.find(".select2-result"),f=this.results.find(".select2-result-with-children"),g=this;e.each2(function(a,b){var c=g.id(b.data("select2-data"));p(c,d)>=0&&(b.addClass("select2-selected"),b.find(".select2-result-selectable").addClass("select2-selected"))}),f.each2(function(a,b){b.is(".select2-result-selectable")||0!==b.find(".select2-result-selectable:not(.select2-selected)").length||b.addClass("select2-selected")}),-1==this.highlight()&&c!==!1&&this.opts.closeOnSelect===!0&&g.highlight(0),!this.opts.createSearchChoice&&!e.filter(".select2-result:not(.select2-selected)").length>0&&(!a||a&&!a.more&&0===this.results.find(".select2-no-results").length)&&J(g.opts.formatNoMatches,"formatNoMatches")&&this.results.append("<li class='select2-no-results'>"+K(g.opts.formatNoMatches,g.opts.element,g.search.val())+"</li>")},getMaxSearchWidth:function(){return this.selection.width()-t(this.search)},resizeSearch:function(){var a,b,c,d,e,f=t(this.search);a=C(this.search)+10,b=this.search.offset().left,c=this.selection.width(),d=this.selection.offset().left,e=c-(b-d)-f,a>e&&(e=c-f),40>e&&(e=c-f),0>=e&&(e=a),this.search.width(Math.floor(e))},getVal:function(){var a;return this.select?(a=this.select.val(),null===a?[]:a):(a=this.opts.element.val(),s(a,this.opts.separator,this.opts.transformVal))},setVal:function(b){var c;this.select?this.select.val(b):(c=[],a(b).each(function(){p(this,c)<0&&c.push(this)}),this.opts.element.val(0===c.length?"":c.join(this.opts.separator)))},buildChangeDetails:function(a,b){for(var b=b.slice(0),a=a.slice(0),c=0;c<b.length;c++)for(var d=0;d<a.length;d++)r(this.opts.id(b[c]),this.opts.id(a[d]))&&(b.splice(c,1),c>0&&c--,a.splice(d,1),d--);return{added:b,removed:a}},val:function(c,d){var e,f=this;if(0===arguments.length)return this.getVal();if(e=this.data(),e.length||(e=[]),!c&&0!==c)return this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),d&&this.triggerChange({added:this.data(),removed:e}),void 0;if(this.setVal(c),this.select)this.opts.initSelection(this.select,this.bind(this.updateSelection)),d&&this.triggerChange(this.buildChangeDetails(e,this.data()));else{if(this.opts.initSelection===b)throw new Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(b){var c=a.map(b,f.id);f.setVal(c),f.updateSelection(b),f.clearSearch(),d&&f.triggerChange(f.buildChangeDetails(e,f.data()))})}this.clearSearch()},onSortStart:function(){if(this.select)throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var b=[],c=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){b.push(c.opts.id(a(this).data("select2-data")))}),this.setVal(b),this.triggerChange()},data:function(b,c){var e,f,d=this;return 0===arguments.length?this.selection.children(".select2-search-choice").map(function(){return a(this).data("select2-data")}).get():(f=this.data(),b||(b=[]),e=a.map(b,function(a){return d.opts.id(a)}),this.setVal(e),this.updateSelection(b),this.clearSearch(),c&&this.triggerChange(this.buildChangeDetails(f,this.data())),void 0)}}),a.fn.select2=function(){var d,e,f,g,h,c=Array.prototype.slice.call(arguments,0),i=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],j=["opened","isFocused","container","dropdown"],k=["val","data"],l={search:"externalSearch"};return this.each(function(){if(0===c.length||"object"==typeof c[0])d=0===c.length?{}:a.extend({},c[0]),d.element=a(this),"select"===d.element.get(0).tagName.toLowerCase()?h=d.element.prop("multiple"):(h=d.multiple||!1,"tags"in d&&(d.multiple=h=!0)),e=h?new window.Select2["class"].multi:new window.Select2["class"].single,e.init(d);else{if("string"!=typeof c[0])throw"Invalid arguments to select2 plugin: "+c;if(p(c[0],i)<0)throw"Unknown method: "+c[0];if(g=b,e=a(this).data("select2"),e===b)return;if(f=c[0],"container"===f?g=e.container:"dropdown"===f?g=e.dropdown:(l[f]&&(f=l[f]),g=e[f].apply(e,c.slice(1))),p(c[0],j)>=0||p(c[0],k)>=0&&1==c.length)return!1}}),g===b?this:g},a.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(a,b,c,d){var e=[];return E(this.text(a),c.term,e,d),e.join("")},transformVal:function(b){return a.trim(b)},formatSelection:function(a,c,d){return a?d(this.text(a)):b},sortResults:function(a){return a},formatResultCssClass:function(a){return a.css},formatSelectionCssClass:function(){return b},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(a){return a==b?null:a.id},text:function(b){return b&&this.data&&this.data.text?a.isFunction(this.data.text)?this.data.text(b):b[this.data.text]:b.text
23
+ },matcher:function(a,b){return o(""+b).toUpperCase().indexOf(o(""+a).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:M,escapeMarkup:F,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(a){return a},adaptDropdownCssClass:function(){return null},nextSearchTerm:function(){return b},searchInputPlaceholder:"",createSearchChoicePosition:"top",shouldFocusInput:function(a){var b="ontouchstart"in window||navigator.msMaxTouchPoints>0;return b?a.opts.minimumResultsForSearch<0?!1:!0:!0}},a.fn.select2.locales=[],a.fn.select2.locales.en={formatMatches:function(a){return 1===a?"One result is available, press enter to select it.":a+" results are available, use up and down arrow keys to navigate."},formatNoMatches:function(){return"No matches found"},formatAjaxError:function(){return"Loading failed"},formatInputTooShort:function(a,b){var c=b-a.length;return"Please enter "+c+" or more character"+(1==c?"":"s")},formatInputTooLong:function(a,b){var c=a.length-b;return"Please delete "+c+" character"+(1==c?"":"s")},formatSelectionTooBig:function(a){return"You can only select "+a+" item"+(1==a?"":"s")},formatLoadMore:function(){return"Loading more results\u2026"},formatSearching:function(){return"Searching\u2026"}},a.extend(a.fn.select2.defaults,a.fn.select2.locales.en),a.fn.select2.ajaxDefaults={transport:a.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:G,local:H,tags:I},util:{debounce:w,markMatch:E,escapeMarkup:F,stripDiacritics:o},"class":{"abstract":c,single:d,multi:e}}}}(jQuery);
embedded/common/views/promote.php DELETED
@@ -1,93 +0,0 @@
1
- <?php
2
-
3
- if (!function_exists('promote_types_and_views')) {
4
-
5
- function is_promote_views() {
6
- $promote_views = false;
7
- if (defined('WPV_VERSION')) {
8
- global $WP_Views;
9
- if ($WP_Views) {
10
- $promote_views = $WP_Views->is_embedded();
11
- }
12
- }
13
- return $promote_views;
14
- }
15
-
16
- function promote_types_and_views() {
17
- static $promoted = false;
18
-
19
- if (!$promoted) {
20
- $promote_types = defined('WPCF_RUNNING_EMBEDDED');
21
- $promote_views = is_promote_views();
22
-
23
- if ($promote_types || $promote_views) {
24
- add_action('admin_menu', 'promote_types_and_views_menu');
25
- }
26
- }
27
- }
28
-
29
- function promote_types_and_views_menu() {
30
- $promote_types = defined('WPCF_RUNNING_EMBEDDED');
31
- $promote_views = is_promote_views();
32
- if ($promote_types || $promote_views) {
33
- add_theme_page(__('Get Types and Views', 'wpv-views'), 'Get Types and Views', 'manage_options', 'wpv-get-types-views', 'promote_types_and_views_admin');
34
- }
35
- }
36
-
37
- function promote_types_and_views_admin() {
38
- ?>
39
- <div class="wrap">
40
- <?php
41
-
42
- $promote_types = defined('WPCF_RUNNING_EMBEDDED');
43
- $promote_views = is_promote_views();
44
- $affiliate_url = '';
45
- if (function_exists('wpv_get_affiliate_url')) {
46
- $affiliate_url = wpv_get_affiliate_url();
47
- }
48
-
49
- $icon_url = icl_get_file_relpath(dirname(__FILE__) . '/res/img/views-32.png') . '/views-32.png';
50
- ?>
51
- <div class="icon32" style='background:url("<?php echo $icon_url; ?>") no-repeat;'><br /></div>
52
- <h2><?php _e('Get Types and Views', 'wpv-views') ?></h2>
53
-
54
- <p style="font-size: 130%;"><?php _e('Your theme was created using <strong>Types</strong> and <strong>Views</strong>. Developers use these two plugins to build complex websites, without coding.', 'wpv-views'); ?></p>
55
- <p style="font-size: 120%;"><?php _e("Right now, you're using the embedded version, which creates the layout but doesn't include the editing interface. You can upgrade to the full version and customize your site yourself - you don't even need to know how to program!", 'wpv-views'); ?></p>
56
-
57
- <p style="font-size: 120%;"><?php echo sprintf(__('Once you have installed the full versions of Types and Views you\'ll be able to create and edit your own content types, layouts and listings.', 'wpv-views'),
58
- 'http://wordpress.org/extend/plugins/types/',
59
- 'http://wp-types.com' . $affiliate_url); ?></p>
60
-
61
- <p style="font-size: 140%; font-weight: bold; "><?php echo sprintf(__('<a href="%s" target="_blank">Learn more</a>', 'wpv-views'),
62
- 'http://wp-types.com' . $affiliate_url); ?></p>
63
-
64
- <br /><hr /><br />
65
- <ol>
66
- <li><?php _e('Every purchase of Views entitles you to commercial-grade support and upgrades for one year.','wpv-views'); ?></li>
67
- <li><?php _e('You can use Types and Views for as many themes and websites as you like.','wpv-views'); ?></li>
68
- </ol>
69
-
70
- <?php
71
-
72
- //if ($promote_types && $promote_views) {
73
- //
74
- // wpv_promote_views_admin();
75
- // echo "<hr />\n";
76
- // wpcf_promote_types_admin();
77
- //} else {
78
- // if ($promote_types) {
79
- // wpcf_promote_types_admin();
80
- // } else {
81
- // wpv_promote_views_admin();
82
- // }
83
- //}
84
-
85
- ?>
86
- </div>
87
- <?php
88
-
89
- }
90
-
91
-
92
- }
93
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
embedded/common/views/res/img/views-32.png DELETED
Binary file
embedded/common/visual-editor/editor-addon.class.php CHANGED
@@ -17,9 +17,17 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
17
  * @param string $text_area
18
  * @param boolean $standard_v is this a standard V button
19
  */
20
- function add_form_button( $context, $text_area = '', $standard_v = true, $add_views = false, $codemirror_button = false ) {
 
 
 
 
 
 
 
 
21
  global $wp_version;
22
-
23
  if ( empty($context) && $text_area == '' ){
24
  return;
25
  }
@@ -84,21 +92,19 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
84
  $menus = $this->sort_menus_alphabetically( $menus );
85
  }
86
 
87
-
88
  $this->_media_menu_direct_links = array();
89
- $menus_output = $this->_output_media_menu( $menus, $text_area,
90
- $standard_v );
91
 
92
  $direct_links = implode( ' ', $this->_media_menu_direct_links );
93
  $dropdown_class = 'js-editor_addon_dropdown-'.$this->name;
94
  $icon_class = 'js-wpv-shortcode-post-icon-'.$this->name;
95
- if ( $this->name == 'wpv-views' ) {
96
- $button_label = __( 'Fields and Views', 'wpv-views' );
97
- } else if ( $this->name == 'types' ) {
98
- $button_label = __( 'Types', 'wpv-views' );
99
- } else {
100
- $button_label = '';
101
- }
102
 
103
  if( '' !== $this->media_button_image )
104
  {
@@ -157,6 +163,9 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
157
 
158
  /**
159
  * Adding a "V" button to the menu (for user fields)
 
 
 
160
  * @param string $context
161
  * @param string $text_area
162
  * @param boolean $standard_v is this a standard V button
@@ -193,13 +202,13 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
193
  array(__('User Status', 'wpv-views'), 'wpv-user field="user_status"',__('Basic', 'wpv-views'),''),
194
  array(__('User Spam Status', 'wpv-views'), 'wpv-user field="spam"',__('Basic', 'wpv-views'),'')
195
  );
196
-
197
  if ( isset( $sitepress ) && function_exists( 'wpml_string_shortcode' ) ) {
198
  $nonce = wp_create_nonce('wpv_editor_callback');
199
  $this->items[] = array(__('Translatable string', 'wpv-views'), 'wpml-string',__('Basic', 'wpv-views'),'WPViews.shortcodes_gui.wpv_insert_translatable_string_popup(\'' . $nonce . '\')');
200
  }
201
-
202
-
203
 
204
  $meta_keys = get_user_meta_keys();
205
  $all_types_fields = get_option( 'wpcf-fields', array() );
@@ -213,7 +222,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
213
  if ( preg_match($exclude_these_hidden_var , $key) ){
214
  continue;
215
  }
216
- $this->items[] = array($key,
217
  'wpv-user field="'.$key.'"',
218
  __('Users fields', 'wpv-views'),'');
219
  }
@@ -222,16 +231,16 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
222
  if ( preg_match($exclude_these_hidden_var , $key) ){
223
  continue;
224
  }
225
- $this->items[] = array($key,
226
  'wpv-user field="'.$key.'"',
227
  __('User fields', 'wpv-views'),'');
228
  }
229
-
230
  }
231
-
232
  if ( function_exists('wpcf_init') ){
233
  //Get types groups and fields
234
- $groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
235
  $user_id = wpcf_usermeta_get_user();
236
  $add = array();
237
  if ( !empty( $groups ) ) {
@@ -242,16 +251,16 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
242
  $fields = wpcf_admin_fields_get_fields_by_group( $group['id'],
243
  'slug', true, false, true, 'wp-types-user-group',
244
  'wpcf-usermeta' );
245
-
246
  if ( !empty( $fields ) ) {
247
  foreach ( $fields as $field_id => $field ) {
248
  $add[] = $field['meta_key'];
249
  $callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'views-usermeta\', -1)';
250
- $this->items[] = array($field['name'],
251
  'types usermeta="'.$field['meta_key'].'"][/types',
252
- $group['name'],$callback);
253
-
254
-
255
  }
256
  }
257
  }
@@ -262,20 +271,20 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
262
  foreach ( $cf_types as $cf_id => $cf ) {
263
  if ( !in_array( $cf['meta_key'], $add) ){
264
  $callback = 'wpcfFieldsEditorCallback(\'' . $cf['id'] . '\', \'views-usermeta\', -1)';
265
- $this->items[] = array($cf['name'],
266
  'types usermeta="'.$cf['meta_key'].'"][/types',
267
- __('Types fields', 'wpv-views'),$callback);
268
-
269
  }
270
  }
271
  }
272
-
273
  $view_available = $wpdb->get_results("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_type='view' AND post_status in ('publish')");
274
  foreach($view_available as $view) {
275
 
276
  $view_settings = get_post_meta($view->ID, '_wpv_settings', true);
277
  if (isset($view_settings['query_type'][0]) && $view_settings['query_type'][0] == 'posts' && !$WP_Views->is_archive_view($view->ID)) {
278
-
279
  $this->items[] = array($view->post_title,
280
  $view->post_title,
281
  __('Post View', 'wpv-views'),
@@ -283,12 +292,12 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
283
  );
284
  }
285
  }
286
-
287
  $out = array();
288
-
289
  $menus = array();
290
  $sub_menus = array();
291
-
292
  if( $this->items )
293
  foreach ( $this->items as $item ) {
294
  $parts = explode( '-!-', $item[2] );
@@ -304,8 +313,8 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
304
  $menu_level[$item[0]] = $item;
305
  }
306
 
307
-
308
-
309
 
310
  // Sort menus
311
  if ( is_array( $menus ) ) {
@@ -365,7 +374,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
365
  } else {
366
  return apply_filters( 'wpv_add_media_buttons', $context . $out );
367
  }
368
-
369
  }
370
 
371
  /**
@@ -567,12 +576,12 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
567
 
568
  // add parent groups for vew templates
569
  function add_view_template_parent_groups( $items ) {
570
- global $post;
571
  // get current View ID
572
  $view_template_id = $post->ID;
573
 
574
  // get all view templates attached in the Settings page for single view
575
- $view_template_relations = $this->get_view_template_settings();
576
 
577
  // find view template groups and get their parents
578
  $current_types = array();
@@ -656,13 +665,25 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
656
  return $searchbar;
657
  }
658
 
 
 
 
 
 
659
  function add_view_type( &$menus, $post_type, $post_name ) {
660
  global $wpdb;
661
  $all_post_types = implode( ' ',
662
  get_post_types( array('public' => true) ) );
663
 
664
- $view_templates_available = $wpdb->get_results( "SELECT ID, post_title, post_name FROM {$wpdb->posts} WHERE
665
- post_type='{$post_type}' AND post_status in ('publish')" );
 
 
 
 
 
 
 
666
  $menus[$post_name] = array();
667
  $menus[$post_name]['css'] = $all_post_types;
668
 
@@ -706,22 +727,6 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
706
  $vtemplate_index++;
707
  }
708
  }
709
-
710
- function get_view_template_settings() {
711
- $post_types = get_post_types();
712
-
713
- $options = array();
714
- $wpv_options = get_option( 'wpv_options' );
715
-
716
- foreach ( $post_types as $type ) {
717
- if ( isset( $wpv_options['views_template_for_' . $type] ) && !empty( $wpv_options['views_template_for_' . $type] ) ) {
718
- $options[$type] = $wpv_options['views_template_for_' . $type];
719
- }
720
- }
721
-
722
- return $options;
723
- }
724
-
725
  }
726
 
727
  /*
@@ -729,8 +734,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
729
  */
730
  function wpv_mce_add_button( $buttons )
731
  {
732
- array_push( $buttons, "separator",
733
- str_replace( '-', '_', $this->name ) );
734
  return $buttons;
735
  }
736
 
@@ -777,8 +781,6 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
777
  <?php
778
  }
779
  }
780
-
781
-
782
 
783
  }
784
 
17
  * @param string $text_area
18
  * @param boolean $standard_v is this a standard V button
19
  */
20
+ function add_form_button( $context, $text_area = '', $standard_v = true, $add_views = false, $codemirror_button = false )
21
+ {
22
+ /**
23
+ * turn off button
24
+ */
25
+ if ( !apply_filters('toolset_editor_add_form_buttons', true) ) {
26
+ return;
27
+ }
28
+
29
  global $wp_version;
30
+
31
  if ( empty($context) && $text_area == '' ){
32
  return;
33
  }
92
  $menus = $this->sort_menus_alphabetically( $menus );
93
  }
94
 
 
95
  $this->_media_menu_direct_links = array();
96
+ $menus_output = $this->_output_media_menu( $menus, $text_area, $standard_v );
 
97
 
98
  $direct_links = implode( ' ', $this->_media_menu_direct_links );
99
  $dropdown_class = 'js-editor_addon_dropdown-'.$this->name;
100
  $icon_class = 'js-wpv-shortcode-post-icon-'.$this->name;
101
+ if ( $this->name == 'wpv-views' ) {
102
+ $button_label = __( 'Fields and Views', 'wpv-views' );
103
+ } else if ( $this->name == 'types' ) {
104
+ $button_label = __( 'Types', 'wpv-views' );
105
+ } else {
106
+ $button_label = '';
107
+ }
108
 
109
  if( '' !== $this->media_button_image )
110
  {
163
 
164
  /**
165
  * Adding a "V" button to the menu (for user fields)
166
+ *
167
+ * @global object $wpdb
168
+ *
169
  * @param string $context
170
  * @param string $text_area
171
  * @param boolean $standard_v is this a standard V button
202
  array(__('User Status', 'wpv-views'), 'wpv-user field="user_status"',__('Basic', 'wpv-views'),''),
203
  array(__('User Spam Status', 'wpv-views'), 'wpv-user field="spam"',__('Basic', 'wpv-views'),'')
204
  );
205
+
206
  if ( isset( $sitepress ) && function_exists( 'wpml_string_shortcode' ) ) {
207
  $nonce = wp_create_nonce('wpv_editor_callback');
208
  $this->items[] = array(__('Translatable string', 'wpv-views'), 'wpml-string',__('Basic', 'wpv-views'),'WPViews.shortcodes_gui.wpv_insert_translatable_string_popup(\'' . $nonce . '\')');
209
  }
210
+
211
+
212
 
213
  $meta_keys = get_user_meta_keys();
214
  $all_types_fields = get_option( 'wpcf-fields', array() );
222
  if ( preg_match($exclude_these_hidden_var , $key) ){
223
  continue;
224
  }
225
+ $this->items[] = array($key,
226
  'wpv-user field="'.$key.'"',
227
  __('Users fields', 'wpv-views'),'');
228
  }
231
  if ( preg_match($exclude_these_hidden_var , $key) ){
232
  continue;
233
  }
234
+ $this->items[] = array($key,
235
  'wpv-user field="'.$key.'"',
236
  __('User fields', 'wpv-views'),'');
237
  }
238
+
239
  }
240
+
241
  if ( function_exists('wpcf_init') ){
242
  //Get types groups and fields
243
+ $groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
244
  $user_id = wpcf_usermeta_get_user();
245
  $add = array();
246
  if ( !empty( $groups ) ) {
251
  $fields = wpcf_admin_fields_get_fields_by_group( $group['id'],
252
  'slug', true, false, true, 'wp-types-user-group',
253
  'wpcf-usermeta' );
254
+
255
  if ( !empty( $fields ) ) {
256
  foreach ( $fields as $field_id => $field ) {
257
  $add[] = $field['meta_key'];
258
  $callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'views-usermeta\', -1)';
259
+ $this->items[] = array($field['name'],
260
  'types usermeta="'.$field['meta_key'].'"][/types',
261
+ $group['name'],$callback);
262
+
263
+
264
  }
265
  }
266
  }
271
  foreach ( $cf_types as $cf_id => $cf ) {
272
  if ( !in_array( $cf['meta_key'], $add) ){
273
  $callback = 'wpcfFieldsEditorCallback(\'' . $cf['id'] . '\', \'views-usermeta\', -1)';
274
+ $this->items[] = array($cf['name'],
275
  'types usermeta="'.$cf['meta_key'].'"][/types',
276
+ __('Types fields', 'wpv-views'),$callback);
277
+
278
  }
279
  }
280
  }
281
+
282
  $view_available = $wpdb->get_results("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_type='view' AND post_status in ('publish')");
283
  foreach($view_available as $view) {
284
 
285
  $view_settings = get_post_meta($view->ID, '_wpv_settings', true);
286
  if (isset($view_settings['query_type'][0]) && $view_settings['query_type'][0] == 'posts' && !$WP_Views->is_archive_view($view->ID)) {
287
+
288
  $this->items[] = array($view->post_title,
289
  $view->post_title,
290
  __('Post View', 'wpv-views'),
292
  );
293
  }
294
  }
295
+
296
  $out = array();
297
+
298
  $menus = array();
299
  $sub_menus = array();
300
+
301
  if( $this->items )
302
  foreach ( $this->items as $item ) {
303
  $parts = explode( '-!-', $item[2] );
313
  $menu_level[$item[0]] = $item;
314
  }
315
 
316
+
317
+
318
 
319
  // Sort menus
320
  if ( is_array( $menus ) ) {
374
  } else {
375
  return apply_filters( 'wpv_add_media_buttons', $context . $out );
376
  }
377
+
378
  }
379
 
380
  /**
576
 
577
  // add parent groups for vew templates
578
  function add_view_template_parent_groups( $items ) {
579
+ global $post, $WPV_settings;
580
  // get current View ID
581
  $view_template_id = $post->ID;
582
 
583
  // get all view templates attached in the Settings page for single view
584
+ $view_template_relations = $WPV_settings->get_view_template_settings();
585
 
586
  // find view template groups and get their parents
587
  $current_types = array();
665
  return $searchbar;
666
  }
667
 
668
+ /**
669
+ *
670
+ * @global object $wpdb
671
+ *
672
+ */
673
  function add_view_type( &$menus, $post_type, $post_name ) {
674
  global $wpdb;
675
  $all_post_types = implode( ' ',
676
  get_post_types( array('public' => true) ) );
677
 
678
+ $view_templates_available = $wpdb->get_results(
679
+ $wpdb->prepare(
680
+ "SELECT ID, post_title, post_name FROM {$wpdb->posts}
681
+ WHERE post_type = %s
682
+ AND post_status in (%s)",
683
+ $post_type,
684
+ 'publish'
685
+ )
686
+ );
687
  $menus[$post_name] = array();
688
  $menus[$post_name]['css'] = $all_post_types;
689
 
727
  $vtemplate_index++;
728
  }
729
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
730
  }
731
 
732
  /*
734
  */
735
  function wpv_mce_add_button( $buttons )
736
  {
737
+ array_push( $buttons, "separator", str_replace( '-', '_', $this->name ) );
 
738
  return $buttons;
739
  }
740
 
781
  <?php
782
  }
783
  }
 
 
784
 
785
  }
786
 
embedded/common/visual-editor/res/js/icl_editor_addon_plugin.js CHANGED
@@ -802,41 +802,76 @@ var icl_editor = (function(window, $){
802
 
803
  function isCodeMirror($textarea)
804
  {
805
- //EMERSON: isCodeMirror method revision: WordPress 4.1 compatibility
806
- //Contact me if you have questions regarding this revision.
807
-
808
- var textareaNext = $textarea[0].nextSibling;
809
- // if CodeMirror
810
- if (
811
- //Usual way before WordPress 4.1
812
- textareaNext && $textarea.is('textarea')&&
813
- textareaNext.CodeMirror &&
814
- $textarea[0]==textareaNext.CodeMirror.getTextArea()
815
- ) {
816
- return textareaNext.CodeMirror;
817
- } else {
818
- //Emerson: WordPress 4.0+ introduces 'content-textarea-clone' div which in some instances loaded before the code mirror div
819
- //This core feature in WP is used in their auto-resize editor and distraction free writing.
820
- //This is particularly found in pages and post affecting syntax highlighting in these areas.
821
- //Let's skip and check if the nextsibling is really the code mirror div
822
-
823
- if(typeof textareaNext === 'undefined'){
824
- //Undefined
825
- return false;
826
- } else if (textareaNext) {
827
-
828
- var textareaNextnext=textareaNext.nextSibling;
829
- if (
830
- textareaNextnext && $textarea.is('textarea')&&
831
- textareaNextnext.CodeMirror &&
832
- $textarea[0]==textareaNextnext.CodeMirror.getTextArea()
833
- ) {
834
- return textareaNextnext.CodeMirror;
835
- }
836
- }
837
- }
 
 
 
 
 
 
 
 
838
  return false;
839
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
840
 
841
  function getContent($area)
842
  {
802
 
803
  function isCodeMirror($textarea)
804
  {
805
+ if ( ! $textarea.is('textarea') ) {
806
+ return false;
807
+ }
808
+ var textareaNext = $textarea[0].nextSibling;
809
+ if ( typeof textareaNext === 'undefined' ) {
810
+ return false;
811
+ }
812
+ if ( textareaNext ) {
813
+ //Usual way before WordPress 4.1
814
+ if (
815
+ textareaNext.CodeMirror
816
+ && $textarea[0] == textareaNext.CodeMirror.getTextArea()
817
+ ) {
818
+ return textareaNext.CodeMirror;
819
+ }
820
+ // Juan: CodeMirror panels wrap the CodeMirror div and themselves into a div.
821
+ // Depending on the panels position, the CodeMirror div becomes the first or last child of that wrapper.
822
+ // We need to check if the relevant node contains the right CodeMirror div as a child node.
823
+ // Note that we will do the same below, so we can have CodeMirror panels in main editors too.
824
+ var textareaNextHasPanels = isCodeMirrorWithPanels( $textarea, textareaNext );
825
+ if ( textareaNextHasPanels ) {
826
+ return textareaNextHasPanels;
827
+ }
828
+ // Emerson: WordPress 4.0+ introduces 'content-textarea-clone' div which in some instances is loaded after our textarea and before the CodeMirror div.
829
+ // This core feature in WP is used in their auto-resize editor and distraction free writing.
830
+ // This is particularly found in pages and post affecting syntax highlighting in main editors.
831
+ // Let's skip that node and check if the nextsibling is really the CodeMirror div.
832
+ var textareaNextNext = textareaNext.nextSibling;
833
+ if ( textareaNextNext ) {
834
+ if (
835
+ textareaNextNext.CodeMirror
836
+ && $textarea[0] == textareaNextNext.CodeMirror.getTextArea()
837
+ ) {
838
+ return textareaNextNext.CodeMirror;
839
+ }
840
+ var textareaNextNextHasPanels = isCodeMirrorWithPanels( $textarea, textareaNextNext );
841
+ if ( textareaNextNextHasPanels ) {
842
+ return textareaNextNextHasPanels;
843
+ }
844
+ }
845
+ }
846
  return false;
847
  };
848
+
849
+ function isCodeMirrorWithPanels( $textarea, candidateNode ) {
850
+ if ( ! $textarea.is('textarea') ) {
851
+ return false;
852
+ }
853
+ if ( typeof candidateNode === 'undefined' ) {
854
+ return false;
855
+ }
856
+ if ( candidateNode ) {
857
+ var candidateNodeFirstChild = candidateNode.firstChild,
858
+ candidateNodeLastChiild = candidateNode.lastChild;
859
+ if (
860
+ candidateNodeFirstChild
861
+ && candidateNodeFirstChild.CodeMirror
862
+ && $textarea[0] == candidateNodeFirstChild.CodeMirror.getTextArea()
863
+ ) {
864
+ return candidateNodeFirstChild.CodeMirror;
865
+ } else if (
866
+ candidateNodeLastChiild
867
+ && candidateNodeLastChiild.CodeMirror
868
+ && $textarea[0] == candidateNodeLastChiild.CodeMirror.getTextArea()
869
+ ) {
870
+ return candidateNodeLastChiild.CodeMirror;
871
+ }
872
+ }
873
+ return false;
874
+ }
875
 
876
  function getContent($area)
877
  {
embedded/common/wplogger.php CHANGED
@@ -4,12 +4,12 @@
4
  *
5
  *
6
  *
7
- Plugin Name: Wordpress Logger
8
- Plugin URI: http://www.turingtarpit.com/2009/05/wordpress-logger-a-plugin-to-display-php-log-messages-in-safari-and-firefox/
9
- Description: Displays log messages in the browser console in Safari, Firefox and Opera. Useful for plugin and theme developers to debug PHP code.
10
- Version: 0.3
11
- Author: Chandima Cumaranatunge
12
- Author URI: http://www.turingtarpit.com
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License as published by
4
  *
5
  *
6
  *
7
+ Wordpress Logger
8
+ http://www.turingtarpit.com/2009/05/wordpress-logger-a-plugin-to-display-php-log-messages-in-safari-and-firefox/
9
+ Displays log messages in the browser console in Safari, Firefox and Opera. Useful for plugin and theme developers to debug PHP code.
10
+ 0.3
11
+ Chandima Cumaranatunge
12
+ http://www.turingtarpit.com
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License as published by
embedded/frontend.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Frontend functions.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/frontend.php $
6
- * $LastChangedDate: 2015-01-28 06:42:34 +0000 (Wed, 28 Jan 2015) $
7
- * $LastChangedRevision: 1077234 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -82,8 +82,11 @@ function wpcf_shortcode( $atts, $content = null, $code = '' ) {
82
  * @param type $atts
83
  * @return type
84
  */
85
- function types_render_field( $field_id, $params, $content = null, $code = '' )
86
  {
 
 
 
87
 
88
  global $wpcf;
89
 
@@ -548,19 +551,63 @@ function wpcf_views_query( $query, $view_settings ) {
548
  }
549
  $options = $opt[$field_name]['data']['options'];
550
 
551
- foreach ( $values as $value ) {
552
- foreach ( $options as $key => $option ) {
553
- if ( $option['title'] == $value ) {
554
- $query['meta_query'][] = array(
555
- 'key' => $meta['key'],
556
- 'compare' => 'NOT IN' == $orginal['compare']? 'NOT LIKE':'LIKE',
557
- 'value' => $key,
558
- 'type' => 'CHAR',
559
- );
560
- break;
561
- }
562
- }
563
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
564
  }
565
  }
566
  }
2
  /*
3
  * Frontend functions.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/frontend.php $
6
+ * $LastChangedDate: 2015-03-10 06:46:08 +0000 (Tue, 10 Mar 2015) $
7
+ * $LastChangedRevision: 1109249 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
82
  * @param type $atts
83
  * @return type
84
  */
85
+ function types_render_field( $field_id = null, $params = array(), $content = null, $code = '' )
86
  {
87
+ if ( empty($field_id) ) {
88
+ return '';
89
+ }
90
 
91
  global $wpcf;
92
 
551
  }
552
  $options = $opt[$field_name]['data']['options'];
553
 
554
+ global $wp_version;
555
+
556
+ if ( version_compare( $wp_version, '4.1', '<' ) ) {
557
+ // We can not use nested meta_query entries
558
+ foreach ( $values as $value ) {
559
+ foreach ( $options as $key => $option ) {
560
+ if ( $option['title'] == $value ) {
561
+ $query['meta_query'][] = array(
562
+ 'key' => $meta['key'],
563
+ 'compare' => in_array( $orginal['compare'], array( '!=', 'NOT LIKE', 'NOT IN' ) ) ? 'NOT LIKE' : 'LIKE',
564
+ 'value' => $key,
565
+ 'type' => 'CHAR',
566
+ );
567
+ break;
568
+ }
569
+ }
570
+ }
571
+ } else {
572
+ // We can use nested meta_query entries
573
+ if ( count( $values ) < 2 ) {
574
+ // Only one value to filter by, so no need to add nested meta_query entries
575
+ foreach ( $values as $value ) {
576
+ foreach ( $options as $key => $option ) {
577
+ if ( $option['title'] == $value ) {
578
+ $query['meta_query'][] = array(
579
+ 'key' => $meta['key'],
580
+ 'compare' => in_array( $orginal['compare'], array( '!=', 'NOT LIKE', 'NOT IN' ) ) ? 'NOT LIKE' : 'LIKE',
581
+ 'value' => $key,
582
+ 'type' => 'CHAR',
583
+ );
584
+ break;
585
+ }
586
+ }
587
+ }
588
+ } else {
589
+ // We will translate each value into a meta_query clause and add them all as a nested meta_query entry
590
+ $inner_relation = in_array( $orginal['compare'], array( '!=', 'NOT LIKE', 'NOT IN' ) ) ? 'AND' : 'OR';
591
+ $inner_compare = in_array( $orginal['compare'], array( '!=', 'NOT LIKE', 'NOT IN' ) ) ? 'NOT LIKE' : 'LIKE';
592
+ $inner_meta_query = array(
593
+ 'relation' => $inner_relation
594
+ );
595
+ foreach ( $values as $value ) {
596
+ foreach ( $options as $key => $option ) {
597
+ if ( $option['title'] == $value ) {
598
+ $inner_meta_query[] = array(
599
+ 'key' => $meta['key'],
600
+ 'compare' => $inner_compare,
601
+ 'value' => $key,
602
+ 'type' => 'CHAR',
603
+ );
604
+ break;
605
+ }
606
+ }
607
+ }
608
+ $query['meta_query'][] = $inner_meta_query;
609
+ }
610
+ }
611
  }
612
  }
613
  }
embedded/functions.php CHANGED
@@ -3,9 +3,9 @@
3
  * Basic and init functions.
4
  * Since Types 1.2 moved from /embedded/types.php
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/functions.php $
7
- * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
8
- * $LastChangedRevision: 1069430 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
@@ -149,10 +149,6 @@ function wpcf_embedded_check_import()
149
  $_POST['overwrite-fields'] = 1;
150
  $_POST['overwrite-types'] = 1;
151
  $_POST['overwrite-tax'] = 1;
152
- // $_POST['delete-groups'] = 0;
153
- // $_POST['delete-fields'] = 0;
154
- // $_POST['delete-types'] = 0;
155
- // $_POST['delete-tax'] = 0;
156
  $_POST['post_relationship'] = 1;
157
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
158
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/import-export.php';
@@ -169,38 +165,6 @@ function wpcf_embedded_check_import()
169
  }
170
  }
171
 
172
- /**
173
- * Display information about upgrading to the plugin version of types.
174
- *
175
- */
176
- function wpcf_promote_types_admin()
177
- {
178
- $custom_types = get_option( 'wpcf-custom-types', array() );
179
-
180
- ?>
181
-
182
- <?php
183
- if ( sizeof( $custom_types ) > 0 ) {
184
- echo '<p>' . __( 'Types creates Custom Post Types. These are user-defined WordPress content types. On your theme the following types are defined:',
185
- 'wpcf' ) . "</p>\n";
186
- echo "<ul style='margin-left:20px;'>\n";
187
- foreach ( $custom_types as $type ) {
188
- echo "<li>" . $type['labels']['name'] . "</li>\n";
189
- }
190
- echo "</ul>\n";
191
- }
192
-
193
- ?>
194
- <p><?php
195
- echo sprintf( __( 'If you want to edit these or create your own you can download the full version of <strong>Types</strong> from <a href="%s">%s</a>',
196
- 'wpcf' ), 'http://wordpress.org/extend/plugins/types/',
197
- 'http://wordpress.org/extend/plugins/types/' );
198
-
199
- ?></p>
200
-
201
- <?php
202
- }
203
-
204
  /**
205
  * Actions for outside fields control.
206
  *
@@ -510,13 +474,12 @@ function wpcf_enqueue_scripts()
510
  /**
511
  * Basic JS
512
  */
513
- wp_enqueue_script( 'wpcf-js', WPCF_RES_RELPATH . '/js/basic.js',
514
- array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs'),
515
- WPCF_VERSION.'-C1' );
516
- /**
517
- * Basic CSS
518
- */
519
- wp_enqueue_style('wpcf-css');
520
  }
521
  /**
522
  * Basic JS
@@ -525,7 +488,7 @@ function wpcf_enqueue_scripts()
525
  'wpcf-js-embedded',
526
  WPCF_EMBEDDED_RES_RELPATH . '/js/basic.js',
527
  array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs'),
528
- WPCF_VERSION.'-D9'
529
  );
530
  /*
531
  *
3
  * Basic and init functions.
4
  * Since Types 1.2 moved from /embedded/types.php
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/functions.php $
7
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
8
+ * $LastChangedRevision: 1120400 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
149
  $_POST['overwrite-fields'] = 1;
150
  $_POST['overwrite-types'] = 1;
151
  $_POST['overwrite-tax'] = 1;
 
 
 
 
152
  $_POST['post_relationship'] = 1;
153
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
154
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/import-export.php';
165
  }
166
  }
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  /**
169
  * Actions for outside fields control.
170
  *
474
  /**
475
  * Basic JS
476
  */
477
+ wp_enqueue_script(
478
+ 'wpcf-js',
479
+ WPCF_RES_RELPATH . '/js/basic.js',
480
+ array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs'),
481
+ WPCF_VERSION
482
+ );
 
483
  }
484
  /**
485
  * Basic JS
488
  'wpcf-js-embedded',
489
  WPCF_EMBEDDED_RES_RELPATH . '/js/basic.js',
490
  array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs'),
491
+ WPCF_VERSION
492
  );
493
  /*
494
  *
embedded/includes/ajax.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  /**
4
  * All AJAX calls go here.
 
 
5
  */
6
  function wpcf_ajax_embedded() {
7
 
@@ -11,9 +13,10 @@ function wpcf_ajax_embedded() {
11
  }
12
  } else {
13
 
14
- if ( !isset( $_REQUEST['_wpnonce'] )
15
- || !wp_verify_nonce( $_REQUEST['_wpnonce'],
16
- $_REQUEST['wpcf_action'] ) ) {
 
17
  die( 'Verification failed' );
18
  }
19
  }
@@ -22,72 +25,80 @@ function wpcf_ajax_embedded() {
22
 
23
  switch ( $_REQUEST['wpcf_action'] ) {
24
 
25
- case 'editor_insert_date':
26
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/date.php';
27
- wpcf_fields_date_editor_form();
28
- break;
29
-
30
  case 'insert_skype_button':
 
 
 
 
31
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/skype.php';
32
  wpcf_fields_skype_meta_box_ajax();
33
  break;
34
 
35
  case 'editor_callback':
 
 
 
 
36
  // Determine Field type and context
37
  $views_usermeta = false;
 
 
 
38
  if ( isset( $_GET['field_type'] ) && $_GET['field_type'] == 'usermeta' ) {
39
  // Group filter
40
  wp_enqueue_script( 'suggest' );
41
- $field = types_get_field( $_GET['field_id'], 'usermeta' );
42
  $meta_type = 'usermeta';
43
  }
44
  elseif ( isset( $_GET['field_type'] ) && $_GET['field_type'] == 'views-usermeta' ){
45
- $field = types_get_field( $_GET['field_id'], 'usermeta' );
46
  $meta_type = 'usermeta';
47
  $views_usermeta = true;
48
  }else {
49
- $field = types_get_field( $_GET['field_id'] );
50
  $meta_type = 'postmeta';
51
  }
52
- $post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : null;
 
53
  $shortcode = isset( $_GET['shortcode'] ) ? urldecode( $_GET['shortcode'] ) : null;
54
- $callback = isset( $_GET['callback'] ) ? $_GET['callback'] : false;
55
  if ( !empty( $field ) ) {
56
  // Editor
57
  WPCF_Loader::loadClass( 'editor' );
58
  $editor = new WPCF_Editor();
59
- $editor->frame( $field, $meta_type, $post_id, $shortcode,
60
  $callback, $views_usermeta );
61
  }
62
  break;
63
 
64
  case 'dismiss_message':
65
- if ( isset( $_GET['id'] ) ) {
66
- $messages = get_option( 'wpcf_dismissed_messages', array() );
67
- $messages[] = $_GET['id'];
68
- update_option( 'wpcf_dismissed_messages', $messages );
69
  }
70
- break;
71
 
72
- case '_dismiss_message':
73
  if ( isset( $_GET['id'] ) ) {
74
- $messages = get_option( '_wpcf_dismissed_messages', array() );
75
- $messages[strval( $_GET['id'] )] = strval( $_GET['id'] );
76
- update_option( '_wpcf_dismissed_messages', $messages );
77
  }
78
  break;
79
 
80
  case 'pr_add_child_post':
81
  $output = 'Passed wrong parameters';
82
- if ( isset( $_GET['post_id'] )
83
- && isset( $_GET['post_type_child'] )
84
- && isset( $_GET['post_type_parent'] ) ) {
 
 
 
85
 
86
  $relationships = get_option( 'wpcf_post_relationship', array() );
87
- $post = get_post( intval( $_GET['post_id'] ) );
88
- if ( !empty( $post->ID ) ) {
89
- $post_type = strval( $_GET['post_type_child'] );
90
- $parent_post_type = strval( $_GET['post_type_parent'] );
 
 
91
  $data = $relationships[$parent_post_type][$post_type];
92
  /*
93
  * Since Types 1.1.5
@@ -95,8 +106,7 @@ function wpcf_ajax_embedded() {
95
  * We save new post
96
  * CHECKPOINT
97
  */
98
- $id = $wpcf->relationship->add_new_child( $post->ID,
99
- $post_type );
100
 
101
  if ( is_wp_error( $id ) ) {
102
  $output = $id->get_error_message();
@@ -105,7 +115,7 @@ function wpcf_ajax_embedded() {
105
  * Here we set Relationship
106
  * CHECKPOINT
107
  */
108
- $parent = get_post( intval( $_GET['post_id'] ) );
109
  $child = get_post( $id );
110
  if ( !empty( $parent->ID ) && !empty( $child->ID ) ) {
111
 
@@ -116,11 +126,10 @@ function wpcf_ajax_embedded() {
116
  $wpcf->relationship->_set( $parent, $child, $data );
117
 
118
  // Render new row
119
- $output = $wpcf->relationship->child_row( $post->ID,
120
  $id, $data );
121
  } else {
122
- $output = __( 'Error creating post relationship',
123
- 'wpcf' );
124
  }
125
  }
126
  } else {
@@ -142,14 +151,17 @@ function wpcf_ajax_embedded() {
142
 
143
  case 'pr_save_all':
144
  $output = '';
145
- if ( isset( $_POST['post_id'] ) ) {
146
 
147
  $parent_id = intval( $_POST['post_id'] );
 
148
  if ( isset( $_POST['wpcf_post_relationship'][$parent_id] ) ) {
149
- $wpcf->relationship->save_children( $parent_id,
150
- (array) $_POST['wpcf_post_relationship'][$parent_id] );
 
 
151
  $output = $wpcf->relationship->child_meta_form(
152
- $parent_id, strval( $_POST['post_type'] )
153
  );
154
  }
155
  }
@@ -172,7 +184,7 @@ function wpcf_ajax_embedded() {
172
  case 'pr_save_child_post':
173
  ob_start(); // Try to catch any errors
174
  $output = '';
175
- if ( isset( $_GET['post_id'] )
176
  && isset( $_GET['parent_id'] )
177
  && isset( $_GET['post_type_parent'] )
178
  && isset( $_GET['post_type_child'] )
@@ -180,20 +192,21 @@ function wpcf_ajax_embedded() {
180
 
181
  $parent_id = intval( $_GET['parent_id'] );
182
  $child_id = intval( $_GET['post_id'] );
183
- $parent_post_type = strval( $_GET['post_type_parent'] );
184
- $child_post_type = strval( $_GET['post_type_child'] );
 
185
  if ( isset( $_POST['wpcf_post_relationship'][$parent_id][$child_id] ) ) {
186
- $fields = (array) $_POST['wpcf_post_relationship'][$parent_id][$child_id];
187
- $wpcf->relationship->save_child( $parent_id, $child_id,
188
- $fields );
189
- $output = $wpcf->relationship->child_row( $parent_id,
 
190
  $child_id,
191
- $wpcf->relationship->settings( $parent_post_type,
192
- $child_post_type ) );
193
  if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
194
- // TODO Move to conditional
195
- $output .= '<script type="text/javascript">wpcfConditionalInit(\'#types-child-row-'
196
- . $child_id . '\');</script>';
197
  }
198
  }
199
  }
@@ -215,7 +228,7 @@ function wpcf_ajax_embedded() {
215
  case 'pr_delete_child_post':
216
  require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
217
  $output = 'Passed wrong parameters';
218
- if ( isset( $_GET['post_id'] ) ) {
219
  $output = wpcf_pr_admin_delete_child_item( intval( $_GET['post_id'] ) );
220
  }
221
  echo json_encode( array(
@@ -226,10 +239,17 @@ function wpcf_ajax_embedded() {
226
  case 'pr-update-belongs':
227
  require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
228
  $output = 'Passed wrong parameters';
229
- if ( isset( $_POST['post_id'] ) && isset( $_POST['wpcf_pr_belongs'][$_POST['post_id']] ) ) {
230
- $post_id = intval( $_POST['post_id'] );
231
- $updated = wpcf_pr_admin_update_belongs( $post_id,
232
- $_POST['wpcf_pr_belongs'][$post_id] );
 
 
 
 
 
 
 
233
  $output = is_wp_error( $updated ) ? $updated->get_error_message() : $updated;
234
  }
235
  if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
@@ -249,10 +269,10 @@ function wpcf_ajax_embedded() {
249
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
250
  require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
251
  $output = 'Passed wrong parameters';
252
- if ( isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
253
  global $wpcf;
254
- $parent = get_post( esc_attr( $_GET['post_id'] ) );
255
- $child_post_type = esc_attr( $_GET['post_type'] );
256
 
257
  if ( !empty( $parent->ID ) ) {
258
 
@@ -284,9 +304,9 @@ function wpcf_ajax_embedded() {
284
 
285
  case 'pr_sort':
286
  $output = 'Passed wrong parameters';
287
- if ( isset( $_GET['field'] ) && isset( $_GET['sort'] ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
288
  $output = $wpcf->relationship->child_meta_form(
289
- intval( $_GET['post_id'] ), strval( $_GET['post_type'] )
290
  );
291
  }
292
  if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
@@ -301,7 +321,8 @@ function wpcf_ajax_embedded() {
301
  }
302
  break;
303
 
304
- case 'pr_sort_parent':
 
305
  $output = 'Passed wrong parameters';
306
  if ( isset( $_GET['field'] ) && isset( $_GET['sort'] ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
307
  $output = $wpcf->relationship->child_meta_form(
@@ -318,20 +339,23 @@ function wpcf_ajax_embedded() {
318
  'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
319
  ) );
320
  }
321
- break;
322
  /* Usermeta */
323
  case 'um_repetitive_add':
324
- if ( isset( $_GET['field_id'] ) ) {
 
 
 
 
 
 
 
 
325
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
326
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
327
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
328
- $field = wpcf_admin_fields_get_field( $_GET['field_id'], false,
329
  false, false, 'wpcf-usermeta' );
330
- if ( isset( $_GET['user_id'] ) ) {
331
- $user_id = $_GET['user_id'];
332
- } else {
333
- $user_id = wpcf_usermeta_get_user();
334
- }
335
  global $wpcf;
336
  $wpcf->usermeta_repeater->set( $user_id, $field );
337
  /*
@@ -354,13 +378,17 @@ function wpcf_ajax_embedded() {
354
  break;
355
 
356
  case 'um_repetitive_delete':
357
- if ( isset( $_POST['user_id'] ) && isset( $_POST['field_id'] ) ) {
 
 
 
358
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
359
- $user_id = $_POST['user_id'];
360
 
361
- $field = wpcf_admin_fields_get_field( $_POST['field_id'], false,
362
  false, false, 'wpcf-usermeta' );
363
- $meta_id = $_POST['meta_id'];
 
364
  if ( !empty( $field ) && !empty( $user_id ) && !empty( $meta_id ) ) {
365
  /*
366
  *
@@ -388,25 +416,25 @@ function wpcf_ajax_embedded() {
388
  break;
389
  /* End Usermeta */
390
  case 'repetitive_add':
391
- if ( isset( $_GET['field_id'] ) ) {
392
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
393
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
394
- $field = wpcf_admin_fields_get_field( $_GET['field_id'] );
395
- $post_id = intval( $_GET['post_id'] );
396
 
397
  /*
398
  * When post is new - post_id is 0
399
  * We can safely set post_id to 1 cause
400
  * values compared are filtered anyway.
401
  */
402
- if ( $post_id == 0 ) {
403
- $post_id = 1;
404
  }
405
 
406
- $post = get_post( $post_id );
407
 
408
  global $wpcf;
409
- $wpcf->repeater->set( $post, $field );
410
  /*
411
  *
412
  * Force empty values!
@@ -427,12 +455,13 @@ function wpcf_ajax_embedded() {
427
  break;
428
 
429
  case 'repetitive_delete':
430
- if ( isset( $_POST['post_id'] ) && isset( $_POST['field_id'] ) ) {
431
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
432
- $post = get_post( $_POST['post_id'] );
433
- $field = wpcf_admin_fields_get_field( $_POST['field_id'] );
434
- $meta_id = $_POST['meta_id'];
435
- if ( !empty( $field ) && !empty( $post->ID ) && !empty( $meta_id ) ) {
 
436
  /*
437
  *
438
  *
@@ -440,7 +469,7 @@ function wpcf_ajax_embedded() {
440
  * Since Types 1.2
441
  */
442
  global $wpcf;
443
- $wpcf->repeater->set( $post, $field );
444
  $wpcf->repeater->delete( $meta_id );
445
 
446
  echo json_encode( array(
@@ -460,7 +489,7 @@ function wpcf_ajax_embedded() {
460
 
461
  case 'cd_verify':
462
 
463
- if ( empty( $_POST['wpcf'] ) && empty( $_POST['wpcf_post_relationship'] ) ) {
464
  die();
465
  }
466
  WPCF_Loader::loadClass( 'helper.ajax' );
@@ -480,8 +509,8 @@ function wpcf_ajax_embedded() {
480
  case 'cd_group_verify':
481
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
482
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/conditional-display.php';
483
- $group = wpcf_admin_fields_get_group( $_POST['group_id'] );
484
- if ( empty( $group ) ) {
485
  echo json_encode( array(
486
  'output' => ''
487
  ) );
@@ -493,23 +522,23 @@ function wpcf_ajax_embedded() {
493
  // Filter meta values (switch them with $_POST values)
494
  add_filter( 'get_post_metadata',
495
  'wpcf_cd_meta_ajax_validation_filter', 10, 4 );
496
- $post = false;
497
  if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
498
  $split = explode( '?', $_SERVER['HTTP_REFERER'] );
499
  if ( isset( $split[1] ) ) {
500
  parse_str( $split[1], $vars );
501
  if ( isset( $vars['post'] ) ) {
502
- $post = get_post( $vars['post'] );
503
  }
504
  }
505
  }
506
  // Dummy post
507
- if ( !$post ) {
508
- $post = new stdClass();
509
- $post->ID = 1;
510
  }
511
  if ( !empty( $group['conditional_display']['conditions'] ) ) {
512
- $result = wpcf_cd_post_groups_filter( array(0 => $group), $post,
513
  'group' );
514
  if ( !empty( $result ) ) {
515
  $result = array_shift( $result );
@@ -547,3 +576,43 @@ function wpcf_ajax_embedded() {
547
  }
548
  die();
549
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  /**
4
  * All AJAX calls go here.
5
+ *
6
+ * @todo auth
7
  */
8
  function wpcf_ajax_embedded() {
9
 
13
  }
14
  } else {
15
 
16
+ if (
17
+ !isset( $_REQUEST['_wpnonce'] )
18
+ || !wp_verify_nonce( $_REQUEST['_wpnonce'], $_REQUEST['wpcf_action'] )
19
+ ) {
20
  die( 'Verification failed' );
21
  }
22
  }
25
 
26
  switch ( $_REQUEST['wpcf_action'] ) {
27
 
 
 
 
 
 
28
  case 'insert_skype_button':
29
+ if( ! current_user_can( 'edit_posts' ) ) {
30
+ die( 'Authentication failed' );
31
+ }
32
+
33
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/skype.php';
34
  wpcf_fields_skype_meta_box_ajax();
35
  break;
36
 
37
  case 'editor_callback':
38
+ if( ! current_user_can( 'edit_posts' ) ) {
39
+ die( 'Authentication failed' );
40
+ }
41
+
42
  // Determine Field type and context
43
  $views_usermeta = false;
44
+ $field_id = sanitize_text_field( $_GET['field_id'] );
45
+
46
+ // todo this could be written in like four lines
47
  if ( isset( $_GET['field_type'] ) && $_GET['field_type'] == 'usermeta' ) {
48
  // Group filter
49
  wp_enqueue_script( 'suggest' );
50
+ $field = types_get_field( $field_id, 'usermeta' );
51
  $meta_type = 'usermeta';
52
  }
53
  elseif ( isset( $_GET['field_type'] ) && $_GET['field_type'] == 'views-usermeta' ){
54
+ $field = types_get_field( $field_id, 'usermeta' );
55
  $meta_type = 'usermeta';
56
  $views_usermeta = true;
57
  }else {
58
+ $field = types_get_field( $field_id );
59
  $meta_type = 'postmeta';
60
  }
61
+
62
+ $parent_post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : null;
63
  $shortcode = isset( $_GET['shortcode'] ) ? urldecode( $_GET['shortcode'] ) : null;
64
+ $callback = isset( $_GET['callback'] ) ? sanitize_text_field( $_GET['callback'] ) : false;
65
  if ( !empty( $field ) ) {
66
  // Editor
67
  WPCF_Loader::loadClass( 'editor' );
68
  $editor = new WPCF_Editor();
69
+ $editor->frame( $field, $meta_type, $parent_post_id, $shortcode,
70
  $callback, $views_usermeta );
71
  }
72
  break;
73
 
74
  case 'dismiss_message':
75
+ if( ! is_user_logged_in() ) {
76
+ die( 'Authentication failed' );
 
 
77
  }
 
78
 
 
79
  if ( isset( $_GET['id'] ) ) {
80
+ $messages = get_option( 'wpcf_dismissed_messages', array() );
81
+ $messages[] = sanitize_text_field( $_GET['id'] );
82
+ update_option( 'wpcf_dismissed_messages', $messages );
83
  }
84
  break;
85
 
86
  case 'pr_add_child_post':
87
  $output = 'Passed wrong parameters';
88
+
89
+ if ( current_user_can( 'edit_posts' )
90
+ && isset( $_GET['post_id'] )
91
+ && isset( $_GET['post_type_child'] )
92
+ && isset( $_GET['post_type_parent'] ) )
93
+ {
94
 
95
  $relationships = get_option( 'wpcf_post_relationship', array() );
96
+ $parent_post_id = intval( $_GET['post_id'] );
97
+ $parent_post = get_post( $parent_post_id );
98
+ if ( !empty( $parent_post->ID ) ) {
99
+ $post_type = sanitize_text_field( $_GET['post_type_child'] );
100
+ $parent_post_type = sanitize_text_field( $_GET['post_type_parent'] );
101
+ // @todo isset & error handling
102
  $data = $relationships[$parent_post_type][$post_type];
103
  /*
104
  * Since Types 1.1.5
106
  * We save new post
107
  * CHECKPOINT
108
  */
109
+ $id = $wpcf->relationship->add_new_child( $parent_post->ID, $post_type );
 
110
 
111
  if ( is_wp_error( $id ) ) {
112
  $output = $id->get_error_message();
115
  * Here we set Relationship
116
  * CHECKPOINT
117
  */
118
+ $parent = get_post( $parent_post_id );
119
  $child = get_post( $id );
120
  if ( !empty( $parent->ID ) && !empty( $child->ID ) ) {
121
 
126
  $wpcf->relationship->_set( $parent, $child, $data );
127
 
128
  // Render new row
129
+ $output = $wpcf->relationship->child_row( $parent_post->ID,
130
  $id, $data );
131
  } else {
132
+ $output = __( 'Error creating post relationship', 'wpcf' );
 
133
  }
134
  }
135
  } else {
151
 
152
  case 'pr_save_all':
153
  $output = '';
154
+ if ( current_user_can( 'edit_posts' ) && isset( $_POST['post_id'] ) ) {
155
 
156
  $parent_id = intval( $_POST['post_id'] );
157
+ $post_type = sanitize_text_field( $_POST['post_type'] );
158
  if ( isset( $_POST['wpcf_post_relationship'][$parent_id] ) ) {
159
+
160
+ $children = wpcf_sanitize_post_realtionship_input( (array) $_POST['wpcf_post_relationship'][$parent_id] );
161
+
162
+ $wpcf->relationship->save_children( $parent_id, $children );
163
  $output = $wpcf->relationship->child_meta_form(
164
+ $parent_id, strval( $post_type )
165
  );
166
  }
167
  }
184
  case 'pr_save_child_post':
185
  ob_start(); // Try to catch any errors
186
  $output = '';
187
+ if ( current_user_can( 'edit_posts' ) && isset( $_GET['post_id'] )
188
  && isset( $_GET['parent_id'] )
189
  && isset( $_GET['post_type_parent'] )
190
  && isset( $_GET['post_type_child'] )
192
 
193
  $parent_id = intval( $_GET['parent_id'] );
194
  $child_id = intval( $_GET['post_id'] );
195
+ $parent_post_type = sanitize_text_field( $_GET['post_type_parent'] );
196
+ $child_post_type = sanitize_text_field( $_GET['post_type_child'] );
197
+
198
  if ( isset( $_POST['wpcf_post_relationship'][$parent_id][$child_id] ) ) {
199
+ $fields = wpcf_sanitize_post_relationship_input_fields( (array) $_POST['wpcf_post_relationship'][$parent_id][$child_id] );
200
+ $wpcf->relationship->save_child( $parent_id, $child_id, $fields );
201
+
202
+ $output = $wpcf->relationship->child_row(
203
+ $parent_id,
204
  $child_id,
205
+ $wpcf->relationship->settings( $parent_post_type, $child_post_type ) );
206
+
207
  if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
208
+ // TODO Move to conditional
209
+ $output .= '<script type="text/javascript">wpcfConditionalInit(\'#types-child-row-' . $child_id . '\');</script>';
 
210
  }
211
  }
212
  }
228
  case 'pr_delete_child_post':
229
  require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
230
  $output = 'Passed wrong parameters';
231
+ if ( current_user_can( 'edit_posts' ) && isset( $_GET['post_id'] ) ) {
232
  $output = wpcf_pr_admin_delete_child_item( intval( $_GET['post_id'] ) );
233
  }
234
  echo json_encode( array(
239
  case 'pr-update-belongs':
240
  require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
241
  $output = 'Passed wrong parameters';
242
+ if ( current_user_can( 'edit_posts' )
243
+ && isset( $_POST['post_id'] )
244
+ && isset( $_POST['wpcf_pr_belongs'][$_POST['post_id']] ) )
245
+ {
246
+ $parent_post_id = intval( $_POST['post_id'] );
247
+ $belongs_assignments = array();
248
+ foreach( $_POST['wpcf_pr_belongs'][$parent_post_id] as $post_type_raw => $post_id_raw ) {
249
+ $belongs_assignments[ sanitize_text_field( $post_type_raw) ] = intval( $post_id_raw );
250
+ }
251
+
252
+ $updated = wpcf_pr_admin_update_belongs( $parent_post_id, $belongs_assignments );
253
  $output = is_wp_error( $updated ) ? $updated->get_error_message() : $updated;
254
  }
255
  if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
269
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
270
  require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
271
  $output = 'Passed wrong parameters';
272
+ if ( current_user_can( 'edit_posts' ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
273
  global $wpcf;
274
+ $parent = get_post( intval( $_GET['post_id'] ) );
275
+ $child_post_type = sanitize_text_field( $_GET['post_type'] );
276
 
277
  if ( !empty( $parent->ID ) ) {
278
 
304
 
305
  case 'pr_sort':
306
  $output = 'Passed wrong parameters';
307
+ if ( current_user_can( 'edit_posts' ) && isset( $_GET['field'] ) && isset( $_GET['sort'] ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
308
  $output = $wpcf->relationship->child_meta_form(
309
+ intval( $_GET['post_id'] ), sanitize_text_field( $_GET['post_type'] )
310
  );
311
  }
312
  if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
321
  }
322
  break;
323
 
324
+ // Not used anywhere
325
+ /*case 'pr_sort_parent':
326
  $output = 'Passed wrong parameters';
327
  if ( isset( $_GET['field'] ) && isset( $_GET['sort'] ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
328
  $output = $wpcf->relationship->child_meta_form(
339
  'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
340
  ) );
341
  }
342
+ break;*/
343
  /* Usermeta */
344
  case 'um_repetitive_add':
345
+
346
+ if ( isset( $_GET['user_id'] ) ) {
347
+ $user_id = $_GET['user_id'];
348
+ } else {
349
+ $user_id = wpcf_usermeta_get_user();
350
+ }
351
+
352
+ if ( isset( $_GET['field_id'] )
353
+ && current_user_can( 'edit_user', $user_id ) ) {
354
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
355
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
356
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
357
+ $field = wpcf_admin_fields_get_field( sanitize_text_field( $_GET['field_id'] ), false,
358
  false, false, 'wpcf-usermeta' );
 
 
 
 
 
359
  global $wpcf;
360
  $wpcf->usermeta_repeater->set( $user_id, $field );
361
  /*
378
  break;
379
 
380
  case 'um_repetitive_delete':
381
+ if ( isset( $_POST['user_id'] )
382
+ && isset( $_POST['field_id'] )
383
+ && current_user_can( 'edit_user', intval( $_POST['user_id'] ) ) )
384
+ {
385
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
386
+ $user_id = intval( $_POST['user_id'] );
387
 
388
+ $field = wpcf_admin_fields_get_field( sanitize_text_field( $_POST['field_id'] ), false,
389
  false, false, 'wpcf-usermeta' );
390
+ $meta_id = intval( $_POST['meta_id'] );
391
+
392
  if ( !empty( $field ) && !empty( $user_id ) && !empty( $meta_id ) ) {
393
  /*
394
  *
416
  break;
417
  /* End Usermeta */
418
  case 'repetitive_add':
419
+ if ( current_user_can( 'edit_posts' ) && isset( $_GET['field_id'] ) ) {
420
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
421
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
422
+ $field = wpcf_admin_fields_get_field( sanitize_text_field( $_GET['field_id'] ) );
423
+ $parent_post_id = intval( $_GET['post_id'] );
424
 
425
  /*
426
  * When post is new - post_id is 0
427
  * We can safely set post_id to 1 cause
428
  * values compared are filtered anyway.
429
  */
430
+ if ( $parent_post_id == 0 ) {
431
+ $parent_post_id = 1;
432
  }
433
 
434
+ $parent_post = get_post( $parent_post_id );
435
 
436
  global $wpcf;
437
+ $wpcf->repeater->set( $parent_post, $field );
438
  /*
439
  *
440
  * Force empty values!
455
  break;
456
 
457
  case 'repetitive_delete':
458
+ if ( current_user_can( 'edit_posts' ) && isset( $_POST['post_id'] ) && isset( $_POST['field_id'] ) ) {
459
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
460
+ $post_id = intval( $_POST['post_id'] );
461
+ $parent_post = get_post( $post_id );
462
+ $field = wpcf_admin_fields_get_field( sanitize_text_field( $_POST['field_id'] ) );
463
+ $meta_id = intval( $_POST['meta_id'] );
464
+ if ( !empty( $field ) && !empty( $parent_post->ID ) && !empty( $meta_id ) ) {
465
  /*
466
  *
467
  *
469
  * Since Types 1.2
470
  */
471
  global $wpcf;
472
+ $wpcf->repeater->set( $parent_post, $field );
473
  $wpcf->repeater->delete( $meta_id );
474
 
475
  echo json_encode( array(
489
 
490
  case 'cd_verify':
491
 
492
+ if ( !current_user_can( 'edit_posts' ) || ( empty( $_POST['wpcf'] ) && empty( $_POST['wpcf_post_relationship'] ) ) ){
493
  die();
494
  }
495
  WPCF_Loader::loadClass( 'helper.ajax' );
509
  case 'cd_group_verify':
510
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
511
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/conditional-display.php';
512
+ $group = wpcf_admin_fields_get_group( sanitize_text_field( $_POST['group_id'] ) );
513
+ if ( !current_user_can( 'edit_posts' ) || empty( $group ) ) {
514
  echo json_encode( array(
515
  'output' => ''
516
  ) );
522
  // Filter meta values (switch them with $_POST values)
523
  add_filter( 'get_post_metadata',
524
  'wpcf_cd_meta_ajax_validation_filter', 10, 4 );
525
+ $parent_post = false;
526
  if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
527
  $split = explode( '?', $_SERVER['HTTP_REFERER'] );
528
  if ( isset( $split[1] ) ) {
529
  parse_str( $split[1], $vars );
530
  if ( isset( $vars['post'] ) ) {
531
+ $parent_post = get_post( $vars['post'] );
532
  }
533
  }
534
  }
535
  // Dummy post
536
+ if ( !$parent_post ) {
537
+ $parent_post = new stdClass();
538
+ $parent_post->ID = 1;
539
  }
540
  if ( !empty( $group['conditional_display']['conditions'] ) ) {
541
+ $result = wpcf_cd_post_groups_filter( array(0 => $group), $parent_post,
542
  'group' );
543
  if ( !empty( $result ) ) {
544
  $result = array_shift( $result );
576
  }
577
  die();
578
  }
579
+
580
+
581
+ /**
582
+ * Sanitize input array with post children and their fields.
583
+ *
584
+ * @param array $children_raw See WPCF_Relationship::save_children().
585
+ * @return array Data with the same structure as input, but sanitized.
586
+ *
587
+ * @todo since
588
+ * @todo move to better location if such exists
589
+ */
590
+ function wpcf_sanitize_post_realtionship_input( $children_raw ) {
591
+ $children = array();
592
+ foreach( $children_raw as $child_id_raw => $child_fields_raw ) {
593
+ $child_id = intval( $child_id_raw );
594
+ $children[ $child_id ] = wpcf_sanitize_post_relationship_input_fields( $child_fields_raw );
595
+ }
596
+ return $children;
597
+ }
598
+
599
+
600
+ /**
601
+ * Sanitize input array with post child fields.
602
+ *
603
+ * Note that only field keys are sanitized. Values can be arbitrary.
604
+ *
605
+ * @param array $fields_raw See WPCF_Relationship::save_child().
606
+ * @return array Data with the same structure as input, but sanitized.
607
+ *
608
+ * @todo since
609
+ * @todo move to better location if such exists
610
+ */
611
+ function wpcf_sanitize_post_relationship_input_fields( $fields_raw ) {
612
+ $fields = array();
613
+ foreach( $fields_raw as $field_key_raw => $field_value_raw ) {
614
+ $field_key = sanitize_text_field( $field_key_raw );
615
+ $fields[ $field_key ] = $field_value_raw;
616
+ }
617
+ return $fields;
618
+ }
embedded/includes/api.php CHANGED
@@ -10,8 +10,9 @@
10
 
11
  /**
12
  * Gets field.
13
- *
14
- * @param type $field
 
15
  * @return array
16
  */
17
  function types_get_field( $field, $meta_type = 'postmeta' ) {
10
 
11
  /**
12
  * Gets field.
13
+ *
14
+ * @param string $field
15
+ * @param string $meta_type
16
  * @return array
17
  */
18
  function types_get_field( $field, $meta_type = 'postmeta' ) {
embedded/includes/classes/class.types.data.installer.php ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Types_Data_Installer') ) {
4
+
5
+ class Types_Data_Installer
6
+ {
7
+ private $data = array();
8
+ private $args = array();
9
+ private $fields = array();
10
+ private $user_fields = array();
11
+ private $reset_toolset_edit_last_list = array();
12
+
13
+ public function __construct($data, $args)
14
+ {
15
+ $this->data = $data;
16
+ $this->args = $args;
17
+ }
18
+
19
+ /**
20
+ * Create data for import.
21
+ *
22
+ * Populate and check data for import from Importer
23
+ *
24
+ * @since 1.6.6
25
+ *
26
+ * @return object data for import
27
+ */
28
+ public function wpvdemo()
29
+ {
30
+ $data = new stdClass;
31
+ foreach(array('groups', 'user_groups', 'fields', 'user_fields', 'taxonomies', 'types') as $key) {
32
+ $data->$key = new stdClass;
33
+ }
34
+
35
+ $data->groups->group = $this->get_data_by_group_name('wp-types-group');
36
+ $data->user_groups->group = $this->get_data_by_group_name('wp-types-user-group');
37
+
38
+ $data->fields->field = $this->get_data_by_field_type('fields');
39
+ $data->user_fields->field = $this->get_data_by_field_type('user_fields');
40
+
41
+ $data->types->type = $this->get_data_by_type('wpcf-custom-types');
42
+ $data->taxonomies->taxonomy = $this->get_data_by_type('wpcf-custom-taxonomies');
43
+
44
+ return $data;
45
+ }
46
+
47
+ /**
48
+ * Helper for group.
49
+ *
50
+ * Helper for importing group.
51
+ *
52
+ * @since 1.6.6
53
+ * @access private
54
+ *
55
+ * @param string $group_name Group name
56
+ *
57
+ * @return object data for import
58
+ */
59
+ private function get_data_by_group_name($group_name)
60
+ {
61
+ $group = 'groups';
62
+ $element = 'group';
63
+ if ( 'wp-types-user-group' == $group_name ) {
64
+ $group = 'user_groups';
65
+ }
66
+
67
+ if (
68
+ isset($this->data->$group)
69
+ && isset($this->data->$group->$element)
70
+ ) {
71
+ return $this->get_data($group_name, $this->data->$group->$element);
72
+ }
73
+ return;
74
+ }
75
+
76
+ /**
77
+ * Build data for group.
78
+ *
79
+ * Build data to importing group.
80
+ *
81
+ * @since 1.6.6
82
+ * @access private
83
+ *
84
+ * @param string $group_name Group name
85
+ * @param object $group Group data
86
+ *
87
+ * @return object data for import
88
+ */
89
+ private function get_data($group_name, $groups)
90
+ {
91
+ $this->reset_toolset_edit_last_list[$group_name] = array();
92
+ $date = date('Y-m-d H:i');
93
+ $new = array();
94
+ foreach($groups as $group ) {
95
+ if (
96
+ isset($this->args['force_skip_post_name'][$group_name])
97
+ && in_array($group->__types_id, $this->args['force_skip_post_name'][$group_name])
98
+ ) {
99
+ continue;
100
+ }
101
+ if (
102
+ isset($this->args['force_import_post_name'][$group_name])
103
+ && in_array($group->__types_id, $this->args['force_import_post_name'][$group_name])
104
+ ) {
105
+ $new[] = $group;
106
+ switch($group_name) {
107
+ case 'wp-types-group':
108
+ $this->fields += explode(',', $group->meta->_wp_types_group_fields);
109
+ break;
110
+ case 'wp-types-user-group':
111
+ $this->user_fields += explode(',', $group->meta->_wp_types_group_fields);
112
+ break;
113
+ }
114
+ $this->reset_toolset_edit_last_list[$group_name][] = $group->__types_id;
115
+ continue;
116
+ }
117
+ if (
118
+ isset($this->args['force_duplicate_post_name'][$group_name])
119
+ && in_array($group->__types_id, $this->args['force_duplicate_post_name'][$group_name])
120
+ ) {
121
+ $one = $group;
122
+ $one->__types_id = wp_unique_post_slug( sanitize_title_with_dashes($group->post_title, null, 'save'), null, 'publish', 'wp-types-group', null);
123
+ $one->__types_title = $one->post_title = sprintf('%s %s', $group->post_title, $date);
124
+ $new[$one->__types_id] = $one;
125
+ continue;
126
+ }
127
+ }
128
+ return $new;
129
+ }
130
+
131
+ /**
132
+ * Helper for CPT & CT.
133
+ *
134
+ * Helper for importing custom post types and custom taxonomies.
135
+ *
136
+ * @since 1.6.6
137
+ * @access private
138
+ *
139
+ * @param string $group_name Group name
140
+ *
141
+ * @return object data for import
142
+ */
143
+ private function get_data_by_field_type($type)
144
+ {
145
+ if (
146
+ isset($this->data->fields)
147
+ && isset($this->data->fields->field)
148
+ ) {
149
+ $fields = $this->data->fields->field;
150
+ } else {
151
+ return;
152
+ }
153
+ $new = array();
154
+ foreach($fields as $field ) {
155
+ if ( in_array($field->id, $this->$type) )
156
+ {
157
+ $new[] = $field;
158
+ }
159
+ }
160
+ return $new;
161
+ }
162
+
163
+ /**
164
+ * Build data for CPT & CT
165
+ *
166
+ * Build data to importing custom post types and custom taxonomies.
167
+ *
168
+ * @since 1.6.6
169
+ * @access private
170
+ *
171
+ * @param string $group_name Group name
172
+ * @param object $group Group data
173
+ *
174
+ * @return object data for import
175
+ */
176
+ private function get_data_by_type($group_name)
177
+ {
178
+ $group = 'types';
179
+ $element = 'type';
180
+ if ( 'wpcf-custom-taxonomies' == $group_name ) {
181
+ $group = 'taxonomies';
182
+ $element = 'taxonomy';
183
+ }
184
+ if (
185
+ isset($this->data->$group)
186
+ && isset($this->data->$group->$element)
187
+ ) {
188
+ $groups = $this->data->$group->$element;
189
+ } else {
190
+ return;
191
+ }
192
+
193
+ $this->reset_toolset_edit_last_list[$group_name] = array();
194
+
195
+ $date = date('Y-m-d H:i');
196
+ $new = array();
197
+ $data = get_option($group_name, array());
198
+
199
+ foreach ( $groups as $group) {
200
+ $slug = $group->slug->__toString();
201
+ if ( isset($data[$slug]) && !isset($data[$slug][TOOLSET_EDIT_LAST]) ) {
202
+ continue;
203
+ }
204
+ $this->reset_toolset_edit_last_list[$group_name][] = $slug;
205
+ if (
206
+ isset($this->args['force_skip_post_name'][$group_name])
207
+ && in_array($group->__types_id, $this->args['force_skip_post_name'][$group_name])
208
+ ) {
209
+ continue;
210
+ }
211
+ if (
212
+ isset($this->args['force_import_post_name'][$group_name])
213
+ && in_array($group->__types_id, $this->args['force_import_post_name'][$group_name])
214
+ ) {
215
+ $this->reset_toolset_edit_last_list[$group_name][] = (int)$group->ID;
216
+ $group->addChild('add', false);
217
+ $group->addChild('update', true);
218
+ $new[] = $group;
219
+ continue;
220
+ }
221
+ }
222
+
223
+ return $new;
224
+ }
225
+
226
+ /**
227
+ * Reset TOOLSET_EDIT_LAST.
228
+ *
229
+ * Function to reset TOOLSET_EDIT_LAST - last edit timestamp in Types
230
+ * definitions.
231
+ *
232
+ * @since 1.6.6
233
+ *
234
+ */
235
+ public function reset_toolset_edit_last()
236
+ {
237
+ if (!empty($this->reset_toolset_edit_last_list)) {
238
+ foreach( $this->reset_toolset_edit_last_list as $group => $data) {
239
+ switch( $group ) {
240
+ case 'wp-types-group':
241
+ case 'wp-types-user-group':
242
+ foreach( $data as $slug) {
243
+ $post = get_page_by_path($slug, OBJECT, $group);
244
+ if ( $post ) {
245
+ delete_post_meta( $post->ID, TOOLSET_EDIT_LAST);
246
+ }
247
+ }
248
+ break;
249
+ case 'wpcf-custom-types':
250
+ case 'wpcf-custom-taxonomies':
251
+ $options = get_option( $group, array() );
252
+ $new = array();
253
+ foreach ( $options as $one ) {
254
+ if ( in_array($one['slug'], $data ) ) {
255
+ if ( isset( $one[TOOLSET_EDIT_LAST]) ) {
256
+ unset($one[TOOLSET_EDIT_LAST]);
257
+ }
258
+ }
259
+ $new[$one['slug']] = $one;
260
+ }
261
+ update_option($group, $new);
262
+ break;
263
+ }
264
+ }
265
+ }
266
+ }
267
+ }
268
+ }
embedded/includes/custom-taxonomies.php CHANGED
@@ -46,6 +46,10 @@ function wpcf_custom_taxonomies_default() {
46
  'choose_from_most_used' => 'Choose from the most used %s',
47
  'menu_name' => '%s',
48
  ),
 
 
 
 
49
  );
50
  }
51
 
@@ -63,9 +67,9 @@ function wpcf_custom_taxonomies_init() {
63
 
64
  /**
65
  * Registers custom taxonomies.
66
- *
67
  * @param type $post_type
68
- * @param type $data
69
  */
70
  function wpcf_custom_taxonomies_register( $taxonomy, $data ) {
71
  if ( !empty( $data['disabled'] ) ) {
@@ -133,6 +137,16 @@ function wpcf_custom_taxonomies_register( $taxonomy, $data ) {
133
  } else {
134
  $data['rewrite'] = false;
135
  }
 
 
 
 
 
 
 
 
 
 
136
  // Force removing capabilities here
137
  unset( $data['capabilities'] );
138
  register_taxonomy( $taxonomy,
@@ -142,8 +156,8 @@ function wpcf_custom_taxonomies_register( $taxonomy, $data ) {
142
 
143
  /**
144
  * Returns only active taxonomies.
145
- *
146
- * @return type
147
  */
148
  function wpcf_get_active_custom_taxonomies() {
149
  $taxonomies = get_option('wpcf-custom-taxonomies', array());
@@ -153,4 +167,4 @@ function wpcf_get_active_custom_taxonomies() {
153
  }
154
  }
155
  return $taxonomies;
156
- }
46
  'choose_from_most_used' => 'Choose from the most used %s',
47
  'menu_name' => '%s',
48
  ),
49
+ 'meta_box_cb' => array(
50
+ 'disabled' => false,
51
+ 'callback' => null,
52
+ ),
53
  );
54
  }
55
 
67
 
68
  /**
69
  * Registers custom taxonomies.
70
+ *
71
  * @param type $post_type
72
+ * @param type $data
73
  */
74
  function wpcf_custom_taxonomies_register( $taxonomy, $data ) {
75
  if ( !empty( $data['disabled'] ) ) {
137
  } else {
138
  $data['rewrite'] = false;
139
  }
140
+ /**
141
+ * meta_box_cb
142
+ */
143
+ if ( isset($data['meta_box_cb']['disabled'])) {
144
+ $data['meta_box_cb'] = false;
145
+ } else if ( isset($data['meta_box_cb']['callback']) && !empty($data['meta_box_cb']['callback']) ){
146
+ $data['meta_box_cb'] = $data['meta_box_cb']['callback'];
147
+ } else {
148
+ unset($data['meta_box_cb']);
149
+ }
150
  // Force removing capabilities here
151
  unset( $data['capabilities'] );
152
  register_taxonomy( $taxonomy,
156
 
157
  /**
158
  * Returns only active taxonomies.
159
+ *
160
+ * @return type
161
  */
162
  function wpcf_get_active_custom_taxonomies() {
163
  $taxonomies = get_option('wpcf-custom-taxonomies', array());
167
  }
168
  }
169
  return $taxonomies;
170
+ }
embedded/includes/custom-types.php CHANGED
@@ -3,9 +3,9 @@
3
  *
4
  * Custom Post Types embedded code.
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/custom-types.php $
7
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
- * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
@@ -200,38 +200,26 @@ function wpcf_custom_types_register( $post_type, $data ) {
200
  $data['permalink_epmask'] = constant( $data['permalink_epmask'] );
201
  }
202
 
203
- $args = register_post_type( $post_type,
204
- apply_filters( 'wpcf_type', $data, $post_type ) );
205
-
206
- do_action( 'wpcf_type_registered', $args );
207
-
208
- /*
209
- * Since Types 1.2
210
- * We do not encourage plural and singular names to be same.
211
  */
212
- $wpcf->post_types->set( $post_type, $data );
213
- if ( $wpcf->post_types->check_singular_plural_match() ) {
214
- if ( is_admin() ) {
215
- // wpcf_admin_message_dismiss( $post_type . 'warning_singular_plural_match',
216
- // $wpcf->post_types->message( 'warning_singular_plural_match' )
217
- // );
218
- }
219
- }
 
 
 
 
 
220
 
221
- // Add the standard tags and categoires if the're set.
222
- $body = '';
223
- if ( in_array( 'post_tag', $data['taxonomies'] ) ) {
224
- $body = 'register_taxonomy_for_object_type("post_tag", "' . $post_type . '");';
225
- }
226
- if ( in_array( 'category', $data['taxonomies'] ) ) {
227
- $body .= 'register_taxonomy_for_object_type("category", "' . $post_type . '");';
228
- }
229
 
230
- // make sure the function name is OK
231
- $post_type = str_replace( '-', '_', $post_type );
232
- if ( $body != '' ) {
233
- add_action( 'init', create_function('', $body ));
234
- }
235
  }
236
 
237
  /**
@@ -297,3 +285,48 @@ function wpcf_get_active_custom_types() {
297
  }
298
  return $types;
299
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  *
4
  * Custom Post Types embedded code.
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/custom-types.php $
7
+ * $LastChangedDate: 2015-03-16 12:03:31 +0000 (Mon, 16 Mar 2015) $
8
+ * $LastChangedRevision: 1113864 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
200
  $data['permalink_epmask'] = constant( $data['permalink_epmask'] );
201
  }
202
 
203
+ /**
204
+ * set default support options
 
 
 
 
 
 
205
  */
206
+ $support_fields = array(
207
+ 'editor' => false,
208
+ 'author' => false,
209
+ 'thumbnail' => false,
210
+ 'excerpt' => false,
211
+ 'trackbacks' => false,
212
+ 'custom-fields' => false,
213
+ 'comments' => false,
214
+ 'revisions' => false,
215
+ 'page-attributes' => false,
216
+ 'post-formats' => false,
217
+ );
218
+ $data['supports'] = array_merge_recursive( $data['supports'], $support_fields );
219
 
220
+ $args = register_post_type( $post_type, apply_filters( 'wpcf_type', $data, $post_type ) );
 
 
 
 
 
 
 
221
 
222
+ do_action( 'wpcf_type_registered', $args );
 
 
 
 
223
  }
224
 
225
  /**
285
  }
286
  return $types;
287
  }
288
+
289
+ /** This action is documented in wp-admin/includes/dashboard.php */
290
+ add_action('dashboard_glance_items', 'wpcf_dashboard_glance_items');
291
+
292
+ /**
293
+ * Add CPT info to "At a Glance"
294
+ *
295
+ * Add to "At a Glance" WordPress admin dashboard widget information
296
+ * about number of posts.
297
+ *
298
+ * @since 1.6.6
299
+ *
300
+ */
301
+ function wpcf_dashboard_glance_items()
302
+ {
303
+ $custom_types = get_option( 'wpcf-custom-types', array() );
304
+ ksort($custom_types);
305
+ if ( !empty( $custom_types ) ) {
306
+ foreach ( $custom_types as $post_type => $data ) {
307
+ if ( !isset($data['dashboard_glance']) || !$data['dashboard_glance']) {
308
+ continue;
309
+ }
310
+ if ( isset($data['disabled']) && $data['disabled'] ) {
311
+ continue;
312
+ }
313
+ $num_posts = wp_count_posts($post_type);
314
+ $num = number_format_i18n($num_posts->publish);
315
+ $text = _n( $data['labels']['singular_name'], $data['labels']['name'], intval($num_posts->publish) );
316
+ printf(
317
+ '<li class="page-count %s-count"><a href="%s"%s>%d %s</a></li>',
318
+ $post_type,
319
+ add_query_arg(
320
+ array(
321
+ 'post_type' => $post_type,
322
+ ),
323
+ admin_url('edit.php')
324
+ ),
325
+ isset($data['icon'])? sprintf('class="dashicons-%s"', $data['icon']):'',
326
+ $num,
327
+ $text
328
+ );
329
+ }
330
+ }
331
+ }
332
+
embedded/includes/editor-support/post-relationship-editor-support.php DELETED
@@ -1,4 +0,0 @@
1
- <?php
2
- /*
3
- *
4
- */
 
 
 
 
embedded/includes/examples/google_map.php CHANGED
@@ -72,9 +72,13 @@ function wpcf_fields_google_map() {
72
  'deps' => array('jquery'), // (optional) Same as WP's enqueue_script() param
73
  'in_footer' => true, // (optional) Same as WP's enqueue_script() param
74
  ),
 
 
 
75
  'wpcf-jquery-fields-my-field' => array(
76
  'src' => get_stylesheet_directory_uri() . '/js/my-field.js', // This will load JS file
77
  ),
 
78
  ),
79
  // Additional CSS on post edit page
80
  'meta_box_css' => array(
@@ -85,14 +89,22 @@ function wpcf_fields_google_map() {
85
  ),
86
  // Additional JS on group edit page
87
  'group_form_js' => array(// Add JS when field is active on post edit page
 
 
 
88
  'wpcf-jquery-fields-my-field' => array(
89
  'inline' => 'wpcf_fields_google_map_group_form_js_inline', // This calls function that renders JS
90
  'deps' => array('jquery'), // (optional) Same as WP's enqueue_script() param
91
  'in_footer' => true, // (optional) Same as WP's enqueue_script() param
92
  ),
 
 
 
 
93
  'wpcf-jquery-fields-my-field' => array(
94
  'src' => get_stylesheet_directory_uri() . '/js/my-field.js', // This will load JS file
95
  ),
 
96
  ),
97
  // Additional CSS on post edit page
98
  'group_form_css' => array(
72
  'deps' => array('jquery'), // (optional) Same as WP's enqueue_script() param
73
  'in_footer' => true, // (optional) Same as WP's enqueue_script() param
74
  ),
75
+ /**
76
+ * example how to add javascript file
77
+ *
78
  'wpcf-jquery-fields-my-field' => array(
79
  'src' => get_stylesheet_directory_uri() . '/js/my-field.js', // This will load JS file
80
  ),
81
+ */
82
  ),
83
  // Additional CSS on post edit page
84
  'meta_box_css' => array(
89
  ),
90
  // Additional JS on group edit page
91
  'group_form_js' => array(// Add JS when field is active on post edit page
92
+ /**
93
+ * example how to add javascript file wit callback fundtion
94
+ *
95
  'wpcf-jquery-fields-my-field' => array(
96
  'inline' => 'wpcf_fields_google_map_group_form_js_inline', // This calls function that renders JS
97
  'deps' => array('jquery'), // (optional) Same as WP's enqueue_script() param
98
  'in_footer' => true, // (optional) Same as WP's enqueue_script() param
99
  ),
100
+ */
101
+ /**
102
+ * example how to add javascript file
103
+ *
104
  'wpcf-jquery-fields-my-field' => array(
105
  'src' => get_stylesheet_directory_uri() . '/js/my-field.js', // This will load JS file
106
  ),
107
+ */
108
  ),
109
  // Additional CSS on post edit page
110
  'group_form_css' => array(
embedded/includes/fields-post.php CHANGED
@@ -4,9 +4,9 @@
4
  * Edit post page functions
5
  *
6
  *
7
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/fields-post.php $
8
- * $LastChangedDate: 2014-10-29 15:57:36 +0000 (Wed, 29 Oct 2014) $
9
- * $LastChangedRevision: 1016002 $
10
  * $LastChangedBy: iworks $
11
  *
12
  * Core file with stable and working functions.
@@ -521,7 +521,7 @@ function wpcf_admin_post_meta_box( $post, $group, $echo = '', $open_style_editor
521
  $field['type'] = 'wysiwyg';
522
  $group_output .= '</div>';
523
  $group_output .= isset( $field['#after'] ) ? $field['#after'] : '';
524
- $group_output .= '</div><br /><br />';
525
  } else {
526
  if (
527
  array_key_exists( '#type', $field )
@@ -1515,9 +1515,8 @@ function wpcf_admin_post_process_field( $field_object ) {
1515
  * @param type $post_ID
1516
  * @return type
1517
  */
1518
- function wpcf_admin_post_get_post_groups_fields( $post = false,
1519
- $context = 'group' ) {
1520
-
1521
  // Get post_type
1522
  /*
1523
  *
@@ -1533,8 +1532,7 @@ function wpcf_admin_post_get_post_groups_fields( $post = false,
1533
  } else {
1534
  if ( !isset( $_GET['post_type'] ) ) {
1535
  $post_type = 'post';
1536
- } else if ( in_array( $_GET['post_type'],
1537
- get_post_types( array('show_ui' => true) ) ) ) {
1538
  $post_type = $_GET['post_type'];
1539
  } else {
1540
  $post_type = 'post';
@@ -1568,10 +1566,8 @@ function wpcf_admin_post_get_post_groups_fields( $post = false,
1568
  $post->_wpcf_post_template = false;
1569
  $post->_wpcf_post_views_template = false;
1570
  } else {
1571
- $post->_wpcf_post_template = get_post_meta( $post->ID,
1572
- '_wp_page_template', true );
1573
- $post->_wpcf_post_views_template = get_post_meta( $post->ID,
1574
- '_views_template', true );
1575
  }
1576
 
1577
  if ( empty( $post->_wpcf_post_terms ) ) {
@@ -1855,7 +1851,7 @@ function wpcf_admin_post_marketing_meta_box() {
1855
  $output .= '<p><a href="' . admin_url( 'edit.php?post_type=view' ) . '">' . __( 'Create <strong>Views</strong> for content lists &raquo;',
1856
  'wpcf' ) . '</a></p>';
1857
  } else {
1858
- $output .= '<p><strong>' . sprintf( __( "%sViews%s let's you build complete websites without coding.",
1859
  'wpcf' ),
1860
  '<a href="http://wp-types.com/home/views-create-elegant-displays-for-your-content/?utm_source=typesplugin&utm_medium=postedit&utm_term=views&utm_content=promobox&utm_campaign=types" title="Views" target="_blank">',
1861
  '</a>' )
4
  * Edit post page functions
5
  *
6
  *
7
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/fields-post.php $
8
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
9
+ * $LastChangedRevision: 1120400 $
10
  * $LastChangedBy: iworks $
11
  *
12
  * Core file with stable and working functions.
521
  $field['type'] = 'wysiwyg';
522
  $group_output .= '</div>';
523
  $group_output .= isset( $field['#after'] ) ? $field['#after'] : '';
524
+ $group_output .= '</div>';
525
  } else {
526
  if (
527
  array_key_exists( '#type', $field )
1515
  * @param type $post_ID
1516
  * @return type
1517
  */
1518
+ function wpcf_admin_post_get_post_groups_fields( $post = false, $context = 'group' )
1519
+ {
 
1520
  // Get post_type
1521
  /*
1522
  *
1532
  } else {
1533
  if ( !isset( $_GET['post_type'] ) ) {
1534
  $post_type = 'post';
1535
+ } else if ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true) ) ) ) {
 
1536
  $post_type = $_GET['post_type'];
1537
  } else {
1538
  $post_type = 'post';
1566
  $post->_wpcf_post_template = false;
1567
  $post->_wpcf_post_views_template = false;
1568
  } else {
1569
+ $post->_wpcf_post_template = get_post_meta( $post->ID, '_wp_page_template', true );
1570
+ $post->_wpcf_post_views_template = get_post_meta( $post->ID, '_views_template', true );
 
 
1571
  }
1572
 
1573
  if ( empty( $post->_wpcf_post_terms ) ) {
1851
  $output .= '<p><a href="' . admin_url( 'edit.php?post_type=view' ) . '">' . __( 'Create <strong>Views</strong> for content lists &raquo;',
1852
  'wpcf' ) . '</a></p>';
1853
  } else {
1854
+ $output .= '<p><strong>' . sprintf( __( "%sViews%s lets you build complete websites without coding.",
1855
  'wpcf' ),
1856
  '<a href="http://wp-types.com/home/views-create-elegant-displays-for-your-content/?utm_source=typesplugin&utm_medium=postedit&utm_term=views&utm_content=promobox&utm_campaign=types" title="Views" target="_blank">',
1857
  '</a>' )
embedded/includes/fields.php CHANGED
@@ -3,7 +3,6 @@
3
  /**
4
  * Gets all groups.
5
  *
6
- * @global type $wpdb
7
  * @param string $post_type
8
  * @param boolean|string $only_active
9
  * @param boolean|string $add_fields - 'field_active', 'field_all', false (to omitt fields)
@@ -38,9 +37,10 @@ function wpcf_admin_fields_get_groups( $post_type = 'wp-types-group',
38
  *
39
  * Since 1.2 we enabled fetching by post title.
40
  *
41
- * @global type $wpdb
42
- * @param type $group_id
43
- * @return type
 
44
  */
45
  function wpcf_admin_fields_get_group( $group_id, $post_type = 'wp-types-group',
46
  $add_fields = false ) {
@@ -60,8 +60,9 @@ function wpcf_admin_fields_get_group( $group_id, $post_type = 'wp-types-group',
60
  /**
61
  * Converts post data.
62
  *
63
- * @param type $post
64
- * @return type
 
65
  */
66
  function wpcf_admin_fields_adjust_group( $post, $add_fields = false ) {
67
  if ( empty( $post ) ) {
@@ -91,20 +92,17 @@ function wpcf_admin_fields_adjust_group( $post, $add_fields = false ) {
91
  /**
92
  * Gets Fields Admin Styles supported by specific group.
93
  *
94
- * @global type $wpdb
95
  * @param type $group_id
96
  * @return type
97
  */
98
  function wpcf_admin_get_groups_admin_styles_by_group( $group_id ) {
99
- $admin_styles = get_post_meta( $group_id, '_wp_types_group_admin_styles',
100
- true );
101
  return trim( $admin_styles );
102
  }
103
 
104
  /**
105
  * Saves group's admin styles
106
  *
107
- * @global type $wpdb
108
  * @param type $group_id
109
  * @param type $padmin_styles
110
  */
@@ -116,8 +114,15 @@ function wpcf_admin_fields_save_group_admin_styles( $group_id, $admin_styles ) {
116
  * Gets all fields.
117
  *
118
  * @todo Move to WPCF_Fields
119
- * @global type $wpdb
 
 
 
 
 
120
  * @return type
 
 
121
  * added param $use_cache by Gen (used when adding new fields to group)
122
  */
123
  function wpcf_admin_fields_get_fields( $only_active = false,
@@ -187,14 +192,26 @@ function wpcf_admin_fields_get_fields( $only_active = false,
187
  return $cache[$cache_key];
188
  }
189
 
 
 
 
 
 
 
 
 
 
 
190
  /**
191
  * Gets field by ID.
192
  * Modified by Gen, 13.02.2013
193
  *
194
- * @global type $wpdb
195
- * @param type $field_id
196
- * @param type $only_active
197
- * @return type
 
 
198
  */
199
  function wpcf_admin_fields_get_field( $field_id, $only_active = false,
200
  $disabled_by_type = false, $strictly_active = false,
@@ -212,7 +229,6 @@ function wpcf_admin_fields_get_field( $field_id, $only_active = false,
212
  * Gets field by slug.
213
  * Modified by Gen, 13.02.2013
214
  *
215
- * @global type $wpdb
216
  * @param type $slug
217
  * @return type
218
  */
@@ -223,7 +239,6 @@ function wpcf_fields_get_field_by_slug( $slug, $meta_name = 'wpcf-fields' ) {
223
  /**
224
  * Gets all fields that belong to specific group.
225
  *
226
- * @global type $wpdb
227
  * @param type $group_id
228
  * @param type $key
229
  * @param type $only_active
@@ -264,7 +279,6 @@ function wpcf_admin_fields_get_fields_by_group( $group_id, $key = 'slug',
264
  /**
265
  * Gets groups that have specific term.
266
  *
267
- * @global type $wpdb
268
  * @param type $term_id
269
  * @param type $fetch_empty
270
  * @param type $only_active
@@ -322,14 +336,14 @@ function wpcf_admin_fields_get_groups_by_term( $term_id = false,
322
  /**
323
  * Gets groups that have specific post_type.
324
  *
325
- * @global type $wpdb
326
  * @param type $post_type
327
  * @param type $fetch_empty
328
  * @param type $only_active
329
  * @return type
330
  */
331
- function wpcf_admin_get_groups_by_post_type( $post_type, $fetch_empty = true,
332
- $terms = null, $only_active = true ) {
333
  $args = array();
334
  $args['post_type'] = 'wp-types-group';
335
  $args['numberposts'] = -1;
@@ -377,23 +391,21 @@ function wpcf_admin_get_groups_by_post_type( $post_type, $fetch_empty = true,
377
  // Distinct terms
378
  if ( !is_null( $terms ) ) {
379
  if ( !empty( $terms ) ) {
380
- // $args['meta_query'] = array('relation' => 'OR');
381
  $terms_sql = array();
382
  $add = '';
383
  if ( $fetch_empty ) {
384
  $add = " OR m.meta_value LIKE 'all'";
385
  }
386
  foreach ( $terms as $term ) {
387
- $terms_sql[] = $term;
388
  }
389
- $terms_sql = "AND (m.meta_value LIKE '%%," . implode( ",%%' OR m.meta_value LIKE '%%,",
390
- $terms ) . ",%%' $add)";
391
  global $wpdb;
392
  $terms_sql = "SELECT * FROM $wpdb->posts p
393
- JOIN $wpdb->postmeta m
394
- WHERE p.post_type='wp-types-group' AND p.post_status='publish'
395
- AND p.ID = m.post_id AND m.meta_key='_wp_types_group_terms'
396
- $terms_sql";
397
  $groups = $wpdb->get_results( $terms_sql );
398
  if ( !empty( $groups ) ) {
399
  foreach ( $groups as $key => $group ) {
@@ -415,7 +427,6 @@ function wpcf_admin_get_groups_by_post_type( $post_type, $fetch_empty = true,
415
  /**
416
  * Gets groups that have specific template.
417
  *
418
- * @global type $wpdb
419
  * @param type $post_type
420
  * @param type $fetch_empty
421
  * @param type $only_active
3
  /**
4
  * Gets all groups.
5
  *
 
6
  * @param string $post_type
7
  * @param boolean|string $only_active
8
  * @param boolean|string $add_fields - 'field_active', 'field_all', false (to omitt fields)
37
  *
38
  * Since 1.2 we enabled fetching by post title.
39
  *
40
+ * @param $group_id
41
+ * @param string $post_type
42
+ * @param bool $add_fields
43
+ * @return array
44
  */
45
  function wpcf_admin_fields_get_group( $group_id, $post_type = 'wp-types-group',
46
  $add_fields = false ) {
60
  /**
61
  * Converts post data.
62
  *
63
+ * @param $post
64
+ * @param bool $add_fields
65
+ * @return array
66
  */
67
  function wpcf_admin_fields_adjust_group( $post, $add_fields = false ) {
68
  if ( empty( $post ) ) {
92
  /**
93
  * Gets Fields Admin Styles supported by specific group.
94
  *
 
95
  * @param type $group_id
96
  * @return type
97
  */
98
  function wpcf_admin_get_groups_admin_styles_by_group( $group_id ) {
99
+ $admin_styles = get_post_meta( $group_id, '_wp_types_group_admin_styles', true );
 
100
  return trim( $admin_styles );
101
  }
102
 
103
  /**
104
  * Saves group's admin styles
105
  *
 
106
  * @param type $group_id
107
  * @param type $padmin_styles
108
  */
114
  * Gets all fields.
115
  *
116
  * @todo Move to WPCF_Fields
117
+ * @param bool $only_active
118
+ * @param bool $disabled_by_type
119
+ * @param bool $strictly_active
120
+ * @param string $option_name
121
+ * @param bool $use_cache
122
+ * @param bool $clear_cache
123
  * @return type
124
+ *
125
+ * added param $use_cache by Gen (used when adding new fields to group)
126
  * added param $use_cache by Gen (used when adding new fields to group)
127
  */
128
  function wpcf_admin_fields_get_fields( $only_active = false,
192
  return $cache[$cache_key];
193
  }
194
 
195
+ function wpcf_admin_fields_get_field_by_meta_key( $meta_key )
196
+ {
197
+ $fields = wpcf_admin_fields_get_fields();
198
+ foreach( $fields as $field) {
199
+ if ( $meta_key == $field['meta_key'] ) {
200
+ return $field;
201
+ }
202
+ }
203
+ }
204
+
205
  /**
206
  * Gets field by ID.
207
  * Modified by Gen, 13.02.2013
208
  *
209
+ * @param string $field_id
210
+ * @param bool $only_active
211
+ * @param bool $disabled_by_type
212
+ * @param bool $strictly_active
213
+ * @param string $option_name
214
+ * @return array
215
  */
216
  function wpcf_admin_fields_get_field( $field_id, $only_active = false,
217
  $disabled_by_type = false, $strictly_active = false,
229
  * Gets field by slug.
230
  * Modified by Gen, 13.02.2013
231
  *
 
232
  * @param type $slug
233
  * @return type
234
  */
239
  /**
240
  * Gets all fields that belong to specific group.
241
  *
 
242
  * @param type $group_id
243
  * @param type $key
244
  * @param type $only_active
279
  /**
280
  * Gets groups that have specific term.
281
  *
 
282
  * @param type $term_id
283
  * @param type $fetch_empty
284
  * @param type $only_active
336
  /**
337
  * Gets groups that have specific post_type.
338
  *
339
+ * @global object $wpdb
340
  * @param type $post_type
341
  * @param type $fetch_empty
342
  * @param type $only_active
343
  * @return type
344
  */
345
+ function wpcf_admin_get_groups_by_post_type( $post_type, $fetch_empty = true, $terms = null, $only_active = true )
346
+ {
347
  $args = array();
348
  $args['post_type'] = 'wp-types-group';
349
  $args['numberposts'] = -1;
391
  // Distinct terms
392
  if ( !is_null( $terms ) ) {
393
  if ( !empty( $terms ) ) {
 
394
  $terms_sql = array();
395
  $add = '';
396
  if ( $fetch_empty ) {
397
  $add = " OR m.meta_value LIKE 'all'";
398
  }
399
  foreach ( $terms as $term ) {
400
+ $terms_sql[] = esc_sql( $term );
401
  }
402
+ $terms_sql = "AND (m.meta_value LIKE '%%," . implode( ",%%' OR m.meta_value LIKE '%%,", $terms_sql ) . ",%%' $add)";
 
403
  global $wpdb;
404
  $terms_sql = "SELECT * FROM $wpdb->posts p
405
+ JOIN $wpdb->postmeta m
406
+ WHERE p.post_type='wp-types-group' AND p.post_status='publish'
407
+ AND p.ID = m.post_id AND m.meta_key='_wp_types_group_terms'
408
+ $terms_sql";
409
  $groups = $wpdb->get_results( $terms_sql );
410
  if ( !empty( $groups ) ) {
411
  foreach ( $groups as $key => $group ) {
427
  /**
428
  * Gets groups that have specific template.
429
  *
 
430
  * @param type $post_type
431
  * @param type $fetch_empty
432
  * @param type $only_active
embedded/includes/fields/audio.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/fields/audio.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/fields/audio.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
embedded/includes/fields/checkbox.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/fields/checkbox.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/fields/checkbox.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
embedded/includes/fields/date.php CHANGED
@@ -321,8 +321,17 @@ function wpcf_fields_date_value_get_filter( $value, $field, $return = 'array',
321
  if (
322
  array_key_exists('datepicker', $value)
323
  && !array_key_exists('timestamp', $value)
324
- && preg_match( '/^\d+$/', $value['datepicker'] )
325
- ) {
 
 
 
 
 
 
 
 
 
326
  $value['timestamp'] = $value['datepicker'];
327
  unset($value['datepicker']);
328
  }
@@ -388,15 +397,6 @@ function wpcf_fields_date_view( $params ) {
388
  $output .= wpcf_fields_date_get_calendar( $params, true, false );
389
  break;
390
 
391
- case 'human-time-diff':
392
- $date_out = human_time_diff($params['field_value']);
393
- if ( $params['field_value'] < time() ) {
394
- $output .= sprintf( __('%s ago', 'wpcf'), $date_out);;
395
- } else {
396
- $output .= sprintf( __('%s to go', 'wpcf'), $date_out);;
397
- }
398
- break;
399
-
400
  default:
401
  $field_name = '';
402
 
321
  if (
322
  array_key_exists('datepicker', $value)
323
  && !array_key_exists('timestamp', $value)
324
+ //Fix date pre-1970 issue
325
+ //https://wp-types.com/forums/topic/pre-1971-dates-throw-error/#post-288989
326
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/194818870/comments
327
+ && (
328
+ preg_match( '/^\d+$/', $value['datepicker'] )
329
+ || (
330
+ -12219292800 <= $value['datepicker']
331
+ && $value['datepicker'] <= 32535215940
332
+ )
333
+ )
334
+ ) {
335
  $value['timestamp'] = $value['datepicker'];
336
  unset($value['datepicker']);
337
  }
397
  $output .= wpcf_fields_date_get_calendar( $params, true, false );
398
  break;
399
 
 
 
 
 
 
 
 
 
 
400
  default:
401
  $field_name = '';
402
 
embedded/includes/fields/date/calendar.php CHANGED
@@ -1,20 +1,20 @@
1
  <?php
2
  /*
3
- *
4
  * Calendar view.
5
  */
6
 
7
  /**
8
  * Calendar view.
9
- *
10
- * @global type $wpdb
11
  * @global type $m
12
  * @global type $wp_locale
13
  * @global type $posts
14
  * @param type $params
15
  * @param type $initial
16
  * @param type $echo
17
- * @return type
18
  */
19
  function wpcf_fields_date_get_calendar( $params, $initial = true, $echo = true ) {
20
 
@@ -55,7 +55,13 @@ function wpcf_fields_date_get_calendar( $params, $initial = true, $echo = true )
55
  // We need to get the month from MySQL
56
  $thisyear = '' . intval( substr( $m, 0, 4 ) );
57
  $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
58
- $thismonth = $wpdb->get_var( "SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')" );
 
 
 
 
 
 
59
  } elseif ( !empty( $m ) ) {
60
  $thisyear = '' . intval( substr( $m, 0, 4 ) );
61
  if ( strlen( $m ) < 6 )
@@ -153,4 +159,4 @@ function wpcf_fields_date_get_calendar( $params, $initial = true, $echo = true )
153
  echo apply_filters( 'get_calendar', $calendar_output );
154
  else
155
  return apply_filters( 'get_calendar', $calendar_output );
156
- }
1
  <?php
2
  /*
3
+ *
4
  * Calendar view.
5
  */
6
 
7
  /**
8
  * Calendar view.
9
+ *
10
+ * @global object $wpdb
11
  * @global type $m
12
  * @global type $wp_locale
13
  * @global type $posts
14
  * @param type $params
15
  * @param type $initial
16
  * @param type $echo
17
+ * @return type
18
  */
19
  function wpcf_fields_date_get_calendar( $params, $initial = true, $echo = true ) {
20
 
55
  // We need to get the month from MySQL
56
  $thisyear = '' . intval( substr( $m, 0, 4 ) );
57
  $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
58
+ $thismonth = $wpdb->get_var(
59
+ $wpdb->prepare(
60
+ "SELECT DATE_FORMAT((DATE_ADD(%s, INTERVAL %d DAY) ), '%%m')",
61
+ sprintf('%d0101', $thisyear),
62
+ $d
63
+ )
64
+ );
65
  } elseif ( !empty( $m ) ) {
66
  $thisyear = '' . intval( substr( $m, 0, 4 ) );
67
  if ( strlen( $m ) < 6 )
159
  echo apply_filters( 'get_calendar', $calendar_output );
160
  else
161
  return apply_filters( 'get_calendar', $calendar_output );
162
+ }
embedded/includes/fields/date/functions.php CHANGED
@@ -183,19 +183,19 @@ function wpcf_fields_date_custom_conditional_statement_filter( $null,
183
  $null = array_shift( $null );
184
  }
185
  $null = wpcf_fields_date_value_get_filter( $null, $field, 'timestamp' );
186
- if ( !is_numeric( $null ) ) {
187
- $null = -1;
188
- }
189
- /**
190
- * be sure do not return string if array is expected!
191
- */
192
- if ( !$single && !is_array($null) ) {
193
- return array($null);
194
- }
195
- }
196
- return $null;
197
- }
198
-
199
  /**
200
  * Returns most suitable date format.
201
  *
@@ -502,23 +502,6 @@ function __wpcf_fields_date_check_leftover( $value, $field, $use_cache = true )
502
  && $meta['minute'] != adodb_date( 'i', $meta['timestamp'] ) ) ) {
503
 
504
  $value = wpcf_fields_date_calculate_time( $meta );
505
-
506
- /*
507
- *
508
- * If enabling clearing old values here,
509
- * pay attention if field is repetitive.
510
- *
511
- * For now - old data is cleared on date save.
512
- * wpcf_fields_date_value_save_filter()
513
- */
514
-
515
- // Update meta
516
- // $success = update_post_meta( $post_id, $field_slug, $value );
517
- // Remove additional meta
518
- // if ( $success ) {
519
- // delete_post_meta( $post_id,
520
- // '_wpcf_' . $field_id . '_hour_and_minute' );
521
- // }
522
  }
523
  }
524
  }
183
  $null = array_shift( $null );
184
  }
185
  $null = wpcf_fields_date_value_get_filter( $null, $field, 'timestamp' );
186
+ if ( !is_numeric( $null ) ) {
187
+ $null = -1;
188
+ }
189
+ /**
190
+ * be sure do not return string if array is expected!
191
+ */
192
+ if ( !$single && !is_array($null) ) {
193
+ return array($null);
194
+ }
195
+ }
196
+ return $null;
197
+ }
198
+
199
  /**
200
  * Returns most suitable date format.
201
  *
502
  && $meta['minute'] != adodb_date( 'i', $meta['timestamp'] ) ) ) {
503
 
504
  $value = wpcf_fields_date_calculate_time( $meta );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505
  }
506
  }
507
  }
embedded/includes/fields/embed.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  /**
4
  * Register data (called automatically).
5
- *
6
- * @return type
7
  */
8
  function wpcf_fields_embed() {
9
  return array(
@@ -17,9 +17,9 @@ function wpcf_fields_embed() {
17
 
18
  /**
19
  * Meta box form.
20
- *
21
  * @param type $field
22
- * @return string
23
  */
24
  function wpcf_fields_embed_meta_box_form( $field ) {
25
  $form = array();
@@ -32,7 +32,7 @@ function wpcf_fields_embed_meta_box_form( $field ) {
32
 
33
  /**
34
  * View function.
35
- *
36
  * @global type $wp_embed
37
  * @param type $field
38
  * @return string
@@ -59,10 +59,10 @@ function wpcf_fields_embed_view( $params ) {
59
  return $output;
60
  }
61
 
62
-
63
-
64
  /**
65
  * Editor callback form.
 
 
66
  */
67
  function wpcf_fields_embed_editor_callback( $field, $data, $meta_type, $post ) {
68
 
@@ -79,9 +79,12 @@ function wpcf_fields_embed_editor_callback( $field, $data, $meta_type, $post ) {
79
  if ( !empty( $file ) ) {
80
  // Get attachment by guid
81
  global $wpdb;
82
- $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts}
83
- WHERE post_type = 'attachment' AND guid=%s",
84
- $file ) );
 
 
 
85
  }
86
  }
87
 
@@ -121,4 +124,4 @@ function wpcf_fields_embed_editor_submit( $data, $field, $context ) {
121
  }
122
 
123
  return $shortcode;
124
- }
2
 
3
  /**
4
  * Register data (called automatically).
5
+ *
6
+ * @return type
7
  */
8
  function wpcf_fields_embed() {
9
  return array(
17
 
18
  /**
19
  * Meta box form.
20
+ *
21
  * @param type $field
22
+ * @return string
23
  */
24
  function wpcf_fields_embed_meta_box_form( $field ) {
25
  $form = array();
32
 
33
  /**
34
  * View function.
35
+ *
36
  * @global type $wp_embed
37
  * @param type $field
38
  * @return string
59
  return $output;
60
  }
61
 
 
 
62
  /**
63
  * Editor callback form.
64
+ *
65
+ * @global object $wpdb
66
  */
67
  function wpcf_fields_embed_editor_callback( $field, $data, $meta_type, $post ) {
68
 
79
  if ( !empty( $file ) ) {
80
  // Get attachment by guid
81
  global $wpdb;
82
+ $attachment_id = $wpdb->get_var(
83
+ $wpdb->prepare(
84
+ "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s",
85
+ $file
86
+ )
87
+ );
88
  }
89
  }
90
 
124
  }
125
 
126
  return $shortcode;
127
+ }
embedded/includes/fields/file.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /*
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/fields/file.php $
5
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
6
- * $LastChangedRevision: 970205 $
7
- * $LastChangedBy: brucepearson $
8
  *
9
  */
10
  /**
@@ -17,11 +17,6 @@ function wpcf_fields_file() {
17
  'id' => 'wpcf-file',
18
  'title' => __( 'File', 'wpcf' ),
19
  'description' => __( 'File', 'wpcf' ),
20
- 'meta_box_js' => array(
21
- 'wpcf-jquery-fields-file' => array(
22
- 'inline' => 'wpcf_fields_file_meta_box_js_inline',
23
- )
24
- ),
25
  'validate' => array('required'),
26
  );
27
  }
@@ -29,6 +24,8 @@ function wpcf_fields_file() {
29
  /**
30
  * Form data for post edit page.
31
  *
 
 
32
  * @param type $field
33
  */
34
  function wpcf_fields_file_meta_box_form( $field ) {
@@ -41,9 +38,12 @@ function wpcf_fields_file_meta_box_form( $field ) {
41
  // Get attachment by guid
42
  global $wpdb;
43
  if ( !empty( $field['value'] ) ) {
44
- $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts}
45
- WHERE post_type = 'attachment' AND guid=%s",
46
- $field['value'] ) );
 
 
 
47
  }
48
 
49
  // Set preview
@@ -100,74 +100,6 @@ function wpcf_fields_file_meta_box_form( $field ) {
100
  return $form;
101
  }
102
 
103
- /**
104
- * Renders inline JS.
105
- */
106
- function wpcf_fields_file_meta_box_js_inline() {
107
- global $post;
108
- $for_post = (isset( $post ) ? 'post_id=' . $post->ID . '&' : '');
109
- ?>
110
- <script type="text/javascript">
111
- //<![CDATA[
112
- jQuery(document).ready(function($){
113
- window.wpcf_formfield = false;
114
- $('.wpcf-fields-file-upload-link').live('click', function() {
115
- window.wpcf_formfield = '#'+$(this).attr('id')+'-holder';
116
- tb_show('', 'media-upload.php?<?php echo $for_post ?>type=file&context=wpcf-fields-media-insert&types[field_type]='+$(this).data('types').id+'&types[field_id]='+$(this).data('types').id+'&TB_iframe=true');
117
- return false;
118
- });
119
- });
120
- function wpcfFieldsFileMediaInsert(url, type) {
121
- jQuery(window.wpcf_formfield).val(url);
122
- if (type == 'image') {
123
- jQuery(window.wpcf_formfield+'-preview').html('<img src="'+url+'" />');
124
- } else {
125
- jQuery(window.wpcf_formfield+'-preview').html('');
126
- }
127
- tb_remove();
128
- window.wpcf_formfield = false;
129
- }
130
- //]]>
131
- </script>
132
- <?php
133
- }
134
-
135
- /**
136
- * Media popup JS.
137
- */
138
- function wpcf_fields_file_media_admin_head() {
139
- ?>
140
- <script type="text/javascript">
141
- function wpcfFieldsFileMediaTrigger(guid, type) {
142
- window.parent.wpcfFieldsFileMediaInsert(guid, type);
143
- window.parent.jQuery('#TB_closeWindowButton').trigger('click');
144
- }
145
- <?php
146
- if ( isset( $_GET['types']['field_type'] ) && in_array( $_GET['types']['field_type'],
147
- array('audio', 'video') ) ):
148
- ?>
149
- jQuery(document).ready(function($){
150
- $('#media-upload-header').after('<div class="message updated"><p><?php printf(esc_js(__('Please note that not all video and audio formats are supported by the WordPress media player. Before you upload media files, have a look at %ssupported media formats%s.', 'wpcf')), '<a href="http://wp-types.com/documentation/user-guides/adding-audio-video-and-other-embedded-content-to-your-site/" target="_blank">', '</a>'); ?></p></div>');
151
- });
152
- <?php endif; ?>
153
- </script>
154
- <style type="text/css">
155
- tr.submit, .ml-submit, #save, #media-items .A1B1 p:last-child { display: none; }
156
- #media-search
157
- {
158
- position: static;
159
- height: auto;
160
- width: auto;
161
- }
162
- #media-search.search-box input[name="s"]
163
- {
164
- float: left;
165
- width: auto;
166
- }
167
- </style>
168
- <?php
169
- }
170
-
171
  /**
172
  * Adds 'Types' column to media item table.
173
  *
@@ -236,6 +168,9 @@ function wpcf_fields_file_view( $params ) {
236
 
237
  /**
238
  * Editor callback form.
 
 
 
239
  */
240
  function wpcf_fields_file_editor_callback( $field, $data, $meta_type, $post ) {
241
 
@@ -252,14 +187,16 @@ function wpcf_fields_file_editor_callback( $field, $data, $meta_type, $post ) {
252
  if ( !empty( $file ) ) {
253
  // Get attachment by guid
254
  global $wpdb;
255
- $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts}
256
- WHERE post_type = 'attachment' AND guid=%s",
257
- $file ) );
 
 
 
258
  }
259
  }
260
 
261
  // Set data
262
- // $data['post_id'] = !empty( $post->ID ) ? $post->ID : -1;
263
  $data['attachment_id'] = $attachment_id;
264
  $data['file'] = !empty($file) ? $file : '';
265
 
1
  <?php
2
  /*
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/fields/file.php $
5
+ * $LastChangedDate: 2015-03-16 12:03:31 +0000 (Mon, 16 Mar 2015) $
6
+ * $LastChangedRevision: 1113864 $
7
+ * $LastChangedBy: iworks $
8
  *
9
  */
10
  /**
17
  'id' => 'wpcf-file',
18
  'title' => __( 'File', 'wpcf' ),
19
  'description' => __( 'File', 'wpcf' ),
 
 
 
 
 
20
  'validate' => array('required'),
21
  );
22
  }
24
  /**
25
  * Form data for post edit page.
26
  *
27
+ * @global object $wpdb
28
+ *
29
  * @param type $field
30
  */
31
  function wpcf_fields_file_meta_box_form( $field ) {
38
  // Get attachment by guid
39
  global $wpdb;
40
  if ( !empty( $field['value'] ) ) {
41
+ $attachment_id = $wpdb->get_var(
42
+ $wpdb->prepare(
43
+ "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s",
44
+ $field['value']
45
+ )
46
+ );
47
  }
48
 
49
  // Set preview
100
  return $form;
101
  }
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  /**
104
  * Adds 'Types' column to media item table.
105
  *
168
 
169
  /**
170
  * Editor callback form.
171
+ *
172
+ * @global object $wpdb
173
+ *
174
  */
175
  function wpcf_fields_file_editor_callback( $field, $data, $meta_type, $post ) {
176
 
187
  if ( !empty( $file ) ) {
188
  // Get attachment by guid
189
  global $wpdb;
190
+ $attachment_id = $wpdb->get_var(
191
+ $wpdb->prepare(
192
+ "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s",
193
+ $file
194
+ )
195
+ );
196
  }
197
  }
198
 
199
  // Set data
 
200
  $data['attachment_id'] = $attachment_id;
201
  $data['file'] = !empty($file) ? $file : '';
202
 
embedded/includes/fields/image.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/fields/image.php $
5
- * $LastChangedDate: 2014-11-21 08:53:16 +0000 (Fri, 21 Nov 2014) $
6
- * $LastChangedRevision: 1029976 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -16,7 +16,7 @@ add_filter( 'types_view', 'wpcf_fields_image_view_filter', 10, 6 );
16
 
17
  /**
18
  * Register data (called automatically).
19
- * @return type
20
  */
21
  function wpcf_fields_image() {
22
  return array(
@@ -24,46 +24,15 @@ function wpcf_fields_image() {
24
  'title' => __( 'Image', 'wpcf' ),
25
  'description' => __( 'Image', 'wpcf' ),
26
  'validate' => array('required'),
27
- 'meta_box_js' => array(
28
- 'wpcf-jquery-fields-file' => array(
29
- 'inline' => 'wpcf_fields_file_meta_box_js_inline',
30
- ),
31
- 'wpcf-jquery-fields-image' => array(
32
- 'inline' => 'wpcf_fields_image_meta_box_js_inline',
33
- ),
34
- ),
35
  'inherited_field_type' => 'file',
36
  );
37
  }
38
 
39
- /**
40
- * Renders inline JS.
41
- */
42
- function wpcf_fields_image_meta_box_js_inline() {
43
- global $post;
44
- $for_post = (isset( $post ) ? 'post_id=' . $post->ID . '&' : '');
45
-
46
- ?>
47
- <script type="text/javascript">
48
- //<![CDATA[
49
- jQuery(document).ready(function(){
50
- wpcf_formfield = false;
51
- jQuery('.wpcf-fields-image-upload-link').live('click', function() {
52
- wpcf_formfield = '#'+jQuery(this).attr('id')+'-holder';
53
- tb_show('<?php
54
- echo esc_js( __( 'Upload image', 'wpcf' ) );
55
-
56
- ?>', 'media-upload.php?<?php echo $for_post ?>type=image&context=wpcf-fields-media-insert&TB_iframe=1&width=640&height=336');
57
- return false;
58
- });
59
- });
60
- //]]>
61
- </script>
62
- <?php
63
- }
64
-
65
  /**
66
  * Editor callback form.
 
 
 
67
  */
68
  function wpcf_fields_image_editor_callback( $field, $data, $context, $post ) {
69
 
@@ -84,9 +53,12 @@ function wpcf_fields_image_editor_callback( $field, $data, $context, $post ) {
84
  if ( !empty( $image ) ) {
85
  // Get attachment by guid
86
  global $wpdb;
87
- $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts}
88
- WHERE post_type = 'attachment' AND guid=%s",
89
- $image ) );
 
 
 
90
  }
91
  }
92
  $data['image'] = $image;
@@ -264,8 +236,8 @@ function wpcf_fields_image_editor_submit( $data, $field, $context ) {
264
 
265
  /**
266
  * View function.
267
- *
268
- * @param type $params
269
  */
270
  function wpcf_fields_image_view( $params ) {
271
 
@@ -311,7 +283,7 @@ function wpcf_fields_image_view( $params ) {
311
  if ( !empty( $params['style'] ) ) {
312
  $style[] = $params['style'];
313
  }
314
-
315
  // Compatibility with old parameters
316
  $old_param = isset( $params['proportional'] ) && $params['proportional'] == 'true' ? 'proportional' : 'crop';
317
  $resize = isset( $params['resize'] ) ? $params['resize'] : $old_param;
@@ -550,10 +522,9 @@ function wpcf_fields_image_resize_image( $url_path, $width = 300, $height = 200,
550
 
551
  /**
552
  * Gets all necessary data for processed image.
553
- *
554
- * @global type $wpdb
555
  * @param type $image
556
- * @return type
557
  */
558
  function wpcf_fields_image_get_data( $image ) {
559
 
@@ -565,7 +536,7 @@ function wpcf_fields_image_get_data( $image ) {
565
  if ( isset( $cache[$cache_key] ) ) {
566
  return $cache[$cache_key];
567
  }
568
-
569
  WPCF_Loader::loadView( 'image' );
570
  $utils = Types_Image_Utils::getInstance();
571
 
@@ -658,9 +629,9 @@ function wpcf_fields_image_get_data( $image ) {
658
 
659
  /**
660
  * Strips GET vars from value.
661
- *
662
  * @param type $value
663
- * @return type
664
  */
665
  function wpcf_fields_image_value_filter( $value ) {
666
  if ( is_string( $value ) && !apply_filters('wpcf_allow_questionmark_in_image_url', false) ) {
@@ -671,8 +642,8 @@ function wpcf_fields_image_value_filter( $value ) {
671
 
672
  /**
673
  * Gets cache directory.
674
- *
675
- * @return \WP_Error
676
  */
677
  function wpcf_fields_image_get_cache_directory( $suppress_filters = false ) {
678
  WPCF_Loader::loadView( 'image' );
@@ -699,9 +670,9 @@ function wpcf_image_http_request_timeout( $timeout ) {
699
 
700
  /**
701
  * Fetches remote images.
702
- *
703
  * @param type $url
704
- * @return \WP_Error
705
  */
706
  function wpcf_fields_image_get_remote( $url ) {
707
 
@@ -800,8 +771,8 @@ function wpcf_fields_image_get_remote( $url ) {
800
 
801
  /**
802
  * Clears remote image cache.
803
- *
804
- * @param type $action
805
  */
806
  function wpcf_fields_image_clear_cache( $cache_dir = null, $action = 'outdated' ) {
807
  if ( is_null( $cache_dir ) ) {
@@ -830,7 +801,7 @@ function wpcf_fields_image_clear_cache( $cache_dir = null, $action = 'outdated'
830
 
831
  /**
832
  * Filters upload paths (to fix Windows issues).
833
- *
834
  * @param type $args
835
  * @return type
836
  */
@@ -843,12 +814,12 @@ function wpcf_fields_image_uploads_realpath( $args ) {
843
  if ( isset( $args[$fix] ) ) {
844
  /*
845
  * Since 1.1.5
846
- *
847
  * We need realpath(), open_basedir restriction check
848
- *
849
  * Suppressing warnings, checking realpath returning FALSE, check
850
  * if open_basedir ini is set.
851
- *
852
  * https://icanlocalize.basecamphq.com/projects/7393061-wp-views/todo_items/153462252/comments
853
  * http://php.net/manual/en/ini.sect.safe-mode.php
854
  * http://php.net/manual/en/ini.core.php#ini.open-basedir
@@ -978,9 +949,9 @@ function wpcf_image_resize( $file, $max_w, $max_h, $crop = false,
978
 
979
  /**
980
  * Fixes for Win.
981
- *
982
  * For now we fix file path to have unified type slashes.
983
- *
984
  * @param type $file
985
  * @param type $attachment_id
986
  * @return type
@@ -1002,10 +973,10 @@ function wpcf_fields_image_win32_update_attached_file_filter( $file,
1002
 
1003
  /**
1004
  * Filters image view.
1005
- *
1006
  * This is added to handle image 'url' parameter.
1007
  * We need to unwrap value. Also added to avoid cludging frontend.php.
1008
- *
1009
  * @param boolean $params
1010
  * @param type $field
1011
  * @return boolean
@@ -1030,7 +1001,7 @@ function wpcf_fields_image_view_filter( $output, $value, $type, $slug, $name,
1030
 
1031
  /**
1032
  * Adds image to library.
1033
- *
1034
  * @param type $post
1035
  * @param type $abspath
1036
  */
@@ -1057,21 +1028,24 @@ function wpcf_image_add_to_library( $post, $abspath ){
1057
 
1058
  /**
1059
  * Checks if image is attachment.
1060
- *
1061
- * @global type $wpdb
1062
  * @param type $guid
1063
  * @return type
1064
  */
1065
  function wpcf_image_is_attachment( $guid ) {
1066
  global $wpdb;
1067
- return $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts}
1068
- WHERE post_type = 'attachment' AND guid=%s",
1069
- $guid ) );
 
 
 
1070
  }
1071
 
1072
  /**
1073
  * Gets attachment URL (in uploads, root or date structure).
1074
- *
1075
  * @param type $abspath
1076
  * @return type
1077
  */
@@ -1082,7 +1056,7 @@ function wpcf_image_attachment_url( $abspath ) {
1082
 
1083
  /**
1084
  * Returns path to attachment relative to upload_dir.
1085
- *
1086
  * @param type $abspath
1087
  * @return string '2014/01/img.jpg'
1088
  */
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/fields/image.php $
5
+ * $LastChangedDate: 2015-03-16 12:03:31 +0000 (Mon, 16 Mar 2015) $
6
+ * $LastChangedRevision: 1113864 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
16
 
17
  /**
18
  * Register data (called automatically).
19
+ * @return type
20
  */
21
  function wpcf_fields_image() {
22
  return array(
24
  'title' => __( 'Image', 'wpcf' ),
25
  'description' => __( 'Image', 'wpcf' ),
26
  'validate' => array('required'),
 
 
 
 
 
 
 
 
27
  'inherited_field_type' => 'file',
28
  );
29
  }
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  /**
32
  * Editor callback form.
33
+ *
34
+ * @global object $wpdb
35
+ *
36
  */
37
  function wpcf_fields_image_editor_callback( $field, $data, $context, $post ) {
38
 
53
  if ( !empty( $image ) ) {
54
  // Get attachment by guid
55
  global $wpdb;
56
+ $attachment_id = $wpdb->get_var(
57
+ $wpdb->prepare(
58
+ "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s",
59
+ $image
60
+ )
61
+ );
62
  }
63
  }
64
  $data['image'] = $image;
236
 
237
  /**
238
  * View function.
239
+ *
240
+ * @param type $params
241
  */
242
  function wpcf_fields_image_view( $params ) {
243
 
283
  if ( !empty( $params['style'] ) ) {
284
  $style[] = $params['style'];
285
  }
286
+
287
  // Compatibility with old parameters
288
  $old_param = isset( $params['proportional'] ) && $params['proportional'] == 'true' ? 'proportional' : 'crop';
289
  $resize = isset( $params['resize'] ) ? $params['resize'] : $old_param;
522
 
523
  /**
524
  * Gets all necessary data for processed image.
525
+ *
 
526
  * @param type $image
527
+ * @return type
528
  */
529
  function wpcf_fields_image_get_data( $image ) {
530
 
536
  if ( isset( $cache[$cache_key] ) ) {
537
  return $cache[$cache_key];
538
  }
539
+
540
  WPCF_Loader::loadView( 'image' );
541
  $utils = Types_Image_Utils::getInstance();
542
 
629
 
630
  /**
631
  * Strips GET vars from value.
632
+ *
633
  * @param type $value
634
+ * @return type
635
  */
636
  function wpcf_fields_image_value_filter( $value ) {
637
  if ( is_string( $value ) && !apply_filters('wpcf_allow_questionmark_in_image_url', false) ) {
642
 
643
  /**
644
  * Gets cache directory.
645
+ *
646
+ * @return \WP_Error
647
  */
648
  function wpcf_fields_image_get_cache_directory( $suppress_filters = false ) {
649
  WPCF_Loader::loadView( 'image' );
670
 
671
  /**
672
  * Fetches remote images.
673
+ *
674
  * @param type $url
675
+ * @return \WP_Error
676
  */
677
  function wpcf_fields_image_get_remote( $url ) {
678
 
771
 
772
  /**
773
  * Clears remote image cache.
774
+ *
775
+ * @param type $action
776
  */
777
  function wpcf_fields_image_clear_cache( $cache_dir = null, $action = 'outdated' ) {
778
  if ( is_null( $cache_dir ) ) {
801
 
802
  /**
803
  * Filters upload paths (to fix Windows issues).
804
+ *
805
  * @param type $args
806
  * @return type
807
  */
814
  if ( isset( $args[$fix] ) ) {
815
  /*
816
  * Since 1.1.5
817
+ *
818
  * We need realpath(), open_basedir restriction check
819
+ *
820
  * Suppressing warnings, checking realpath returning FALSE, check
821
  * if open_basedir ini is set.
822
+ *
823
  * https://icanlocalize.basecamphq.com/projects/7393061-wp-views/todo_items/153462252/comments
824
  * http://php.net/manual/en/ini.sect.safe-mode.php
825
  * http://php.net/manual/en/ini.core.php#ini.open-basedir
949
 
950
  /**
951
  * Fixes for Win.
952
+ *
953
  * For now we fix file path to have unified type slashes.
954
+ *
955
  * @param type $file
956
  * @param type $attachment_id
957
  * @return type
973
 
974
  /**
975
  * Filters image view.
976
+ *
977
  * This is added to handle image 'url' parameter.
978
  * We need to unwrap value. Also added to avoid cludging frontend.php.
979
+ *
980
  * @param boolean $params
981
  * @param type $field
982
  * @return boolean
1001
 
1002
  /**
1003
  * Adds image to library.
1004
+ *
1005
  * @param type $post
1006
  * @param type $abspath
1007
  */
1028
 
1029
  /**
1030
  * Checks if image is attachment.
1031
+ *
1032
+ * @global object $wpdb
1033
  * @param type $guid
1034
  * @return type
1035
  */
1036
  function wpcf_image_is_attachment( $guid ) {
1037
  global $wpdb;
1038
+ return $wpdb->get_var(
1039
+ $wpdb->prepare(
1040
+ "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s",
1041
+ $guid
1042
+ )
1043
+ );
1044
  }
1045
 
1046
  /**
1047
  * Gets attachment URL (in uploads, root or date structure).
1048
+ *
1049
  * @param type $abspath
1050
  * @return type
1051
  */
1056
 
1057
  /**
1058
  * Returns path to attachment relative to upload_dir.
1059
+ *
1060
  * @param type $abspath
1061
  * @return string '2014/01/img.jpg'
1062
  */
embedded/includes/fields/skype.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/fields/skype.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -18,7 +18,12 @@ function wpcf_fields_skype() {
18
  'id' => 'wpcf-skype',
19
  'title' => __( 'Skype', 'wpcf' ),
20
  'description' => __( 'Skype', 'wpcf' ),
21
- 'validate' => array('required'),
 
 
 
 
 
22
  );
23
  }
24
 
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/fields/skype.php $
5
+ * $LastChangedDate: 2015-02-18 14:28:53 +0000 (Wed, 18 Feb 2015) $
6
+ * $LastChangedRevision: 1093394 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
18
  'id' => 'wpcf-skype',
19
  'title' => __( 'Skype', 'wpcf' ),
20
  'description' => __( 'Skype', 'wpcf' ),
21
+ 'validate' => array(
22
+ 'required',
23
+ 'skype',
24
+ 'maxlength' => array('value' => 32),
25
+ 'minlength' => array('value' => 6)
26
+ ),
27
  );
28
  }
29
 
embedded/includes/fields/textarea.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/fields/textarea.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/fields/textarea.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
embedded/includes/fields/video.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/fields/video.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -28,6 +28,8 @@ function wpcf_fields_video() {
28
  * View function.
29
  *
30
  * @global type $wp_embed
 
 
31
  * @param type $field
32
  * @return string
33
  */
@@ -83,9 +85,12 @@ function wpcf_fields_video_editor_callback( $field, $data, $meta_type, $post ) {
83
  if ( !empty( $file ) ) {
84
  // Get attachment by guid
85
  global $wpdb;
86
- $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts}
87
- WHERE post_type = 'attachment' AND guid=%s",
88
- $file ) );
 
 
 
89
  }
90
  }
91
 
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/fields/video.php $
5
+ * $LastChangedDate: 2015-03-16 12:03:31 +0000 (Mon, 16 Mar 2015) $
6
+ * $LastChangedRevision: 1113864 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
28
  * View function.
29
  *
30
  * @global type $wp_embed
31
+ * @global object $wpdb
32
+ *
33
  * @param type $field
34
  * @return string
35
  */
85
  if ( !empty( $file ) ) {
86
  // Get attachment by guid
87
  global $wpdb;
88
+ $attachment_id = $wpdb->get_var(
89
+ $wpdb->prepare(
90
+ "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s",
91
+ $file
92
+ )
93
+ );
94
  }
95
  }
96
 
embedded/includes/fields/wysiwyg.php CHANGED
@@ -140,13 +140,23 @@ function wpcf_fields_wysiwyg_view( $params ) {
140
  }
141
  $output .= $content;
142
  } else {
143
- $output .= apply_filters( 'the_content',
144
- htmlspecialchars_decode( stripslashes( $params['field_value'] ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
145
  }
146
-
147
-
148
  if ( !empty( $params['style'] ) || !empty( $params['class'] ) ) {
149
  $output .= '</div>';
150
  }
151
  return $output;
152
- }
140
  }
141
  $output .= $content;
142
  } else {
143
+ /**
144
+ * remove_shortcode playlist to avoid htmlspecialchars_decode on json
145
+ * data
146
+ */
147
+ remove_shortcode('playlist', 'wp_playlist_shortcode');
148
+ $output .= apply_filters( 'the_content', htmlspecialchars_decode( stripslashes( $params['field_value'] ) ) );
149
+ if ( preg_match_all('/playlist[^\]]+/', $output, $matches ) ) {
150
+ foreach( $matches[0] as $one ) {
151
+ $re = '/'.$one.'/';
152
+ $one = preg_replace('/\&\#(8221|8243);/', '"', $one);
153
+ $output = preg_replace($re, $one, $output);
154
+ }
155
+ }
156
+ add_shortcode( 'playlist', 'wp_playlist_shortcode' );
157
  }
 
 
158
  if ( !empty( $params['style'] ) || !empty( $params['class'] ) ) {
159
  $output .= '</div>';
160
  }
161
  return $output;
162
+ }
embedded/includes/import-export.php CHANGED
@@ -2,19 +2,23 @@
2
  /*
3
  * Import/export data.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/import-export.php $
6
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
7
- * $LastChangedRevision: 970205 $
8
- * $LastChangedBy: brucepearson $
9
  *
10
  */
11
 
12
  /**
13
  * Imports data from XML.
 
 
 
14
  */
15
- function wpcf_admin_import_data($data = '', $redirect = true,
16
- $context = 'types') {
17
  global $wpdb;
 
18
 
19
  libxml_use_internal_errors( true );
20
  $data = simplexml_load_string( $data );
@@ -36,6 +40,20 @@ function wpcf_admin_import_data($data = '', $redirect = true,
36
  $delete_types = isset( $_POST['delete-types'] );
37
  $delete_tax = isset( $_POST['delete-tax'] );
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  /**
40
  * process settings
41
  */
@@ -58,6 +76,7 @@ function wpcf_admin_import_data($data = '', $redirect = true,
58
  $group = wpcf_admin_import_export_simplexml2array( $group );
59
  $groups[$group['ID']] = $group;
60
  }
 
61
  // Set insert data from POST
62
  if ( !empty( $_POST['groups'] ) ) {
63
  foreach ( $_POST['groups'] as $group_id => $group ) {
@@ -90,10 +109,13 @@ function wpcf_admin_import_data($data = '', $redirect = true,
90
  $post['post_name'] = $group['__types_id'];
91
  }
92
  if ( (isset( $group['add'] ) && $group['add'] ) ) {
93
- $post_to_update = $wpdb->get_var( $wpdb->prepare(
94
- "SELECT ID FROM $wpdb->posts
95
- WHERE post_title = %s AND post_type = %s",
96
- $group['post_title'], 'wp-types-group' ) );
 
 
 
97
  // Update (may be forced by bulk action)
98
  if ( $group['update'] || ($overwrite_groups && !empty( $post_to_update )) ) {
99
  if ( !empty( $post_to_update ) ) {
@@ -150,6 +172,7 @@ function wpcf_admin_import_data($data = '', $redirect = true,
150
  }
151
  // Delete groups (forced, set in bulk actions)
152
  }
 
153
  if ( $delete_groups ) {
154
  $groups_to_delete = get_posts(
155
  array(
@@ -289,7 +312,7 @@ function wpcf_admin_import_data($data = '', $redirect = true,
289
  // Process user groups
290
  //print_r($data->user_groups);exit;
291
  $groups_check = array();
292
- if ( !empty( $data->user_groups ) ) {
293
  $groups = array();
294
  // Set insert data from XML
295
  foreach ( $data->user_groups->group as $group ) {
@@ -321,10 +344,13 @@ function wpcf_admin_import_data($data = '', $redirect = true,
321
  'post_content' => !empty( $group['post_content'] ) ? $group['post_content'] : '',
322
  );
323
  if ( (isset( $group['add'] ) && $group['add'] ) ) {
324
- $post_to_update = $wpdb->get_var( $wpdb->prepare(
325
- "SELECT ID FROM $wpdb->posts
326
- WHERE post_title = %s AND post_type = %s",
327
- $group['post_title'], 'wp-types-user-group' ) );
 
 
 
328
 
329
  // Update (may be forced by bulk action)
330
  if ( $group['update'] || ($overwrite_groups && !empty( $post_to_update )) ) {
@@ -509,7 +535,7 @@ function wpcf_admin_import_data($data = '', $redirect = true,
509
 
510
  $types_existing = get_option( 'wpcf-custom-types', array() );
511
  $types_check = array();
512
- if ( !empty( $data->types ) ) {
513
  $types = array();
514
  // Set insert data from XML
515
  foreach ( $data->types->type as $type ) {
@@ -570,7 +596,7 @@ function wpcf_admin_import_data($data = '', $redirect = true,
570
 
571
  $taxonomies_existing = get_option( 'wpcf-custom-taxonomies', array() );
572
  $taxonomies_check = array();
573
- if ( !empty( $data->taxonomies ) ) {
574
  $taxonomies = array();
575
  // Set insert data from XML
576
  foreach ( $data->taxonomies->taxonomy as $taxonomy ) {
@@ -606,21 +632,28 @@ function wpcf_admin_import_data($data = '', $redirect = true,
606
  'wpcf' ), $taxonomy_id ) );
607
  }
608
  }
 
 
 
 
 
 
 
 
 
609
  // Delete taxonomies
610
  if ( $delete_tax ) {
611
  foreach ( $taxonomies_existing as $k => $v ) {
612
  if ( !in_array( $k, $taxonomies_check ) ) {
613
  unset( $taxonomies_existing[$k] );
614
- wpcf_admin_message_store( sprintf( __( 'Custom taxonomy "%s" deleted',
615
- 'wpcf' ), $k ) );
616
  }
617
  }
618
  } else {
619
  if ( !empty( $_POST['taxonomies-to-be-deleted'] ) ) {
620
  foreach ( $_POST['taxonomies-to-be-deleted'] as
621
  $taxonomy_to_delete ) {
622
- wpcf_admin_message_store( sprintf( __( 'Custom taxonomy "%s" deleted',
623
- 'wpcf' ),
624
  $taxonomies_existing[$taxonomy_to_delete]['labels']['name'] ) );
625
  unset( $taxonomies_existing[$taxonomy_to_delete] );
626
  }
@@ -710,3 +743,4 @@ function wpcf_admin_import_export_simplexml2array($element)
710
 
711
  return $element;
712
  }
 
2
  /*
3
  * Import/export data.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/import-export.php $
6
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
7
+ * $LastChangedRevision: 1120400 $
8
+ * $LastChangedBy: iworks $
9
  *
10
  */
11
 
12
  /**
13
  * Imports data from XML.
14
+ *
15
+ * @global object $wpdb
16
+ *
17
  */
18
+ function wpcf_admin_import_data($data = '', $redirect = true, $context = 'types', $args = array() )
19
+ {
20
  global $wpdb;
21
+ $data_installer = false;
22
 
23
  libxml_use_internal_errors( true );
24
  $data = simplexml_load_string( $data );
40
  $delete_types = isset( $_POST['delete-types'] );
41
  $delete_tax = isset( $_POST['delete-tax'] );
42
 
43
+ if ('wpvdemo' == $context && !empty($args)) {
44
+ /**
45
+ * allow overwrite
46
+ */
47
+ $overwrite_groups = true;
48
+ $overwrite_fields = true;
49
+ $overwrite_types = true;
50
+ $overwrite_tax = true;
51
+
52
+ include_once dirname(__FILE__).'/classes/class.types.data.installer.php';
53
+ $data_installer = new Types_Data_Installer($data, $args);
54
+ $data = $data_installer->wpvdemo();
55
+ }
56
+
57
  /**
58
  * process settings
59
  */
76
  $group = wpcf_admin_import_export_simplexml2array( $group );
77
  $groups[$group['ID']] = $group;
78
  }
79
+
80
  // Set insert data from POST
81
  if ( !empty( $_POST['groups'] ) ) {
82
  foreach ( $_POST['groups'] as $group_id => $group ) {
109
  $post['post_name'] = $group['__types_id'];
110
  }
111
  if ( (isset( $group['add'] ) && $group['add'] ) ) {
112
+ $post_to_update = $wpdb->get_var(
113
+ $wpdb->prepare(
114
+ "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = %s",
115
+ $group['post_title'],
116
+ 'wp-types-group'
117
+ )
118
+ );
119
  // Update (may be forced by bulk action)
120
  if ( $group['update'] || ($overwrite_groups && !empty( $post_to_update )) ) {
121
  if ( !empty( $post_to_update ) ) {
172
  }
173
  // Delete groups (forced, set in bulk actions)
174
  }
175
+
176
  if ( $delete_groups ) {
177
  $groups_to_delete = get_posts(
178
  array(
312
  // Process user groups
313
  //print_r($data->user_groups);exit;
314
  $groups_check = array();
315
+ if ( !empty( $data->user_groups ) && isset( $data->user_groups->group) ) {
316
  $groups = array();
317
  // Set insert data from XML
318
  foreach ( $data->user_groups->group as $group ) {
344
  'post_content' => !empty( $group['post_content'] ) ? $group['post_content'] : '',
345
  );
346
  if ( (isset( $group['add'] ) && $group['add'] ) ) {
347
+ $post_to_update = $wpdb->get_var(
348
+ $wpdb->prepare(
349
+ "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = %s",
350
+ $group['post_title'],
351
+ 'wp-types-user-group'
352
+ )
353
+ );
354
 
355
  // Update (may be forced by bulk action)
356
  if ( $group['update'] || ($overwrite_groups && !empty( $post_to_update )) ) {
535
 
536
  $types_existing = get_option( 'wpcf-custom-types', array() );
537
  $types_check = array();
538
+ if ( !empty($data->types) && isset($data->types->type) ) {
539
  $types = array();
540
  // Set insert data from XML
541
  foreach ( $data->types->type as $type ) {
596
 
597
  $taxonomies_existing = get_option( 'wpcf-custom-taxonomies', array() );
598
  $taxonomies_check = array();
599
+ if ( !empty( $data->taxonomies ) && isset($data->taxonomies->taxonomy)) {
600
  $taxonomies = array();
601
  // Set insert data from XML
602
  foreach ( $data->taxonomies->taxonomy as $taxonomy ) {
632
  'wpcf' ), $taxonomy_id ) );
633
  }
634
  }
635
+
636
+
637
+ /**
638
+ * reset TOOLSET_EDIT_LAST
639
+ */
640
+ if ( $data_installer ) {
641
+ $data_installer->reset_toolset_edit_last();
642
+ }
643
+
644
  // Delete taxonomies
645
  if ( $delete_tax ) {
646
  foreach ( $taxonomies_existing as $k => $v ) {
647
  if ( !in_array( $k, $taxonomies_check ) ) {
648
  unset( $taxonomies_existing[$k] );
649
+ wpcf_admin_message_store( sprintf( __( 'Custom taxonomy "%s" deleted', 'wpcf' ), $k ) );
 
650
  }
651
  }
652
  } else {
653
  if ( !empty( $_POST['taxonomies-to-be-deleted'] ) ) {
654
  foreach ( $_POST['taxonomies-to-be-deleted'] as
655
  $taxonomy_to_delete ) {
656
+ wpcf_admin_message_store( sprintf( __( 'Custom taxonomy "%s" deleted', 'wpcf' ),
 
657
  $taxonomies_existing[$taxonomy_to_delete]['labels']['name'] ) );
658
  unset( $taxonomies_existing[$taxonomy_to_delete] );
659
  }
743
 
744
  return $element;
745
  }
746
+
embedded/includes/module-manager.php CHANGED
@@ -4,9 +4,9 @@
4
  *
5
  * Since Types 1.2
6
  *
7
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/module-manager.php $
8
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
9
- * $LastChangedRevision: 1027712 $
10
  * $LastChangedBy: iworks $
11
  *
12
  */
@@ -775,7 +775,7 @@ function wpcf_admin_export_selected_data ( array $items, $_type = 'all', $return
775
  *
776
  * Import selected items given by xmlstring.
777
  *
778
- * @global type $wpdb
779
  * @global type $iclTranslationManagement
780
  * @param type $data
781
  * @param type $_type
@@ -850,10 +850,13 @@ function wpcf_admin_import_data_from_xmlstring( $data = '', $_type = 'types',
850
  'post_content' => !empty( $group['post_content'] ) ? $group['post_content'] : '',
851
  );
852
  if ( (isset( $group['add'] ) && $group['add'] ) ) {
853
- $post_to_update = $wpdb->get_var( $wpdb->prepare(
854
- "SELECT ID FROM $wpdb->posts
855
- WHERE post_title = %s AND post_type = %s",
856
- $group['post_title'], 'wp-types-group' ) );
 
 
 
857
  // Update (may be forced by bulk action)
858
  if ( $group['update'] || (!empty( $post_to_update )) ) {
859
  if ( !empty( $post_to_update ) ) {
4
  *
5
  * Since Types 1.2
6
  *
7
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/module-manager.php $
8
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
9
+ * $LastChangedRevision: 1120400 $
10
  * $LastChangedBy: iworks $
11
  *
12
  */
775
  *
776
  * Import selected items given by xmlstring.
777
  *
778
+ * @global object $wpdb
779
  * @global type $iclTranslationManagement
780
  * @param type $data
781
  * @param type $_type
850
  'post_content' => !empty( $group['post_content'] ) ? $group['post_content'] : '',
851
  );
852
  if ( (isset( $group['add'] ) && $group['add'] ) ) {
853
+ $post_to_update = $wpdb->get_var(
854
+ $wpdb->prepare(
855
+ "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = %s",
856
+ $group['post_title'],
857
+ 'wp-types-group'
858
+ )
859
+ );
860
  // Update (may be forced by bulk action)
861
  if ( $group['update'] || (!empty( $post_to_update )) ) {
862
  if ( !empty( $post_to_update ) ) {
embedded/includes/post-relationship.php CHANGED
@@ -2,14 +2,12 @@
2
  /*
3
  * Post relationship code.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/post-relationship.php $
6
- * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
7
- * $LastChangedRevision: 1069430 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
11
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/editor-support/post-relationship-editor-support.php';
12
-
13
  add_action( 'wpcf_admin_post_init', 'wpcf_pr_admin_post_init_action', 10, 4 );
14
  add_action( 'save_post', 'wpcf_pr_admin_save_post_hook', 20, 2 ); // Trigger afer main hook
15
 
@@ -139,7 +137,6 @@ function wpcf_pr_admin_post_meta_box( $post, $args )
139
  _e( 'You will be able to manage child posts after saving this post.', 'wpcf' );
140
  } else {
141
  _e( 'You will be able to add parent posts after saving this post.', 'wpcf' );
142
- // add_action( 'admin_footer', 'wpcf_admin_notice_post_locked_no_parent');
143
  }
144
  }
145
  }
@@ -258,7 +255,7 @@ function wpcf_pr_admin_post_meta_box_output( $post, $args )
258
  /**
259
  * AJAX delete child item call.
260
  *
261
- * @param type $post_id
262
  * @return string
263
  */
264
  function wpcf_pr_admin_delete_child_item( $post_id ) {
@@ -266,6 +263,22 @@ function wpcf_pr_admin_delete_child_item( $post_id ) {
266
  return __( 'Post deleted', 'wpcf' );
267
  }
268
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  /**
270
  * Belongs form.
271
  *
@@ -301,20 +314,59 @@ function wpcf_pr_admin_post_meta_box_belongs_form( $post, $type, $belongs )
301
  if ( empty( $items ) ) {
302
  return array();
303
  }
304
-
305
- $_titles = $wpdb->get_results( $wpdb->prepare(
306
- "SELECT ID, post_title FROM $wpdb->posts
307
- WHERE post_type=%s AND post_status<>%s",
308
- $type, 'auto-draft'
309
- ), OBJECT_K );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
 
311
  foreach ( $items as $temp_post ) {
312
  if ( !isset( $_titles[$temp_post]->post_title ) ) {
313
  continue;
314
  }
315
- $options[] = array(
316
- '#title' => $_titles[$temp_post]->post_title,
317
- '#value' => $temp_post,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  );
319
  }
320
 
@@ -339,7 +391,7 @@ function wpcf_pr_admin_post_meta_box_belongs_form( $post, $type, $belongs )
339
  /**
340
  * Updates belongs data.
341
  *
342
- * @param type $post_id
343
  * @param array $data $post_type => $post_id
344
  * @return string
345
  */
@@ -414,13 +466,13 @@ function wpcf_pr_admin_has_pagination( $post, $post_type, $page, $prev, $next,
414
  $link = '';
415
  $add = '';
416
  if ( isset( $_GET['sort'] ) ) {
417
- $add .= '&sort=' . $_GET['sort'];
418
  }
419
  if ( isset( $_GET['field'] ) ) {
420
- $add .= '&field=' . $_GET['field'];
421
  }
422
  if ( isset( $_GET['post_type_sort_parent'] ) ) {
423
- $add .= '&post_type_sort_parent=' . $_GET['post_type_sort_parent'];
424
  }
425
 
426
  /**
2
  /*
3
  * Post relationship code.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/post-relationship.php $
6
+ * $LastChangedDate: 2015-04-01 14:15:17 +0000 (Wed, 01 Apr 2015) $
7
+ * $LastChangedRevision: 1125405 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
 
 
11
  add_action( 'wpcf_admin_post_init', 'wpcf_pr_admin_post_init_action', 10, 4 );
12
  add_action( 'save_post', 'wpcf_pr_admin_save_post_hook', 20, 2 ); // Trigger afer main hook
13
 
137
  _e( 'You will be able to manage child posts after saving this post.', 'wpcf' );
138
  } else {
139
  _e( 'You will be able to add parent posts after saving this post.', 'wpcf' );
 
140
  }
141
  }
142
  }
255
  /**
256
  * AJAX delete child item call.
257
  *
258
+ * @param int $post_id
259
  * @return string
260
  */
261
  function wpcf_pr_admin_delete_child_item( $post_id ) {
263
  return __( 'Post deleted', 'wpcf' );
264
  }
265
 
266
+ /**
267
+ *
268
+ * Belongs form helper to build correct SQL string to prepare.
269
+ *
270
+ * Belongs form helper to build correct SQL string to $wpdb->prepare - replace
271
+ * any item by digital placeholder.
272
+ *
273
+ * @param any $item
274
+ * @return string
275
+ *
276
+ */
277
+ function wpcf_pr_admin_post_meta_box_belongs_form_items_helper( $item )
278
+ {
279
+ return '%d';
280
+ }
281
+
282
  /**
283
  * Belongs form.
284
  *
314
  if ( empty( $items ) ) {
315
  return array();
316
  }
317
+ /**
318
+ * Filter array of parent objects.
319
+ *
320
+ * Allow to change array of parent objects, modyfiy titles, remove
321
+ * or add some data from list of avaiable post parents.
322
+ *
323
+ * @since 1.6.6
324
+ *
325
+ * @param array $args {
326
+ * Array of objects with all possible parents
327
+ *
328
+ * @param int $ID Post ID
329
+ * @param string $type Post title.
330
+ * }
331
+ * @param string $type Post Type of parent.
332
+ */
333
+ $_titles = apply_filters(
334
+ 'wpcf_pr_belongs_items',
335
+ $wpdb->get_results(
336
+ $wpdb->prepare(
337
+ sprintf(
338
+ 'SELECT ID, post_title FROM %s WHERE ID IN (%s)',
339
+ $wpdb->posts,
340
+ implode(', ', array_map( 'wpcf_pr_admin_post_meta_box_belongs_form_items_helper', $items))
341
+ ),
342
+ $items
343
+ ),
344
+ OBJECT_K
345
+ ),
346
+ $type
347
+ );
348
 
349
  foreach ( $items as $temp_post ) {
350
  if ( !isset( $_titles[$temp_post]->post_title ) ) {
351
  continue;
352
  }
353
+ /**
354
+ * Filter single parent data
355
+ *
356
+ * Allow change singla parent data.
357
+ *
358
+ * @since 1.6.6
359
+ *
360
+ * @param array $args Single parent title and id
361
+ * @param string $type Post Type of parent.
362
+ */
363
+ $options[] = apply_filters(
364
+ 'wpcf_pr_belongs_item',
365
+ array(
366
+ '#title' => $_titles[$temp_post]->post_title,
367
+ '#value' => $temp_post,
368
+ ),
369
+ $type
370
  );
371
  }
372
 
391
  /**
392
  * Updates belongs data.
393
  *
394
+ * @param int $post_id
395
  * @param array $data $post_type => $post_id
396
  * @return string
397
  */
466
  $link = '';
467
  $add = '';
468
  if ( isset( $_GET['sort'] ) ) {
469
+ $add .= '&sort=' . sanitize_text_field( $_GET['sort'] );
470
  }
471
  if ( isset( $_GET['field'] ) ) {
472
+ $add .= '&field=' . sanitize_text_field( $_GET['field'] );
473
  }
474
  if ( isset( $_GET['post_type_sort_parent'] ) ) {
475
+ $add .= '&post_type_sort_parent=' . sanitize_text_field( $_GET['post_type_sort_parent'] );
476
  }
477
 
478
  /**
embedded/includes/relationship/child-table.php CHANGED
@@ -15,7 +15,11 @@
15
 
16
  <!--TITLE-->
17
  <div class="wpcf-pr-has-title"><?php echo $this->child_post_type_object->label; ?></div>
18
-
 
 
 
 
19
  <!--BUTTONS-->
20
 
21
  <!--SAVE ALL-->
@@ -118,4 +122,4 @@ echo admin_url( 'admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=pr_save_all'
118
  <!--PAGINATION BOTTOM-->
119
  <div class="wpcf-pagination-boottom"><?php echo $this->pagination_bottom; ?></div>
120
  <hr />
121
- </div>
15
 
16
  <!--TITLE-->
17
  <div class="wpcf-pr-has-title"><?php echo $this->child_post_type_object->label; ?></div>
18
+ <?php
19
+ if ( isset($this->child_post_type_object->description) && $this->child_post_type_object->description ) {
20
+ echo wpautop($this->child_post_type_object->description);
21
+ }
22
+ ?>
23
  <!--BUTTONS-->
24
 
25
  <!--SAVE ALL-->
122
  <!--PAGINATION BOTTOM-->
123
  <div class="wpcf-pagination-boottom"><?php echo $this->pagination_bottom; ?></div>
124
  <hr />
125
+ </div>
embedded/includes/usermeta-add-user.php CHANGED
@@ -4,7 +4,6 @@
4
  * Included on add_action('load-user-new.php') hook.
5
  */
6
  add_action( 'in_admin_footer', 'wpcf_usermeta_add_user_templates' );
7
- // if ( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], array('createuser') ) ) {
8
  add_action( 'user_register', 'wpcf_usermets_add_user_submit' );
9
 
10
  /**
@@ -43,4 +42,4 @@ function wpcf_usermeta_add_user_screen_init() {
43
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
44
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
45
  remove_action( 'admin_footer', 'wpcf_admin_profile_js_validation' );
46
- }
4
  * Included on add_action('load-user-new.php') hook.
5
  */
6
  add_action( 'in_admin_footer', 'wpcf_usermeta_add_user_templates' );
 
7
  add_action( 'user_register', 'wpcf_usermets_add_user_submit' );
8
 
9
  /**
42
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
43
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
44
  remove_action( 'admin_footer', 'wpcf_admin_profile_js_validation' );
45
+ }
embedded/includes/usermeta-post.php CHANGED
@@ -98,6 +98,7 @@ function wpcf_admin_userprofile_init($user_id){
98
  if ( isset( $config['validation']['required'] ) ) {
99
  $config['title'] .= '&#42;';
100
  }
 
101
  $output .= '
102
  <div class="wpcf-profile-field-line">
103
  <div class="wpcf-profile-line-left">
98
  if ( isset( $config['validation']['required'] ) ) {
99
  $config['title'] .= '&#42;';
100
  }
101
+ $config['_title'] = $config['title'];
102
  $output .= '
103
  <div class="wpcf-profile-field-line">
104
  <div class="wpcf-profile-line-left">
embedded/includes/usermeta.php CHANGED
@@ -5,10 +5,9 @@ define("WORKINGTYPE", "usermeta");
5
 
6
  /**
7
  * Saves group's user roles.
8
- *
9
- * @global type $wpdb
10
  * @param type $group_id
11
- * @param type $post_types
12
  */
13
  function wpcf_admin_fields_save_group_showfor($group_id, $post_types) {
14
  if (empty($post_types)) {
@@ -23,16 +22,15 @@ function wpcf_admin_fields_save_group_showfor($group_id, $post_types) {
23
 
24
  /**
25
  * Gets user roles supported by specific group.
26
- *
27
- * @global type $wpdb
28
  * @param type $group_id
29
- * @return type
30
  */
31
  function wpcf_admin_get_groups_showfor_by_group($group_id) {
32
  $for_users = get_post_meta($group_id, '_wp_types_group_showfor', true);
33
- if ($for_users == 'all') {
34
  return array();
35
  }
36
  $for_users = explode(',', trim($for_users, ','));
37
  return $for_users;
38
- }
5
 
6
  /**
7
  * Saves group's user roles.
8
+ *
 
9
  * @param type $group_id
10
+ * @param type $post_types
11
  */
12
  function wpcf_admin_fields_save_group_showfor($group_id, $post_types) {
13
  if (empty($post_types)) {
22
 
23
  /**
24
  * Gets user roles supported by specific group.
25
+ *
 
26
  * @param type $group_id
27
+ * @return type
28
  */
29
  function wpcf_admin_get_groups_showfor_by_group($group_id) {
30
  $for_users = get_post_meta($group_id, '_wp_types_group_showfor', true);
31
+ if (empty($for_users) || $for_users == 'all') {
32
  return array();
33
  }
34
  $for_users = explode(',', trim($for_users, ','));
35
  return $for_users;
36
+ }
embedded/includes/wpml.php CHANGED
@@ -1,16 +1,16 @@
1
  <?php
2
  /*
3
  * @since Types 1.2
4
- *
5
  * All WPML specific functions should be moved here.
6
- *
7
  * Mind wpml_action parameter for field.
8
  * Values:
9
  * 0 nothing (ignore), 1 copy, 2 translate
10
  *
11
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/includes/wpml.php $
12
- * $LastChangedDate: 2015-01-28 06:42:34 +0000 (Wed, 28 Jan 2015) $
13
- * $LastChangedRevision: 1077234 $
14
  * $LastChangedBy: iworks $
15
  *
16
  */
@@ -33,7 +33,7 @@ if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
33
  add_filter( 'types_taxonomy', 'wpcf_wpml_taxonomy_translate', 10, 3 );
34
 
35
  /*
36
- *
37
  * Filter terms used when:
38
  * - Displaying Group form
39
  * - Filtering Group on post edit screen
@@ -73,7 +73,7 @@ if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
73
  'wpcf_wpml_sync_postmeta_hook_add', 10, 2 );
74
  add_action( 'wpcf_postmeta_after_add_repetitive',
75
  'wpcf_wpml_sync_postmeta_hook_add', 10, 2 );
76
-
77
  // Fix to set correct parent and children for duplicated posts
78
  add_action( 'icl_make_duplicate', 'wpcf_wpml_duplicated_post_relationships',
79
  20, 4);
@@ -81,7 +81,7 @@ if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
81
 
82
  /**
83
  * Adds wpml_action property.
84
- *
85
  * @param type $fields
86
  * @return array
87
  */
@@ -94,7 +94,7 @@ function wpcf_wpml_fields_filter( $fields ) {
94
 
95
  /**
96
  * Adds wpml_action property.
97
- *
98
  * @global type $iclTranslationManagement
99
  * @param type $field
100
  * @return array
@@ -129,7 +129,7 @@ function wpcf_wpml_field_filter( $field ) {
129
 
130
  /**
131
  * Returns WPML action by field type.
132
- *
133
  * @param type $type
134
  * @return type
135
  */
@@ -151,10 +151,10 @@ function wpcf_wpml_init() {
151
 
152
  /**
153
  * WPML translate call.
154
- *
155
  * @param type $name
156
  * @param type $string
157
- * @return type
158
  */
159
  function wpcf_translate( $name, $string, $context = 'plugin Types' ) {
160
  if ( !function_exists( 'icl_t' ) || !is_string($string) || empty($string) ) {
@@ -165,10 +165,10 @@ function wpcf_translate( $name, $string, $context = 'plugin Types' ) {
165
 
166
  /**
167
  * Registers WPML translation string.
168
- *
169
  * @param type $context
170
  * @param type $name
171
- * @param type $value
172
  */
173
  function wpcf_translate_register_string( $context, $name, $value,
174
  $allow_empty_value = false ) {
@@ -180,7 +180,7 @@ function wpcf_translate_register_string( $context, $name, $value,
180
 
181
  /**
182
  * Relationship filter get_children query.
183
- *
184
  * @param type $_query string for get_posts()
185
  * @param type $parent Parent
186
  * @param type $post_type Children post type
@@ -202,9 +202,9 @@ function wpcf_wpml_relationship_get_children_query( $query, $parent, $post_type,
202
 
203
  /**
204
  * WPML editor filter
205
- *
206
  * @param type $cf_name
207
- * @return type
208
  */
209
  function wpcf_icl_editor_cf_name_filter( $cf_name ) {
210
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
@@ -225,10 +225,10 @@ function wpcf_icl_editor_cf_name_filter( $cf_name ) {
225
 
226
  /**
227
  * WPML editor filter
228
- *
229
  * @param type $cf_name
230
  * @param type $description
231
- * @return type
232
  */
233
  function wpcf_icl_editor_cf_description_filter( $description, $cf_name ) {
234
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
@@ -250,10 +250,10 @@ function wpcf_icl_editor_cf_description_filter( $description, $cf_name ) {
250
 
251
  /**
252
  * WPML editor filter
253
- *
254
  * @param type $cf_name
255
  * @param type $style
256
- * @return type
257
  */
258
  function wpcf_icl_editor_cf_style_filter( $style, $cf_name ) {
259
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
@@ -278,7 +278,7 @@ function wpcf_icl_editor_cf_style_filter( $style, $cf_name ) {
278
  }
279
 
280
  /**
281
- * Bulk translation.
282
  */
283
  function wpcf_admin_bulk_string_translation() {
284
  if ( !function_exists( 'icl_register_string' ) ) {
@@ -412,9 +412,11 @@ function wpcf_post_relationship_set_translated_children( $parent_post_id ) {
412
 
413
  global $wpdb;
414
 
415
- $query = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key= %s AND meta_value= %d";
416
- $original_children = $wpdb->get_col( $wpdb->prepare( $query,
417
- $meta_key, $original_post_id ) );
 
 
418
 
419
  foreach ( $original_children as $child_id ) {
420
 
@@ -483,13 +485,13 @@ function wpcf_post_relationship_set_translated_parent( $child_post_id ) {
483
 
484
  /**
485
  * Returns translated '_wpcf_belongs_XXX_id' if any.
486
- *
487
  * @global type $sitepress
488
  * @param type $value
489
  * @param type $object_id
490
  * @param type $meta_key
491
  * @param type $single
492
- * @return type
493
  */
494
  function wpcf_wpml_relationship_meta_belongs_filter( $value, $object_id,
495
  $meta_key, $single ) {
@@ -520,7 +522,7 @@ function wpcf_wpml_relationship_meta_belongs_filter( $value, $object_id,
520
  } else {
521
  $value = array($meta_translated_id);
522
  }
523
-
524
  }
525
  }
526
  }
@@ -532,7 +534,7 @@ function wpcf_wpml_relationship_meta_belongs_filter( $value, $object_id,
532
 
533
  /**
534
  * Adjust translated IDs.
535
- *
536
  * @global type $sitepress
537
  * @param type $parent_post_id
538
  */
@@ -584,9 +586,9 @@ function wpcf_wpml_relationship_save_post_hook( $parent_post_id ){
584
 
585
  /**
586
  * Registers translation data.
587
- *
588
  * @param type $post_type
589
- * @param type $data
590
  */
591
  function wpcf_custom_types_register_translation( $post_type, $data ) {
592
  if ( !function_exists( 'icl_register_string' ) ) {
@@ -601,9 +603,9 @@ function wpcf_custom_types_register_translation( $post_type, $data ) {
601
 
602
  /**
603
  * Registers translation data.
604
- *
605
  * @param type $post_type
606
- * @param type $data
607
  */
608
  function wpcf_custom_taxonimies_register_translation( $taxonomy, $data ) {
609
  if ( !function_exists( 'icl_register_string' ) ) {
@@ -618,7 +620,7 @@ function wpcf_custom_taxonimies_register_translation( $taxonomy, $data ) {
618
 
619
  /**
620
  * Registers labels.
621
- *
622
  * @param type $prefix
623
  * @param type $data
624
  * @param type $context
@@ -668,9 +670,9 @@ function wpcf_wpml_register_labels( $prefix, $data, $context = 'post' ) {
668
 
669
  /**
670
  * Translates data.
671
- *
672
  * @param type $post_type
673
- * @param type $data
674
  */
675
  function wpcf_wpml_post_types_translate( $data, $post_type ) {
676
  if ( !function_exists( 'icl_t' ) ) {
@@ -700,9 +702,9 @@ function wpcf_wpml_post_types_translate( $data, $post_type ) {
700
 
701
  /**
702
  * Translates data.
703
- *
704
  * @param type $taxonomy
705
- * @param type $data
706
  */
707
  function wpcf_wpml_taxonomy_translate( $data, $taxonomy ) {
708
  if ( !function_exists( 'icl_t' ) ) {
@@ -732,10 +734,10 @@ function wpcf_wpml_taxonomy_translate( $data, $taxonomy ) {
732
 
733
  /**
734
  * Filters terms on Group form filter.
735
- *
736
  * Do not complicate this, just replace term ID
737
  * with corresponding original ID.
738
- *
739
  * @param array $terms array of terms objects.
740
  * @return array
741
  */
@@ -758,7 +760,7 @@ function wpcf_wpml_group_form_filter_terms_filter( $terms ) {
758
  // Only if translation found
759
  if ( $term->term_id != $original_term_id ) {
760
  /*
761
- *
762
  * Note that WPML will return term_id.
763
  */
764
  $_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %d LIMIT 1",
@@ -791,9 +793,9 @@ function wpcf_wpml_group_form_filter_terms_filter( $terms ) {
791
 
792
  /**
793
  * Adjusts term_id in group filter in post edit screen.
794
- *
795
  * @global type $sitepress
796
- * @global type $wpdb
797
  * @param type $group
798
  * @return type
799
  */
@@ -844,11 +846,11 @@ function wpcf_wpml_post_group_filter_taxonomies( $group, $post, $context,
844
 
845
  /**
846
  * Append missing terms from saved filter.
847
- *
848
  * If terms are added in another language and still valid,
849
  * append them as 'hidden' fields. That way we keep terms in sync if swithing
850
  * languages in admin area.
851
- *
852
  * @global type $wpcf
853
  * @param type $form
854
  * @param type $settings
@@ -870,7 +872,7 @@ function wpcf_wpml_group_filter_add_missing_terms( $form, $settings ) {
870
  }
871
  /*
872
  * Check if term is filtered out, but existing in saved option
873
- * and if it's not translated already.
874
  */
875
  if ( !isset( $wpcf->wpml->group_form_filter_taxonomies_filtered[$term_taxonomy_id] ) ) {
876
  $_add = true;
@@ -904,7 +906,7 @@ function wpcf_wpml_group_filter_add_missing_terms( $form, $settings ) {
904
 
905
  /**
906
  * Sync when slug changed.
907
- *
908
  * @global type $sitepress
909
  * @global type $sitepress_settings
910
  * @param type $new_slug
@@ -934,7 +936,7 @@ function wpcf_wpml_post_type_renamed( $new_slug, $old_slug ) {
934
 
935
  /**
936
  * Sync when slug changed.
937
- *
938
  * @global type $sitepress
939
  * @global type $sitepress_settings
940
  * @param type $new_slug
@@ -960,7 +962,7 @@ function wpcf_wpml_taxonomy_renamed( $new_slug, $old_slug ) {
960
 
961
  /**
962
  * Relationship save child language.
963
- *
964
  * @global type $sitepress
965
  * @param type $child
966
  * @param type $parent
@@ -977,7 +979,7 @@ function wpcf_wpml_relationship_save_child( $child, $parent ) {
977
 
978
  /**
979
  * Checks if field is copied on post edit screen.
980
- *
981
  * @global type $sitepress
982
  * @param type $field
983
  * @param type $post
@@ -994,7 +996,7 @@ function wpcf_wpml_field_is_copied( $field, $post = null ) {
994
 
995
  /**
996
  * Checks if field is copied on profile edit screen.
997
- *
998
  * @global type $sitepress
999
  * @param type $field
1000
  * @return boolean
@@ -1011,7 +1013,7 @@ function wpcf_wpml_is_translated_profile_page( $field ) {
1011
 
1012
  /**
1013
  * Checks if field is copied.
1014
- *
1015
  * @param type $field
1016
  * @return type
1017
  */
@@ -1022,7 +1024,7 @@ function wpcf_wpml_field_is_copy( $field ) {
1022
 
1023
  /**
1024
  * Checks if field is translated.
1025
- *
1026
  * @param type $field
1027
  * @return type
1028
  */
@@ -1033,7 +1035,7 @@ function wpcf_wpml_field_is_translated( $field ) {
1033
 
1034
  /**
1035
  * Checks if field is ignored.
1036
- *
1037
  * @param type $field
1038
  * @return type
1039
  */
@@ -1044,7 +1046,7 @@ function wpcf_wpml_field_is_ignored( $field ) {
1044
 
1045
  /**
1046
  * Determine if post is in original language.
1047
- *
1048
  * @global type $sitepress
1049
  * @global type $pagenow
1050
  * @param type $field
@@ -1057,7 +1059,7 @@ function wpcf_wpml_post_is_original( $post = null ) {
1057
  // WPML There is no lang on new post
1058
  if ( $pagenow == 'post-new.php' ) {
1059
  $post_type = wpcf_admin_get_edited_post_type();
1060
- $current_lang = isset( $_GET['lang'] ) ? $_GET['lang'] : $sitepress->get_current_language();
1061
  if ( in_array( $post_type,
1062
  array_keys( $sitepress->get_translatable_documents() ) ) ) {
1063
  return $sitepress->get_default_language() == $current_lang;
@@ -1089,12 +1091,12 @@ function wpcf_wpml_have_original( $post = null ) {
1089
  static $cache = array();
1090
  global $pagenow;
1091
  $res = false;
1092
-
1093
  // WPML There is no lang on new post
1094
  if ( $pagenow == 'post-new.php' ) {
1095
  return isset( $_GET['trid'] );
1096
  }
1097
-
1098
  if ( empty( $post->ID ) ) {
1099
  $post = wpcf_admin_get_edited_post();
1100
  }
@@ -1107,11 +1109,17 @@ function wpcf_wpml_have_original( $post = null ) {
1107
  $post_lang = $sitepress->get_element_language_details( $post->ID,
1108
  'post_' . $post->post_type );
1109
  if ( isset( $post_lang->language_code ) ) {
1110
- $sql = "SELECT trid FROM {$wpdb->prefix}icl_translations
1111
- WHERE language_code = '{$post_lang->language_code}'
1112
- AND element_id = {$post->ID}
1113
- AND element_type = 'post_{$post->post_type}'
1114
- AND source_language_code IS NOT NULL";
 
 
 
 
 
 
1115
  $res = (bool) $wpdb->get_var( $sql );
1116
  }
1117
  $cache[$cache_key] = $res;
@@ -1121,7 +1129,7 @@ function wpcf_wpml_have_original( $post = null ) {
1121
 
1122
  /**
1123
  * Removes temporarily hook to avoid deleting custom fields from translated post.
1124
- *
1125
  * @global type $sitepress
1126
  * @param type $post
1127
  * @param type $field
@@ -1135,7 +1143,7 @@ function wpcf_wpml_remove_delete_postmeta_hook_remove( $post, $field ) {
1135
 
1136
  /**
1137
  * Re-enables hook.
1138
- *
1139
  * @see wpcf_wpml_remove_delete_postmeta_hook_remove()
1140
  * @global type $sitepress
1141
  * @param type $post
@@ -1150,7 +1158,7 @@ function wpcf_wpml_remove_delete_postmeta_hook_add( $post, $field ) {
1150
 
1151
  /**
1152
  * Removes temporarily hook to fix asving repetitive fields.
1153
- *
1154
  * @global type $sitepress
1155
  * @param type $post
1156
  * @param type $field
@@ -1169,7 +1177,7 @@ function wpcf_wpml_sync_postmeta_hook_remove( $post, $field ) {
1169
 
1170
  /**
1171
  * Re-enables hook.
1172
- *
1173
  * @see wpcf_wpml_remove_delete_postmeta_hook_remove()
1174
  * @global type $sitepress
1175
  * @param type $post
@@ -1194,7 +1202,7 @@ function wpcf_wpml_warnings_init()
1194
  * check is configuration done?!
1195
  */
1196
  global $sitepress, $sitepress_settings;
1197
- if ( icl_get_setting('st') ) {
1198
  return;
1199
  }
1200
 
1
  <?php
2
  /*
3
  * @since Types 1.2
4
+ *
5
  * All WPML specific functions should be moved here.
6
+ *
7
  * Mind wpml_action parameter for field.
8
  * Values:
9
  * 0 nothing (ignore), 1 copy, 2 translate
10
  *
11
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/includes/wpml.php $
12
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
13
+ * $LastChangedRevision: 1120400 $
14
  * $LastChangedBy: iworks $
15
  *
16
  */
33
  add_filter( 'types_taxonomy', 'wpcf_wpml_taxonomy_translate', 10, 3 );
34
 
35
  /*
36
+ *
37
  * Filter terms used when:
38
  * - Displaying Group form
39
  * - Filtering Group on post edit screen
73
  'wpcf_wpml_sync_postmeta_hook_add', 10, 2 );
74
  add_action( 'wpcf_postmeta_after_add_repetitive',
75
  'wpcf_wpml_sync_postmeta_hook_add', 10, 2 );
76
+
77
  // Fix to set correct parent and children for duplicated posts
78
  add_action( 'icl_make_duplicate', 'wpcf_wpml_duplicated_post_relationships',
79
  20, 4);
81
 
82
  /**
83
  * Adds wpml_action property.
84
+ *
85
  * @param type $fields
86
  * @return array
87
  */
94
 
95
  /**
96
  * Adds wpml_action property.
97
+ *
98
  * @global type $iclTranslationManagement
99
  * @param type $field
100
  * @return array
129
 
130
  /**
131
  * Returns WPML action by field type.
132
+ *
133
  * @param type $type
134
  * @return type
135
  */
151
 
152
  /**
153
  * WPML translate call.
154
+ *
155
  * @param type $name
156
  * @param type $string
157
+ * @return type
158
  */
159
  function wpcf_translate( $name, $string, $context = 'plugin Types' ) {
160
  if ( !function_exists( 'icl_t' ) || !is_string($string) || empty($string) ) {
165
 
166
  /**
167
  * Registers WPML translation string.
168
+ *
169
  * @param type $context
170
  * @param type $name
171
+ * @param type $value
172
  */
173
  function wpcf_translate_register_string( $context, $name, $value,
174
  $allow_empty_value = false ) {
180
 
181
  /**
182
  * Relationship filter get_children query.
183
+ *
184
  * @param type $_query string for get_posts()
185
  * @param type $parent Parent
186
  * @param type $post_type Children post type
202
 
203
  /**
204
  * WPML editor filter
205
+ *
206
  * @param type $cf_name
207
+ * @return type
208
  */
209
  function wpcf_icl_editor_cf_name_filter( $cf_name ) {
210
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
225
 
226
  /**
227
  * WPML editor filter
228
+ *
229
  * @param type $cf_name
230
  * @param type $description
231
+ * @return type
232
  */
233
  function wpcf_icl_editor_cf_description_filter( $description, $cf_name ) {
234
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
250
 
251
  /**
252
  * WPML editor filter
253
+ *
254
  * @param type $cf_name
255
  * @param type $style
256
+ * @return type
257
  */
258
  function wpcf_icl_editor_cf_style_filter( $style, $cf_name ) {
259
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
278
  }
279
 
280
  /**
281
+ * Bulk translation.
282
  */
283
  function wpcf_admin_bulk_string_translation() {
284
  if ( !function_exists( 'icl_register_string' ) ) {
412
 
413
  global $wpdb;
414
 
415
+ $query = sprintf(
416
+ 'SELECT post_id FROM %s WHERE meta_key= %%s AND meta_value= %%d',
417
+ $wpdb->postmeta
418
+ );
419
+ $original_children = $wpdb->get_col( $wpdb->prepare( $query, $meta_key, $original_post_id ) );
420
 
421
  foreach ( $original_children as $child_id ) {
422
 
485
 
486
  /**
487
  * Returns translated '_wpcf_belongs_XXX_id' if any.
488
+ *
489
  * @global type $sitepress
490
  * @param type $value
491
  * @param type $object_id
492
  * @param type $meta_key
493
  * @param type $single
494
+ * @return type
495
  */
496
  function wpcf_wpml_relationship_meta_belongs_filter( $value, $object_id,
497
  $meta_key, $single ) {
522
  } else {
523
  $value = array($meta_translated_id);
524
  }
525
+
526
  }
527
  }
528
  }
534
 
535
  /**
536
  * Adjust translated IDs.
537
+ *
538
  * @global type $sitepress
539
  * @param type $parent_post_id
540
  */
586
 
587
  /**
588
  * Registers translation data.
589
+ *
590
  * @param type $post_type
591
+ * @param type $data
592
  */
593
  function wpcf_custom_types_register_translation( $post_type, $data ) {
594
  if ( !function_exists( 'icl_register_string' ) ) {
603
 
604
  /**
605
  * Registers translation data.
606
+ *
607
  * @param type $post_type
608
+ * @param type $data
609
  */
610
  function wpcf_custom_taxonimies_register_translation( $taxonomy, $data ) {
611
  if ( !function_exists( 'icl_register_string' ) ) {
620
 
621
  /**
622
  * Registers labels.
623
+ *
624
  * @param type $prefix
625
  * @param type $data
626
  * @param type $context
670
 
671
  /**
672
  * Translates data.
673
+ *
674
  * @param type $post_type
675
+ * @param type $data
676
  */
677
  function wpcf_wpml_post_types_translate( $data, $post_type ) {
678
  if ( !function_exists( 'icl_t' ) ) {
702
 
703
  /**
704
  * Translates data.
705
+ *
706
  * @param type $taxonomy
707
+ * @param type $data
708
  */
709
  function wpcf_wpml_taxonomy_translate( $data, $taxonomy ) {
710
  if ( !function_exists( 'icl_t' ) ) {
734
 
735
  /**
736
  * Filters terms on Group form filter.
737
+ *
738
  * Do not complicate this, just replace term ID
739
  * with corresponding original ID.
740
+ *
741
  * @param array $terms array of terms objects.
742
  * @return array
743
  */
760
  // Only if translation found
761
  if ( $term->term_id != $original_term_id ) {
762
  /*
763
+ *
764
  * Note that WPML will return term_id.
765
  */
766
  $_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %d LIMIT 1",
793
 
794
  /**
795
  * Adjusts term_id in group filter in post edit screen.
796
+ *
797
  * @global type $sitepress
798
+ * @global object $wpdb
799
  * @param type $group
800
  * @return type
801
  */
846
 
847
  /**
848
  * Append missing terms from saved filter.
849
+ *
850
  * If terms are added in another language and still valid,
851
  * append them as 'hidden' fields. That way we keep terms in sync if swithing
852
  * languages in admin area.
853
+ *
854
  * @global type $wpcf
855
  * @param type $form
856
  * @param type $settings
872
  }
873
  /*
874
  * Check if term is filtered out, but existing in saved option
875
+ * and if it's not translated already.
876
  */
877
  if ( !isset( $wpcf->wpml->group_form_filter_taxonomies_filtered[$term_taxonomy_id] ) ) {
878
  $_add = true;
906
 
907
  /**
908
  * Sync when slug changed.
909
+ *
910
  * @global type $sitepress
911
  * @global type $sitepress_settings
912
  * @param type $new_slug
936
 
937
  /**
938
  * Sync when slug changed.
939
+ *
940
  * @global type $sitepress
941
  * @global type $sitepress_settings
942
  * @param type $new_slug
962
 
963
  /**
964
  * Relationship save child language.
965
+ *
966
  * @global type $sitepress
967
  * @param type $child
968
  * @param type $parent
979
 
980
  /**
981
  * Checks if field is copied on post edit screen.
982
+ *
983
  * @global type $sitepress
984
  * @param type $field
985
  * @param type $post
996
 
997
  /**
998
  * Checks if field is copied on profile edit screen.
999
+ *
1000
  * @global type $sitepress
1001
  * @param type $field
1002
  * @return boolean
1013
 
1014
  /**
1015
  * Checks if field is copied.
1016
+ *
1017
  * @param type $field
1018
  * @return type
1019
  */
1024
 
1025
  /**
1026
  * Checks if field is translated.
1027
+ *
1028
  * @param type $field
1029
  * @return type
1030
  */
1035
 
1036
  /**
1037
  * Checks if field is ignored.
1038
+ *
1039
  * @param type $field
1040
  * @return type
1041
  */
1046
 
1047
  /**
1048
  * Determine if post is in original language.
1049
+ *
1050
  * @global type $sitepress
1051
  * @global type $pagenow
1052
  * @param type $field
1059
  // WPML There is no lang on new post
1060
  if ( $pagenow == 'post-new.php' ) {
1061
  $post_type = wpcf_admin_get_edited_post_type();
1062
+ $current_lang = isset( $_GET['lang'] ) ? sanitize_text_field( $_GET['lang'] ) : $sitepress->get_current_language();
1063
  if ( in_array( $post_type,
1064
  array_keys( $sitepress->get_translatable_documents() ) ) ) {
1065
  return $sitepress->get_default_language() == $current_lang;
1091
  static $cache = array();
1092
  global $pagenow;
1093
  $res = false;
1094
+
1095
  // WPML There is no lang on new post
1096
  if ( $pagenow == 'post-new.php' ) {
1097
  return isset( $_GET['trid'] );
1098
  }
1099
+
1100
  if ( empty( $post->ID ) ) {
1101
  $post = wpcf_admin_get_edited_post();
1102
  }
1109
  $post_lang = $sitepress->get_element_language_details( $post->ID,
1110
  'post_' . $post->post_type );
1111
  if ( isset( $post_lang->language_code ) ) {
1112
+
1113
+ $sql = $wpdb->prepare(
1114
+ "SELECT trid FROM {$wpdb->prefix}icl_translations
1115
+ WHERE language_code = %s
1116
+ AND element_id = %d
1117
+ AND element_type = %s
1118
+ AND source_language_code IS NOT NULL",
1119
+ $post_lang->language_code,
1120
+ $post->ID,
1121
+ sprintf('post_%s', $post->post_type)
1122
+ );
1123
  $res = (bool) $wpdb->get_var( $sql );
1124
  }
1125
  $cache[$cache_key] = $res;
1129
 
1130
  /**
1131
  * Removes temporarily hook to avoid deleting custom fields from translated post.
1132
+ *
1133
  * @global type $sitepress
1134
  * @param type $post
1135
  * @param type $field
1143
 
1144
  /**
1145
  * Re-enables hook.
1146
+ *
1147
  * @see wpcf_wpml_remove_delete_postmeta_hook_remove()
1148
  * @global type $sitepress
1149
  * @param type $post
1158
 
1159
  /**
1160
  * Removes temporarily hook to fix asving repetitive fields.
1161
+ *
1162
  * @global type $sitepress
1163
  * @param type $post
1164
  * @param type $field
1177
 
1178
  /**
1179
  * Re-enables hook.
1180
+ *
1181
  * @see wpcf_wpml_remove_delete_postmeta_hook_remove()
1182
  * @global type $sitepress
1183
  * @param type $post
1202
  * check is configuration done?!
1203
  */
1204
  global $sitepress, $sitepress_settings;
1205
+ if ( function_exists('icl_get_setting') && icl_get_setting('st') ) {
1206
  return;
1207
  }
1208
 
embedded/models/relationship.php CHANGED
@@ -8,8 +8,9 @@ class WPCF_Relationship_Model
8
 
9
  /**
10
  * Fetch children by post type.
11
- *
12
- * @global type $wpdb
 
13
  * @param type $post
14
  * @param type $post_type
15
  * @param string $data
@@ -17,8 +18,9 @@ class WPCF_Relationship_Model
17
  * @param array $user_query - Override default query
18
  * @return type
19
  */
20
- public static function getChildrenByPostType( $post, $post_type, $data,
21
- $params = array(), $user_query = array() ) {
 
22
  if ( empty( $post->ID ) ) {
23
  return array();
24
  }
@@ -28,15 +30,16 @@ class WPCF_Relationship_Model
28
  $items = array();
29
 
30
  // Merge with user query
31
- $query = wp_parse_args( $user_query,
32
- array(
33
- 'post_type' => $post_type,
34
- 'numberposts' => -1,
35
- 'post_status' => array('publish', 'pending', 'draft', 'future', 'private'),
36
- 'meta_key' => '_wpcf_belongs_' . $post->post_type . '_id',
37
- 'meta_value' => $post->ID,
38
- 'suppress_filters' => 0,
39
- )
 
40
  );
41
 
42
  // Cleanup data
@@ -49,9 +52,12 @@ class WPCF_Relationship_Model
49
 
50
  // Set sorting
51
  $query['order'] = esc_attr( strtoupper( strval( $params['sort'] ) ) );
 
 
 
52
 
53
  /*
54
- *
55
  * Order by title
56
  */
57
  if ( $params['field'] == '_wp_title' ) {
@@ -61,7 +67,7 @@ class WPCF_Relationship_Model
61
  esc_attr( $params['field'] ) );
62
  $items = get_posts( $query );
63
  /*
64
- *
65
  * Order by parents
66
  */
67
  } else if ( $params['field'] == '_wpcf_pr_parent' ) {
@@ -98,7 +104,7 @@ class WPCF_Relationship_Model
98
  }
99
  }
100
  /*
101
- *
102
  * Order by body
103
  */
104
  } else if ( $params['field'] == '_wp_body' ) {
@@ -107,9 +113,8 @@ class WPCF_Relationship_Model
107
  FROM $wpdb->posts p
108
  WHERE p.post_type = %s
109
  AND p.post_status NOT IN ('auto-draft', 'trash', 'inherit')
110
- ORDER BY p.post_content " . $query['order'];
111
- $sorted = $wpdb->get_results( $wpdb->prepare( $_query,
112
- $post_type ) );
113
  if ( !empty( $sorted ) ) {
114
  $query['orderby'] = 'post__in';
115
  foreach ( $sorted as $key => $value ) {
@@ -121,8 +126,8 @@ class WPCF_Relationship_Model
121
  esc_attr( $params['field'] ) );
122
  $items = get_posts( $query );
123
  /*
124
- *
125
- *
126
  * Order by custom field
127
  */
128
  } else {
@@ -175,18 +180,15 @@ class WPCF_Relationship_Model
175
  }
176
  }
177
  }
178
- /*
179
- *
180
- *
181
  * Regular
 
182
  */
183
  } else {
184
- $query = apply_filters( 'wpcf_relationship_get_children_query',
185
- $query, $post, $post_type, $data );
186
  $items = get_posts( $query );
187
  }
188
-
189
  return $items;
190
  }
191
-
192
- }
8
 
9
  /**
10
  * Fetch children by post type.
11
+ *
12
+ * @global object $wpdb
13
+ *
14
  * @param type $post
15
  * @param type $post_type
16
  * @param string $data
18
  * @param array $user_query - Override default query
19
  * @return type
20
  */
21
+ public static function getChildrenByPostType( $post, $post_type, $data, $params = array(), $user_query = array() )
22
+ {
23
+
24
  if ( empty( $post->ID ) ) {
25
  return array();
26
  }
30
  $items = array();
31
 
32
  // Merge with user query
33
+ $query = wp_parse_args(
34
+ $user_query,
35
+ array(
36
+ 'post_type' => $post_type,
37
+ 'numberposts' => -1,
38
+ 'post_status' => array('publish', 'pending', 'draft', 'future', 'private'),
39
+ 'meta_key' => '_wpcf_belongs_' . $post->post_type . '_id',
40
+ 'meta_value' => $post->ID,
41
+ 'suppress_filters' => 0,
42
+ )
43
  );
44
 
45
  // Cleanup data
52
 
53
  // Set sorting
54
  $query['order'] = esc_attr( strtoupper( strval( $params['sort'] ) ) );
55
+ if ( !preg_match('/^(A|DE)SC$/', $query['order']) ) {
56
+ $query['order'] = 'ASC';
57
+ }
58
 
59
  /*
60
+ *
61
  * Order by title
62
  */
63
  if ( $params['field'] == '_wp_title' ) {
67
  esc_attr( $params['field'] ) );
68
  $items = get_posts( $query );
69
  /*
70
+ *
71
  * Order by parents
72
  */
73
  } else if ( $params['field'] == '_wpcf_pr_parent' ) {
104
  }
105
  }
106
  /*
107
+ *
108
  * Order by body
109
  */
110
  } else if ( $params['field'] == '_wp_body' ) {
113
  FROM $wpdb->posts p
114
  WHERE p.post_type = %s
115
  AND p.post_status NOT IN ('auto-draft', 'trash', 'inherit')
116
+ ORDER BY p.post_content " . ( ( 'ASC' == $query['order'] ) ? 'ASC' : 'DESC' );
117
+ $sorted = $wpdb->get_results( $wpdb->prepare( $_query, $post_type ) );
 
118
  if ( !empty( $sorted ) ) {
119
  $query['orderby'] = 'post__in';
120
  foreach ( $sorted as $key => $value ) {
126
  esc_attr( $params['field'] ) );
127
  $items = get_posts( $query );
128
  /*
129
+ *
130
+ *
131
  * Order by custom field
132
  */
133
  } else {
180
  }
181
  }
182
  }
183
+ /**
184
+ *
 
185
  * Regular
186
+ *
187
  */
188
  } else {
189
+ $query = apply_filters( 'wpcf_relationship_get_children_query', $query, $post, $post_type, $data );
 
190
  $items = get_posts( $query );
191
  }
 
192
  return $items;
193
  }
194
+ }
 
embedded/onthego-resources/loader.php CHANGED
@@ -51,14 +51,13 @@ if( !function_exists('on_the_go_systems_branding_plugins_loaded') ) {
51
  $latest = $key;
52
  }
53
  }
54
-
55
  if ($latest > 0) {
56
  require_once $onthegosystems_branding_paths[$latest]['path'] . '/onthegosystems-branding-loader.php';
57
  ont_set_on_the_go_systems_uri_and_start( $onthegosystems_branding_paths[$latest]['url'] );
58
  }
59
  }
60
 
61
- add_action( 'plugins_loaded', 'on_the_go_systems_branding_plugins_loaded');
62
  }
63
 
64
  if( !function_exists('onthego_initialize') ) {
51
  $latest = $key;
52
  }
53
  }
 
54
  if ($latest > 0) {
55
  require_once $onthegosystems_branding_paths[$latest]['path'] . '/onthegosystems-branding-loader.php';
56
  ont_set_on_the_go_systems_uri_and_start( $onthegosystems_branding_paths[$latest]['url'] );
57
  }
58
  }
59
 
60
+ add_action( 'after_setup_theme', 'on_the_go_systems_branding_plugins_loaded');
61
  }
62
 
63
  if( !function_exists('onthego_initialize') ) {
embedded/onthego-resources/onthego-styles/onthego-admin-styles.css CHANGED
@@ -11,6 +11,7 @@ li#toplevel_page_dd_layouts div.wp-menu-image:before, li#toplevel_page_dd_layout
11
  padding-left: 3px;
12
  padding-top: 5px; }
13
 
 
14
  li#toplevel_page_views div.wp-menu-image:before {
15
  font-family: "onthegosystems-icons"!important;
16
  content: "\f11e";
@@ -59,6 +60,14 @@ li#toplevel_page_CRED_Commerce div.wp-menu-image:before {
59
  padding-left: 3px;
60
  padding-top: 3px; }
61
 
 
 
 
 
 
 
 
 
62
  /* POST EDIT PAGE SHORT TAGS BUTTONS ICONS */
63
  #wp-content-editor-tools [class^="icon-"] {
64
  color: #888;
11
  padding-left: 3px;
12
  padding-top: 5px; }
13
 
14
+ li#toplevel_page_embedded-views div.wp-menu-image:before,
15
  li#toplevel_page_views div.wp-menu-image:before {
16
  font-family: "onthegosystems-icons"!important;
17
  content: "\f11e";
60
  padding-left: 3px;
61
  padding-top: 3px; }
62
 
63
+ li#toplevel_page_toolset-packager div.wp-menu-image:before {
64
+ font-family: "onthegosystems-icons"!important;
65
+ content: "\f121";
66
+ font-size: 23px!important;
67
+ width: 30px;
68
+ padding-left: 3px;
69
+ padding-top: 3px; }
70
+
71
  /* POST EDIT PAGE SHORT TAGS BUTTONS ICONS */
72
  #wp-content-editor-tools [class^="icon-"] {
73
  color: #888;
embedded/onthego-resources/onthego-styles/onthego-colors.css CHANGED
@@ -5,7 +5,7 @@ This file is a collection of generic colors used in our styles
5
  color: #444444; }
6
 
7
  .ont-color-orange {
8
- color: #f05a29; }
9
 
10
  .ont-color-gray {
11
  color: #888; }
5
  color: #444444; }
6
 
7
  .ont-color-orange {
8
+ color: #f05a28; }
9
 
10
  .ont-color-gray {
11
  color: #888; }
embedded/onthego-resources/onthegosystems-icons/.fontcustom-manifest.json CHANGED
@@ -1,13 +1,13 @@
1
  {
2
  "checksum": {
3
- "previous": "33da83f67be9c5797490c4baa29104c1311787053a2711571308c2562fc16af7",
4
- "current": "33da83f67be9c5797490c4baa29104c1311787053a2711571308c2562fc16af7"
5
  },
6
  "fonts": [
7
- "fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.ttf",
8
- "fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.svg",
9
- "fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.woff",
10
- "fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.eot"
11
  ],
12
  "glyphs": {
13
  "access": {
@@ -50,6 +50,14 @@
50
  "codepoint": 61721,
51
  "source": "vectors/module-logo.svg"
52
  },
 
 
 
 
 
 
 
 
53
  "toolset-logo": {
54
  "codepoint": 61722,
55
  "source": "vectors/toolset-logo.svg"
@@ -72,37 +80,37 @@
72
  },
73
  "wpml-logo": {
74
  "codepoint": 61727,
75
- "source": "vectors/wpml logo.svg"
76
  }
77
  },
78
  "options": {
 
 
 
 
 
 
 
79
  "input": {
80
- "vectors": "vectors",
81
- "templates": "vectors"
82
  },
 
83
  "output": {
84
- "fonts": "fonts",
85
  "css": "css",
 
86
  "preview": "fonts"
87
  },
88
- "config": "fontcustom.yml",
89
- "templates": [
90
- "css",
91
- "scss",
92
- "preview"
93
- ],
94
- "font_name": "onthegosystems-icons",
95
- "css_selector": ".icon-{{glyph}}",
96
  "preprocessor_path": null,
97
- "autowidth": false,
98
- "no_hash": false,
99
- "debug": false,
100
- "force": false,
101
- "quiet": false,
102
  "project_root": {
103
  "pwd": null
104
  },
105
- "file_hash": false
 
 
 
 
 
106
  },
107
  "templates": [
108
  "css/onthegosystems-icons.css",
1
  {
2
  "checksum": {
3
+ "previous": "ea0d501b723f7b75d3147cf08210b5cf2c0c279dff82e74a178b3badd9bf0318",
4
+ "current": "ea0d501b723f7b75d3147cf08210b5cf2c0c279dff82e74a178b3badd9bf0318"
5
  },
6
  "fonts": [
7
+ "fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.ttf",
8
+ "fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.svg",
9
+ "fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.woff",
10
+ "fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.eot"
11
  ],
12
  "glyphs": {
13
  "access": {
50
  "codepoint": 61721,
51
  "source": "vectors/module-logo.svg"
52
  },
53
+ "packager": {
54
+ "codepoint": 61728,
55
+ "source": "vectors/packager.svg"
56
+ },
57
+ "packager-logo": {
58
+ "codepoint": 61729,
59
+ "source": "vectors/packager-logo.svg"
60
+ },
61
  "toolset-logo": {
62
  "codepoint": 61722,
63
  "source": "vectors/toolset-logo.svg"
80
  },
81
  "wpml-logo": {
82
  "codepoint": 61727,
83
+ "source": "vectors/wpml-logo.svg"
84
  }
85
  },
86
  "options": {
87
+ "autowidth": false,
88
+ "config": "fontcustom.yml",
89
+ "css_selector": ".icon-{{glyph}}",
90
+ "debug": false,
91
+ "file_hash": false,
92
+ "font_name": "onthegosystems-icons",
93
+ "force": false,
94
  "input": {
95
+ "templates": "vectors",
96
+ "vectors": "vectors"
97
  },
98
+ "no_hash": false,
99
  "output": {
 
100
  "css": "css",
101
+ "fonts": "fonts",
102
  "preview": "fonts"
103
  },
 
 
 
 
 
 
 
 
104
  "preprocessor_path": null,
 
 
 
 
 
105
  "project_root": {
106
  "pwd": null
107
  },
108
+ "quiet": false,
109
+ "templates": [
110
+ "css",
111
+ "scss",
112
+ "preview"
113
+ ]
114
  },
115
  "templates": [
116
  "css/onthegosystems-icons.css",
embedded/onthego-resources/onthegosystems-icons/css/_onthegosystems-icons.scss CHANGED
@@ -4,11 +4,11 @@
4
 
5
  @font-face {
6
  font-family: "onthegosystems-icons";
7
- src: font-url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.eot");
8
- src: font-url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.eot?#iefix") format("embedded-opentype"),
9
- font-url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.woff") format("woff"),
10
- font-url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.ttf") format("truetype"),
11
- font-url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.svg#onthegosystems-icons") format("svg");
12
  font-weight: normal;
13
  font-style: normal;
14
  }
@@ -16,7 +16,7 @@
16
  @media screen and (-webkit-min-device-pixel-ratio:0) {
17
  @font-face {
18
  font-family: "onthegosystems-icons";
19
- src: font-url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.svg#onthegosystems-icons") format("svg");
20
  }
21
  }
22
 
@@ -33,6 +33,8 @@
33
  .icon-layouts-logo:before,
34
  .icon-module:before,
35
  .icon-module-logo:before,
 
 
36
  .icon-toolset-logo:before,
37
  .icon-types:before,
38
  .icon-types-logo:before,
@@ -63,6 +65,8 @@
63
  .icon-layouts-logo:before { content: "\f117"; }
64
  .icon-module:before { content: "\f118"; }
65
  .icon-module-logo:before { content: "\f119"; }
 
 
66
  .icon-toolset-logo:before { content: "\f11a"; }
67
  .icon-types:before { content: "\f11b"; }
68
  .icon-types-logo:before { content: "\f11c"; }
4
 
5
  @font-face {
6
  font-family: "onthegosystems-icons";
7
+ src: font-url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.eot");
8
+ src: font-url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.eot?#iefix") format("embedded-opentype"),
9
+ font-url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.woff") format("woff"),
10
+ font-url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.ttf") format("truetype"),
11
+ font-url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.svg#onthegosystems-icons") format("svg");
12
  font-weight: normal;
13
  font-style: normal;
14
  }
16
  @media screen and (-webkit-min-device-pixel-ratio:0) {
17
  @font-face {
18
  font-family: "onthegosystems-icons";
19
+ src: font-url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.svg#onthegosystems-icons") format("svg");
20
  }
21
  }
22
 
33
  .icon-layouts-logo:before,
34
  .icon-module:before,
35
  .icon-module-logo:before,
36
+ .icon-packager:before,
37
+ .icon-packager-logo:before,
38
  .icon-toolset-logo:before,
39
  .icon-types:before,
40
  .icon-types-logo:before,
65
  .icon-layouts-logo:before { content: "\f117"; }
66
  .icon-module:before { content: "\f118"; }
67
  .icon-module-logo:before { content: "\f119"; }
68
+ .icon-packager:before { content: "\f120"; }
69
+ .icon-packager-logo:before { content: "\f121"; }
70
  .icon-toolset-logo:before { content: "\f11a"; }
71
  .icon-types:before { content: "\f11b"; }
72
  .icon-types-logo:before { content: "\f11c"; }
embedded/onthego-resources/onthegosystems-icons/css/onthegosystems-icons.css CHANGED
@@ -4,11 +4,11 @@
4
 
5
  @font-face {
6
  font-family: "onthegosystems-icons";
7
- src: url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.eot");
8
- src: url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.eot?#iefix") format("embedded-opentype"),
9
- url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.woff") format("woff"),
10
- url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.ttf") format("truetype"),
11
- url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.svg#onthegosystems-icons") format("svg");
12
  font-weight: normal;
13
  font-style: normal;
14
  }
@@ -16,7 +16,7 @@
16
  @media screen and (-webkit-min-device-pixel-ratio:0) {
17
  @font-face {
18
  font-family: "onthegosystems-icons";
19
- src: url("../fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.svg#onthegosystems-icons") format("svg");
20
  }
21
  }
22
 
@@ -33,6 +33,8 @@
33
  .icon-layouts-logo:before,
34
  .icon-module:before,
35
  .icon-module-logo:before,
 
 
36
  .icon-toolset-logo:before,
37
  .icon-types:before,
38
  .icon-types-logo:before,
@@ -63,6 +65,8 @@
63
  .icon-layouts-logo:before { content: "\f117"; }
64
  .icon-module:before { content: "\f118"; }
65
  .icon-module-logo:before { content: "\f119"; }
 
 
66
  .icon-toolset-logo:before { content: "\f11a"; }
67
  .icon-types:before { content: "\f11b"; }
68
  .icon-types-logo:before { content: "\f11c"; }
4
 
5
  @font-face {
6
  font-family: "onthegosystems-icons";
7
+ src: url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.eot");
8
+ src: url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.eot?#iefix") format("embedded-opentype"),
9
+ url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.woff") format("woff"),
10
+ url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.ttf") format("truetype"),
11
+ url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.svg#onthegosystems-icons") format("svg");
12
  font-weight: normal;
13
  font-style: normal;
14
  }
16
  @media screen and (-webkit-min-device-pixel-ratio:0) {
17
  @font-face {
18
  font-family: "onthegosystems-icons";
19
+ src: url("../fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.svg#onthegosystems-icons") format("svg");
20
  }
21
  }
22
 
33
  .icon-layouts-logo:before,
34
  .icon-module:before,
35
  .icon-module-logo:before,
36
+ .icon-packager:before,
37
+ .icon-packager-logo:before,
38
  .icon-toolset-logo:before,
39
  .icon-types:before,
40
  .icon-types-logo:before,
65
  .icon-layouts-logo:before { content: "\f117"; }
66
  .icon-module:before { content: "\f118"; }
67
  .icon-module-logo:before { content: "\f119"; }
68
+ .icon-packager:before { content: "\f120"; }
69
+ .icon-packager-logo:before { content: "\f121"; }
70
  .icon-toolset-logo:before { content: "\f11a"; }
71
  .icon-types:before { content: "\f11b"; }
72
  .icon-types-logo:before { content: "\f11c"; }
embedded/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons-preview.html CHANGED
@@ -141,11 +141,11 @@
141
 
142
  @font-face {
143
  font-family: "onthegosystems-icons";
144
- src: url("./onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.eot");
145
- src: url("./onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.eot?#iefix") format("embedded-opentype"),
146
- url("./onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.woff") format("woff"),
147
- url("./onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.ttf") format("truetype"),
148
- url("./onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.svg#onthegosystems-icons") format("svg");
149
  font-weight: normal;
150
  font-style: normal;
151
  }
@@ -153,7 +153,7 @@
153
  @media screen and (-webkit-min-device-pixel-ratio:0) {
154
  @font-face {
155
  font-family: "onthegosystems-icons";
156
- src: url("./onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.svg#onthegosystems-icons") format("svg");
157
  }
158
  }
159
 
@@ -170,6 +170,8 @@
170
  .icon-layouts-logo:before,
171
  .icon-module:before,
172
  .icon-module-logo:before,
 
 
173
  .icon-toolset-logo:before,
174
  .icon-types:before,
175
  .icon-types-logo:before,
@@ -200,6 +202,8 @@
200
  .icon-layouts-logo:before { content: "\f117"; }
201
  .icon-module:before { content: "\f118"; }
202
  .icon-module-logo:before { content: "\f119"; }
 
 
203
  .icon-toolset-logo:before { content: "\f11a"; }
204
  .icon-types:before { content: "\f11b"; }
205
  .icon-types-logo:before { content: "\f11c"; }
@@ -221,7 +225,7 @@
221
  <body class="characters-off">
222
  <div id="page" class="container">
223
  <header>
224
- <h1>onthegosystems-icons contains 16 glyphs:</h1>
225
  <a onclick="toggleCharacters(); return false;" href="#">Toggle Preview Characters</a>
226
  </header>
227
 
@@ -356,6 +360,32 @@
356
  </div>
357
  </div>
358
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
359
  <div class="glyph">
360
  <div class="preview-glyphs">
361
  <span class="step size-12"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-14"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-16"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-18"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-21"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-24"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-36"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-48"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-60"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-72"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span>
141
 
142
  @font-face {
143
  font-family: "onthegosystems-icons";
144
+ src: url("./onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.eot");
145
+ src: url("./onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.eot?#iefix") format("embedded-opentype"),
146
+ url("./onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.woff") format("woff"),
147
+ url("./onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.ttf") format("truetype"),
148
+ url("./onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.svg#onthegosystems-icons") format("svg");
149
  font-weight: normal;
150
  font-style: normal;
151
  }
153
  @media screen and (-webkit-min-device-pixel-ratio:0) {
154
  @font-face {
155
  font-family: "onthegosystems-icons";
156
+ src: url("./onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.svg#onthegosystems-icons") format("svg");
157
  }
158
  }
159
 
170
  .icon-layouts-logo:before,
171
  .icon-module:before,
172
  .icon-module-logo:before,
173
+ .icon-packager:before,
174
+ .icon-packager-logo:before,
175
  .icon-toolset-logo:before,
176
  .icon-types:before,
177
  .icon-types-logo:before,
202
  .icon-layouts-logo:before { content: "\f117"; }
203
  .icon-module:before { content: "\f118"; }
204
  .icon-module-logo:before { content: "\f119"; }
205
+ .icon-packager:before { content: "\f120"; }
206
+ .icon-packager-logo:before { content: "\f121"; }
207
  .icon-toolset-logo:before { content: "\f11a"; }
208
  .icon-types:before { content: "\f11b"; }
209
  .icon-types-logo:before { content: "\f11c"; }
225
  <body class="characters-off">
226
  <div id="page" class="container">
227
  <header>
228
+ <h1>onthegosystems-icons contains 18 glyphs:</h1>
229
  <a onclick="toggleCharacters(); return false;" href="#">Toggle Preview Characters</a>
230
  </header>
231
 
360
  </div>
361
  </div>
362
 
363
+ <div class="glyph">
364
+ <div class="preview-glyphs">
365
+ <span class="step size-12"><span class="letters">Pp</span><i id="icon-packager" class="icon-packager"></i></span><span class="step size-14"><span class="letters">Pp</span><i id="icon-packager" class="icon-packager"></i></span><span class="step size-16"><span class="letters">Pp</span><i id="icon-packager" class="icon-packager"></i></span><span class="step size-18"><span class="letters">Pp</span><i id="icon-packager" class="icon-packager"></i></span><span class="step size-21"><span class="letters">Pp</span><i id="icon-packager" class="icon-packager"></i></span><span class="step size-24"><span class="letters">Pp</span><i id="icon-packager" class="icon-packager"></i></span><span class="step size-36"><span class="letters">Pp</span><i id="icon-packager" class="icon-packager"></i></span><span class="step size-48"><span class="letters">Pp</span><i id="icon-packager" class="icon-packager"></i></span><span class="step size-60"><span class="letters">Pp</span><i id="icon-packager" class="icon-packager"></i></span><span class="step size-72"><span class="letters">Pp</span><i id="icon-packager" class="icon-packager"></i></span>
366
+ </div>
367
+ <div class="preview-scale">
368
+ <span class="step">12</span><span class="step">14</span><span class="step">16</span><span class="step">18</span><span class="step">21</span><span class="step">24</span><span class="step">36</span><span class="step">48</span><span class="step">60</span><span class="step">72</span>
369
+ </div>
370
+ <div class="usage">
371
+ <input class="class" type="text" readonly="readonly" onClick="this.select();" value=".icon-packager" />
372
+ <input class="point" type="text" readonly="readonly" onClick="this.select();" value="&amp;#xf120;" />
373
+ </div>
374
+ </div>
375
+
376
+ <div class="glyph">
377
+ <div class="preview-glyphs">
378
+ <span class="step size-12"><span class="letters">Pp</span><i id="icon-packager-logo" class="icon-packager-logo"></i></span><span class="step size-14"><span class="letters">Pp</span><i id="icon-packager-logo" class="icon-packager-logo"></i></span><span class="step size-16"><span class="letters">Pp</span><i id="icon-packager-logo" class="icon-packager-logo"></i></span><span class="step size-18"><span class="letters">Pp</span><i id="icon-packager-logo" class="icon-packager-logo"></i></span><span class="step size-21"><span class="letters">Pp</span><i id="icon-packager-logo" class="icon-packager-logo"></i></span><span class="step size-24"><span class="letters">Pp</span><i id="icon-packager-logo" class="icon-packager-logo"></i></span><span class="step size-36"><span class="letters">Pp</span><i id="icon-packager-logo" class="icon-packager-logo"></i></span><span class="step size-48"><span class="letters">Pp</span><i id="icon-packager-logo" class="icon-packager-logo"></i></span><span class="step size-60"><span class="letters">Pp</span><i id="icon-packager-logo" class="icon-packager-logo"></i></span><span class="step size-72"><span class="letters">Pp</span><i id="icon-packager-logo" class="icon-packager-logo"></i></span>
379
+ </div>
380
+ <div class="preview-scale">
381
+ <span class="step">12</span><span class="step">14</span><span class="step">16</span><span class="step">18</span><span class="step">21</span><span class="step">24</span><span class="step">36</span><span class="step">48</span><span class="step">60</span><span class="step">72</span>
382
+ </div>
383
+ <div class="usage">
384
+ <input class="class" type="text" readonly="readonly" onClick="this.select();" value=".icon-packager-logo" />
385
+ <input class="point" type="text" readonly="readonly" onClick="this.select();" value="&amp;#xf121;" />
386
+ </div>
387
+ </div>
388
+
389
  <div class="glyph">
390
  <div class="preview-glyphs">
391
  <span class="step size-12"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-14"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-16"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-18"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-21"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-24"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-36"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-48"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-60"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span><span class="step size-72"><span class="letters">Pp</span><i id="icon-toolset-logo" class="icon-toolset-logo"></i></span>
embedded/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.woff DELETED
Binary file
embedded/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.eot → onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.eot} RENAMED
Binary file
embedded/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.svg → onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.svg} RENAMED
@@ -1,28 +1,28 @@
1
  <?xml version="1.0" standalone="no"?>
2
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
  <!--
4
- 2014-11-13: Created.
5
  -->
6
- <svg xmlns="http://www.w3.org/2000/svg">
7
  <metadata>
8
- Created by FontForge 20120731 at Thu Nov 13 16:01:00 2014
9
  By Riccardo Strobbia
10
- Created by Riccardo Strobbia with FontForge 2.0 (http://fontforge.sf.net)
11
  </metadata>
12
  <defs>
13
  <font id="onthegosystems-icons" horiz-adv-x="512" >
14
  <font-face
15
  font-family="onthegosystems-icons"
16
- font-weight="500"
17
  font-stretch="normal"
18
  units-per-em="512"
19
- panose-1="2 0 6 9 0 0 0 0 0 0"
20
  ascent="448"
21
  descent="-64"
22
  bbox="53.2423 -38.4004 460.8 422.4"
23
  underline-thickness="25.6"
24
  underline-position="-51.2"
25
- unicode-range="U+F110-F11F"
26
  />
27
  <missing-glyph />
28
  <glyph glyph-name="uniF11F" unicode="&#xf11f;"
@@ -257,6 +257,12 @@ c1.7666 0.626953 3.46875 1.27344 5.09473 1.93945l0.390625 0.133789l0.40918 0.192
257
  c1.47852 0.787109 2.86035 1.59961 4.15332 2.45117l0.217773 0.115234l0.0771484 0.0576172c1.05566 0.678711 2.02832 1.40137 2.95605 2.125l0.358398 0.249023l0.25 0.217773c0.838867 0.65918 1.62598 1.35059 2.34863 2.03516l0.102539 0.0898438l0.223633 0.249023
258
  c0.588867 0.583008 1.13965 1.17188 1.63867 1.78613l0.275391 0.288086l0.160156 0.223633c0.563477 0.68457 1.0752 1.38867 1.50391 2.08691l0.0253906 0.0253906l0.0703125 0.102539c0.410156 0.671875 0.755859 1.35059 1.0752 2.02246l0.134766 0.275391
259
  l0.115234 0.300781c0.275391 0.65918 0.537109 1.33105 0.691406 2.02148l0.0761719 0.186523v0.0439453c0.210938 0.78125 0.333008 1.5752 0.397461 2.375z" />
 
 
 
 
 
 
260
  <glyph glyph-name="uniF114" unicode="&#xf114;"
261
  d="M342.15 99.4111l0.0898438 1.29883l0.43457 -50.0029l-0.0380859 -1.03027l-0.0507812 -0.262695c-0.0644531 -0.799805 -0.199219 -1.58691 -0.397461 -2.37402v-0.0322266l-0.0761719 -0.172852c-0.154297 -0.68457 -0.416016 -1.36914 -0.691406 -2.03516
262
  l-0.115234 -0.293945l-0.134766 -0.269531c-0.319336 -0.671875 -0.671875 -1.35645 -1.0752 -2.02148l-0.0703125 -0.102539l-0.0253906 -0.0263672c-0.428711 -0.709961 -0.94043 -1.40137 -1.50391 -2.08594l-0.15332 -0.217773l-0.275391 -0.306641
1
  <?xml version="1.0" standalone="no"?>
2
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
  <!--
4
+ 2015-3-4: Created with FontForge (http://fontforge.org)
5
  -->
6
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
7
  <metadata>
8
+ Created by FontForge 20141127 at Wed Mar 4 12:40:05 2015
9
  By Riccardo Strobbia
10
+ Copyright (c) 2015, Riccardo Strobbia
11
  </metadata>
12
  <defs>
13
  <font id="onthegosystems-icons" horiz-adv-x="512" >
14
  <font-face
15
  font-family="onthegosystems-icons"
16
+ font-weight="400"
17
  font-stretch="normal"
18
  units-per-em="512"
19
+ panose-1="2 0 5 9 0 0 0 0 0 0"
20
  ascent="448"
21
  descent="-64"
22
  bbox="53.2423 -38.4004 460.8 422.4"
23
  underline-thickness="25.6"
24
  underline-position="-51.2"
25
+ unicode-range="U+F110-F121"
26
  />
27
  <missing-glyph />
28
  <glyph glyph-name="uniF11F" unicode="&#xf11f;"
257
  c1.47852 0.787109 2.86035 1.59961 4.15332 2.45117l0.217773 0.115234l0.0771484 0.0576172c1.05566 0.678711 2.02832 1.40137 2.95605 2.125l0.358398 0.249023l0.25 0.217773c0.838867 0.65918 1.62598 1.35059 2.34863 2.03516l0.102539 0.0898438l0.223633 0.249023
258
  c0.588867 0.583008 1.13965 1.17188 1.63867 1.78613l0.275391 0.288086l0.160156 0.223633c0.563477 0.68457 1.0752 1.38867 1.50391 2.08691l0.0253906 0.0253906l0.0703125 0.102539c0.410156 0.671875 0.755859 1.35059 1.0752 2.02246l0.134766 0.275391
259
  l0.115234 0.300781c0.275391 0.65918 0.537109 1.33105 0.691406 2.02148l0.0761719 0.186523v0.0439453c0.210938 0.78125 0.333008 1.5752 0.397461 2.375z" />
260
+ <glyph glyph-name="uniF120" unicode="&#xf120;"
261
+ d="M373.56 379.779l73.6641 -73.6553v-242.989c0.945312 -11.4707 -8.60645 -21.041 -20.0859 -21.041h-341.385c-11.4609 0 -21.0312 9.54297 -21.0312 21.041v242.989l73.665 73.6553h235.173zM306.702 160.703h77.3633l-127.062 102.367l-128.188 -102.367h77.4912
262
+ v-67.9395h100.396v67.9395zM118.291 310.896h277.263l-31.5557 32.5283h-213.188z" />
263
+ <glyph glyph-name="uniF121" unicode="&#xf121;"
264
+ d="M170.238 102.4l85.7617 68.4805l85.1191 -68.4805h-51.8389v-45.4375h-67.1992v45.4375h-51.8428zM371.2 345.6h76.7998v-384h-384v384h76.7998v76.8008h76.7998v-76.8008h76.8008v76.8008h76.7998v-76.8008zM383.357 37.1221v162.558l-49.2754 49.2793h-157.442
265
+ l-49.2783 -49.2793v-162.558c0 -7.68066 6.39746 -14.0781 14.0781 -14.0781h228.479c7.67676 0 14.082 6.39746 13.4395 14.0781zM184.959 224.641h142.721l21.123 -21.7617h-185.602z" />
266
  <glyph glyph-name="uniF114" unicode="&#xf114;"
267
  d="M342.15 99.4111l0.0898438 1.29883l0.43457 -50.0029l-0.0380859 -1.03027l-0.0507812 -0.262695c-0.0644531 -0.799805 -0.199219 -1.58691 -0.397461 -2.37402v-0.0322266l-0.0761719 -0.172852c-0.154297 -0.68457 -0.416016 -1.36914 -0.691406 -2.03516
268
  l-0.115234 -0.293945l-0.134766 -0.269531c-0.319336 -0.671875 -0.671875 -1.35645 -1.0752 -2.02148l-0.0703125 -0.102539l-0.0253906 -0.0263672c-0.428711 -0.709961 -0.94043 -1.40137 -1.50391 -2.08594l-0.15332 -0.217773l-0.275391 -0.306641
embedded/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_33da83f67be9c5797490c4baa29104c1.ttf → onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.ttf} RENAMED
Binary file
embedded/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons_ea0d501b723f7b75d3147cf08210b5cf.woff ADDED
Binary file
embedded/onthego-resources/onthegosystems-icons/vectors/packager-logo.svg ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
4
+ <svg version="1.1" baseProfile="tiny" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
5
+ x="0px" y="0px" width="141px" height="141px" viewBox="0 0 141 141" xml:space="preserve">
6
+ <g>
7
+ <polygon fill="#F05A29" points="46.882,95.175 61.159,95.175 61.159,107.688 79.665,107.688 79.665,95.175 93.941,95.175
8
+ 70.5,76.316 "/>
9
+ <path fill="#F05A29" d="M102.225,28.2V7.05H81.075V28.2h-21.15V7.05h-21.15V28.2h-21.15v105.75h105.75V28.2H102.225z
10
+ M105.573,113.152c0.177,2.115-1.587,3.877-3.701,3.877H38.951c-2.115,0-3.877-1.762-3.877-3.877V68.385l13.571-13.571h43.358
11
+ l13.57,13.571V113.152z"/>
12
+ <polygon fill="#F05A29" points="50.936,61.511 44.944,67.504 96.057,67.504 90.24,61.511 "/>
13
+ </g>
14
+ </svg>
embedded/onthego-resources/onthegosystems-icons/vectors/packager.svg ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
4
+ <svg version="1.1" baseProfile="tiny" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
5
+ x="0px" y="0px" width="56.333px" height="52.166px" viewBox="0 0 56.333 52.166" xml:space="preserve">
6
+ <path fill="#333333" d="M41.101,7.506H15.226L7.121,15.61v26.735c0,1.265,1.053,2.315,2.314,2.315h37.561
7
+ c1.263,0,2.314-1.053,2.21-2.315V15.61L41.101,7.506z M33.745,31.61v7.475H22.699V31.61h-8.526l14.104-11.263l13.98,11.263H33.745z
8
+ M13.015,15.085l3.578-3.579h23.456l3.472,3.579H13.015z"/>
9
+ </svg>
embedded/onthego-resources/onthegosystems-icons/vectors/{wpml logo.svg → wpml-logo.svg} RENAMED
File without changes
embedded/plugin.php CHANGED
@@ -1,18 +1,18 @@
1
  <?php
2
  /*
3
- Plugin Name: Types Embeded - Complete Solution for Custom Fields and Types
4
  Plugin URI: http://wordpress.org/extend/plugins/types/
5
  Description: Define custom post types, custom taxonomy and custom fields.
6
  Author: OnTheGoSystems
7
  Author URI: http://www.onthegosystems.com
8
- Version: 1.6.5
9
  */
10
  /**
11
  *
12
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/plugin.php $
13
- * $LastChangedDate: 2015-02-10 17:10:42 +0000 (Tue, 10 Feb 2015) $
14
- * $LastChangedRevision: 1086547 $
15
- * $LastChangedBy: AmirHelzer $
16
  *
17
  */
18
 
1
  <?php
2
  /*
3
+ Plugin Name: Types - Complete Solution for Custom Fields and Types Embedded
4
  Plugin URI: http://wordpress.org/extend/plugins/types/
5
  Description: Define custom post types, custom taxonomy and custom fields.
6
  Author: OnTheGoSystems
7
  Author URI: http://www.onthegosystems.com
8
+ Version: 1.6.6
9
  */
10
  /**
11
  *
12
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/plugin.php $
13
+ * $LastChangedDate: 2015-04-01 14:17:52 +0000 (Wed, 01 Apr 2015) $
14
+ * $LastChangedRevision: 1125409 $
15
+ * $LastChangedBy: iworks $
16
  *
17
  */
18
 
embedded/readme.txt CHANGED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  The Embedded version lets you create custom types, taxonomy and fields for your theme or plugin, without requiring any plugin.
2
 
3
  = Instructions =
1
+ === Types Embedded - Custom Fields and Custom Post Types Management ===
2
+ Contributors: brucepearson, AmirHelzer, jozik, mihaimihai, iworks
3
+ Donate link: http://wp-types.com
4
+ Tags: CMS, custom field, custom fields, custom post type, custom post types, post, post type, post types, cck, taxonomy, fields
5
+ License: GPLv2
6
+ Requires at least: 3.4
7
+ Tested up to: 4.1.1
8
+ Stable tag: 1.6.6
9
+
10
  The Embedded version lets you create custom types, taxonomy and fields for your theme or plugin, without requiring any plugin.
11
 
12
  = Instructions =
embedded/resources/css/basic.css CHANGED
@@ -564,6 +564,17 @@ input.wpcf-form-error {
564
 
565
  .status-inactive
566
  {
567
- opacity: .5;
568
- transition: all .4s;
 
 
 
 
 
 
 
 
 
 
 
569
  }
564
 
565
  .status-inactive
566
  {
567
+ opacity: .7;
568
+ /*transition: all .4s;*/
569
+ }
570
+
571
+ .wpcf-table-column-name
572
+ {
573
+ min-width: 250px;
574
+ }
575
+
576
+ #wpcf_types_list
577
+ ,#wpcf_tax_list
578
+ {
579
+ margin: 1.5em 0;
580
  }
embedded/resources/css/colorbox.css CHANGED
@@ -12,7 +12,7 @@
12
  position:absolute;
13
  top:0;
14
  left:0;
15
- z-index:9999;
16
  /* overflow:hidden;*/
17
  }
18
 
@@ -82,4 +82,4 @@
82
  .cboxIE #cboxMiddleRight {
83
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
84
  }
85
- /* Dialogs END */
12
  position:absolute;
13
  top:0;
14
  left:0;
15
+ z-index: 20000;
16
  /* overflow:hidden;*/
17
  }
18
 
82
  .cboxIE #cboxMiddleRight {
83
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
84
  }
85
+ /* Dialogs END */
embedded/resources/css/dashicons.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  *
3
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/resources/css/dashicons.css $
4
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
5
  * $LastChangedRevision: 1027712 $
6
  * $LastChangedBy: iworks $
1
  /**
2
  *
3
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/resources/css/dashicons.css $
4
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
5
  * $LastChangedRevision: 1027712 $
6
  * $LastChangedBy: iworks $
embedded/resources/css/usermeta.css CHANGED
@@ -33,8 +33,8 @@
33
  max-width:40%;
34
  height:auto;
35
  }
36
- .CodeMirror-wrap{
37
- background:#fff;
38
  border:1px solid #ccc;
39
  }
40
  .wpcf-admin-css-preview-style-edit{
@@ -78,4 +78,4 @@
78
  }
79
  #createuser .wpcf-profile-field-line .wpcf-profile-field-line {
80
  margin-bottom: 10px;
81
- }
33
  max-width:40%;
34
  height:auto;
35
  }
36
+ .wpcf-fields-form .CodeMirror-wrap
37
+ {
38
  border:1px solid #ccc;
39
  }
40
  .wpcf-admin-css-preview-style-edit{
78
  }
79
  #createuser .wpcf-profile-field-line .wpcf-profile-field-line {
80
  margin-bottom: 10px;
81
+ }
embedded/resources/js/basic.js CHANGED
@@ -4,9 +4,9 @@
4
  * For now full and embedded version use this script.
5
  * Before moving full-version-only code - make sure it's not needed here.
6
  *
7
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/resources/js/basic.js $
8
- * $LastChangedDate: 2015-01-28 06:42:34 +0000 (Wed, 28 Jan 2015) $
9
- * $LastChangedRevision: 1077234 $
10
  * $LastChangedBy: iworks $
11
  *
12
  */
@@ -243,7 +243,7 @@ jQuery(document).ready(function(){
243
  passed = false;
244
  }
245
  });
246
-
247
  if (passed == false) {
248
  // Bind message fade out
249
  jQuery('.wpcf-forms-field-slug').live('keyup', function(){
@@ -265,6 +265,7 @@ jQuery(document).ready(function(){
265
  var updateAdd = wpcfGetParameterByName('wpcf_ajax_update_add', jQuery(this).attr('href'));
266
  var warning = wpcfGetParameterByName('wpcf_warning', jQuery(this).attr('href'));
267
  var thisObject = jQuery(this);
 
268
  if (warning != false) {
269
  var answer = confirm(warning);
270
  if (answer == false) {
@@ -275,7 +276,6 @@ jQuery(document).ready(function(){
275
  url: jQuery(this).attr('href'),
276
  type: 'get',
277
  dataType: 'json',
278
- // data: ,
279
  cache: false,
280
  beforeSend: function() {
281
  if (update != false) {
@@ -300,6 +300,17 @@ jQuery(document).ready(function(){
300
  && data.wpcf_nonce_ajax_callback == wpcf_nonce_ajax_callback)) {
301
  eval(data.execute);
302
  }
 
 
 
 
 
 
 
 
 
 
 
303
  }
304
  if (callback != false) {
305
  eval(callback+'(data, thisObject)');
@@ -371,6 +382,16 @@ jQuery(document).ready(function(){
371
  jQuery('#wpcf-types-form-rewrite-toggle').slideUp();
372
  }
373
  });
 
 
 
 
 
 
 
 
 
 
374
  jQuery('input[name="ct[show_in_menu]"]').change(function(){
375
  if (jQuery(this).is(':checked')) {
376
  jQuery('#wpcf-types-form-showinmenu-toggle').slideDown();
@@ -523,18 +544,6 @@ function wpcfLoadingButtonStop() {
523
  //type modal didnt disappeared
524
  jQuery('.types_modal_box').remove();
525
  jQuery('.types_block_page').remove();
526
-
527
- }
528
-
529
- /**
530
- * Controls supports title or body Warning.
531
- */
532
- function wpcfTitleEditorCheck() {
533
- if (!jQuery('#wpcf-supports-title').is(':checked') && !jQuery('#wpcf-supports-editor').is(':checked')) {
534
- jQuery('#wpcf-types-title-editor-warning').fadeIn();
535
- } else {
536
- jQuery('#wpcf-types-title-editor-warning').fadeOut();
537
- }
538
  }
539
 
540
  /**
4
  * For now full and embedded version use this script.
5
  * Before moving full-version-only code - make sure it's not needed here.
6
  *
7
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/resources/js/basic.js $
8
+ * $LastChangedDate: 2015-03-10 06:46:08 +0000 (Tue, 10 Mar 2015) $
9
+ * $LastChangedRevision: 1109249 $
10
  * $LastChangedBy: iworks $
11
  *
12
  */
243
  passed = false;
244
  }
245
  });
246
+
247
  if (passed == false) {
248
  // Bind message fade out
249
  jQuery('.wpcf-forms-field-slug').live('keyup', function(){
265
  var updateAdd = wpcfGetParameterByName('wpcf_ajax_update_add', jQuery(this).attr('href'));
266
  var warning = wpcfGetParameterByName('wpcf_warning', jQuery(this).attr('href'));
267
  var thisObject = jQuery(this);
268
+ var thisObjectTR = jQuery(this).closest('tr');
269
  if (warning != false) {
270
  var answer = confirm(warning);
271
  if (answer == false) {
276
  url: jQuery(this).attr('href'),
277
  type: 'get',
278
  dataType: 'json',
 
279
  cache: false,
280
  beforeSend: function() {
281
  if (update != false) {
300
  && data.wpcf_nonce_ajax_callback == wpcf_nonce_ajax_callback)) {
301
  eval(data.execute);
302
  }
303
+ if (typeof data.status != 'undefined' ) {
304
+ if ( 'inactive' == data.status ) {
305
+ thisObjectTR.addClass('status-inactive');
306
+
307
+ } else {
308
+ thisObjectTR.removeClass('status-inactive');
309
+ }
310
+ }
311
+ if (typeof data.status_label != 'undefined' ) {
312
+ jQuery('td.status', thisObjectTR).html(data.status_label);
313
+ }
314
  }
315
  if (callback != false) {
316
  eval(callback+'(data, thisObject)');
382
  jQuery('#wpcf-types-form-rewrite-toggle').slideUp();
383
  }
384
  });
385
+ /**
386
+ * meta_box_cb
387
+ */
388
+ jQuery('.wpcf-tax-form input[name="ct[meta_box_cb][disabled]"]').change(function(){
389
+ if (jQuery(this).is(':checked')) {
390
+ jQuery('#wpcf-types-form-meta_box_cb-toggle').slideUp();
391
+ } else {
392
+ jQuery('#wpcf-types-form-meta_box_cb-toggle').slideDown();
393
+ }
394
+ });
395
  jQuery('input[name="ct[show_in_menu]"]').change(function(){
396
  if (jQuery(this).is(':checked')) {
397
  jQuery('#wpcf-types-form-showinmenu-toggle').slideDown();
544
  //type modal didnt disappeared
545
  jQuery('.types_modal_box').remove();
546
  jQuery('.types_block_page').remove();
 
 
 
 
 
 
 
 
 
 
 
 
547
  }
548
 
549
  /**
embedded/resources/js/fields-form.js CHANGED
@@ -1,6 +1,6 @@
1
- /*
2
  * Group edit page JS
3
- *
4
  * This file should be used from now on as dedicated JS for group edit page.
5
  * Avoid adding new functionalities to basic.js
6
  *
@@ -9,9 +9,9 @@
9
  * @since Types 1.1.5
10
  * @autor srdjan
11
  *
12
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/resources/js/fields-form.js $
13
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
14
- * $LastChangedRevision: 1027712 $
15
  * $LastChangedBy: iworks $
16
  *
17
  */
@@ -25,7 +25,7 @@ jQuery(document).ready(function($){
25
  handle: 'img.js-types-sort-button',
26
  start: function(e, ui){
27
  ui.placeholder.height(ui.item.find('.wpcf-form-fieldset').height());
28
- }
29
  });
30
  }
31
  });
@@ -39,7 +39,6 @@ jQuery(document).ready(function($){
39
  start: function(e, ui){
40
  ui.placeholder.height(ui.item.height() + 23);
41
  }
42
-
43
  });
44
 
45
  $('.wpcf-fields-radio-sortable,.wpcf-fields-select-sortable').sortable({
@@ -48,7 +47,7 @@ jQuery(document).ready(function($){
48
  handle: 'img.js-types-sort-button',
49
  start: function(e, ui){
50
  ui.placeholder.height(ui.item.height() - 2);
51
- }
52
  });
53
 
54
  $('.wpcf-fields-checkboxes-sortable').sortable({
@@ -57,7 +56,7 @@ jQuery(document).ready(function($){
57
  handle: 'img.js-types-sort-button',
58
  start: function(e, ui){
59
  ui.placeholder.height(ui.item.height() + 13);
60
- }
61
  });
62
 
63
  $('[data-wpcf-type="checkbox"],[data-wpcf-type=checkboxes]').each( function() {
@@ -66,6 +65,16 @@ jQuery(document).ready(function($){
66
  });
67
  wpcf_checkbox_value_zero($(this));
68
  });
 
 
 
 
 
 
 
 
 
 
69
  });
70
 
71
  function wpcf_checkbox_value_zero(field) {
@@ -75,15 +84,22 @@ function wpcf_checkbox_value_zero(field) {
75
  jQuery(field).prev().remove();
76
  jQuery(field).removeClass('wpcf-value-store-error-error');
77
  }
78
-
79
  var value = jQuery(field).val();
80
  if (value === '') {
81
  passed = false;
82
  if (!jQuery(field).hasClass('wpcf-value-store-error-error')) {
83
  jQuery(field).before('<div class="wpcf-form-error">' + jQuery(field).data('required-message') + '</div>').addClass('wpcf-value-store-error-error');
 
 
 
 
 
 
 
 
84
  }
85
  jQuery(field).focus();
86
-
87
  }
88
  if (value === '0') {
89
  passed = false;
@@ -92,8 +108,6 @@ function wpcf_checkbox_value_zero(field) {
92
  }
93
  jQuery(field).focus();
94
  }
95
-
96
  return !passed;
97
-
98
  }
99
 
1
+ /*
2
  * Group edit page JS
3
+ *
4
  * This file should be used from now on as dedicated JS for group edit page.
5
  * Avoid adding new functionalities to basic.js
6
  *
9
  * @since Types 1.1.5
10
  * @autor srdjan
11
  *
12
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/resources/js/fields-form.js $
13
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
14
+ * $LastChangedRevision: 1120400 $
15
  * $LastChangedBy: iworks $
16
  *
17
  */
25
  handle: 'img.js-types-sort-button',
26
  start: function(e, ui){
27
  ui.placeholder.height(ui.item.find('.wpcf-form-fieldset').height());
28
+ }
29
  });
30
  }
31
  });
39
  start: function(e, ui){
40
  ui.placeholder.height(ui.item.height() + 23);
41
  }
 
42
  });
43
 
44
  $('.wpcf-fields-radio-sortable,.wpcf-fields-select-sortable').sortable({
47
  handle: 'img.js-types-sort-button',
48
  start: function(e, ui){
49
  ui.placeholder.height(ui.item.height() - 2);
50
+ }
51
  });
52
 
53
  $('.wpcf-fields-checkboxes-sortable').sortable({
56
  handle: 'img.js-types-sort-button',
57
  start: function(e, ui){
58
  ui.placeholder.height(ui.item.height() + 13);
59
+ }
60
  });
61
 
62
  $('[data-wpcf-type="checkbox"],[data-wpcf-type=checkboxes]').each( function() {
65
  });
66
  wpcf_checkbox_value_zero($(this));
67
  });
68
+
69
+ /**
70
+ * confitonal logic button close on group edit screen
71
+ */
72
+ $('#conditional-logic-button-ok').live('click', function(){
73
+ $(this).parent().slideUp('slow', function() {
74
+ $('#conditional-logic-button-open').fadeIn();
75
+ });
76
+ return false;
77
+ });
78
  });
79
 
80
  function wpcf_checkbox_value_zero(field) {
84
  jQuery(field).prev().remove();
85
  jQuery(field).removeClass('wpcf-value-store-error-error');
86
  }
87
+
88
  var value = jQuery(field).val();
89
  if (value === '') {
90
  passed = false;
91
  if (!jQuery(field).hasClass('wpcf-value-store-error-error')) {
92
  jQuery(field).before('<div class="wpcf-form-error">' + jQuery(field).data('required-message') + '</div>').addClass('wpcf-value-store-error-error');
93
+ var legend = jQuery(field).closest('div.ui-draggable').children('fieldset').children('legend');
94
+ if ( legend.hasClass('legend-collapsed') ) {
95
+ legend.click();
96
+ }
97
+ var fieldset = jQuery(field).closest('fieldset');
98
+ if ( jQuery('legend.legend-collapsed', fieldset ) ) {
99
+ jQuery('legend.legend-collapsed', fieldset).click();
100
+ }
101
  }
102
  jQuery(field).focus();
 
103
  }
104
  if (value === '0') {
105
  passed = false;
108
  }
109
  jQuery(field).focus();
110
  }
 
111
  return !passed;
 
112
  }
113
 
embedded/resources/js/fields-post.js CHANGED
@@ -173,6 +173,8 @@ var typesPostScreen = (function($){
173
  $this.bind('blur', previewWarningShow);
174
  }
175
  });
 
 
176
  });
177
  }
178
  function previewWarning(header, content) {
@@ -193,4 +195,4 @@ var typesPostScreen = (function($){
193
  return {
194
  previewWarning: previewWarning
195
  };
196
- })(jQuery);
173
  $this.bind('blur', previewWarningShow);
174
  }
175
  });
176
+ $('.js-wpt-repadd,.js-wpt-repdelete,.js-wpt-date-clear').on('click', previewWarningShow);
177
+ $('.js-wpt-repdrag').on('mouseup', previewWarningShow);
178
  });
179
  }
180
  function previewWarning(header, content) {
195
  return {
196
  previewWarning: previewWarning
197
  };
198
+ })(jQuery);
embedded/resources/js/post-relationship.js CHANGED
@@ -149,7 +149,7 @@ var tChildTable = (function($) {
149
 
150
  tTagBox = {
151
  clean: function(tags) {
152
- var comma = postL10n.comma;
153
  if (',' !== comma)
154
  tags = tags.replace(new RegExp(comma, 'g'), ',');
155
  tags = tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, '');
@@ -159,7 +159,7 @@ var tChildTable = (function($) {
159
  },
160
  parseTags: function(el) {
161
  var id = el.id, num = id.split('-check-num-')[1], taxbox = $(el).closest('.js-types-child-tagsdiv'),
162
- thetags = taxbox.find('.the-tags'), comma = postL10n.comma,
163
  current_tags = thetags.val().split(comma), new_tags = [];
164
  delete current_tags[num];
165
 
@@ -179,14 +179,15 @@ var tChildTable = (function($) {
179
  var thetags = $('.the-tags', el),
180
  tagchecklist = $('.tagchecklist', el),
181
  id = $(el).attr('id'),
182
- current_tags, disabled;
 
183
 
184
  if (!thetags.length)
185
  return;
186
 
187
  disabled = thetags.prop('disabled');
188
 
189
- current_tags = thetags.val().split(postL10n.comma);
190
  tagchecklist.empty();
191
 
192
  $.each(current_tags, function(key, val) {
@@ -217,7 +218,7 @@ var tChildTable = (function($) {
217
  a = a || false;
218
  var tags = $('.the-tags', el),
219
  newtag = $('input.js-types-newtag', el),
220
- comma = postL10n.comma,
221
  newtags, text;
222
 
223
  text = a ? $(a).text() : newtag.val();
@@ -286,8 +287,9 @@ var tChildTable = (function($) {
286
  }
287
  }).each(function() {
288
  // var tax = $(this).closest('div.tagsdiv').attr('id');
289
- var tax = $(this).data('types-tax');
290
- $(this).suggest(ajaxurl + '?action=ajax-tag-search&tax=' + tax, {delay: 500, minchars: 2, multiple: true, multipleSep: postL10n.comma + ' '});
 
291
  });
292
 
293
  // save tags on post save/publish
149
 
150
  tTagBox = {
151
  clean: function(tags) {
152
+ var comma = postL10n.comma || window.tagsBoxL10n.tagDelimiter;
153
  if (',' !== comma)
154
  tags = tags.replace(new RegExp(comma, 'g'), ',');
155
  tags = tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, '');
159
  },
160
  parseTags: function(el) {
161
  var id = el.id, num = id.split('-check-num-')[1], taxbox = $(el).closest('.js-types-child-tagsdiv'),
162
+ thetags = taxbox.find('.the-tags'), comma = postL10n.comma || window.tagsBoxL10n.tagDelimiter,
163
  current_tags = thetags.val().split(comma), new_tags = [];
164
  delete current_tags[num];
165
 
179
  var thetags = $('.the-tags', el),
180
  tagchecklist = $('.tagchecklist', el),
181
  id = $(el).attr('id'),
182
+ current_tags, disabled,
183
+ comma = postL10n.comma || window.tagsBoxL10n.tagDelimiter;
184
 
185
  if (!thetags.length)
186
  return;
187
 
188
  disabled = thetags.prop('disabled');
189
 
190
+ current_tags = thetags.val().split(comma);
191
  tagchecklist.empty();
192
 
193
  $.each(current_tags, function(key, val) {
218
  a = a || false;
219
  var tags = $('.the-tags', el),
220
  newtag = $('input.js-types-newtag', el),
221
+ comma = postL10n.comma || window.tagsBoxL10n.tagDelimiter,
222
  newtags, text;
223
 
224
  text = a ? $(a).text() : newtag.val();
287
  }
288
  }).each(function() {
289
  // var tax = $(this).closest('div.tagsdiv').attr('id');
290
+ var tax = $(this).data('types-tax'),
291
+ comma = postL10n.comma || window.tagsBoxL10n.tagDelimiter;
292
+ $(this).suggest(ajaxurl + '?action=ajax-tag-search&tax=' + tax, {delay: 500, minchars: 2, multiple: true, multipleSep: comma + ' '});
293
  });
294
 
295
  // save tags on post save/publish
embedded/usermeta-init.php CHANGED
@@ -10,9 +10,9 @@ $fields_access = new Post_Fields_Access;
10
  * @author Gen gen.i@icanlocalize.com
11
  * @since Types 1.3
12
  *
13
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/embedded/usermeta-init.php $
14
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
15
- * $LastChangedRevision: 1027712 $
16
  * $LastChangedBy: iworks $
17
  *
18
  */
@@ -98,8 +98,7 @@ function wpcf_admin_menu_edit_user_fields() {
98
  } else {
99
  $title = __( 'Add New Usermeta Group', 'wpcf' );
100
  }
101
- echo wpcf_add_admin_header( $title );
102
-
103
  $form = wpcf_form( 'wpcf_form_fields' );
104
  echo '<br /><form method="post" action="" class="wpcf-fields-form '
105
  . 'wpcf-form-validate" onsubmit="';
@@ -124,7 +123,7 @@ function wpcf_admin_menu_edit_user_fields() {
124
  echo '">';
125
  echo $form->renderForm();
126
  echo '</form>';
127
- echo wpcf_add_admin_footer();
128
  }
129
 
130
  /**
@@ -147,7 +146,7 @@ function wpcf_admin_menu_user_fields_control_hook() {
147
  && wp_verify_nonce( $_REQUEST['_wpnonce'],
148
  'user_fields_control_bulk' )
149
  && (isset( $_POST['action'] ) || isset( $_POST['action2'] )) && !empty( $_POST['fields'] ) ) {
150
- $action = $_POST['action'] == '-1' ? $_POST['action2'] : $_POST['action'];
151
  wpcf_admin_user_fields_control_bulk_actions( $action );
152
  }
153
 
@@ -165,13 +164,13 @@ function wpcf_admin_menu_user_fields_control_hook() {
165
  */
166
  function wpcf_admin_menu_user_fields_control() {
167
  global $wpcf_control_table;
168
- echo wpcf_add_admin_header( __( 'User Fields Control', 'wpcf' ) );
169
  echo '<br /><form method="post" action="" id="wpcf-custom-fields-control-form" class="wpcf-custom-fields-control-form '
170
  . 'wpcf-form-validate" enctype="multipart/form-data">';
171
  echo wpcf_admin_custom_fields_control_form( $wpcf_control_table );
172
  wp_nonce_field( 'user_fields_control_bulk' );
173
  echo '</form>';
174
- echo wpcf_add_admin_footer();
175
  }
176
 
177
  /**
@@ -180,18 +179,22 @@ function wpcf_admin_menu_user_fields_control() {
180
  * @author Gen gen.i@icanlocalize.com
181
  * @since Types 1.3
182
  */
183
- function wpcf_usermeta_summary() {
184
- echo wpcf_add_admin_header( __( 'User Fields', 'wpcf' ) );
 
 
 
 
 
185
  require_once WPCF_INC_ABSPATH . '/fields.php';
186
  require_once WPCF_INC_ABSPATH . '/usermeta.php';
187
  require_once WPCF_INC_ABSPATH . '/usermeta-list.php';
188
  $to_display = wpcf_admin_fields_get_fields();
189
  if ( !empty( $to_display ) ) {
190
- add_action( 'wpcf_groups_list_table_after',
191
- 'wpcf_admin_promotional_text' );
192
  }
193
  wpcf_admin_usermeta_list();
194
- echo wpcf_add_admin_footer();
195
  }
196
 
197
  //Add usermeta hook when user profile loaded
@@ -207,17 +210,13 @@ add_action( 'edit_user_profile_update', 'wpcf_admin_user_profile_save_hook' );
207
  /**
208
  * Add usermeta groups to post editor
209
  */
210
- add_filter( 'editor_addon_menus_types',
211
- 'wpcf_admin_post_add_usermeta_to_editor_js' );
212
-
213
 
214
  add_action( 'load-post.php', '__wpcf_usermeta_test', PHP_INT_MAX );
215
  add_action( 'load-post-new.php', '__wpcf_usermeta_test', PHP_INT_MAX );
216
- if ( is_admin() ) {
217
- add_filter( 'wpcf_post_groups', '__wpcf_usermeta_test_groups' );
218
- }
219
 
220
- function __wpcf_usermeta_test() {
 
221
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
222
  $field['id'] = md5( 'date' . time() );
223
  $here = array(basename( $_SERVER['REQUEST_URI'] ), basename( $_SERVER['SCRIPT_FILENAME'] ));
@@ -226,58 +225,27 @@ function __wpcf_usermeta_test() {
226
  if ( $post ) {
227
  $post_type = get_post_type( $post );
228
  } else if ( !empty( $_GET['post'] ) ) {
229
- $post_type = get_post_type( $_GET['post'] );
 
 
230
  }
231
  if ( ( $here[0] == ('index.php' || 'wp-admin')) && ( $here[1] != 'index.php') ) {
232
- if ( isset( $post_type )
233
- && in_array( $post_type,
234
- array('view', 'view-template', 'cred-form') ) ) {
 
235
  return;
236
  }
237
  wpcf_admin_post_add_to_editor( $field );
238
  }
239
  }
240
 
241
- function __wpcf_usermeta_test_groups( $groups ) {
242
- if ( !empty( $groups ) ) {
243
- return $groups;
244
- }
245
- $groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
246
- $check = false;
247
- if ( !empty( $groups ) ) {
248
-
249
- foreach ( $groups as $group_id => $group ) {
250
-
251
- // Mark meta box as hidden
252
- $groups[$group_id]['__show_meta_box'] = false;
253
-
254
- if ( empty( $group['is_active'] ) ) {
255
- unset( $groups[$group_id] );
256
- continue;
257
- }
258
- $fields = wpcf_admin_fields_get_fields_by_group( $group['id'],
259
- 'slug', true, false, true, 'wp-types-user-group',
260
- 'wpcf-usermeta' );
261
- if ( empty( $fields ) ) {
262
- unset( $groups[$group_id] );
263
- continue;
264
- }
265
- $check = true;
266
- }
267
- }
268
- if ( !$check ) {
269
- remove_action( 'admin_enqueue_scripts',
270
- 'wpcf_admin_post_add_to_editor_js' );
271
- } else {
272
- wpcf_edit_post_screen_scripts();
273
- }
274
- return $groups;
275
- }
276
-
277
  if ( !isset( $_GET['post_type'] ) && isset( $_GET['post'] ) ) {
278
- $post_type = get_post_type( $_GET['post'] );
279
- } else if ( isset( $_GET['post_type'] ) && in_array( $_GET['post_type'],
280
- get_post_types( array('show_ui' => true) ) ) ) {
 
 
281
  $post_type = $_GET['post_type'];
282
  }
283
 
@@ -400,6 +368,8 @@ function wpcf_usermeta_get_shortcode( $field, $add = '', $content = '' ) {
400
  /**
401
  * Calls view function for specific usermeta field type.
402
  *
 
 
403
  * @param type $field
404
  * @param type $atts (additional attributes: user_id, user_name, user_is_author, user_current)
405
  * @return type
@@ -433,8 +403,12 @@ function types_render_usermeta( $field_id, $params, $content = null, $code = ''
433
  if ( isset( $params['user_id'] ) ) {
434
  $user_id = $params['user_id'];
435
  } else if ( isset( $params['user_name'] ) ) { //Get user by login
436
- $user_id = $wpdb->get_var( "SELECT * FROM " . $wpdb->users . " WHERE user_login = '" . $params['user_name'] . "'",
437
- 0, 0 );
 
 
 
 
438
  } else if ( isset( $params['user_is_author'] ) ) { //Get Post author
439
  $user_id = $post->post_author;
440
  } else if ( isset( $params['user_current'] ) ) {//Get current logged user
@@ -563,6 +537,8 @@ function types_render_usermeta( $field_id, $params, $content = null, $code = ''
563
  /**
564
  * Calls view function for specific field type.
565
  *
 
 
566
  * @param type $field
567
  * @param type $atts
568
  * @return type
@@ -571,7 +547,7 @@ function types_render_usermeta_field( $field_id, $params, $content = null,
571
  $code = '' ) {
572
 
573
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
574
- global $wpcf, $post;
575
 
576
  // HTML var holds actual output
577
  $html = '';
@@ -603,8 +579,12 @@ function types_render_usermeta_field( $field_id, $params, $content = null,
603
  if ( isset( $params['user_id'] ) ) {
604
  $user_id = $params['user_id'];
605
  } else if ( isset( $params['user_name'] ) ) { //Get user by login
606
- $user_id = $wpdb->get_var( "SELECT * FROM " . $wpdb->prefix . "users WHERE user_login = '" . $params['user_name'] . "'",
607
- 0, 0 );
 
 
 
 
608
  } else if ( isset( $params['user_is_author'] ) ) { //Get Post author
609
  $user_id = $post->post_author;
610
  } else if ( isset( $params['user_current'] ) ) {//Get current logged user
@@ -721,9 +701,6 @@ function wpcf_admin_user_profile_load_hook( $user ){
721
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
722
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
723
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
724
- add_action( 'admin_footer', 'wpcf_admin_fields_usermeta_styles' );
725
-
726
-
727
  wpcf_admin_userprofile_init( $user );
728
  }
729
 
@@ -746,8 +723,25 @@ function wpcf_admin_fields_usermeta_styles(){
746
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
747
  $groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
748
  $content = '';
 
749
  if ( !empty( $groups ) ) {
 
 
 
 
 
 
 
750
  foreach ( $groups as $group ) {
 
 
 
 
 
 
 
 
 
751
  $content .= str_replace( "}", '}'.PHP_EOL, wpcf_admin_get_groups_admin_styles_by_group( $group['id'] ) );
752
  $content .= PHP_EOL;
753
  }
@@ -996,18 +990,29 @@ class Post_Fields_Access
996
 
997
  }
998
 
999
- add_action( 'wp_ajax_wpcf_types_suggest_user',
1000
- 'wpcf_access_wpcf_types_suggest_user_ajax' );
1001
 
1002
  /**
1003
  * Suggest user AJAX.
 
 
 
1004
  */
1005
  function wpcf_access_wpcf_types_suggest_user_ajax()
1006
  {
1007
  global $wpdb;
1008
  $users = '';
1009
- $q = wptoolset_esc_like(esc_sql( trim( $_GET['q'] ) ));
1010
- $found = $wpdb->get_results( "SELECT ID, display_name, user_login FROM $wpdb->users WHERE user_nicename LIKE '%%$q%%' OR user_login LIKE '%%$q%%' OR display_name LIKE '%%$q%%' OR user_email LIKE '%%$q%%' LIMIT 10" );
 
 
 
 
 
 
 
 
 
1011
 
1012
  if ( !empty( $found ) ) {
1013
  foreach ( $found as $user ) {
@@ -1032,9 +1037,9 @@ function wpcf_get_usermeta_form_addon_submit( $views_usermeta = false ){
1032
  }
1033
  else {
1034
  if ( $_POST['display_username_for_suser_selector'] == 'specific_user_by_id' ) {
1035
- $add .= ' user_id="' . $_POST['display_username_for_suser_id_value'] . '"';
1036
  } else {
1037
- $add .= ' user_name="' . $_POST['display_username_for_suser_username_value'] . '"';
1038
  }
1039
  }
1040
  }
@@ -1044,7 +1049,10 @@ function wpcf_get_usermeta_form_addon_submit( $views_usermeta = false ){
1044
  /*
1045
  * Usermeta fields addon.
1046
  * Add form user users
1047
- */
 
 
 
1048
 
1049
  function wpcf_get_usermeta_form_addon( $settings = array() ){
1050
  global $wpdb;
10
  * @author Gen gen.i@icanlocalize.com
11
  * @since Types 1.3
12
  *
13
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/embedded/usermeta-init.php $
14
+ * $LastChangedDate: 2015-04-01 14:15:17 +0000 (Wed, 01 Apr 2015) $
15
+ * $LastChangedRevision: 1125405 $
16
  * $LastChangedBy: iworks $
17
  *
18
  */
98
  } else {
99
  $title = __( 'Add New Usermeta Group', 'wpcf' );
100
  }
101
+ wpcf_add_admin_header( $title );
 
102
  $form = wpcf_form( 'wpcf_form_fields' );
103
  echo '<br /><form method="post" action="" class="wpcf-fields-form '
104
  . 'wpcf-form-validate" onsubmit="';
123
  echo '">';
124
  echo $form->renderForm();
125
  echo '</form>';
126
+ wpcf_add_admin_footer();
127
  }
128
 
129
  /**
146
  && wp_verify_nonce( $_REQUEST['_wpnonce'],
147
  'user_fields_control_bulk' )
148
  && (isset( $_POST['action'] ) || isset( $_POST['action2'] )) && !empty( $_POST['fields'] ) ) {
149
+ $action = ( $_POST['action'] == '-1' ) ? sanitize_text_field($_POST['action2']) : sanitize_text_field($_POST['action']);
150
  wpcf_admin_user_fields_control_bulk_actions( $action );
151
  }
152
 
164
  */
165
  function wpcf_admin_menu_user_fields_control() {
166
  global $wpcf_control_table;
167
+ wpcf_add_admin_header( __( 'User Fields Control', 'wpcf' ) );
168
  echo '<br /><form method="post" action="" id="wpcf-custom-fields-control-form" class="wpcf-custom-fields-control-form '
169
  . 'wpcf-form-validate" enctype="multipart/form-data">';
170
  echo wpcf_admin_custom_fields_control_form( $wpcf_control_table );
171
  wp_nonce_field( 'user_fields_control_bulk' );
172
  echo '</form>';
173
+ wpcf_add_admin_footer();
174
  }
175
 
176
  /**
179
  * @author Gen gen.i@icanlocalize.com
180
  * @since Types 1.3
181
  */
182
+ function wpcf_usermeta_summary()
183
+ {
184
+ wpcf_add_admin_header(
185
+ __( 'User Fields', 'wpcf' ),
186
+ array('page' => 'wpcf-edit-usermeta'),
187
+ __('Add New Usermeta Group', 'wpcf')
188
+ );
189
  require_once WPCF_INC_ABSPATH . '/fields.php';
190
  require_once WPCF_INC_ABSPATH . '/usermeta.php';
191
  require_once WPCF_INC_ABSPATH . '/usermeta-list.php';
192
  $to_display = wpcf_admin_fields_get_fields();
193
  if ( !empty( $to_display ) ) {
194
+ add_action( 'wpcf_groups_list_table_after', 'wpcf_admin_promotional_text' );
 
195
  }
196
  wpcf_admin_usermeta_list();
197
+ wpcf_add_admin_footer();
198
  }
199
 
200
  //Add usermeta hook when user profile loaded
210
  /**
211
  * Add usermeta groups to post editor
212
  */
213
+ add_filter( 'editor_addon_menus_types', 'wpcf_admin_post_add_usermeta_to_editor_js' );
 
 
214
 
215
  add_action( 'load-post.php', '__wpcf_usermeta_test', PHP_INT_MAX );
216
  add_action( 'load-post-new.php', '__wpcf_usermeta_test', PHP_INT_MAX );
 
 
 
217
 
218
+ function __wpcf_usermeta_test()
219
+ {
220
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
221
  $field['id'] = md5( 'date' . time() );
222
  $here = array(basename( $_SERVER['REQUEST_URI'] ), basename( $_SERVER['SCRIPT_FILENAME'] ));
225
  if ( $post ) {
226
  $post_type = get_post_type( $post );
227
  } else if ( !empty( $_GET['post'] ) ) {
228
+ $post_type = get_post_type( sanitize_text_field( $_GET['post'] ) );
229
+ } else if ( !empty( $_GET['post_type'] ) ) {
230
+ $post_type = esc_html( sanitize_text_field( $_GET['post_type'] ) );
231
  }
232
  if ( ( $here[0] == ('index.php' || 'wp-admin')) && ( $here[1] != 'index.php') ) {
233
+ if (
234
+ isset( $post_type )
235
+ && in_array( $post_type, array('view', 'view-template', 'cred-form') )
236
+ ) {
237
  return;
238
  }
239
  wpcf_admin_post_add_to_editor( $field );
240
  }
241
  }
242
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  if ( !isset( $_GET['post_type'] ) && isset( $_GET['post'] ) ) {
244
+ $post_type = get_post_type( sanitize_text_field( $_GET['post'] ) );
245
+ } else if (
246
+ isset( $_GET['post_type'] )
247
+ && in_array( $_GET['post_type'], get_post_types( array('show_ui' => true) ) )
248
+ ) {
249
  $post_type = $_GET['post_type'];
250
  }
251
 
368
  /**
369
  * Calls view function for specific usermeta field type.
370
  *
371
+ * @global object $wpdb
372
+ *
373
  * @param type $field
374
  * @param type $atts (additional attributes: user_id, user_name, user_is_author, user_current)
375
  * @return type
403
  if ( isset( $params['user_id'] ) ) {
404
  $user_id = $params['user_id'];
405
  } else if ( isset( $params['user_name'] ) ) { //Get user by login
406
+ $user_id = $wpdb->get_var(
407
+ $wpdb->prepare(
408
+ "SELECT * FROM " . $wpdb->users . " WHERE user_login = %s",
409
+ $params['user_name']
410
+ )
411
+ );
412
  } else if ( isset( $params['user_is_author'] ) ) { //Get Post author
413
  $user_id = $post->post_author;
414
  } else if ( isset( $params['user_current'] ) ) {//Get current logged user
537
  /**
538
  * Calls view function for specific field type.
539
  *
540
+ * @global object $wpdb
541
+ *
542
  * @param type $field
543
  * @param type $atts
544
  * @return type
547
  $code = '' ) {
548
 
549
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
550
+ global $wpcf, $post, $wpdb;
551
 
552
  // HTML var holds actual output
553
  $html = '';
579
  if ( isset( $params['user_id'] ) ) {
580
  $user_id = $params['user_id'];
581
  } else if ( isset( $params['user_name'] ) ) { //Get user by login
582
+ $user_id = $wpdb->get_var(
583
+ $wpdb->prepare(
584
+ "SELECT * FROM " . $wpdb->users . " WHERE user_login = %s",
585
+ $params['user_name']
586
+ )
587
+ );
588
  } else if ( isset( $params['user_is_author'] ) ) { //Get Post author
589
  $user_id = $post->post_author;
590
  } else if ( isset( $params['user_current'] ) ) {//Get current logged user
701
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
702
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
703
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
 
 
 
704
  wpcf_admin_userprofile_init( $user );
705
  }
706
 
723
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
724
  $groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
725
  $content = '';
726
+
727
  if ( !empty( $groups ) ) {
728
+ global $user_id;
729
+ $user_role = false;
730
+ if ( !empty( $user_id ) ) {
731
+ $user_info = get_userdata($user_id);
732
+ $user_role = isset($user_info->roles) ? array_shift($user_info->roles) : 'subscriber';
733
+ unset($user_info);
734
+ }
735
  foreach ( $groups as $group ) {
736
+ if ( !empty($user_id) ) {
737
+ $for_users = wpcf_admin_get_groups_showfor_by_group($group['id']);
738
+ if ( !empty($for_users) && !in_array($user_role, $for_users) ) {
739
+ continue;
740
+ }
741
+ }
742
+ if ( empty( $group['is_active'] ) ) {
743
+ continue;
744
+ }
745
  $content .= str_replace( "}", '}'.PHP_EOL, wpcf_admin_get_groups_admin_styles_by_group( $group['id'] ) );
746
  $content .= PHP_EOL;
747
  }
990
 
991
  }
992
 
993
+ add_action( 'wp_ajax_wpcf_types_suggest_user', 'wpcf_access_wpcf_types_suggest_user_ajax' );
 
994
 
995
  /**
996
  * Suggest user AJAX.
997
+ *
998
+ * @todo nonce
999
+ * @todo auth
1000
  */
1001
  function wpcf_access_wpcf_types_suggest_user_ajax()
1002
  {
1003
  global $wpdb;
1004
  $users = '';
1005
+ $q = '%'.wptoolset_esc_like(esc_sql( trim( $_GET['q'] ) )).'%';
1006
+ $found = $wpdb->get_results(
1007
+ $wpdb->prepare(
1008
+ "SELECT ID, display_name, user_login FROM $wpdb->users WHERE user_nicename LIKE %s OR user_login LIKE %s OR display_name LIKE %s OR user_email LIKE %s LIMIT %d",
1009
+ $q,
1010
+ $q,
1011
+ $q,
1012
+ $q,
1013
+ 10
1014
+ )
1015
+ );
1016
 
1017
  if ( !empty( $found ) ) {
1018
  foreach ( $found as $user ) {
1037
  }
1038
  else {
1039
  if ( $_POST['display_username_for_suser_selector'] == 'specific_user_by_id' ) {
1040
+ $add .= ' user_id="' . sanitize_text_field($_POST['display_username_for_suser_id_value']) . '"';
1041
  } else {
1042
+ $add .= ' user_name="' . sanitize_text_field($_POST['display_username_for_suser_username_value']) . '"';
1043
  }
1044
  }
1045
  }
1049
  /*
1050
  * Usermeta fields addon.
1051
  * Add form user users
1052
+ *
1053
+ * @global object $wpdb
1054
+ *
1055
+ */
1056
 
1057
  function wpcf_get_usermeta_form_addon( $settings = array() ){
1058
  global $wpdb;
embedded/views/image.php CHANGED
@@ -649,10 +649,12 @@ class Types_Image_Utils
649
  $upload_dir = self::uploadInfo();
650
  if ( $upload_dir ) {
651
  $parsed = parse_url( $imgUrl );
 
 
 
652
  $upload_dir_parsed = parse_url( $upload_dir['baseurl'] );
653
  // This works for regular installation and main blog on multisite
654
- if ( (!is_multisite() || is_main_site()) && strpos( $parsed['path'],
655
- $upload_dir_parsed['path'] ) === 0 ) {
656
  return true;
657
  // Check Multisite
658
  } else if ( is_multisite() && !is_main_site() ) {
649
  $upload_dir = self::uploadInfo();
650
  if ( $upload_dir ) {
651
  $parsed = parse_url( $imgUrl );
652
+ if ( !isset($upload_dir['baseurl'] ) ) {
653
+ return false;
654
+ }
655
  $upload_dir_parsed = parse_url( $upload_dir['baseurl'] );
656
  // This works for regular installation and main blog on multisite
657
+ if ( (!is_multisite() || is_main_site()) && strpos( $parsed['path'], $upload_dir_parsed['path'] ) === 0 ) {
 
658
  return true;
659
  // Check Multisite
660
  } else if ( is_multisite() && !is_main_site() ) {
embedded/views/templates/editor-modal-checkbox.tpl.php CHANGED
@@ -34,11 +34,11 @@ $data = array_merge( array(
34
  <div id="cb-states" class="group-nested" data-bind="visible: cb_mode() == 'value'">
35
  <p>
36
  <label for="cb-sel" class="input-title"><?php _e( 'Selected:', 'wpcf' ); ?></label>
37
- <input id="cb-sel" type="text" name="selected" value="<?php echo $data['selected']; ?>" />
38
  </p>
39
  <p>
40
  <label for="cb-not-sel" class="input-title"><?php _e( 'Not selected:', 'wpcf' ); ?></label>
41
- <input id="cb-not-sel" type="text" name="not_selected" value="<?php echo $data['not_selected']; ?>" />
42
  </p>
43
  </div>
44
 
@@ -49,4 +49,4 @@ $data = array_merge( array(
49
  </div>
50
 
51
 
52
- </script><!--END TYPES MODAL CHECKBOX-->
34
  <div id="cb-states" class="group-nested" data-bind="visible: cb_mode() == 'value'">
35
  <p>
36
  <label for="cb-sel" class="input-title"><?php _e( 'Selected:', 'wpcf' ); ?></label>
37
+ <input id="cb-sel" type="text" name="selected" value="<?php echo $data['selected']; ?>"placeholder="<?php _e('Enter selected value', 'wpcf'); ?>" />
38
  </p>
39
  <p>
40
  <label for="cb-not-sel" class="input-title"><?php _e( 'Not selected:', 'wpcf' ); ?></label>
41
+ <input id="cb-not-sel" type="text" name="not_selected" value="<?php echo $data['not_selected']; ?>" placeholder="<?php _e('Enter not selected value', 'wpcf'); ?>" />
42
  </p>
43
  </div>
44
 
49
  </div>
50
 
51
 
52
+ </script><!--END TYPES MODAL CHECKBOX-->
embedded/views/templates/editor-modal-checkboxes.tpl.php CHANGED
@@ -42,11 +42,11 @@ $data = array_merge( array(
42
  <h3><?php echo $cb[ 'title' ]; ?></h3>
43
  <p>
44
  <label for="cbs-sel-<?php echo $key ?>" class="input-title"><?php _e( 'Selected:', 'wpcf' ); ?></label>
45
- <input id="cbs-sel-<?php echo $key ?>" type="text" name="options[<?php echo $cb[ 'id' ]; ?>][selected]" value="<?php echo $cb[ 'selected' ]; ?>" />
46
  </p>
47
  <p>
48
  <label for="cbs-not-sel-<?php echo $key ?>" class="input-title"><?php _e( 'Not selected:', 'wpcf' ); ?></label>
49
- <input id="cbs-not-sel-<?php echo $key ?>" type="text" name="options[<?php echo $cb[ 'id' ]; ?>][not_selected]" value="<?php echo $cb[ 'not_selected' ]; ?>" />
50
  </p>
51
  </div>
52
  <?php endforeach; ?>
@@ -60,4 +60,4 @@ $data = array_merge( array(
60
 
61
  </div>
62
 
63
- </script><!--END TYPES MODAL CHECKBOXES-->
42
  <h3><?php echo $cb[ 'title' ]; ?></h3>
43
  <p>
44
  <label for="cbs-sel-<?php echo $key ?>" class="input-title"><?php _e( 'Selected:', 'wpcf' ); ?></label>
45
+ <input id="cbs-sel-<?php echo $key ?>" type="text" name="options[<?php echo $cb[ 'id' ]; ?>][selected]" value="<?php echo $cb[ 'selected' ]; ?>" placeholder="<?php _e('Enter selected value', 'wpcf'); ?>" />
46
  </p>
47
  <p>
48
  <label for="cbs-not-sel-<?php echo $key ?>" class="input-title"><?php _e( 'Not selected:', 'wpcf' ); ?></label>
49
+ <input id="cbs-not-sel-<?php echo $key ?>" type="text" name="options[<?php echo $cb[ 'id' ]; ?>][not_selected]" value="<?php echo $cb[ 'not_selected' ]; ?>" placeholder="<?php _e('Enter not selected value', 'wpcf'); ?>" />
50
  </p>
51
  </div>
52
  <?php endforeach; ?>
60
 
61
  </div>
62
 
63
+ </script><!--END TYPES MODAL CHECKBOXES-->
embedded/views/templates/editor-modal-date.tpl.php CHANGED
@@ -27,10 +27,6 @@ $data = array_merge( array(
27
  <input id="date-calendar" type="radio" name="style" value="calendar" data-bind="checked: date_mode, click: dateStyling" />
28
  <label for="date-calendar"><?php _e( 'Show as calendar ', 'wpcf' ); ?></label>
29
  </li>
30
- <li>
31
- <input id="date-human-time-diff" type="radio" name="style" value="human-time-diff" data-bind="checked: date_mode, click: dateStyling" />
32
- <label for="date-human-time-diff"><?php _e( 'Show as human time diff ', 'wpcf' ); ?></label>
33
- </li>
34
  <li>
35
  <input id="date-text" type="radio" name="style" value="text" data-bind="checked: date_mode, click: dateStyling" />
36
  <label for="date-text"><?php _e( 'Show as text', 'wpcf' ); ?></label>
27
  <input id="date-calendar" type="radio" name="style" value="calendar" data-bind="checked: date_mode, click: dateStyling" />
28
  <label for="date-calendar"><?php _e( 'Show as calendar ', 'wpcf' ); ?></label>
29
  </li>
 
 
 
 
30
  <li>
31
  <input id="date-text" type="radio" name="style" value="text" data-bind="checked: date_mode, click: dateStyling" />
32
  <label for="date-text"><?php _e( 'Show as text', 'wpcf' ); ?></label>
help.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Plugin contextual help
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/help.php $
6
  * $LastChangedDate: 2014-05-29 08:44:10 +0000 (Thu, 29 May 2014) $
7
  * $LastChangedRevision: 922956 $
8
  * $LastChangedBy: iworks $
2
  /*
3
  * Plugin contextual help
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/help.php $
6
  * $LastChangedDate: 2014-05-29 08:44:10 +0000 (Thu, 29 May 2014) $
7
  * $LastChangedRevision: 922956 $
8
  * $LastChangedBy: iworks $
includes/ajax.php CHANGED
@@ -2,6 +2,9 @@
2
 
3
  /**
4
  * All AJAX calls go here.
 
 
 
5
  */
6
  function wpcf_ajax() {
7
  if (!current_user_can('manage_options')
@@ -23,10 +26,12 @@ function wpcf_ajax() {
23
  case 'delete_usermeta':
24
  require_once WPCF_INC_ABSPATH . '/fields.php';
25
  if (isset($_GET['field_id'])) {
26
- wpcf_admin_fields_delete_field($_GET['field_id'],'wp-types-user-group','wpcf-usermeta');
 
27
  }
28
  if (isset($_GET['field'])) {
29
- wpcf_admin_fields_delete_field($_GET['field'],'wp-types-user-group','wpcf-usermeta');
 
30
  }
31
  echo json_encode(array(
32
  'output' => ''
@@ -58,6 +63,8 @@ function wpcf_ajax() {
58
  . '\');jQuery(".wpcf-table-column-active-'
59
  . intval($_GET['group_id']) . '").html("' . __('No', 'wpcf') . '");',
60
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
 
 
61
  ));
62
  } else {
63
  echo json_encode(array(
@@ -79,6 +86,8 @@ function wpcf_ajax() {
79
  . '\');jQuery(".wpcf-table-column-active-'
80
  . intval($_GET['group_id']) . '").html("' . __('Yes', 'wpcf') . '");',
81
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
 
 
82
  ));
83
  } else {
84
  echo json_encode(array(
@@ -129,8 +138,8 @@ function wpcf_ajax() {
129
  case 'remove_field_from_group':
130
  require_once WPCF_INC_ABSPATH . '/fields.php';
131
  if (isset($_GET['group_id']) && isset($_GET['field_id'])) {
132
- wpcf_admin_fields_remove_field_from_group($_GET['group_id'],
133
- $_GET['field_id']);
134
  }
135
  break;
136
 
@@ -146,6 +155,8 @@ function wpcf_ajax() {
146
  . '\');jQuery(".wpcf-table-column-active-'
147
  . intval($_GET['group_id']) . '").html("' . __('No', 'wpcf') . '");',
148
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
 
 
149
  ));
150
  } else {
151
  echo json_encode(array(
@@ -166,6 +177,8 @@ function wpcf_ajax() {
166
  . '\');jQuery(".wpcf-table-column-active-'
167
  . intval($_GET['group_id']) . '").html("' . __('Yes', 'wpcf') . '");',
168
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
 
 
169
  ));
170
  } else {
171
  echo json_encode(array(
@@ -194,15 +207,16 @@ function wpcf_ajax() {
194
  $custom_types = get_option('wpcf-custom-types', array());
195
  if (isset($custom_types[$_GET['wpcf-post-type']])) {
196
  $custom_types[$_GET['wpcf-post-type']]['disabled'] = 1;
 
197
  update_option('wpcf-custom-types', $custom_types);
198
  echo json_encode(array(
199
  'output' => __('Post type deactivated', 'wpcf'),
200
  'execute' => 'jQuery("#wpcf-list-activate-'
201
- . $_GET['wpcf-post-type'] . '").replaceWith(\''
202
  . wpcf_admin_custom_types_get_ajax_activation_link(esc_attr(
203
  $_GET['wpcf-post-type']))
204
  . '\');jQuery(".wpcf-table-column-active-'
205
- . $_GET['wpcf-post-type'] . '").html("' . __('No', 'wpcf') . '");',
206
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
207
  ));
208
  } else {
@@ -220,14 +234,15 @@ function wpcf_ajax() {
220
  $custom_types = get_option('wpcf-custom-types', array());
221
  if (isset($custom_types[$_GET['wpcf-post-type']])) {
222
  $custom_types[$_GET['wpcf-post-type']]['disabled'] = 0;
 
223
  update_option('wpcf-custom-types', $custom_types);
224
  echo json_encode(array(
225
  'output' => __('Post type activated', 'wpcf'),
226
  'execute' => 'jQuery("#wpcf-list-activate-'
227
- . $_GET['wpcf-post-type'] . '").replaceWith(\''
228
- . wpcf_admin_custom_types_get_ajax_deactivation_link($_GET['wpcf-post-type'])
229
  . '\');jQuery(".wpcf-table-column-active-'
230
- . $_GET['wpcf-post-type'] . '").html("' . __('Yes', 'wpcf') . '");',
231
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
232
  ));
233
  } else {
@@ -245,9 +260,17 @@ function wpcf_ajax() {
245
  $custom_type = strval($_GET['wpcf-post-type']);
246
 
247
  /**
248
- * delete relataion?
 
 
 
 
 
 
 
 
249
  */
250
- if ( apply_filters('wpcf_delete_relation_meta', false) ) {
251
  global $wpdb;
252
  $wpdb->delete(
253
  $wpdb->postmeta,
@@ -270,6 +293,7 @@ function wpcf_ajax() {
270
  && array_key_exists( $custom_type, $custom_types[$post_type]['post_relationship']['has'] )
271
  ) {
272
  unset($custom_types[$post_type]['post_relationship']['has'][$custom_type]);
 
273
  }
274
  /**
275
  * remove "belongs" relation
@@ -279,6 +303,7 @@ function wpcf_ajax() {
279
  && array_key_exists( $custom_type, $custom_types[$post_type]['post_relationship']['belongs'] )
280
  ) {
281
  unset($custom_types[$post_type]['post_relationship']['belongs'][$custom_type]);
 
282
  }
283
  }
284
  }
@@ -287,7 +312,7 @@ function wpcf_ajax() {
287
  echo json_encode(array(
288
  'output' => '',
289
  'execute' => 'jQuery("#wpcf-list-activate-'
290
- . $_GET['wpcf-post-type']
291
  . '").parents("tr").css("background-color", "#FF0000").fadeOut();',
292
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
293
  ));
@@ -301,14 +326,15 @@ function wpcf_ajax() {
301
  $custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
302
  if (isset($custom_taxonomies[$_GET['wpcf-tax']])) {
303
  $custom_taxonomies[$_GET['wpcf-tax']]['disabled'] = 1;
 
304
  update_option('wpcf-custom-taxonomies', $custom_taxonomies);
305
  echo json_encode(array(
306
  'output' => __('Taxonomy deactivated', 'wpcf'),
307
  'execute' => 'jQuery("#wpcf-list-activate-'
308
- . $_GET['wpcf-tax'] . '").replaceWith(\''
309
- . wpcf_admin_custom_taxonomies_get_ajax_activation_link($_GET['wpcf-tax'])
310
  . '\');jQuery(".wpcf-table-column-active-'
311
- . $_GET['wpcf-tax'] . '").html("' . __('No', 'wpcf') . '");',
312
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
313
  ));
314
  } else {
@@ -326,14 +352,15 @@ function wpcf_ajax() {
326
  $custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
327
  if (isset($custom_taxonomies[$_GET['wpcf-tax']])) {
328
  $custom_taxonomies[$_GET['wpcf-tax']]['disabled'] = 0;
 
329
  update_option('wpcf-custom-taxonomies', $custom_taxonomies);
330
  echo json_encode(array(
331
  'output' => __('Taxonomy activated', 'wpcf'),
332
  'execute' => 'jQuery("#wpcf-list-activate-'
333
- . $_GET['wpcf-tax'] . '").replaceWith(\''
334
- . wpcf_admin_custom_taxonomies_get_ajax_deactivation_link($_GET['wpcf-tax'])
335
  . '\');jQuery(".wpcf-table-column-active-'
336
- . $_GET['wpcf-tax'] . '").html("' . __('Yes', 'wpcf') . '");',
337
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
338
  ));
339
  } else {
@@ -355,7 +382,7 @@ function wpcf_ajax() {
355
  echo json_encode(array(
356
  'output' => '',
357
  'execute' => 'jQuery("#wpcf-list-activate-'
358
- . $_GET['wpcf-tax']
359
  . '").parents("tr").css("background-color", "#FF0000").fadeOut();',
360
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
361
  ));
@@ -404,24 +431,25 @@ function wpcf_ajax() {
404
 
405
  case 'group_form_collapsed':
406
  require_once WPCF_INC_ABSPATH . '/fields-form.php';
407
- $group_id = $_GET['group_id'];
408
- $action = $_GET['toggle'];
409
- $fieldset = $_GET['id'];
410
  wpcf_admin_fields_form_save_open_fieldset($action, $fieldset,
411
  $group_id);
412
  break;
413
 
414
  case 'form_fieldset_toggle':
415
- $action = $_GET['toggle'];
416
- $fieldset = $_GET['id'];
417
  wpcf_admin_form_fieldset_save_toggle($action, $fieldset);
418
  break;
419
 
420
  case 'group_update_post_types':
421
  require_once WPCF_INC_ABSPATH . '/fields.php';
 
422
  $post_types = empty($_GET['wpcf']['group']['supports']) ? array() : $_GET['wpcf']['group']['supports'];
423
  if (!empty($_GET['group_id'])) {
424
- wpcf_admin_fields_save_group_post_types($_GET['group_id'],
425
  $post_types);
426
  $output = array();
427
  foreach ($post_types as $post_type) {
@@ -452,7 +480,7 @@ function wpcf_ajax() {
452
  }
453
  }
454
  if (!empty($_GET['group_id'])) {
455
- wpcf_admin_fields_save_group_terms($_GET['group_id'], $terms);
456
  $output = array();
457
  foreach ($taxonomies_post as $taxonomy => $terms) {
458
  $taxonomy = get_taxonomy($taxonomy);
@@ -488,10 +516,10 @@ function wpcf_ajax() {
488
  case 'delete_field':
489
  require_once WPCF_INC_ABSPATH . '/fields.php';
490
  if (isset($_GET['field_id'])) {
491
- wpcf_admin_fields_delete_field($_GET['field_id']);
492
  }
493
  if (isset($_GET['field'])) {
494
- wpcf_admin_fields_delete_field($_GET['field']);
495
  }
496
  echo json_encode(array(
497
  'output' => ''
@@ -523,7 +551,7 @@ function wpcf_ajax() {
523
  ));
524
  } else {
525
  $data['id'] = str_replace('_conditional_display', '',
526
- $_GET['field']);
527
  $output = wpcf_form_simple(wpcf_cd_admin_form_single_filter($data,
528
  array(), null, false));
529
  if (!empty($data['id'])) {
@@ -547,7 +575,7 @@ function wpcf_ajax() {
547
  if (!empty($_GET['parent']) && !empty($_GET['child'])) {
548
  require_once WPCF_INC_ABSPATH . '/fields.php';
549
  require_once WPCF_INC_ABSPATH . '/post-relationship.php';
550
- wpcf_pr_admin_edit_fields($_GET['parent'], $_GET['child']);
551
  }
552
  break;
553
 
@@ -571,8 +599,8 @@ function wpcf_ajax() {
571
  if (isset($_GET['field']) && isset($_GET['subaction'])) {
572
  require_once WPCF_INC_ABSPATH . '/fields.php';
573
  $option = $_GET['meta_type'] == 'usermeta' ? 'wpcf-usermeta' : 'wpcf-fields';
574
- $meta_type = $_GET['meta_type'];
575
- $field = wpcf_admin_fields_get_field($_GET['field'], false, false,
576
  false, $option);
577
 
578
  $_txt_updates = $meta_type == 'usermeta' ? __( '%d users require update',
@@ -595,7 +623,7 @@ function wpcf_ajax() {
595
  . sprintf($_txt_updates, count($posts)) . '&nbsp;'
596
  . '<a href="javascript:void(0);" class="button-primary" onclick="'
597
  . 'wpcfCbSaveEmptyMigrate(jQuery(this).parent().parent().parent(), \''
598
- . $_GET['field'] . '\', '
599
  . count($posts) . ', \''
600
  . wp_create_nonce('cb_save_empty_migrate') . '\', \'';
601
  $output .= $_GET['subaction'] == 'save_check' ? 'save' : 'do_not_save';
@@ -623,7 +651,7 @@ function wpcf_ajax() {
623
  $output = '<script type="text/javascript">wpcfCbMigrateStep('
624
  . intval($_GET['total']) . ','
625
  . $posts['offset'] . ','
626
- . '\'' . $_GET['field'] . '\','
627
  . '\'' . wp_create_nonce('cb_save_empty_migrate')
628
  . '\', \'' . $meta_type . '\');</script>'
629
  . number_format($posts['offset'])
2
 
3
  /**
4
  * All AJAX calls go here.
5
+ *
6
+ * @global object $wpdb
7
+ *
8
  */
9
  function wpcf_ajax() {
10
  if (!current_user_can('manage_options')
26
  case 'delete_usermeta':
27
  require_once WPCF_INC_ABSPATH . '/fields.php';
28
  if (isset($_GET['field_id'])) {
29
+ $field_id = sanitize_text_field( $_GET['field_id'] );
30
+ wpcf_admin_fields_delete_field($field_id,'wp-types-user-group','wpcf-usermeta');
31
  }
32
  if (isset($_GET['field'])) {
33
+ $field = sanitize_text_field( $_GET['field'] );
34
+ wpcf_admin_fields_delete_field($field,'wp-types-user-group','wpcf-usermeta');
35
  }
36
  echo json_encode(array(
37
  'output' => ''
63
  . '\');jQuery(".wpcf-table-column-active-'
64
  . intval($_GET['group_id']) . '").html("' . __('No', 'wpcf') . '");',
65
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
66
+ 'status' => 'inactive',
67
+ 'status_label' => __('No', 'wpcf'),
68
  ));
69
  } else {
70
  echo json_encode(array(
86
  . '\');jQuery(".wpcf-table-column-active-'
87
  . intval($_GET['group_id']) . '").html("' . __('Yes', 'wpcf') . '");',
88
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
89
+ 'status' => 'active',
90
+ 'status_label' => __('Yes', 'wpcf'),
91
  ));
92
  } else {
93
  echo json_encode(array(
138
  case 'remove_field_from_group':
139
  require_once WPCF_INC_ABSPATH . '/fields.php';
140
  if (isset($_GET['group_id']) && isset($_GET['field_id'])) {
141
+ wpcf_admin_fields_remove_field_from_group(intval($_GET['group_id']),
142
+ sanitize_text_field($_GET['field_id']));
143
  }
144
  break;
145
 
155
  . '\');jQuery(".wpcf-table-column-active-'
156
  . intval($_GET['group_id']) . '").html("' . __('No', 'wpcf') . '");',
157
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
158
+ 'status' => 'inactive',
159
+ 'status_label' => __('No', 'wpcf'),
160
  ));
161
  } else {
162
  echo json_encode(array(
177
  . '\');jQuery(".wpcf-table-column-active-'
178
  . intval($_GET['group_id']) . '").html("' . __('Yes', 'wpcf') . '");',
179
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
180
+ 'status' => 'active',
181
+ 'status_label' => __('Yes', 'wpcf'),
182
  ));
183
  } else {
184
  echo json_encode(array(
207
  $custom_types = get_option('wpcf-custom-types', array());
208
  if (isset($custom_types[$_GET['wpcf-post-type']])) {
209
  $custom_types[$_GET['wpcf-post-type']]['disabled'] = 1;
210
+ $custom_types[$_GET['wpcf-post-type']][TOOLSET_EDIT_LAST] = time();
211
  update_option('wpcf-custom-types', $custom_types);
212
  echo json_encode(array(
213
  'output' => __('Post type deactivated', 'wpcf'),
214
  'execute' => 'jQuery("#wpcf-list-activate-'
215
+ . sanitize_text_field($_GET['wpcf-post-type']) . '").replaceWith(\''
216
  . wpcf_admin_custom_types_get_ajax_activation_link(esc_attr(
217
  $_GET['wpcf-post-type']))
218
  . '\');jQuery(".wpcf-table-column-active-'
219
+ . sanitize_text_field($_GET['wpcf-post-type']) . '").html("' . __('No', 'wpcf') . '");',
220
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
221
  ));
222
  } else {
234
  $custom_types = get_option('wpcf-custom-types', array());
235
  if (isset($custom_types[$_GET['wpcf-post-type']])) {
236
  $custom_types[$_GET['wpcf-post-type']]['disabled'] = 0;
237
+ $custom_types[$_GET['wpcf-post-type']][TOOLSET_EDIT_LAST] = time();
238
  update_option('wpcf-custom-types', $custom_types);
239
  echo json_encode(array(
240
  'output' => __('Post type activated', 'wpcf'),
241
  'execute' => 'jQuery("#wpcf-list-activate-'
242
+ . sanitize_text_field($_GET['wpcf-post-type']) . '").replaceWith(\''
243
+ . wpcf_admin_custom_types_get_ajax_deactivation_link(sanitize_text_field($_GET['wpcf-post-type']))
244
  . '\');jQuery(".wpcf-table-column-active-'
245
+ . sanitize_text_field($_GET['wpcf-post-type']) . '").html("' . __('Yes', 'wpcf') . '");',
246
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
247
  ));
248
  } else {
260
  $custom_type = strval($_GET['wpcf-post-type']);
261
 
262
  /**
263
+ * Delete relation between custom posts types
264
+ *
265
+ * Filter allow to delete all custom fields used to make
266
+ * a relation between posts.
267
+ *
268
+ * @since 1.6.4
269
+ *
270
+ * @param bool $delete True or false flag to delete relationships.
271
+ * @param string $var Currently deleted custom post type.
272
  */
273
+ if ( apply_filters('wpcf_delete_relation_meta', false, $custom_type) ) {
274
  global $wpdb;
275
  $wpdb->delete(
276
  $wpdb->postmeta,
293
  && array_key_exists( $custom_type, $custom_types[$post_type]['post_relationship']['has'] )
294
  ) {
295
  unset($custom_types[$post_type]['post_relationship']['has'][$custom_type]);
296
+ $custom_types[$post_type][TOOLSET_EDIT_LAST] = time();
297
  }
298
  /**
299
  * remove "belongs" relation
303
  && array_key_exists( $custom_type, $custom_types[$post_type]['post_relationship']['belongs'] )
304
  ) {
305
  unset($custom_types[$post_type]['post_relationship']['belongs'][$custom_type]);
306
+ $custom_types[$post_type][TOOLSET_EDIT_LAST] = time();
307
  }
308
  }
309
  }
312
  echo json_encode(array(
313
  'output' => '',
314
  'execute' => 'jQuery("#wpcf-list-activate-'
315
+ . sanitize_text_field($_GET['wpcf-post-type'])
316
  . '").parents("tr").css("background-color", "#FF0000").fadeOut();',
317
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
318
  ));
326
  $custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
327
  if (isset($custom_taxonomies[$_GET['wpcf-tax']])) {
328
  $custom_taxonomies[$_GET['wpcf-tax']]['disabled'] = 1;
329
+ $custom_taxonomies[$_GET['wpcf-tax']][TOOLSET_EDIT_LAST] = time();
330
  update_option('wpcf-custom-taxonomies', $custom_taxonomies);
331
  echo json_encode(array(
332
  'output' => __('Taxonomy deactivated', 'wpcf'),
333
  'execute' => 'jQuery("#wpcf-list-activate-'
334
+ . sanitize_text_field($_GET['wpcf-tax']) . '").replaceWith(\''
335
+ . wpcf_admin_custom_taxonomies_get_ajax_activation_link(sanitize_text_field($_GET['wpcf-tax']))
336
  . '\');jQuery(".wpcf-table-column-active-'
337
+ . sanitize_text_field($_GET['wpcf-tax']) . '").html("' . __('No', 'wpcf') . '");',
338
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
339
  ));
340
  } else {
352
  $custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
353
  if (isset($custom_taxonomies[$_GET['wpcf-tax']])) {
354
  $custom_taxonomies[$_GET['wpcf-tax']]['disabled'] = 0;
355
+ $custom_taxonomies[$_GET['wpcf-tax']][TOOLSET_EDIT_LAST] = time();
356
  update_option('wpcf-custom-taxonomies', $custom_taxonomies);
357
  echo json_encode(array(
358
  'output' => __('Taxonomy activated', 'wpcf'),
359
  'execute' => 'jQuery("#wpcf-list-activate-'
360
+ . sanitize_text_field($_GET['wpcf-tax']) . '").replaceWith(\''
361
+ . wpcf_admin_custom_taxonomies_get_ajax_deactivation_link(sanitize_text_field($_GET['wpcf-tax']))
362
  . '\');jQuery(".wpcf-table-column-active-'
363
+ . sanitize_text_field($_GET['wpcf-tax']) . '").html("' . __('Yes', 'wpcf') . '");',
364
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
365
  ));
366
  } else {
382
  echo json_encode(array(
383
  'output' => '',
384
  'execute' => 'jQuery("#wpcf-list-activate-'
385
+ . sanitize_text_field($_GET['wpcf-tax'])
386
  . '").parents("tr").css("background-color", "#FF0000").fadeOut();',
387
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
388
  ));
431
 
432
  case 'group_form_collapsed':
433
  require_once WPCF_INC_ABSPATH . '/fields-form.php';
434
+ $group_id = sanitize_text_field($_GET['group_id']);
435
+ $action = sanitize_text_field($_GET['toggle']);
436
+ $fieldset = sanitize_text_field($_GET['id']);
437
  wpcf_admin_fields_form_save_open_fieldset($action, $fieldset,
438
  $group_id);
439
  break;
440
 
441
  case 'form_fieldset_toggle':
442
+ $action = sanitize_text_field($_GET['toggle']);
443
+ $fieldset = sanitize_text_field($_GET['id']);
444
  wpcf_admin_form_fieldset_save_toggle($action, $fieldset);
445
  break;
446
 
447
  case 'group_update_post_types':
448
  require_once WPCF_INC_ABSPATH . '/fields.php';
449
+ // @todo Sanitize this $post_types
450
  $post_types = empty($_GET['wpcf']['group']['supports']) ? array() : $_GET['wpcf']['group']['supports'];
451
  if (!empty($_GET['group_id'])) {
452
+ wpcf_admin_fields_save_group_post_types(sanitize_text_field($_GET['group_id']),
453
  $post_types);
454
  $output = array();
455
  foreach ($post_types as $post_type) {
480
  }
481
  }
482
  if (!empty($_GET['group_id'])) {
483
+ wpcf_admin_fields_save_group_terms(sanitize_text_field($_GET['group_id']), $terms);
484
  $output = array();
485
  foreach ($taxonomies_post as $taxonomy => $terms) {
486
  $taxonomy = get_taxonomy($taxonomy);
516
  case 'delete_field':
517
  require_once WPCF_INC_ABSPATH . '/fields.php';
518
  if (isset($_GET['field_id'])) {
519
+ wpcf_admin_fields_delete_field(sanitize_text_field($_GET['field_id']));
520
  }
521
  if (isset($_GET['field'])) {
522
+ wpcf_admin_fields_delete_field(sanitize_text_field($_GET['field']));
523
  }
524
  echo json_encode(array(
525
  'output' => ''
551
  ));
552
  } else {
553
  $data['id'] = str_replace('_conditional_display', '',
554
+ sanitize_text_field($_GET['field']));
555
  $output = wpcf_form_simple(wpcf_cd_admin_form_single_filter($data,
556
  array(), null, false));
557
  if (!empty($data['id'])) {
575
  if (!empty($_GET['parent']) && !empty($_GET['child'])) {
576
  require_once WPCF_INC_ABSPATH . '/fields.php';
577
  require_once WPCF_INC_ABSPATH . '/post-relationship.php';
578
+ wpcf_pr_admin_edit_fields(sanitize_text_field($_GET['parent']), sanitize_text_field($_GET['child']));
579
  }
580
  break;
581
 
599
  if (isset($_GET['field']) && isset($_GET['subaction'])) {
600
  require_once WPCF_INC_ABSPATH . '/fields.php';
601
  $option = $_GET['meta_type'] == 'usermeta' ? 'wpcf-usermeta' : 'wpcf-fields';
602
+ $meta_type = sanitize_text_field($_GET['meta_type']);
603
+ $field = wpcf_admin_fields_get_field(sanitize_text_field($_GET['field']), false, false,
604
  false, $option);
605
 
606
  $_txt_updates = $meta_type == 'usermeta' ? __( '%d users require update',
623
  . sprintf($_txt_updates, count($posts)) . '&nbsp;'
624
  . '<a href="javascript:void(0);" class="button-primary" onclick="'
625
  . 'wpcfCbSaveEmptyMigrate(jQuery(this).parent().parent().parent(), \''
626
+ . sanitize_text_field($_GET['field']) . '\', '
627
  . count($posts) . ', \''
628
  . wp_create_nonce('cb_save_empty_migrate') . '\', \'';
629
  $output .= $_GET['subaction'] == 'save_check' ? 'save' : 'do_not_save';
651
  $output = '<script type="text/javascript">wpcfCbMigrateStep('
652
  . intval($_GET['total']) . ','
653
  . $posts['offset'] . ','
654
+ . '\'' . sanitize_text_field($_GET['field']) . '\','
655
  . '\'' . wp_create_nonce('cb_save_empty_migrate')
656
  . '\', \'' . $meta_type . '\');</script>'
657
  . number_format($posts['offset'])
includes/classes/class.wpcf.custom.fields.list.table.php ADDED
@@ -0,0 +1,486 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*************************** LOAD THE BASE CLASS *******************************
4
+ *******************************************************************************
5
+ * The WP_List_Table class isn't automatically available to plugins, so we need
6
+ * to check if it's available and load it if necessary. In this tutorial, we are
7
+ * going to use the WP_List_Table class directly from WordPress core.
8
+ *
9
+ * IMPORTANT:
10
+ * Please note that the WP_List_Table class technically isn't an official API,
11
+ * and it could change at some point in the distant future. Should that happen,
12
+ * I will update this plugin with the most current techniques for your reference
13
+ * immediately.
14
+ *
15
+ * If you are really worried about future compatibility, you can make a copy of
16
+ * the WP_List_Table class (file path is shown just below) to use and distribute
17
+ * with your plugins. If you do that, just remember to change the name of the
18
+ * class to avoid conflicts with core.
19
+ *
20
+ * Since I will be keeping this tutorial up-to-date for the foreseeable future,
21
+ * I am going to work with the copy of the class provided in WordPress core.
22
+ */
23
+ if(!class_exists('WP_List_Table')){
24
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
25
+ }
26
+
27
+ /************************** CREATE A PACKAGE CLASS *****************************
28
+ *******************************************************************************
29
+ * Create a new list table package that extends the core WP_List_Table class.
30
+ * WP_List_Table contains most of the framework for generating the table, but we
31
+ * need to define and override some methods so that our data can be displayed
32
+ * exactly the way we need it to be.
33
+ *
34
+ * To display this example on a page, you will first need to instantiate the class,
35
+ * then call $yourInstance->prepare_items() to handle any data manipulation, then
36
+ * finally call $yourInstance->display() to render the table to the page.
37
+ *
38
+ * Our theme for this list table is going to be movies.
39
+ */
40
+ class WPCF_Custom_Fields_List_Table extends WP_List_Table
41
+ {
42
+ var $bulk_action_field_name = 'wpcf_cf_ids';
43
+ /** ************************************************************************
44
+ * REQUIRED. Set up a constructor that references the parent constructor. We
45
+ * use the parent reference to set some default configs.
46
+ ***************************************************************************/
47
+ function __construct()
48
+ {
49
+ global $status, $page;
50
+
51
+ //Set parent defaults
52
+ parent::__construct( array(
53
+ 'singular' => 'custom field group', //singular name of the listed records
54
+ 'plural' => 'custom field groups', //plural name of the listed records
55
+ 'ajax' => true //does this table support ajax?
56
+ ) );
57
+ }
58
+
59
+ /** ************************************************************************
60
+ * Recommended. This method is called when the parent class can't find a method
61
+ * specifically build for a given column. Generally, it's recommended to include
62
+ * one method for each column you want to render, keeping your package class
63
+ * neat and organized. For example, if the class needs to process a column
64
+ * named 'title', it would first see if a method named $this->column_title()
65
+ * exists - if it does, that method will be used. If it doesn't, this one will
66
+ * be used. Generally, you should try to use custom column methods as much as
67
+ * possible.
68
+ *
69
+ * Since we have defined a column_title() method later on, this method doesn't
70
+ * need to concern itself with any column with a name of 'title'. Instead, it
71
+ * needs to handle everything else.
72
+ *
73
+ * For more detailed insight into how columns are handled, take a look at
74
+ * WP_List_Table::single_row_columns()
75
+ *
76
+ * @param array $item A singular item (one full row's worth of data)
77
+ * @param array $column_name The name/slug of the column to be processed
78
+ * @return string Text or HTML to be placed inside the column <td>
79
+ **************************************************************************/
80
+ function column_default($item, $column_name)
81
+ {
82
+ switch($column_name){
83
+ case 'title':
84
+ case 'description':
85
+ return $item[$column_name];
86
+ case 'post_types':
87
+ $post_types = wpcf_admin_get_post_types_by_group($item['id']);
88
+ return empty($post_types) ? __('All post types', 'wpcf') : implode(', ', $post_types);
89
+ break;
90
+ case 'taxonomies':
91
+ $taxonomies = wpcf_admin_get_taxonomies_by_group($item['id']);
92
+ $output = '';
93
+ if (empty($taxonomies)) {
94
+ $output = __('None', 'wpcf');
95
+ } else {
96
+ foreach ($taxonomies as $taxonomy => $terms) {
97
+ $output .= '<em>' . $taxonomy . '</em>: ';
98
+ $terms_output = array();
99
+ foreach ($terms as $term_id => $term) {
100
+ $terms_output[] = $term['name'];
101
+ }
102
+ $output .= implode(', ', $terms_output) . '<br />';
103
+ }
104
+ }
105
+ return $output;
106
+ case 'status':
107
+ return 'active' == $item[$column_name]? __('Yes', 'wpcf'):__('No', 'wpcf');
108
+ default:
109
+ return print_r($item,true); //Show the whole array for troubleshooting purposes
110
+ }
111
+ }
112
+
113
+ /** ************************************************************************
114
+ * Recommended. This is a custom column method and is responsible for what
115
+ * is rendered in any column with a name/slug of 'title'. Every time the class
116
+ * needs to render a column, it first looks for a method named
117
+ * column_{$column_title} - if it exists, that method is run. If it doesn't
118
+ * exist, column_default() is called instead.
119
+ *
120
+ * This example also illustrates how to implement rollover actions. Actions
121
+ * should be an associative array formatted as 'slug'=>'link html' - and you
122
+ * will need to generate the URLs yourself. You could even ensure the links
123
+ *
124
+ *
125
+ * @see WP_List_Table::::single_row_columns()
126
+ * @param array $item A singular item (one full row's worth of data)
127
+ * @return string Text to be placed inside the column <td> (movie title only)
128
+ **************************************************************************/
129
+ function column_title($item)
130
+ {
131
+ $edit_link = add_query_arg(
132
+ array(
133
+ 'page' => 'wpcf-edit',
134
+ 'group_id' => $item['id']
135
+ ),
136
+ admin_url('admin.php')
137
+ );
138
+
139
+ //Build row actions
140
+ $actions = array(
141
+ 'edit' => sprintf('<a href="%s">%s</a>', $edit_link, __('Edit', 'wpcf')),
142
+ 'status' => 'active' == $item['status']? wpcf_admin_fields_get_ajax_deactivation_link($item['id']):wpcf_admin_fields_get_ajax_activation_link($item['id']),
143
+ 'delete' => sprintf(
144
+ '<a href="%s" class="submitdelete wpcf-ajax-link" id="wpcf-list-delete-%d"">%s</a>',
145
+ add_query_arg(
146
+ array(
147
+ 'action' => 'wpcf_ajax',
148
+ 'wpcf_action' => 'delete_group',
149
+ 'group_id' => $item['id'],
150
+ 'wpcf_ajax_update' => 'wpcf_list_ajax_response_'.$item['id'],
151
+ 'wpcf_ajax_callback' => 'wpcfRefresh',
152
+ '_wpnonce' => wp_create_nonce('delete_group'),
153
+ 'wpcf_warning' => urlencode(__('Are you sure?', 'wpcf')),
154
+ ),
155
+ admin_url('admin-ajax.php')
156
+ ),
157
+ $item['id'],
158
+ __('Delete', 'wpcf')
159
+ ),
160
+ );
161
+
162
+ //Return the title contents
163
+ return sprintf(
164
+ '<strong><a href="%s" class="row-title">%s</strong>%s',
165
+ $edit_link,
166
+ $item['title'],
167
+ $this->row_actions($actions)
168
+ );
169
+ }
170
+
171
+ /** ************************************************************************
172
+ * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column
173
+ * is given special treatment when columns are processed. It ALWAYS needs to
174
+ * have it's own method.
175
+ *
176
+ * @see WP_List_Table::::single_row_columns()
177
+ * @param array $item A singular item (one full row's worth of data)
178
+ * @return string Text to be placed inside the column <td> (movie title only)
179
+ **************************************************************************/
180
+ function column_cb($item)
181
+ {
182
+ return sprintf(
183
+ '<input type="checkbox" name="%s[]" value="%s" />',
184
+ $this->bulk_action_field_name,
185
+ $item['id']
186
+ );
187
+ }
188
+
189
+ /** ************************************************************************
190
+ * REQUIRED! This method dictates the table's columns and titles. This should
191
+ * return an array where the key is the column slug (and class) and the value
192
+ * is the column's title text. If you need a checkbox for bulk actions, refer
193
+ * to the $columns array below.
194
+ *
195
+ * The 'cb' column is treated differently than the rest. If including a checkbox
196
+ * column in your table you must create a column_cb() method. If you don't need
197
+ * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
198
+ *
199
+ * @see WP_List_Table::::single_row_columns()
200
+ * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
201
+ **************************************************************************/
202
+ function get_columns()
203
+ {
204
+ $columns = array(
205
+ 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
206
+ 'title' => __('Group Name', 'wpcf'),
207
+ 'description' => __('Description', 'wpcf'),
208
+ 'status' => __('Active', 'wpcf'),
209
+ 'post_types' => __('Post types', 'wpcf'),
210
+ 'taxonomies' => __('Taxonomies', 'wpcf'),
211
+ );
212
+ return $columns;
213
+ }
214
+
215
+ /** ************************************************************************
216
+ * Optional. If you want one or more columns to be sortable (ASC/DESC toggle),
217
+ * you will need to register it here. This should return an array where the
218
+ * key is the column that needs to be sortable, and the value is db column to
219
+ * sort by. Often, the key and value will be the same, but this is not always
220
+ * the case (as the value is a column name from the database, not the list table).
221
+ *
222
+ * This method merely defines which columns should be sortable and makes them
223
+ * clickable - it does not handle the actual sorting. You still need to detect
224
+ * the ORDERBY and ORDER querystring variables within prepare_items() and sort
225
+ * your data accordingly (usually by modifying your query).
226
+ *
227
+ * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
228
+ **************************************************************************/
229
+ function get_sortable_columns()
230
+ {
231
+ $sortable_columns = array(
232
+ 'title' => array('title',true), //true means it's already sorted
233
+ 'description' => array('description',false),
234
+ 'status' => array('status',false)
235
+ );
236
+ return $sortable_columns;
237
+ }
238
+
239
+ /** ************************************************************************
240
+ * Optional. If you need to include bulk actions in your list table, this is
241
+ * the place to define them. Bulk actions are an associative array in the format
242
+ * 'slug'=>'Visible Title'
243
+ *
244
+ * If this method returns an empty value, no bulk action will be rendered. If
245
+ * you specify any bulk actions, the bulk actions box will be rendered with
246
+ * the table automatically on display().
247
+ *
248
+ * Also note that list tables are not automatically wrapped in <form> elements,
249
+ * so you will need to create those manually in order for bulk actions to function.
250
+ *
251
+ * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
252
+ **************************************************************************/
253
+ function get_bulk_actions()
254
+ {
255
+ $actions = array(
256
+ 'activate' => __('Activate', 'wpcf'),
257
+ 'deactivate' => __('Deactivate', 'wpcf'),
258
+ );
259
+ return $actions;
260
+ }
261
+
262
+ /** ************************************************************************
263
+ * Optional. You can handle your bulk actions anywhere or anyhow you prefer.
264
+ * For this example package, we will handle it in the class to keep things
265
+ * clean and organized.
266
+ *
267
+ * @global object $wpdb
268
+ *
269
+ * @see $this->prepare_items()
270
+ **************************************************************************/
271
+ function process_bulk_action()
272
+ {
273
+ global $wpdb;
274
+ $action = $this->current_action();
275
+ //Detect when a bulk action is being triggered...
276
+ switch($action) {
277
+ case 'deactivate':
278
+ if (
279
+ true
280
+ && isset($_POST[$this->bulk_action_field_name])
281
+ && !empty($_POST[$this->bulk_action_field_name])
282
+ ) {
283
+ foreach( $_POST[$this->bulk_action_field_name] as $key ) {
284
+ $wpdb->update(
285
+ $wpdb->posts,
286
+ array( 'post_status' => 'draft' ),
287
+ array( 'ID' => $key, 'post_type' => 'wp-types-group' ),
288
+ array('%s'),
289
+ array('%d', '%s')
290
+ );
291
+ }
292
+ }
293
+ break;
294
+ case 'activate':
295
+ if (
296
+ true
297
+ && isset($_POST[$this->bulk_action_field_name])
298
+ && !empty($_POST[$this->bulk_action_field_name])
299
+ ) {
300
+ foreach( $_POST[$this->bulk_action_field_name] as $key ) {
301
+ $wpdb->update(
302
+ $wpdb->posts,
303
+ array( 'post_status' => 'publish' ),
304
+ array( 'ID' => $key ),
305
+ array('%s'),
306
+ array('%d')
307
+ );
308
+ }
309
+ }
310
+ break;
311
+ }
312
+ wp_cache_delete(md5('group::_get_group'.'wp-types-group'),'types_cache_groups');
313
+ }
314
+
315
+ /** ************************************************************************
316
+ * REQUIRED! This is where you prepare your data for display. This method will
317
+ * usually be used to query the database, sort and filter the data, and generally
318
+ * get it ready to be displayed. At a minimum, we should set $this->items and
319
+ * $this->set_pagination_args(), although the following properties and methods
320
+ * are frequently interacted with here...
321
+ *
322
+ * @uses $this->_column_headers
323
+ * @uses $this->items
324
+ * @uses $this->get_columns()
325
+ * @uses $this->get_sortable_columns()
326
+ * @uses $this->get_pagenum()
327
+ * @uses $this->set_pagination_args()
328
+ **************************************************************************/
329
+ function prepare_items()
330
+ {
331
+ /**
332
+ * First, lets decide how many records per page to show
333
+ */
334
+ $per_page = $this->get_items_per_page('wpcf_cf_per_page', 10);;
335
+
336
+ /**
337
+ * REQUIRED. Now we need to define our column headers. This includes a complete
338
+ * array of columns to be displayed (slugs & titles), a list of columns
339
+ * to keep hidden, and a list of columns that are sortable. Each of these
340
+ * can be defined in another method (as we've done here) before being
341
+ * used to build the value for our _column_headers property.
342
+ */
343
+ $columns = $this->get_columns();
344
+ $hidden = array();
345
+ $sortable = $this->get_sortable_columns();
346
+
347
+ /**
348
+ * REQUIRED. Finally, we build an array to be used by the class for column
349
+ * headers. The $this->_column_headers property takes an array which contains
350
+ * 3 other arrays. One for all columns, one for hidden columns, and one
351
+ * for sortable columns.
352
+ */
353
+ $this->_column_headers = array($columns, $hidden, $sortable);
354
+
355
+ /**
356
+ * Optional. You can handle your bulk actions however you see fit. In this
357
+ * case, we'll handle them within our package just to keep things clean.
358
+ */
359
+ $this->process_bulk_action();
360
+
361
+ /**
362
+ * Instead of querying a database, we're going to fetch the example data
363
+ * property we created for use in this plugin. This makes this example
364
+ * package slightly different than one you might build on your own. In
365
+ * this example, we'll be using array manipulation to sort and paginate
366
+ * our data. In a real-world implementation, you will probably want to
367
+ * use sort and pagination data to build a custom query instead, as you'll
368
+ * be able to use your precisely-queried data immediately.
369
+ */
370
+
371
+ $s = isset($_POST['s'])? mb_strtolower(trim($_POST['s'])):false;
372
+
373
+ $data = array();
374
+ $groups = wpcf_admin_fields_get_groups();
375
+ if ( !empty($groups) ){
376
+ foreach( array_values($groups) as $group ) {
377
+ $one = array(
378
+ 'description' => $group['description'],
379
+ 'id' => $group['id'],
380
+ 'slug' => $group['slug'],
381
+ 'status' => (isset($group['is_active']) && $group['is_active'])? 'active':'inactive',
382
+ 'supports' => isset($group['supports'])? $group['supports']:array(),
383
+ 'title' => $group['name'],
384
+ );
385
+ $add_one = true;
386
+ if ( $s ) {
387
+ $add_one = false;
388
+ foreach( array('description', 'id', 'slug', 'title' ) as $key ) {
389
+ if ( $add_one || empty( $one[$key] ) ) {
390
+ continue;
391
+ }
392
+ if ( is_numeric(strpos(mb_strtolower($one[$key]), $s))) {
393
+ $add_one = true;
394
+ }
395
+ }
396
+ }
397
+ if ( $add_one ) {
398
+ $data[] = $one;
399
+ }
400
+ }
401
+ }
402
+
403
+ /**
404
+ * This checks for sorting input and sorts the data in our array accordingly.
405
+ */
406
+ usort($data, 'wpcf_usort_reorder');
407
+
408
+ /**
409
+ * REQUIRED for pagination. Let's figure out what page the user is currently
410
+ * looking at. We'll need this later, so you should always include it in
411
+ * your own package classes.
412
+ */
413
+ $current_page = $this->get_pagenum();
414
+
415
+ /**
416
+ * REQUIRED for pagination. Let's check how many items are in our data array.
417
+ * In real-world use, this would be the total number of items in your database,
418
+ * without filtering. We'll need this later, so you should always include it
419
+ * in your own package classes.
420
+ */
421
+ $total_items = count($data);
422
+
423
+ /**
424
+ * The WP_List_Table class does not handle pagination for us, so we need
425
+ * to ensure that the data is trimmed to only the current page. We can use
426
+ * array_slice() to
427
+ */
428
+ $data = array_slice($data,(($current_page-1)*$per_page),$per_page);
429
+
430
+ /**
431
+ * REQUIRED. Now we can add our *sorted* data to the items property, where
432
+ * it can be used by the rest of the class.
433
+ */
434
+ $this->items = $data;
435
+
436
+ /**
437
+ * REQUIRED. We also have to register our pagination options & calculations.
438
+ */
439
+ $this->set_pagination_args( array(
440
+ 'total_items' => $total_items, //WE have to calculate the total number of items
441
+ 'per_page' => $per_page, //WE have to determine how many items to show on a page
442
+ 'total_pages' => ceil($total_items/$per_page) //WE have to calculate the total number of pages
443
+ ) );
444
+ }
445
+
446
+ /**
447
+ * Generates content for a single row of the table
448
+ *
449
+ * @since 3.1.0
450
+ * @access public
451
+ *
452
+ * @param object $item The current item
453
+ */
454
+ public function single_row( $item )
455
+ {
456
+ static $row_class = '';
457
+ $row_class = ( $row_class == '' ? 'alternate' : '' );
458
+
459
+ printf('<tr class="%s status-%s">', $row_class, $item['status']);
460
+ $this->single_row_columns( $item );
461
+ echo '</tr>';
462
+ }
463
+
464
+ public function no_items()
465
+ {
466
+ if ( isset($_POST['s']) ) {
467
+ _e('No custom field groups found.','wpcf');
468
+ return;
469
+ }
470
+ printf(
471
+ '<p>%s</p>',
472
+ __('To use custom fields, please create a group to hold them.', 'wpcf')
473
+ );
474
+ printf(
475
+ '<a class="button-primary" href="%s">%s</a>',
476
+ add_query_arg(
477
+ array(
478
+ 'page' => 'wpcf-edit',
479
+ ),
480
+ admin_url('admin.php')
481
+ ),
482
+ __('Add New Group', 'wpcf')
483
+ );
484
+ }
485
+
486
+ }
includes/classes/class.wpcf.custom.post.types.list.table.php ADDED
@@ -0,0 +1,468 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*************************** LOAD THE BASE CLASS *******************************
4
+ *******************************************************************************
5
+ * The WP_List_Table class isn't automatically available to plugins, so we need
6
+ * to check if it's available and load it if necessary. In this tutorial, we are
7
+ * going to use the WP_List_Table class directly from WordPress core.
8
+ *
9
+ * IMPORTANT:
10
+ * Please note that the WP_List_Table class technically isn't an official API,
11
+ * and it could change at some point in the distant future. Should that happen,
12
+ * I will update this plugin with the most current techniques for your reference
13
+ * immediately.
14
+ *
15
+ * If you are really worried about future compatibility, you can make a copy of
16
+ * the WP_List_Table class (file path is shown just below) to use and distribute
17
+ * with your plugins. If you do that, just remember to change the name of the
18
+ * class to avoid conflicts with core.
19
+ *
20
+ * Since I will be keeping this tutorial up-to-date for the foreseeable future,
21
+ * I am going to work with the copy of the class provided in WordPress core.
22
+ */
23
+ if(!class_exists('WP_List_Table')){
24
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
25
+ }
26
+
27
+ /************************** CREATE A PACKAGE CLASS *****************************
28
+ *******************************************************************************
29
+ * Create a new list table package that extends the core WP_List_Table class.
30
+ * WP_List_Table contains most of the framework for generating the table, but we
31
+ * need to define and override some methods so that our data can be displayed
32
+ * exactly the way we need it to be.
33
+ *
34
+ * To display this example on a page, you will first need to instantiate the class,
35
+ * then call $yourInstance->prepare_items() to handle any data manipulation, then
36
+ * finally call $yourInstance->display() to render the table to the page.
37
+ *
38
+ * Our theme for this list table is going to be movies.
39
+ */
40
+ class WPCF_Custom_Post_Types_List_Table extends WP_List_Table
41
+ {
42
+ var $custom_types;
43
+ var $bulk_action_field_name = 'wpcf_cpt_ids';
44
+
45
+ /** ************************************************************************
46
+ * REQUIRED. Set up a constructor that references the parent constructor. We
47
+ * use the parent reference to set some default configs.
48
+ ***************************************************************************/
49
+ function __construct()
50
+ {
51
+ global $status, $page;
52
+
53
+ //Set parent defaults
54
+ parent::__construct( array(
55
+ 'singular' => 'custom post type', //singular name of the listed records
56
+ 'plural' => 'custom post types', //plural name of the listed records
57
+ 'ajax' => true //does this table support ajax?
58
+ ) );
59
+
60
+ $this->custom_types = get_option('wpcf-custom-types', array());
61
+ }
62
+
63
+ /** ************************************************************************
64
+ * Recommended. This method is called when the parent class can't find a method
65
+ * specifically build for a given column. Generally, it's recommended to include
66
+ * one method for each column you want to render, keeping your package class
67
+ * neat and organized. For example, if the class needs to process a column
68
+ * named 'title', it would first see if a method named $this->column_title()
69
+ * exists - if it does, that method will be used. If it doesn't, this one will
70
+ * be used. Generally, you should try to use custom column methods as much as
71
+ * possible.
72
+ *
73
+ * Since we have defined a column_title() method later on, this method doesn't
74
+ * need to concern itself with any column with a name of 'title'. Instead, it
75
+ * needs to handle everything else.
76
+ *
77
+ * For more detailed insight into how columns are handled, take a look at
78
+ * WP_List_Table::single_row_columns()
79
+ *
80
+ * @param array $item A singular item (one full row's worth of data)
81
+ * @param array $column_name The name/slug of the column to be processed
82
+ * @return string Text or HTML to be placed inside the column <td>
83
+ **************************************************************************/
84
+ function column_default($item, $column_name)
85
+ {
86
+ switch($column_name){
87
+ case 'title':
88
+ case 'description':
89
+ return $item[$column_name];
90
+ case 'taxonomies':
91
+ $rows = array();
92
+ if (!empty($item[$column_name])) {
93
+ foreach ($item[$column_name] as $temp_tax => $true) {
94
+ $rows[] = stripslashes(wpcf_translate($temp_tax . ' name', $temp_tax, 'Types-TAX'));
95
+ }
96
+ }
97
+ return empty($rows)? __('None', 'wpcf'):implode(', ', $rows);
98
+ case 'status':
99
+ return 'active' == $item[$column_name]? __('Yes', 'wpcf'):__('No', 'wpcf');
100
+ default:
101
+ return print_r($item,true); //Show the whole array for troubleshooting purposes
102
+ }
103
+ }
104
+
105
+ /** ************************************************************************
106
+ * Recommended. This is a custom column method and is responsible for what
107
+ * is rendered in any column with a name/slug of 'title'. Every time the class
108
+ * needs to render a column, it first looks for a method named
109
+ * column_{$column_title} - if it exists, that method is run. If it doesn't
110
+ * exist, column_default() is called instead.
111
+ *
112
+ * This example also illustrates how to implement rollover actions. Actions
113
+ * should be an associative array formatted as 'slug'=>'link html' - and you
114
+ * will need to generate the URLs yourself. You could even ensure the links
115
+ *
116
+ *
117
+ * @see WP_List_Table::::single_row_columns()
118
+ * @param array $item A singular item (one full row's worth of data)
119
+ * @return string Text to be placed inside the column <td> (movie title only)
120
+ **************************************************************************/
121
+ function column_title($item)
122
+ {
123
+ $edit_link = add_query_arg(
124
+ array(
125
+ 'page' => 'wpcf-edit-type',
126
+ 'wpcf-post-type' => $item['slug']
127
+ ),
128
+ admin_url('admin.php')
129
+ );
130
+
131
+ //Build row actions
132
+ $actions = array(
133
+ 'edit' => sprintf('<a href="%s">%s</a>', $edit_link, __('Edit', 'wpcf')),
134
+ 'status' => 'active' == $item['status'] ? wpcf_admin_custom_types_get_ajax_deactivation_link($item['slug']):wpcf_admin_custom_types_get_ajax_activation_link($item['slug']),
135
+ 'delete' => sprintf(
136
+ '<a href="%s" class="submitdelete wpcf-ajax-link" id="wpcf-list-delete-%s"">%s</a>',
137
+ add_query_arg(
138
+ array(
139
+ 'action' => 'wpcf_ajax',
140
+ 'wpcf_action' => 'delete_post_type',
141
+ 'wpcf-post-type' => $item['slug'],
142
+ 'wpcf_ajax_update' => 'wpcf_list_ajax_response_'.$item['slug'],
143
+ 'wpcf_ajax_callback' => 'wpcfRefresh',
144
+ '_wpnonce' => wp_create_nonce('delete_post_type'),
145
+ 'wpcf_warning' => urlencode(__('Are you sure?', 'wpcf')),
146
+ ),
147
+ admin_url('admin-ajax.php')
148
+ ),
149
+ $item['slug'],
150
+ __('Delete', 'wpcf')
151
+ ),
152
+ );
153
+
154
+ //Return the title contents
155
+ return sprintf(
156
+ '<strong><a href="%s" class="row-title">%s</strong>%s',
157
+ $edit_link,
158
+ $item['title'],
159
+ $this->row_actions($actions)
160
+ );
161
+ }
162
+
163
+ /** ************************************************************************
164
+ * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column
165
+ * is given special treatment when columns are processed. It ALWAYS needs to
166
+ * have it's own method.
167
+ *
168
+ * @see WP_List_Table::::single_row_columns()
169
+ * @param array $item A singular item (one full row's worth of data)
170
+ * @return string Text to be placed inside the column <td> (movie title only)
171
+ **************************************************************************/
172
+ function column_cb($item)
173
+ {
174
+ return sprintf(
175
+ '<input type="checkbox" name="%s[]" value="%s" />',
176
+ $this->bulk_action_field_name,
177
+ $item['slug']
178
+ );
179
+ }
180
+
181
+ /** ************************************************************************
182
+ * REQUIRED! This method dictates the table's columns and titles. This should
183
+ * return an array where the key is the column slug (and class) and the value
184
+ * is the column's title text. If you need a checkbox for bulk actions, refer
185
+ * to the $columns array below.
186
+ *
187
+ * The 'cb' column is treated differently than the rest. If including a checkbox
188
+ * column in your table you must create a column_cb() method. If you don't need
189
+ * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
190
+ *
191
+ * @see WP_List_Table::::single_row_columns()
192
+ * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
193
+ **************************************************************************/
194
+ function get_columns()
195
+ {
196
+ $columns = array(
197
+ 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
198
+ 'title' => __('Post Type Name', 'wpcf'),
199
+ 'description' => __('Description', 'wpcf'),
200
+ 'status' => __('Active', 'wpcf'),
201
+ 'taxonomies' => __('Taxonomies', 'wpcf'),
202
+ );
203
+ return $columns;
204
+ }
205
+
206
+ /** ************************************************************************
207
+ * Optional. If you want one or more columns to be sortable (ASC/DESC toggle),
208
+ * you will need to register it here. This should return an array where the
209
+ * key is the column that needs to be sortable, and the value is db column to
210
+ * sort by. Often, the key and value will be the same, but this is not always
211
+ * the case (as the value is a column name from the database, not the list table).
212
+ *
213
+ * This method merely defines which columns should be sortable and makes them
214
+ * clickable - it does not handle the actual sorting. You still need to detect
215
+ * the ORDERBY and ORDER querystring variables within prepare_items() and sort
216
+ * your data accordingly (usually by modifying your query).
217
+ *
218
+ * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
219
+ **************************************************************************/
220
+ function get_sortable_columns()
221
+ {
222
+ $sortable_columns = array(
223
+ 'title' => array('title',true), //true means it's already sorted
224
+ 'description' => array('description',false),
225
+ 'status' => array('status',false)
226
+ );
227
+ return $sortable_columns;
228
+ }
229
+
230
+ /** ************************************************************************
231
+ * Optional. If you need to include bulk actions in your list table, this is
232
+ * the place to define them. Bulk actions are an associative array in the format
233
+ * 'slug'=>'Visible Title'
234
+ *
235
+ * If this method returns an empty value, no bulk action will be rendered. If
236
+ * you specify any bulk actions, the bulk actions box will be rendered with
237
+ * the table automatically on display().
238
+ *
239
+ * Also note that list tables are not automatically wrapped in <form> elements,
240
+ * so you will need to create those manually in order for bulk actions to function.
241
+ *
242
+ * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
243
+ **************************************************************************/
244
+ function get_bulk_actions()
245
+ {
246
+ $actions = array(
247
+ 'activate' => __('Activate', 'wpcf'),
248
+ 'deactivate' => __('Deactivate', 'wpcf'),
249
+ );
250
+ return $actions;
251
+ }
252
+
253
+ /** ************************************************************************
254
+ * Optional. You can handle your bulk actions anywhere or anyhow you prefer.
255
+ * For this example package, we will handle it in the class to keep things
256
+ * clean and organized.
257
+ *
258
+ * @see $this->prepare_items()
259
+ **************************************************************************/
260
+ function process_bulk_action()
261
+ {
262
+ $action = $this->current_action();
263
+ //Detect when a bulk action is being triggered...
264
+ switch($action) {
265
+ case 'deactivate':
266
+ if (
267
+ !empty($this->custom_types)
268
+ && isset($_POST[$this->bulk_action_field_name])
269
+ && !empty($_POST[$this->bulk_action_field_name])
270
+ ) {
271
+ foreach( $_POST[$this->bulk_action_field_name] as $key ) {
272
+ if ( !isset($this->custom_types[$key]) ) {
273
+ continue;
274
+ }
275
+ $this->custom_types[$key]['disabled'] = 1;
276
+ $this->custom_types[$key][TOOLSET_EDIT_LAST] = time();
277
+ }
278
+ update_option('wpcf-custom-types', $this->custom_types);
279
+ }
280
+ break;
281
+ case 'activate':
282
+ if (
283
+ !empty($this->custom_types)
284
+ && isset($_POST[$this->bulk_action_field_name])
285
+ && !empty($_POST[$this->bulk_action_field_name])
286
+ ) {
287
+ foreach( $_POST[$this->bulk_action_field_name] as $key ) {
288
+ if ( !isset($this->custom_types[$key]) ) {
289
+ continue;
290
+ }
291
+ if ( isset($this->custom_types[$key]['disabled']) ) {
292
+ unset($this->custom_types[$key]['disabled']);
293
+ $this->custom_types[$key][TOOLSET_EDIT_LAST] = time();
294
+ }
295
+ }
296
+ update_option('wpcf-custom-types', $this->custom_types);
297
+ }
298
+ break;
299
+ }
300
+ }
301
+
302
+ /** ************************************************************************
303
+ * REQUIRED! This is where you prepare your data for display. This method will
304
+ * usually be used to query the database, sort and filter the data, and generally
305
+ * get it ready to be displayed. At a minimum, we should set $this->items and
306
+ * $this->set_pagination_args(), although the following properties and methods
307
+ * are frequently interacted with here...
308
+ *
309
+ * @uses $this->_column_headers
310
+ * @uses $this->items
311
+ * @uses $this->get_columns()
312
+ * @uses $this->get_sortable_columns()
313
+ * @uses $this->get_pagenum()
314
+ * @uses $this->set_pagination_args()
315
+ **************************************************************************/
316
+ function prepare_items()
317
+ {
318
+ /**
319
+ * First, lets decide how many records per page to show
320
+ */
321
+ $per_page = $this->get_items_per_page('wpcf_cpt_per_page', 10);;
322
+
323
+ /**
324
+ * REQUIRED. Now we need to define our column headers. This includes a complete
325
+ * array of columns to be displayed (slugs & titles), a list of columns
326
+ * to keep hidden, and a list of columns that are sortable. Each of these
327
+ * can be defined in another method (as we've done here) before being
328
+ * used to build the value for our _column_headers property.
329
+ */
330
+ $columns = $this->get_columns();
331
+ $hidden = array();
332
+ $sortable = $this->get_sortable_columns();
333
+
334
+ /**
335
+ * REQUIRED. Finally, we build an array to be used by the class for column
336
+ * headers. The $this->_column_headers property takes an array which contains
337
+ * 3 other arrays. One for all columns, one for hidden columns, and one
338
+ * for sortable columns.
339
+ */
340
+ $this->_column_headers = array($columns, $hidden, $sortable);
341
+
342
+ /**
343
+ * Optional. You can handle your bulk actions however you see fit. In this
344
+ * case, we'll handle them within our package just to keep things clean.
345
+ */
346
+ $this->process_bulk_action();
347
+
348
+ /**
349
+ * Instead of querying a database, we're going to fetch the example data
350
+ * property we created for use in this plugin. This makes this example
351
+ * package slightly different than one you might build on your own. In
352
+ * this example, we'll be using array manipulation to sort and paginate
353
+ * our data. In a real-world implementation, you will probably want to
354
+ * use sort and pagination data to build a custom query instead, as you'll
355
+ * be able to use your precisely-queried data immediately.
356
+ */
357
+
358
+ $s = isset($_POST['s'])? mb_strtolower(trim($_POST['s'])):false;
359
+
360
+ $data = array();
361
+ if ( !empty($this->custom_types) ){
362
+ foreach( array_values($this->custom_types) as $type ) {
363
+ $one = array(
364
+ 'description' => $type['description'],
365
+ 'taxonomies' => isset($type['taxonomies'])? $type['taxonomies']:array(),
366
+ 'slug' => $type['slug'],
367
+ 'status' => isset($type['disabled'])? 'inactive':'active',
368
+ 'title' => $type['labels']['singular_name'],
369
+ );
370
+ $add_one = true;
371
+ if ( $s ) {
372
+ $add_one = false;
373
+ foreach( array('description', 'slug', 'title' ) as $key ) {
374
+ if ( $add_one || empty( $one[$key] ) ) {
375
+ continue;
376
+ }
377
+ if ( is_numeric(strpos(mb_strtolower($one[$key]), $s))) {
378
+ $add_one = true;
379
+ }
380
+ }
381
+ }
382
+ if ( $add_one ) {
383
+ $data[] = $one;
384
+ }
385
+ }
386
+ }
387
+
388
+ /**
389
+ * This checks for sorting input and sorts the data in our array accordingly.
390
+ */
391
+ usort($data, 'wpcf_usort_reorder');
392
+
393
+ /**
394
+ * REQUIRED for pagination. Let's figure out what page the user is currently
395
+ * looking at. We'll need this later, so you should always include it in
396
+ * your own package classes.
397
+ */
398
+ $current_page = $this->get_pagenum();
399
+
400
+ /**
401
+ * REQUIRED for pagination. Let's check how many items are in our data array.
402
+ * In real-world use, this would be the total number of items in your database,
403
+ * without filtering. We'll need this later, so you should always include it
404
+ * in your own package classes.
405
+ */
406
+ $total_items = count($data);
407
+
408
+ /**
409
+ * The WP_List_Table class does not handle pagination for us, so we need
410
+ * to ensure that the data is trimmed to only the current page. We can use
411
+ * array_slice() to
412
+ */
413
+ $data = array_slice($data,(($current_page-1)*$per_page),$per_page);
414
+
415
+ /**
416
+ * REQUIRED. Now we can add our *sorted* data to the items property, where
417
+ * it can be used by the rest of the class.
418
+ */
419
+ $this->items = $data;
420
+
421
+ /**
422
+ * REQUIRED. We also have to register our pagination options & calculations.
423
+ */
424
+ $this->set_pagination_args( array(
425
+ 'total_items' => $total_items, //WE have to calculate the total number of items
426
+ 'per_page' => $per_page, //WE have to determine how many items to show on a page
427
+ 'total_pages' => ceil($total_items/$per_page) //WE have to calculate the total number of pages
428
+ ) );
429
+ }
430
+
431
+ /**
432
+ * Generates content for a single row of the table
433
+ *
434
+ * @since 3.1.0
435
+ * @access public
436
+ *
437
+ * @param object $item The current item
438
+ */
439
+ public function single_row( $item )
440
+ {
441
+ static $row_class = '';
442
+ $row_class = ( $row_class == '' ? 'alternate' : '' );
443
+
444
+ printf('<tr class="%s status-%s">', $row_class, $item['status']);
445
+ $this->single_row_columns( $item );
446
+ echo '</tr>';
447
+ }
448
+
449
+ public function no_items()
450
+ {
451
+ if ( isset($_POST['s']) ) {
452
+ _e('No custom post types found.','wpcf');
453
+ return;
454
+ }
455
+ wpcf_admin_ctt_list_header();
456
+ printf(
457
+ '<a class="button-primary" href="%s">%s</a>',
458
+ add_query_arg(
459
+ array(
460
+ 'page' => 'wpcf-edit-type',
461
+ ),
462
+ admin_url('admin.php')
463
+ ),
464
+ __('Add New Custom Post Type', 'wpcf')
465
+ );
466
+ }
467
+
468
+ }
includes/classes/class.wpcf.custom.taxonomies.list.table.php ADDED
@@ -0,0 +1,466 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*************************** LOAD THE BASE CLASS *******************************
4
+ *******************************************************************************
5
+ * The WP_List_Table class isn't automatically available to plugins, so we need
6
+ * to check if it's available and load it if necessary. In this tutorial, we are
7
+ * going to use the WP_List_Table class directly from WordPress core.
8
+ *
9
+ * IMPORTANT:
10
+ * Please note that the WP_List_Table class technically isn't an official API,
11
+ * and it could change at some point in the distant future. Should that happen,
12
+ * I will update this plugin with the most current techniques for your reference
13
+ * immediately.
14
+ *
15
+ * If you are really worried about future compatibility, you can make a copy of
16
+ * the WP_List_Table class (file path is shown just below) to use and distribute
17
+ * with your plugins. If you do that, just remember to change the name of the
18
+ * class to avoid conflicts with core.
19
+ *
20
+ * Since I will be keeping this tutorial up-to-date for the foreseeable future,
21
+ * I am going to work with the copy of the class provided in WordPress core.
22
+ */
23
+ if(!class_exists('WP_List_Table')){
24
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
25
+ }
26
+
27
+ /************************** CREATE A PACKAGE CLASS *****************************
28
+ *******************************************************************************
29
+ * Create a new list table package that extends the core WP_List_Table class.
30
+ * WP_List_Table contains most of the framework for generating the table, but we
31
+ * need to define and override some methods so that our data can be displayed
32
+ * exactly the way we need it to be.
33
+ *
34
+ * To display this example on a page, you will first need to instantiate the class,
35
+ * then call $yourInstance->prepare_items() to handle any data manipulation, then
36
+ * finally call $yourInstance->display() to render the table to the page.
37
+ *
38
+ * Our theme for this list table is going to be movies.
39
+ */
40
+ class WPCF_Custom_Taxonomies_List_Table extends WP_List_Table
41
+ {
42
+ var $custom_taxonomies;
43
+ var $bulk_action_field_name = 'wpcf_ct_ids';
44
+
45
+ /** ************************************************************************
46
+ * REQUIRED. Set up a constructor that references the parent constructor. We
47
+ * use the parent reference to set some default configs.
48
+ ***************************************************************************/
49
+ function __construct()
50
+ {
51
+ global $status, $page;
52
+
53
+ //Set parent defaults
54
+ parent::__construct( array(
55
+ 'singular' => 'custom taxonomy', //singular name of the listed records
56
+ 'plural' => 'custom taxonomies', //plural name of the listed records
57
+ 'ajax' => true //does this table support ajax?
58
+ ) );
59
+
60
+ $this->custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
61
+ }
62
+
63
+ /** ************************************************************************
64
+ * Recommended. This method is called when the parent class can't find a method
65
+ * specifically build for a given column. Generally, it's recommended to include
66
+ * one method for each column you want to render, keeping your package class
67
+ * neat and organized. For example, if the class needs to process a column
68
+ * named 'title', it would first see if a method named $this->column_title()
69
+ * exists - if it does, that method will be used. If it doesn't, this one will
70
+ * be used. Generally, you should try to use custom column methods as much as
71
+ * possible.
72
+ *
73
+ * Since we have defined a column_title() method later on, this method doesn't
74
+ * need to concern itself with any column with a name of 'title'. Instead, it
75
+ * needs to handle everything else.
76
+ *
77
+ * For more detailed insight into how columns are handled, take a look at
78
+ * WP_List_Table::single_row_columns()
79
+ *
80
+ * @param array $item A singular item (one full row's worth of data)
81
+ * @param array $column_name The name/slug of the column to be processed
82
+ * @return string Text or HTML to be placed inside the column <td>
83
+ **************************************************************************/
84
+ function column_default($item, $column_name)
85
+ {
86
+ switch($column_name){
87
+ case 'title':
88
+ case 'description':
89
+ return $item[$column_name];
90
+ case 'supports':
91
+ $rows = array();
92
+ if (!empty($item[$column_name])) {
93
+ foreach ($item[$column_name] as $temp_post_type => $true) {
94
+ $rows[] = stripslashes(wpcf_translate($temp_post_type . ' name', $temp_post_type, 'Types-CPT'));
95
+ }
96
+ }
97
+ return empty($rows)? __('None', 'wpcf'):implode(', ', $rows);
98
+ case 'status':
99
+ return 'active' == $item[$column_name]? __('Yes', 'wpcf'):__('No', 'wpcf');
100
+ default:
101
+ return print_r($item,true); //Show the whole array for troubleshooting purposes
102
+ }
103
+ }
104
+
105
+ /** ************************************************************************
106
+ * Recommended. This is a custom column method and is responsible for what
107
+ * is rendered in any column with a name/slug of 'title'. Every time the class
108
+ * needs to render a column, it first looks for a method named
109
+ * column_{$column_title} - if it exists, that method is run. If it doesn't
110
+ * exist, column_default() is called instead.
111
+ *
112
+ * This example also illustrates how to implement rollover actions. Actions
113
+ * should be an associative array formatted as 'slug'=>'link html' - and you
114
+ * will need to generate the URLs yourself. You could even ensure the links
115
+ *
116
+ *
117
+ * @see WP_List_Table::::single_row_columns()
118
+ * @param array $item A singular item (one full row's worth of data)
119
+ * @return string Text to be placed inside the column <td> (movie title only)
120
+ **************************************************************************/
121
+ function column_title($item)
122
+ {
123
+ $edit_link = add_query_arg(
124
+ array(
125
+ 'page' => 'wpcf-edit-tax',
126
+ 'wpcf-tax' => $item['slug']
127
+ ),
128
+ admin_url('admin.php')
129
+ );
130
+
131
+ //Build row actions
132
+ $actions = array(
133
+ 'edit' => sprintf('<a href="%s">%s</a>', $edit_link, __('Edit', 'wpcf')),
134
+ 'status' => 'active' == $item['status']? wpcf_admin_custom_taxonomies_get_ajax_deactivation_link($item['slug']):wpcf_admin_custom_taxonomies_get_ajax_activation_link($item['slug']),
135
+ 'delete' => sprintf(
136
+ '<a href="%s" class="submitdelete wpcf-ajax-link" id="wpcf-list-delete-%s"">%s</a>',
137
+ add_query_arg(
138
+ array(
139
+ 'action' => 'wpcf_ajax',
140
+ 'wpcf_action' => 'delete_taxonomy',
141
+ 'wpcf-tax' => $item['slug'],
142
+ 'wpcf_ajax_update' => 'wpcf_list_ajax_response_'.$item['slug'],
143
+ 'wpcf_ajax_callback' => 'wpcfRefresh',
144
+ '_wpnonce' => wp_create_nonce('delete_taxonomy'),
145
+ 'wpcf_warning' => urlencode(__('Are you sure?', 'wpcf')),
146
+ ),
147
+ admin_url('admin-ajax.php')
148
+ ),
149
+ $item['slug'],
150
+ __('Delete', 'wpcf')
151
+ ),
152
+ );
153
+
154
+ //Return the title contents
155
+ return sprintf(
156
+ '<strong><a href="%s" class="row-title">%s</strong>%s',
157
+ $edit_link,
158
+ $item['title'],
159
+ $this->row_actions($actions)
160
+ );
161
+ }
162
+
163
+ /** ************************************************************************
164
+ * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column
165
+ * is given special treatment when columns are processed. It ALWAYS needs to
166
+ * have it's own method.
167
+ *
168
+ * @see WP_List_Table::::single_row_columns()
169
+ * @param array $item A singular item (one full row's worth of data)
170
+ * @return string Text to be placed inside the column <td> (movie title only)
171
+ **************************************************************************/
172
+ function column_cb($item)
173
+ {
174
+ return sprintf(
175
+ '<input type="checkbox" name="%s[]" value="%s" />',
176
+ $this->bulk_action_field_name,
177
+ $item['slug']
178
+ );
179
+ }
180
+
181
+ /** ************************************************************************
182
+ * REQUIRED! This method dictates the table's columns and titles. This should
183
+ * return an array where the key is the column slug (and class) and the value
184
+ * is the column's title text. If you need a checkbox for bulk actions, refer
185
+ * to the $columns array below.
186
+ *
187
+ * The 'cb' column is treated differently than the rest. If including a checkbox
188
+ * column in your table you must create a column_cb() method. If you don't need
189
+ * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
190
+ *
191
+ * @see WP_List_Table::::single_row_columns()
192
+ * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
193
+ **************************************************************************/
194
+ function get_columns()
195
+ {
196
+ $columns = array(
197
+ 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
198
+ 'title' => __('Taxonomy Name', 'wpcf'),
199
+ 'description' => __('Description', 'wpcf'),
200
+ 'status' => __('Active', 'wpcf'),
201
+ 'supports' => __('Post Types', 'wpcf'),
202
+ );
203
+ return $columns;
204
+ }
205
+
206
+ /** ************************************************************************
207
+ * Optional. If you want one or more columns to be sortable (ASC/DESC toggle),
208
+ * you will need to register it here. This should return an array where the
209
+ * key is the column that needs to be sortable, and the value is db column to
210
+ * sort by. Often, the key and value will be the same, but this is not always
211
+ * the case (as the value is a column name from the database, not the list table).
212
+ *
213
+ * This method merely defines which columns should be sortable and makes them
214
+ * clickable - it does not handle the actual sorting. You still need to detect
215
+ * the ORDERBY and ORDER querystring variables within prepare_items() and sort
216
+ * your data accordingly (usually by modifying your query).
217
+ *
218
+ * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
219
+ **************************************************************************/
220
+ function get_sortable_columns()
221
+ {
222
+ $sortable_columns = array(
223
+ 'title' => array('title',true), //true means it's already sorted
224
+ 'description' => array('description',false),
225
+ 'status' => array('status',false)
226
+ );
227
+ return $sortable_columns;
228
+ }
229
+
230
+ /** ************************************************************************
231
+ * Optional. If you need to include bulk actions in your list table, this is
232
+ * the place to define them. Bulk actions are an associative array in the format
233
+ * 'slug'=>'Visible Title'
234
+ *
235
+ * If this method returns an empty value, no bulk action will be rendered. If
236
+ * you specify any bulk actions, the bulk actions box will be rendered with
237
+ * the table automatically on display().
238
+ *
239
+ * Also note that list tables are not automatically wrapped in <form> elements,
240
+ * so you will need to create those manually in order for bulk actions to function.
241
+ *
242
+ * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
243
+ **************************************************************************/
244
+ function get_bulk_actions()
245
+ {
246
+ $actions = array(
247
+ 'activate' => __('Activate', 'wpcf'),
248
+ 'deactivate' => __('Deactivate', 'wpcf'),
249
+ );
250
+ return $actions;
251
+ }
252
+
253
+ /** ************************************************************************
254
+ * Optional. You can handle your bulk actions anywhere or anyhow you prefer.
255
+ * For this example package, we will handle it in the class to keep things
256
+ * clean and organized.
257
+ *
258
+ * @see $this->prepare_items()
259
+ **************************************************************************/
260
+ function process_bulk_action()
261
+ {
262
+ $action = $this->current_action();
263
+ //Detect when a bulk action is being triggered...
264
+ switch($action) {
265
+ case 'deactivate':
266
+ if (
267
+ !empty($this->custom_taxonomies)
268
+ && isset($_POST[$this->bulk_action_field_name])
269
+ && !empty($_POST[$this->bulk_action_field_name])
270
+ ) {
271
+ foreach( $_POST[$this->bulk_action_field_name] as $key ) {
272
+ if ( !isset($this->custom_taxonomies[$key]) ) {
273
+ continue;
274
+ }
275
+ $this->custom_taxonomies[$key]['disabled'] = 1;
276
+ }
277
+ update_option('wpcf-custom-taxonomies', $this->custom_taxonomies);
278
+ }
279
+ break;
280
+ case 'activate':
281
+ if (
282
+ !empty($this->custom_taxonomies)
283
+ && isset($_POST[$this->bulk_action_field_name])
284
+ && !empty($_POST[$this->bulk_action_field_name])
285
+ ) {
286
+ foreach( $_POST[$this->bulk_action_field_name] as $key ) {
287
+ if ( !isset($this->custom_taxonomies[$key]) ) {
288
+ continue;
289
+ }
290
+ if ( isset($this->custom_taxonomies[$key]['disabled']) ) {
291
+ unset($this->custom_taxonomies[$key]['disabled']);
292
+ }
293
+ }
294
+ update_option('wpcf-custom-taxonomies', $this->custom_taxonomies);
295
+ }
296
+ break;
297
+ }
298
+ }
299
+
300
+ /** ************************************************************************
301
+ * REQUIRED! This is where you prepare your data for display. This method will
302
+ * usually be used to query the database, sort and filter the data, and generally
303
+ * get it ready to be displayed. At a minimum, we should set $this->items and
304
+ * $this->set_pagination_args(), although the following properties and methods
305
+ * are frequently interacted with here...
306
+ *
307
+ * @uses $this->_column_headers
308
+ * @uses $this->items
309
+ * @uses $this->get_columns()
310
+ * @uses $this->get_sortable_columns()
311
+ * @uses $this->get_pagenum()
312
+ * @uses $this->set_pagination_args()
313
+ **************************************************************************/
314
+ function prepare_items()
315
+ {
316
+ /**
317
+ * First, lets decide how many records per page to show
318
+ */
319
+ $per_page = $this->get_items_per_page('wpcf_ctt_per_page', 10);;
320
+
321
+ /**
322
+ * REQUIRED. Now we need to define our column headers. This includes a complete
323
+ * array of columns to be displayed (slugs & titles), a list of columns
324
+ * to keep hidden, and a list of columns that are sortable. Each of these
325
+ * can be defined in another method (as we've done here) before being
326
+ * used to build the value for our _column_headers property.
327
+ */
328
+ $columns = $this->get_columns();
329
+ $hidden = array();
330
+ $sortable = $this->get_sortable_columns();
331
+
332
+ /**
333
+ * REQUIRED. Finally, we build an array to be used by the class for column
334
+ * headers. The $this->_column_headers property takes an array which contains
335
+ * 3 other arrays. One for all columns, one for hidden columns, and one
336
+ * for sortable columns.
337
+ */
338
+ $this->_column_headers = array($columns, $hidden, $sortable);
339
+
340
+ /**
341
+ * Optional. You can handle your bulk actions however you see fit. In this
342
+ * case, we'll handle them within our package just to keep things clean.
343
+ */
344
+ $this->process_bulk_action();
345
+
346
+ /**
347
+ * Instead of querying a database, we're going to fetch the example data
348
+ * property we created for use in this plugin. This makes this example
349
+ * package slightly different than one you might build on your own. In
350
+ * this example, we'll be using array manipulation to sort and paginate
351
+ * our data. In a real-world implementation, you will probably want to
352
+ * use sort and pagination data to build a custom query instead, as you'll
353
+ * be able to use your precisely-queried data immediately.
354
+ */
355
+
356
+ $s = isset($_POST['s'])? mb_strtolower(trim($_POST['s'])):false;
357
+
358
+ $data = array();
359
+ if ( !empty($this->custom_taxonomies) ){
360
+ foreach( array_values($this->custom_taxonomies) as $taxonomy ) {
361
+ $one = array(
362
+ 'description' => $taxonomy['description'],
363
+ 'supports' => isset($taxonomy['supports'])? $taxonomy['supports']:array(),
364
+ 'slug' => $taxonomy['slug'],
365
+ 'status' => (isset($taxonomy['disabled']) && $taxonomy['disabled'])? 'inactive':'active',
366
+ 'title' => $taxonomy['labels']['singular_name'],
367
+ );
368
+ $add_one = true;
369
+ if ( $s ) {
370
+ $add_one = false;
371
+ foreach( array('description', 'slug', 'title' ) as $key ) {
372
+ if ( $add_one || empty( $one[$key] ) ) {
373
+ continue;
374
+ }
375
+ if ( is_numeric(strpos(mb_strtolower($one[$key]), $s))) {
376
+ $add_one = true;
377
+ }
378
+ }
379
+ }
380
+ if ( $add_one ) {
381
+ $data[] = $one;
382
+ }
383
+ }
384
+ }
385
+
386
+ /**
387
+ * This checks for sorting input and sorts the data in our array accordingly.
388
+ */
389
+ usort($data, 'wpcf_usort_reorder');
390
+
391
+ /**
392
+ * REQUIRED for pagination. Let's figure out what page the user is currently
393
+ * looking at. We'll need this later, so you should always include it in
394
+ * your own package classes.
395
+ */
396
+ $current_page = $this->get_pagenum();
397
+
398
+ /**
399
+ * REQUIRED for pagination. Let's check how many items are in our data array.
400
+ * In real-world use, this would be the total number of items in your database,
401
+ * without filtering. We'll need this later, so you should always include it
402
+ * in your own package classes.
403
+ */
404
+ $total_items = count($data);
405
+
406
+ /**
407
+ * The WP_List_Table class does not handle pagination for us, so we need
408
+ * to ensure that the data is trimmed to only the current page. We can use
409
+ * array_slice() to
410
+ */
411
+ $data = array_slice($data,(($current_page-1)*$per_page),$per_page);
412
+
413
+ /**
414
+ * REQUIRED. Now we can add our *sorted* data to the items property, where
415
+ * it can be used by the rest of the class.
416
+ */
417
+ $this->items = $data;
418
+
419
+ /**
420
+ * REQUIRED. We also have to register our pagination options & calculations.
421
+ */
422
+ $this->set_pagination_args( array(
423
+ 'total_items' => $total_items, //WE have to calculate the total number of items
424
+ 'per_page' => $per_page, //WE have to determine how many items to show on a page
425
+ 'total_pages' => ceil($total_items/$per_page) //WE have to calculate the total number of pages
426
+ ) );
427
+ }
428
+
429
+ /**
430
+ * Generates content for a single row of the table
431
+ *
432
+ * @since 3.1.0
433
+ * @access public
434
+ *
435
+ * @param object $item The current item
436
+ */
437
+ public function single_row( $item )
438
+ {
439
+ static $row_class = '';
440
+ $row_class = ( $row_class == '' ? 'alternate' : '' );
441
+
442
+ printf('<tr class="%s status-%s">', $row_class, $item['status']);
443
+ $this->single_row_columns( $item );
444
+ echo '</tr>';
445
+ }
446
+
447
+ public function no_items()
448
+ {
449
+ if ( isset($_POST['s']) ) {
450
+ _e('No custom taxonomies found.','wpcf');
451
+ return;
452
+ }
453
+ wpcf_admin_ctt_list_header();
454
+ printf(
455
+ '<a class="button-primary" href="%s">%s</a>',
456
+ add_query_arg(
457
+ array(
458
+ 'page' => 'wpcf-edit-tax',
459
+ ),
460
+ admin_url('admin.php')
461
+ ),
462
+ __('Add New Taxonomy', 'wpcf')
463
+ );
464
+ }
465
+
466
+ }
includes/classes/class.wpcf.user.fields.list.table.php ADDED
@@ -0,0 +1,475 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*************************** LOAD THE BASE CLASS *******************************
4
+ *******************************************************************************
5
+ * The WP_List_Table class isn't automatically available to plugins, so we need
6
+ * to check if it's available and load it if necessary. In this tutorial, we are
7
+ * going to use the WP_List_Table class directly from WordPress core.
8
+ *
9
+ * IMPORTANT:
10
+ * Please note that the WP_List_Table class technically isn't an official API,
11
+ * and it could change at some point in the distant future. Should that happen,
12
+ * I will update this plugin with the most current techniques for your reference
13
+ * immediately.
14
+ *
15
+ * If you are really worried about future compatibility, you can make a copy of
16
+ * the WP_List_Table class (file path is shown just below) to use and distribute
17
+ * with your plugins. If you do that, just remember to change the name of the
18
+ * class to avoid conflicts with core.
19
+ *
20
+ * Since I will be keeping this tutorial up-to-date for the foreseeable future,
21
+ * I am going to work with the copy of the class provided in WordPress core.
22
+ */
23
+ if(!class_exists('WP_List_Table')){
24
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
25
+ }
26
+
27
+ /************************** CREATE A PACKAGE CLASS *****************************
28
+ *******************************************************************************
29
+ * Create a new list table package that extends the core WP_List_Table class.
30
+ * WP_List_Table contains most of the framework for generating the table, but we
31
+ * need to define and override some methods so that our data can be displayed
32
+ * exactly the way we need it to be.
33
+ *
34
+ * To display this example on a page, you will first need to instantiate the class,
35
+ * then call $yourInstance->prepare_items() to handle any data manipulation, then
36
+ * finally call $yourInstance->display() to render the table to the page.
37
+ *
38
+ * Our theme for this list table is going to be movies.
39
+ */
40
+ class WPCF_User_Fields_List_Table extends WP_List_Table
41
+ {
42
+ var $bulk_action_field_name = 'wpcf_ids';
43
+ /** ************************************************************************
44
+ * REQUIRED. Set up a constructor that references the parent constructor. We
45
+ * use the parent reference to set some default configs.
46
+ ***************************************************************************/
47
+ function __construct()
48
+ {
49
+ global $status, $page;
50
+
51
+ //Set parent defaults
52
+ parent::__construct( array(
53
+ 'singular' => 'user field group', //singular name of the listed records
54
+ 'plural' => 'user field groups', //plural name of the listed records
55
+ 'ajax' => true //does this table support ajax?
56
+ ) );
57
+ }
58
+
59
+ /** ************************************************************************
60
+ * Recommended. This method is called when the parent class can't find a method
61
+ * specifically build for a given column. Generally, it's recommended to include
62
+ * one method for each column you want to render, keeping your package class
63
+ * neat and organized. For example, if the class needs to process a column
64
+ * named 'title', it would first see if a method named $this->column_title()
65
+ * exists - if it does, that method will be used. If it doesn't, this one will
66
+ * be used. Generally, you should try to use custom column methods as much as
67
+ * possible.
68
+ *
69
+ * Since we have defined a column_title() method later on, this method doesn't
70
+ * need to concern itself with any column with a name of 'title'. Instead, it
71
+ * needs to handle everything else.
72
+ *
73
+ * For more detailed insight into how columns are handled, take a look at
74
+ * WP_List_Table::single_row_columns()
75
+ *
76
+ * @param array $item A singular item (one full row's worth of data)
77
+ * @param array $column_name The name/slug of the column to be processed
78
+ * @return string Text or HTML to be placed inside the column <td>
79
+ **************************************************************************/
80
+ function column_default($item, $column_name)
81
+ {
82
+ switch($column_name){
83
+ case 'title':
84
+ case 'description':
85
+ return $item[$column_name];
86
+ case 'show_for':
87
+ $show_for = wpcf_admin_get_groups_showfor_by_group($item['id']);
88
+ if (function_exists('wpcf_access_register_caps')){
89
+ $show_for = __('This groups visibility is also controlled by the Access plugin.',
90
+ 'wpcf');
91
+ }
92
+ else{
93
+ $show_for = (count($show_for) == 0) ? __('Displayed for all users roles', 'wpcf') : ucwords(implode($show_for, ', '));
94
+ }
95
+ return $show_for;
96
+ case 'status':
97
+ return 'active' == $item[$column_name]? __('Yes', 'wpcf'):__('No', 'wpcf');
98
+ default:
99
+ return print_r($item,true); //Show the whole array for troubleshooting purposes
100
+ }
101
+ }
102
+
103
+ /** ************************************************************************
104
+ * Recommended. This is a custom column method and is responsible for what
105
+ * is rendered in any column with a name/slug of 'title'. Every time the class
106
+ * needs to render a column, it first looks for a method named
107
+ * column_{$column_title} - if it exists, that method is run. If it doesn't
108
+ * exist, column_default() is called instead.
109
+ *
110
+ * This example also illustrates how to implement rollover actions. Actions
111
+ * should be an associative array formatted as 'slug'=>'link html' - and you
112
+ * will need to generate the URLs yourself. You could even ensure the links
113
+ *
114
+ *
115
+ * @see WP_List_Table::::single_row_columns()
116
+ * @param array $item A singular item (one full row's worth of data)
117
+ * @return string Text to be placed inside the column <td> (movie title only)
118
+ **************************************************************************/
119
+ function column_title($item)
120
+ {
121
+ $edit_link = add_query_arg(
122
+ array(
123
+ 'page' => 'wpcf-edit-usermeta',
124
+ 'group_id' => $item['id']
125
+ ),
126
+ admin_url('admin.php')
127
+ );
128
+
129
+ //Build row actions
130
+ $actions = array(
131
+ 'edit' => sprintf('<a href="%s">%s</a>', $edit_link, __('Edit', 'wpcf')),
132
+ 'status' => 'active' == $item['status']? wpcf_admin_usermeta_get_ajax_deactivation_link($item['id']):wpcf_admin_usermeta_get_ajax_activation_link($item['id']),
133
+ 'delete' => sprintf(
134
+ '<a href="%s" class="submitdelete wpcf-ajax-link" id="wpcf-list-delete-%d"">%s</a>',
135
+ add_query_arg(
136
+ array(
137
+ 'action' => 'wpcf_ajax',
138
+ 'wpcf_action' => 'delete_usermeta_group',
139
+ 'group_id' => $item['id'],
140
+ 'wpcf_ajax_update' => 'wpcf_list_ajax_response_'.$item['id'],
141
+ 'wpcf_ajax_callback' => 'wpcfRefresh',
142
+ '_wpnonce' => wp_create_nonce('delete_usermeta_group'),
143
+ 'wpcf_warning' => urlencode(__('Are you sure?', 'wpcf')),
144
+ ),
145
+ admin_url('admin-ajax.php')
146
+ ),
147
+ $item['id'],
148
+ __('Delete', 'wpcf')
149
+ ),
150
+ );
151
+
152
+ //Return the title contents
153
+ return sprintf(
154
+ '<strong><a href="%s" class="row-title">%s</strong>%s',
155
+ $edit_link,
156
+ $item['title'],
157
+ $this->row_actions($actions)
158
+ );
159
+ }
160
+
161
+ /** ************************************************************************
162
+ * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column
163
+ * is given special treatment when columns are processed. It ALWAYS needs to
164
+ * have it's own method.
165
+ *
166
+ * @see WP_List_Table::::single_row_columns()
167
+ * @param array $item A singular item (one full row's worth of data)
168
+ * @return string Text to be placed inside the column <td> (movie title only)
169
+ **************************************************************************/
170
+ function column_cb($item)
171
+ {
172
+ return sprintf(
173
+ '<input type="checkbox" name="%s[]" value="%s" />',
174
+ $this->bulk_action_field_name,
175
+ $item['id']
176
+ );
177
+ }
178
+
179
+ /** ************************************************************************
180
+ * REQUIRED! This method dictates the table's columns and titles. This should
181
+ * return an array where the key is the column slug (and class) and the value
182
+ * is the column's title text. If you need a checkbox for bulk actions, refer
183
+ * to the $columns array below.
184
+ *
185
+ * The 'cb' column is treated differently than the rest. If including a checkbox
186
+ * column in your table you must create a column_cb() method. If you don't need
187
+ * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
188
+ *
189
+ * @see WP_List_Table::::single_row_columns()
190
+ * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
191
+ **************************************************************************/
192
+ function get_columns()
193
+ {
194
+ $columns = array(
195
+ 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
196
+ 'title' => __('Group Name', 'wpcf'),
197
+ 'description' => __('Description', 'wpcf'),
198
+ 'status' => __('Active', 'wpcf'),
199
+ 'show_for' => __('Available for', 'wpcf'),
200
+ );
201
+ return $columns;
202
+ }
203
+
204
+ /** ************************************************************************
205
+ * Optional. If you want one or more columns to be sortable (ASC/DESC toggle),
206
+ * you will need to register it here. This should return an array where the
207
+ * key is the column that needs to be sortable, and the value is db column to
208
+ * sort by. Often, the key and value will be the same, but this is not always
209
+ * the case (as the value is a column name from the database, not the list table).
210
+ *
211
+ * This method merely defines which columns should be sortable and makes them
212
+ * clickable - it does not handle the actual sorting. You still need to detect
213
+ * the ORDERBY and ORDER querystring variables within prepare_items() and sort
214
+ * your data accordingly (usually by modifying your query).
215
+ *
216
+ * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
217
+ **************************************************************************/
218
+ function get_sortable_columns()
219
+ {
220
+ $sortable_columns = array(
221
+ 'title' => array('title',true), //true means it's already sorted
222
+ 'description' => array('description',false),
223
+ 'status' => array('status',false)
224
+ );
225
+ return $sortable_columns;
226
+ }
227
+
228
+ /** ************************************************************************
229
+ * Optional. If you need to include bulk actions in your list table, this is
230
+ * the place to define them. Bulk actions are an associative array in the format
231
+ * 'slug'=>'Visible Title'
232
+ *
233
+ * If this method returns an empty value, no bulk action will be rendered. If
234
+ * you specify any bulk actions, the bulk actions box will be rendered with
235
+ * the table automatically on display().
236
+ *
237
+ * Also note that list tables are not automatically wrapped in <form> elements,
238
+ * so you will need to create those manually in order for bulk actions to function.
239
+ *
240
+ * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
241
+ **************************************************************************/
242
+ function get_bulk_actions()
243
+ {
244
+ $actions = array(
245
+ 'activate' => __('Activate', 'wpcf'),
246
+ 'deactivate' => __('Deactivate', 'wpcf'),
247
+ );
248
+ return $actions;
249
+ }
250
+
251
+ /** ************************************************************************
252
+ * Optional. You can handle your bulk actions anywhere or anyhow you prefer.
253
+ * For this example package, we will handle it in the class to keep things
254
+ * clean and organized.
255
+ *
256
+ * @global object $wpdb
257
+ *
258
+ * @see $this->prepare_items()
259
+ **************************************************************************/
260
+ function process_bulk_action()
261
+ {
262
+ global $wpdb;
263
+ $action = $this->current_action();
264
+ //Detect when a bulk action is being triggered...
265
+ switch($action) {
266
+ case 'deactivate':
267
+ if (
268
+ true
269
+ && isset($_POST[$this->bulk_action_field_name])
270
+ && !empty($_POST[$this->bulk_action_field_name])
271
+ ) {
272
+ foreach( $_POST[$this->bulk_action_field_name] as $key ) {
273
+ $wpdb->update(
274
+ $wpdb->posts,
275
+ array( 'post_status' => 'draft' ),
276
+ array( 'ID' => $key, 'post_type' => 'wp-types-user-group' ),
277
+ array('%s'),
278
+ array('%d', '%s')
279
+ );
280
+ }
281
+ }
282
+ break;
283
+ case 'activate':
284
+ if (
285
+ true
286
+ && isset($_POST[$this->bulk_action_field_name])
287
+ && !empty($_POST[$this->bulk_action_field_name])
288
+ ) {
289
+ foreach( $_POST[$this->bulk_action_field_name] as $key ) {
290
+ $wpdb->update(
291
+ $wpdb->posts,
292
+ array( 'post_status' => 'publish' ),
293
+ array( 'ID' => $key ),
294
+ array('%s'),
295
+ array('%d')
296
+ );
297
+ }
298
+ }
299
+ break;
300
+ }
301
+ wp_cache_delete(md5('group::_get_group'.'wp-types-user-group'),'types_cache_groups');
302
+ }
303
+
304
+ /** ************************************************************************
305
+ * REQUIRED! This is where you prepare your data for display. This method will
306
+ * usually be used to query the database, sort and filter the data, and generally
307
+ * get it ready to be displayed. At a minimum, we should set $this->items and
308
+ * $this->set_pagination_args(), although the following properties and methods
309
+ * are frequently interacted with here...
310
+ *
311
+ * @uses $this->_column_headers
312
+ * @uses $this->items
313
+ * @uses $this->get_columns()
314
+ * @uses $this->get_sortable_columns()
315
+ * @uses $this->get_pagenum()
316
+ * @uses $this->set_pagination_args()
317
+ **************************************************************************/
318
+ function prepare_items()
319
+ {
320
+ /**
321
+ * First, lets decide how many records per page to show
322
+ */
323
+ $per_page = $this->get_items_per_page('wpcf_uf_per_page', 10);;
324
+
325
+ /**
326
+ * REQUIRED. Now we need to define our column headers. This includes a complete
327
+ * array of columns to be displayed (slugs & titles), a list of columns
328
+ * to keep hidden, and a list of columns that are sortable. Each of these
329
+ * can be defined in another method (as we've done here) before being
330
+ * used to build the value for our _column_headers property.
331
+ */
332
+ $columns = $this->get_columns();
333
+ $hidden = array();
334
+ $sortable = $this->get_sortable_columns();
335
+
336
+ /**
337
+ * REQUIRED. Finally, we build an array to be used by the class for column
338
+ * headers. The $this->_column_headers property takes an array which contains
339
+ * 3 other arrays. One for all columns, one for hidden columns, and one
340
+ * for sortable columns.
341
+ */
342
+ $this->_column_headers = array($columns, $hidden, $sortable);
343
+
344
+ /**
345
+ * Optional. You can handle your bulk actions however you see fit. In this
346
+ * case, we'll handle them within our package just to keep things clean.
347
+ */
348
+ $this->process_bulk_action();
349
+
350
+ /**
351
+ * Instead of querying a database, we're going to fetch the example data
352
+ * property we created for use in this plugin. This makes this example
353
+ * package slightly different than one you might build on your own. In
354
+ * this example, we'll be using array manipulation to sort and paginate
355
+ * our data. In a real-world implementation, you will probably want to
356
+ * use sort and pagination data to build a custom query instead, as you'll
357
+ * be able to use your precisely-queried data immediately.
358
+ */
359
+
360
+ $s = isset($_POST['s'])? mb_strtolower(trim($_POST['s'])):false;
361
+
362
+ $data = array();
363
+ $groups = wpcf_admin_fields_get_groups('wp-types-user-group');
364
+ if ( !empty($groups) ){
365
+ foreach( array_values($groups) as $group ) {
366
+ $one = array(
367
+ 'description' => $group['description'],
368
+ 'id' => $group['id'],
369
+ 'slug' => $group['slug'],
370
+ 'status' => (isset($group['is_active']) && $group['is_active'])? 'active':'inactive',
371
+ 'supports' => isset($group['supports'])? $group['supports']:array(),
372
+ 'title' => $group['name'],
373
+ );
374
+ $add_one = true;
375
+ if ( $s ) {
376
+ $add_one = false;
377
+ foreach( array('description', 'id', 'slug', 'title' ) as $key ) {
378
+ if ( $add_one || empty( $one[$key] ) ) {
379
+ continue;
380
+ }
381
+ if ( is_numeric(strpos(mb_strtolower($one[$key]), $s))) {
382
+ $add_one = true;
383
+ }
384
+ }
385
+ }
386
+ if ( $add_one ) {
387
+ $data[] = $one;
388
+ }
389
+ }
390
+ }
391
+
392
+ /**
393
+ * This checks for sorting input and sorts the data in our array accordingly.
394
+ */
395
+ usort($data, 'wpcf_usort_reorder');
396
+
397
+ /**
398
+ * REQUIRED for pagination. Let's figure out what page the user is currently
399
+ * looking at. We'll need this later, so you should always include it in
400
+ * your own package classes.
401
+ */
402
+ $current_page = $this->get_pagenum();
403
+
404
+ /**
405
+ * REQUIRED for pagination. Let's check how many items are in our data array.
406
+ * In real-world use, this would be the total number of items in your database,
407
+ * without filtering. We'll need this later, so you should always include it
408
+ * in your own package classes.
409
+ */
410
+ $total_items = count($data);
411
+
412
+ /**
413
+ * The WP_List_Table class does not handle pagination for us, so we need
414
+ * to ensure that the data is trimmed to only the current page. We can use
415
+ * array_slice() to
416
+ */
417
+ $data = array_slice($data,(($current_page-1)*$per_page),$per_page);
418
+
419
+ /**
420
+ * REQUIRED. Now we can add our *sorted* data to the items property, where
421
+ * it can be used by the rest of the class.
422
+ */
423
+ $this->items = $data;
424
+
425
+ /**
426
+ * REQUIRED. We also have to register our pagination options & calculations.
427
+ */
428
+ $this->set_pagination_args( array(
429
+ 'total_items' => $total_items, //WE have to calculate the total number of items
430
+ 'per_page' => $per_page, //WE have to determine how many items to show on a page
431
+ 'total_pages' => ceil($total_items/$per_page) //WE have to calculate the total number of pages
432
+ ) );
433
+ }
434
+
435
+ /**
436
+ * Generates content for a single row of the table
437
+ *
438
+ * @since 3.1.0
439
+ * @access public
440
+ *
441
+ * @param object $item The current item
442
+ */
443
+ public function single_row( $item )
444
+ {
445
+ static $row_class = '';
446
+ $row_class = ( $row_class == '' ? 'alternate' : '' );
447
+
448
+ printf('<tr class="%s status-%s">', $row_class, $item['status']);
449
+ $this->single_row_columns( $item );
450
+ echo '</tr>';
451
+ }
452
+
453
+ public function no_items()
454
+ {
455
+ if ( isset($_POST['s']) ) {
456
+ _e('No user field groups found.','wpcf');
457
+ return;
458
+ }
459
+ printf(
460
+ '<p>%s</p>',
461
+ __('User Fields, also known as user-meta, are additional fields that belong to user profiles.','wpcf')
462
+ );
463
+ printf(
464
+ '<a class="button-primary" href="%s">%s</a>',
465
+ add_query_arg(
466
+ array(
467
+ 'page' => 'wpcf-edit-usermeta',
468
+ ),
469
+ admin_url('admin.php')
470
+ ),
471
+ __('Add New Usermeta Group', 'wpcf')
472
+ );
473
+ }
474
+
475
+ }
includes/common-functions.php CHANGED
@@ -3,7 +3,7 @@
3
  *
4
  * Custom types form - common functions
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/includes/common-functions.php $
7
  * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
8
  * $LastChangedRevision: 1069430 $
9
  * $LastChangedBy: iworks $
3
  *
4
  * Custom types form - common functions
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/includes/common-functions.php $
7
  * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
8
  * $LastChangedRevision: 1069430 $
9
  * $LastChangedBy: iworks $
includes/conditional-display.php CHANGED
@@ -31,7 +31,7 @@ function wpcf_cd_form_field_filter( $form, $data ) {
31
  parse_str( $_SERVER['HTTP_REFERER'], $vars );
32
  } else if ( isset( $_GET['group_id'] ) ) {
33
  $vars = array();
34
- $vars['group_id'] = $_GET['group_id'];
35
  }
36
  if ( !isset( $vars['group_id'] ) ) {
37
  return $form + array(
@@ -165,7 +165,7 @@ function wpcf_cd_admin_form_filter( $data, $group = false ) {
165
  'wpcf' ), $count_text ) . '</strong><br />'
166
  . __( "Specify additional filters that control this group's display, based on values of custom fields.",
167
  'wpcf' )
168
- . '<br /><a class="button-secondary" onclick="jQuery(this).css(\'display\',\'none\').next().slideToggle();" ' . $wpcf_button_style30 . ' href="javascript:void(0);">'
169
  . __( 'Edit', 'wpcf' ) . '</a><div id="wpcf-cd-group" class="wpcf-cd-fieldset" style="display:none;">',
170
  );
171
  }
@@ -197,7 +197,7 @@ function wpcf_cd_admin_form_filter( $data, $group = false ) {
197
  $_add_id .= $group ? 'group' : 'field_' . $data['id'];
198
 
199
  // Set link param
200
- $_temp_group_id = isset( $_GET['group_id'] ) ? '&group_id=' . $_GET['group_id'] : '';
201
  $_url = admin_url( 'admin-ajax.php?action=wpcf_ajax&wpcf_action=add_condition'
202
  . $_temp_group_id . '&_wpnonce='
203
  . wp_create_nonce( 'add_condition' ) );
@@ -313,10 +313,21 @@ function wpcf_cd_admin_form_filter( $data, $group = false ) {
313
  ),
314
  );
315
  if ( $group ) {
 
 
 
 
 
 
 
 
 
 
 
 
316
  $form['cd']['wrap_close'] = array(
317
  '#type' => 'markup',
318
- '#markup' => '<br /><a class="button-primary" onclick="jQuery(this).parent().slideUp().prev().css(\'display\',\'static\');" ' . $wpcf_button_style30 . ' href="javascript:void(0);">'
319
- . __( 'OK', 'wpcf' ) . '</a></div>',
320
  );
321
  }
322
  return $group ? $form['cd'] : $form;
31
  parse_str( $_SERVER['HTTP_REFERER'], $vars );
32
  } else if ( isset( $_GET['group_id'] ) ) {
33
  $vars = array();
34
+ $vars['group_id'] = sanitize_text_field( $_GET['group_id'] );
35
  }
36
  if ( !isset( $vars['group_id'] ) ) {
37
  return $form + array(
165
  'wpcf' ), $count_text ) . '</strong><br />'
166
  . __( "Specify additional filters that control this group's display, based on values of custom fields.",
167
  'wpcf' )
168
+ . '<br /><a class="button-secondary" id="conditional-logic-button-open" onclick="jQuery(this).css(\'display\',\'none\').next().slideToggle();" ' . $wpcf_button_style30 . ' href="javascript:void(0);">'
169
  . __( 'Edit', 'wpcf' ) . '</a><div id="wpcf-cd-group" class="wpcf-cd-fieldset" style="display:none;">',
170
  );
171
  }
197
  $_add_id .= $group ? 'group' : 'field_' . $data['id'];
198
 
199
  // Set link param
200
+ $_temp_group_id = isset( $_GET['group_id'] ) ? '&group_id=' . sanitize_text_field( $_GET['group_id'] ) : '';
201
  $_url = admin_url( 'admin-ajax.php?action=wpcf_ajax&wpcf_action=add_condition'
202
  . $_temp_group_id . '&_wpnonce='
203
  . wp_create_nonce( 'add_condition' ) );
313
  ),
314
  );
315
  if ( $group ) {
316
+ $form['cd']['wrap_close_button'] = array(
317
+ '#name' => 'button',
318
+ '#type' => 'button',
319
+ '#value' => __('OK', 'wpcf'),
320
+ '#id' => 'conditional-logic-button-ok',
321
+ '#attributes' => array(
322
+ 'class' => 'button-primary',
323
+ 'href' => '#',
324
+ ),
325
+ '#before' => '<br />',
326
+
327
+ );
328
  $form['cd']['wrap_close'] = array(
329
  '#type' => 'markup',
330
+ '#markup' => '</div>',
 
331
  );
332
  }
333
  return $group ? $form['cd'] : $form;
includes/custom-taxonomies-form.php CHANGED
@@ -3,9 +3,9 @@
3
  *
4
  * Custom taxonomies form
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/includes/custom-taxonomies-form.php $
7
- * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
8
- * $LastChangedRevision: 1069430 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
@@ -24,9 +24,9 @@ function wpcf_admin_custom_taxonomies_form() {
24
  $update = false;
25
 
26
  if ( isset( $_GET['wpcf-tax'] ) ) {
27
- $id = $_GET['wpcf-tax'];
28
  } else if ( isset( $_POST['wpcf-tax'] ) ) {
29
- $id = $_POST['wpcf-tax'];
30
  }
31
 
32
  if ( $id ) {
@@ -93,7 +93,6 @@ function wpcf_admin_custom_taxonomies_form() {
93
  '#markup' => '<div id="post-body-content">',
94
  );
95
 
96
-
97
  $form['table-1-open'] = array(
98
  '#type' => 'markup',
99
  '#markup' => '<table id="wpcf-types-form-name-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="2">' . __( 'Name and description',
@@ -104,19 +103,19 @@ function wpcf_admin_custom_taxonomies_form() {
104
  $form['name'] = array(
105
  '#type' => 'textfield',
106
  '#name' => 'ct[labels][name]',
107
- '#title' => __( 'Custom taxonomy name plural', 'wpcf' ) . ' (<strong>' . __( 'required',
108
- 'wpcf' ) . '</strong>)',
109
  '#description' => '<strong>' . __( 'Enter in plural!', 'wpcf' )
110
- // . '</strong><br />' . __('Alphanumeric with whitespaces only', 'wpcf')
111
  . '.',
112
  '#value' => isset( $ct['labels']['name'] ) ? $ct['labels']['name'] : '',
113
  '#validate' => array(
114
  'required' => array('value' => true),
115
  'maxlength' => array('value' => 30),
116
- // 'alphanumeric' => array('value' => true),
117
  ),
118
  '#pattern' => $table_row,
119
  '#inline' => true,
 
 
 
120
  );
121
  $form['name-singular'] = array(
122
  '#type' => 'textfield',
@@ -125,25 +124,26 @@ function wpcf_admin_custom_taxonomies_form() {
125
  'wpcf' ) . '</strong>)',
126
  '#description' => '<strong>' . __( 'Enter in singular!', 'wpcf' )
127
  . '</strong><br />'
128
- // . __('Alphanumeric with whitespaces only', 'wpcf')
129
  . '.',
130
  '#value' => isset( $ct['labels']['singular_name'] ) ? $ct['labels']['singular_name'] : '',
131
  '#validate' => array(
132
  'required' => array('value' => true),
133
  'maxlength' => array('value' => 30),
134
- // 'alphanumeric' => array('value' => true),
135
  ),
136
  '#pattern' => $table_row,
137
  '#inline' => true,
 
 
 
138
  );
139
 
140
  /*
141
- *
142
  * IF isset $_POST['slug'] it means form is not submitted
143
  */
144
  $attributes = array();
145
  if ( !empty( $_POST['ct']['slug'] ) ) {
146
- $reserved = wpcf_is_reserved_name( $_POST['ct']['slug'], 'taxonomy' );
147
  if ( is_wp_error( $reserved ) ) {
148
  $attributes = array(
149
  'class' => 'wpcf-form-error',
@@ -168,7 +168,10 @@ function wpcf_admin_custom_taxonomies_form() {
168
  'nospecialchars' => array('value' => true),
169
  'maxlength' => array('value' => 30),
170
  ),
171
- '#attributes' => $attributes + array('maxlength' => '30'),
 
 
 
172
  );
173
  $form['description'] = array(
174
  '#type' => 'textarea',
@@ -178,6 +181,7 @@ function wpcf_admin_custom_taxonomies_form() {
178
  '#attributes' => array(
179
  'rows' => 4,
180
  'cols' => 60,
 
181
  ),
182
  '#pattern' => $table_row,
183
  '#inline' => true,
@@ -191,13 +195,16 @@ function wpcf_admin_custom_taxonomies_form() {
191
  '#markup' => '</div>',
192
  );
193
 
194
-
195
  /**
196
  * get box order
197
  */
198
- $meta_box_order_defaults = array(
199
- 'side' => 'submitdiv,wpcf_visibility,post_types',
200
- 'normal' => 'labels,options',
 
 
 
 
201
  );
202
  $screen = get_current_screen();
203
  if ( false == ( $meta_box_order = get_user_option( 'meta-box-order_'.$screen->id) )) {
@@ -208,13 +215,20 @@ function wpcf_admin_custom_taxonomies_form() {
208
  }
209
  }
210
 
211
- $meta_boxes = array(
212
- 'submitdiv' => false,
213
- 'wpcf_visibility' => $ct,
214
- 'post_types' => $ct,
215
- 'labels' => $ct,
216
- 'options' => $ct,
217
- );
 
 
 
 
 
 
 
218
 
219
  /**
220
  * postbox-container-1
@@ -224,7 +238,7 @@ function wpcf_admin_custom_taxonomies_form() {
224
  '#type' => 'markup',
225
  '#markup' => '<div id="postbox-container-1" class="postbox-container"><div class="meta-box-sortables ui-sortable" id="side-sortables">',
226
  );
227
- foreach( explode(',',$meta_box_order['side']) as $key ) {
228
  $function = sprintf('wpcf_admin_metabox_%s', $key);
229
  if ( is_callable($function) ) {
230
  $form += $function($meta_boxes[$key], 'side');
@@ -245,7 +259,7 @@ function wpcf_admin_custom_taxonomies_form() {
245
  '#type' => 'markup',
246
  '#markup' => '<div id="postbox-container-2" class="postbox-container"><div class="meta-box-sortables ui-sortable" id="normal-sortables">',
247
  );
248
- foreach( explode(',',$meta_box_order['normal']) as $key ) {
249
  $function = sprintf('wpcf_admin_metabox_%s', $key);
250
  if ( is_callable($function) ) {
251
  $form += $function($meta_boxes[$key]);
@@ -294,6 +308,9 @@ function wpcf_admin_tax_form_js_validation()
294
 
295
  /**
296
  * Submit function
 
 
 
297
  */
298
  function wpcf_admin_custom_taxonomies_form_submit( $form )
299
  {
@@ -387,8 +404,14 @@ function wpcf_admin_custom_taxonomies_form_submit( $form )
387
  $post_types = get_option( 'wpcf-custom-types', array() );
388
  foreach ( $post_types as $id => $type ) {
389
  if ( array_key_exists( $id, $data['supports'] ) ) {
 
 
 
390
  $post_types[$id]['taxonomies'][$data['slug']] = 1;
391
  } else {
 
 
 
392
  unset( $post_types[$id]['taxonomies'][$data['slug']] );
393
  }
394
  }
@@ -396,6 +419,7 @@ function wpcf_admin_custom_taxonomies_form_submit( $form )
396
  }
397
 
398
  $custom_taxonomies[$tax] = $data;
 
399
  update_option( 'wpcf-custom-taxonomies', $custom_taxonomies );
400
 
401
  // WPML register strings
@@ -695,6 +719,31 @@ function wpcf_admin_metabox_options($data)
695
  '#value' => !empty( $data['update_count_callback'] ) ? $data['update_count_callback'] : '',
696
  '#inline' => true,
697
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
698
  /**
699
  * close
700
  */
3
  *
4
  * Custom taxonomies form
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/includes/custom-taxonomies-form.php $
7
+ * $LastChangedDate: 2015-04-01 14:15:17 +0000 (Wed, 01 Apr 2015) $
8
+ * $LastChangedRevision: 1125405 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
24
  $update = false;
25
 
26
  if ( isset( $_GET['wpcf-tax'] ) ) {
27
+ $id = sanitize_text_field( $_GET['wpcf-tax'] );
28
  } else if ( isset( $_POST['wpcf-tax'] ) ) {
29
+ $id = sanitize_text_field( $_POST['wpcf-tax'] );
30
  }
31
 
32
  if ( $id ) {
93
  '#markup' => '<div id="post-body-content">',
94
  );
95
 
 
96
  $form['table-1-open'] = array(
97
  '#type' => 'markup',
98
  '#markup' => '<table id="wpcf-types-form-name-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="2">' . __( 'Name and description',
103
  $form['name'] = array(
104
  '#type' => 'textfield',
105
  '#name' => 'ct[labels][name]',
106
+ '#title' => __( 'Custom taxonomy name plural', 'wpcf' ) . ' (<strong>' . __( 'required', 'wpcf' ) . '</strong>)',
 
107
  '#description' => '<strong>' . __( 'Enter in plural!', 'wpcf' )
 
108
  . '.',
109
  '#value' => isset( $ct['labels']['name'] ) ? $ct['labels']['name'] : '',
110
  '#validate' => array(
111
  'required' => array('value' => true),
112
  'maxlength' => array('value' => 30),
 
113
  ),
114
  '#pattern' => $table_row,
115
  '#inline' => true,
116
+ '#attributes' => array(
117
+ 'placeholder' => __('Enter custom taxonomy name plural','wpcf'),
118
+ ),
119
  );
120
  $form['name-singular'] = array(
121
  '#type' => 'textfield',
124
  'wpcf' ) . '</strong>)',
125
  '#description' => '<strong>' . __( 'Enter in singular!', 'wpcf' )
126
  . '</strong><br />'
 
127
  . '.',
128
  '#value' => isset( $ct['labels']['singular_name'] ) ? $ct['labels']['singular_name'] : '',
129
  '#validate' => array(
130
  'required' => array('value' => true),
131
  'maxlength' => array('value' => 30),
 
132
  ),
133
  '#pattern' => $table_row,
134
  '#inline' => true,
135
+ '#attributes' => array(
136
+ 'placeholder' => __('Enter custom taxonomy name singular','wpcf'),
137
+ ),
138
  );
139
 
140
  /*
141
+ *
142
  * IF isset $_POST['slug'] it means form is not submitted
143
  */
144
  $attributes = array();
145
  if ( !empty( $_POST['ct']['slug'] ) ) {
146
+ $reserved = wpcf_is_reserved_name( sanitize_text_field( $_POST['ct']['slug'] ), 'taxonomy' );
147
  if ( is_wp_error( $reserved ) ) {
148
  $attributes = array(
149
  'class' => 'wpcf-form-error',
168
  'nospecialchars' => array('value' => true),
169
  'maxlength' => array('value' => 30),
170
  ),
171
+ '#attributes' => $attributes + array(
172
+ 'maxlength' => '30',
173
+ 'placeholder' => __('Enter custom taxonomy slug','wpcf'),
174
+ ),
175
  );
176
  $form['description'] = array(
177
  '#type' => 'textarea',
181
  '#attributes' => array(
182
  'rows' => 4,
183
  'cols' => 60,
184
+ 'placeholder' => __('Enter custom taxonomy description','wpcf'),
185
  ),
186
  '#pattern' => $table_row,
187
  '#inline' => true,
195
  '#markup' => '</div>',
196
  );
197
 
 
198
  /**
199
  * get box order
200
  */
201
+ $meta_box_order_defaults = apply_filters(
202
+ 'wpcf_meta_box_order_defaults',
203
+ array(
204
+ 'side' => array('submitdiv', 'wpcf_visibility', 'post_types'),
205
+ 'normal' => array('labels', 'options'),
206
+ ),
207
+ 'taxonomy'
208
  );
209
  $screen = get_current_screen();
210
  if ( false == ( $meta_box_order = get_user_option( 'meta-box-order_'.$screen->id) )) {
215
  }
216
  }
217
 
218
+ $meta_boxes = array();
219
+ foreach( $meta_box_order_defaults as $key => $value ) {
220
+ foreach($value as $meta_box_key) {
221
+ $meta_boxes[$meta_box_key] = $ct;
222
+ }
223
+ }
224
+ $meta_boxes[ 'submitdiv'] = false;
225
+
226
+ foreach ( $meta_box_order as $key => $value ) {
227
+ if ( is_array($value) ) {
228
+ continue;
229
+ }
230
+ $meta_box_order[$key] = explode(',', $value);
231
+ }
232
 
233
  /**
234
  * postbox-container-1
238
  '#type' => 'markup',
239
  '#markup' => '<div id="postbox-container-1" class="postbox-container"><div class="meta-box-sortables ui-sortable" id="side-sortables">',
240
  );
241
+ foreach( $meta_box_order['side'] as $key ) {
242
  $function = sprintf('wpcf_admin_metabox_%s', $key);
243
  if ( is_callable($function) ) {
244
  $form += $function($meta_boxes[$key], 'side');
259
  '#type' => 'markup',
260
  '#markup' => '<div id="postbox-container-2" class="postbox-container"><div class="meta-box-sortables ui-sortable" id="normal-sortables">',
261
  );
262
+ foreach( $meta_box_order['normal'] as $key ) {
263
  $function = sprintf('wpcf_admin_metabox_%s', $key);
264
  if ( is_callable($function) ) {
265
  $form += $function($meta_boxes[$key]);
308
 
309
  /**
310
  * Submit function
311
+ *
312
+ * @global object $wpdb
313
+ *
314
  */
315
  function wpcf_admin_custom_taxonomies_form_submit( $form )
316
  {
404
  $post_types = get_option( 'wpcf-custom-types', array() );
405
  foreach ( $post_types as $id => $type ) {
406
  if ( array_key_exists( $id, $data['supports'] ) ) {
407
+ if ( empty($post_types[$id]['taxonomies'][$data['slug']]) ) {
408
+ $post_types[$id][TOOLSET_EDIT_LAST] = time();
409
+ }
410
  $post_types[$id]['taxonomies'][$data['slug']] = 1;
411
  } else {
412
+ if ( !empty($post_types[$id]['taxonomies'][$data['slug']]) ) {
413
+ $post_types[$id][TOOLSET_EDIT_LAST] = time();
414
+ }
415
  unset( $post_types[$id]['taxonomies'][$data['slug']] );
416
  }
417
  }
419
  }
420
 
421
  $custom_taxonomies[$tax] = $data;
422
+ $custom_taxonomies[$tax][TOOLSET_EDIT_LAST] = time();
423
  update_option( 'wpcf-custom-taxonomies', $custom_taxonomies );
424
 
425
  // WPML register strings
719
  '#value' => !empty( $data['update_count_callback'] ) ? $data['update_count_callback'] : '',
720
  '#inline' => true,
721
  );
722
+
723
+ $form['meta_box_cb-header'] = array(
724
+ '#type' => 'markup',
725
+ '#markup' => sprintf('<h3>%s</h3>', __('Meta box callback function', 'wpcf')),
726
+ );
727
+ $form['meta_box_cb-disabled'] = array(
728
+ '#type' => 'checkbox',
729
+ '#force_boolean' => true,
730
+ '#title' => __( 'Hide taxonomy meta box.', 'wpcf' ),
731
+ '#name' => 'ct[meta_box_cb][disabled]',
732
+ '#default_value' => !empty( $data['meta_box_cb']['disabled'] ),
733
+ '#inline' => true,
734
+ '#description' => __( 'If you disable this, there will be no metabox on entry edit screen.', 'wpcf' ),
735
+ );
736
+ $hidden = empty( $data['meta_box_cb']['disabled'] ) ? '':' class="hidden"';
737
+ $form['meta_box_cb'] = array(
738
+ '#type' => 'textfield',
739
+ '#name' => 'ct[meta_box_cb][callback]',
740
+ '#title' => __('meta_box_cb', 'wpcf'),
741
+ '#description' => __( 'Provide a callback function name for the meta box display.', 'wpcf' ) . '<br />' . __( 'Default: None.', 'wpcf' ),
742
+ '#value' => !empty( $data['meta_box_cb']['callback']) ? $data['meta_box_cb']['callback'] : '',
743
+ '#inline' => true,
744
+ '#before' => '<div id="wpcf-types-form-meta_box_cb-toggle"' . $hidden . '>',
745
+ '#after' => '</div>',
746
+ );
747
  /**
748
  * close
749
  */
includes/custom-types-form.php CHANGED
@@ -3,9 +3,9 @@
3
  *
4
  * Custom types form
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/includes/custom-types-form.php $
7
- * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
8
- * $LastChangedRevision: 1069430 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
@@ -18,15 +18,16 @@ function wpcf_admin_custom_types_form()
18
  global $wpcf;
19
 
20
  include_once dirname(__FILE__).'/common-functions.php';
 
21
 
22
  $ct = array();
23
  $id = false;
24
  $update = false;
25
 
26
  if ( isset( $_GET['wpcf-post-type'] ) ) {
27
- $id = $_GET['wpcf-post-type'];
28
  } elseif ( isset( $_POST['wpcf-post-type'] ) ) {
29
- $id = $_POST['wpcf-post-type'];
30
  }
31
 
32
  if ( $id ) {
@@ -39,8 +40,7 @@ function wpcf_admin_custom_types_form()
39
  flush_rewrite_rules();
40
  }
41
  } else {
42
- wpcf_admin_message( __( 'Wrong custom post type specified', 'wpcf' ),
43
- 'error' );
44
  return false;
45
  }
46
  } else {
@@ -125,12 +125,10 @@ function wpcf_admin_custom_types_form()
125
  '#title' => __( 'Custom post type name plural', 'wpcf' ) . ' (<strong>' . __( 'required',
126
  'wpcf' ) . '</strong>)',
127
  '#description' => '<strong>' . __( 'Enter in plural!', 'wpcf' )
128
- // . '</strong><br />' . __('Alphanumeric with whitespaces only', 'wpcf')
129
  . '.',
130
  '#value' => isset( $ct['labels']['name'] ) ? $ct['labels']['name'] : '',
131
  '#validate' => array(
132
  'required' => array('value' => 'true'),
133
- // 'alphanumeric' => array('value' => 'true'),
134
  ),
135
  '#pattern' => $table_row,
136
  '#inline' => true,
@@ -138,6 +136,7 @@ function wpcf_admin_custom_types_form()
138
  '#attributes' => array(
139
  'data-wpcf_warning_same_as_slug' => $wpcf->post_types->message( 'warning_singular_plural_match' ),
140
  'data-wpcf_warning_same_as_slug_ignore' => $wpcf->post_types->message( 'warning_singular_plural_match_ignore' ),
 
141
  ),
142
  );
143
  $form['name-singular'] = array(
@@ -147,25 +146,25 @@ function wpcf_admin_custom_types_form()
147
  'wpcf' ) . '</strong>)',
148
  '#description' => '<strong>' . __( 'Enter in singular!', 'wpcf' )
149
  . '</strong><br />'
150
- // . __('Alphanumeric with whitespaces only', 'wpcf')
151
  . '.',
152
  '#value' => isset( $ct['labels']['singular_name'] ) ? $ct['labels']['singular_name'] : '',
153
  '#validate' => array(
154
  'required' => array('value' => 'true'),
155
- // 'alphanumeric' => array('value' => 'true'),
156
  ),
157
  '#pattern' => $table_row,
158
  '#inline' => true,
159
  '#id' => 'name-singular',
 
 
 
160
  );
161
 
162
- /*
163
- *
164
  * IF isset $_POST['slug'] it means form is not submitted
165
  */
166
  $attributes = array();
167
  if ( !empty( $_POST['ct']['slug'] ) ) {
168
- $reserved = wpcf_is_reserved_name( $_POST['ct']['slug'], 'post_type' );
169
  if ( is_wp_error( $reserved ) ) {
170
  $attributes = array(
171
  'class' => 'wpcf-form-error',
@@ -186,7 +185,10 @@ function wpcf_admin_custom_types_form()
186
  'nospecialchars' => array('value' => 'true'),
187
  'maxlength' => array('value' => '20'),
188
  ),
189
- '#attributes' => $attributes + array('maxlength' => '20'),
 
 
 
190
  '#id' => 'slug',
191
  );
192
  $form['description'] = array(
@@ -197,6 +199,7 @@ function wpcf_admin_custom_types_form()
197
  '#attributes' => array(
198
  'rows' => 4,
199
  'cols' => 60,
 
200
  ),
201
  '#pattern' => $table_row,
202
  '#inline' => true,
@@ -422,11 +425,13 @@ function wpcf_admin_custom_types_form()
422
  );
423
 
424
  global $sitepress;
425
- if ( $update && isset( $sitepress )
426
- && version_compare( ICL_SITEPRESS_VERSION, '2.6.2', '>=' )
427
- && function_exists( 'wpml_custom_post_translation_options' ) ) {
 
 
428
  $form['table-1-close']['#markup'] .= wpml_custom_post_translation_options( $ct['slug'] );
429
- }
430
 
431
  $form['post-body-content-close'] = array(
432
  '#type' => 'markup',
@@ -436,9 +441,13 @@ function wpcf_admin_custom_types_form()
436
  /**
437
  * get box order
438
  */
439
- $meta_box_order_defaults = array(
440
- 'side' => 'submitdiv,wpcf_visibility,taxonomies',
441
- 'normal' => 'labels,display_sections,options',
 
 
 
 
442
  );
443
  $screen = get_current_screen();
444
  if ( false == ( $meta_box_order = get_user_option( 'meta-box-order_'.$screen->id) )) {
@@ -449,14 +458,20 @@ function wpcf_admin_custom_types_form()
449
  }
450
  }
451
 
452
- $meta_boxes = array(
453
- 'submitdiv' => false,
454
- 'wpcf_visibility' => $ct,
455
- 'taxonomies' => $ct,
456
- 'labels' => $ct,
457
- 'display_sections' => $ct,
458
- 'options' => $ct,
459
- );
 
 
 
 
 
 
460
 
461
  /**
462
  * postbox-container-1
@@ -466,7 +481,7 @@ function wpcf_admin_custom_types_form()
466
  '#type' => 'markup',
467
  '#markup' => '<div id="postbox-container-1" class="postbox-container"><div class="meta-box-sortables ui-sortable" id="side-sortables">',
468
  );
469
- foreach( explode(',',$meta_box_order['side']) as $key ) {
470
  $function = sprintf('wpcf_admin_metabox_%s', $key);
471
  if ( is_callable($function) ) {
472
  $form += $function($meta_boxes[$key]);
@@ -487,7 +502,7 @@ function wpcf_admin_custom_types_form()
487
  '#type' => 'markup',
488
  '#markup' => '<div id="postbox-container-2" class="postbox-container"><div class="meta-box-sortables ui-sortable">',
489
  );
490
- foreach( explode(',',$meta_box_order['normal']) as $key ) {
491
  $function = sprintf('wpcf_admin_metabox_%s', $key);
492
  if ( is_callable($function) ) {
493
  $form += $function($meta_boxes[$key]);
@@ -536,6 +551,9 @@ function wpcf_admin_types_form_js_validation()
536
 
537
  /**
538
  * Submit function
 
 
 
539
  */
540
  function wpcf_admin_custom_types_form_submit($form)
541
  {
@@ -617,9 +635,11 @@ function wpcf_admin_custom_types_form_submit($form)
617
  /**
618
  * update post meta "_wp_types_group_post_types"
619
  */
620
- $sql = sprintf(
621
- 'select meta_id, meta_value from %s where meta_key = \'%s\'',
622
- $wpdb->postmeta,
 
 
623
  '_wp_types_group_post_types'
624
  );
625
  $all_meta = $wpdb->get_results($sql, OBJECT_K);
@@ -728,6 +748,11 @@ function wpcf_admin_custom_types_form_submit($form)
728
  }
729
  }
730
 
 
 
 
 
 
731
  // Merging protected data
732
  $custom_types[$post_type] = array_merge( $protected_data_check, $data );
733
 
@@ -778,7 +803,7 @@ function wpcf_admin_metabox_submitdiv($cf)
778
  /**
779
  * Visibility
780
  */
781
- function wpcf_admin_metabox_wpcf_visibility($cf)
782
  {
783
  $form = array();
784
  $form['table-2-open'] = wpcf_admin_metabox_begin(__( 'Visibility', 'wpcf' ), 'wpcf_visibility', 'wpcf-types-form-visibility-table', false);
@@ -813,6 +838,16 @@ function wpcf_admin_metabox_wpcf_visibility($cf)
813
  '#pattern' => '<BEFORE><p><LABEL><ELEMENT><ERROR></p><AFTER>',
814
  '#after' => '</div>',
815
  );
 
 
 
 
 
 
 
 
 
 
816
  $form['table-2-close'] = wpcf_admin_metabox_end();
817
  return $form;
818
  }
@@ -860,7 +895,7 @@ function wpcf_admin_metabox_taxonomies($ct)
860
  /**
861
  * Labels
862
  */
863
- function wpcf_admin_metabox_labels($cf)
864
  {
865
  $form = array();
866
  $form['table-4-open'] = wpcf_admin_metabox_begin(__( 'Labels', 'wpcf' ), 'labels', 'wpcf-types-form-table');
@@ -911,12 +946,6 @@ function wpcf_admin_metabox_display_sections($ct)
911
  {
912
  $form = array();
913
  $form['table-5-open'] = wpcf_admin_metabox_begin(__( 'Display Sections', 'wpcf' ), 'display_sections', 'wpcf-types-form-supports-table');
914
- $form['title-editor-warning'] = array(
915
- '#type' => 'markup',
916
- '#markup' => '<div id="wpcf-types-title-editor-warning" class="wpcf-form-error" style="display:none;">'
917
- . __( 'WordPress does not allow disabling both the title and the editor. Please enable at least one of these.',
918
- 'wpcf' ) . '</div>',
919
- );
920
  $options = array(
921
  'title' => array(
922
  '#name' => 'ct[supports][title]',
@@ -926,9 +955,6 @@ function wpcf_admin_metabox_display_sections($ct)
926
  'wpcf' ),
927
  '#inline' => true,
928
  '#id' => 'wpcf-supports-title',
929
- '#attributes' => array(
930
- 'onclick' => 'wpcfTitleEditorCheck();',
931
- ),
932
  ),
933
  'editor' => array(
934
  '#name' => 'ct[supports][editor]',
@@ -937,9 +963,6 @@ function wpcf_admin_metabox_display_sections($ct)
937
  '#description' => __( 'Content input box for writing.', 'wpcf' ),
938
  '#inline' => true,
939
  '#id' => 'wpcf-supports-editor',
940
- '#attributes' => array(
941
- 'onclick' => 'wpcfTitleEditorCheck();',
942
- ),
943
  ),
944
  'comments' => array(
945
  '#name' => 'ct[supports][comments]',
3
  *
4
  * Custom types form
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/includes/custom-types-form.php $
7
+ * $LastChangedDate: 2015-04-01 14:15:17 +0000 (Wed, 01 Apr 2015) $
8
+ * $LastChangedRevision: 1125405 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
18
  global $wpcf;
19
 
20
  include_once dirname(__FILE__).'/common-functions.php';
21
+ include_once dirname(__FILE__).'/fields.php';
22
 
23
  $ct = array();
24
  $id = false;
25
  $update = false;
26
 
27
  if ( isset( $_GET['wpcf-post-type'] ) ) {
28
+ $id = sanitize_text_field( $_GET['wpcf-post-type'] );
29
  } elseif ( isset( $_POST['wpcf-post-type'] ) ) {
30
+ $id = sanitize_text_field( $_POST['wpcf-post-type'] );
31
  }
32
 
33
  if ( $id ) {
40
  flush_rewrite_rules();
41
  }
42
  } else {
43
+ wpcf_admin_message( __( 'Wrong custom post type specified', 'wpcf' ), 'error' );
 
44
  return false;
45
  }
46
  } else {
125
  '#title' => __( 'Custom post type name plural', 'wpcf' ) . ' (<strong>' . __( 'required',
126
  'wpcf' ) . '</strong>)',
127
  '#description' => '<strong>' . __( 'Enter in plural!', 'wpcf' )
 
128
  . '.',
129
  '#value' => isset( $ct['labels']['name'] ) ? $ct['labels']['name'] : '',
130
  '#validate' => array(
131
  'required' => array('value' => 'true'),
 
132
  ),
133
  '#pattern' => $table_row,
134
  '#inline' => true,
136
  '#attributes' => array(
137
  'data-wpcf_warning_same_as_slug' => $wpcf->post_types->message( 'warning_singular_plural_match' ),
138
  'data-wpcf_warning_same_as_slug_ignore' => $wpcf->post_types->message( 'warning_singular_plural_match_ignore' ),
139
+ 'placeholder' => __('Enter post type name plural', 'wpcf' ),
140
  ),
141
  );
142
  $form['name-singular'] = array(
146
  'wpcf' ) . '</strong>)',
147
  '#description' => '<strong>' . __( 'Enter in singular!', 'wpcf' )
148
  . '</strong><br />'
 
149
  . '.',
150
  '#value' => isset( $ct['labels']['singular_name'] ) ? $ct['labels']['singular_name'] : '',
151
  '#validate' => array(
152
  'required' => array('value' => 'true'),
 
153
  ),
154
  '#pattern' => $table_row,
155
  '#inline' => true,
156
  '#id' => 'name-singular',
157
+ '#attributes' => array(
158
+ 'placeholder' => __('Enter post type name singular', 'wpcf' ),
159
+ ),
160
  );
161
 
162
+ /**
 
163
  * IF isset $_POST['slug'] it means form is not submitted
164
  */
165
  $attributes = array();
166
  if ( !empty( $_POST['ct']['slug'] ) ) {
167
+ $reserved = wpcf_is_reserved_name( sanitize_text_field( $_POST['ct']['slug'] ), 'post_type' );
168
  if ( is_wp_error( $reserved ) ) {
169
  $attributes = array(
170
  'class' => 'wpcf-form-error',
185
  'nospecialchars' => array('value' => 'true'),
186
  'maxlength' => array('value' => '20'),
187
  ),
188
+ '#attributes' => $attributes + array(
189
+ 'maxlength' => '20',
190
+ 'placeholder' => __('Enter post type slug', 'wpcf' ),
191
+ ),
192
  '#id' => 'slug',
193
  );
194
  $form['description'] = array(
199
  '#attributes' => array(
200
  'rows' => 4,
201
  'cols' => 60,
202
+ 'placeholder' => __('Enter post type description', 'wpcf' ),
203
  ),
204
  '#pattern' => $table_row,
205
  '#inline' => true,
425
  );
426
 
427
  global $sitepress;
428
+ if (
429
+ $update && isset( $sitepress )
430
+ && version_compare( ICL_SITEPRESS_VERSION, '2.6.2', '>=' )
431
+ && function_exists( 'wpml_custom_post_translation_options' )
432
+ ) {
433
  $form['table-1-close']['#markup'] .= wpml_custom_post_translation_options( $ct['slug'] );
434
+ }
435
 
436
  $form['post-body-content-close'] = array(
437
  '#type' => 'markup',
441
  /**
442
  * get box order
443
  */
444
+ $meta_box_order_defaults = apply_filters(
445
+ 'wpcf_meta_box_order_defaults',
446
+ array(
447
+ 'side' => array('submitdiv', 'wpcf_visibility', 'taxonomies'),
448
+ 'normal' => array('labels', 'display_sections', 'options'),
449
+ ),
450
+ 'post_type'
451
  );
452
  $screen = get_current_screen();
453
  if ( false == ( $meta_box_order = get_user_option( 'meta-box-order_'.$screen->id) )) {
458
  }
459
  }
460
 
461
+ $meta_boxes = array();
462
+ foreach( $meta_box_order_defaults as $key => $value ) {
463
+ foreach($value as $meta_box_key) {
464
+ $meta_boxes[$meta_box_key] = $ct;
465
+ }
466
+ }
467
+ $meta_boxes[ 'submitdiv'] = false;
468
+
469
+ foreach ( $meta_box_order as $key => $value ) {
470
+ if ( is_array($value) ) {
471
+ continue;
472
+ }
473
+ $meta_box_order[$key] = explode(',', $value);
474
+ }
475
 
476
  /**
477
  * postbox-container-1
481
  '#type' => 'markup',
482
  '#markup' => '<div id="postbox-container-1" class="postbox-container"><div class="meta-box-sortables ui-sortable" id="side-sortables">',
483
  );
484
+ foreach( $meta_box_order['side'] as $key ) {
485
  $function = sprintf('wpcf_admin_metabox_%s', $key);
486
  if ( is_callable($function) ) {
487
  $form += $function($meta_boxes[$key]);
502
  '#type' => 'markup',
503
  '#markup' => '<div id="postbox-container-2" class="postbox-container"><div class="meta-box-sortables ui-sortable">',
504
  );
505
+ foreach( $meta_box_order['normal'] as $key ) {
506
  $function = sprintf('wpcf_admin_metabox_%s', $key);
507
  if ( is_callable($function) ) {
508
  $form += $function($meta_boxes[$key]);
551
 
552
  /**
553
  * Submit function
554
+ *
555
+ * @global object $wpdb
556
+ *
557
  */
558
  function wpcf_admin_custom_types_form_submit($form)
559
  {
635
  /**
636
  * update post meta "_wp_types_group_post_types"
637
  */
638
+ $sql = $wpdb->prepare(
639
+ sprintf(
640
+ 'select meta_id, meta_value from %s where meta_key = %%s',
641
+ $wpdb->postmeta
642
+ ),
643
  '_wp_types_group_post_types'
644
  );
645
  $all_meta = $wpdb->get_results($sql, OBJECT_K);
748
  }
749
  }
750
 
751
+ /**
752
+ * set last edit time
753
+ */
754
+ $data[TOOLSET_EDIT_LAST] = time();
755
+
756
  // Merging protected data
757
  $custom_types[$post_type] = array_merge( $protected_data_check, $data );
758
 
803
  /**
804
  * Visibility
805
  */
806
+ function wpcf_admin_metabox_wpcf_visibility($ct)
807
  {
808
  $form = array();
809
  $form['table-2-open'] = wpcf_admin_metabox_begin(__( 'Visibility', 'wpcf' ), 'wpcf_visibility', 'wpcf-types-form-visibility-table', false);
838
  '#pattern' => '<BEFORE><p><LABEL><ELEMENT><ERROR></p><AFTER>',
839
  '#after' => '</div>',
840
  );
841
+ /**
842
+ * dashboard glance option to show counters on admin dashbord widget
843
+ */
844
+ $form['dashboard_glance'] = array(
845
+ '#type' => 'checkbox',
846
+ '#before' => sprintf('<h4>%s</h4>', __( 'Show in Right Now', 'wpcf' )),
847
+ '#name' => 'ct[dashboard_glance]',
848
+ '#title' => __( 'Show number of entries on "At a Glance" admin widget.', 'wpcf' ),
849
+ '#default_value' => !empty( $ct['dashboard_glance'] ),
850
+ );
851
  $form['table-2-close'] = wpcf_admin_metabox_end();
852
  return $form;
853
  }
895
  /**
896
  * Labels
897
  */
898
+ function wpcf_admin_metabox_labels($ct)
899
  {
900
  $form = array();
901
  $form['table-4-open'] = wpcf_admin_metabox_begin(__( 'Labels', 'wpcf' ), 'labels', 'wpcf-types-form-table');
946
  {
947
  $form = array();
948
  $form['table-5-open'] = wpcf_admin_metabox_begin(__( 'Display Sections', 'wpcf' ), 'display_sections', 'wpcf-types-form-supports-table');
 
 
 
 
 
 
949
  $options = array(
950
  'title' => array(
951
  '#name' => 'ct[supports][title]',
955
  'wpcf' ),
956
  '#inline' => true,
957
  '#id' => 'wpcf-supports-title',
 
 
 
958
  ),
959
  'editor' => array(
960
  '#name' => 'ct[supports][editor]',
963
  '#description' => __( 'Content input box for writing.', 'wpcf' ),
964
  '#inline' => true,
965
  '#id' => 'wpcf-supports-editor',
 
 
 
966
  ),
967
  'comments' => array(
968
  '#name' => 'ct[supports][comments]',
includes/custom-types-taxonomies-list.php CHANGED
@@ -3,10 +3,8 @@
3
  * Custom Types and Taxonomies list functions
4
  */
5
 
6
- /**
7
- * Renders 'widefat' table.
8
- */
9
- function wpcf_admin_ctt_list() {
10
  $custom_types = get_option('wpcf-custom-types', array());
11
  $custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
12
 
@@ -18,111 +16,44 @@ function wpcf_admin_ctt_list() {
18
  'wpcf')
19
  . '</p>';
20
  }
 
21
 
22
- echo '<br /><a class="button-secondary" href="'
23
- . admin_url('admin.php?page=wpcf-edit-type')
24
- . '">' . __('Add Custom Post Type', 'wpcf') . '</a>'
25
- . '&nbsp;&nbsp;<a class="button-secondary" href="'
26
- . admin_url('admin.php?page=wpcf-edit-tax')
27
- . '">' . __('Add Custom Taxonomy', 'wpcf') . '</a><br /><br />';
28
- if (!empty($custom_types)) {
29
- $rows = array();
30
- $header = array(
31
- 'name' => __('Post Type Name', 'wpcf'),
32
- 'description' => __('Description', 'wpcf'),
33
- 'active' => __('Active', 'wpcf'),
34
- 'tax' => __('Taxonomies', 'wpcf'),
35
- );
36
- foreach ($custom_types as $post_type => $type) {
37
- $name = '';
38
- $name .= '<a href="'
39
- . admin_url('admin.php?page=wpcf-edit-type&amp;wpcf-post-type='
40
- . $post_type) . '">' . stripslashes(wpcf_translate($post_type . ' name',
41
- $type['labels']['name'], 'Types-CPT')) . '</a>';
42
- $name .= '<br />';
43
- $name .= '<a href="'
44
- . admin_url('admin.php?page=wpcf-edit-type&amp;wpcf-post-type='
45
- . $post_type) . '">' . __('Edit', 'wpcf') . '</a> | ';
46
- $name .= empty($type['disabled']) ? wpcf_admin_custom_types_get_ajax_deactivation_link($post_type) . ' | ' : wpcf_admin_custom_types_get_ajax_activation_link($post_type) . ' | ';
47
- $name .= '<a href="'
48
- . admin_url('admin-ajax.php?action=wpcf_ajax&amp;'
49
- . 'wpcf_action=delete_post_type&amp;wpcf-post-type='
50
- . $post_type . '&amp;wpcf_ajax_update=wpcf_list_ajax_response_'
51
- . $post_type) . '&amp;wpcf_ajax_callback=wpcfRefresh&amp;_wpnonce='
52
- . wp_create_nonce('delete_post_type') . '&amp;wpcf_warning='
53
- . __('Are you sure?', 'wpcf') . '" class="wpcf-ajax-link" id="wpcf-list-delete-'
54
- . $post_type . '">'
55
- . __('Delete Permanently', 'wpcf') . '</a>';
56
- $name .= '<div id="wpcf_list_ajax_response_' . $post_type . '"></div>';
57
- $rows[$post_type]['name'] = $name;
58
- $rows[$post_type]['description'] = isset($type['description']) ? htmlspecialchars(stripslashes(wpcf_translate($post_type . ' description',
59
- $type['description'], 'Types-CPT')),
60
- ENT_QUOTES) : '';
61
- $rows[$post_type]['active-' . $post_type] = !empty($type['disabled']) ? __('No',
62
- 'wpcf') : __('Yes', 'wpcf');
63
- $rows[$post_type]['tax'] = array();
64
- if (!empty($type['taxonomies'])) {
65
- foreach ($type['taxonomies'] as $temp_tax => $true) {
66
- $rows[$post_type]['tax'][] = stripslashes(wpcf_translate($temp_tax . ' name',
67
- $temp_tax, 'Types-TAX'));
68
- }
69
- }
70
- $rows[$post_type]['tax'] = !empty($rows[$post_type]['tax']) ? implode(', ',
71
- $rows[$post_type]['tax']) : __('None', 'wpcf');
72
- }
73
 
74
- // Render table
75
- wpcf_admin_widefat_table('wpcf_types_list', $header, $rows);
76
- }
77
 
78
- if (!empty($custom_taxonomies)) {
79
- $rows = array();
80
- $header = array(
81
- 'name' => __('Taxonomy Name', 'wpcf'),
82
- 'description' => __('Description', 'wpcf'),
83
- 'active' => __('Active', 'wpcf'),
84
- 'post_types' => __('Post Types', 'wpcf'),
85
- );
86
- foreach ($custom_taxonomies as $taxonomy => $data) {
87
- $name = '';
88
- $name .= '<a href="'
89
- . admin_url('admin.php?page=wpcf-edit-tax&amp;wpcf-tax='
90
- . $taxonomy) . '">' . stripslashes(wpcf_translate($taxonomy . ' name',
91
- $data['labels']['name'], 'Types-TAX')) . '</a>';
92
- $name .= '<br />';
93
- $name .= '<a href="'
94
- . admin_url('admin.php?page=wpcf-edit-tax&amp;wpcf-tax='
95
- . $taxonomy) . '">' . __('Edit', 'wpcf') . '</a> | ';
96
- $name .= empty($data['disabled']) ? wpcf_admin_custom_taxonomies_get_ajax_deactivation_link($taxonomy) . ' | ' : wpcf_admin_custom_taxonomies_get_ajax_activation_link($taxonomy) . ' | ';
97
- $name .= '<a href="'
98
- . admin_url('admin-ajax.php?action=wpcf_ajax&amp;'
99
- . 'wpcf_action=delete_taxonomy&amp;wpcf-tax='
100
- . $taxonomy . '&amp;wpcf_ajax_callback=wpcfRefresh&amp;wpcf_ajax_update=wpcf_list_ajax_response_'
101
- . $taxonomy) . '&amp;_wpnonce=' . wp_create_nonce('delete_taxonomy')
102
- . '&amp;wpcf_warning='
103
- . __('Are you sure?', 'wpcf') . '" class="wpcf-ajax-link" id="wpcf-list-delete-'
104
- . $taxonomy . '">'
105
- . __('Delete Permanently', 'wpcf') . '</a>';
106
- $name .= '<div id="wpcf_list_ajax_response_' . $taxonomy . '"></div>';
107
- $rows[$taxonomy]['name'] = $name;
108
- $rows[$taxonomy]['description'] = isset($data['description']) ? htmlspecialchars(stripslashes(wpcf_translate($taxonomy . ' description',
109
- $data['description'], 'Types-TAX')),
110
- ENT_QUOTES) : '';
111
- $rows[$taxonomy]['active-' . $taxonomy] = !empty($data['disabled']) ? __('No',
112
- 'wpcf') : __('Yes', 'wpcf');
113
- $rows[$taxonomy]['post_types'] = array();
114
- if (!empty($data['supports'])) {
115
- foreach ($data['supports'] as $temp_post_type => $true) {
116
- $rows[$taxonomy]['post_types'][] = stripslashes(wpcf_translate($temp_post_type . ' name',
117
- $temp_post_type, 'Types-CPT'));
118
- }
119
- }
120
- $rows[$taxonomy]['post_types'] = !empty($rows[$taxonomy]['post_types']) ? implode(', ',
121
- $rows[$taxonomy]['post_types']) : __('None', 'wpcf');
122
- }
123
- // Render table
124
- echo '<br />';
125
- wpcf_admin_widefat_table('wpcf_tax_list', $header, $rows);
126
- }
127
- do_action('wpcf_types_tax_list_table_after');
128
- }
3
  * Custom Types and Taxonomies list functions
4
  */
5
 
6
+ function wpcf_admin_ctt_list_header()
7
+ {
 
 
8
  $custom_types = get_option('wpcf-custom-types', array());
9
  $custom_taxonomies = get_option('wpcf-custom-taxonomies', array());
10
 
16
  'wpcf')
17
  . '</p>';
18
  }
19
+ }
20
 
21
+ function wpcf_admin_custom_post_types_list()
22
+ {
23
+ include_once dirname(__FILE__).'/classes/class.wpcf.custom.post.types.list.table.php';
24
+ //Create an instance of our package class...
25
+ $listTable = new WPCF_Custom_Post_Types_List_Table();
26
+ //Fetch, prepare, sort, and filter our data...
27
+ $listTable->prepare_items();
28
+ ?>
29
+ <!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
30
+ <form id="cpt-filter" method="post">
31
+ <!-- For plugins, we also need to ensure that the form posts back to our current page -->
32
+ <input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?>" />
33
+ <?php $listTable->search_box(__('Search custom posts', 'wcpf'), 'search_id'); ?>
34
+ <!-- Now we can render the completed list table -->
35
+ <?php $listTable->display() ?>
36
+ </form>
37
+ <?php
38
+ }
39
+
40
+ function wpcf_admin_custom_taxonomies_list()
41
+ {
42
+ include_once dirname(__FILE__).'/classes/class.wpcf.custom.taxonomies.list.table.php';
43
+ //Create an instance of our package class...
44
+ $listTable = new WPCF_Custom_Taxonomies_List_Table();
45
+ //Fetch, prepare, sort, and filter our data...
46
+ $listTable->prepare_items();
47
+ ?>
48
+ <!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
49
+ <form id="ct-filter" method="post">
50
+ <!-- For plugins, we also need to ensure that the form posts back to our current page -->
51
+ <input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?>" />
52
+ <?php $listTable->search_box(__('Search custom taxonomies', 'wcpf'), 'search_id'); ?>
53
+ <!-- Now we can render the completed list table -->
54
+ <?php $listTable->display() ?>
55
+ </form>
56
+ <?php
57
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
 
 
 
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/fields-control.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Custom Fields Control Screen
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/includes/fields-control.php $
6
- * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
7
- * $LastChangedRevision: 1069430 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -25,7 +25,11 @@ function wpcf_admin_custom_fields_control_form($table) {
25
  */
26
  class WPCF_Custom_Fields_Control_Table extends WP_List_Table
27
  {
28
-
 
 
 
 
29
  function prepare_items() {
30
  global $wpdb;
31
  $wpcf_per_page = 15;
@@ -119,10 +123,14 @@ class WPCF_Custom_Fields_Control_Table extends WP_List_Table
119
  $sorted_keys = array();
120
  $new_array = array();
121
  foreach ($cf_types as $cf_id_temp => $cf_temp) {
122
- $sorted_keys[$cf_temp['id']] = strtolower( $cf_temp[$sort_matches[$_REQUEST['orderby']]] );
 
 
 
 
123
  }
124
  asort($sorted_keys, SORT_STRING);
125
- if ($_REQUEST['order'] == 'desc') {
126
  $sorted_keys = array_reverse($sorted_keys, true);
127
  }
128
  foreach ($sorted_keys as $cf_id_temp => $groups_txt) {
@@ -237,22 +245,33 @@ class WPCF_Custom_Fields_Control_Table extends WP_List_Table
237
  $actions['wpcf-remove-from-group-bulk'] = __('Remove from group', 'wpcf');
238
  $actions['wpcf-change-type-bulk'] = __('Change type', 'wpcf');
239
  $actions['wpcf-activate-bulk'] = __("Add to Types control", 'wpcf');
240
- $actions['wpcf-deactivate-bulk'] = __("Stop controlling with Types",
241
- 'wpcf');
242
  $actions['wpcf-delete-bulk'] = __("Delete", 'wpcf');
243
  return $actions;
244
  }
245
 
246
- function view_switcher($current_mode = '') {
247
- echo '<div style="clear:both; margin: 20px 0 10px 0; float: right;"><a class="button button-secondary" href="';
 
 
248
  if (empty($_GET['display_all'])) {
249
- echo esc_url($_SERVER['REQUEST_URI']) . '&amp;display_all=1">' . __('Display all items',
250
- 'wpcf');
251
- } else {
252
- echo esc_url($_SERVER['REQUEST_URI']) . '&amp;display_all=0">' . __('Show pagination',
253
- 'wpcf');
254
  }
255
- echo '</a></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  }
257
 
258
  }
@@ -316,10 +335,18 @@ function wpcf_admin_custom_fields_control_js()
316
  /**
317
  * Submitted Bulk actions.
318
  */
319
- function wpcf_admin_custom_fields_control_bulk_actions($action = '') {
 
 
 
 
 
 
 
320
  if ($action == 'wpcf-deactivate-bulk') {
321
  $fields = wpcf_admin_fields_get_fields(false, true);
322
  foreach ($_POST['fields'] as $field_id) {
 
323
  if (isset($fields[$field_id])) {
324
  $fields[$field_id]['data']['disabled'] = 1;
325
  wpcf_admin_message_store(sprintf(__('Removed from Types control: %s',
@@ -332,7 +359,6 @@ function wpcf_admin_custom_fields_control_bulk_actions($action = '') {
332
  $fields_bulk = wpcf_types_cf_under_control('add',
333
  array('fields' => $_POST['fields']));
334
  foreach ($fields_bulk as $field_id) {
335
- // if (isset($fields[$field_id]) && empty($fields[$field_id]['data']['disabled_by_type'])) {
336
  if (isset($fields[$field_id])) {
337
  $fields[$field_id]['data']['disabled'] = 0;
338
  }
@@ -345,6 +371,7 @@ function wpcf_admin_custom_fields_control_bulk_actions($action = '') {
345
  $failed = array();
346
  $success = array();
347
  foreach ($_POST['fields'] as $field_id) {
 
348
  $response = wpcf_admin_fields_delete_field($field_id);
349
  if (!$response) {
350
  $failed[] = str_replace('_' . md5('wpcf_not_controlled'), '',
@@ -367,7 +394,14 @@ function wpcf_admin_custom_fields_control_bulk_actions($action = '') {
367
  );
368
  }
369
  }
370
- wp_redirect($_SERVER['REQUEST_URI']);
 
 
 
 
 
 
 
371
  die();
372
  }
373
 
@@ -380,8 +414,9 @@ function wpcf_admin_custom_fields_control_bulk_ajax() {
380
  }
381
  if (!empty($_POST)) {
382
  if (!empty($_POST['groups']) && !empty($_POST['fields'])) {
383
- $action = isset($_POST['wpcf_action_control']) ? $_POST['wpcf_action_control'] : 'wpcf-add-to-group-bulk';
384
  foreach ($_POST['groups'] as $group_id) {
 
385
  switch ($action) {
386
  case 'wpcf-add-to-group-bulk':
387
  wpcf_admin_fields_save_group_fields($group_id,
@@ -399,7 +434,7 @@ function wpcf_admin_custom_fields_control_bulk_ajax() {
399
  }
400
  } else if (!empty($_POST['type']) && !empty($_POST['fields'])) {
401
  wpcf_admin_custom_fields_change_type($_POST['fields'],
402
- $_POST['type']);
403
  }
404
  echo '<script type="text/javascript">
405
  window.parent.jQuery("#TB_closeWindowButton").click();
@@ -427,6 +462,7 @@ function wpcf_admin_custom_fields_control_bulk_ajax() {
427
  die('Not valid action');
428
  }
429
  foreach ($_GET['fields'] as $field_id) {
 
430
  $output[$field_id] = array(
431
  '#type' => 'hidden',
432
  '#name' => 'fields[]',
@@ -450,7 +486,7 @@ function wpcf_admin_custom_fields_control_bulk_ajax() {
450
 
451
  /**
452
  * Change type dropdown.
453
- *
454
  * @return array Form array
455
  */
456
  function wpcf_admin_custom_fields_control_change_type_dropdown() {
2
  /*
3
  * Custom Fields Control Screen
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/includes/fields-control.php $
6
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
7
+ * $LastChangedRevision: 1120400 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
25
  */
26
  class WPCF_Custom_Fields_Control_Table extends WP_List_Table
27
  {
28
+ /**
29
+ *
30
+ * @global object $wpdb
31
+ *
32
+ */
33
  function prepare_items() {
34
  global $wpdb;
35
  $wpcf_per_page = 15;
123
  $sorted_keys = array();
124
  $new_array = array();
125
  foreach ($cf_types as $cf_id_temp => $cf_temp) {
126
+ if ( isset($sort_matches[$_REQUEST['orderby']]) ) {
127
+ $sorted_keys[$cf_temp['id']] = strtolower( $cf_temp[$sort_matches[$_REQUEST['orderby']]] );
128
+ } else {
129
+ $sorted_keys[$cf_temp['id']] = strtolower( $cf_temp[$sort_matches['c']] );
130
+ }
131
  }
132
  asort($sorted_keys, SORT_STRING);
133
+ if ('desc' == $_REQUEST['order']) {
134
  $sorted_keys = array_reverse($sorted_keys, true);
135
  }
136
  foreach ($sorted_keys as $cf_id_temp => $groups_txt) {
245
  $actions['wpcf-remove-from-group-bulk'] = __('Remove from group', 'wpcf');
246
  $actions['wpcf-change-type-bulk'] = __('Change type', 'wpcf');
247
  $actions['wpcf-activate-bulk'] = __("Add to Types control", 'wpcf');
248
+ $actions['wpcf-deactivate-bulk'] = __("Stop controlling with Types", 'wpcf');
 
249
  $actions['wpcf-delete-bulk'] = __("Delete", 'wpcf');
250
  return $actions;
251
  }
252
 
253
+ function view_switcher($current_mode = '')
254
+ {
255
+ $display = 0;
256
+ $text = __('Show pagination', 'wpcf');
257
  if (empty($_GET['display_all'])) {
258
+ $display = 1;
259
+ $text = __('Display all items', 'wpcf');
 
 
 
260
  }
261
+ $url = add_query_arg(
262
+ array(
263
+ 'page' => 'wpcf-custom-fields-control',
264
+ 'display_all' => $display,
265
+ ),
266
+ admin_url('admin.php')
267
+ );
268
+ echo '<div style="clear:both; margin: 20px 0 10px 0; float: right;">';
269
+ printf(
270
+ '<a class="button button-secondary" href="%s">%s</a>',
271
+ $url,
272
+ $text
273
+ );
274
+ echo '</div>';
275
  }
276
 
277
  }
335
  /**
336
  * Submitted Bulk actions.
337
  */
338
+ function wpcf_admin_custom_fields_control_bulk_actions($action = '')
339
+ {
340
+ if (
341
+ !isset($_POST['_wpnonce'])
342
+ || !wp_verify_nonce($_POST['_wpnonce'], 'custom_fields_control_bulk')
343
+ ) {
344
+ return;
345
+ }
346
  if ($action == 'wpcf-deactivate-bulk') {
347
  $fields = wpcf_admin_fields_get_fields(false, true);
348
  foreach ($_POST['fields'] as $field_id) {
349
+ $field_id = sanitize_text_field( $field_id );
350
  if (isset($fields[$field_id])) {
351
  $fields[$field_id]['data']['disabled'] = 1;
352
  wpcf_admin_message_store(sprintf(__('Removed from Types control: %s',
359
  $fields_bulk = wpcf_types_cf_under_control('add',
360
  array('fields' => $_POST['fields']));
361
  foreach ($fields_bulk as $field_id) {
 
362
  if (isset($fields[$field_id])) {
363
  $fields[$field_id]['data']['disabled'] = 0;
364
  }
371
  $failed = array();
372
  $success = array();
373
  foreach ($_POST['fields'] as $field_id) {
374
+ $field_id = sanitize_text_field( $field_id );
375
  $response = wpcf_admin_fields_delete_field($field_id);
376
  if (!$response) {
377
  $failed[] = str_replace('_' . md5('wpcf_not_controlled'), '',
394
  );
395
  }
396
  }
397
+ $url = add_query_arg(
398
+ array(
399
+ 'page' => 'wpcf-custom-fields-control',
400
+ 'display_all' => isset($_REQUEST['display_all'])? 1:0,
401
+ ),
402
+ admin_url('admin.php')
403
+ );
404
+ wp_redirect($url);
405
  die();
406
  }
407
 
414
  }
415
  if (!empty($_POST)) {
416
  if (!empty($_POST['groups']) && !empty($_POST['fields'])) {
417
+ $action = isset($_POST['wpcf_action_control']) ? sanitize_text_field( $_POST['wpcf_action_control'] ) : 'wpcf-add-to-group-bulk';
418
  foreach ($_POST['groups'] as $group_id) {
419
+ $group_id = sanitize_text_field( $group_id );
420
  switch ($action) {
421
  case 'wpcf-add-to-group-bulk':
422
  wpcf_admin_fields_save_group_fields($group_id,
434
  }
435
  } else if (!empty($_POST['type']) && !empty($_POST['fields'])) {
436
  wpcf_admin_custom_fields_change_type($_POST['fields'],
437
+ sanitize_text_field( $_POST['type'] ));
438
  }
439
  echo '<script type="text/javascript">
440
  window.parent.jQuery("#TB_closeWindowButton").click();
462
  die('Not valid action');
463
  }
464
  foreach ($_GET['fields'] as $field_id) {
465
+ $field_id = sanitize_text_field( $field_id );
466
  $output[$field_id] = array(
467
  '#type' => 'hidden',
468
  '#name' => 'fields[]',
486
 
487
  /**
488
  * Change type dropdown.
489
+ *
490
  * @return array Form array
491
  */
492
  function wpcf_admin_custom_fields_control_change_type_dropdown() {
includes/fields-form.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Fields and groups form functions.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/includes/fields-form.php $
6
- * $LastChangedDate: 2015-01-28 06:42:34 +0000 (Wed, 28 Jan 2015) $
7
- * $LastChangedRevision: 1077234 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -22,22 +22,31 @@ if ( version_compare( $wp_version, '3.5', '<' ) ) {
22
 
23
  /**
24
  * Saves fields and groups.
25
- *
26
  * If field name is changed in specific group - new one will be created,
27
  * otherwise old one will be updated and will appear in that way in other grups.
28
- *
29
- * @return type
30
  */
31
- function wpcf_admin_save_fields_groups_submit( $form ) {
32
- if ( !isset( $_POST['wpcf']['group']['name'] ) ) {
 
 
 
 
 
33
  return false;
34
  }
35
- $_POST['wpcf']['group']['name'] = trim( $_POST['wpcf']['group']['name'] );
 
36
 
37
- $_POST['wpcf']['group'] = apply_filters( 'wpcf_group_pre_save',
38
- $_POST['wpcf']['group'] );
39
 
40
- global $wpdb;
 
 
 
 
41
 
42
  $new_group = false;
43
 
@@ -46,37 +55,45 @@ function wpcf_admin_save_fields_groups_submit( $form ) {
46
  // Basic check
47
  if ( isset( $_REQUEST['group_id'] ) ) {
48
  // Check if group exists
49
- $post = get_post( $_REQUEST['group_id'] );
50
  // Name changed
51
  if ( strtolower( $_POST['wpcf']['group']['name'] ) != strtolower( $post->post_title ) ) {
52
  // Check if already exists
53
- $exists = get_page_by_title( $_POST['wpcf']['group']['name'],
54
- 'OBJECT', 'wp-types-group' );
55
  if ( !empty( $exists ) ) {
56
  $form->triggerError();
57
- wpcf_admin_message( sprintf( __( "A group by name <em>%s</em> already exists. Please use a different name and save again.",
58
- 'wpcf' ),
59
- $_POST['wpcf']['group']['name'] ), 'error' );
 
 
 
 
60
  return $form;
61
  }
62
  }
63
  if ( empty( $post ) || $post->post_type != 'wp-types-group' ) {
64
  $form->triggerError();
65
- wpcf_admin_message( sprintf( __( "Wrong group ID %d", 'wpcf' ),
66
- intval( $_REQUEST['group_id'] ) ), 'error' );
 
 
67
  return $form;
68
  }
69
  $group_id = $post->ID;
70
  } else {
71
  $new_group = true;
72
  // Check if already exists
73
- $exists = get_page_by_title( $_POST['wpcf']['group']['name'], 'OBJECT',
74
- 'wp-types-group' );
75
  if ( !empty( $exists ) ) {
76
  $form->triggerError();
77
- wpcf_admin_message( sprintf( __( "A group by name <em>%s</em> already exists. Please use a different name and save again.",
78
- 'wpcf' ), $_POST['wpcf']['group']['name'] ),
79
- 'error' );
 
 
 
 
80
  return $form;
81
  }
82
  }
@@ -153,7 +170,7 @@ function wpcf_admin_save_fields_groups_submit( $form ) {
153
  }
154
  // Rename if needed
155
  if ( isset( $_REQUEST['group_id'] ) ) {
156
- $_POST['wpcf']['group']['id'] = $_REQUEST['group_id'];
157
  }
158
 
159
  $group_id = wpcf_admin_fields_save_group( $_POST['wpcf']['group'] );
@@ -219,11 +236,11 @@ function wpcf_admin_fields_form() {
219
  wpcf_admin_message( sprintf( __( "Group with ID %d do not exist",
220
  'wpcf' ), intval( $_REQUEST['group_id'] ) ) );
221
  } else {
222
- $update['fields'] = wpcf_admin_fields_get_fields_by_group( $_REQUEST['group_id'], 'slug', false, true );
223
- $update['post_types'] = wpcf_admin_get_post_types_by_group( $_REQUEST['group_id'] );
224
- $update['taxonomies'] = wpcf_admin_get_taxonomies_by_group( $_REQUEST['group_id'] );
225
- $update['templates'] = wpcf_admin_get_templates_by_group( $_REQUEST['group_id'] );
226
- $update['admin_styles'] = wpcf_admin_get_groups_admin_styles_by_group( $_REQUEST['group_id'] );
227
  }
228
  }
229
 
@@ -356,50 +373,33 @@ function wpcf_admin_fields_form() {
356
  '#type' => 'textfield',
357
  '#name' => 'wpcf[group][name]',
358
  '#id' => 'wpcf-group-name',
359
- '#value' => $update ? $update['name'] : __( 'Enter group title', 'wpcf' ),
360
  '#inline' => true,
361
- '#attributes' => array('style' => 'width:100%;margin-bottom:10px;'),
 
 
 
362
  '#validate' => array(
363
  'required' => array(
364
  'value' => true,
365
  ),
366
  )
367
  );
368
- if ( !$update ) {
369
- $form['title']['#attributes']['data-label'] = addcslashes(__( 'Enter group title', 'wpcf' ), '"');
370
- $form['title']['#attributes']['onfocus'] = 'if (jQuery(this).val() == jQuery(this).data(\'label\')) { jQuery(this).val(\'\'); }';
371
- $form['title']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(jQuery(this).data(\'label\')) }';
372
- }
373
  $form['description'] = array(
374
  '#type' => 'textarea',
375
  '#id' => 'wpcf-group-description',
376
  '#name' => 'wpcf[group][description]',
377
- '#value' => $update ? $update['description'] : __( 'Enter a description for this group', 'wpcf' ),
 
 
 
378
  );
379
- if ( !$update ) {
380
- $form['description']['#attributes']['data-label'] = addcslashes(__( 'Enter a description for this group', 'wpcf' ), '"');
381
- $form['description']['#attributes']['onfocus'] = 'if (jQuery(this).val() == jQuery(this).data(\'label\')) { jQuery(this).val(\'\'); }';
382
- $form['description']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(jQuery(this).data(\'label\')) }';
383
- }
384
 
385
- /*
386
- *
387
- *
388
- *
389
- *
390
- *
391
- *
392
- *
393
- *
394
- *
395
- *
396
- *
397
- *
398
- *
399
- *
400
- *
401
  * FILTER BOX
402
  * Since Types 1.2 we moved JS to /embedded/resources/js/custom-fields-form-filter.js
 
403
  */
404
  // Support post types and taxonomies
405
 
@@ -431,17 +431,7 @@ function wpcf_admin_fields_form() {
431
  }
432
 
433
 
434
- /*
435
- *
436
- *
437
- *
438
- *
439
- *
440
- *
441
- *
442
- *
443
- *
444
- *
445
  * POST TYPE FILTER
446
  */
447
  $temp = array(
@@ -450,8 +440,7 @@ function wpcf_admin_fields_form() {
450
  '#name' => 'wpcf[group][supports]',
451
  '#inline' => true,
452
  );
453
- /*
454
- *
455
  * Here we use unique function for all filters
456
  * Since Types 1.2
457
  */
@@ -460,15 +449,7 @@ function wpcf_admin_fields_form() {
460
  implode( ',', $post_types_currently_supported ),
461
  __( 'Displayed on all content types', 'wpcf' ), $temp );
462
 
463
- /*
464
- *
465
- *
466
- *
467
- *
468
- *
469
- *
470
- *
471
- *
472
  * TAXONOMIES FILTER QUERY
473
  */
474
  $taxonomies = apply_filters( 'wpcf_group_form_filter_taxonomies', get_taxonomies( '', 'objects' ) );
@@ -478,9 +459,7 @@ function wpcf_admin_fields_form() {
478
  $form_tax_single = array();
479
 
480
 
481
- /*
482
- *
483
- *
484
  * Filter toxonomies
485
  */
486
  foreach ( $taxonomies as $category_slug => $category ) {
@@ -533,11 +512,7 @@ function wpcf_admin_fields_form() {
533
  $tax_currently_supported[] = __( 'Not Selected', 'wpcf' );
534
  }
535
 
536
- /*
537
- *
538
- *
539
- *
540
- *
541
  * Since Types 1.2 we use unique function
542
  */
543
  $form_tax = _wpcf_filter_wrap( 'custom_taxonomies', __( 'Terms:', 'wpcf' ),
@@ -546,20 +521,7 @@ function wpcf_admin_fields_form() {
546
 
547
 
548
 
549
- /*
550
- *
551
- *
552
- *
553
- *
554
- *
555
- *
556
- *
557
- *
558
- *
559
- *
560
- *
561
- *
562
- *
563
  * TEMPLATES
564
  */
565
  // Choose templates
@@ -569,8 +531,7 @@ function wpcf_admin_fields_form() {
569
  $options = array();
570
  $options['default-template'] = array(
571
  '#title' => __( 'Default Template' ),
572
- '#default_value' => !empty( $update['templates'] ) && in_array( 'default',
573
- $update['templates'] ),
574
  '#name' => 'wpcf[group][templates][]',
575
  '#value' => 'default',
576
  '#inline' => true,
@@ -579,8 +540,7 @@ function wpcf_admin_fields_form() {
579
  foreach ( $templates as $template_name => $template_filename ) {
580
  $options[$template_filename] = array(
581
  '#title' => $template_name,
582
- '#default_value' => !empty( $update['templates'] ) && in_array( $template_filename,
583
- $update['templates'] ),
584
  '#name' => 'wpcf[group][templates][]',
585
  '#value' => $template_filename,
586
  '#inline' => true,
@@ -590,8 +550,7 @@ function wpcf_admin_fields_form() {
590
  foreach ( $templates_views as $template_view ) {
591
  $options[$template_view->post_name] = array(
592
  '#title' => 'View Template ' . $template_view->post_title,
593
- '#default_value' => !empty( $update['templates'] ) && in_array( $template_view->ID,
594
- $update['templates'] ),
595
  '#name' => 'wpcf[group][templates][]',
596
  '#value' => $template_view->ID,
597
  '#inline' => true,
@@ -629,37 +588,19 @@ function wpcf_admin_fields_form() {
629
  '#options' => $options,
630
  '#inline' => true,
631
  );
632
- // $form['templates'] = wpcf_admin_fields_form_nested_elements('templates',
633
- // $form['templates'], __('Content templates:', 'wpcf'), $text,
634
- // $empty_txt);
635
 
636
- /*
637
- *
638
- *
639
- *
640
- *
641
  * Since Types 1.2 we use unique function
642
  */
643
- $form_templates = _wpcf_filter_wrap( 'templates',
644
- __( 'Templates:', 'wpcf' ), $text, __( 'Not Selected', 'wpcf' ),
645
- $form_templates );
646
-
647
-
648
-
649
-
650
 
651
- /*
652
- *
653
- *
654
- *
655
- *
656
- *
657
- *
658
- *
659
- *
660
- *
661
- *
662
- *
663
  * Now starting form
664
  */
665
  $form['supports-table-open'] = array(
@@ -672,14 +613,8 @@ function wpcf_admin_fields_form() {
672
  'wpcf' )
673
  . '</p>',
674
  );
675
- /*
676
- *
677
- *
678
- *
679
- *
680
- *
681
- *
682
- *
683
  * Join filter forms
684
  */
685
  // Types
@@ -707,19 +642,10 @@ function wpcf_admin_fields_form() {
707
  '#markup' => '</p>',
708
  );
709
 
710
-
711
- /*
712
- *
713
- *
714
- *
715
- *
716
- *
717
- *
718
- *
719
  * TODO Code from now on should be revised
720
  */
721
 
722
-
723
  $count = 0;
724
  $count +=!empty( $update['post_types'] ) ? 1 : 0;
725
  $count +=!empty( $update['taxonomies'] ) ? 1 : 0;
@@ -821,7 +747,6 @@ function wpcf_admin_fields_form() {
821
  '#type' => 'textarea',
822
  '#name' => 'wpcf[group][admin_html_preview]',
823
  '#inline' => true,
824
- '#value' => '',
825
  '#id' => 'wpcf-form-groups-admin-html-preview',
826
  '#before' => '<h3>Field group HTML</h3>'
827
  );
@@ -834,21 +759,18 @@ function wpcf_admin_fields_form() {
834
  '#default_value' => '',
835
  '#id' => 'wpcf-form-groups-css-fields-editor',
836
  '#after' => '
837
- <div class="wpcf-update-preview-btn"><input type="button" value="Update preview" onclick="wpcfPreviewHtml()" style="float:right;" class="button-secondary"></div>
838
- <h3>Field group preview</h3>
839
- <div id="wpcf-update-preview-div">Preview here</div>
840
- <script type="text/javascript">
841
- var wpcfReadOnly = ' . json_encode( $preview_profile ) . ';
842
- var wpcfEditMode = ' . json_encode( $edit_profile ) . ';
843
- var wpcfDefaultCss = ' . json_encode( $admin_styles_value ) . ';
844
- </script>
845
- ',
846
  '#before' => '<h3>Your CSS</h3>'
847
  );
848
 
849
-
850
-
851
-
852
  $admin_styles = _wpcf_filter_wrap( 'admin_styles',
853
  __( 'Admin styles for fields:', 'wpcf' ), '', '', $temp,
854
  __( 'Open style editor', 'wpcf' ) );
@@ -974,20 +896,20 @@ function wpcf_admin_fields_form() {
974
 
975
  /**
976
  * Dynamically adds new field on AJAX call.
977
- *
978
- * @param type $form_data
979
  */
980
  function wpcf_fields_insert_ajax( $form_data = array() ) {
981
- echo wpcf_fields_get_field_form( $_GET['field'] );
982
  }
983
 
984
  /**
985
  * Dynamically adds existing field on AJAX call.
986
- *
987
- * @param type $form_data
988
  */
989
  function wpcf_fields_insert_existing_ajax() {
990
- $field = wpcf_admin_fields_get_field( $_GET['field'], false, true );
991
  if ( !empty( $field ) ) {
992
  echo wpcf_fields_get_field_form( $field['type'], $field );
993
  } else {
@@ -997,10 +919,10 @@ function wpcf_fields_insert_existing_ajax() {
997
 
998
  /**
999
  * Returns HTML formatted field form (draggable).
1000
- *
1001
  * @param type $type
1002
  * @param type $form_data
1003
- * @return type
1004
  */
1005
  function wpcf_fields_get_field_form( $type, $form_data = array() ) {
1006
  $form = wpcf_fields_get_field_form_data( $type, $form_data );
@@ -1033,10 +955,10 @@ function wpcf_fields_get_field_form( $type, $form_data = array() ) {
1033
 
1034
  /**
1035
  * Processes field form data.
1036
- *
1037
  * @param type $type
1038
  * @param type $form_data
1039
- * @return type
1040
  */
1041
  function wpcf_fields_get_field_form_data( $type, $form_data = array() ) {
1042
 
@@ -1123,31 +1045,26 @@ function wpcf_fields_get_field_form_data( $type, $form_data = array() ) {
1123
  $form_field['name'] = array(
1124
  '#type' => 'textfield',
1125
  '#name' => 'name',
1126
- '#attributes' => array('class' => 'wpcf-forms-set-legend wpcf-forms-field-name', 'style' => 'width:100%;margin:10px 0 10px 0;'),
 
 
 
 
1127
  '#validate' => array('required' => array('value' => true)),
1128
  '#inline' => true,
1129
- '#value' => __( 'Enter field name', 'wpcf' ),
1130
  );
1131
- if ( empty( $form_data['name'] ) ) {
1132
- $form_field['name']['#attributes']['onclick'] = 'if (jQuery(this).val() == \''
1133
- . __( 'Enter field name', 'wpcf' ) . '\') { jQuery(this).val(\'\'); }';
1134
- $form_field['name']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(\''
1135
- . __( 'Enter field name', 'wpcf' ) . '\') }';
1136
- }
1137
  $form_field['slug'] = array(
1138
  '#type' => 'textfield',
1139
  '#name' => 'slug',
1140
- '#attributes' => array('class' => 'wpcf-forms-field-slug', 'style' => 'width:100%;margin:0 0 10px 0;'),
 
 
 
 
 
1141
  '#validate' => array('nospecialchars' => array('value' => true)),
1142
  '#inline' => true,
1143
- '#value' => __( 'Enter field slug', 'wpcf' ),
1144
  );
1145
- if ( empty( $form_data['slug'] ) ) {
1146
- $form_field['slug']['#attributes']['onclick'] = 'if (jQuery(this).val() == \''
1147
- . __( 'Enter field slug', 'wpcf' ) . '\') { jQuery(this).val(\'\'); }';
1148
- $form_field['slug']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(\''
1149
- . __( 'Enter field slug', 'wpcf' ) . '\') }';
1150
- }
1151
 
1152
  // If insert form callback is not provided, use generic form data
1153
  if ( function_exists( 'wpcf_fields_' . $type . '_insert_form' ) ) {
@@ -1164,27 +1081,49 @@ function wpcf_fields_get_field_form_data( $type, $form_data = array() ) {
1164
  $form_field['description'] = array(
1165
  '#type' => 'textarea',
1166
  '#name' => 'description',
1167
- '#attributes' => array('rows' => 5, 'cols' => 1, 'style' => 'margin:0 0 10px 0;'),
 
 
 
 
 
1168
  '#inline' => true,
1169
- '#value' => __( 'Describe this field', 'wpcf' ),
1170
  );
1171
- if ( empty( $form_data['description'] ) ) {
1172
- $form_field['description']['#attributes']['onfocus'] = 'if (jQuery(this).val() == \''
1173
- . __( 'Describe this field', 'wpcf' ) . '\') { jQuery(this).val(\'\'); }';
1174
- $form_field['description']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(\''
1175
- . __( 'Describe this field', 'wpcf' ) . '\') }';
1176
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1177
 
1178
  if ( wpcf_admin_can_be_repetitive( $type ) ) {
1179
  $temp_warning_message = '';
1180
- // $temp_warning_message .= '<div class="wpcf-message wpcf-cd-repetitive-warning wpcf-error"';
1181
- // if (empty($form_data['data']['repetitive'])) {
1182
- // $temp_warning_message .= ' style="display:none;"';
1183
- // }
1184
- // $temp_warning_message .= '><p>'
1185
- // . __('Since this field is repeating, you cannot use it to control the display of other fields.',
1186
- // 'wpcf')
1187
- // . '</p></div>';
1188
  $form_field['repetitive'] = array(
1189
  '#type' => 'radios',
1190
  '#name' => 'repetitive',
@@ -1204,7 +1143,6 @@ function wpcf_fields_get_field_form_data( $type, $form_data = array() ) {
1204
  ),
1205
  ),
1206
  '#default_value' => isset( $form_data['data']['repetitive'] ) ? $form_data['data']['repetitive'] : '0',
1207
- // '#attributes' => array('onclick' => 'if (jQuery(this).is(\':checked\')) { jQuery(this).parent().find(\'.wpcf-cd-warning\').hide(); jQuery(this).parent().find(\'.wpcf-cd-repetitive-warning\').show(); } else { jQuery(this).parent().find(\'.wpcf-cd-warning\').show(); jQuery(this).parent().find(\'.wpcf-cd-repetitive-warning\').hide(); }'),
1208
  '#after' => wpcf_admin_is_repetitive( $form_data ) ? '<div class="wpcf-message wpcf-cd-warning wpcf-error" style="display:none;"><p>' . __( "There may be multiple instances of this field already. When you switch back to single-field mode, all values of this field will be updated when it's edited.",
1209
  'wpcf' ) . '</p></div>' . $temp_warning_message : $temp_warning_message,
1210
  );
@@ -1296,11 +1234,11 @@ function wpcf_fields_get_field_form_data( $type, $form_data = array() ) {
1296
 
1297
  /**
1298
  * Adds validation box.
1299
- *
1300
  * @param type $name
1301
  * @param string $field
1302
  * @param type $form_data
1303
- * @return type
1304
  */
1305
  function wpcf_admin_fields_form_validation( $name, $field, $form_data = array() ) {
1306
  $form = array();
@@ -1385,10 +1323,10 @@ function wpcf_admin_fields_form_js_validation() {
1385
 
1386
  /**
1387
  * Saves open fieldsets.
1388
- *
1389
  * @param type $action
1390
  * @param type $fieldset
1391
- * @param type $group_id
1392
  */
1393
  function wpcf_admin_fields_form_save_open_fieldset( $action, $fieldset,
1394
  $group_id = false ) {
@@ -1412,10 +1350,10 @@ function wpcf_admin_fields_form_save_open_fieldset( $action, $fieldset,
1412
 
1413
  /**
1414
  * Saves open fieldsets.
1415
- *
1416
  * @param type $action
1417
  * @param type $fieldset
1418
- * @param type $group_id
1419
  */
1420
  function wpcf_admin_fields_form_fieldset_is_collapsed( $fieldset ) {
1421
  if ( isset( $_REQUEST['group_id'] ) ) {
@@ -1432,15 +1370,15 @@ function wpcf_admin_fields_form_fieldset_is_collapsed( $fieldset ) {
1432
 
1433
  /**
1434
  * Adds 'Edit' and 'Cancel' buttons, expandable div.
1435
- *
1436
  * @todo REMOVE THIS - Since Types 1.2 we do not need it
1437
- *
1438
  * @param type $id
1439
  * @param type $element
1440
  * @param type $title
1441
  * @param type $list
1442
  * @param type $empty_txt
1443
- * @return string
1444
  */
1445
  function wpcf_admin_fields_form_nested_elements( $id, $element, $title, $list,
1446
  $empty_txt ) {
@@ -1479,33 +1417,33 @@ function wpcf_admin_fields_form_nested_elements( $id, $element, $title, $list,
1479
  }
1480
 
1481
  /*
1482
- *
1483
- *
1484
- *
1485
- *
1486
- *
1487
- *
1488
- *
1489
- *
1490
- *
1491
- *
1492
- *
1493
- *
1494
- *
1495
- *
1496
- *
1497
- *
1498
- *
1499
- *
1500
- *
1501
- *
1502
  * From here add revised code
1503
  */
1504
 
1505
  /**
1506
- *
1507
  * Use this to show filter item
1508
- *
1509
  * @since Types 1.2
1510
  * @global type $wpcf_button_style
1511
  * @global type $wpcf_button_style30
@@ -1531,7 +1469,7 @@ function _wpcf_filter_wrap( $id, $title, $txt, $txt_empty, $e, $edit_button = ''
1531
  $edit = $edit_button;
1532
  }
1533
  /*
1534
- *
1535
  * Title and Edit button
1536
  */
1537
  $form['filter_' . $unique_id . '_wrapper'] = array(
@@ -1545,9 +1483,7 @@ function _wpcf_filter_wrap( $id, $title, $txt, $txt_empty, $e, $edit_button = ''
1545
  . $edit . '</a><div class="hidden" id="wpcf-form-fields-' . $id . '">',
1546
  );
1547
 
1548
- /*
1549
- *
1550
- *
1551
  * Form element as param
1552
  * It may be single element or array of elements
1553
  * Simply check if array has #type - indicates it is a form item
@@ -1556,15 +1492,12 @@ function _wpcf_filter_wrap( $id, $title, $txt, $txt_empty, $e, $edit_button = ''
1556
  $form['filter_' . $unique_id . '_items'] = $e;
1557
  } else {
1558
  /*
1559
- *
1560
  * If array of elements just join
1561
  */
1562
  $form = $form + (array) $e;
1563
  }
1564
 
1565
- /*
1566
- *
1567
- *
1568
  * OK button
1569
  */
1570
  $form['filter_' . $unique_id . '_ok'] = array(
@@ -1577,9 +1510,7 @@ function _wpcf_filter_wrap( $id, $title, $txt, $txt_empty, $e, $edit_button = ''
1577
  . __( 'OK', 'wpcf' ) . '</a>&nbsp;',
1578
  );
1579
 
1580
- /*
1581
- *
1582
- *
1583
  * Cancel button
1584
  */
1585
  $form['filter_' . $unique_id . '_cancel'] = array(
@@ -1592,9 +1523,7 @@ function _wpcf_filter_wrap( $id, $title, $txt, $txt_empty, $e, $edit_button = ''
1592
  . __( 'Cancel', 'wpcf' ) . '</a>',
1593
  );
1594
 
1595
- /*
1596
- *
1597
- *
1598
  * Close wrapper
1599
  */
1600
  $form['filter_' . $unique_id . 'wrapper_close'] = array(
2
  /*
3
  * Fields and groups form functions.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/includes/fields-form.php $
6
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
7
+ * $LastChangedRevision: 1120400 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
22
 
23
  /**
24
  * Saves fields and groups.
25
+ *
26
  * If field name is changed in specific group - new one will be created,
27
  * otherwise old one will be updated and will appear in that way in other grups.
28
+ *
29
+ * @return type
30
  */
31
+ function wpcf_admin_save_fields_groups_submit( $form )
32
+ {
33
+ if (
34
+ !isset( $_POST['wpcf'] )
35
+ || !isset( $_POST['wpcf']['group'] )
36
+ || !isset( $_POST['wpcf']['group']['name'] )
37
+ ) {
38
  return false;
39
  }
40
+ // @todo maybe sanitize_text_field this too
41
+ $_POST['wpcf']['group']['name'] = trim(strip_tags($_POST['wpcf']['group']['name']));
42
 
43
+ $_POST['wpcf']['group'] = apply_filters( 'wpcf_group_pre_save', $_POST['wpcf']['group'] );
 
44
 
45
+ if ( empty($_POST['wpcf']['group']['name']) ) {
46
+ $form->triggerError();
47
+ wpcf_admin_message( __( 'Group name can not be empty.', 'wpcf' ), 'error');
48
+ return $form;
49
+ }
50
 
51
  $new_group = false;
52
 
55
  // Basic check
56
  if ( isset( $_REQUEST['group_id'] ) ) {
57
  // Check if group exists
58
+ $post = get_post( intval($_REQUEST['group_id']) );
59
  // Name changed
60
  if ( strtolower( $_POST['wpcf']['group']['name'] ) != strtolower( $post->post_title ) ) {
61
  // Check if already exists
62
+ $exists = get_page_by_title( $_POST['wpcf']['group']['name'], 'OBJECT', 'wp-types-group' );
 
63
  if ( !empty( $exists ) ) {
64
  $form->triggerError();
65
+ wpcf_admin_message(
66
+ sprintf(
67
+ __( "A group by name <em>%s</em> already exists. Please use a different name and save again.", 'wpcf' ),
68
+ htmlspecialchars($_POST['wpcf']['group']['name'])
69
+ ),
70
+ 'error'
71
+ );
72
  return $form;
73
  }
74
  }
75
  if ( empty( $post ) || $post->post_type != 'wp-types-group' ) {
76
  $form->triggerError();
77
+ wpcf_admin_message(
78
+ sprintf( __( "Wrong group ID %d", 'wpcf' ), intval( $_REQUEST['group_id'] ) ),
79
+ 'error'
80
+ );
81
  return $form;
82
  }
83
  $group_id = $post->ID;
84
  } else {
85
  $new_group = true;
86
  // Check if already exists
87
+ $exists = get_page_by_title( $_POST['wpcf']['group']['name'], 'OBJECT', 'wp-types-group' );
 
88
  if ( !empty( $exists ) ) {
89
  $form->triggerError();
90
+ wpcf_admin_message(
91
+ sprintf(
92
+ __( "A group by name <em>%s</em> already exists. Please use a different name and save again.", 'wpcf' ),
93
+ htmlspecialchars($_POST['wpcf']['group']['name'])
94
+ ),
95
+ 'error'
96
+ );
97
  return $form;
98
  }
99
  }
170
  }
171
  // Rename if needed
172
  if ( isset( $_REQUEST['group_id'] ) ) {
173
+ $_POST['wpcf']['group']['id'] = intval($_REQUEST['group_id']);
174
  }
175
 
176
  $group_id = wpcf_admin_fields_save_group( $_POST['wpcf']['group'] );
236
  wpcf_admin_message( sprintf( __( "Group with ID %d do not exist",
237
  'wpcf' ), intval( $_REQUEST['group_id'] ) ) );
238
  } else {
239
+ $update['fields'] = wpcf_admin_fields_get_fields_by_group( sanitize_text_field( $_REQUEST['group_id'] ), 'slug', false, true );
240
+ $update['post_types'] = wpcf_admin_get_post_types_by_group( sanitize_text_field( $_REQUEST['group_id'] ) );
241
+ $update['taxonomies'] = wpcf_admin_get_taxonomies_by_group( sanitize_text_field( $_REQUEST['group_id'] ) );
242
+ $update['templates'] = wpcf_admin_get_templates_by_group( sanitize_text_field( $_REQUEST['group_id'] ) );
243
+ $update['admin_styles'] = wpcf_admin_get_groups_admin_styles_by_group( sanitize_text_field( $_REQUEST['group_id'] ) );
244
  }
245
  }
246
 
373
  '#type' => 'textfield',
374
  '#name' => 'wpcf[group][name]',
375
  '#id' => 'wpcf-group-name',
376
+ '#value' => $update ? $update['name']:'',
377
  '#inline' => true,
378
+ '#attributes' => array(
379
+ 'style' => 'width:100%;margin-bottom:10px;',
380
+ 'placeholder' => __( 'Enter group title', 'wpcf' ),
381
+ ),
382
  '#validate' => array(
383
  'required' => array(
384
  'value' => true,
385
  ),
386
  )
387
  );
 
 
 
 
 
388
  $form['description'] = array(
389
  '#type' => 'textarea',
390
  '#id' => 'wpcf-group-description',
391
  '#name' => 'wpcf[group][description]',
392
+ '#value' => $update ? $update['description']:'',
393
+ '#attributes' => array(
394
+ 'placeholder' => __( 'Enter a description for this group', 'wpcf' ),
395
+ ),
396
  );
 
 
 
 
 
397
 
398
+ /**
399
+ *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  * FILTER BOX
401
  * Since Types 1.2 we moved JS to /embedded/resources/js/custom-fields-form-filter.js
402
+ *
403
  */
404
  // Support post types and taxonomies
405
 
431
  }
432
 
433
 
434
+ /**
 
 
 
 
 
 
 
 
 
 
435
  * POST TYPE FILTER
436
  */
437
  $temp = array(
440
  '#name' => 'wpcf[group][supports]',
441
  '#inline' => true,
442
  );
443
+ /**
 
444
  * Here we use unique function for all filters
445
  * Since Types 1.2
446
  */
449
  implode( ',', $post_types_currently_supported ),
450
  __( 'Displayed on all content types', 'wpcf' ), $temp );
451
 
452
+ /**
 
 
 
 
 
 
 
 
453
  * TAXONOMIES FILTER QUERY
454
  */
455
  $taxonomies = apply_filters( 'wpcf_group_form_filter_taxonomies', get_taxonomies( '', 'objects' ) );
459
  $form_tax_single = array();
460
 
461
 
462
+ /**
 
 
463
  * Filter toxonomies
464
  */
465
  foreach ( $taxonomies as $category_slug => $category ) {
512
  $tax_currently_supported[] = __( 'Not Selected', 'wpcf' );
513
  }
514
 
515
+ /**
 
 
 
 
516
  * Since Types 1.2 we use unique function
517
  */
518
  $form_tax = _wpcf_filter_wrap( 'custom_taxonomies', __( 'Terms:', 'wpcf' ),
521
 
522
 
523
 
524
+ /**
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  * TEMPLATES
526
  */
527
  // Choose templates
531
  $options = array();
532
  $options['default-template'] = array(
533
  '#title' => __( 'Default Template' ),
534
+ '#default_value' => !empty( $update['templates'] ) && in_array( 'default', $update['templates'] ),
 
535
  '#name' => 'wpcf[group][templates][]',
536
  '#value' => 'default',
537
  '#inline' => true,
540
  foreach ( $templates as $template_name => $template_filename ) {
541
  $options[$template_filename] = array(
542
  '#title' => $template_name,
543
+ '#default_value' => !empty( $update['templates'] ) && in_array( $template_filename, $update['templates'] ),
 
544
  '#name' => 'wpcf[group][templates][]',
545
  '#value' => $template_filename,
546
  '#inline' => true,
550
  foreach ( $templates_views as $template_view ) {
551
  $options[$template_view->post_name] = array(
552
  '#title' => 'View Template ' . $template_view->post_title,
553
+ '#default_value' => !empty( $update['templates'] ) && in_array( $template_view->ID, $update['templates'] ),
 
554
  '#name' => 'wpcf[group][templates][]',
555
  '#value' => $template_view->ID,
556
  '#inline' => true,
588
  '#options' => $options,
589
  '#inline' => true,
590
  );
 
 
 
591
 
592
+ /**
 
 
 
 
593
  * Since Types 1.2 we use unique function
594
  */
595
+ $form_templates = _wpcf_filter_wrap(
596
+ 'templates',
597
+ __( 'Templates:', 'wpcf' ),
598
+ $text,
599
+ __( 'Not Selected', 'wpcf' ),
600
+ $form_templates
601
+ );
602
 
603
+ /**
 
 
 
 
 
 
 
 
 
 
 
604
  * Now starting form
605
  */
606
  $form['supports-table-open'] = array(
613
  'wpcf' )
614
  . '</p>',
615
  );
616
+
617
+ /**
 
 
 
 
 
 
618
  * Join filter forms
619
  */
620
  // Types
642
  '#markup' => '</p>',
643
  );
644
 
645
+ /**
 
 
 
 
 
 
 
 
646
  * TODO Code from now on should be revised
647
  */
648
 
 
649
  $count = 0;
650
  $count +=!empty( $update['post_types'] ) ? 1 : 0;
651
  $count +=!empty( $update['taxonomies'] ) ? 1 : 0;
747
  '#type' => 'textarea',
748
  '#name' => 'wpcf[group][admin_html_preview]',
749
  '#inline' => true,
 
750
  '#id' => 'wpcf-form-groups-admin-html-preview',
751
  '#before' => '<h3>Field group HTML</h3>'
752
  );
759
  '#default_value' => '',
760
  '#id' => 'wpcf-form-groups-css-fields-editor',
761
  '#after' => '
762
+ <div class="wpcf-update-preview-btn"><input type="button" value="Update preview" onclick="wpcfPreviewHtml()" style="float:right;" class="button-secondary"></div>
763
+ <h3>Field group preview</h3>
764
+ <div id="wpcf-update-preview-div">Preview here</div>
765
+ <script type="text/javascript">
766
+ var wpcfReadOnly = ' . json_encode( $preview_profile ) . ';
767
+ var wpcfEditMode = ' . json_encode( $edit_profile ) . ';
768
+ var wpcfDefaultCss = ' . json_encode( $admin_styles_value ) . ';
769
+ </script>
770
+ ',
771
  '#before' => '<h3>Your CSS</h3>'
772
  );
773
 
 
 
 
774
  $admin_styles = _wpcf_filter_wrap( 'admin_styles',
775
  __( 'Admin styles for fields:', 'wpcf' ), '', '', $temp,
776
  __( 'Open style editor', 'wpcf' ) );
896
 
897
  /**
898
  * Dynamically adds new field on AJAX call.
899
+ *
900
+ * @param type $form_data
901
  */
902
  function wpcf_fields_insert_ajax( $form_data = array() ) {
903
+ echo wpcf_fields_get_field_form( sanitize_text_field( $_GET['field'] ) );
904
  }
905
 
906
  /**
907
  * Dynamically adds existing field on AJAX call.
908
+ *
909
+ * @param type $form_data
910
  */
911
  function wpcf_fields_insert_existing_ajax() {
912
+ $field = wpcf_admin_fields_get_field( sanitize_text_field( $_GET['field'] ), false, true );
913
  if ( !empty( $field ) ) {
914
  echo wpcf_fields_get_field_form( $field['type'], $field );
915
  } else {
919
 
920
  /**
921
  * Returns HTML formatted field form (draggable).
922
+ *
923
  * @param type $type
924
  * @param type $form_data
925
+ * @return type
926
  */
927
  function wpcf_fields_get_field_form( $type, $form_data = array() ) {
928
  $form = wpcf_fields_get_field_form_data( $type, $form_data );
955
 
956
  /**
957
  * Processes field form data.
958
+ *
959
  * @param type $type
960
  * @param type $form_data
961
+ * @return type
962
  */
963
  function wpcf_fields_get_field_form_data( $type, $form_data = array() ) {
964
 
1045
  $form_field['name'] = array(
1046
  '#type' => 'textfield',
1047
  '#name' => 'name',
1048
+ '#attributes' => array(
1049
+ 'class' => 'wpcf-forms-set-legend wpcf-forms-field-name',
1050
+ 'style' => 'width:100%;margin:10px 0 10px 0;',
1051
+ 'placeholder' => __( 'Enter field name', 'wpcf' ),
1052
+ ),
1053
  '#validate' => array('required' => array('value' => true)),
1054
  '#inline' => true,
 
1055
  );
 
 
 
 
 
 
1056
  $form_field['slug'] = array(
1057
  '#type' => 'textfield',
1058
  '#name' => 'slug',
1059
+ '#attributes' => array(
1060
+ 'class' => 'wpcf-forms-field-slug',
1061
+ 'style' => 'width:100%;margin:0 0 10px 0;',
1062
+ 'maxlength' => 255,
1063
+ 'placeholder' => __( 'Enter field slug', 'wpcf' ),
1064
+ ),
1065
  '#validate' => array('nospecialchars' => array('value' => true)),
1066
  '#inline' => true,
 
1067
  );
 
 
 
 
 
 
1068
 
1069
  // If insert form callback is not provided, use generic form data
1070
  if ( function_exists( 'wpcf_fields_' . $type . '_insert_form' ) ) {
1081
  $form_field['description'] = array(
1082
  '#type' => 'textarea',
1083
  '#name' => 'description',
1084
+ '#attributes' => array(
1085
+ 'rows' => 5,
1086
+ 'cols' => 1,
1087
+ 'style' => 'margin:0 0 10px 0;',
1088
+ 'placeholder' => __( 'Describe this field', 'wpcf' ),
1089
+ ),
1090
  '#inline' => true,
 
1091
  );
1092
+
1093
+ /**
1094
+ * add placeholder field
1095
+ */
1096
+ switch($type)
1097
+ {
1098
+ case 'audio':
1099
+ case 'colorpicker':
1100
+ case 'date':
1101
+ case 'email':
1102
+ case 'embed':
1103
+ case 'file':
1104
+ case 'image':
1105
+ case 'numeric':
1106
+ case 'phone':
1107
+ case 'skype':
1108
+ case 'textarea':
1109
+ case 'textfield':
1110
+ case 'url':
1111
+ case 'video':
1112
+ $form_field['placeholder'] = array(
1113
+ '#type' => 'textfield',
1114
+ '#name' => 'placeholder',
1115
+ '#inline' => true,
1116
+ '#title' => __( 'Placeholder', 'wpcf' ),
1117
+ '#attributes' => array(
1118
+ 'style' => 'width:100%;margin:0 0 10px 0;',
1119
+ 'placeholder' => __('Enter placeholder', 'wpcf'),
1120
+ ),
1121
+ );
1122
+ break;
1123
+ }
1124
 
1125
  if ( wpcf_admin_can_be_repetitive( $type ) ) {
1126
  $temp_warning_message = '';
 
 
 
 
 
 
 
 
1127
  $form_field['repetitive'] = array(
1128
  '#type' => 'radios',
1129
  '#name' => 'repetitive',
1143
  ),
1144
  ),
1145
  '#default_value' => isset( $form_data['data']['repetitive'] ) ? $form_data['data']['repetitive'] : '0',
 
1146
  '#after' => wpcf_admin_is_repetitive( $form_data ) ? '<div class="wpcf-message wpcf-cd-warning wpcf-error" style="display:none;"><p>' . __( "There may be multiple instances of this field already. When you switch back to single-field mode, all values of this field will be updated when it's edited.",
1147
  'wpcf' ) . '</p></div>' . $temp_warning_message : $temp_warning_message,
1148
  );
1234
 
1235
  /**
1236
  * Adds validation box.
1237
+ *
1238
  * @param type $name
1239
  * @param string $field
1240
  * @param type $form_data
1241
+ * @return type
1242
  */
1243
  function wpcf_admin_fields_form_validation( $name, $field, $form_data = array() ) {
1244
  $form = array();
1323
 
1324
  /**
1325
  * Saves open fieldsets.
1326
+ *
1327
  * @param type $action
1328
  * @param type $fieldset
1329
+ * @param type $group_id
1330
  */
1331
  function wpcf_admin_fields_form_save_open_fieldset( $action, $fieldset,
1332
  $group_id = false ) {
1350
 
1351
  /**
1352
  * Saves open fieldsets.
1353
+ *
1354
  * @param type $action
1355
  * @param type $fieldset
1356
+ * @param type $group_id
1357
  */
1358
  function wpcf_admin_fields_form_fieldset_is_collapsed( $fieldset ) {
1359
  if ( isset( $_REQUEST['group_id'] ) ) {
1370
 
1371
  /**
1372
  * Adds 'Edit' and 'Cancel' buttons, expandable div.
1373
+ *
1374
  * @todo REMOVE THIS - Since Types 1.2 we do not need it
1375
+ *
1376
  * @param type $id
1377
  * @param type $element
1378
  * @param type $title
1379
  * @param type $list
1380
  * @param type $empty_txt
1381
+ * @return string
1382
  */
1383
  function wpcf_admin_fields_form_nested_elements( $id, $element, $title, $list,
1384
  $empty_txt ) {
1417
  }
1418
 
1419
  /*
1420
+ *
1421
+ *
1422
+ *
1423
+ *
1424
+ *
1425
+ *
1426
+ *
1427
+ *
1428
+ *
1429
+ *
1430
+ *
1431
+ *
1432
+ *
1433
+ *
1434
+ *
1435
+ *
1436
+ *
1437
+ *
1438
+ *
1439
+ *
1440
  * From here add revised code
1441
  */
1442
 
1443
  /**
1444
+ *
1445
  * Use this to show filter item
1446
+ *
1447
  * @since Types 1.2
1448
  * @global type $wpcf_button_style
1449
  * @global type $wpcf_button_style30
1469
  $edit = $edit_button;
1470
  }
1471
  /*
1472
+ *
1473
  * Title and Edit button
1474
  */
1475
  $form['filter_' . $unique_id . '_wrapper'] = array(
1483
  . $edit . '</a><div class="hidden" id="wpcf-form-fields-' . $id . '">',
1484
  );
1485
 
1486
+ /**
 
 
1487
  * Form element as param
1488
  * It may be single element or array of elements
1489
  * Simply check if array has #type - indicates it is a form item
1492
  $form['filter_' . $unique_id . '_items'] = $e;
1493
  } else {
1494
  /*
 
1495
  * If array of elements just join
1496
  */
1497
  $form = $form + (array) $e;
1498
  }
1499
 
1500
+ /**
 
 
1501
  * OK button
1502
  */
1503
  $form['filter_' . $unique_id . '_ok'] = array(
1510
  . __( 'OK', 'wpcf' ) . '</a>&nbsp;',
1511
  );
1512
 
1513
+ /**
 
 
1514
  * Cancel button
1515
  */
1516
  $form['filter_' . $unique_id . '_cancel'] = array(
1523
  . __( 'Cancel', 'wpcf' ) . '</a>',
1524
  );
1525
 
1526
+ /**
 
 
1527
  * Close wrapper
1528
  */
1529
  $form['filter_' . $unique_id . 'wrapper_close'] = array(
includes/fields-list.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Fields and groups list functions
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/includes/fields-list.php $
6
- * $LastChangedDate: 2015-02-04 13:43:06 +0000 (Wed, 04 Feb 2015) $
7
- * $LastChangedRevision: 1082328 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -12,101 +12,23 @@
12
  /**
13
  * Renders 'widefat' table.
14
  */
15
- function wpcf_admin_fields_list() {
16
- $groups = wpcf_admin_fields_get_groups();
17
-
18
- if (empty($groups)) {
19
- echo '<p>'
20
- . __("To use custom fields, please create a group to hold them.",
21
- 'wpcf')
22
- . '</p>';
23
- echo '<br /><a class="button-primary" href="'
24
- . admin_url('admin.php?page=wpcf-edit')
25
- . '">' . __('Add a custom fields group', 'wpcf') . '</a><br /><br />';
26
- } else {
27
- echo '<br /><a class="button-secondary" href="'
28
- . admin_url('admin.php?page=wpcf-edit')
29
- . '">' . __('Add a custom fields group', 'wpcf') . '</a><br /><br />';
30
-
31
- $rows = array();
32
- $header = array(
33
- 'group_name' => __('Group name', 'wpcf'),
34
- 'group_description' => __('Description', 'wpcf'),
35
- 'group_active' => __('Active', 'wpcf'),
36
- 'group_post_types' => __('Post types', 'wpcf'),
37
- 'group_taxonomies' => __('Taxonomies', 'wpcf'),
38
- );
39
- foreach ($groups as $group) {
40
-
41
- // Set 'name' column
42
- $name = '';
43
- $name .= '<a href="'
44
- . admin_url('admin.php?page=wpcf-edit&amp;group_id='
45
- . $group['id']) . '">' . $group['name'] . '</a>';
46
- $name .= '<br />';
47
- $name .= '<a href="'
48
- . admin_url('admin.php?page=wpcf-edit&amp;group_id='
49
- . $group['id']) . '">' . __('Edit', 'wpcf') . '</a> | ';
50
-
51
- $name .= $group['is_active'] ? wpcf_admin_fields_get_ajax_deactivation_link($group['id']) . ' | ' : wpcf_admin_fields_get_ajax_activation_link($group['id']) . ' | ';
52
-
53
- $name .= '<a href="'
54
- . admin_url('admin-ajax.php?action=wpcf_ajax&amp;'
55
- . 'wpcf_action=delete_group&amp;group_id='
56
- . $group['id'] . '&amp;wpcf_ajax_update=wpcf_list_ajax_response_'
57
- . $group['id']) . '&amp;_wpnonce=' . wp_create_nonce('delete_group')
58
- . '&amp;wpcf_warning='
59
- . __('Are you sure?', 'wpcf') . '" class="wpcf-ajax-link" '
60
- . 'id="wpcf-list-delete-' . $group['id'] . '">'
61
- . __('Delete Permanently', 'wpcf') . '</a>';
62
-
63
- $name .= '<div id="wpcf_list_ajax_response_' . $group['id'] . '"></div>';
64
-
65
- $rows[$group['id']]['name'] = $name;
66
- $rows[$group['id']]['raw_name'] = $group['name'];
67
-
68
-
69
- $rows[$group['id']]['description'] = $group['description'];
70
- $rows[$group['id']]['active-' . $group['id']] = $group['is_active'] ? __('Yes', 'wpcf') : __('No', 'wpcf');
71
- $rows[$group['id']]['status'] = $group['is_active']? 'active':'inactive';
72
-
73
- // Set 'post_tpes' column
74
- $post_types = wpcf_admin_get_post_types_by_group($group['id']);
75
- $rows[$group['id']]['post_types'] = empty($post_types) ? __('All post types', 'wpcf') : implode(', ', $post_types);
76
-
77
- // Set 'taxonomies' column
78
- $taxonomies = wpcf_admin_get_taxonomies_by_group($group['id']);
79
- $output = '';
80
- if (empty($taxonomies)) {
81
- $output = __('None', 'wpcf');
82
- } else {
83
- foreach ($taxonomies as $taxonomy => $terms) {
84
- $output .= '<em>' . $taxonomy . '</em>: ';
85
- $terms_output = array();
86
- foreach ($terms as $term_id => $term) {
87
- $terms_output[] = $term['name'];
88
- }
89
- $output .= implode(', ', $terms_output) . '<br />';
90
- }
91
- }
92
- $rows[$group['id']]['tax'] = $output;
93
- }
94
- uasort($rows, 'wpcf_admin_fields_list_sort');
95
-
96
- // Render table
97
- wpcf_admin_widefat_table('wpcf_groups_list', $header, $rows);
98
- }
99
-
100
  do_action('wpcf_groups_list_table_after');
101
  }
102
 
103
- function wpcf_admin_fields_list_sort($a,$b)
104
- {
105
- $a = strtolower($a['raw_name']);
106
- $b = strtolower($b['raw_name']);
107
- if ($a == $b) {
108
- return 0;
109
- }
110
- return ($a < $b) ? -1 : 1;
111
-
112
- }
2
  /*
3
  * Fields and groups list functions
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/includes/fields-list.php $
6
+ * $LastChangedDate: 2015-03-02 10:49:00 +0000 (Mon, 02 Mar 2015) $
7
+ * $LastChangedRevision: 1103173 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
12
  /**
13
  * Renders 'widefat' table.
14
  */
15
+ function wpcf_admin_fields_list()
16
+ {
17
+ include_once dirname(__FILE__).'/classes/class.wpcf.custom.fields.list.table.php';
18
+ //Create an instance of our package class...
19
+ $listTable = new WPCF_Custom_Fields_List_Table();
20
+ //Fetch, prepare, sort, and filter our data...
21
+ $listTable->prepare_items();
22
+ ?>
23
+ <!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
24
+ <form id="cf-filter" method="post">
25
+ <!-- For plugins, we also need to ensure that the form posts back to our current page -->
26
+ <input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?>" />
27
+ <?php $listTable->search_box(__('Search custom fields', 'wcpf'), 'search_id'); ?>
28
+ <!-- Now we can render the completed list table -->
29
+ <?php $listTable->display() ?>
30
+ </form>
31
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  do_action('wpcf_groups_list_table_after');
33
  }
34
 
 
 
 
 
 
 
 
 
 
 
includes/fields.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Fields and groups functions
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/includes/fields.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -13,7 +13,6 @@ require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
13
  /**
14
  * Gets post_types supported by specific group.
15
  *
16
- * @global type $wpdb
17
  * @param type $group_id
18
  * @return type
19
  */
@@ -29,7 +28,8 @@ function wpcf_admin_get_post_types_by_group( $group_id ) {
29
  /**
30
  * Gets taxonomies supported by specific group.
31
  *
32
- * @global type $wpdb
 
33
  * @param type $group_id
34
  * @return type
35
  */
@@ -43,12 +43,13 @@ function wpcf_admin_get_taxonomies_by_group( $group_id ) {
43
  $taxonomies = array();
44
  if ( !empty( $terms ) ) {
45
  foreach ( $terms as $term ) {
46
- $term = $wpdb->get_row( "SELECT tt.term_taxonomy_id, tt.taxonomy,
47
- t.term_id, t.slug, t.name
48
- FROM {$wpdb->prefix}term_taxonomy tt
49
- JOIN {$wpdb->prefix}terms t
50
- WHERE t.term_id = tt.term_id AND tt.term_taxonomy_id="
51
- . intval( $term ), ARRAY_A );
 
52
  if ( !empty( $term ) ) {
53
  $taxonomies[$term['taxonomy']][$term['term_taxonomy_id']] = $term;
54
  }
@@ -62,12 +63,11 @@ function wpcf_admin_get_taxonomies_by_group( $group_id ) {
62
  /**
63
  * Gets templates supported by specific group.
64
  *
65
- * @global type $wpdb
66
  * @param type $group_id
67
  * @return type
68
  */
69
- function wpcf_admin_get_templates_by_group( $group_id ) {
70
- global $wpdb;
71
  $data = get_post_meta( $group_id, '_wp_types_group_templates', true );
72
  if ( $data == 'all' ) {
73
  return array();
@@ -94,12 +94,13 @@ function wpcf_admin_get_templates_by_group( $group_id ) {
94
  * Activates group.
95
  * Modified by Gen, 13.02.2013
96
  *
97
- * @global type $wpdb
 
98
  * @param type $group_id
99
  * @return type
100
  */
101
- function wpcf_admin_fields_activate_group( $group_id,
102
- $post_type = 'wp-types-group' ) {
103
  global $wpdb;
104
  return $wpdb->update( $wpdb->posts, array('post_status' => 'publish'),
105
  array('ID' => intval( $group_id ), 'post_type' => $post_type),
@@ -111,7 +112,8 @@ function wpcf_admin_fields_activate_group( $group_id,
111
  * Deactivates group.
112
  * Modified by Gen, 13.02.2013
113
  *
114
- * @global type $wpdb
 
115
  * @param type $group_id
116
  * @return type
117
  */
@@ -127,8 +129,6 @@ function wpcf_admin_fields_deactivate_group( $group_id,
127
  /**
128
  * Removes specific field from group.
129
  *
130
- * @global type $wpdb
131
- * @global type $wpdb
132
  * @param type $group_id
133
  * @param type $field_id
134
  * @return type
@@ -151,6 +151,7 @@ function wpcf_admin_fields_remove_field_from_group( $group_id, $field_id ) {
151
  */
152
  function wpcf_admin_fields_remove_field_from_group_bulk( $group_id, $fields ) {
153
  foreach ( $fields as $field_id ) {
 
154
  wpcf_admin_fields_remove_field_from_group( $group_id, $field_id );
155
  }
156
  }
@@ -159,6 +160,8 @@ function wpcf_admin_fields_remove_field_from_group_bulk( $group_id, $fields ) {
159
  * Deletes field.
160
  * Modified by Gen, 13.02.2013
161
  *
 
 
162
  * @param type $field_id
163
  */
164
  function wpcf_admin_fields_delete_field( $field_id,
@@ -172,9 +175,13 @@ function wpcf_admin_fields_delete_field( $field_id,
172
  wpcf_admin_fields_remove_field_from_group( $group['id'], $field_id );
173
  }
174
  // Remove from posts
175
- if ( !wpcf_types_cf_under_control( 'check_outsider', $field_id,
176
- $post_type, $meta_name ) ) {
177
- $results = $wpdb->get_results( "SELECT post_id, meta_key FROM $wpdb->postmeta WHERE meta_key = '" . wpcf_types_get_meta_prefix( $fields[$field_id] ) . strval( $field_id ) . "'" );
 
 
 
 
178
  foreach ( $results as $result ) {
179
  delete_post_meta( $result->post_id, $result->meta_key );
180
  }
@@ -191,7 +198,6 @@ function wpcf_admin_fields_delete_field( $field_id,
191
  * Deletes group by ID.
192
  * Modified by Gen, 13.02.2013
193
  *
194
- * @global type $wpdb
195
  * @param type $group_id
196
  * @return type
197
  */
@@ -240,6 +246,7 @@ function wpcf_admin_fields_save_group( $group, $post_type = 'wp-types-group' ) {
240
  if ( !$group_id ) {
241
  return false;
242
  }
 
243
  } else {
244
  $group_id = wp_insert_post( $post, true );
245
  if ( is_wp_error( $group_id ) ) {
@@ -550,7 +557,6 @@ function wpcf_admin_custom_fields_change_type( $fields, $type,
550
  * Saves group's fields.
551
  * Modified by Gen, 13.02.2013
552
  *
553
- * @global type $wpdb
554
  * @param type $group_id
555
  * @param type $fields
556
  */
@@ -571,7 +577,7 @@ function wpcf_admin_fields_save_group_fields( $group_id, $fields, $add = false,
571
  $order[] = $field['id'];
572
  }
573
  foreach ( $fields as $field ) {
574
- $order[] = $field;
575
  }
576
  $fields = $order;
577
  }
@@ -587,7 +593,6 @@ function wpcf_admin_fields_save_group_fields( $group_id, $fields, $add = false,
587
  /**
588
  * Saves group's post types.
589
  *
590
- * @global type $wpdb
591
  * @param type $group_id
592
  * @param type $post_types
593
  */
@@ -603,7 +608,6 @@ function wpcf_admin_fields_save_group_post_types( $group_id, $post_types ) {
603
  /**
604
  * Saves group's terms.
605
  *
606
- * @global type $wpdb
607
  * @param type $group_id
608
  * @param type $terms
609
  */
@@ -619,7 +623,6 @@ function wpcf_admin_fields_save_group_terms( $group_id, $terms ) {
619
  /**
620
  * Saves group's templates.
621
  *
622
- * @global type $wpdb
623
  * @param type $group_id
624
  * @param type $terms
625
  */
@@ -635,6 +638,8 @@ function wpcf_admin_fields_save_group_templates( $group_id, $templates ) {
635
  /**
636
  * Returns HTML formatted AJAX activation link.
637
  *
 
 
638
  * @param type $group_id
639
  * @return type
640
  */
@@ -678,7 +683,7 @@ function wpcf_admin_fields_checkbox_migrate_empty_check( $field, $action ) {
678
  $filter = wpcf_admin_fields_get_filter_by_field( $field['id'] );
679
  if ( !empty( $filter ) ) {
680
  $posts = array();
681
- $meta_key = wpcf_types_get_meta_prefix( $field ) . $field['id'];
682
  $meta_query = '';
683
  if ( $action == 'do_not_save_check' ) {
684
  $meta_query = "(m.meta_key = '$meta_key' AND m.meta_value = '0')";
@@ -864,21 +869,27 @@ function wpcf_admin_fields_get_filter_by_field( $field ) {
864
  /**
865
  * Gets posts by filter fetched with wpcf_admin_fields_get_filter_by_field().
866
  *
867
- * @global type $wpdb
868
- * @param type $filter
869
- * @return type
870
  */
871
  function wpcf_admin_fields_get_posts_by_filter( $filter, $meta_query = '' ) {
872
  global $wpdb, $wpcf;
873
  $query = array();
874
  $join = array();
875
  if ( $filter['types'] != 'all' && !empty( $filter['types'] ) ) {
876
- $query[] = 'p.post_type IN (\'' . implode( '\',\'', $filter['types'] ) . '\')';
 
 
 
 
877
  } else {
878
  $post_types = get_post_types( array('show_ui' => true), 'names' );
879
  foreach ( $post_types as $post_type_slug => $post_type ) {
880
  if ( in_array( $post_type_slug, $wpcf->excluded_post_types ) ) {
881
  unset( $post_types[$post_type_slug] );
 
 
882
  }
883
  }
884
  $query[] = 'p.post_type IN (\'' . implode( '\',\'', $post_types ) . '\')';
@@ -886,18 +897,26 @@ function wpcf_admin_fields_get_posts_by_filter( $filter, $meta_query = '' ) {
886
  if ( $filter['terms'] != 'all' && !empty( $filter['terms'] ) ) {
887
  $ttid = array();
888
  foreach ( $filter['terms'] as $term_id ) {
889
- $term_taxonomy_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id=%d",
890
- $term_id ) );
 
 
 
 
891
  if ( !empty( $term_taxonomy_id ) ) {
892
- $ttid[] = $term_taxonomy_id;
893
  }
894
  }
895
  $query[] = 't.term_taxonomy_id IN (\'' . implode( '\',\'', $ttid ) . '\')';
896
  $join[] = "LEFT JOIN $wpdb->term_relationships t ON p.ID = t.object_id ";
897
  }
898
  if ( $filter['templates'] != 'all' && !empty( $filter['templates'] ) ) {
 
 
 
 
899
  $query[] = '(m.meta_key = \'_wp_page_template\' AND m.meta_value IN (\'' . implode( '\',\'',
900
- $filter['templates'] ) . '\'))';
901
  }
902
  if ( !empty( $meta_query )
903
  || ($filter['templates'] != 'all' && !empty( $filter['templates'] )) ) {
@@ -906,7 +925,8 @@ function wpcf_admin_fields_get_posts_by_filter( $filter, $meta_query = '' ) {
906
 
907
  $_query = "SELECT p.ID FROM $wpdb->posts p " . implode( '', $join );
908
  if ( !empty( $query ) ) {
909
- $_query .= "WHERE " . implode( ' ' . $filter['association'] . ' ',
 
910
  $query ) . ' ';
911
  if ( !empty( $meta_query ) ) {
912
  $_query .= ' AND ' . $meta_query . ' ';
@@ -923,7 +943,7 @@ function wpcf_admin_fields_get_posts_by_filter( $filter, $meta_query = '' ) {
923
  * Gets posts by filter with missing meta fetched
924
  * with wpcf_admin_fields_get_filter_by_field().
925
  *
926
- * @global type $wpdb
927
  * @param type $filter
928
  * @return type
929
  */
@@ -933,12 +953,18 @@ function wpcf_admin_fields_get_posts_by_filter_missing_meta( $filter,
933
  $query = array();
934
  $join = array();
935
  if ( $filter['types'] != 'all' && !empty( $filter['types'] ) ) {
936
- $query[] = 'p.post_type IN (\'' . implode( '\',\'', $filter['types'] ) . '\')';
 
 
 
 
937
  } else {
938
  $post_types = get_post_types( array('show_ui' => true), 'names' );
939
  foreach ( $post_types as $post_type_slug => $post_type ) {
940
  if ( in_array( $post_type_slug, $wpcf->excluded_post_types ) ) {
941
  unset( $post_types[$post_type_slug] );
 
 
942
  }
943
  }
944
  $query[] = 'p.post_type IN (\'' . implode( '\',\'', $post_types ) . '\')';
@@ -946,24 +972,33 @@ function wpcf_admin_fields_get_posts_by_filter_missing_meta( $filter,
946
  if ( $filter['terms'] != 'all' && !empty( $filter['terms'] ) ) {
947
  $ttid = array();
948
  foreach ( $filter['terms'] as $term_id ) {
949
- $term_taxonomy_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id=%d",
950
- $term_id ) );
 
 
 
 
951
  if ( !empty( $term_taxonomy_id ) ) {
952
- $ttid[] = $term_taxonomy_id;
953
  }
954
  }
955
  $query[] = 't.term_taxonomy_id IN (\'' . implode( '\',\'', $ttid ) . '\')';
956
  $join[] = "LEFT JOIN $wpdb->term_relationships t ON p.ID = t.object_id ";
957
  }
958
  if ( $filter['templates'] != 'all' && !empty( $filter['templates'] ) ) {
 
 
 
 
959
  $query[] = '(m.meta_key = \'_wp_page_template\' AND m.meta_value IN (\'' . implode( '\',\'',
960
- $filter['templates'] ) . '\'))';
961
  $join[] = "LEFT JOIN $wpdb->postmeta m ON p.ID = m.post_id ";
962
  }
963
  $_query = "SELECT DISTINCT p.ID FROM $wpdb->posts p " . implode( '', $join );
964
- $_query .= "WHERE NOT EXISTS (SELECT * FROM $wpdb->postmeta mm WHERE p.ID = mm.post_id AND mm.meta_key = '$meta_key')";
965
  if ( !empty( $query ) ) {
966
- $_query .= "AND (" . implode( ' ' . $filter['association'] . ' ', $query ) . ') ';
 
967
  }
968
  $_query .= "GROUP BY p.ID";
969
  $posts = $wpdb->get_col( $_query );
@@ -973,6 +1008,8 @@ function wpcf_admin_fields_get_posts_by_filter_missing_meta( $filter,
973
  /**
974
  * Check how many posts needs checkboxes update.
975
  *
 
 
976
  * @param type $field
977
  * @param type $action
978
  * @return boolean|int
@@ -986,8 +1023,7 @@ function wpcf_admin_fields_checkboxes_migrate_empty_check( $field, $action ) {
986
  if ( $action == 'do_not_save_check' ) {
987
  $query = array();
988
  foreach ( $field['data']['options'] as $option_id => $option_data ) {
989
- // $query[] = '\"' . $option_id . '\";s:1:\"0\";';
990
- $query[] = '\"' . $option_id . '\";i:0;';
991
  }
992
  $meta_query = "SELECT u.ID FROM {$wpdb->users} u
993
  LEFT JOIN {$wpdb->usermeta} um ON u.ID = um.user_id
@@ -996,9 +1032,8 @@ function wpcf_admin_fields_checkboxes_migrate_empty_check( $field, $action ) {
996
  } else if ( $action == 'save_check' ) {
997
  $query = array();
998
  foreach ( $field['data']['options'] as $option_id => $option_data ) {
999
- // $query[] = '\"' . $option_id . '\";s:1:\"0\";';
1000
  // Check only if missing
1001
- $query[] = '\"' . $option_id . '\"';
1002
  }
1003
  $meta_query = "SELECT u.ID FROM {$wpdb->users} u
1004
  LEFT JOIN {$wpdb->usermeta} um ON u.ID = um.user_id
@@ -1015,13 +1050,13 @@ function wpcf_admin_fields_checkboxes_migrate_empty_check( $field, $action ) {
1015
  $filter = wpcf_admin_fields_get_filter_by_field( $field['id'] );
1016
  if ( !empty( $filter ) ) {
1017
  $posts = array();
1018
- $meta_key = wpcf_types_get_meta_prefix( $field ) . $field['id'];
1019
  $meta_query = '';
1020
  // "wpcf-fields-checkboxes-option-1873650245";s:1:"1";
1021
  if ( $action == 'do_not_save_check' ) {
1022
  $query = array();
1023
  foreach ( $field['data']['options'] as $option_id => $option_data ) {
1024
- $query[] = '\"' . $option_id . '\";i:0;';
1025
  }
1026
  $meta_query = "(m.meta_key = '$meta_key' AND (m.meta_value LIKE '%%"
1027
  . implode( "%%' OR m.meta_value LIKE '%%", $query ) . "%%'))";
@@ -1030,7 +1065,7 @@ function wpcf_admin_fields_checkboxes_migrate_empty_check( $field, $action ) {
1030
  $query = array();
1031
  foreach ( $field['data']['options'] as $option_id => $option_data ) {
1032
  // Check only if missing
1033
- $query[] = '\"' . $option_id . '\"';
1034
  }
1035
  $meta_query = "(m.meta_key = '$meta_key' AND (m.meta_value NOT LIKE '%%"
1036
  . implode( "%%' OR m.meta_value NOT LIKE '%%", $query ) . "%%'))";
@@ -1226,3 +1261,71 @@ function wpcf_admin_fields_form_fix_styles()
1226
  );
1227
  }
1228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /*
3
  * Fields and groups functions
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/includes/fields.php $
6
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
7
+ * $LastChangedRevision: 1120400 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
13
  /**
14
  * Gets post_types supported by specific group.
15
  *
 
16
  * @param type $group_id
17
  * @return type
18
  */
28
  /**
29
  * Gets taxonomies supported by specific group.
30
  *
31
+ * @global object $wpdb
32
+ *
33
  * @param type $group_id
34
  * @return type
35
  */
43
  $taxonomies = array();
44
  if ( !empty( $terms ) ) {
45
  foreach ( $terms as $term ) {
46
+ $term = $wpdb->get_row(
47
+ $wpdb->prepare(
48
+ "SELECT tt.term_taxonomy_id, tt.taxonomy, t.term_id, t.slug, t.name FROM {$wpdb->term_taxonomy} tt JOIN {$wpdb->terms} t WHERE t.term_id = tt.term_id AND tt.term_taxonomy_id = %d",
49
+ $term
50
+ ),
51
+ ARRAY_A
52
+ );
53
  if ( !empty( $term ) ) {
54
  $taxonomies[$term['taxonomy']][$term['term_taxonomy_id']] = $term;
55
  }
63
  /**
64
  * Gets templates supported by specific group.
65
  *
 
66
  * @param type $group_id
67
  * @return type
68
  */
69
+ function wpcf_admin_get_templates_by_group( $group_id )
70
+ {
71
  $data = get_post_meta( $group_id, '_wp_types_group_templates', true );
72
  if ( $data == 'all' ) {
73
  return array();
94
  * Activates group.
95
  * Modified by Gen, 13.02.2013
96
  *
97
+ * @global object $wpdb
98
+ *
99
  * @param type $group_id
100
  * @return type
101
  */
102
+ function wpcf_admin_fields_activate_group( $group_id, $post_type = 'wp-types-group' )
103
+ {
104
  global $wpdb;
105
  return $wpdb->update( $wpdb->posts, array('post_status' => 'publish'),
106
  array('ID' => intval( $group_id ), 'post_type' => $post_type),
112
  * Deactivates group.
113
  * Modified by Gen, 13.02.2013
114
  *
115
+ * @global object $wpdb
116
+ *
117
  * @param type $group_id
118
  * @return type
119
  */
129
  /**
130
  * Removes specific field from group.
131
  *
 
 
132
  * @param type $group_id
133
  * @param type $field_id
134
  * @return type
151
  */
152
  function wpcf_admin_fields_remove_field_from_group_bulk( $group_id, $fields ) {
153
  foreach ( $fields as $field_id ) {
154
+ $field_id = sanitize_text_field( $field_id );
155
  wpcf_admin_fields_remove_field_from_group( $group_id, $field_id );
156
  }
157
  }
160
  * Deletes field.
161
  * Modified by Gen, 13.02.2013
162
  *
163
+ * @global object $wpdb
164
+ *
165
  * @param type $field_id
166
  */
167
  function wpcf_admin_fields_delete_field( $field_id,
175
  wpcf_admin_fields_remove_field_from_group( $group['id'], $field_id );
176
  }
177
  // Remove from posts
178
+ if ( !wpcf_types_cf_under_control( 'check_outsider', $field_id, $post_type, $meta_name ) ) {
179
+ $results = $wpdb->get_results(
180
+ $wpdb->prepare(
181
+ "SELECT post_id, meta_key FROM $wpdb->postmeta WHERE meta_key = %s",
182
+ wpcf_types_get_meta_prefix( $fields[$field_id] ) . strval( $field_id )
183
+ )
184
+ );
185
  foreach ( $results as $result ) {
186
  delete_post_meta( $result->post_id, $result->meta_key );
187
  }
198
  * Deletes group by ID.
199
  * Modified by Gen, 13.02.2013
200
  *
 
201
  * @param type $group_id
202
  * @return type
203
  */
246
  if ( !$group_id ) {
247
  return false;
248
  }
249
+ update_post_meta( $group_id, TOOLSET_EDIT_LAST, time());
250
  } else {
251
  $group_id = wp_insert_post( $post, true );
252
  if ( is_wp_error( $group_id ) ) {
557
  * Saves group's fields.
558
  * Modified by Gen, 13.02.2013
559
  *
 
560
  * @param type $group_id
561
  * @param type $fields
562
  */
577
  $order[] = $field['id'];
578
  }
579
  foreach ( $fields as $field ) {
580
+ $order[] = sanitize_text_field( $field );
581
  }
582
  $fields = $order;
583
  }
593
  /**
594
  * Saves group's post types.
595
  *
 
596
  * @param type $group_id
597
  * @param type $post_types
598
  */
608
  /**
609
  * Saves group's terms.
610
  *
 
611
  * @param type $group_id
612
  * @param type $terms
613
  */
623
  /**
624
  * Saves group's templates.
625
  *
 
626
  * @param type $group_id
627
  * @param type $terms
628
  */
638
  /**
639
  * Returns HTML formatted AJAX activation link.
640
  *
641
+ * @global object $wpdb
642
+ *
643
  * @param type $group_id
644
  * @return type
645
  */
683
  $filter = wpcf_admin_fields_get_filter_by_field( $field['id'] );
684
  if ( !empty( $filter ) ) {
685
  $posts = array();
686
+ $meta_key = esc_sql( wpcf_types_get_meta_prefix( $field ) . $field['id'] );
687
  $meta_query = '';
688
  if ( $action == 'do_not_save_check' ) {
689
  $meta_query = "(m.meta_key = '$meta_key' AND m.meta_value = '0')";
869
  /**
870
  * Gets posts by filter fetched with wpcf_admin_fields_get_filter_by_field().
871
  *
872
+ * @param array $filter
873
+ * @param string $meta_query This argument needs to be allways sanitized!
874
+ * @return array
875
  */
876
  function wpcf_admin_fields_get_posts_by_filter( $filter, $meta_query = '' ) {
877
  global $wpdb, $wpcf;
878
  $query = array();
879
  $join = array();
880
  if ( $filter['types'] != 'all' && !empty( $filter['types'] ) ) {
881
+ $post_types = array();
882
+ foreach( $filter['types'] as $post_type ) {
883
+ $post_types[] = esc_sql( $post_type );
884
+ }
885
+ $query[] = 'p.post_type IN (\'' . implode( '\',\'', $post_types ) . '\')';
886
  } else {
887
  $post_types = get_post_types( array('show_ui' => true), 'names' );
888
  foreach ( $post_types as $post_type_slug => $post_type ) {
889
  if ( in_array( $post_type_slug, $wpcf->excluded_post_types ) ) {
890
  unset( $post_types[$post_type_slug] );
891
+ } else {
892
+ $post_types[$post_type_slug] = esc_sql( $post_type );
893
  }
894
  }
895
  $query[] = 'p.post_type IN (\'' . implode( '\',\'', $post_types ) . '\')';
897
  if ( $filter['terms'] != 'all' && !empty( $filter['terms'] ) ) {
898
  $ttid = array();
899
  foreach ( $filter['terms'] as $term_id ) {
900
+ $term_taxonomy_id = $wpdb->get_var(
901
+ $wpdb->prepare(
902
+ "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id=%d",
903
+ $term_id
904
+ )
905
+ );
906
  if ( !empty( $term_taxonomy_id ) ) {
907
+ $ttid[] = esc_sql( $term_taxonomy_id );
908
  }
909
  }
910
  $query[] = 't.term_taxonomy_id IN (\'' . implode( '\',\'', $ttid ) . '\')';
911
  $join[] = "LEFT JOIN $wpdb->term_relationships t ON p.ID = t.object_id ";
912
  }
913
  if ( $filter['templates'] != 'all' && !empty( $filter['templates'] ) ) {
914
+ $templates = array();
915
+ foreach( $filter['templates'] as $template ) {
916
+ $templates[] = esc_sql( $template );
917
+ }
918
  $query[] = '(m.meta_key = \'_wp_page_template\' AND m.meta_value IN (\'' . implode( '\',\'',
919
+ $templates ) . '\'))';
920
  }
921
  if ( !empty( $meta_query )
922
  || ($filter['templates'] != 'all' && !empty( $filter['templates'] )) ) {
925
 
926
  $_query = "SELECT p.ID FROM $wpdb->posts p " . implode( '', $join );
927
  if ( !empty( $query ) ) {
928
+ $association = ( strtoupper( trim( $filter['association'] ) ) == 'OR' ) ? 'OR' : 'AND';
929
+ $_query .= "WHERE " . implode( ' ' . $association . ' ',
930
  $query ) . ' ';
931
  if ( !empty( $meta_query ) ) {
932
  $_query .= ' AND ' . $meta_query . ' ';
943
  * Gets posts by filter with missing meta fetched
944
  * with wpcf_admin_fields_get_filter_by_field().
945
  *
946
+ * @global object $wpdb
947
  * @param type $filter
948
  * @return type
949
  */
953
  $query = array();
954
  $join = array();
955
  if ( $filter['types'] != 'all' && !empty( $filter['types'] ) ) {
956
+ $post_types = array();
957
+ foreach( $filter['types'] as $post_type ) {
958
+ $post_types[] = esc_sql( $post_type );
959
+ }
960
+ $query[] = 'p.post_type IN (\'' . implode( '\',\'', $post_types ) . '\')';
961
  } else {
962
  $post_types = get_post_types( array('show_ui' => true), 'names' );
963
  foreach ( $post_types as $post_type_slug => $post_type ) {
964
  if ( in_array( $post_type_slug, $wpcf->excluded_post_types ) ) {
965
  unset( $post_types[$post_type_slug] );
966
+ } else {
967
+ $post_types[$post_type_slug] = esc_sql( $post_type );
968
  }
969
  }
970
  $query[] = 'p.post_type IN (\'' . implode( '\',\'', $post_types ) . '\')';
972
  if ( $filter['terms'] != 'all' && !empty( $filter['terms'] ) ) {
973
  $ttid = array();
974
  foreach ( $filter['terms'] as $term_id ) {
975
+ $term_taxonomy_id = $wpdb->get_var(
976
+ $wpdb->prepare(
977
+ "SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE term_id=%d",
978
+ $term_id
979
+ )
980
+ );
981
  if ( !empty( $term_taxonomy_id ) ) {
982
+ $ttid[] = esc_sql( $term_taxonomy_id );
983
  }
984
  }
985
  $query[] = 't.term_taxonomy_id IN (\'' . implode( '\',\'', $ttid ) . '\')';
986
  $join[] = "LEFT JOIN $wpdb->term_relationships t ON p.ID = t.object_id ";
987
  }
988
  if ( $filter['templates'] != 'all' && !empty( $filter['templates'] ) ) {
989
+ $templates = array();
990
+ foreach( $filter['templates'] as $template ) {
991
+ $templates[] = esc_sql( $template );
992
+ }
993
  $query[] = '(m.meta_key = \'_wp_page_template\' AND m.meta_value IN (\'' . implode( '\',\'',
994
+ $templates ) . '\'))';
995
  $join[] = "LEFT JOIN $wpdb->postmeta m ON p.ID = m.post_id ";
996
  }
997
  $_query = "SELECT DISTINCT p.ID FROM $wpdb->posts p " . implode( '', $join );
998
+ $_query .= "WHERE NOT EXISTS (SELECT * FROM $wpdb->postmeta mm WHERE p.ID = mm.post_id AND mm.meta_key = '" . esc_sql( $meta_key ) . "')";
999
  if ( !empty( $query ) ) {
1000
+ $association = ( strtoupper( trim( $filter['association'] ) ) == 'OR' ) ? 'OR' : 'AND';
1001
+ $_query .= "AND (" . implode( ' ' . $association . ' ', $query ) . ') ';
1002
  }
1003
  $_query .= "GROUP BY p.ID";
1004
  $posts = $wpdb->get_col( $_query );
1008
  /**
1009
  * Check how many posts needs checkboxes update.
1010
  *
1011
+ * @global object $wpdb
1012
+ *
1013
  * @param type $field
1014
  * @param type $action
1015
  * @return boolean|int
1023
  if ( $action == 'do_not_save_check' ) {
1024
  $query = array();
1025
  foreach ( $field['data']['options'] as $option_id => $option_data ) {
1026
+ $query[] = '\"' . esc_sql( $option_id ) . '\";i:0;';
 
1027
  }
1028
  $meta_query = "SELECT u.ID FROM {$wpdb->users} u
1029
  LEFT JOIN {$wpdb->usermeta} um ON u.ID = um.user_id
1032
  } else if ( $action == 'save_check' ) {
1033
  $query = array();
1034
  foreach ( $field['data']['options'] as $option_id => $option_data ) {
 
1035
  // Check only if missing
1036
+ $query[] = '\"' . esc_sql( $option_id ) . '\"';
1037
  }
1038
  $meta_query = "SELECT u.ID FROM {$wpdb->users} u
1039
  LEFT JOIN {$wpdb->usermeta} um ON u.ID = um.user_id
1050
  $filter = wpcf_admin_fields_get_filter_by_field( $field['id'] );
1051
  if ( !empty( $filter ) ) {
1052
  $posts = array();
1053
+ $meta_key = esc_sql( wpcf_types_get_meta_prefix( $field ) . $field['id'] );
1054
  $meta_query = '';
1055
  // "wpcf-fields-checkboxes-option-1873650245";s:1:"1";
1056
  if ( $action == 'do_not_save_check' ) {
1057
  $query = array();
1058
  foreach ( $field['data']['options'] as $option_id => $option_data ) {
1059
+ $query[] = '\"' . esc_sql( $option_id ) . '\";i:0;';
1060
  }
1061
  $meta_query = "(m.meta_key = '$meta_key' AND (m.meta_value LIKE '%%"
1062
  . implode( "%%' OR m.meta_value LIKE '%%", $query ) . "%%'))";
1065
  $query = array();
1066
  foreach ( $field['data']['options'] as $option_id => $option_data ) {
1067
  // Check only if missing
1068
+ $query[] = '\"' . esc_sql( $option_id ) . '\"';
1069
  }
1070
  $meta_query = "(m.meta_key = '$meta_key' AND (m.meta_value NOT LIKE '%%"
1071
  . implode( "%%' OR m.meta_value NOT LIKE '%%", $query ) . "%%'))";
1261
  );
1262
  }
1263
 
1264
+ /**
1265
+ * add
1266
+ */
1267
+ add_filter('wpcf_meta_box_order_defaults', 'wpcf_admin_fields_add_metabox', 10, 2);
1268
+ function wpcf_admin_fields_add_metabox($meta_boxes, $type )
1269
+ {
1270
+ if ( 'post_type' == $type ) {
1271
+ $key = 'custom_fields';
1272
+ if ( !in_array($key, $meta_boxes['side']) && !in_array($key, $meta_boxes['normal'])) {
1273
+ $meta_boxes['side'][] = $key;
1274
+ }
1275
+ }
1276
+ return $meta_boxes;
1277
+ }
1278
+
1279
+ function wpcf_admin_metabox_custom_fields($ct)
1280
+ {
1281
+ $form = array();
1282
+ $options = array();
1283
+ $groups = wpcf_admin_fields_get_groups('wp-types-group', true, true);
1284
+ foreach( $groups as $group ) {
1285
+ $post_types = wpcf_admin_get_post_types_by_group($group['id']);
1286
+ if ( empty($post_types) || (isset( $ct['wpcf-post-type']) && in_array($ct['wpcf-post-type'], $post_types)) ) {
1287
+ if ( !(empty($group['fields']) ) ) {
1288
+ foreach($group['fields'] as $field => $data) {
1289
+ if ( isset($data['data']['repetitive']) && $data['data']['repetitive']) {
1290
+ continue;
1291
+ }
1292
+ switch( $data['type'] ) {
1293
+ case 'embed':
1294
+ case 'checkboxes':
1295
+ case 'audio':
1296
+ case 'file':
1297
+ case 'textarea':
1298
+ case 'video':
1299
+ case 'wysiwyg':
1300
+ continue;
1301
+ default:
1302
+ $options[$field] = array(
1303
+ '#name' => 'ct[custom_fields][]',
1304
+ '#title' => sprintf( '%s <small>(%s)</small>', $data['name'], $data['type']),
1305
+ '#value' => $data['meta_key'],
1306
+ '#inline' => true,
1307
+ '#before' => '<li>',
1308
+ '#after' => '</li>',
1309
+ '#default_value' => intval(isset($ct['custom_fields']) && in_array($data['meta_key'], $ct['custom_fields']))
1310
+ );
1311
+ }
1312
+ }
1313
+ }
1314
+ }
1315
+ }
1316
+ unset($groups);
1317
+
1318
+ $form['table-custom_fields-open'] = wpcf_admin_metabox_begin(__( 'Custom Fields', 'wpcf' ), 'custom_fields', 'wpcf-types-form-visiblity-custom-fields-table', false);
1319
+
1320
+ $form['table-custom_fields-description'] = array(
1321
+ '#type' => 'checkboxes',
1322
+ '#options' => $options,
1323
+ '#name' => 'wpcf[group][supports]',
1324
+ '#inline' => true,
1325
+ '#before' => wpautop(__('Check which fields should be shown on custom post list as a column.', 'wpcf')).'<ul>',
1326
+ '#after' => '</ul>',
1327
+ );
1328
+
1329
+ $form['table-custom_fields-close'] = wpcf_admin_metabox_end();
1330
+ return $form;
1331
+ }
includes/fields/checkbox.php CHANGED
@@ -119,12 +119,18 @@ function wpcf_fields_checkbox_insert_form( $form_data ) {
119
  '#name' => 'display_value_not_selected',
120
  '#value' => '',
121
  '#inline' => true,
 
 
 
122
  );
123
  $form['display-value-2'] = array(
124
  '#type' => 'textfield',
125
  '#title' => __( 'Selected:', 'wpcf' ),
126
  '#name' => 'display_value_selected',
127
  '#value' => '',
 
 
 
128
  );
129
  $form['help'] = array(
130
  '#type' => 'markup',
119
  '#name' => 'display_value_not_selected',
120
  '#value' => '',
121
  '#inline' => true,
122
+ '#attributes' => array(
123
+ 'placeholder' => __('Enter not selected value', 'wpcf'),
124
+ ),
125
  );
126
  $form['display-value-2'] = array(
127
  '#type' => 'textfield',
128
  '#title' => __( 'Selected:', 'wpcf' ),
129
  '#name' => 'display_value_selected',
130
  '#value' => '',
131
+ '#attributes' => array(
132
+ 'placeholder' => __('Enter selected value', 'wpcf'),
133
+ ),
134
  );
135
  $form['help'] = array(
136
  '#type' => 'markup',
includes/fields/checkboxes.php CHANGED
@@ -112,7 +112,7 @@ function wpcf_fields_checkboxes_insert_form( $form_data, $parent_name = '' ) {
112
  . admin_url( 'admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=add_checkboxes_option&amp;_wpnonce='
113
  . wp_create_nonce( 'add_checkboxes_option' ) . '&amp;wpcf_ajax_update_add='
114
  . $id . '-sortable&amp;parent_name=' . urlencode( $parent_name )
115
- . '&amp;page='. $_GET['page']
116
  . '&amp;count=' . $count)
117
  . '" onclick="wpcfFieldsFormCountOptions(jQuery(this));"'
118
  . ' class="button-secondary wpcf-ajax-link">'
@@ -136,8 +136,8 @@ function wpcf_fields_checkboxes_get_option( $parent_name = '',
136
  $form_data = array(), $field = array() ) {
137
  $id = isset( $form_data['key'] ) ? $form_data['key'] : 'wpcf-fields-checkboxes-option-' . wpcf_unique_id( serialize( $form_data ) . $parent_name );
138
  $form = array();
139
- $count = isset( $_GET['count'] ) ? $_GET['count'] : 1;
140
- $title = isset( $_GET['count'] ) ? __( 'Checkbox title', 'wpcf' ) . ' ' . $_GET['count'] : __( 'Checkbox title',
141
  'wpcf' ) . ' 1';
142
  $title = isset( $form_data['title'] ) ? $form_data['title'] : $title;
143
  $form[$id . '-id'] = $id;
@@ -220,12 +220,18 @@ function wpcf_fields_checkboxes_get_option( $parent_name = '',
220
  '#name' => $parent_name . '[options][' . $id . '][display_value_not_selected]',
221
  '#value' => isset( $form_data['display_value_not_selected'] ) ? $form_data['display_value_not_selected'] : '',
222
  '#inline' => true,
 
 
 
223
  );
224
  $form[$id]['display-value-2'] = array(
225
  '#type' => 'textfield',
226
  '#title' => __( 'Selected:', 'wpcf' ),
227
  '#name' => $parent_name . '[options][' . $id . '][display_value_selected]',
228
  '#value' => isset( $form_data['display_value_selected'] ) ? $form_data['display_value_selected'] : '',
 
 
 
229
  );
230
  $form[$id . 'drag-close'] = array(
231
  '#type' => 'markup',
@@ -247,7 +253,7 @@ function wpcf_fields_checkboxes_get_option_alt_text( $id, $parent_name = '',
247
  $title = isset( $_GET['count'] ) ? __( 'Checkbox title', 'wpcf' ) . ' ' . $_GET['count'] : __( 'Checkbox title',
248
  'wpcf' ) . ' 1';
249
  $title = isset( $form_data['title'] ) ? $form_data['title'] : $title;
250
- $value = isset( $_GET['count'] ) ? $_GET['count'] : 1;
251
  $value = isset( $form_data['value'] ) ? $form_data['value'] : $value;
252
  $value = isset( $form_data['display_value'] ) ? $form_data['display_value'] : $value;
253
  $form = array(
@@ -261,4 +267,4 @@ function wpcf_fields_checkboxes_get_option_alt_text( $id, $parent_name = '',
261
  '#after' => '</div>',
262
  );
263
  return $form;
264
- }
112
  . admin_url( 'admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=add_checkboxes_option&amp;_wpnonce='
113
  . wp_create_nonce( 'add_checkboxes_option' ) . '&amp;wpcf_ajax_update_add='
114
  . $id . '-sortable&amp;parent_name=' . urlencode( $parent_name )
115
+ . '&amp;page='. sanitize_text_field( $_GET['page'] )
116
  . '&amp;count=' . $count)
117
  . '" onclick="wpcfFieldsFormCountOptions(jQuery(this));"'
118
  . ' class="button-secondary wpcf-ajax-link">'
136
  $form_data = array(), $field = array() ) {
137
  $id = isset( $form_data['key'] ) ? $form_data['key'] : 'wpcf-fields-checkboxes-option-' . wpcf_unique_id( serialize( $form_data ) . $parent_name );
138
  $form = array();
139
+ $count = isset( $_GET['count'] ) ? intval( $_GET['count'] ) : 1;
140
+ $title = isset( $_GET['count'] ) ? __( 'Checkbox title', 'wpcf' ) . ' ' . intval( $_GET['count'] ) : __( 'Checkbox title',
141
  'wpcf' ) . ' 1';
142
  $title = isset( $form_data['title'] ) ? $form_data['title'] : $title;
143
  $form[$id . '-id'] = $id;
220
  '#name' => $parent_name . '[options][' . $id . '][display_value_not_selected]',
221
  '#value' => isset( $form_data['display_value_not_selected'] ) ? $form_data['display_value_not_selected'] : '',
222
  '#inline' => true,
223
+ '#attributes' => array(
224
+ 'placeholder' => __('Enter not selected value', 'wpcf'),
225
+ ),
226
  );
227
  $form[$id]['display-value-2'] = array(
228
  '#type' => 'textfield',
229
  '#title' => __( 'Selected:', 'wpcf' ),
230
  '#name' => $parent_name . '[options][' . $id . '][display_value_selected]',
231
  '#value' => isset( $form_data['display_value_selected'] ) ? $form_data['display_value_selected'] : '',
232
+ '#attributes' => array(
233
+ 'placeholder' => __('Enter selected value', 'wpcf'),
234
+ ),
235
  );
236
  $form[$id . 'drag-close'] = array(
237
  '#type' => 'markup',
253
  $title = isset( $_GET['count'] ) ? __( 'Checkbox title', 'wpcf' ) . ' ' . $_GET['count'] : __( 'Checkbox title',
254
  'wpcf' ) . ' 1';
255
  $title = isset( $form_data['title'] ) ? $form_data['title'] : $title;
256
+ $value = isset( $_GET['count'] ) ? intval( $_GET['count'] ) : 1;
257
  $value = isset( $form_data['value'] ) ? $form_data['value'] : $value;
258
  $value = isset( $form_data['display_value'] ) ? $form_data['display_value'] : $value;
259
  $form = array(
267
  '#after' => '</div>',
268
  );
269
  return $form;
270
+ }
includes/fields/radio.php CHANGED
@@ -160,8 +160,7 @@ function wpcf_fields_radio_get_option( $parent_name = '', $form_data = array() )
160
  $id = isset( $form_data['key'] ) ? $form_data['key'] : 'wpcf-fields-radio-option-'
161
  . wpcf_unique_id( serialize( $form_data ) );
162
  $form = array();
163
- $value = isset( $_GET['count'] ) ? __( 'Option title', 'wpcf' ) . ' ' . $_GET['count'] : __( 'Option title',
164
- 'wpcf' ) . ' 1';
165
  $value = isset( $form_data['title'] ) ? $form_data['title'] : $value;
166
  $form[$id . '-id'] = $id;
167
  $form[$id . '-title'] = array(
@@ -173,6 +172,7 @@ function wpcf_fields_radio_get_option( $parent_name = '', $form_data = array() )
173
  '#attributes' => array(
174
  'style' => 'width:80px;',
175
  'class' => 'wpcf-form-groups-radio-update-title-display-value',
 
176
  ),
177
  '#before' => '<div class="js-types-sortable"><img src="'
178
  . WPCF_RES_RELPATH
@@ -187,7 +187,7 @@ function wpcf_fields_radio_get_option( $parent_name = '', $form_data = array() )
187
  . '-display-value-wrapper\').fadeOut(function(){jQuery(this).remove();}); }"'
188
  . 'alt="' . __( 'Delete this option', 'wpcf' ) . '" />',
189
  );
190
- $value = isset( $_GET['count'] ) ? $_GET['count'] : 1;
191
  $value = isset( $form_data['value'] ) ? $form_data['value'] : $value;
192
  $form[$id . '-value'] = array(
193
  '#type' => 'textfield',
@@ -198,6 +198,7 @@ function wpcf_fields_radio_get_option( $parent_name = '', $form_data = array() )
198
  '#attributes' => array(
199
  'style' => 'width:80px;',
200
  'class' => 'wpcf-compare-unique-value',
 
201
  ),
202
  );
203
  $form[$id . '-default'] = array(
@@ -223,10 +224,10 @@ function wpcf_fields_radio_get_option( $parent_name = '', $form_data = array() )
223
  function wpcf_fields_radio_get_option_alt_text( $id, $parent_name = '',
224
  $form_data = array() ) {
225
  $form = array();
226
- $title = isset( $_GET['count'] ) ? __( 'Option title', 'wpcf' ) . ' ' . $_GET['count'] : __( 'Option title',
227
  'wpcf' ) . ' 1';
228
  $title = isset( $form_data['title'] ) ? $form_data['title'] : $title;
229
- $value = isset( $_GET['count'] ) ? $_GET['count'] : 1;
230
  $value = isset( $form_data['value'] ) ? $form_data['value'] : $value;
231
  $value = isset( $form_data['display_value'] ) ? $form_data['display_value'] : $value;
232
  $form[$id . '-display-value'] = array(
@@ -238,6 +239,9 @@ function wpcf_fields_radio_get_option_alt_text( $id, $parent_name = '',
238
  '#inline' => true,
239
  '#before' => '<div id="' . $id . '-title-display-value-wrapper">',
240
  '#after' => '</div>',
 
 
 
241
  );
242
  return $form;
243
- }
160
  $id = isset( $form_data['key'] ) ? $form_data['key'] : 'wpcf-fields-radio-option-'
161
  . wpcf_unique_id( serialize( $form_data ) );
162
  $form = array();
163
+ $value = isset( $_GET['count'] ) ? __( 'Option title', 'wpcf' ) . ' ' . intval( $_GET['count'] ) : __( 'Option title', 'wpcf' ) . ' 1';
 
164
  $value = isset( $form_data['title'] ) ? $form_data['title'] : $value;
165
  $form[$id . '-id'] = $id;
166
  $form[$id . '-title'] = array(
172
  '#attributes' => array(
173
  'style' => 'width:80px;',
174
  'class' => 'wpcf-form-groups-radio-update-title-display-value',
175
+ 'placeholder' => __('Title', 'wpcf'),
176
  ),
177
  '#before' => '<div class="js-types-sortable"><img src="'
178
  . WPCF_RES_RELPATH
187
  . '-display-value-wrapper\').fadeOut(function(){jQuery(this).remove();}); }"'
188
  . 'alt="' . __( 'Delete this option', 'wpcf' ) . '" />',
189
  );
190
+ $value = isset( $_GET['count'] ) ? intval( $_GET['count'] ) : 1;
191
  $value = isset( $form_data['value'] ) ? $form_data['value'] : $value;
192
  $form[$id . '-value'] = array(
193
  '#type' => 'textfield',
198
  '#attributes' => array(
199
  'style' => 'width:80px;',
200
  'class' => 'wpcf-compare-unique-value',
201
+ 'placeholder' => __('Value', 'wpcf'),
202
  ),
203
  );
204
  $form[$id . '-default'] = array(
224
  function wpcf_fields_radio_get_option_alt_text( $id, $parent_name = '',
225
  $form_data = array() ) {
226
  $form = array();
227
+ $title = isset( $_GET['count'] ) ? __( 'Option title', 'wpcf' ) . ' ' . intval( $_GET['count'] ) : __( 'Option title',
228
  'wpcf' ) . ' 1';
229
  $title = isset( $form_data['title'] ) ? $form_data['title'] : $title;
230
+ $value = isset( $_GET['count'] ) ? intval( $_GET['count'] ) : 1;
231
  $value = isset( $form_data['value'] ) ? $form_data['value'] : $value;
232
  $value = isset( $form_data['display_value'] ) ? $form_data['display_value'] : $value;
233
  $form[$id . '-display-value'] = array(
239
  '#inline' => true,
240
  '#before' => '<div id="' . $id . '-title-display-value-wrapper">',
241
  '#after' => '</div>',
242
+ '#attributes' => array(
243
+ 'placeholder' => __('Value to display', 'wpcf'),
244
+ ),
245
  );
246
  return $form;
247
+ }
includes/fields/select.php CHANGED
@@ -93,8 +93,7 @@ function wpcf_fields_select_get_option( $parent_name = '', $form_data = array()
93
  $id = isset( $form_data['key'] ) ? $form_data['key'] : 'wpcf-fields-select-option-'
94
  . wpcf_unique_id( serialize( $form_data ) );
95
  $form = array();
96
- $value = isset( $_GET['count'] ) ? __( 'Option title', 'wpcf' ) . ' ' . $_GET['count'] : __( 'Option title',
97
- 'wpcf' ) . ' 1';
98
  $value = isset( $form_data['title'] ) ? $form_data['title'] : $value;
99
  $form[$id . '-title'] = array(
100
  '#type' => 'textfield',
@@ -102,7 +101,10 @@ function wpcf_fields_select_get_option( $parent_name = '', $form_data = array()
102
  '#name' => $parent_name . '[options][' . $id . '][title]',
103
  '#value' => $value,
104
  '#inline' => true,
105
- '#attributes' => array('style' => 'width:80px;'),
 
 
 
106
  '#before' => '<div class="js-types-sortable"><img src="'
107
  . WPCF_RES_RELPATH
108
  . '/images/move.png" class="js-types-sort-button" alt="'
@@ -113,7 +115,7 @@ function wpcf_fields_select_get_option( $parent_name = '', $form_data = array()
113
  . '\')) { jQuery(this).parent().fadeOut(function(){jQuery(this).remove();}); }"'
114
  . 'alt="' . __( 'Delete this option', 'wpcf' ) . '" />',
115
  );
116
- $value = isset( $_GET['count'] ) ? $_GET['count'] : 1;
117
  $value = isset( $form_data['value'] ) ? $form_data['value'] : $value;
118
  $form[$id . '-value'] = array(
119
  '#type' => 'textfield',
@@ -124,6 +126,7 @@ function wpcf_fields_select_get_option( $parent_name = '', $form_data = array()
124
  '#attributes' => array(
125
  'style' => 'width:80px;',
126
  'class' => 'wpcf-compare-unique-value',
 
127
  ),
128
  );
129
  $form[$id . '-default'] = array(
@@ -137,4 +140,4 @@ function wpcf_fields_select_get_option( $parent_name = '', $form_data = array()
137
  '#default_value' => isset( $form_data['default'] ) ? $form_data['default'] : false,
138
  );
139
  return $form;
140
- }
93
  $id = isset( $form_data['key'] ) ? $form_data['key'] : 'wpcf-fields-select-option-'
94
  . wpcf_unique_id( serialize( $form_data ) );
95
  $form = array();
96
+ $value = isset( $_GET['count'] ) ? __( 'Option title', 'wpcf' ) . ' ' . intval( $_GET['count'] ) : __( 'Option title', 'wpcf' ) . ' 1';
 
97
  $value = isset( $form_data['title'] ) ? $form_data['title'] : $value;
98
  $form[$id . '-title'] = array(
99
  '#type' => 'textfield',
101
  '#name' => $parent_name . '[options][' . $id . '][title]',
102
  '#value' => $value,
103
  '#inline' => true,
104
+ '#attributes' => array(
105
+ 'style' => 'width:80px;',
106
+ 'placeholder' => __('Title', 'wpcf'),
107
+ ),
108
  '#before' => '<div class="js-types-sortable"><img src="'
109
  . WPCF_RES_RELPATH
110
  . '/images/move.png" class="js-types-sort-button" alt="'
115
  . '\')) { jQuery(this).parent().fadeOut(function(){jQuery(this).remove();}); }"'
116
  . 'alt="' . __( 'Delete this option', 'wpcf' ) . '" />',
117
  );
118
+ $value = isset( $_GET['count'] ) ? intval( $_GET['count'] ) : 1;
119
  $value = isset( $form_data['value'] ) ? $form_data['value'] : $value;
120
  $form[$id . '-value'] = array(
121
  '#type' => 'textfield',
126
  '#attributes' => array(
127
  'style' => 'width:80px;',
128
  'class' => 'wpcf-compare-unique-value',
129
+ 'placeholder' => __('Value', 'wpcf'),
130
  ),
131
  );
132
  $form[$id . '-default'] = array(
140
  '#default_value' => isset( $form_data['default'] ) ? $form_data['default'] : false,
141
  );
142
  return $form;
143
+ }
includes/import-export.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Import/export data.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/includes/import-export.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -29,7 +29,7 @@ function wpcf_admin_import_export_form()
29
  $show_first_screen = false;
30
  if ( isset( $_POST['import-final'] ) ) {
31
  if ( $_POST['mode'] == 'file' && !empty( $_POST['file'] ) ) {
32
- $file = get_transient( $_POST['file'] );
33
  if ( file_exists($file) ) {
34
  $info = pathinfo($file);
35
  $is_zip = $info['extension'] == 'zip' ? true : false;
@@ -70,7 +70,7 @@ function wpcf_admin_import_export_form()
70
  }
71
  }
72
  if ( $_POST['mode'] == 'text' && !empty( $_POST['text'] ) ) {
73
- $charset = !empty( $_POST['text-encoding'] ) ? $_POST['text-encoding'] : get_option( 'blog_charset' );
74
  wpcf_admin_import_data( stripslashes( html_entity_decode( $_POST['text'],
75
  ENT_QUOTES, $charset ) ) );
76
  }
@@ -143,7 +143,7 @@ function wpcf_admin_import_export_form()
143
  $match ) ) {
144
  $charset = trim( $match[1], '"' );
145
  } else {
146
- $charset = !empty( $_POST['text-encoding'] ) ? $_POST['text-encoding'] : get_option( 'blog_charset' );
147
  }
148
  $form['text'] = array(
149
  '#type' => 'hidden',
@@ -303,7 +303,7 @@ function wpcf_admin_import_export_file_upload_error($file, $error_msg)
303
  /**
304
  * Import settings.
305
  *
306
- * @global type $wpdb
307
  * @param SimpleXMLElement $data
308
  * @return string
309
  */
@@ -385,10 +385,13 @@ function wpcf_admin_import_export_settings($data)
385
  '#inline' => true,
386
  '#after' => '<br />',
387
  );
388
- $post = $wpdb->get_var( $wpdb->prepare(
389
- "SELECT ID FROM $wpdb->posts
390
- WHERE post_title = %s AND post_type = %s",
391
- $group['post_title'], $group['post_type'] ) );
 
 
 
392
  if ( !empty( $post ) ) {
393
  $form['group-add-' . $group['ID']]['#after'] = wpcf_form_simple(
394
  array('group-add-update-' . $group['ID'] => array(
@@ -491,10 +494,13 @@ function wpcf_admin_import_export_settings($data)
491
  '#inline' => true,
492
  '#after' => '<br /><br />',
493
  );
494
- $post = $wpdb->get_var( $wpdb->prepare(
495
- "SELECT ID FROM $wpdb->posts
496
- WHERE post_title = %s AND post_type = %s",
497
- $group['post_title'], $group['post_type'] ) );
 
 
 
498
  if ( !empty( $post ) ) {
499
  $form['user-group-add-' . $group['ID']]['#after'] = wpcf_form_simple(
500
  array('user-group-add-update-' . $group['ID'] => array(
2
  /*
3
  * Import/export data.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/includes/import-export.php $
6
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
7
+ * $LastChangedRevision: 1120400 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
29
  $show_first_screen = false;
30
  if ( isset( $_POST['import-final'] ) ) {
31
  if ( $_POST['mode'] == 'file' && !empty( $_POST['file'] ) ) {
32
+ $file = get_transient( sanitize_text_field( $_POST['file'] ) );
33
  if ( file_exists($file) ) {
34
  $info = pathinfo($file);
35
  $is_zip = $info['extension'] == 'zip' ? true : false;
70
  }
71
  }
72
  if ( $_POST['mode'] == 'text' && !empty( $_POST['text'] ) ) {
73
+ $charset = !empty( $_POST['text-encoding'] ) ? sanitize_text_field( $_POST['text-encoding'] ) : get_option( 'blog_charset' );
74
  wpcf_admin_import_data( stripslashes( html_entity_decode( $_POST['text'],
75
  ENT_QUOTES, $charset ) ) );
76
  }
143
  $match ) ) {
144
  $charset = trim( $match[1], '"' );
145
  } else {
146
+ $charset = !empty( $_POST['text-encoding'] ) ? sanitize_text_field( $_POST['text-encoding'] ) : get_option( 'blog_charset' );
147
  }
148
  $form['text'] = array(
149
  '#type' => 'hidden',
303
  /**
304
  * Import settings.
305
  *
306
+ * @global object $wpdb
307
  * @param SimpleXMLElement $data
308
  * @return string
309
  */
385
  '#inline' => true,
386
  '#after' => '<br />',
387
  );
388
+ $post = $wpdb->get_var(
389
+ $wpdb->prepare(
390
+ "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = %s",
391
+ $group['post_title'],
392
+ $group['post_type']
393
+ )
394
+ );
395
  if ( !empty( $post ) ) {
396
  $form['group-add-' . $group['ID']]['#after'] = wpcf_form_simple(
397
  array('group-add-update-' . $group['ID'] => array(
494
  '#inline' => true,
495
  '#after' => '<br /><br />',
496
  );
497
+ $post = $wpdb->get_var(
498
+ $wpdb->prepare(
499
+ "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = %s",
500
+ $group['post_title'],
501
+ $group['post_type']
502
+ )
503
+ );
504
  if ( !empty( $post ) ) {
505
  $form['user-group-add-' . $group['ID']]['#after'] = wpcf_form_simple(
506
  array('user-group-add-update-' . $group['ID'] => array(
includes/migration.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Migration functions
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/includes/migration.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -12,11 +12,12 @@
12
  /**
13
  * Migration form.
14
  *
 
 
15
  * @return array
16
  */
17
- function wpcf_admin_migration_form() {
18
-
19
-
20
  global $wpdb;
21
  $wpcf_types = get_option('wpcf-custom-types', array());
22
  $wpcf_taxonomies = get_option('wpcf-custom-taxonomies', array());
@@ -35,7 +36,7 @@ function wpcf_admin_migration_form() {
35
  if (!empty($cfui_types)) {
36
  $form['types_title'] = array(
37
  '#type' => 'markup',
38
- '#markup' => '<h3>' . __('Custom Types UI Post Types') . '</h3>',
39
  );
40
 
41
  foreach ($cfui_types as $key => $cfui_type) {
@@ -43,8 +44,6 @@ function wpcf_admin_migration_form() {
43
  $wpcf_types);
44
  if ($exists) {
45
  $attributes = array('readonly' => 'readonly', 'disabled' => 'disabled');
46
- // wpcf_admin_message(sprintf(__("Custom Post Type %s will not be imported because post type with same name exist in Types",
47
- // 'wpcf'), $cfui_type['label']), 'error');
48
  $add = __('(exists)', 'wpcf');
49
  } else {
50
  $attributes = array();
@@ -76,8 +75,6 @@ function wpcf_admin_migration_form() {
76
  $wpcf_taxonomies);
77
  if ($exists) {
78
  $attributes = array('readonly' => 'readonly', 'disabled' => 'disabled');
79
- // wpcf_admin_message(sprintf(__("Custom Taxonomy %s will not be imported because taxonomy with same name exist in Types",
80
- // 'wpcf'), $title), 'error');
81
  $add = __('(exists)', 'wpcf');
82
  } else {
83
  $attributes = array();
@@ -108,9 +105,6 @@ function wpcf_admin_migration_form() {
108
  );
109
  };
110
 
111
-
112
-
113
-
114
  // ACF
115
 
116
  $acf_groups = get_posts('post_type=acf&status=publish&numberposts=-1');
@@ -149,8 +143,12 @@ function wpcf_admin_migration_form() {
149
  }
150
 
151
  foreach ($acf_groups as $acf_key => $acf_post) {
152
- $group_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type='wp-types-group'",
153
- $acf_post->post_title));
 
 
 
 
154
  if (empty($group_id)) {
155
  $add = __('Group will be created', 'wpcf');
156
  } else {
@@ -234,12 +232,6 @@ function wpcf_admin_migration_form() {
234
  '#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][slug]',
235
  '#value' => esc_attr($data['name']),
236
  );
237
- // @todo Not supported yet
238
- // $form[$acf_post->ID . '_acf_field_' . $meta_name . '_details_order'] = array(
239
- // '#type' => 'hidden',
240
- // '#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][order]',
241
- // '#value' => esc_attr($data['order']),
242
- // );
243
  // Add options for radios and select
244
  if (in_array($data['type'], array('radio', 'select'))
245
  && !empty($data['choices'])) {
@@ -253,9 +245,9 @@ function wpcf_admin_migration_form() {
253
  $option_value = trim($temp[0]);
254
  $option_title = trim($temp[1]);
255
  }
256
-
257
  $_key = sanitize_title($option_value);
258
-
259
  $form[$acf_post->ID . '_acf_field_' . $meta_name . '_option_' . $_key . '_value'] = array(
260
  '#type' => 'hidden',
261
  '#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][options][' . $_key . '][value]',
@@ -278,9 +270,6 @@ function wpcf_admin_migration_form() {
278
  if (($exists && !$outsider) || !$supported) {
279
  $attributes = array('disabled' => 'disabled');
280
  if ($exists) {
281
- // wpcf_admin_message(sprintf(__("Field %s will not be imported because field with same name exist in Types",
282
- // 'wpcf'), $data['label']),
283
- // 'error');
284
  }
285
  } else {
286
  $attributes = array();
@@ -369,6 +358,7 @@ function wpcf_admin_migration_form_submit() {
369
  $wpcf_types[$types_slug]['taxonomies'] = array();
370
  }
371
  $wpcf_types[$types_slug]['taxonomies'][$tax_slug] = 1;
 
372
  }
373
  }
374
 
@@ -389,9 +379,14 @@ function wpcf_admin_migration_form_submit() {
389
  continue;
390
  }
391
  global $wpdb;
392
- $group = $wpdb->get_row($wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_title = %s AND post_type='wp-types-group'",
393
- $_POST['acf_posts'][$acf_group_id]['post_title']));
 
 
 
 
394
  if (empty($group)) {
 
395
  $group = array();
396
  $group['name'] = $_POST['acf_posts'][$acf_group_id]['post_title'];
397
  $group['description'] = $_POST['acf_posts'][$acf_group_id]['post_content'];
@@ -449,9 +444,9 @@ function wpcf_admin_migration_form_submit() {
449
 
450
  /**
451
  * Gets types data.
452
- *
453
  * @param type $cfui_type
454
- * @return type
455
  */
456
  function wpcf_admin_migrate_get_cfui_type_data($cfui_type) {
457
  $cfui_types_migrated = array();
@@ -538,9 +533,9 @@ function wpcf_admin_migrate_get_cfui_type_data($cfui_type) {
538
 
539
  /**
540
  * Gets taxonomies data.
541
- *
542
  * @param type $cfui_tax
543
- * @return type
544
  */
545
  function wpcf_admin_migrate_get_cfui_tax_data($cfui_tax) {
546
  $cfui_tax_migrated = array();
2
  /*
3
  * Migration functions
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/includes/migration.php $
6
+ * $LastChangedDate: 2015-04-01 14:15:17 +0000 (Wed, 01 Apr 2015) $
7
+ * $LastChangedRevision: 1125405 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
12
  /**
13
  * Migration form.
14
  *
15
+ * @global object $wpdb
16
+ *
17
  * @return array
18
  */
19
+ function wpcf_admin_migration_form()
20
+ {
 
21
  global $wpdb;
22
  $wpcf_types = get_option('wpcf-custom-types', array());
23
  $wpcf_taxonomies = get_option('wpcf-custom-taxonomies', array());
36
  if (!empty($cfui_types)) {
37
  $form['types_title'] = array(
38
  '#type' => 'markup',
39
+ '#markup' => '<h3>' . __('Custom Types UI Post Types', 'wpcf') . '</h3>',
40
  );
41
 
42
  foreach ($cfui_types as $key => $cfui_type) {
44
  $wpcf_types);
45
  if ($exists) {
46
  $attributes = array('readonly' => 'readonly', 'disabled' => 'disabled');
 
 
47
  $add = __('(exists)', 'wpcf');
48
  } else {
49
  $attributes = array();
75
  $wpcf_taxonomies);
76
  if ($exists) {
77
  $attributes = array('readonly' => 'readonly', 'disabled' => 'disabled');
 
 
78
  $add = __('(exists)', 'wpcf');
79
  } else {
80
  $attributes = array();
105
  );
106
  };
107
 
 
 
 
108
  // ACF
109
 
110
  $acf_groups = get_posts('post_type=acf&status=publish&numberposts=-1');
143
  }
144
 
145
  foreach ($acf_groups as $acf_key => $acf_post) {
146
+ $group_id = $wpdb->get_var(
147
+ $wpdb->prepare(
148
+ "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type='wp-types-group'",
149
+ $acf_post->post_title
150
+ )
151
+ );
152
  if (empty($group_id)) {
153
  $add = __('Group will be created', 'wpcf');
154
  } else {
232
  '#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][slug]',
233
  '#value' => esc_attr($data['name']),
234
  );
 
 
 
 
 
 
235
  // Add options for radios and select
236
  if (in_array($data['type'], array('radio', 'select'))
237
  && !empty($data['choices'])) {
245
  $option_value = trim($temp[0]);
246
  $option_title = trim($temp[1]);
247
  }
248
+
249
  $_key = sanitize_title($option_value);
250
+
251
  $form[$acf_post->ID . '_acf_field_' . $meta_name . '_option_' . $_key . '_value'] = array(
252
  '#type' => 'hidden',
253
  '#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][options][' . $_key . '][value]',
270
  if (($exists && !$outsider) || !$supported) {
271
  $attributes = array('disabled' => 'disabled');
272
  if ($exists) {
 
 
 
273
  }
274
  } else {
275
  $attributes = array();
358
  $wpcf_types[$types_slug]['taxonomies'] = array();
359
  }
360
  $wpcf_types[$types_slug]['taxonomies'][$tax_slug] = 1;
361
+ $wpcf_types[$types_slug][TOOLSET_EDIT_LAST] = time();
362
  }
363
  }
364
 
379
  continue;
380
  }
381
  global $wpdb;
382
+ $group = $wpdb->get_row(
383
+ $wpdb->prepare(
384
+ "SELECT ID, post_title FROM $wpdb->posts WHERE post_title = %s AND post_type='wp-types-group'",
385
+ $_POST['acf_posts'][$acf_group_id]['post_title']
386
+ )
387
+ );
388
  if (empty($group)) {
389
+ // @todo Maybe sanitize here
390
  $group = array();
391
  $group['name'] = $_POST['acf_posts'][$acf_group_id]['post_title'];
392
  $group['description'] = $_POST['acf_posts'][$acf_group_id]['post_content'];
444
 
445
  /**
446
  * Gets types data.
447
+ *
448
  * @param type $cfui_type
449
+ * @return type
450
  */
451
  function wpcf_admin_migrate_get_cfui_type_data($cfui_type) {
452
  $cfui_types_migrated = array();
533
 
534
  /**
535
  * Gets taxonomies data.
536
+ *
537
  * @param type $cfui_tax
538
+ * @return type
539
  */
540
  function wpcf_admin_migrate_get_cfui_tax_data($cfui_tax) {
541
  $cfui_tax_migrated = array();
includes/post-relationship.php CHANGED
@@ -1,200 +1,41 @@
1
  <?php
2
  /*
3
  * Post relationship code.
4
- *
5
  */
6
  require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
7
- add_filter( 'wpcf_post_type_form', 'wpcf_pr_post_type_form_filter', 10, 2 );
8
  add_action( 'wpcf_custom_types_save', 'wpcf_pr_custom_types_save_action' );
9
 
10
  /**
11
- * Init funtion.
12
  */
13
  function wpcf_post_relationship_init() {
14
  add_thickbox();
15
  wp_enqueue_script( 'wpcf-post-relationship',
16
  WPCF_EMBEDDED_RELPATH . '/resources/js/post-relationship.js',
17
  array('jquery'), WPCF_VERSION );
 
18
  }
19
 
20
  /**
21
- * Adds Post relationship table to form.
22
- *
23
- * @param type $form
24
- * @param type $post_type
25
- * @return string
26
  */
27
- function wpcf_pr_post_type_form_filter( $form, $post_type ) {
28
 
29
- global $wpcf;
30
-
31
- $has = wpcf_pr_admin_get_has( $post_type['slug'] );
32
- $belongs = wpcf_pr_admin_get_belongs( $post_type['slug'] );
33
- $post_types = get_post_types( '', 'objects' );
34
-
35
- if ( empty( $has ) || empty( $post_type['slug'] ) ) {
36
- $txt_has = __( "Children: None", 'wpcf' );
37
- } else {
38
- $txt_has = array();
39
- foreach ( $has as $pr_key => $pr_data ) {
40
- $txt_has[] = isset( $post_types[$pr_key] ) ? $post_types[$pr_key]->labels->singular_name : $pr_key;
41
- }
42
- $txt_has = sprintf( __( "Children: %s", 'wpcf' ),
43
- implode( ', ', $txt_has ) );
44
- }
45
- wpcf_admin_add_js_settings( 'wpcf_pr_has_empty_txt',
46
- '\'' . __( "Children: None", 'wpcf' ) . '\'' );
47
- wpcf_admin_add_js_settings( 'wpcf_pr_has_txt',
48
- '\'' . __( "Children: %s", 'wpcf' ) . '\'' );
49
- // Others belonging to
50
- if ( !empty( $belongs ) ) {
51
- $txt_belongs = array();
52
- foreach ( $belongs as $pr_key => $pr_data ) {
53
- $txt_belongs[] = isset( $post_types[$pr_key] ) ? $post_types[$pr_key]->labels->singular_name : $pr_key;
54
- }
55
- $txt_belongs = sprintf( __( "Parent: %s", 'wpcf' ),
56
- implode( ', ', $txt_belongs ) );
57
- } else {
58
- $txt_belongs = __( "Parent: None", 'wpcf' );
59
- }
60
- wpcf_admin_add_js_settings( 'wpcf_pr_belongs_empty_txt',
61
- '\'' . __( "Parent: None", 'wpcf' ) . '\'' );
62
- wpcf_admin_add_js_settings( 'wpcf_pr_belongs_txt',
63
- '\'' . __( "Parent: %s", 'wpcf' ) . '\'' );
64
-
65
- $form['table-pr-open'] = array(
66
- '#type' => 'markup',
67
- '#markup' => '<table id="wpcf-types-form-pr-table" class="wpcf-types-form-table widefat"><thead><tr><th>'
68
- . __( 'Post Relationship', 'wpcf' ) . '</th></tr></thead><tbody><tr><td>',
69
- );
70
- $form['table-pr-belongs'] = array(
71
- '#type' => 'markup',
72
- '#markup' => '<div style="margin: 10px 0 10px 0;"><span class="wpcf-pr-belongs-summary">' . $txt_belongs . '</span>&nbsp;'
73
- . '<a href="javascript:void(0);" id="wpcf-pr-belongs-edit" class="button-secondary wpcf-pr-edit">'
74
- . __( 'Edit', 'wpcf' ) . '</a>',
75
- );
76
-
77
- $options = array();
78
-
79
- /**
80
- * build excluded post types
81
- */
82
- $excluded_post_types = $wpcf->excluded_post_types;
83
- $excluded_post_types[] = $post_type['slug'];
84
-
85
- foreach ( $post_types as $temp_post_type_slug => $temp_post_type ) {
86
- if (
87
- in_array( $temp_post_type_slug, $excluded_post_types )
88
- || (
89
- !$temp_post_type->show_ui
90
- && !apply_filters('wpcf_show_ui_hide_in_relationships', true)
91
- )
92
- ) {
93
- continue;
94
- }
95
- // Check if it's in has
96
- if ( isset( $has[$temp_post_type_slug] ) ) {
97
- continue;
98
- }
99
- $options[$temp_post_type_slug]['#name'] = 'ct[post_relationship][belongs][' . $temp_post_type_slug . ']';
100
- $options[$temp_post_type_slug]['#title'] = $temp_post_type->labels->singular_name;
101
- $options[$temp_post_type_slug]['#default_value'] = isset( $belongs[$temp_post_type_slug] );
102
- $options[$temp_post_type_slug]['#inline'] = true;
103
- $options[$temp_post_type_slug]['#after'] = '&nbsp;&nbsp;';
104
- if ( is_rtl() ) {
105
- $options[$temp_post_type_slug]['#before'] = '<div style="float:right;margin-left:10px;">';
106
- $options[$temp_post_type_slug]['#after'] .= '</div>';
107
  }
108
  }
109
- $form['table-pr-has-form'] = array(
110
- '#type' => 'checkboxes',
111
- '#options' => $options,
112
- '#name' => 'ct[post_relationship]',
113
- '#before' => '<div style="display:none; margin: 10px 0 20px 0;">',
114
- '#after' => '<br /><br /><a href="javascript:void(0);" class="button-primary wpcf-pr-belongs-apply">'
115
- . __( 'Apply', 'wpcf' ) . '</a>&nbsp;<a href="javascript:void(0);" class="button-secondary wpcf-pr-belongs-cancel">'
116
- . __( 'Cancel', 'wpcf' ) . '</a></div></div>',
117
- '#inline' => true,
118
- );
119
- $form['table-pr-has'] = array(
120
- '#type' => 'markup',
121
- '#markup' => '<div style="margin: 10px 0 5px 0;"><span class="wpcf-pr-has-summary">' . $txt_has . '</span>&nbsp;'
122
- . '<a href="javascript:void(0);" id="wpcf-pr-has-edit" class="button-secondary wpcf-pr-edit">'
123
- . __( 'Edit', 'wpcf' ) . '</a>',
124
- );
125
- $options = array();
126
- foreach ( $post_types as $temp_post_type_slug => $temp_post_type ) {
127
- if (
128
- in_array( $temp_post_type_slug, $excluded_post_types )
129
- || (
130
- !$temp_post_type->show_ui
131
- && !apply_filters('wpcf_show_ui_hide_in_relationships', true)
132
- )
133
- ) {
134
- continue;
135
- }
136
- // Check if it already belongs
137
- if ( isset( $belongs[$temp_post_type_slug] ) ) {
138
- continue;
139
- }
140
- $options[$temp_post_type_slug]['#name'] = 'ct[post_relationship][has][' . $temp_post_type_slug . ']';
141
- $options[$temp_post_type_slug]['#title'] = $temp_post_type->labels->singular_name;
142
- $options[$temp_post_type_slug]['#default_value'] = isset( $has[$temp_post_type_slug] );
143
- $options[$temp_post_type_slug]['#inline'] = true;
144
- $options[$temp_post_type_slug]['#after'] = isset( $has[$temp_post_type_slug] ) ? ''
145
- . '<a href="'
146
- . admin_url( 'admin-ajax.php?action=wpcf_ajax&wpcf_action=pt_edit_fields&child='
147
- . $temp_post_type_slug . '&parent='
148
- . $post_type['slug']
149
- . '&_wpnonce='
150
- . wp_create_nonce( 'pt_edit_fields' )
151
- . '&KeepThis=true&TB_iframe=true' )
152
- . '" class="thickbox" title="'
153
- . __('Select child fields to be displayed', 'wpcf') . '">('
154
- . __( 'Edit fields' ) . ')</a>&nbsp;&nbsp;' : ''
155
- . '<a href="javascript:void(0);" style="color:Gray;" title="'
156
- . __( 'Please save the page first, before you can edit the child items',
157
- 'wpcf' ) . '">('
158
- . __( 'Edit fields' ) . ')</a>&nbsp;&nbsp;';
159
- if ( is_rtl() ) {
160
- $options[$temp_post_type_slug]['#before'] = '<div style="float:right;margin-left:10px;">';
161
- $options[$temp_post_type_slug]['#after'] .= '</div>';
162
- }
163
- }
164
- $form['table-pr-belongs-form'] = array(
165
- '#type' => 'checkboxes',
166
- '#options' => $options,
167
- '#name' => 'ct[post_relationship]',
168
- '#before' => '<div style="display:none; margin: 10px 0 20px 0;">',
169
- '#after' => '<br /><br /><a href="javascript:void(0);" class="button-primary wpcf-pr-has-apply">'
170
- . __( 'Apply', 'wpcf' ) . '</a>&nbsp;<a href="javascript:void(0);" class="button-secondary wpcf-pr-has-cancel">'
171
- . __( 'Cancel', 'wpcf' ) . '</a></div></div>',
172
- '#inline' => true,
173
- );
174
- $form['table-pr-close'] = array(
175
- '#type' => 'markup',
176
- '#markup' => '</td></tr></tbody></table>',
177
- );
178
- $form['table-pr-explanation'] = array(
179
- '#type' => 'markup',
180
- '#markup' => '<p>'
181
- . __( "You can choose which fields will show when editing parent pages.",
182
- 'wpcf' )
183
- . '<br />' . __( "Click on the 'edit' button to select them for each parent.",
184
- 'wpcf' )
185
- . '<br />'
186
- . sprintf( __( 'Learn about %sPost Type Relationships%s', 'wpcf' ),
187
- '<a href="http://wp-types.com/documentation/user-guides/creating-post-type-relationships/" target="_blank">',
188
- ' &raquo;</a>' )
189
- . '</p>',
190
- );
191
- return $form;
192
  }
193
 
194
  /**
195
  * Saves relationships.
196
- *
197
- * @param type $data
198
  */
199
  function wpcf_pr_custom_types_save_action( $data ) {
200
  $relationships = get_option( 'wpcf_post_relationship', array() );
@@ -238,13 +79,11 @@ function wpcf_pr_custom_types_save_action( $data ) {
238
 
239
  /**
240
  * Edit fields form.
241
- *
242
- * @global type $wpdb
243
  * @param type $parent
244
- * @param type $child
245
  */
246
  function wpcf_pr_admin_edit_fields( $parent, $child ) {
247
- global $wpdb;
248
 
249
  $post_type_parent = get_post_type_object( $parent );
250
  $post_type_child = get_post_type_object( $child );
@@ -261,7 +100,8 @@ function wpcf_pr_admin_edit_fields( $parent, $child ) {
261
  wpcf_admin_ajax_head( 'Edit fields', 'wpcf' );
262
  // Process submit
263
  if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'pt_edit_fields' ) ) {
264
- $relationships[$parent][$child]['fields_setting'] = $_POST['fields_setting'];
 
265
  $relationships[$parent][$child]['fields'] = isset( $_POST['fields'] ) ? $_POST['fields'] : array();
266
  update_option( 'wpcf_post_relationship', $relationships );
267
  ?>
@@ -376,7 +216,7 @@ function wpcf_pr_admin_edit_fields( $parent, $child ) {
376
  if (jQuery('input[name="fields_setting"]:checked').val() == 'specific') {
377
  jQuery('#wpcf-specific').show();
378
  } else {
379
- <?php if ( $repetitive_warning && 'only_list' != $form['select']['#default_value']) {
380
 
381
  ?>
382
  jQuery('#wpcf-repetitive-warning').show();
@@ -401,3 +241,176 @@ function wpcf_pr_admin_edit_fields( $parent, $child ) {
401
  <?php
402
  wpcf_admin_ajax_footer();
403
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /*
3
  * Post relationship code.
4
+ *
5
  */
6
  require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
 
7
  add_action( 'wpcf_custom_types_save', 'wpcf_pr_custom_types_save_action' );
8
 
9
  /**
10
+ * Init funtion.
11
  */
12
  function wpcf_post_relationship_init() {
13
  add_thickbox();
14
  wp_enqueue_script( 'wpcf-post-relationship',
15
  WPCF_EMBEDDED_RELPATH . '/resources/js/post-relationship.js',
16
  array('jquery'), WPCF_VERSION );
17
+ add_filter('wpcf_meta_box_order_defaults', 'wpcf_post_relationship_add_metabox', 10, 2);
18
  }
19
 
20
  /**
21
+ * add metabox relationship to list
 
 
 
 
22
  */
 
23
 
24
+ function wpcf_post_relationship_add_metabox($meta_boxes, $type )
25
+ {
26
+ if ( 'post_type' == $type ) {
27
+ $key = 'relationship';
28
+ if ( !in_array($key, $meta_boxes['side']) && !in_array($key, $meta_boxes['normal'])) {
29
+ $meta_boxes['normal'][] = $key;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  }
31
  }
32
+ return $meta_boxes;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  }
34
 
35
  /**
36
  * Saves relationships.
37
+ *
38
+ * @param type $data
39
  */
40
  function wpcf_pr_custom_types_save_action( $data ) {
41
  $relationships = get_option( 'wpcf_post_relationship', array() );
79
 
80
  /**
81
  * Edit fields form.
82
+ *
 
83
  * @param type $parent
84
+ * @param type $child
85
  */
86
  function wpcf_pr_admin_edit_fields( $parent, $child ) {
 
87
 
88
  $post_type_parent = get_post_type_object( $parent );
89
  $post_type_child = get_post_type_object( $child );
100
  wpcf_admin_ajax_head( 'Edit fields', 'wpcf' );
101
  // Process submit
102
  if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'pt_edit_fields' ) ) {
103
+ $relationships[$parent][$child]['fields_setting'] = sanitize_text_field( $_POST['fields_setting'] );
104
+ // @todo Maybe sanitization here
105
  $relationships[$parent][$child]['fields'] = isset( $_POST['fields'] ) ? $_POST['fields'] : array();
106
  update_option( 'wpcf_post_relationship', $relationships );
107
  ?>
216
  if (jQuery('input[name="fields_setting"]:checked').val() == 'specific') {
217
  jQuery('#wpcf-specific').show();
218
  } else {
219
+ <?php if ( $repetitive_warning && 'only_list' != $form['select']['#default_value']) {
220
 
221
  ?>
222
  jQuery('#wpcf-repetitive-warning').show();
241
  <?php
242
  wpcf_admin_ajax_footer();
243
  }
244
+
245
+ function wpcf_admin_metabox_relationship($post_type)
246
+ {
247
+ $form = array();
248
+ $form['table-pr-open'] = wpcf_admin_metabox_begin(__( 'Post Relationship', 'wpcf' ), 'relationship', 'wpcf-types-form-pr-table', false);
249
+ /**
250
+ * belongs/children section
251
+ */
252
+ $has = wpcf_pr_admin_get_has( $post_type['slug'] );
253
+ $belongs = wpcf_pr_admin_get_belongs( $post_type['slug'] );
254
+ $post_types = get_post_types( '', 'objects' );
255
+
256
+ if ( empty( $has ) || empty( $post_type['slug'] ) ) {
257
+ $txt_has = __( "Children: None", 'wpcf' );
258
+ } else {
259
+ $txt_has = array();
260
+ foreach ( $has as $pr_key => $pr_data ) {
261
+ $txt_has[] = isset( $post_types[$pr_key] ) ? $post_types[$pr_key]->labels->singular_name : $pr_key;
262
+ }
263
+ $txt_has = sprintf( __( "Children: %s", 'wpcf' ), implode( ', ', $txt_has ) );
264
+ }
265
+ if ( !empty( $belongs ) ) {
266
+ $txt_belongs = array();
267
+ foreach ( $belongs as $pr_key => $pr_data ) {
268
+ $txt_belongs[] = isset( $post_types[$pr_key] ) ? $post_types[$pr_key]->labels->singular_name : $pr_key;
269
+ }
270
+ $txt_belongs = sprintf( __( "Parent: %s", 'wpcf' ),
271
+ implode( ', ', $txt_belongs ) );
272
+ } else {
273
+ $txt_belongs = __( "Parent: None", 'wpcf' );
274
+ }
275
+ // Others belonging to
276
+ if ( !empty( $belongs ) ) {
277
+ $txt_belongs = array();
278
+ foreach ( $belongs as $pr_key => $pr_data ) {
279
+ $txt_belongs[] = isset( $post_types[$pr_key] ) ? $post_types[$pr_key]->labels->singular_name : $pr_key;
280
+ }
281
+ $txt_belongs = sprintf( __( "Parent: %s", 'wpcf' ),
282
+ implode( ', ', $txt_belongs ) );
283
+ } else {
284
+ $txt_belongs = __( "Parent: None", 'wpcf' );
285
+ }
286
+ $form['table-pr-belongs'] = array(
287
+ '#type' => 'markup',
288
+ '#markup' => '<div style="margin: 10px 0 10px 0;"><span class="wpcf-pr-belongs-summary">' . $txt_belongs . '</span>&nbsp;'
289
+ . '<a href="javascript:void(0);" id="wpcf-pr-belongs-edit" class="button-secondary wpcf-pr-edit">'
290
+ . __( 'Edit', 'wpcf' ) . '</a>',
291
+ );
292
+ $options = array();
293
+
294
+ /**
295
+ * build excluded post types
296
+ */
297
+ global $wpcf;
298
+ $excluded_post_types = $wpcf->excluded_post_types;
299
+ $excluded_post_types[] = $post_type['slug'];
300
+
301
+ foreach ( $post_types as $temp_post_type_slug => $temp_post_type ) {
302
+ if (
303
+ in_array( $temp_post_type_slug, $excluded_post_types )
304
+ || (
305
+ !$temp_post_type->show_ui
306
+ && !apply_filters('wpcf_show_ui_hide_in_relationships', true)
307
+ )
308
+ ) {
309
+ continue;
310
+ }
311
+ // Check if it's in has
312
+ if ( isset( $has[$temp_post_type_slug] ) ) {
313
+ continue;
314
+ }
315
+ $options[$temp_post_type_slug]['#name'] = 'ct[post_relationship][belongs][' . $temp_post_type_slug . ']';
316
+ $options[$temp_post_type_slug]['#title'] = $temp_post_type->labels->singular_name;
317
+ $options[$temp_post_type_slug]['#default_value'] = isset( $belongs[$temp_post_type_slug] );
318
+ $options[$temp_post_type_slug]['#inline'] = true;
319
+ $options[$temp_post_type_slug]['#after'] = '&nbsp;&nbsp;';
320
+ if ( is_rtl() ) {
321
+ $options[$temp_post_type_slug]['#before'] = '<div style="float:right;margin-left:10px;">';
322
+ $options[$temp_post_type_slug]['#after'] .= '</div>';
323
+ }
324
+ }
325
+ $form['table-pr-has-form'] = array(
326
+ '#type' => 'checkboxes',
327
+ '#options' => $options,
328
+ '#name' => 'ct[post_relationship]',
329
+ '#before' => '<div style="display:none; margin: 10px 0 20px 0;">',
330
+ '#after' => '<br /><br /><a href="javascript:void(0);" class="button-primary wpcf-pr-belongs-apply">'
331
+ . __( 'Apply', 'wpcf' ) . '</a>&nbsp;<a href="javascript:void(0);" class="button-secondary wpcf-pr-belongs-cancel">'
332
+ . __( 'Cancel', 'wpcf' ) . '</a></div></div>',
333
+ '#inline' => true,
334
+ );
335
+ $form['table-pr-has'] = array(
336
+ '#type' => 'markup',
337
+ '#markup' => '<div style="margin: 10px 0 5px 0;"><span class="wpcf-pr-has-summary">' . $txt_has . '</span>&nbsp;'
338
+ . '<a href="javascript:void(0);" id="wpcf-pr-has-edit" class="button-secondary wpcf-pr-edit">'
339
+ . __( 'Edit', 'wpcf' ) . '</a>',
340
+ );
341
+ $options = array();
342
+ foreach ( $post_types as $temp_post_type_slug => $temp_post_type ) {
343
+ if (
344
+ in_array( $temp_post_type_slug, $excluded_post_types )
345
+ || (
346
+ !$temp_post_type->show_ui
347
+ && !apply_filters('wpcf_show_ui_hide_in_relationships', true)
348
+ )
349
+ ) {
350
+ continue;
351
+ }
352
+ // Check if it already belongs
353
+ if ( isset( $belongs[$temp_post_type_slug] ) ) {
354
+ continue;
355
+ }
356
+ $options[$temp_post_type_slug]['#name'] = 'ct[post_relationship][has][' . $temp_post_type_slug . ']';
357
+ $options[$temp_post_type_slug]['#title'] = $temp_post_type->labels->singular_name;
358
+ $options[$temp_post_type_slug]['#default_value'] = isset( $has[$temp_post_type_slug] );
359
+ $options[$temp_post_type_slug]['#inline'] = true;
360
+ $options[$temp_post_type_slug]['#after'] = isset( $has[$temp_post_type_slug] ) ? ''
361
+ . '<a href="'
362
+ . admin_url( 'admin-ajax.php?action=wpcf_ajax&wpcf_action=pt_edit_fields&child='
363
+ . $temp_post_type_slug . '&parent='
364
+ . $post_type['slug']
365
+ . '&_wpnonce='
366
+ . wp_create_nonce( 'pt_edit_fields' )
367
+ . '&KeepThis=true&TB_iframe=true' )
368
+ . '" class="thickbox" title="'
369
+ . __('Select child fields to be displayed', 'wpcf') . '">('
370
+ . __( 'Edit fields' ) . ')</a>&nbsp;&nbsp;' : ''
371
+ . '<a href="javascript:void(0);" style="color:Gray;" title="'
372
+ . __( 'Please save the page first, before you can edit the child items',
373
+ 'wpcf' ) . '">('
374
+ . __( 'Edit fields' ) . ')</a>&nbsp;&nbsp;';
375
+ if ( is_rtl() ) {
376
+ $options[$temp_post_type_slug]['#before'] = '<div style="float:right;margin-left:10px;">';
377
+ $options[$temp_post_type_slug]['#after'] .= '</div>';
378
+ }
379
+ }
380
+ $form['table-pr-belongs-form'] = array(
381
+ '#type' => 'checkboxes',
382
+ '#options' => $options,
383
+ '#name' => 'ct[post_relationship]',
384
+ '#before' => '<div style="display:none; margin: 10px 0 20px 0;">',
385
+ '#after' => '<br /><br /><a href="javascript:void(0);" class="button-primary wpcf-pr-has-apply">'
386
+ . __( 'Apply', 'wpcf' ) . '</a>&nbsp;<a href="javascript:void(0);" class="button-secondary wpcf-pr-has-cancel">'
387
+ . __( 'Cancel', 'wpcf' ) . '</a></div></div>',
388
+ '#inline' => true,
389
+ );
390
+ $form['table-pr-explanation'] = array(
391
+ '#type' => 'markup',
392
+ '#markup' => '<p>'
393
+ . __( "You can choose which fields will show when editing parent pages.",
394
+ 'wpcf' )
395
+ . '<br />' . __( "Click on the 'edit' button to select them for each parent.",
396
+ 'wpcf' )
397
+ . '<br />'
398
+ . sprintf( __( 'Learn about %sPost Type Relationships%s', 'wpcf' ),
399
+ '<a href="http://wp-types.com/documentation/user-guides/creating-post-type-relationships/" target="_blank">',
400
+ ' &raquo;</a>' )
401
+ . '</p>',
402
+ );
403
+ /**
404
+ * close form
405
+ */
406
+ $form['table-pr-close'] = wpcf_admin_metabox_end();
407
+ /**
408
+ * additional settings
409
+ */
410
+ wpcf_admin_add_js_settings( 'wpcf_pr_has_empty_txt', '\'' . __( "Children: None", 'wpcf' ) . '\'' );
411
+ wpcf_admin_add_js_settings( 'wpcf_pr_has_txt', '\'' . __( "Children: %s", 'wpcf' ) . '\'' );
412
+ wpcf_admin_add_js_settings( 'wpcf_pr_belongs_empty_txt', '\'' . __( "Parent: None", 'wpcf' ) . '\'' );
413
+ wpcf_admin_add_js_settings( 'wpcf_pr_belongs_txt', '\'' . __( "Parent: %s", 'wpcf' ) . '\'' );
414
+ return $form;
415
+ }
416
+
includes/settings.php CHANGED
@@ -187,6 +187,7 @@ function wpcf_admin_image_settings_form_submit($form) {
187
  if (!isset($data[$setting])) {
188
  $settings[$setting] = 0;
189
  } else {
 
190
  $settings[$setting] = $data[$setting];
191
  }
192
  }
@@ -203,27 +204,11 @@ function wpcf_admin_general_settings_form_submit($form) {
203
  if (!isset($data[$setting])) {
204
  $settings[$setting] = 0;
205
  } else {
 
206
  $settings[$setting] = $data[$setting];
207
  }
208
  }
209
  update_option('wpcf_settings', $settings);
210
 
211
- // Credits
212
- // TODO Remove
213
- // require_once WPCF_EMBEDDED_INC_ABSPATH . '/footer-credit.php';
214
- // $option = get_option('wpcf_footer_credit', array());
215
- // if (!isset($option['message'])) {
216
- // $data = wpcf_footer_credit_defaults();
217
- // shuffle($data);
218
- // $option['message'] = rand(0, count($data));
219
- // }
220
- // if (!isset($_POST['show_credits'])) {
221
- // update_option('wpcf_footer_credit',
222
- // array('active' => 0, 'message' => $option['message']));
223
- // } else {
224
- // update_option('wpcf_footer_credit',
225
- // array('active' => 1, 'message' => $option['message']));
226
- // }
227
-
228
  wpcf_admin_message_store(__('Settings saved', 'wpcf'));
229
  }
187
  if (!isset($data[$setting])) {
188
  $settings[$setting] = 0;
189
  } else {
190
+ // @todo Add sanitization here
191
  $settings[$setting] = $data[$setting];
192
  }
193
  }
204
  if (!isset($data[$setting])) {
205
  $settings[$setting] = 0;
206
  } else {
207
+ // @todo Add sanitization here
208
  $settings[$setting] = $data[$setting];
209
  }
210
  }
211
  update_option('wpcf_settings', $settings);
212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  wpcf_admin_message_store(__('Settings saved', 'wpcf'));
214
  }
includes/usermeta-control.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Custom Fields Control Screen
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/includes/usermeta-control.php $
6
- * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
7
- * $LastChangedRevision: 1069430 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -14,6 +14,9 @@
14
  class WPCF_User_Fields_Control_Table extends WP_List_Table
15
  {
16
 
 
 
 
17
  function prepare_items() {
18
  global $wpdb;
19
  $wpcf_per_page = 15;
@@ -109,10 +112,14 @@ class WPCF_User_Fields_Control_Table extends WP_List_Table
109
  $sorted_keys = array();
110
  $new_array = array();
111
  foreach ($cf_types as $cf_id_temp => $cf_temp) {
112
- $sorted_keys[$cf_temp['id']] = strtolower( $cf_temp[$sort_matches[$_REQUEST['orderby']]] );
 
 
 
 
113
  }
114
  asort($sorted_keys, SORT_STRING);
115
- if ($_REQUEST['order'] == 'desc') {
116
  $sorted_keys = array_reverse($sorted_keys, true);
117
  }
118
  foreach ($sorted_keys as $cf_id_temp => $groups_txt) {
@@ -125,8 +132,7 @@ class WPCF_User_Fields_Control_Table extends WP_List_Table
125
  if (!empty($_REQUEST['s'])) {
126
  $search_results = array();
127
  foreach ($cf_types as $search_id => $search_field) {
128
- if (strpos(strval($search_field['name']),
129
- strval(trim(stripslashes($_REQUEST['s'])))) !== false) {
130
  $search_results[$search_id] = $cf_types[$search_id];
131
  }
132
  }
@@ -233,14 +239,28 @@ class WPCF_User_Fields_Control_Table extends WP_List_Table
233
  return $actions;
234
  }
235
 
236
- function view_switcher($current_mode = '') {
237
- echo '<div style="clear:both; margin: 20px 0 10px 0; float: right;"><a class="button button-secondary" href="';
 
 
238
  if (empty($_GET['display_all'])) {
239
- echo esc_url($_SERVER['REQUEST_URI']) . '&amp;display_all=1">' . __('Display all items', 'wpcf');
240
- } else {
241
- echo esc_url($_SERVER['REQUEST_URI']) . '&amp;display_all=0">' . __('Show pagination', 'wpcf');
242
  }
243
- echo '</a></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  }
245
 
246
  }
@@ -249,16 +269,23 @@ class WPCF_User_Fields_Control_Table extends WP_List_Table
249
  /**
250
  * Submitted Bulk actions.
251
  */
252
- function wpcf_admin_user_fields_control_bulk_actions($action = '') {
 
 
 
 
 
 
 
253
 
254
  if ($action == 'wpcf-deactivate-bulk') {
255
 
256
  $fields = wpcf_admin_fields_get_fields(false, true, false, 'wpcf-usermeta');
257
  foreach ($_POST['fields'] as $field_id) {
 
258
  if (isset($fields[$field_id])) {
259
  $fields[$field_id]['data']['disabled'] = 1;
260
- wpcf_admin_message_store(sprintf(__('Removed from Types control: %s',
261
- 'wpcf'), $fields[$field_id]['name']));
262
  }
263
  }
264
  wpcf_admin_fields_save_fields($fields, false, 'wpcf-usermeta');
@@ -266,13 +293,12 @@ function wpcf_admin_user_fields_control_bulk_actions($action = '') {
266
 
267
  $fields = wpcf_admin_fields_get_fields(false, true, false, 'wpcf-usermeta');
268
  $fields_bulk = wpcf_types_cf_under_control('add',
269
- array('fields' => $_POST['fields']), 'wp-types-user-group', 'wpcf-usermeta');
270
  foreach ($fields_bulk as $field_id) {
271
  if (isset($fields[$field_id])) {
272
  $fields[$field_id]['data']['disabled'] = 0;
273
  }
274
- wpcf_admin_message_store(sprintf(__('Added to Types control: %s',
275
- 'wpcf'), $field_id));
276
  }
277
  wpcf_admin_fields_save_fields($fields, false, 'wpcf-usermeta');
278
  } else if ($action == 'wpcf-delete-bulk') {
@@ -280,17 +306,16 @@ function wpcf_admin_user_fields_control_bulk_actions($action = '') {
280
  $failed = array();
281
  $success = array();
282
  foreach ($_POST['fields'] as $field_id) {
 
283
  $response = wpcf_admin_fields_delete_field($field_id, 'wp-types-user-group', 'wpcf-usermeta');
284
  if (!$response) {
285
- $failed[] = str_replace('_' . md5('wpcf_not_controlled'), '',
286
- $field_id);
287
  } else {
288
  $success[] = $field_id;
289
  }
290
  }
291
  if (!empty($success)) {
292
- wpcf_admin_message_store(sprintf(__('Fields %s have been deleted.',
293
- 'wpcf'), implode(', ', $success)));
294
  }
295
  if (!empty($failed)) {
296
  wpcf_admin_message_store(
@@ -302,7 +327,15 @@ function wpcf_admin_user_fields_control_bulk_actions($action = '') {
302
  );
303
  }
304
  }
305
- wp_redirect($_SERVER['REQUEST_URI']);
 
 
 
 
 
 
 
 
306
  die();
307
  }
308
 
@@ -363,8 +396,9 @@ function wpcf_admin_user_fields_control_bulk_ajax() {
363
  }
364
  if (!empty($_POST)) {
365
  if (!empty($_POST['groups']) && !empty($_POST['fields'])) {
366
- $action = isset($_POST['wpcf_action_control']) ? $_POST['wpcf_action_control'] : 'wpcf-add-to-group-bulk';
367
  foreach ($_POST['groups'] as $group_id) {
 
368
  switch ($action) {
369
  case 'wpcf-add-to-group-bulk':
370
  wpcf_admin_fields_save_group_fields($group_id,
@@ -382,7 +416,7 @@ function wpcf_admin_user_fields_control_bulk_ajax() {
382
  }
383
  } else if (!empty($_POST['type']) && !empty($_POST['fields'])) {
384
  wpcf_admin_custom_fields_change_type($_POST['fields'],
385
- $_POST['type'], 'wp-types-user-group', 'wpcf-usermeta');
386
  }
387
  echo '<script type="text/javascript">
388
  window.parent.jQuery("#TB_closeWindowButton").click();
@@ -414,6 +448,7 @@ function wpcf_admin_user_fields_control_bulk_ajax() {
414
  }
415
 
416
  foreach ($_GET['fields'] as $field_id) {
 
417
  $output[$field_id] = array(
418
  '#type' => 'hidden',
419
  '#name' => 'fields[]',
2
  /*
3
  * Custom Fields Control Screen
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/includes/usermeta-control.php $
6
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
7
+ * $LastChangedRevision: 1120400 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
14
  class WPCF_User_Fields_Control_Table extends WP_List_Table
15
  {
16
 
17
+ /**
18
+ * @global object $wpdb
19
+ */
20
  function prepare_items() {
21
  global $wpdb;
22
  $wpcf_per_page = 15;
112
  $sorted_keys = array();
113
  $new_array = array();
114
  foreach ($cf_types as $cf_id_temp => $cf_temp) {
115
+ if ( isset($sort_matches[$_REQUEST['orderby']] ) ) {
116
+ $sorted_keys[$cf_temp['id']] = strtolower( $cf_temp[$sort_matches[$_REQUEST['orderby']]] );
117
+ } else {
118
+ $sorted_keys[$cf_temp['id']] = strtolower( $cf_temp[$sort_matches['c']] );
119
+ }
120
  }
121
  asort($sorted_keys, SORT_STRING);
122
+ if ('desc' == $_REQUEST['order']) {
123
  $sorted_keys = array_reverse($sorted_keys, true);
124
  }
125
  foreach ($sorted_keys as $cf_id_temp => $groups_txt) {
132
  if (!empty($_REQUEST['s'])) {
133
  $search_results = array();
134
  foreach ($cf_types as $search_id => $search_field) {
135
+ if (strpos(strval($search_field['name']), strval(trim(stripslashes($_REQUEST['s'])))) !== false) {
 
136
  $search_results[$search_id] = $cf_types[$search_id];
137
  }
138
  }
239
  return $actions;
240
  }
241
 
242
+ function view_switcher($current_mode = '')
243
+ {
244
+ $display = 0;
245
+ $text = __('Show pagination', 'wpcf');
246
  if (empty($_GET['display_all'])) {
247
+ $display = 1;
248
+ $text = __('Display all items', 'wpcf');
 
249
  }
250
+ $url = add_query_arg(
251
+ array(
252
+ 'page' => 'wpcf-user-fields-control',
253
+ 'display_all' => $display,
254
+ ),
255
+ admin_url('admin.php')
256
+ );
257
+ echo '<div style="clear:both; margin: 20px 0 10px 0; float: right;">';
258
+ printf(
259
+ '<a class="button button-secondary" href="%s">%s</a>',
260
+ $url,
261
+ $text
262
+ );
263
+ echo '</div>';
264
  }
265
 
266
  }
269
  /**
270
  * Submitted Bulk actions.
271
  */
272
+ function wpcf_admin_user_fields_control_bulk_actions($action = '')
273
+ {
274
+ if (
275
+ !isset($_POST['_wpnonce'])
276
+ || !wp_verify_nonce($_POST['_wpnonce'], 'user_fields_control_bulk')
277
+ ) {
278
+ return;
279
+ }
280
 
281
  if ($action == 'wpcf-deactivate-bulk') {
282
 
283
  $fields = wpcf_admin_fields_get_fields(false, true, false, 'wpcf-usermeta');
284
  foreach ($_POST['fields'] as $field_id) {
285
+ $field_id = sanitize_text_field( $field_id );
286
  if (isset($fields[$field_id])) {
287
  $fields[$field_id]['data']['disabled'] = 1;
288
+ wpcf_admin_message_store(sprintf(__('Removed from Types control: %s', 'wpcf'), $fields[$field_id]['name']));
 
289
  }
290
  }
291
  wpcf_admin_fields_save_fields($fields, false, 'wpcf-usermeta');
293
 
294
  $fields = wpcf_admin_fields_get_fields(false, true, false, 'wpcf-usermeta');
295
  $fields_bulk = wpcf_types_cf_under_control('add',
296
+ array('fields' => $_POST['fields']), 'wp-types-user-group', 'wpcf-usermeta');
297
  foreach ($fields_bulk as $field_id) {
298
  if (isset($fields[$field_id])) {
299
  $fields[$field_id]['data']['disabled'] = 0;
300
  }
301
+ wpcf_admin_message_store(sprintf(__('Added to Types control: %s', 'wpcf'), $field_id));
 
302
  }
303
  wpcf_admin_fields_save_fields($fields, false, 'wpcf-usermeta');
304
  } else if ($action == 'wpcf-delete-bulk') {
306
  $failed = array();
307
  $success = array();
308
  foreach ($_POST['fields'] as $field_id) {
309
+ $field_id = sanitize_text_field( $field_id );
310
  $response = wpcf_admin_fields_delete_field($field_id, 'wp-types-user-group', 'wpcf-usermeta');
311
  if (!$response) {
312
+ $failed[] = str_replace('_' . md5('wpcf_not_controlled'), '', $field_id);
 
313
  } else {
314
  $success[] = $field_id;
315
  }
316
  }
317
  if (!empty($success)) {
318
+ wpcf_admin_message_store(sprintf(__('Fields %s have been deleted.', 'wpcf'), implode(', ', $success)));
 
319
  }
320
  if (!empty($failed)) {
321
  wpcf_admin_message_store(
327
  );
328
  }
329
  }
330
+
331
+ $url = add_query_arg(
332
+ array(
333
+ 'page' => 'wpcf-user-fields-control',
334
+ 'display_all' => isset($_REQUEST['display_all'])? 1:0,
335
+ ),
336
+ admin_url('admin.php')
337
+ );
338
+ wp_redirect($url);
339
  die();
340
  }
341
 
396
  }
397
  if (!empty($_POST)) {
398
  if (!empty($_POST['groups']) && !empty($_POST['fields'])) {
399
+ $action = isset($_POST['wpcf_action_control']) ? sanitize_text_field( $_POST['wpcf_action_control'] ) : 'wpcf-add-to-group-bulk';
400
  foreach ($_POST['groups'] as $group_id) {
401
+ $group_id = sanitize_text_field( $group_id );
402
  switch ($action) {
403
  case 'wpcf-add-to-group-bulk':
404
  wpcf_admin_fields_save_group_fields($group_id,
416
  }
417
  } else if (!empty($_POST['type']) && !empty($_POST['fields'])) {
418
  wpcf_admin_custom_fields_change_type($_POST['fields'],
419
+ sanitize_text_field( $_POST['type'] ), 'wp-types-user-group', 'wpcf-usermeta');
420
  }
421
  echo '<script type="text/javascript">
422
  window.parent.jQuery("#TB_closeWindowButton").click();
448
  }
449
 
450
  foreach ($_GET['fields'] as $field_id) {
451
+ $field_id = sanitize_text_field( $field_id );
452
  $output[$field_id] = array(
453
  '#type' => 'hidden',
454
  '#name' => 'fields[]',
includes/usermeta-form.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Fields and groups form functions.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/includes/usermeta-form.php $
6
- * $LastChangedDate: 2015-01-28 06:42:34 +0000 (Wed, 28 Jan 2015) $
7
- * $LastChangedRevision: 1077234 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -23,55 +23,64 @@ if (version_compare($wp_version, '3.5', '<')) {
23
 
24
  /**
25
  * Saves user fields and groups.
26
- *
27
  * If field name is changed in specific group - new one will be created,
28
  * otherwise old one will be updated and will appear in that way in other grups.
29
- *
30
- * @return type
31
  */
32
  function wpcf_admin_save_usermeta_groups_submit($form) {
33
- if (!isset($_POST['wpcf']['group']['name'])) {
 
 
 
 
34
  return false;
35
  }
36
-
37
- $_POST['wpcf']['group']['name'] = trim($_POST['wpcf']['group']['name']);
38
 
39
- $_POST['wpcf']['group'] = apply_filters('wpcf_group_pre_save',
40
- $_POST['wpcf']['group']);
 
 
 
 
 
 
 
41
 
42
- global $wpdb;
43
-
44
  $new_group = false;
45
 
46
  $group_slug = $_POST['wpcf']['group']['slug'] = sanitize_title($_POST['wpcf']['group']['name']);
47
 
48
  // Basic check
49
-
50
-
51
  if (isset($_REQUEST['group_id'])) {
52
  // Check if group exists
53
- $post = get_post($_REQUEST['group_id']);
54
  // Name changed
55
  if (strtolower($_POST['wpcf']['group']['name']) != strtolower($post->post_title)) {
56
  // Check if already exists
57
- $exists = get_page_by_title($_POST['wpcf']['group']['name'],
58
- 'OBJECT', 'wp-types-user-group');
59
  if (!empty($exists)) {
60
  $form->triggerError();
61
- wpcf_admin_message(sprintf(__("A group by name <em>%s</em> already exists. Please use a different name and save again.",
62
- 'wpcf'), $_POST['wpcf']['group']['name']),
63
- 'error');
 
 
 
 
64
  return $form;
65
  }
66
  }
67
  if (empty($post) || $post->post_type != 'wp-types-user-group') {
68
  $form->triggerError();
69
- wpcf_admin_message(sprintf(__("Wrong group ID %d", 'wpcf'),
70
- intval($_REQUEST['group_id'])), 'error');
71
  return $form;
72
  }
73
  $group_id = $post->ID;
74
-
75
  } else {
76
  $new_group = true;
77
  // Check if already exists
@@ -79,9 +88,13 @@ function wpcf_admin_save_usermeta_groups_submit($form) {
79
  'wp-types-user-group');
80
  if (!empty($exists)) {
81
  $form->triggerError();
82
- wpcf_admin_message(sprintf(__("A group by name <em>%s</em> already exists. Please use a different name and save again.",
83
- 'wpcf'), $_POST['wpcf']['group']['name']),
84
- 'error');
 
 
 
 
85
  return $form;
86
  }
87
  }
@@ -101,7 +114,7 @@ function wpcf_admin_save_usermeta_groups_submit($form) {
101
  return $form;
102
  }
103
  }
104
-
105
  foreach ($_POST['wpcf']['fields'] as $key => $field) {
106
  $field = apply_filters('wpcf_field_pre_save', $field);
107
  if (!empty($field['is_new'])) {
@@ -126,16 +139,16 @@ function wpcf_admin_save_usermeta_groups_submit($form) {
126
  if (!empty($field_id)) {
127
  $fields[] = $field_id;
128
  }
129
-
130
  }
131
  }
132
 
133
  // Save group
134
  $roles = isset($_POST['wpcf']['group']['supports']) ? $_POST['wpcf']['group']['supports'] : array();
135
- $admin_style = $_POST['wpcf']['group']['admin_styles'];
136
  // Rename if needed
137
  if (isset($_REQUEST['group_id'])) {
138
- $_POST['wpcf']['group']['id'] = $_REQUEST['group_id'];
139
  }
140
 
141
  $group_id = wpcf_admin_fields_save_group($_POST['wpcf']['group'], 'wp-types-user-group');
@@ -152,14 +165,14 @@ function wpcf_admin_save_usermeta_groups_submit($form) {
152
  $open_fieldsets);
153
  }
154
  }
155
-
156
-
157
  // Rest of processes
158
  if (!empty($group_id)) {
159
  wpcf_admin_fields_save_group_fields($group_id, $fields, false, 'wp-types-user-group');
160
  wpcf_admin_fields_save_group_showfor($group_id, $roles);
161
- wpcf_admin_fields_save_group_admin_styles($group_id, $admin_style);
162
-
163
  $_POST['wpcf']['group']['fields'] = isset($_POST['wpcf']['fields']) ? $_POST['wpcf']['fields'] : array();
164
  do_action('wpcf_save_group', $_POST['wpcf']['group']);
165
  wpcf_admin_message_store(apply_filters('types_message_usermeta_saved',
@@ -170,8 +183,8 @@ function wpcf_admin_save_usermeta_groups_submit($form) {
170
  } else {
171
  wpcf_admin_message_store(__('Error saving group', 'wpcf'), 'error');
172
  }
173
-
174
-
175
  }
176
 
177
 
@@ -179,7 +192,7 @@ function wpcf_admin_save_usermeta_groups_submit($form) {
179
  * Generates form data.
180
  */
181
  function wpcf_admin_usermeta_form() {
182
- global $wpcf;
183
  wpcf_admin_add_js_settings('wpcf_nonce_toggle_group',
184
  '\'' . wp_create_nonce('group_form_collapsed') . '\'');
185
  wpcf_admin_add_js_settings('wpcf_nonce_toggle_fieldset',
@@ -195,15 +208,14 @@ function wpcf_admin_usermeta_form() {
195
  $update = wpcf_admin_fields_get_group(intval($_REQUEST['group_id']), 'wp-types-user-group');
196
  if (empty($update)) {
197
  $update = false;
198
- wpcf_admin_message(sprintf(__("Group with ID %d do not exist",
199
- 'wpcf'), intval($_REQUEST['group_id'])));
200
  } else {
201
- $update['fields'] = wpcf_admin_fields_get_fields_by_group($_REQUEST['group_id'], 'slug', false, true, false, 'wp-types-user-group', 'wpcf-usermeta');
202
- $update['show_for'] = wpcf_admin_get_groups_showfor_by_group($_REQUEST['group_id']);
203
- $update['admin_styles'] = wpcf_admin_get_groups_admin_styles_by_group($_REQUEST['group_id']);
204
  }
205
  }
206
-
207
  $form = array();
208
  $form['#form']['callback'] = array('wpcf_admin_save_usermeta_groups_submit');
209
 
@@ -287,7 +299,7 @@ function wpcf_admin_usermeta_form() {
287
  continue;
288
  }
289
  if ( !empty( $field['data']['removed_from_history'] ) ) {
290
- continue;
291
  }
292
  $form['fields-existing'][$key] = array(
293
  '#type' => 'markup',
@@ -322,7 +334,7 @@ function wpcf_admin_usermeta_form() {
322
  '#type' => 'markup',
323
  '#markup' => '</div>',
324
  );
325
-
326
  // Group data
327
 
328
  $form['open-main'] = array(
@@ -334,40 +346,35 @@ function wpcf_admin_usermeta_form() {
334
  '#type' => 'textfield',
335
  '#name' => 'wpcf[group][name]',
336
  '#id' => 'wpcf-group-name',
337
- '#value' => $update ? $update['name'] : __('Enter group title', 'wpcf'),
338
  '#inline' => true,
339
- '#attributes' => array('style' => 'width:100%;margin-bottom:10px;'),
 
 
 
340
  '#validate' => array(
341
  'required' => array(
342
  'value' => true,
343
  ),
344
  )
345
  );
346
- if (!$update) {
347
- $form['title']['#attributes']['data-label'] = addcslashes(__( 'Enter group title', 'wpcf' ), '"');
348
- $form['title']['#attributes']['onfocus'] = 'if (jQuery(this).val() == jQuery(this).data(\'label\')) { jQuery(this).val(\'\'); }';
349
- $form['title']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(jQuery(this).data(\'label\')) }';
350
- }
351
  $form['description'] = array(
352
  '#type' => 'textarea',
353
  '#id' => 'wpcf-group-description',
354
  '#name' => 'wpcf[group][description]',
355
- '#value' => $update ? $update['description'] : __('Enter a description for this group',
356
- 'wpcf'),
 
 
357
  );
358
- if (!$update) {
359
- $form['description']['#attributes']['data-label'] = addcslashes(__( 'Enter a description for this group', 'wpcf' ), '"');
360
- $form['description']['#attributes']['onfocus'] = 'if (jQuery(this).val() == jQuery(this).data(\'label\')) { jQuery(this).val(\'\'); }';
361
- $form['description']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(jQuery(this).data(\'label\')) }';
362
- }
363
 
364
- // Show Fields for
365
- global $wp_roles;
366
  $options = array();
367
  $users_currently_supported = array();
368
  $form_types = array();
369
- foreach ( $wp_roles->role_names as $role => $name ) :
370
- $options[$role]['#name'] = 'wpcf[group][supports][' . $role . ']';
371
  $options[$role]['#title'] = ucwords($role);
372
  $options[$role]['#default_value'] = ($update && !empty($update['show_for']) && in_array($role,
373
  $update['show_for'])) ? 1 : 0;
@@ -380,9 +387,9 @@ function wpcf_admin_usermeta_form() {
380
  $update['show_for'])) {
381
  $users_currently_supported[] = ucwords($role);
382
  }
383
- endforeach;
384
-
385
- if (empty($users_currently_supported)) {
386
  $users_currently_supported[] = __('Displayed for all users roles',
387
  'wpcf');
388
  }
@@ -397,7 +404,7 @@ function wpcf_admin_usermeta_form() {
397
  '#inline' => true,
398
  );
399
  /*
400
- *
401
  * Here we use unique function for all filters
402
  * Since Types 1.1.4
403
  */
@@ -406,24 +413,24 @@ function wpcf_admin_usermeta_form() {
406
  implode(', ', $users_currently_supported),
407
  __('Displayed for all users roles', 'wpcf'), $temp);
408
 
409
- /*
410
  * Now starting form
411
  */
412
- $access_notification = '';
413
- if (function_exists('wpcf_access_register_caps')){
414
- $access_notification = '<div class="message custom wpcf-notif"><span class="wpcf-notif-congrats">'
415
- . __('This groups visibility is also controlled by the Access plugin.',
416
  'wpcf') .'</span></div>';
417
- }
418
  $form['supports-table-open'] = array(
419
  '#type' => 'markup',
420
  '#markup' => '<table class="widefat"><thead><tr><th>'
421
  . __('Where to display this group', 'wpcf')
422
  . '</th></tr></thead><tbody><tr><td>'
423
  . '<p>'
424
- . __('Each usermeta group can display different fields for user roles.',
425
  'wpcf')
426
- . $access_notification
427
  . '</p>',
428
  );
429
  /*
@@ -440,13 +447,13 @@ function wpcf_admin_usermeta_form() {
440
  '#type' => 'markup',
441
  '#markup' => '</td></tr></tbody></table><br />',
442
  );
443
-
444
-
445
-
446
-
447
- /** Admin styles**/
448
-
449
- $form['adminstyles-table-open'] = array(
450
  '#type' => 'markup',
451
  '#markup' => '<table class="widefat" id="wpcf-admin-styles-box"><thead><tr><th>'
452
  . __('Styling Editor', 'wpcf')
@@ -456,93 +463,93 @@ function wpcf_admin_usermeta_form() {
456
  'wpcf')
457
  . '</p>',
458
  );
459
-
460
- $admin_styles_value = $preview_profile = $edit_profile = '';
461
- if ( isset ($update['admin_styles']) ){
462
- $admin_styles_value = $update['admin_styles'];
463
- }
464
- $temp = '';
465
- if ($update){
466
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
467
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
468
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
469
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
470
-
471
- $user_id = wpcf_usermeta_get_user();
472
- $preview_profile = wpcf_usermeta_preview_profile( $user_id, $update, 1 );
473
- $group = $update;
474
- $group['fields'] = wpcf_admin_usermeta_process_fields( $user_id, $group['fields'], true, false );
475
- $edit_profile = wpcf_admin_render_fields($group, $user_id, 1);
476
  add_action( 'admin_enqueue_scripts', 'wpcf_admin_fields_form_fix_styles', PHP_INT_MAX );
477
- }
478
- $temp[] = array(
479
- '#type' => 'radio',
480
- '#suffix' => '<br />',
481
- '#value' => 'edit_mode',
482
- '#title' => 'Edit mode',
483
  '#name' => 'wpcf[group][preview]','#default_value' => '',
484
- '#before' => '<div class="wpcf-admin-css-preview-style-edit">',
485
  '#inline' => true,
486
- '#attributes' => array('onclick' => 'changePreviewHtml(\'editmode\')','checked'=>'checked')
487
- );
488
-
489
- $temp[] = array(
490
- '#type' => 'radio',
491
- '#title' => 'Read Only',
492
  '#name' => 'wpcf[group][preview]','#default_value' => '',
493
- '#after' => '</div>',
494
  '#inline' => true,
495
- '#attributes' => array('onclick' => 'changePreviewHtml(\'readonly\')')
496
- );
497
-
498
- $temp[] = array(
499
  '#type' => 'textarea',
500
  '#name' => 'wpcf[group][admin_html_preview]',
501
  '#inline' => true,
502
- '#value' => '',
503
- '#id' => 'wpcf-form-groups-admin-html-preview',
504
- '#before' => '<h3>Field group HTML</h3>'
505
  );
506
-
507
- $temp[] = array(
508
  '#type' => 'textarea',
509
  '#name' => 'wpcf[group][admin_styles]',
510
  '#inline' => true,
511
- '#value' => $admin_styles_value,
512
- '#default_value' => '',
513
- '#id' => 'wpcf-form-groups-css-fields-editor',
514
- '#after' => '
515
- <div class="wpcf-update-preview-btn"><input type="button" value="Update preview" onclick="wpcfPreviewHtml()" style="float:right;" class="button-secondary"></div>
516
- <h3>Field group preview</h3>
517
- <div id="wpcf-update-preview-div">Preview here</div>
518
- <script type="text/javascript">
519
- var wpcfReadOnly = ' . json_encode($preview_profile) . ';
520
- var wpcfEditMode = ' . json_encode($edit_profile) . ';
521
- var wpcfDefaultCss = ' . json_encode($admin_styles_value) . ';
522
- </script>
523
- ',
524
- '#before' => '<h3>Your CSS</h3>'
525
  );
526
-
527
-
528
-
529
-
530
- $admin_styles = _wpcf_filter_wrap( 'admin_styles',
531
  __('Admin styles for fields:', 'wpcf'), '', '', $temp, __( 'Open style editor', 'wpcf' ) );
532
- $form['p_wrap_1_' . wpcf_unique_id(serialize($admin_styles))] = array(
533
  '#type' => 'markup',
534
  '#markup' => '<p class="wpcf-filter-wrap">',
535
  );
536
- $form = $form + $admin_styles;
537
- $form['adminstyles-table-close'] = array(
538
  '#type' => 'markup',
539
  '#markup' => '</td></tr></tbody></table><br />',
540
  );
541
- /** End admin Styles **/
542
-
543
-
544
-
545
-
546
  // Group fields
547
 
548
  $form['fields_title'] = array(
@@ -636,8 +643,8 @@ function wpcf_admin_usermeta_form() {
636
  '#markup' => '</div>',
637
  );
638
 
639
-
640
- wpcf_admin_add_js_settings( 'wpcf_filters_association_or',
641
  '\'' . __( 'This group will appear on %pt% edit pages where content belongs to taxonomy: %tx% or View Template is: %vt%',
642
  'wpcf' ) . '\'' );
643
  wpcf_admin_add_js_settings( 'wpcf_filters_association_and',
@@ -663,12 +670,12 @@ function wpcf_admin_usermeta_form() {
663
 
664
  /**
665
  * Dynamically adds existing field on AJAX call.
666
- *
667
- * @param type $form_data
668
  */
669
  function wpcf_usermeta_insert_existing_ajax() {
670
- $field = wpcf_admin_fields_get_field( $_GET['field'], false, true, false, 'wpcf-usermeta');
671
-
672
  if ( !empty( $field ) ) {
673
  echo wpcf_fields_get_field_form( $field['type'], $field );
674
  } else {
2
  /*
3
  * Fields and groups form functions.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/includes/usermeta-form.php $
6
+ * $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
7
+ * $LastChangedRevision: 1120400 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
23
 
24
  /**
25
  * Saves user fields and groups.
26
+ *
27
  * If field name is changed in specific group - new one will be created,
28
  * otherwise old one will be updated and will appear in that way in other grups.
29
+ *
30
+ * @return type
31
  */
32
  function wpcf_admin_save_usermeta_groups_submit($form) {
33
+ if (
34
+ !isset($_POST['wpcf'])
35
+ || !isset($_POST['wpcf']['group'])
36
+ || !isset($_POST['wpcf']['group']['name'])
37
+ ) {
38
  return false;
39
  }
 
 
40
 
41
+ $_POST['wpcf']['group']['name'] = trim(strip_tags($_POST['wpcf']['group']['name']));
42
+
43
+ $_POST['wpcf']['group'] = apply_filters('wpcf_group_pre_save', $_POST['wpcf']['group']);
44
+
45
+ if ( empty($_POST['wpcf']['group']['name']) ) {
46
+ $form->triggerError();
47
+ wpcf_admin_message( __( 'Group name can not be empty.', 'wpcf' ), 'error');
48
+ return $form;
49
+ }
50
 
 
 
51
  $new_group = false;
52
 
53
  $group_slug = $_POST['wpcf']['group']['slug'] = sanitize_title($_POST['wpcf']['group']['name']);
54
 
55
  // Basic check
56
+
57
+
58
  if (isset($_REQUEST['group_id'])) {
59
  // Check if group exists
60
+ $post = get_post(intval($_REQUEST['group_id']));
61
  // Name changed
62
  if (strtolower($_POST['wpcf']['group']['name']) != strtolower($post->post_title)) {
63
  // Check if already exists
64
+ $exists = get_page_by_title($_POST['wpcf']['group']['name'], 'OBJECT', 'wp-types-user-group');
 
65
  if (!empty($exists)) {
66
  $form->triggerError();
67
+ wpcf_admin_message(
68
+ sprintf(
69
+ __("A group by name <em>%s</em> already exists. Please use a different name and save again.", 'wpcf'),
70
+ htmlspecialchars($_POST['wpcf']['group']['name'])
71
+ ),
72
+ 'error'
73
+ );
74
  return $form;
75
  }
76
  }
77
  if (empty($post) || $post->post_type != 'wp-types-user-group') {
78
  $form->triggerError();
79
+ wpcf_admin_message(sprintf(__("Wrong group ID %d", 'wpcf'), intval($_REQUEST['group_id'])), 'error');
 
80
  return $form;
81
  }
82
  $group_id = $post->ID;
83
+
84
  } else {
85
  $new_group = true;
86
  // Check if already exists
88
  'wp-types-user-group');
89
  if (!empty($exists)) {
90
  $form->triggerError();
91
+ wpcf_admin_message(
92
+ sprintf(
93
+ __("A group by name <em>%s</em> already exists. Please use a different name and save again.", 'wpcf'),
94
+ htmlspecialchars($_POST['wpcf']['group']['name'])
95
+ ),
96
+ 'error'
97
+ );
98
  return $form;
99
  }
100
  }
114
  return $form;
115
  }
116
  }
117
+
118
  foreach ($_POST['wpcf']['fields'] as $key => $field) {
119
  $field = apply_filters('wpcf_field_pre_save', $field);
120
  if (!empty($field['is_new'])) {
139
  if (!empty($field_id)) {
140
  $fields[] = $field_id;
141
  }
142
+
143
  }
144
  }
145
 
146
  // Save group
147
  $roles = isset($_POST['wpcf']['group']['supports']) ? $_POST['wpcf']['group']['supports'] : array();
148
+ $admin_style = $_POST['wpcf']['group']['admin_styles'];
149
  // Rename if needed
150
  if (isset($_REQUEST['group_id'])) {
151
+ $_POST['wpcf']['group']['id'] = intval($_REQUEST['group_id']);
152
  }
153
 
154
  $group_id = wpcf_admin_fields_save_group($_POST['wpcf']['group'], 'wp-types-user-group');
165
  $open_fieldsets);
166
  }
167
  }
168
+
169
+
170
  // Rest of processes
171
  if (!empty($group_id)) {
172
  wpcf_admin_fields_save_group_fields($group_id, $fields, false, 'wp-types-user-group');
173
  wpcf_admin_fields_save_group_showfor($group_id, $roles);
174
+ wpcf_admin_fields_save_group_admin_styles($group_id, $admin_style);
175
+
176
  $_POST['wpcf']['group']['fields'] = isset($_POST['wpcf']['fields']) ? $_POST['wpcf']['fields'] : array();
177
  do_action('wpcf_save_group', $_POST['wpcf']['group']);
178
  wpcf_admin_message_store(apply_filters('types_message_usermeta_saved',
183
  } else {
184
  wpcf_admin_message_store(__('Error saving group', 'wpcf'), 'error');
185
  }
186
+
187
+
188
  }
189
 
190
 
192
  * Generates form data.
193
  */
194
  function wpcf_admin_usermeta_form() {
195
+ global $wpcf;
196
  wpcf_admin_add_js_settings('wpcf_nonce_toggle_group',
197
  '\'' . wp_create_nonce('group_form_collapsed') . '\'');
198
  wpcf_admin_add_js_settings('wpcf_nonce_toggle_fieldset',
208
  $update = wpcf_admin_fields_get_group(intval($_REQUEST['group_id']), 'wp-types-user-group');
209
  if (empty($update)) {
210
  $update = false;
211
+ wpcf_admin_message(sprintf(__("Group with ID %d do not exist", 'wpcf'), intval($_REQUEST['group_id'])));
 
212
  } else {
213
+ $update['fields'] = wpcf_admin_fields_get_fields_by_group( sanitize_text_field( $_REQUEST['group_id'] ), 'slug', false, true, false, 'wp-types-user-group', 'wpcf-usermeta');
214
+ $update['show_for'] = wpcf_admin_get_groups_showfor_by_group( sanitize_text_field( $_REQUEST['group_id'] ) );
215
+ $update['admin_styles'] = wpcf_admin_get_groups_admin_styles_by_group( sanitize_text_field( $_REQUEST['group_id'] ) );
216
  }
217
  }
218
+
219
  $form = array();
220
  $form['#form']['callback'] = array('wpcf_admin_save_usermeta_groups_submit');
221
 
299
  continue;
300
  }
301
  if ( !empty( $field['data']['removed_from_history'] ) ) {
302
+ continue;
303
  }
304
  $form['fields-existing'][$key] = array(
305
  '#type' => 'markup',
334
  '#type' => 'markup',
335
  '#markup' => '</div>',
336
  );
337
+
338
  // Group data
339
 
340
  $form['open-main'] = array(
346
  '#type' => 'textfield',
347
  '#name' => 'wpcf[group][name]',
348
  '#id' => 'wpcf-group-name',
349
+ '#value' => $update ? $update['name'] : '',
350
  '#inline' => true,
351
+ '#attributes' => array(
352
+ 'style' => 'width:100%;margin-bottom:10px;',
353
+ 'placeholder' => __('Enter group title', 'wpcf'),
354
+ ),
355
  '#validate' => array(
356
  'required' => array(
357
  'value' => true,
358
  ),
359
  )
360
  );
 
 
 
 
 
361
  $form['description'] = array(
362
  '#type' => 'textarea',
363
  '#id' => 'wpcf-group-description',
364
  '#name' => 'wpcf[group][description]',
365
+ '#value' => $update ? $update['description'] : '',
366
+ '#attributes' => array(
367
+ 'placeholder' => __('Enter a description for this group', 'wpcf'),
368
+ ),
369
  );
 
 
 
 
 
370
 
371
+ // Show Fields for
372
+ global $wp_roles;
373
  $options = array();
374
  $users_currently_supported = array();
375
  $form_types = array();
376
+ foreach ( $wp_roles->role_names as $role => $name ) :
377
+ $options[$role]['#name'] = 'wpcf[group][supports][' . $role . ']';
378
  $options[$role]['#title'] = ucwords($role);
379
  $options[$role]['#default_value'] = ($update && !empty($update['show_for']) && in_array($role,
380
  $update['show_for'])) ? 1 : 0;
387
  $update['show_for'])) {
388
  $users_currently_supported[] = ucwords($role);
389
  }
390
+ endforeach;
391
+
392
+ if (empty($users_currently_supported)) {
393
  $users_currently_supported[] = __('Displayed for all users roles',
394
  'wpcf');
395
  }
404
  '#inline' => true,
405
  );
406
  /*
407
+ *
408
  * Here we use unique function for all filters
409
  * Since Types 1.1.4
410
  */
413
  implode(', ', $users_currently_supported),
414
  __('Displayed for all users roles', 'wpcf'), $temp);
415
 
416
+ /*
417
  * Now starting form
418
  */
419
+ $access_notification = '';
420
+ if (function_exists('wpcf_access_register_caps')){
421
+ $access_notification = '<div class="message custom wpcf-notif"><span class="wpcf-notif-congrats">'
422
+ . __('This groups visibility is also controlled by the Access plugin.',
423
  'wpcf') .'</span></div>';
424
+ }
425
  $form['supports-table-open'] = array(
426
  '#type' => 'markup',
427
  '#markup' => '<table class="widefat"><thead><tr><th>'
428
  . __('Where to display this group', 'wpcf')
429
  . '</th></tr></thead><tbody><tr><td>'
430
  . '<p>'
431
+ . __('Each usermeta group can display different fields for user roles.',
432
  'wpcf')
433
+ . $access_notification
434
  . '</p>',
435
  );
436
  /*
447
  '#type' => 'markup',
448
  '#markup' => '</td></tr></tbody></table><br />',
449
  );
450
+
451
+
452
+
453
+
454
+ /** Admin styles**/
455
+
456
+ $form['adminstyles-table-open'] = array(
457
  '#type' => 'markup',
458
  '#markup' => '<table class="widefat" id="wpcf-admin-styles-box"><thead><tr><th>'
459
  . __('Styling Editor', 'wpcf')
463
  'wpcf')
464
  . '</p>',
465
  );
466
+
467
+ $admin_styles_value = $preview_profile = $edit_profile = '';
468
+ if ( isset ($update['admin_styles']) ){
469
+ $admin_styles_value = $update['admin_styles'];
470
+ }
471
+ $temp = '';
472
+ if ($update){
473
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
474
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
475
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
476
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
477
+
478
+ $user_id = wpcf_usermeta_get_user();
479
+ $preview_profile = wpcf_usermeta_preview_profile( $user_id, $update, 1 );
480
+ $group = $update;
481
+ $group['fields'] = wpcf_admin_usermeta_process_fields( $user_id, $group['fields'], true, false );
482
+ $edit_profile = wpcf_admin_render_fields($group, $user_id, 1);
483
  add_action( 'admin_enqueue_scripts', 'wpcf_admin_fields_form_fix_styles', PHP_INT_MAX );
484
+ }
485
+ $temp[] = array(
486
+ '#type' => 'radio',
487
+ '#suffix' => '<br />',
488
+ '#value' => 'edit_mode',
489
+ '#title' => 'Edit mode',
490
  '#name' => 'wpcf[group][preview]','#default_value' => '',
491
+ '#before' => '<div class="wpcf-admin-css-preview-style-edit">',
492
  '#inline' => true,
493
+ '#attributes' => array('onclick' => 'changePreviewHtml(\'editmode\')','checked'=>'checked')
494
+ );
495
+
496
+ $temp[] = array(
497
+ '#type' => 'radio',
498
+ '#title' => 'Read Only',
499
  '#name' => 'wpcf[group][preview]','#default_value' => '',
500
+ '#after' => '</div>',
501
  '#inline' => true,
502
+ '#attributes' => array('onclick' => 'changePreviewHtml(\'readonly\')')
503
+ );
504
+
505
+ $temp[] = array(
506
  '#type' => 'textarea',
507
  '#name' => 'wpcf[group][admin_html_preview]',
508
  '#inline' => true,
509
+ '#value' => '',
510
+ '#id' => 'wpcf-form-groups-admin-html-preview',
511
+ '#before' => '<h3>Field group HTML</h3>'
512
  );
513
+
514
+ $temp[] = array(
515
  '#type' => 'textarea',
516
  '#name' => 'wpcf[group][admin_styles]',
517
  '#inline' => true,
518
+ '#value' => $admin_styles_value,
519
+ '#default_value' => '',
520
+ '#id' => 'wpcf-form-groups-css-fields-editor',
521
+ '#after' => '
522
+ <div class="wpcf-update-preview-btn"><input type="button" value="Update preview" onclick="wpcfPreviewHtml()" style="float:right;" class="button-secondary"></div>
523
+ <h3>Field group preview</h3>
524
+ <div id="wpcf-update-preview-div">Preview here</div>
525
+ <script type="text/javascript">
526
+ var wpcfReadOnly = ' . json_encode($preview_profile) . ';
527
+ var wpcfEditMode = ' . json_encode($edit_profile) . ';
528
+ var wpcfDefaultCss = ' . json_encode($admin_styles_value) . ';
529
+ </script>
530
+ ',
531
+ '#before' => '<h3>Your CSS</h3>'
532
  );
533
+
534
+
535
+
536
+
537
+ $admin_styles = _wpcf_filter_wrap( 'admin_styles',
538
  __('Admin styles for fields:', 'wpcf'), '', '', $temp, __( 'Open style editor', 'wpcf' ) );
539
+ $form['p_wrap_1_' . wpcf_unique_id(serialize($admin_styles))] = array(
540
  '#type' => 'markup',
541
  '#markup' => '<p class="wpcf-filter-wrap">',
542
  );
543
+ $form = $form + $admin_styles;
544
+ $form['adminstyles-table-close'] = array(
545
  '#type' => 'markup',
546
  '#markup' => '</td></tr></tbody></table><br />',
547
  );
548
+ /** End admin Styles **/
549
+
550
+
551
+
552
+
553
  // Group fields
554
 
555
  $form['fields_title'] = array(
643
  '#markup' => '</div>',
644
  );
645
 
646
+
647
+ wpcf_admin_add_js_settings( 'wpcf_filters_association_or',
648
  '\'' . __( 'This group will appear on %pt% edit pages where content belongs to taxonomy: %tx% or View Template is: %vt%',
649
  'wpcf' ) . '\'' );
650
  wpcf_admin_add_js_settings( 'wpcf_filters_association_and',
670
 
671
  /**
672
  * Dynamically adds existing field on AJAX call.
673
+ *
674
+ * @param type $form_data
675
  */
676
  function wpcf_usermeta_insert_existing_ajax() {
677
+ $field = wpcf_admin_fields_get_field( sanitize_text_field( $_GET['field'] ), false, true, false, 'wpcf-usermeta');
678
+
679
  if ( !empty( $field ) ) {
680
  echo wpcf_fields_get_field_form( $field['type'], $field );
681
  } else {
includes/usermeta-list.php CHANGED
@@ -6,74 +6,22 @@
6
  /**
7
  * Renders 'widefat' table.
8
  */
9
- function wpcf_admin_usermeta_list() {
10
-
11
- $post_type = 'wp-types-user-group';
12
- $groups = wpcf_admin_fields_get_groups('wp-types-user-group');
13
- if (empty($groups)) {
14
- echo '<p>'
15
- . __("User Fields, also known as user-meta, are additional fields that belong to user profiles.",'wpcf')
16
- . '</p>';
17
- }
18
-
19
- echo '<br /><a class="button-secondary" href="'
20
- . admin_url('admin.php?page=wpcf-edit-usermeta')
21
- . '">' . __('Add a user meta group', 'wpcf') . '</a><br /><br />';
22
- if (!empty($groups)) {
23
- $rows = array();
24
- $header = array(
25
- 'group_name' => __('Group name', 'wpcf'),
26
- 'group_description' => __('Description', 'wpcf'),
27
- 'group_active' => __('Active', 'wpcf'),
28
- 'group_post_types' => __('Available for', 'wpcf'),
29
- );
30
- foreach ($groups as $group) {
31
-
32
- // Set 'name' column
33
- $name = '';
34
- $name .= '<a href="'
35
- . admin_url('admin.php?page=wpcf-edit-usermeta&amp;group_id='
36
- . $group['id']) . '">' . $group['name'] . '</a>';
37
- $name .= '<br />';
38
- $name .= '<a href="'
39
- . admin_url('admin.php?page=wpcf-edit-usermeta&amp;group_id='
40
- . $group['id']) . '">' . __('Edit', 'wpcf') . '</a> | ';
41
-
42
- $name .= $group['is_active'] ? wpcf_admin_usermeta_get_ajax_deactivation_link($group['id']) .
43
- ' | ' : wpcf_admin_usermeta_get_ajax_activation_link($group['id']) . ' | ';
44
-
45
- $name .= '<a href="'
46
- . admin_url('admin-ajax.php?action=wpcf_ajax&amp;'
47
- . 'wpcf_action=delete_usermeta_group&amp;group_id='
48
- . $group['id'] . '&amp;wpcf_ajax_update=wpcf_list_ajax_response_'
49
- . $group['id']) . '&amp;_wpnonce=' . wp_create_nonce('delete_usermeta_group')
50
- . '&amp;wpcf_warning='
51
- . __('Are you sure?', 'wpcf') . '" class="wpcf-ajax-link" '
52
- . 'id="wpcf-list-delete-' . $group['id'] . '">'
53
- . __('Delete Permanently', 'wpcf') . '</a>';
54
-
55
- $name .= '<div id="wpcf_list_ajax_response_' . $group['id'] . '"></div>';
56
-
57
- $rows[$group['id']]['name'] = $name;
58
-
59
-
60
- $rows[$group['id']]['description'] = $group['description'];
61
- $rows[$group['id']]['active-' . $group['id']] = $group['is_active'] ? __('Yes', 'wpcf') : __('No', 'wpcf');
62
- $show_for = wpcf_admin_get_groups_showfor_by_group($group['id']);
63
- if (function_exists('wpcf_access_register_caps')){
64
- $show_for = __('This groups visibility is also controlled by the Access plugin.',
65
- 'wpcf');
66
- }
67
- else{
68
- $show_for = (count($show_for) == 0) ? __('Displayed for all users roles', 'wpcf') : ucwords(implode($show_for, ', '));
69
- }
70
- $rows[$group['id']]['group_post_types'] = $show_for;
71
-
72
- }
73
-
74
- // Render table
75
- wpcf_admin_widefat_table('wpcf_groups_list', $header, $rows);
76
- }
77
-
78
  do_action('wpcf_groups_list_table_after');
79
- }
6
  /**
7
  * Renders 'widefat' table.
8
  */
9
+ function wpcf_admin_usermeta_list()
10
+ {
11
+ include_once dirname(__FILE__).'/classes/class.wpcf.user.fields.list.table.php';
12
+ //Create an instance of our package class...
13
+ $listTable = new WPCF_User_Fields_List_Table();
14
+ //Fetch, prepare, sort, and filter our data...
15
+ $listTable->prepare_items();
16
+ ?>
17
+ <!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
18
+ <form id="usermeta-filter" method="post">
19
+ <!-- For plugins, we also need to ensure that the form posts back to our current page -->
20
+ <input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?>" />
21
+ <?php $listTable->search_box(__('Search user fields', 'wcpf'), 'search_id'); ?>
22
+ <!-- Now we can render the completed list table -->
23
+ <?php $listTable->display() ?>
24
+ </form>
25
+ <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  do_action('wpcf_groups_list_table_after');
27
+ }
includes/usermeta.php CHANGED
@@ -10,14 +10,14 @@ require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
10
  * @param type $group_id
11
  * @return type
12
  */
13
- function wpcf_admin_usermeta_get_ajax_activation_link($group_id) {
14
- return '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;'
15
- . 'wpcf_action=activate_user_group&amp;group_id='
16
- . $group_id . '&amp;wpcf_ajax_update=wpcf_list_ajax_response_'
17
- . $group_id) . '&amp;_wpnonce=' . wp_create_nonce('activate_user_group')
18
- . '" class="wpcf-ajax-link" id="wpcf-list-activate-'
19
- . $group_id . '">'
20
- . __('Activate', 'wpcf') . '</a>';
21
  }
22
 
23
  /**
@@ -26,12 +26,46 @@ function wpcf_admin_usermeta_get_ajax_activation_link($group_id) {
26
  * @return type
27
  */
28
  function wpcf_admin_usermeta_get_ajax_deactivation_link($group_id) {
29
- return '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;'
30
- . 'wpcf_action=deactivate_user_group&amp;group_id='
31
- . $group_id . '&amp;wpcf_ajax_update=wpcf_list_ajax_response_'
32
- . $group_id) . '&amp;_wpnonce=' . wp_create_nonce('deactivate_user_group')
33
- . '" class="wpcf-ajax-link" id="wpcf-list-activate-'
34
- . $group_id . '">'
35
- . __('Deactivate', 'wpcf') . '</a>';
36
  }
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  * @param type $group_id
11
  * @return type
12
  */
13
+ function wpcf_admin_usermeta_get_ajax_activation_link($group_id)
14
+ {
15
+ return sprintf(
16
+ '<a href="%s" class="wpcf-ajax-link" id="wpcf-list-activate-%d">%s</a>',
17
+ wpcf_admin_usermeta_get_ajax_link('activate', $group_id),
18
+ $group_id,
19
+ __('Activate', 'wpcf')
20
+ );
21
  }
22
 
23
  /**
26
  * @return type
27
  */
28
  function wpcf_admin_usermeta_get_ajax_deactivation_link($group_id) {
29
+ return sprintf(
30
+ '<a href="%s" class="wpcf-ajax-link" id="wpcf-list-activate-%d">%s</a>',
31
+ wpcf_admin_usermeta_get_ajax_link('deactivate', $group_id),
32
+ $group_id,
33
+ __('Deactivate', 'wpcf')
34
+ );
 
35
  }
36
 
37
+ /**
38
+ * Helper function to build url
39
+ *
40
+ * @param string $status status of action
41
+ * @param int $group_id group id
42
+ * @return string link for Activate/Deactivate action
43
+ */
44
+ function wpcf_admin_usermeta_get_ajax_link($status, $group_id)
45
+ {
46
+ /**
47
+ * sanitize status
48
+ */
49
+ if ( !preg_match('/^(de)?activate$/', $status ) ) {
50
+ return '#wrong-status';
51
+ }
52
+ /**
53
+ * sanitize group_id
54
+ */
55
+ if ( !is_numeric($group_id) ) {
56
+ return '#wrong-group_id';
57
+ }
58
+ /**
59
+ * build link
60
+ */
61
+ return add_query_arg(
62
+ array(
63
+ 'action' => 'wpcf_ajax',
64
+ 'wpcf_action' => $status.'_user_group',
65
+ 'group_id' => $group_id,
66
+ 'wpcf_ajax_update' => 'wpcf_list_ajax_response_' . $group_id,
67
+ '_wpnonce' => '' . wp_create_nonce($status.'_user_group'),
68
+ ),
69
+ admin_url('admin-ajax.php')
70
+ );
71
+ }
marketing/helpful-links.php CHANGED
@@ -1,5 +1,12 @@
1
- <br />
2
- <h3><?php _e('Need Help?', 'wpcf'); ?></h3>
 
 
 
 
 
 
 
3
 
4
  <ul style="margin-left:1em;">
5
  <li>
1
+ <?php
2
+ /**
3
+ * $HeadURL: https://www.onthegosystems.com/misc_svn/cck/trunk/marketing/helpful-links.php $
4
+ * $LastChangedDate: 2015-02-26 07:51:21 +0100 (Thu, 26 Feb 2015) $
5
+ * $LastChangedRevision: 31922 $
6
+ * $LastChangedBy: marcin $
7
+ *
8
+ */
9
+ ?><h3><?php _e('Need Help?', 'wpcf'); ?></h3>
10
 
11
  <ul style="margin-left:1em;">
12
  <li>
plus/installer/changelog.txt CHANGED
@@ -1,8 +1,15 @@
1
- = 1.5.1.1 =
2
- * Changed products urls from S3 to CF
3
 
4
- = 1.5.1 =
 
 
 
 
 
 
5
 
 
6
  * Fix for allowing embedded plugins to be updated
7
  * Logic for the migration from embedded plugins to full plugins
8
 
1
+ = 1.5.3 =
2
+ * Fixed bug in WP_Installer::custom_plugins_api_call (filter for plugins_api) causing conflicts with other filters for plugins_api
3
 
4
+ = 1.5.2 =
5
+ * More meaningful errors when plugin downloads fail
6
+ * WordPress 4.2 compatibility
7
+ * Performance improvements (will not load in places where it's not needed and not make unnecessary requests to the CDN)
8
+ * Support putting deps.xml config file in the theme folder (root)
9
+ * Included code for importing data for toolset plugins
10
+ * Use CloudFront urls for products list files
11
 
12
+ = 1.5.1 =
13
  * Fix for allowing embedded plugins to be updated
14
  * Logic for the migration from embedded plugins to full plugins
15
 
plus/installer/includes/deps-loader.class.php DELETED
@@ -1,558 +0,0 @@
1
- <?php
2
-
3
- class Installer_Deps_Loader{
4
-
5
- private $config = array();
6
- private $missing = array();
7
-
8
- function __construct(){
9
-
10
- //_disable_wp_redirects
11
- if(isset($_POST['action']) && $_POST['action'] == 'wp_installer_fix_deps'){
12
- add_filter('wp_redirect', '__return_false', 10000);
13
- }
14
-
15
- add_action('admin_init', array($this, 'init'), 30);
16
- add_filter('installer_deps_missing', array($this, 'get_missing_deps'));
17
- }
18
-
19
- public function init(){
20
- global $wp_installer_instances;
21
-
22
- $repositories = array();
23
-
24
- add_action('wp_ajax_wp_installer_fix_deps', array($this, 'run'));
25
-
26
- foreach($wp_installer_instances as $instance) {
27
-
28
- $config_file = dirname($instance['bootfile']) . '/deps.xml';
29
-
30
- if (file_exists($config_file) && is_readable($config_file)) {
31
-
32
- $config = $this->read_config($config_file);
33
- $config_arr_key = md5($config_file) . '|' . $config['name'];
34
-
35
- foreach ($config['repositories'] as $repository_id => $repository) {
36
-
37
- foreach ($repository['plugins'] as $plugin) {
38
-
39
- if(empty($plugin['version']) || $plugin['version'] == 'latest'){
40
- $plugin['version'] = WP_Installer()->get_plugin_repository_version($repository_id, $plugin['name']);
41
- }
42
-
43
-
44
- $plugin_full_name = $this->get_plugin_full_name($repository_id, $plugin['name'], $config);
45
- if (!$plugin_full_name) continue;
46
-
47
- $real_basename = $plugin['name'];
48
- if (isset($plugin['format'])) {
49
- $real_basename .= '-' . $plugin['format'];
50
- }
51
-
52
- $latest_version = WP_Installer()->get_plugin_repository_version($repository_id, $plugin['name']);
53
- $installed_version = WP_Installer()->get_plugin_installed_version($plugin_full_name, $plugin['name']);
54
-
55
- if ($this->is_plugin_installed($plugin['name']) && !$this->is_plugin_installed($real_basename)) { //FULL PLUGIN INSTALLED?
56
- if (!$this->is_plugin_active($plugin['name'])) {
57
- $this->missing[$config_arr_key][] = array(
58
- 'basename' => $plugin['name'],
59
- 'name' => $plugin_full_name,
60
- 'url' => $this->get_plugin_download_url($repository_id, $plugin['name'], $config),
61
- 'repository_id' => $repository_id,
62
- 'status' => __('inactive', 'installer')
63
- );
64
- } else {
65
- continue;
66
- }
67
- } elseif (!$this->is_plugin_installed($real_basename)) {
68
- $this->missing[$config_arr_key][] = array(
69
- 'basename' => $plugin['name'],
70
- 'name' => $plugin_full_name,
71
- 'url' => $this->get_plugin_download_url($repository_id, $plugin['name'], $config),
72
- 'repository_id' => $repository_id,
73
- 'status' => __('not installed', 'installer')
74
- );
75
- } elseif (version_compare($latest_version, $installed_version)) {
76
-
77
- if(!$this->is_plugin_active($real_basename) && !$this->is_plugin_active($plugin['name'])){
78
- $status = sprintf(__('inactive and out of date: installed - %s, available - %s', 'installer'), $installed_version, $latest_version);
79
- }else{
80
- $status = sprintf(__('out of date: installed - %s, available - %s', 'installer'), $installed_version, $latest_version);
81
- }
82
-
83
- $this->missing[$config_arr_key][] = array(
84
- 'basename' => $plugin['name'],
85
- 'name' => $plugin_full_name,
86
- 'url' => $this->get_plugin_download_url($repository_id, $plugin['name'], $config),
87
- 'repository_id' => $repository_id,
88
- 'status' => $status
89
- );
90
- } elseif (!$this->is_plugin_active($real_basename) && !$this->is_plugin_active($plugin['name'])) {
91
- $this->missing[$config_arr_key][] = array(
92
- 'basename' => $plugin['name'],
93
- 'name' => $plugin_full_name,
94
- 'url' => $this->get_plugin_download_url($repository_id, $plugin['name'], $config),
95
- 'repository_id' => $repository_id,
96
- 'status' => __('inactive', 'installer')
97
- );
98
- }
99
-
100
- //set affiliate info if any
101
- if (isset($repository['affiliate_id']) && isset($repository['affiliate_key'])) {
102
- WP_Installer()->set_config('affiliate_id:' . $repository_id, $repository['affiliate_id']);
103
- WP_Installer()->set_config('affiliate_key:' . $repository_id, $repository['affiliate_key']);
104
- }
105
-
106
- }
107
-
108
- }
109
-
110
- $this->config[$config_arr_key] = $config;
111
-
112
- }
113
-
114
- }
115
-
116
- if($this->missing){
117
- add_action('admin_notices', array($this, 'setup_notice'));
118
- add_action('admin_footer', array($this, 'js_footer'));
119
-
120
- }
121
-
122
- }
123
-
124
- public function read_config($config_file){
125
-
126
- $repositories = array();
127
-
128
- $repositories_xml = simplexml_load_file($config_file);
129
-
130
- $array = json_decode(json_encode($repositories_xml), true);
131
-
132
- $repositories_arr = isset($array['repositories']['repository'][0]) ? $array['repositories']['repository'] : array($array['repositories']['repository']);
133
-
134
- foreach($repositories_arr as $r){
135
- $r['plugins'] = isset($r['plugins']['plugin'][0]) ? $r['plugins']['plugin'] : array($r['plugins']['plugin']);
136
-
137
- $repositories[$r['id']] = $r;
138
- }
139
-
140
- $config['repositories'] = $repositories;
141
- $config['name'] = $array['name'];
142
-
143
- return $config;
144
-
145
- }
146
-
147
- public function get_missing_deps(){
148
- return $this->missing;
149
- }
150
-
151
- public function setup_notice(){
152
- ?>
153
- <div class="updated" id="wp_installer_fix_deps_notice" >
154
- <?php foreach($this->missing as $key => $missing): ?>
155
- <?php list($null, $name) = explode('|', $key); ?>
156
- <p><strong><?php printf(__('%s needs these plugins to work:', 'installer'), $name); ?></strong></p>
157
- <ul>
158
- <?php foreach($missing as $p): ?>
159
- <li>
160
- <?php echo $p['name'] ?> (<?php echo $p['status'] ?>)
161
- <?php if(!WP_Installer()->is_uploading_allowed()): ?>
162
- | <a href="<?php echo $p['url'] ?>"><?php _e('Download', 'installer') ?></a>
163
- <?php endif; ?>
164
- </li>
165
- <?php endforeach;?>
166
- </ul>
167
-
168
- <?php endforeach; ?>
169
-
170
- <?php if(!WP_Installer()->is_uploading_allowed()): ?>
171
- <p class="installer-warn-box">
172
- <?php _e('Automatic downloading is not possible because WordPress cannot write into the plugins folder. Please use the download links above to get the zip files, unpack and upload to the plugins folder. If folders with the same name exist, please replace with the new ones.', 'installer') ?>
173
- </p>
174
- <?php endif; ?>
175
-
176
- <p class="submit">
177
- <input id="wp_installer_fix_deps" type="button" class="button-primary" value="<?php esc_attr_e('Install and activate', 'installer') ?>" <?php
178
- disabled(!WP_Installer()->is_uploading_allowed()); ?> />
179
- <span class="spinner"></span>&nbsp;<span id="wp_installer_fix_deps_status"></span>
180
- </p>
181
-
182
- </div>
183
-
184
- <?php
185
-
186
- }
187
-
188
- public function is_plugin_installed($basename, $version = false, $compare = '='){
189
-
190
- $is = false;
191
- $plugins = get_plugins();
192
- foreach($plugins as $plugin_id => $plugin_data){
193
-
194
- if(dirname($plugin_id) == $basename){
195
- if($version !== false ){
196
- if(version_compare($plugin_data['Version'], $version, $compare)){
197
- $is = true;
198
- }
199
- }else{
200
- $is = true;
201
-
202
- }
203
- break;
204
-
205
- }
206
- }
207
-
208
- return $is;
209
-
210
- }
211
-
212
- public function is_plugin_active($basename){
213
-
214
- $is = false;
215
- $plugins = get_plugins();
216
- foreach($plugins as $plugin_id => $plugin_data){
217
- if(dirname($plugin_id) == $basename && is_plugin_active($plugin_id)){
218
- $is = true;
219
- break;
220
-
221
- }
222
- }
223
-
224
- return $is;
225
-
226
- }
227
-
228
- public function get_plugin_id($basename){
229
-
230
- $plugin_wp_id = false;
231
-
232
- $plugins = get_plugins();
233
- foreach($plugins as $plugin_id => $plugin_data){
234
- if(dirname($plugin_id) == $basename){
235
- $plugin_wp_id = $plugin_id;
236
- break;
237
-
238
- }
239
- }
240
-
241
- return $plugin_wp_id;
242
-
243
- }
244
-
245
- function plugins_upgrade_check($update_plugins){
246
- global $wp_installer_instances;
247
-
248
- foreach($wp_installer_instances as $instance) {
249
-
250
- $config_file = dirname($instance['bootfile']) . '/deps.xml';
251
-
252
- if (file_exists($config_file) && is_readable($config_file)) {
253
-
254
- $config = $this->read_config($config_file);
255
- $config_arr_key = md5($config_file) . '|' . $config['name'];
256
-
257
- foreach($config['repositories'] as $repository_id => $repository){
258
-
259
- $downloads = $this->get_repository_downloads($repository_id, $config);
260
-
261
- foreach($repository['plugins'] as $plugin){
262
-
263
- if(!isset($downloads[$plugin['name']])) continue;
264
-
265
- $real_basename = $plugin['name'];
266
- if(isset($plugin['format']) && $plugin['format'] != 'standard'){
267
- $real_basename .= '-' . $plugin['format'];
268
- }
269
- $plugin_wp_id = $this->get_plugin_id($real_basename);
270
- if($plugin_wp_id){
271
-
272
- $latest_version = WP_Installer()->get_plugin_repository_version($repository_id, $plugin['name']);
273
-
274
- $response = new stdClass();
275
- $response->id = 0;
276
- $response->slug = $real_basename;
277
- $response->plugin = $plugin_wp_id;
278
- $response->new_version = $latest_version;
279
- $response->upgrade_notice = '';
280
- $response->url = $this->get_plugin_download_url($repository_id, $plugin['name'], $config);
281
- $response->package = $this->get_plugin_download_url($repository_id, $plugin['name'], $config);
282
- $update_plugins->checked[$plugin_wp_id] = $latest_version;
283
- $update_plugins->response[$plugin_wp_id] = $response;
284
-
285
-
286
- }
287
-
288
- }
289
-
290
- }
291
-
292
- }
293
- }
294
-
295
- return $update_plugins;
296
- }
297
-
298
- public function run(){
299
- global $wp_installer_instances;
300
-
301
- $return['stop'] = 0;
302
-
303
- foreach($wp_installer_instances as $instance) {
304
-
305
- $config_file = dirname($instance['bootfile']) . '/deps.xml';
306
-
307
- if (file_exists($config_file) && is_readable($config_file)) {
308
-
309
- $config = $this->read_config($config_file);
310
- $config_arr_key = md5($config_file) . '|' . $config['name'];
311
-
312
- foreach($config['repositories'] as $repository_id => $repository){
313
-
314
- $downloads = $this->get_repository_downloads($repository_id, $config);
315
-
316
- foreach($repository['plugins'] as $plugin){
317
-
318
- if(!isset($downloads[$plugin['name']])) continue;
319
-
320
- $plugin_full_name = $this->get_plugin_full_name($repository_id, $plugin['name'], $config);
321
-
322
- $latest_version = WP_Installer()->get_plugin_repository_version($repository_id, $plugin['name']);
323
- $installed_version = WP_Installer()->get_plugin_installed_version($plugin_full_name, $plugin['name']);
324
-
325
- $real_basename = $plugin['name'];
326
- if(isset($plugin['format']) && $plugin['format'] != 'standard'){
327
- $real_basename .= '-' . $plugin['format'];
328
- }
329
-
330
- $plugin_downloaded_once = false;
331
- if(isset($_POST['plugins_downloaded'])){
332
- $return['plugins_downloaded'] = $_POST['plugins_downloaded'];
333
- if(in_array($real_basename, $_POST['plugins_downloaded'])){
334
- $plugin_downloaded_once = true;
335
- }
336
- }else{
337
- $return['plugins_downloaded'] = array();
338
- }
339
-
340
- if(!$plugin_downloaded_once && $this->is_plugin_installed($plugin['name']) && !$this->is_plugin_active($plugin['name']) && !$this->is_plugin_active($real_basename)){ // FULL PLUGIN PRESENT BUT INACTIVE
341
- if($plugin_wp_id = $this->get_plugin_id($plugin['name'])){
342
- //prevent redirects
343
- add_filter('wp_redirect', '__return_false', 10000);
344
- $ret = activate_plugin($plugin_wp_id);
345
- $return['status_message'] = sprintf(__('Activated %s', 'installer'), $downloads[$plugin['name']]['name']);
346
- }else{
347
-
348
- $return['status_message'] = sprintf(__('Plugin not found: %s', 'installer'), $downloads[$plugin['name']]['name']);
349
- $return['stop'] = 1;
350
- }
351
- break; // one operation at the time
352
- }elseif(!$plugin_downloaded_once && !$this->is_plugin_installed($real_basename) && !$this->is_plugin_installed($plugin['name'])){
353
- $ret = WP_Installer()->download_plugin($downloads[$plugin['name']]['basename'],
354
- $downloads[$plugin['name']]['url']);
355
- if($ret){
356
- $return['status_message'] = sprintf(__('Installed %s', 'installer'), $downloads[$plugin['name']]['name']);
357
- }else{
358
- $return['status_message'] = sprintf(__('Failed to download %s', 'installer'), $downloads[$plugin['name']]['name']);
359
- $return['stop'] = 1;
360
- }
361
- $return['plugins_downloaded'][] = $real_basename;
362
- break; // one operation at the time
363
-
364
- } elseif (version_compare($latest_version, $installed_version)) {
365
-
366
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
367
- require_once WP_Installer()->plugin_path() . '/includes/installer-upgrader-skins.php';
368
-
369
- $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
370
- $upgrader = new Plugin_Upgrader($upgrader_skins);
371
-
372
- remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
373
- add_filter( 'site_transient_update_plugins', array( $this, 'plugins_upgrade_check') );
374
-
375
- $plugin_wp_id = $this->get_plugin_id($real_basename);
376
- $ret = $upgrader->upgrade($plugin_wp_id);
377
-
378
- if($ret){
379
- activate_plugin($plugin_wp_id);
380
- $return['status_message'] = sprintf(__('Upgraded %s', 'installer'), $downloads[$plugin['name']]['name']);
381
- }else{
382
- $return['status_message'] = sprintf(__('Failed to upgrade %s', 'installer'), $downloads[$plugin['name']]['name']);
383
- $return['stop'] = 1;
384
- }
385
-
386
- $return['plugins_downloaded'][] = $real_basename;
387
-
388
- break; // one operation at the time
389
-
390
- }elseif(!$this->is_plugin_active($real_basename) && !$this->is_plugin_active($plugin['name'])){
391
-
392
- if($plugin_wp_id = $this->get_plugin_id($real_basename)){
393
- //prevent redirects
394
- add_filter('wp_redirect', '__return_false', 10000);
395
-
396
- $ret = activate_plugin($plugin_wp_id);
397
- $return['status_message'] = sprintf(__('Activated %s', 'installer'), $downloads[$plugin['name']]['name']);
398
- }else{
399
-
400
- $return['status_message'] = sprintf(__('Plugin not found: %s', 'installer'), $downloads[$plugin['name']]['name']);
401
- $return['stop'] = 1;
402
- }
403
- break; // one operation at the time
404
-
405
- }
406
-
407
- }
408
-
409
- }
410
-
411
- }
412
- }
413
-
414
- if(empty($return['status_message'])){
415
- $return['status_message'] = __('Operation complete!', 'installer');
416
- $return['status_message'] .= '&nbsp;<a href="#" id="wp_installer_fix_deps_dismiss">'. __('Dismiss', 'installer') . '</a>';
417
- $return['stop'] = 1;
418
- }
419
-
420
- echo json_encode($return);
421
- exit;
422
-
423
- }
424
-
425
- public function get_repository_downloads($repository_id, $config){
426
-
427
- if(!isset($this->repository_downloads[md5(serialize($config))][$repository_id])) {
428
-
429
- $downloads = array();
430
- $installer_settings = WP_Installer()->get_settings();
431
-
432
- if (isset($installer_settings['repositories'][$repository_id])) {
433
-
434
- foreach ($installer_settings['repositories'][$repository_id]['data']['packages'] as $package) {
435
-
436
- foreach ($package['products'] as $product) {
437
-
438
- $available_in_installer = WP_Installer()->is_product_available_for_download($product['name'], $repository_id);
439
-
440
- foreach ($product['downloads'] as $download) {
441
-
442
- if (!isset($downloads[$download['basename']]) || (empty($d['_installer_download_url']) && $available_in_installer)) {
443
-
444
- $d['name'] = $download['name'];
445
- $d['basename'] = $download['basename'];
446
- $d['version'] = $download['version'];
447
- $d['date'] = $download['date'];
448
- $d['_installer_url'] = $available_in_installer;
449
-
450
- /*
451
- $format = 'standard';
452
- foreach($config['repositories'][$repository_id]['plugins'] as $p){
453
- if($p['name'] == $d['basename']){
454
- if(isset($p['format'])){
455
- $format = $p['format'];
456
- }
457
- break;
458
- }
459
- }
460
- */
461
-
462
- //case of valid subscription
463
- if($available_in_installer){
464
- $d['url'] = WP_Installer()->append_site_key_to_download_url($download['url'], WP_Installer()->get_site_key($repository_id), $repository_id);
465
-
466
- }else{
467
-
468
- $d['url'] = $download['url'] . '&theme_key=' . $config['repositories'][$repository_id]['key']
469
- . '&theme_name=' . urlencode($config['name']);
470
- //. '&format=' . $format;
471
- }
472
-
473
-
474
- $downloads[$d['basename']] = $d;
475
- }
476
-
477
- }
478
-
479
- }
480
-
481
- }
482
-
483
- }
484
-
485
- $this->repository_downloads[md5(serialize($config))][$repository_id] = $downloads;
486
-
487
- }
488
-
489
- return $this->repository_downloads[md5(serialize($config))][$repository_id];
490
-
491
- }
492
-
493
- public function get_plugin_download_url($repository_id, $basename, $config){
494
-
495
- $downloads = $this->get_repository_downloads($repository_id, $config);
496
-
497
- return isset($downloads[$basename]) ? $downloads[$basename]['url'] : false;
498
-
499
- }
500
-
501
- public function get_plugin_full_name($repository_id, $basename, $config){
502
-
503
- $downloads = $this->get_repository_downloads($repository_id, $config);
504
-
505
- return isset($downloads[$basename]) ? $downloads[$basename]['name'] : false;
506
-
507
- }
508
-
509
- public function js_footer(){
510
- ?>
511
- <script type='text/javascript'>
512
- /* <![CDATA[ */
513
-
514
- jQuery('#wp_installer_fix_deps').click(function(){
515
-
516
- jQuery('#wp_installer_fix_deps').attr('disabled', 'disabled');
517
- jQuery('#wp_installer_fix_deps_notice').find('.spinner').addClass('spinner-inline').show();
518
-
519
- var plugins_downloaded = [];
520
- wp_installer_deps_load_run(plugins_downloaded);
521
- return false;
522
- })
523
-
524
- function wp_installer_deps_load_run(plugins_downloaded){
525
-
526
- jQuery.ajax({
527
- url: ajaxurl,
528
- type: 'post',
529
- dataType: 'json',
530
- data: {action: 'wp_installer_fix_deps', plugins_downloaded: plugins_downloaded},
531
- success: function(ret){
532
-
533
- plugins_downloaded = ret.plugins_downloaded;
534
- jQuery('#wp_installer_fix_deps_status').html(ret.status_message);
535
-
536
- if(ret.stop){
537
- jQuery('#wp_installer_fix_deps_notice').find('.spinner').removeClass('spinner-inline').hide();
538
-
539
- }else{
540
-
541
- wp_installer_deps_load_run(plugins_downloaded);
542
- }
543
-
544
- }
545
- })
546
- }
547
-
548
- jQuery('#wp_installer_fix_deps_status').on('click', '#wp_installer_fix_deps_dismiss', function(){
549
- jQuery('#wp_installer_fix_deps_notice').fadeOut();
550
- return false;
551
- })
552
-
553
- /* ]]> */
554
- </script>
555
- <?php
556
- }
557
-
558
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
plus/installer/includes/installer.class.php CHANGED
@@ -23,35 +23,53 @@ final class WP_Installer{
23
  }
24
 
25
  public function __construct(){
26
-
27
- $this->_gz_on = function_exists('gzuncompress') && function_exists('gzcompress');
28
 
 
 
 
29
  $this->settings = $this->get_settings();
30
 
31
- // register repositories
32
- $this->load_repositories_list();
33
-
34
- // default config
35
- $this->config['plugins_install_tab'] = false;
36
-
37
- add_action('init', array($this, 'init'));
38
 
39
- add_action('admin_init', array($this, 'load_deps_loader'), 0);
40
 
41
  add_action('admin_menu', array($this, 'menu_setup'));
42
  add_action('network_admin_menu', array($this, 'menu_setup'));
43
-
44
- add_filter('wp_installer_buy_url', array($this, 'append_parameters_to_buy_url'));
45
-
46
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'plugins_upgrade_check') );
47
 
48
  if(defined('DOING_AJAX') && isset($_POST['action']) && $_POST['action'] == 'installer_download_plugin'){
49
  add_filter( 'site_transient_update_plugins', array( $this, 'plugins_upgrade_check') );
50
  }
51
- add_filter( 'plugins_api', array( $this, 'custom_plugins_api_call'), 10, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
- add_action('admin_notices', array($this, 'show_site_key_nags'));
54
 
 
 
 
55
  }
56
 
57
  public function set_config($key, $value){
@@ -67,27 +85,22 @@ final class WP_Installer{
67
  $this->_pre_1_0_clean_up();
68
  }
69
 
70
- if(empty($this->settings['last_repositories_update']) || time() - $this->settings['last_repositories_update'] > 86400){
71
- $this->refresh_repositories_data();
72
- }
73
-
74
- // refresh repositories data on WP update schedule
75
- // add_action('wp_maybe_auto_update', array($this, 'refresh_repositories_data'));
76
-
77
- if(is_admin()){
78
- wp_enqueue_script('installer-admin', $this->res_url() . '/res/js/admin.js', array('jquery'), $this->version());
79
- wp_enqueue_style('installer-admin', $this->res_url() . '/res/css/admin.css', array(), $this->version());
80
- }
81
 
82
- if(is_admin() && $pagenow == 'plugins.php'){
83
  add_action('admin_notices', array($this, 'setup_plugins_page_notices'));
84
  add_action('admin_notices', array($this, 'setup_plugins_renew_warnings'), 10);
85
  add_action('admin_notices', array($this, 'queue_plugins_renew_warnings'), 20);
86
 
87
  add_action('admin_init', array($this, 'setup_plugins_action_links'));
88
-
89
  }
90
-
 
 
 
 
91
  if(defined('DOING_AJAX')){
92
  add_action('wp_ajax_save_site_key', array($this, 'save_site_key'));
93
  add_action('wp_ajax_remove_site_key', array($this, 'remove_site_key'));
@@ -97,18 +110,31 @@ final class WP_Installer{
97
  add_action('wp_ajax_installer_activate_plugin', array($this, 'activate_plugin'));
98
 
99
  add_action('wp_ajax_installer_dismiss_nag', array($this, 'dismiss_nag'));
100
-
101
-
102
  }
103
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
-
106
- }
107
 
108
- public function load_deps_loader(){
109
 
110
- new Installer_Deps_Loader();
111
 
 
 
 
 
 
 
 
112
  }
113
 
114
  public function menu_setup(){
@@ -242,10 +268,22 @@ final class WP_Installer{
242
  }
243
 
244
  public function plugin_url() {
245
- return untrailingslashit( plugins_url( '/', dirname(__FILE__) ) );
 
 
 
 
 
 
246
  }
247
-
248
- public function res_url(){
 
 
 
 
 
 
249
  if(isset($this->config['in_theme_folder']) && !empty($this->config['in_theme_folder'])){
250
  $url = untrailingslashit(get_template_directory_uri() . '/' . $this->config['in_theme_folder']);
251
  }else{
@@ -304,13 +342,6 @@ final class WP_Installer{
304
  }
305
  }
306
 
307
- /*
308
- echo '<pre>';
309
- print_r($settings);
310
- echo '</pre>';
311
- exit;
312
- */
313
-
314
  return $settings;
315
  }
316
 
@@ -380,44 +411,40 @@ final class WP_Installer{
380
  public function load_repositories_list(){
381
  global $wp_installer_instances;
382
 
 
383
 
384
- foreach($wp_installer_instances as $instance){
385
-
386
- if(file_exists(dirname($instance['bootfile']) . '/repositories.xml')){
387
  $config_file = dirname($instance['bootfile']) . '/repositories.xml';
388
 
389
- if(file_exists(dirname($instance['bootfile']) . '/repositories.sandbox.xml')){
390
  $config_file = dirname($instance['bootfile']) . '/repositories.sandbox.xml';
391
  }
392
 
393
  $repos = simplexml_load_file($config_file);
394
 
395
- foreach($repos as $repo){
396
  $id = strval($repo->id);
397
 
398
- $data['api-url'] = strval($repo->apiurl);
399
- $data['products'] = strval($repo->products);
400
 
401
  // excludes rule;
402
- if(isset($this->config['repositories_exclude']) && in_array($id, $this->config['repositories_exclude'])){
403
  continue;
404
  }
405
 
406
  // includes rule;
407
- if(isset($this->config['repositories_include']) && !in_array($id, $this->config['repositories_include'])){
408
  continue;
409
  }
410
 
411
  $this->repositories[$id] = $data;
412
 
413
-
414
  }
415
 
416
  }
417
-
418
  }
419
 
420
-
421
  }
422
 
423
  public function filter_repositories_list(){
@@ -439,9 +466,18 @@ final class WP_Installer{
439
 
440
 
441
  }
442
-
 
 
 
 
 
 
 
 
 
443
  public function refresh_repositories_data(){
444
-
445
  foreach($this->repositories as $id => $data){
446
 
447
  $response = wp_remote_get($data['products']);
@@ -490,7 +526,7 @@ final class WP_Installer{
490
  $this->settings['last_repositories_update']= time();
491
 
492
  $this->save_settings();
493
-
494
  }
495
 
496
  public function show_products($args = array()){
@@ -709,7 +745,6 @@ final class WP_Installer{
709
  }elseif($subscription_data){
710
  $this->settings['repositories'][$repository_id]['subscription'] = array('key' => $site_key, 'data' => $subscription_data);
711
  $this->save_settings();
712
-
713
  }else{
714
  $error = __('Invalid site key for the current site.', 'installer');
715
  }
@@ -751,7 +786,28 @@ final class WP_Installer{
751
  }
752
  exit;
753
  }
754
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
755
  public function update_site_key(){
756
 
757
  $error = '';
@@ -810,7 +866,7 @@ final class WP_Installer{
810
  'site_url' => $this->get_installer_site_url($repository_id),
811
  );
812
  $args['timeout'] = 45;
813
-
814
  $response = wp_remote_post($this->repositories[$repository_id]['api-url'], $args);
815
 
816
  $this->api_debug_log("POST {$this->repositories[$repository_id]['api-url']}");
@@ -834,7 +890,7 @@ final class WP_Installer{
834
  $this->api_debug_log($response);
835
  $subscription_data = $response;
836
  }
837
-
838
  return $subscription_data;
839
 
840
  }
@@ -1112,8 +1168,8 @@ final class WP_Installer{
1112
  }
1113
 
1114
  if(!empty($package['sub-packages'])){
1115
- foreach($package['sub-packages'] as $package){
1116
- foreach($package['products'] as $product){
1117
  if($product['name'] == $product_name && ($subscription_type == $product['subscription_type'] || $has_top_package)){
1118
  return $available = true;
1119
  }
@@ -1236,7 +1292,7 @@ final class WP_Installer{
1236
  foreach($package['products'] as $product) {
1237
 
1238
  foreach($product['downloads'] as $download){
1239
-
1240
  if($download['basename'] == $plugin_basename){
1241
  $version = $download['version'];
1242
  break (3);
@@ -1294,7 +1350,7 @@ final class WP_Installer{
1294
  //validate subscription
1295
  $site_key = $this->get_repository_site_key($data['repository_id']);
1296
  $subscription_data = $this->fetch_subscription_data($data['repository_id'], $site_key);
1297
-
1298
  if($subscription_data && !is_wp_error($subscription_data) && $this->repository_has_valid_subscription($data['repository_id'])){
1299
 
1300
  if($data['nonce'] == wp_create_nonce('install_plugin_' . $data['url'])){
@@ -1455,7 +1511,7 @@ final class WP_Installer{
1455
 
1456
  }
1457
 
1458
- public function custom_plugins_api_call($false = false, $action, $args){
1459
 
1460
  if($action == 'plugin_information'){
1461
 
@@ -1498,14 +1554,12 @@ final class WP_Installer{
1498
 
1499
  }
1500
 
1501
- return false;
1502
 
1503
  }
1504
 
1505
  public function plugins_upgrade_check($update_plugins){
1506
-
1507
- $this->refresh_repositories_data();
1508
-
1509
  if(!empty($this->settings['repositories'])){
1510
  $plugins = get_plugins();
1511
 
@@ -1630,9 +1684,7 @@ final class WP_Installer{
1630
 
1631
  public function localize_strings(){
1632
  global $sitepress;
1633
-
1634
-
1635
-
1636
  if(!empty($this->settings['repositories'])){
1637
  foreach($this->settings['repositories'] as $repository_id => $repository){
1638
  //set name as call2action when don't have any
@@ -1776,8 +1828,7 @@ final class WP_Installer{
1776
  foreach($repository['data']['packages'] as $package_id => $package){
1777
 
1778
  foreach($package['products'] as $product_id => $product){
1779
-
1780
- $fprice = false;
1781
  if($match['dtp'] == '%'){
1782
  $fprice = round( $product['price'] * (1 - $match['amt']/100), 2 );
1783
  $fprice = $fprice != round($fprice) ? sprintf('%.2f', $fprice) : round($fprice, 0);
@@ -1856,7 +1907,7 @@ final class WP_Installer{
1856
  }
1857
 
1858
  // order parents
1859
- usort($ordered_packages, create_function('$a, $b', 'return $a[\'order\'] > $b[\'order\'];'));
1860
  //order sub-packages
1861
  foreach($ordered_packages as $package_id => $package){
1862
  if(!empty($package['sub-packages'])) {
@@ -1873,6 +1924,10 @@ final class WP_Installer{
1873
 
1874
  }
1875
 
 
 
 
 
1876
  public function filter_downloads_by_icl(){
1877
  if(function_exists('wpml_site_uses_icl') && wpml_site_uses_icl()){
1878
 
@@ -1920,4 +1975,169 @@ final class WP_Installer{
1920
 
1921
  return false;
1922
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1923
  }
23
  }
24
 
25
  public function __construct(){
 
 
26
 
27
+ if(!is_admin() || !is_user_logged_in()) return; //Only for admin
28
+
29
+ $this->_gz_on = function_exists('gzuncompress') && function_exists('gzcompress');
30
  $this->settings = $this->get_settings();
31
 
32
+ add_action('admin_notices', array($this, 'show_site_key_nags'));
 
 
 
 
 
 
33
 
34
+ add_action('admin_init', array($this, 'load_embedded_plugins'), 0);
35
 
36
  add_action('admin_menu', array($this, 'menu_setup'));
37
  add_action('network_admin_menu', array($this, 'menu_setup'));
 
 
 
 
38
 
39
  if(defined('DOING_AJAX') && isset($_POST['action']) && $_POST['action'] == 'installer_download_plugin'){
40
  add_filter( 'site_transient_update_plugins', array( $this, 'plugins_upgrade_check') );
41
  }
42
+ add_filter('plugins_api', array( $this, 'custom_plugins_api_call'), 10, 3);
43
+ add_filter('pre_set_site_transient_update_plugins', array( $this, 'plugins_upgrade_check'));
44
+
45
+ // register repositories
46
+ $this->load_repositories_list();
47
+
48
+ if(empty($this->settings['last_repositories_update']) || time() - $this->settings['last_repositories_update'] > 86400){
49
+ $this->refresh_repositories_data();
50
+ }
51
+
52
+ /* Original setup for plugins updates check
53
+ add_action('wp_maybe_auto_update', array($this, 'refresh_repositories_data'));
54
+ if(isset($_GET['force-check']) && $_GET['force-check']){
55
+ add_action('core_upgrade_preamble', array($this, 'refresh_repositories_data'));
56
+ }
57
+ add_action('wp_update_plugins', array($this, 'refresh_repositories_data'));
58
+ */
59
+
60
+ // Hook to wp_update_plugins before the WP API request
61
+ // Using this in place of a missing hook in wp_update_plugins
62
+ // This is being triggered every time WP checks for plugin updates
63
+ add_filter('plugins_update_check_locales', array($this, 'update_plugins_information'));
64
+
65
+ // default config
66
+ $this->config['plugins_install_tab'] = false;
67
 
68
+ add_action('init', array($this, 'init'));
69
 
70
+ //add_filter('wp_installer_buy_url', array($this, 'append_parameters_to_buy_url'));
71
+
72
+
73
  }
74
 
75
  public function set_config($key, $value){
85
  $this->_pre_1_0_clean_up();
86
  }
87
 
88
+ wp_enqueue_script('installer-admin', $this->res_url() . '/res/js/admin.js', array('jquery'), $this->version());
89
+ wp_enqueue_style('installer-admin', $this->res_url() . '/res/css/admin.css', array(), $this->version());
 
 
 
 
 
 
 
 
 
90
 
91
+ if($pagenow == 'plugins.php'){
92
  add_action('admin_notices', array($this, 'setup_plugins_page_notices'));
93
  add_action('admin_notices', array($this, 'setup_plugins_renew_warnings'), 10);
94
  add_action('admin_notices', array($this, 'queue_plugins_renew_warnings'), 20);
95
 
96
  add_action('admin_init', array($this, 'setup_plugins_action_links'));
97
+
98
  }
99
+
100
+ if($this->is_repositories_page()){
101
+ add_action('admin_init', array($this, 'validate_repository_subscription'));
102
+ }
103
+
104
  if(defined('DOING_AJAX')){
105
  add_action('wp_ajax_save_site_key', array($this, 'save_site_key'));
106
  add_action('wp_ajax_remove_site_key', array($this, 'remove_site_key'));
110
  add_action('wp_ajax_installer_activate_plugin', array($this, 'activate_plugin'));
111
 
112
  add_action('wp_ajax_installer_dismiss_nag', array($this, 'dismiss_nag'));
 
 
113
  }
114
 
115
+ if($pagenow == 'update.php'){
116
+ if(isset($_GET['action']) && $_GET['action'] == 'update-selected'){
117
+ add_action('admin_head', array($this, 'plugin_upgrade_custom_errors')); //iframe/bulk
118
+ }else{
119
+ add_action('all_admin_notices', array($this, 'plugin_upgrade_custom_errors')); //regular/singular
120
+ }
121
+ }
122
+
123
+ // WP 4.2
124
+ if(defined('DOING_AJAX')){
125
+ add_action('wp_ajax_update-plugin', array($this, 'plugin_upgrade_custom_errors'), 0); // high priority, before WP
126
+ }
127
 
 
 
128
 
 
129
 
 
130
 
131
+ }
132
+
133
+ public function load_embedded_plugins(){
134
+ if(file_exists($this->plugin_path() . '/embedded-plugins' )) {
135
+ include_once $this->plugin_path() . '/embedded-plugins/embedded-plugins.class.php';
136
+ $this->installer_embedded_plugins = new Installer_Embedded_Plugins();
137
+ }
138
  }
139
 
140
  public function menu_setup(){
268
  }
269
 
270
  public function plugin_url() {
271
+ if(isset($this->config['in_theme_folder']) && !empty($this->config['in_theme_folder'])){
272
+ $url = untrailingslashit(get_template_directory_uri() . '/' . $this->config['in_theme_folder']);
273
+ }else{
274
+ $url = untrailingslashit( plugins_url( '/', dirname(__FILE__) ) );
275
+ }
276
+
277
+ return $url;
278
  }
279
+
280
+ public function is_repositories_page(){
281
+ global $pagenow;
282
+
283
+ return $pagenow == 'plugin-install.php' && isset($_GET['tab']) && $_GET['tab'] == 'commercial';
284
+ }
285
+
286
+ public function res_url(){
287
  if(isset($this->config['in_theme_folder']) && !empty($this->config['in_theme_folder'])){
288
  $url = untrailingslashit(get_template_directory_uri() . '/' . $this->config['in_theme_folder']);
289
  }else{
342
  }
343
  }
344
 
 
 
 
 
 
 
 
345
  return $settings;
346
  }
347
 
411
  public function load_repositories_list(){
412
  global $wp_installer_instances;
413
 
414
+ foreach ($wp_installer_instances as $instance) {
415
 
416
+ if (file_exists(dirname($instance['bootfile']) . '/repositories.xml')) {
 
 
417
  $config_file = dirname($instance['bootfile']) . '/repositories.xml';
418
 
419
+ if (file_exists(dirname($instance['bootfile']) . '/repositories.sandbox.xml')) {
420
  $config_file = dirname($instance['bootfile']) . '/repositories.sandbox.xml';
421
  }
422
 
423
  $repos = simplexml_load_file($config_file);
424
 
425
+ foreach ($repos as $repo) {
426
  $id = strval($repo->id);
427
 
428
+ $data['api-url'] = strval($repo->apiurl);
429
+ $data['products'] = strval($repo->products);
430
 
431
  // excludes rule;
432
+ if (isset($this->config['repositories_exclude']) && in_array($id, $this->config['repositories_exclude'])) {
433
  continue;
434
  }
435
 
436
  // includes rule;
437
+ if (isset($this->config['repositories_include']) && !in_array($id, $this->config['repositories_include'])) {
438
  continue;
439
  }
440
 
441
  $this->repositories[$id] = $data;
442
 
 
443
  }
444
 
445
  }
 
446
  }
447
 
 
448
  }
449
 
450
  public function filter_repositories_list(){
466
 
467
 
468
  }
469
+
470
+ // Using this in place of a missing hook in wp_update_plugins
471
+ // This is being triggered every time WP checks for plugin updates
472
+ public function update_plugins_information($locale_data){
473
+
474
+ $this->refresh_repositories_data();
475
+
476
+ return $locale_data;
477
+ }
478
+
479
  public function refresh_repositories_data(){
480
+
481
  foreach($this->repositories as $id => $data){
482
 
483
  $response = wp_remote_get($data['products']);
526
  $this->settings['last_repositories_update']= time();
527
 
528
  $this->save_settings();
529
+
530
  }
531
 
532
  public function show_products($args = array()){
745
  }elseif($subscription_data){
746
  $this->settings['repositories'][$repository_id]['subscription'] = array('key' => $site_key, 'data' => $subscription_data);
747
  $this->save_settings();
 
748
  }else{
749
  $error = __('Invalid site key for the current site.', 'installer');
750
  }
786
  }
787
  exit;
788
  }
789
+
790
+ public function validate_repository_subscription(){
791
+ $repository_id = isset($_GET['validate_repository']) ? $_GET['validate_repository'] : false;
792
+ if($repository_id){
793
+
794
+ $site_key = $this->get_site_key($repository_id);
795
+ if($site_key) {
796
+ $subscription_data = $this->fetch_subscription_data($repository_id, $site_key);
797
+ if(empty($subscription_data)){
798
+ unset($this->settings['repositories'][$repository_id]['subscription']);
799
+ delete_site_transient('update_plugins');
800
+ $this->save_settings();
801
+ }
802
+ }
803
+
804
+ wp_redirect($this->menu_url() . '#repository-' . $repository_id);
805
+ exit;
806
+
807
+ }
808
+
809
+ }
810
+
811
  public function update_site_key(){
812
 
813
  $error = '';
866
  'site_url' => $this->get_installer_site_url($repository_id),
867
  );
868
  $args['timeout'] = 45;
869
+
870
  $response = wp_remote_post($this->repositories[$repository_id]['api-url'], $args);
871
 
872
  $this->api_debug_log("POST {$this->repositories[$repository_id]['api-url']}");
890
  $this->api_debug_log($response);
891
  $subscription_data = $response;
892
  }
893
+
894
  return $subscription_data;
895
 
896
  }
1168
  }
1169
 
1170
  if(!empty($package['sub-packages'])){
1171
+ foreach($package['sub-packages'] as $sub_package){
1172
+ foreach($sub_package['products'] as $product){
1173
  if($product['name'] == $product_name && ($subscription_type == $product['subscription_type'] || $has_top_package)){
1174
  return $available = true;
1175
  }
1292
  foreach($package['products'] as $product) {
1293
 
1294
  foreach($product['downloads'] as $download){
1295
+
1296
  if($download['basename'] == $plugin_basename){
1297
  $version = $download['version'];
1298
  break (3);
1350
  //validate subscription
1351
  $site_key = $this->get_repository_site_key($data['repository_id']);
1352
  $subscription_data = $this->fetch_subscription_data($data['repository_id'], $site_key);
1353
+
1354
  if($subscription_data && !is_wp_error($subscription_data) && $this->repository_has_valid_subscription($data['repository_id'])){
1355
 
1356
  if($data['nonce'] == wp_create_nonce('install_plugin_' . $data['url'])){
1511
 
1512
  }
1513
 
1514
+ public function custom_plugins_api_call($false, $action, $args){
1515
 
1516
  if($action == 'plugin_information'){
1517
 
1554
 
1555
  }
1556
 
1557
+ return $false;
1558
 
1559
  }
1560
 
1561
  public function plugins_upgrade_check($update_plugins){
1562
+
 
 
1563
  if(!empty($this->settings['repositories'])){
1564
  $plugins = get_plugins();
1565
 
1684
 
1685
  public function localize_strings(){
1686
  global $sitepress;
1687
+
 
 
1688
  if(!empty($this->settings['repositories'])){
1689
  foreach($this->settings['repositories'] as $repository_id => $repository){
1690
  //set name as call2action when don't have any
1828
  foreach($repository['data']['packages'] as $package_id => $package){
1829
 
1830
  foreach($package['products'] as $product_id => $product){
1831
+
 
1832
  if($match['dtp'] == '%'){
1833
  $fprice = round( $product['price'] * (1 - $match['amt']/100), 2 );
1834
  $fprice = $fprice != round($fprice) ? sprintf('%.2f', $fprice) : round($fprice, 0);
1907
  }
1908
 
1909
  // order parents
1910
+ usort($ordered_packages, array($this, '_order_packages_callback'));
1911
  //order sub-packages
1912
  foreach($ordered_packages as $package_id => $package){
1913
  if(!empty($package['sub-packages'])) {
1924
 
1925
  }
1926
 
1927
+ public function _order_packages_callback($a, $b){
1928
+ return $a['order'] > $b['order'];
1929
+ }
1930
+
1931
  public function filter_downloads_by_icl(){
1932
  if(function_exists('wpml_site_uses_icl') && wpml_site_uses_icl()){
1933
 
1975
 
1976
  return false;
1977
  }
1978
+
1979
+ public function plugin_upgrade_custom_errors(){
1980
+
1981
+ if ( isset($_REQUEST['action']) ) {
1982
+
1983
+ $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
1984
+
1985
+ //bulk mode
1986
+ if('update-selected' == $action) {
1987
+
1988
+ global $plugins;
1989
+
1990
+ if(isset($plugins) && is_array($plugins)) {
1991
+
1992
+ foreach ($plugins as $k => $plugin) {
1993
+ $plugin_repository = false;
1994
+
1995
+ foreach ($this->settings['repositories'] as $repository_id => $repository) {
1996
+
1997
+ foreach ($repository['data']['packages'] as $package) {
1998
+
1999
+ foreach ($package['products'] as $product) {
2000
+
2001
+ foreach ($product['downloads'] as $download) {
2002
+
2003
+ //match by folder, will change to match by name and folder
2004
+ if ($download['basename'] == dirname($plugin)) {
2005
+ $plugin_repository = $repository_id;
2006
+ $product_name = $repository['data']['product-name'];
2007
+ $plugin_name = $download['name'];
2008
+ break;
2009
+ }
2010
+
2011
+ }
2012
+
2013
+ }
2014
+
2015
+ }
2016
+
2017
+ }
2018
+
2019
+ if ($plugin_repository) {
2020
+
2021
+ //validate subscription
2022
+ static $sub_cache = array();
2023
+
2024
+ if(empty($sub_cache[$plugin_repository])){
2025
+ $site_key = $this->get_repository_site_key($plugin_repository);
2026
+ if ($site_key) {
2027
+ $subscription_data = $this->fetch_subscription_data($plugin_repository, $site_key);
2028
+ }
2029
+ $sub_cache[$plugin_repository]['site_key'] = $site_key;
2030
+ $sub_cache[$plugin_repository]['subscription_data'] = isset($subscription_data) ? $subscription_data : false;
2031
+ }else{
2032
+
2033
+ $site_key = $sub_cache[$plugin_repository]['site_key'];
2034
+ $subscription_data = $sub_cache[$plugin_repository]['subscription_data'];
2035
+
2036
+ }
2037
+
2038
+ if (empty($site_key) || empty($subscription_data)) {
2039
+
2040
+
2041
+ $error_message = sprintf(__("%s cannot update because your site's registration is not valid. Please %sregister %s%s again for this site first.", 'installer'),
2042
+ '<strong>' . $plugin_name . '</strong>', '<a target="_top" href="' . $this->menu_url() . '&validate_repository=' . $plugin_repository .
2043
+ '#repository-' . $plugin_repository . '">', $product_name, '</a>');
2044
+
2045
+ echo '<div class="updated error"><p>' . $error_message . '</p></div>';
2046
+
2047
+ unset($plugins[$k]);
2048
+
2049
+
2050
+ }
2051
+
2052
+ }
2053
+
2054
+ }
2055
+
2056
+ }
2057
+
2058
+ }
2059
+
2060
+
2061
+ if( 'upgrade-plugin' == $action || 'update-plugin' == $action ) {
2062
+
2063
+ $plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
2064
+
2065
+ $plugin_repository = false;
2066
+
2067
+ foreach($this->settings['repositories'] as $repository_id => $repository){
2068
+
2069
+ foreach($repository['data']['packages'] as $package){
2070
+
2071
+ foreach($package['products'] as $product){
2072
+
2073
+ foreach($product['downloads'] as $download){
2074
+
2075
+ //match by folder, will change to match by name and folder
2076
+ if($download['basename'] == dirname($plugin)) {
2077
+ $plugin_repository = $repository_id;
2078
+ $product_name = $repository['data']['product-name'];
2079
+ $plugin_name = $download['name'];
2080
+ break;
2081
+ }
2082
+
2083
+ }
2084
+
2085
+ }
2086
+
2087
+ }
2088
+
2089
+ }
2090
+
2091
+ if($plugin_repository) {
2092
+
2093
+ //validate subscription
2094
+ $site_key = $this->get_repository_site_key($plugin_repository);
2095
+ if ($site_key) {
2096
+ $subscription_data = $this->fetch_subscription_data($plugin_repository, $site_key);
2097
+ }
2098
+
2099
+ if (empty($site_key) || empty($subscription_data)) {
2100
+
2101
+ $error_message = sprintf(__("%s cannot update because your site's registration is not valid. Please %sregister %s%s again for this site first.", 'installer'),
2102
+ '<strong>'.$plugin_name . '</strong>', '<a href="' . $this->menu_url() . '&validate_repository=' . $plugin_repository .
2103
+ '#repository-' . $plugin_repository . '">', $product_name, '</a>');
2104
+
2105
+ if(defined('DOING_AJAX')){ //WP 4.2
2106
+
2107
+ $status = array(
2108
+ 'update' => 'plugin',
2109
+ 'plugin' => $plugin,
2110
+ 'slug' => sanitize_key( $_POST['slug'] ),
2111
+ 'oldVersion' => '',
2112
+ 'newVersion' => '',
2113
+ );
2114
+
2115
+ $status['errorCode'] = 'wp_installer_invalid_subscription';
2116
+ $status['error'] = $error_message;
2117
+
2118
+ wp_send_json_error( $status );
2119
+
2120
+ } else { // WP 4.1.1
2121
+ echo '<div class="updated error"><p>' . $error_message . '</p></div>';
2122
+
2123
+
2124
+ echo '<div class="wrap">';
2125
+ echo '<h2>' . __('Update Plugin') . '</h2>';
2126
+ echo '<a href="' . admin_url('plugins.php') . '">' . __('Return to the plugins page') . '</a>';
2127
+ echo '</div>';
2128
+ require_once(ABSPATH . 'wp-admin/admin-footer.php');
2129
+ exit;
2130
+
2131
+ }
2132
+
2133
+ }
2134
+
2135
+
2136
+ }
2137
+
2138
+ }
2139
+ }
2140
+
2141
+ }
2142
+
2143
  }
plus/installer/installer.php CHANGED
@@ -1,8 +1,7 @@
1
  <?php
2
- define('WP_INSTALLER_VERSION', '1.5.1.1');
3
 
4
  include_once dirname(__FILE__) . '/includes/installer.class.php';
5
- include_once dirname(__FILE__) . '/includes/deps-loader.class.php';
6
 
7
  function WP_Installer() {
8
  return WP_Installer::instance();
1
  <?php
2
+ define('WP_INSTALLER_VERSION', '1.5.3');
3
 
4
  include_once dirname(__FILE__) . '/includes/installer.class.php';
 
5
 
6
  function WP_Installer() {
7
  return WP_Installer::instance();
plus/installer/loader.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Installer
4
  Plugin URI: http://wp-compatibility.com/installer-plugin/
5
  Description: Need help buying, installing and upgrading commercial themes and plugins? **Installer** handles all this for you, right from the WordPress admin. Installer lets you find themes and plugins from different sources, then, buy them from within the WordPress admin. Instead of manually uploading and unpacking, you'll see those themes and plugins available, just like any other plugin you're getting from WordPress.org.
6
- Version: 1.5.1.1
7
  Author: OnTheGoSystems Inc.
8
  Author URI: http://www.onthegosystems.com/
9
  */
@@ -13,14 +13,22 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  exit; // Exit if accessed directly
14
  }
15
 
 
 
 
 
 
 
 
16
 
17
  $wp_installer_instance = dirname(__FILE__) . '/installer.php';
18
 
 
19
  // Global stack of instances
20
  global $wp_installer_instances;
21
  $wp_installer_instances[$wp_installer_instance] = array(
22
  'bootfile' => $wp_installer_instance,
23
- 'version' => '1.5.1.1'
24
  );
25
 
26
  // Only one of these in the end
3
  Plugin Name: Installer
4
  Plugin URI: http://wp-compatibility.com/installer-plugin/
5
  Description: Need help buying, installing and upgrading commercial themes and plugins? **Installer** handles all this for you, right from the WordPress admin. Installer lets you find themes and plugins from different sources, then, buy them from within the WordPress admin. Instead of manually uploading and unpacking, you'll see those themes and plugins available, just like any other plugin you're getting from WordPress.org.
6
+ Version: 1.5.3
7
  Author: OnTheGoSystems Inc.
8
  Author URI: http://www.onthegosystems.com/
9
  */
13
  exit; // Exit if accessed directly
14
  }
15
 
16
+ //It should only be loaded on the admin side
17
+ if( !is_admin() ){
18
+ if(!function_exists('WP_Installer_Setup')){ function WP_Installer_Setup(){} }
19
+ $wp_installer_instance = null;
20
+ return;
21
+ }
22
+
23
 
24
  $wp_installer_instance = dirname(__FILE__) . '/installer.php';
25
 
26
+
27
  // Global stack of instances
28
  global $wp_installer_instances;
29
  $wp_installer_instances[$wp_installer_instance] = array(
30
  'bootfile' => $wp_installer_instance,
31
+ 'version' => '1.5.3'
32
  );
33
 
34
  // Only one of these in the end
plus/installer/res/css/admin.css CHANGED
@@ -50,6 +50,11 @@
50
  color: #f00;
51
  }
52
 
 
 
 
 
 
53
  .installer-warn-box{
54
  -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;border:1px solid #962722;background-color:#F5C8C6;
55
  color: #333;
@@ -140,4 +145,9 @@
140
 
141
  .installer_highlight_package{
142
  background-color: #fff9c0;
 
 
 
 
 
143
  }
50
  color: #f00;
51
  }
52
 
53
+ .installer-status-note{
54
+ color: #6F6E6D;
55
+ font-style: italic;
56
+ }
57
+
58
  .installer-warn-box{
59
  -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;border:1px solid #962722;background-color:#F5C8C6;
60
  color: #333;
145
 
146
  .installer_highlight_package{
147
  background-color: #fff9c0;
148
+ }
149
+
150
+ .plugin_progress{
151
+ font-style: italic;
152
+ color: #777
153
  }
plus/installer/res/js/admin.js CHANGED
@@ -18,6 +18,27 @@
18
 
19
  otgs_wp_installer.scroll_to_repository();
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  },
22
 
23
  reset_errors: function(){
@@ -342,4 +363,5 @@
342
 
343
  }
344
 
 
345
  jQuery(document).ready(otgs_wp_installer.init);
18
 
19
  otgs_wp_installer.scroll_to_repository();
20
 
21
+ if( pagenow == 'plugins'){
22
+
23
+ jQuery(document).ajaxSuccess(function(event, xhr, settings) {
24
+ var data = otgs_wp_installer.getQueryParameters(settings.data);
25
+ if(typeof data.action != 'undefined' && data.action == 'update-plugin'){
26
+ response = xhr.responseJSON.data;
27
+ console.log(typeof response.error);
28
+ if(typeof response.error != 'undefined'){
29
+ var default_error = jQuery('#' + response.slug + '-update .update-message').html();
30
+ jQuery('#' + response.slug + '-update .update-message').html(default_error + ' &raquo;<span class="installer-red-text"> ' + response.error + '</span>');
31
+ }
32
+ }
33
+ return false;
34
+ });
35
+
36
+ }
37
+
38
+ },
39
+
40
+ getQueryParameters : function(str) {
41
+ return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
42
  },
43
 
44
  reset_errors: function(){
363
 
364
  }
365
 
366
+
367
  jQuery(document).ready(otgs_wp_installer.init);
plus/installer/res/js/iframeResizer.min.js CHANGED
@@ -1,10 +1,10 @@
1
- /*! iFrame Resizer (iframeSizer.min.js ) - v2.6.1 - 2014-09-03
2
- * Desc: Force cross domain iframes to size to content.
3
- * Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame.
4
- * Copyright: (c) 2014 David J. Bradshaw - dave@bradshaw.net
5
- * License: MIT
6
- */
7
-
8
- !function(){"use strict";function a(a,b,c){"addEventListener"in window?a.addEventListener(b,c,!1):"attachEvent"in window&&a.attachEvent("on"+b,c)}function b(){var a,b=["moz","webkit","o","ms"];for(a=0;a<b.length&&!w;a+=1)w=window[b[a]+"RequestAnimationFrame"];w||c(" RequestAnimationFrame not supported")}function c(a){y.log&&"object"==typeof console&&console.log(s+"[Host page"+u+"]"+a)}function d(a){function b(){function a(){h(z),f(),y.resizedCallback(z)}i(a,z,"resetPage")}function d(a){var b=a.id;c(" Removing iFrame: "+b),a.parentNode.removeChild(a),y.closedCallback(b),c(" --")}function e(){var a=x.substr(t).split(":");return{iframe:document.getElementById(a[0]),id:a[0],height:a[1],width:a[2],type:a[3]}}function j(a){var b=Number(y["max"+a]),d=Number(y["min"+a]),e=a.toLowerCase(),f=Number(z[e]);if(d>b)throw new Error("Value for min"+a+" can not be greater than max"+a);c(" Checking "+e+" is in range "+d+"-"+b),d>f&&(f=d,c(" Set "+e+" to min value")),f>b&&(f=b,c(" Set "+e+" to max value")),z[e]=""+f}function k(){var b=a.origin,d=z.iframe.src.split("/").slice(0,3).join("/");if(y.checkOrigin&&(c(" Checking connection is from: "+d),""+b!="null"&&b!==d))throw new Error("Unexpected message received from: "+b+" for "+z.iframe.id+". Message was: "+a.data+". This error can be disabled by adding the checkOrigin: false option.");return!0}function l(){return s===(""+x).substr(0,t)}function m(){var a=z.type in{"true":1,"false":1};return a&&c(" Ignoring init message from meta parent page"),a}function n(){var a=x.substr(x.indexOf(":")+r+6);c(" MessageCallback passed: {iframe: "+z.iframe.id+", message: "+a+"}"),y.messageCallback({iframe:z.iframe,message:a}),c(" --")}function o(){if(null===z.iframe)throw new Error("iFrame ("+z.id+") does not exist on "+u);return!0}function q(){c(" Reposition requested from iFrame"),v={x:z.width,y:z.height},f()}function w(){switch(z.type){case"close":d(z.iframe),y.resizedCallback(z);break;case"message":n();break;case"scrollTo":q();break;case"reset":g(z);break;case"init":b(),y.initCallback(z.iframe);break;default:b()}}var x=a.data,z={};l()&&(c(" Received: "+x),z=e(),j("Height"),j("Width"),!m()&&o()&&k()&&(w(),p=!1))}function e(){null===v&&(v={x:void 0!==window.pageXOffset?window.pageXOffset:document.documentElement.scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop},c(" Get position: "+v.x+","+v.y))}function f(){null!==v&&(window.scrollTo(v.x,v.y),c(" Set position: "+v.x+","+v.y),v=null)}function g(a){function b(){h(a),j("reset","reset",a.iframe)}c(" Size reset requested by "+("init"===a.type?"host page":"iFrame")),e(),i(b,a,"init")}function h(a){function b(b){a.iframe.style[b]=a[b]+"px",c(" IFrame ("+a.iframe.id+") "+b+" set to "+a[b]+"px")}y.sizeHeight&&b("height"),y.sizeWidth&&b("width")}function i(a,b,d){d!==b.type&&w?(c(" Requesting animation frame"),w(a)):a()}function j(a,b,d){c("["+a+"] Sending msg to iframe ("+b+")"),d.contentWindow.postMessage(s+b,"*")}function k(){function b(){function a(a){1/0!==y[a]&&0!==y[a]&&(k.style[a]=y[a]+"px",c(" Set "+a+" = "+y[a]+"px"))}a("maxHeight"),a("minHeight"),a("maxWidth"),a("minWidth")}function d(a){return""===a&&(k.id=a="iFrameResizer"+o++,c(" Added missing iframe ID: "+a+" ("+k.src+")")),a}function e(){c(" IFrame scrolling "+(y.scrolling?"enabled":"disabled")+" for "+l),k.style.overflow=!1===y.scrolling?"hidden":"auto",k.scrolling=!1===y.scrolling?"no":"yes"}function f(){("number"==typeof y.bodyMargin||"0"===y.bodyMargin)&&(y.bodyMarginV1=y.bodyMargin,y.bodyMargin=""+y.bodyMargin+"px")}function h(){return l+":"+y.bodyMarginV1+":"+y.sizeWidth+":"+y.log+":"+y.interval+":"+y.enablePublicMethods+":"+y.autoResize+":"+y.bodyMargin+":"+y.heightCalculationMethod+":"+y.bodyBackground+":"+y.bodyPadding+":"+y.tolerance}function i(b){a(k,"load",function(){var a=p;j("iFrame.onload",b,k),!a&&y.heightCalculationMethod in x&&g({iframe:k,height:0,width:0,type:"init"})}),j("init",b,k)}var k=this,l=d(k.id);e(),b(),f(),i(h())}function l(a){if("object"!=typeof a)throw new TypeError("Options is not an object.")}function m(){function a(a){if("IFRAME"!==a.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+a.tagName+">.");k.call(a)}function b(a){a=a||{},l(a);for(var b in z)z.hasOwnProperty(b)&&(y[b]=a.hasOwnProperty(b)?a[b]:z[b])}return function(c,d){b(c),Array.prototype.forEach.call(document.querySelectorAll(d||"iframe"),a)}}function n(a){a.fn.iFrameResize=function(b){return b=b||{},l(b),y=a.extend({},z,b),this.filter("iframe").each(k).end()}}var o=0,p=!0,q="message",r=q.length,s="[iFrameSizer]",t=s.length,u="",v=null,w=window.requestAnimationFrame,x={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},y={},z={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,enablePublicMethods:!1,heightCalculationMethod:"offset",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,closedCallback:function(){},initCallback:function(){},messageCallback:function(){},resizedCallback:function(){}};b(),a(window,"message",d),"jQuery"in window&&n(jQuery),"function"==typeof define&&define.amd?define(function(){return m()}):window.iFrameResize=m()}();
9
- //# sourceMappingURL=../src/iframeResizer.map
10
-
1
+ /*! iFrame Resizer (iframeSizer.min.js ) - v2.6.1 - 2014-09-03
2
+ * Desc: Force cross domain iframes to size to content.
3
+ * Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame.
4
+ * Copyright: (c) 2014 David J. Bradshaw - dave@bradshaw.net
5
+ * License: MIT
6
+ */
7
+
8
+ !function(){"use strict";function a(a,b,c){"addEventListener"in window?a.addEventListener(b,c,!1):"attachEvent"in window&&a.attachEvent("on"+b,c)}function b(){var a,b=["moz","webkit","o","ms"];for(a=0;a<b.length&&!w;a+=1)w=window[b[a]+"RequestAnimationFrame"];w||c(" RequestAnimationFrame not supported")}function c(a){y.log&&"object"==typeof console&&console.log(s+"[Host page"+u+"]"+a)}function d(a){function b(){function a(){h(z),f(),y.resizedCallback(z)}i(a,z,"resetPage")}function d(a){var b=a.id;c(" Removing iFrame: "+b),a.parentNode.removeChild(a),y.closedCallback(b),c(" --")}function e(){var a=x.substr(t).split(":");return{iframe:document.getElementById(a[0]),id:a[0],height:a[1],width:a[2],type:a[3]}}function j(a){var b=Number(y["max"+a]),d=Number(y["min"+a]),e=a.toLowerCase(),f=Number(z[e]);if(d>b)throw new Error("Value for min"+a+" can not be greater than max"+a);c(" Checking "+e+" is in range "+d+"-"+b),d>f&&(f=d,c(" Set "+e+" to min value")),f>b&&(f=b,c(" Set "+e+" to max value")),z[e]=""+f}function k(){var b=a.origin,d=z.iframe.src.split("/").slice(0,3).join("/");if(y.checkOrigin&&(c(" Checking connection is from: "+d),""+b!="null"&&b!==d))throw new Error("Unexpected message received from: "+b+" for "+z.iframe.id+". Message was: "+a.data+". This error can be disabled by adding the checkOrigin: false option.");return!0}function l(){return s===(""+x).substr(0,t)}function m(){var a=z.type in{"true":1,"false":1};return a&&c(" Ignoring init message from meta parent page"),a}function n(){var a=x.substr(x.indexOf(":")+r+6);c(" MessageCallback passed: {iframe: "+z.iframe.id+", message: "+a+"}"),y.messageCallback({iframe:z.iframe,message:a}),c(" --")}function o(){if(null===z.iframe)throw new Error("iFrame ("+z.id+") does not exist on "+u);return!0}function q(){c(" Reposition requested from iFrame"),v={x:z.width,y:z.height},f()}function w(){switch(z.type){case"close":d(z.iframe),y.resizedCallback(z);break;case"message":n();break;case"scrollTo":q();break;case"reset":g(z);break;case"init":b(),y.initCallback(z.iframe);break;default:b()}}var x=a.data,z={};l()&&(c(" Received: "+x),z=e(),j("Height"),j("Width"),!m()&&o()&&k()&&(w(),p=!1))}function e(){null===v&&(v={x:void 0!==window.pageXOffset?window.pageXOffset:document.documentElement.scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:document.documentElement.scrollTop},c(" Get position: "+v.x+","+v.y))}function f(){null!==v&&(window.scrollTo(v.x,v.y),c(" Set position: "+v.x+","+v.y),v=null)}function g(a){function b(){h(a),j("reset","reset",a.iframe)}c(" Size reset requested by "+("init"===a.type?"host page":"iFrame")),e(),i(b,a,"init")}function h(a){function b(b){a.iframe.style[b]=a[b]+"px",c(" IFrame ("+a.iframe.id+") "+b+" set to "+a[b]+"px")}y.sizeHeight&&b("height"),y.sizeWidth&&b("width")}function i(a,b,d){d!==b.type&&w?(c(" Requesting animation frame"),w(a)):a()}function j(a,b,d){c("["+a+"] Sending msg to iframe ("+b+")"),d.contentWindow.postMessage(s+b,"*")}function k(){function b(){function a(a){1/0!==y[a]&&0!==y[a]&&(k.style[a]=y[a]+"px",c(" Set "+a+" = "+y[a]+"px"))}a("maxHeight"),a("minHeight"),a("maxWidth"),a("minWidth")}function d(a){return""===a&&(k.id=a="iFrameResizer"+o++,c(" Added missing iframe ID: "+a+" ("+k.src+")")),a}function e(){c(" IFrame scrolling "+(y.scrolling?"enabled":"disabled")+" for "+l),k.style.overflow=!1===y.scrolling?"hidden":"auto",k.scrolling=!1===y.scrolling?"no":"yes"}function f(){("number"==typeof y.bodyMargin||"0"===y.bodyMargin)&&(y.bodyMarginV1=y.bodyMargin,y.bodyMargin=""+y.bodyMargin+"px")}function h(){return l+":"+y.bodyMarginV1+":"+y.sizeWidth+":"+y.log+":"+y.interval+":"+y.enablePublicMethods+":"+y.autoResize+":"+y.bodyMargin+":"+y.heightCalculationMethod+":"+y.bodyBackground+":"+y.bodyPadding+":"+y.tolerance}function i(b){a(k,"load",function(){var a=p;j("iFrame.onload",b,k),!a&&y.heightCalculationMethod in x&&g({iframe:k,height:0,width:0,type:"init"})}),j("init",b,k)}var k=this,l=d(k.id);e(),b(),f(),i(h())}function l(a){if("object"!=typeof a)throw new TypeError("Options is not an object.")}function m(){function a(a){if("IFRAME"!==a.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+a.tagName+">.");k.call(a)}function b(a){a=a||{},l(a);for(var b in z)z.hasOwnProperty(b)&&(y[b]=a.hasOwnProperty(b)?a[b]:z[b])}return function(c,d){b(c),Array.prototype.forEach.call(document.querySelectorAll(d||"iframe"),a)}}function n(a){a.fn.iFrameResize=function(b){return b=b||{},l(b),y=a.extend({},z,b),this.filter("iframe").each(k).end()}}var o=0,p=!0,q="message",r=q.length,s="[iFrameSizer]",t=s.length,u="",v=null,w=window.requestAnimationFrame,x={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},y={},z={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,enablePublicMethods:!1,heightCalculationMethod:"offset",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,closedCallback:function(){},initCallback:function(){},messageCallback:function(){},resizedCallback:function(){}};b(),a(window,"message",d),"jQuery"in window&&n(jQuery),"function"==typeof define&&define.amd?define(function(){return m()}):window.iFrameResize=m()}();
9
+ //# sourceMappingURL=../src/iframeResizer.map
10
+
plus/types-access.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Types Access teaser.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/plus/types-access.php $
6
- * $LastChangedDate: 2015-02-24 10:05:51 +0000 (Tue, 24 Feb 2015) $
7
- * $LastChangedRevision: 1097977 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -80,7 +80,7 @@ function wpcf_access_teaser_admin_menu_page()
80
  /**
81
  * show message
82
  */
83
- echo wpcf_add_admin_header( __( 'Access', 'wpcf' ), 'icon-wpcf-access' );
84
  echo '<div class="types-help"><div class="types-help-content"';
85
  echo '<p>' . sprintf(__( 'This screen shows a preview of %sAccess%s - the access control and roles management addon for Types.',
86
  'wpcf' ), '<strong><a href="http://wp-types.com/home/types-access/?utm_source=typesplugin&utm_medium=accessadmin&utm_term=Access&utm_campaign=typesplugin" target="_blank">','</a></strong>')
@@ -96,5 +96,5 @@ function wpcf_access_teaser_admin_menu_page()
96
  echo '</div></div>';
97
  require_once WPCF_ACCESS_INC . '/admin-edit-access.php';
98
  wpcf_access_admin_edit_access( false );
99
- echo wpcf_add_admin_footer();
100
  }
2
  /*
3
  * Types Access teaser.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/plus/types-access.php $
6
+ * $LastChangedDate: 2015-03-02 10:49:00 +0000 (Mon, 02 Mar 2015) $
7
+ * $LastChangedRevision: 1103173 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
80
  /**
81
  * show message
82
  */
83
+ wpcf_add_admin_header( __( 'Access', 'wpcf' ), 'icon-wpcf-access' );
84
  echo '<div class="types-help"><div class="types-help-content"';
85
  echo '<p>' . sprintf(__( 'This screen shows a preview of %sAccess%s - the access control and roles management addon for Types.',
86
  'wpcf' ), '<strong><a href="http://wp-types.com/home/types-access/?utm_source=typesplugin&utm_medium=accessadmin&utm_term=Access&utm_campaign=typesplugin" target="_blank">','</a></strong>')
96
  echo '</div></div>';
97
  require_once WPCF_ACCESS_INC . '/admin-edit-access.php';
98
  wpcf_access_admin_edit_access( false );
99
+ wpcf_add_admin_footer();
100
  }
plus/types-access/includes/admin-edit-access.php CHANGED
@@ -264,7 +264,7 @@ function wpcf_access_admin_edit_access($enabled = true) {
264
  }
265
  }
266
  if (isset($cap['style']) && $cap['style'] == 'dropdown') {
267
-
268
  } else {
269
  $output .= wpcf_access_permissions_table($roles, $saved_data,
270
  $caps, $area['id'], $group['id'], $enabled);
@@ -310,11 +310,11 @@ function wpcf_access_admin_edit_access($enabled = true) {
310
 
311
  /**
312
  * Renders dropdown with editable roles.
313
- *
314
  * @param type $roles
315
  * @param type $name
316
  * @param type $data
317
- * @return string
318
  */
319
  function wpcf_access_admin_roles_dropdown($roles, $name, $data = array(),
320
  $dummy = false, $enabled = true, $exclude = array()) {
@@ -360,10 +360,10 @@ function wpcf_access_admin_roles_dropdown($roles, $name, $data = array(),
360
 
361
  /**
362
  * Auto-suggest users search.
363
- *
364
  * @param type $data
365
  * @param type $name
366
- * @return string
367
  */
368
  function wpcf_access_admin_users_form($data, $name, $enabled = true,
369
  $managed = true) {
@@ -386,12 +386,12 @@ function wpcf_access_admin_users_form($data, $name, $enabled = true,
386
 
387
  /**
388
  * Renders pre-defined table.
389
- *
390
  * @param type $type_slug
391
  * @param type $roles
392
  * @param type $name
393
  * @param type $data
394
- * @return string
395
  */
396
  function wpcf_access_admin_predefined($type_slug, $roles, $name, $data,
397
  $enabled = true) {
@@ -418,12 +418,12 @@ function wpcf_access_admin_predefined($type_slug, $roles, $name, $data,
418
 
419
  /**
420
  * Renders custom caps types table.
421
- *
422
  * @param type $type_slug
423
  * @param type $roles
424
  * @param type $name
425
  * @param type $data
426
- * @return string
427
  */
428
  function wpcf_access_admin_edit_access_types_item($type_slug, $roles, $name,
429
  $data, $enabled = true) {
@@ -455,12 +455,12 @@ function wpcf_access_admin_edit_access_types_item($type_slug, $roles, $name,
455
 
456
  /**
457
  * Renders custom caps tax table.
458
- *
459
  * @param type $type_slug
460
  * @param type $roles
461
  * @param type $name
462
  * @param type $data
463
- * @return string
464
  */
465
  function wpcf_access_admin_edit_access_tax_item($type_slug, $roles, $name,
466
  $data, $enabled = true) {
@@ -485,10 +485,10 @@ function wpcf_access_admin_edit_access_tax_item($type_slug, $roles, $name,
485
 
486
  /**
487
  * Reset caps button.
488
- *
489
  * @param type $type_slug
490
  * @param type $type
491
- * @return string
492
  */
493
  function wpcf_access_reset_button($type_slug, $type = 'type', $enabled = true,
494
  $managed = true) {
@@ -515,10 +515,10 @@ function wpcf_access_reset_button($type_slug, $type = 'type', $enabled = true,
515
 
516
  /**
517
  * Submit button.
518
- *
519
  * @param type $enabled
520
  * @param type $managed
521
- * @return type
522
  */
523
  function wpcf_access_submit_button($enabled = true, $managed = true) {
524
  $output = '';
@@ -538,9 +538,9 @@ function wpcf_access_submit_button($enabled = true, $managed = true) {
538
 
539
  /**
540
  * Custom roles form.
541
- *
542
  * @param type $roles
543
- * @return string
544
  */
545
  function wpcf_access_admin_set_custom_roles_level_form($roles, $enabled = true) {
546
  $levels = wpcf_access_role_to_level_map();
@@ -704,11 +704,11 @@ function wpcf_access_admin_set_custom_roles_level_form($roles, $enabled = true)
704
 
705
  /**
706
  * HTML formatted permissions table.
707
- *
708
  * @param type $roles
709
  * @param type $permissions
710
  * @param type $name
711
- * @return string
712
  */
713
  function wpcf_access_permissions_table($roles, $permissions, $settings,
714
  $group_id, $id, $enabled = true, $managed = true) {
@@ -816,9 +816,9 @@ function wpcf_access_permissions_table($roles, $permissions, $settings,
816
 
817
  /**
818
  * Suggest user form.
819
- *
820
- * @global type $wpdb
821
- * @return string
822
  */
823
  function wpcf_access_suggest_user($enabled = true, $managed = false) {
824
  global $wpdb;
@@ -850,8 +850,8 @@ function wpcf_access_suggest_user($enabled = true, $managed = false) {
850
 
851
  /**
852
  * New role form.
853
- *
854
- * @return string
855
  */
856
  function wpcf_access_new_role_form($enabled) {
857
  $output = '';
@@ -876,9 +876,9 @@ function wpcf_access_new_role_form($enabled) {
876
 
877
  /**
878
  * Reassing role form.
879
- *
880
  * @param type $role
881
- * @return string
882
  */
883
  function wpcf_access_reassign_role_form($role) {
884
  $output = '';
@@ -917,4 +917,4 @@ function wpcf_access_reassign_role_form($role) {
917
  </div>';
918
  $output .= '<div class="ajax-response"></div></div></div>';
919
  return $output;
920
- }
264
  }
265
  }
266
  if (isset($cap['style']) && $cap['style'] == 'dropdown') {
267
+
268
  } else {
269
  $output .= wpcf_access_permissions_table($roles, $saved_data,
270
  $caps, $area['id'], $group['id'], $enabled);
310
 
311
  /**
312
  * Renders dropdown with editable roles.
313
+ *
314
  * @param type $roles
315
  * @param type $name
316
  * @param type $data
317
+ * @return string
318
  */
319
  function wpcf_access_admin_roles_dropdown($roles, $name, $data = array(),
320
  $dummy = false, $enabled = true, $exclude = array()) {
360
 
361
  /**
362
  * Auto-suggest users search.
363
+ *
364
  * @param type $data
365
  * @param type $name
366
+ * @return string
367
  */
368
  function wpcf_access_admin_users_form($data, $name, $enabled = true,
369
  $managed = true) {
386
 
387
  /**
388
  * Renders pre-defined table.
389
+ *
390
  * @param type $type_slug
391
  * @param type $roles
392
  * @param type $name
393
  * @param type $data
394
+ * @return string
395
  */
396
  function wpcf_access_admin_predefined($type_slug, $roles, $name, $data,
397
  $enabled = true) {
418
 
419
  /**
420
  * Renders custom caps types table.
421
+ *
422
  * @param type $type_slug
423
  * @param type $roles
424
  * @param type $name
425
  * @param type $data
426
+ * @return string
427
  */
428
  function wpcf_access_admin_edit_access_types_item($type_slug, $roles, $name,
429
  $data, $enabled = true) {
455
 
456
  /**
457
  * Renders custom caps tax table.
458
+ *
459
  * @param type $type_slug
460
  * @param type $roles
461
  * @param type $name
462
  * @param type $data
463
+ * @return string
464
  */
465
  function wpcf_access_admin_edit_access_tax_item($type_slug, $roles, $name,
466
  $data, $enabled = true) {
485
 
486
  /**
487
  * Reset caps button.
488
+ *
489
  * @param type $type_slug
490
  * @param type $type
491
+ * @return string
492
  */
493
  function wpcf_access_reset_button($type_slug, $type = 'type', $enabled = true,
494
  $managed = true) {
515
 
516
  /**
517
  * Submit button.
518
+ *
519
  * @param type $enabled
520
  * @param type $managed
521
+ * @return type
522
  */
523
  function wpcf_access_submit_button($enabled = true, $managed = true) {
524
  $output = '';
538
 
539
  /**
540
  * Custom roles form.
541
+ *
542
  * @param type $roles
543
+ * @return string
544
  */
545
  function wpcf_access_admin_set_custom_roles_level_form($roles, $enabled = true) {
546
  $levels = wpcf_access_role_to_level_map();
704
 
705
  /**
706
  * HTML formatted permissions table.
707
+ *
708
  * @param type $roles
709
  * @param type $permissions
710
  * @param type $name
711
+ * @return string
712
  */
713
  function wpcf_access_permissions_table($roles, $permissions, $settings,
714
  $group_id, $id, $enabled = true, $managed = true) {
816
 
817
  /**
818
  * Suggest user form.
819
+ *
820
+ * @global object $wpdb
821
+ * @return string
822
  */
823
  function wpcf_access_suggest_user($enabled = true, $managed = false) {
824
  global $wpdb;
850
 
851
  /**
852
  * New role form.
853
+ *
854
+ * @return string
855
  */
856
  function wpcf_access_new_role_form($enabled) {
857
  $output = '';
876
 
877
  /**
878
  * Reassing role form.
879
+ *
880
  * @param type $role
881
+ * @return string
882
  */
883
  function wpcf_access_reassign_role_form($role) {
884
  $output = '';
917
  </div>';
918
  $output .= '<div class="ajax-response"></div></div></div>';
919
  return $output;
920
+ }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: CMS, custom field, custom fields, custom post type, custom post types, pos
5
  License: GPLv2
6
  Requires at least: 3.4
7
  Tested up to: 4.1.1
8
- Stable tag: 1.6.5.1
9
 
10
  The complete and reliable plugin for managing custom post types, custom taxonomy and custom fields.
11
 
@@ -143,22 +143,41 @@ Additionally, Types is the only plugin that lets you define parent/child relatio
143
 
144
  == Screenshots ==
145
 
146
- 1. Defining custom post types and taxonomy
147
- 2. Defining custom fields (meta-groups)
148
- 3. Editing custom fields
149
- 4. Inserting custom fields to content
150
- 5. Bulk editing child content using Field Tables
151
- 6. Edit Custom Post Type
152
- 7. Edit Taxonomy
 
 
153
 
154
  == Changelog ==
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  = 1.6.5.1 =
157
 
158
  * Release date: 2015-02-24
159
- * Fix Installer patch to plugins.
160
- * Fix problem with "Access Control and User Roles" menu in Types, when Access is active http://wp-types.com/forums/topic/update-issues-fatal-error-require_once-failed-opening-required-wpcf_access_/
161
- * Change utm_media used in links on "Getting Started" pages.
162
 
163
  = 1.6.5 =
164
 
5
  License: GPLv2
6
  Requires at least: 3.4
7
  Tested up to: 4.1.1
8
+ Stable tag: 1.6.6
9
 
10
  The complete and reliable plugin for managing custom post types, custom taxonomy and custom fields.
11
 
143
 
144
  == Screenshots ==
145
 
146
+ 1. Custom post types list
147
+ 2. Defining custom taxonomy list
148
+ 3. Defining custom post type
149
+ 4. Defining custom fields (meta-groups)
150
+ 5. Editing custom fields
151
+ 6. Inserting custom fields to content
152
+ 7. Bulk editing child content using Field Tables
153
+ 8. Edit Custom Post Type
154
+ 9. Edit Taxonomy
155
 
156
  == Changelog ==
157
 
158
+ = 1.6.6 =
159
+
160
+ * Fixed problem with shortcode "playlist" used in WYSIWYG field. http://wp-types.com/forums/topic/media-play-list-not-outputting-from-custom-wysiwyg-field-js-error/
161
+ * Fixed empty title problem for filter "wpt_field_options" on user edit/add screen https://wp-types.com/forums/topic/populate-select-field-in-wpcf-um-group/
162
+ * Added ability to create CPT without title and editor. https://wp-types.com/forums/topic/inaccurate-warning-message-when-creatingediting-a-cpt/
163
+ * Added Skype field validation.
164
+ * Fixed problem with loading custom CSS when user meta group is inactive or not assign to certain user role.
165
+ * Added ability to add to menu link to archive of post type.
166
+ * Added ability to setup meta box callback function. https://wp-types.com/forums/topic/add-support-for-meta_box_cb-in-custom-taxonomy/
167
+ * Added ability to add HTML5 placeholder attribute for custom post fields.
168
+ * Fixed problem with CPT labels. https://wp-types.com/forums/topic/after-save-cpts-cutom-labels-always-revert-to-default-label/
169
+ * Added a filters to the post title as option text in the select dropdown for post parents. wpcf_pr_belongs_items for array of options and wpcf_pr_belongs_item for one option. https://wp-types.com/forums/topic/help-to-distinguish-duplicate-titles-in-post-relationship/
170
+ * Added ability to choose custom fields to display it on custom posts admin list.
171
+ * Fixed problem with saving parent data into child data. On parent edit screen.
172
+ * Added check group name for Custom Fields and User Fields.
173
+ * Fixed missing "Edit" button on group edit screen when we close custom logic form.
174
+
175
  = 1.6.5.1 =
176
 
177
  * Release date: 2015-02-24
178
+ * Fixed Installer patch to plugins.
179
+ * Fixed problem with "Access Control and User Roles" menu in Types, when Access is active http://wp-types.com/forums/topic/update-issues-fatal-error-require_once-failed-opening-required-wpcf_access_/
180
+ * Changed utm_media used in links on "Getting Started" pages.
181
 
182
  = 1.6.5 =
183
 
resources/css/basic.css DELETED
@@ -1,6 +0,0 @@
1
- /*
2
- Full version CSS
3
-
4
- Before moving out of embedded version - check twice.
5
- NO DUPLICATES
6
- */
 
 
 
 
 
 
resources/js/basic.js CHANGED
@@ -1,7 +1,7 @@
1
  /** * * Use this file only for scripts needed in full version.
2
  * Before moving from embedded JS - make sure it's needed only here.
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5.1/resources/js/basic.js $
1
  /** * * Use this file only for scripts needed in full version.
2
  * Before moving from embedded JS - make sure it's needed only here.
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6/resources/js/basic.