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

Version Description

  • Change in relationships, now all posts are showed, even those which have show_ui to false.
  • Added ability to hide custom post types on post relationships list. https://wp-types.com/forums/topic/post-relationship-doesnt-show-post-type-events-created-by-events-espresso/ using filter add_filter('wpcf_show_ui_hide_in_relationships', '__return_false');
  • Fixed a problem with deleting last children on post relationships table.
  • Added filter to allow use "?" in image url. https://wp-types.com/forums/topic/image-custom-field-is-not-storing-image-path-with-parameters/
  • Added option for child table, when editing parent to allow show only list of children instead edit form. http://wp-types.com/forums/topic/miss-settings-for-post-relationship-child-options/
  • Fixed a problem with slug in custom fields, when field have special chars.
  • Fixed wrong display message about custom fields not manageable by Types.
  • Fixed a conflict with Formidable-Pro plugin https://wp-types.com/forums/topic/plugin-conflict/
  • Fixed creating new post in relationships. WP 4.1 need real title not faked by one space.
  • Fixed problem with validate fields on user create page. http://wp-types.com/forums/topic/custom-usermeta-bypassed-even-required-is-set/
  • Improve Edit CPT and Edit CT screens to be more compatible with WP Admin UI
  • Fixed problem with default label which contains single quote character (eg. French) https://wp-types.com/forums/topic/default-label-always-shown/
  • Improve display list of custom fields groups.
Download this release

Release Info

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

Code changes from version 1.6.4 to 1.6.5

Files changed (167) hide show
  1. admin.php +1122 -978
  2. classes/class.wpcf-marketing-messages.php +358 -0
  3. classes/class.wpcf-marketing-tutorial.php +247 -0
  4. classes/class.wpcf-marketing.php +159 -0
  5. embedded/admin.php +4 -40
  6. embedded/bootstrap.php +13 -5
  7. embedded/classes/class.wpcf-post-types.php +1 -1
  8. embedded/classes/field.php +1 -1
  9. embedded/classes/fields.php +1 -1
  10. embedded/classes/forms.php +1 -1
  11. embedded/classes/loader.php +1 -1
  12. embedded/classes/path.php +1 -1
  13. embedded/classes/post-types/messages.php +1 -1
  14. embedded/classes/relationship.php +68 -17
  15. embedded/common/changelog.txt +14 -0
  16. embedded/common/classes/forms.php +1 -1
  17. embedded/common/classes/validation-cakephp.php +11 -0
  18. embedded/common/debug/debug-information.php +1 -1
  19. embedded/common/debug/functions_debug_information.php +1 -1
  20. embedded/common/installer/changelog.txt +0 -17
  21. embedded/common/res/css/toolset-common.css +2 -2
  22. embedded/common/toolset-forms/api.php +1 -1
  23. embedded/common/toolset-forms/bootstrap.php +45 -43
  24. embedded/common/toolset-forms/classes/class.audio.php +1 -1
  25. embedded/common/toolset-forms/classes/class.checkbox.php +6 -6
  26. embedded/common/toolset-forms/classes/class.checkboxes.php +5 -4
  27. embedded/common/toolset-forms/classes/class.colorpicker.php +18 -4
  28. embedded/common/toolset-forms/classes/class.conditional.php +194 -205
  29. embedded/common/toolset-forms/classes/class.credaudio.php +1 -1
  30. embedded/common/toolset-forms/classes/class.credfile.php +1 -1
  31. embedded/common/toolset-forms/classes/class.credimage.php +1 -1
  32. embedded/common/toolset-forms/classes/class.credvideo.php +1 -1
  33. embedded/common/toolset-forms/classes/class.date.scripts.php +1 -1
  34. embedded/common/toolset-forms/classes/class.eforms.php +265 -330
  35. embedded/common/toolset-forms/classes/class.field_factory.php +1 -1
  36. embedded/common/toolset-forms/classes/class.fieldconfig.php +42 -39
  37. embedded/common/toolset-forms/classes/class.file.php +1 -1
  38. embedded/common/toolset-forms/classes/class.form_factory.php +16 -9
  39. embedded/common/toolset-forms/classes/class.image.php +1 -1
  40. embedded/common/toolset-forms/classes/class.radios.php +1 -1
  41. embedded/common/toolset-forms/classes/class.repetitive.php +1 -1
  42. embedded/common/toolset-forms/classes/class.select.php +1 -1
  43. embedded/common/toolset-forms/classes/class.skype.php +1 -1
  44. embedded/common/toolset-forms/classes/class.submit.php +1 -1
  45. embedded/common/toolset-forms/classes/class.taxonomy.php +1 -1
  46. embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php +1 -1
  47. embedded/common/toolset-forms/classes/class.textarea.php +1 -1
  48. embedded/common/toolset-forms/classes/class.textfield.php +1 -1
  49. embedded/common/toolset-forms/classes/class.types.php +1 -1
  50. embedded/common/toolset-forms/classes/class.validation.php +17 -17
  51. embedded/common/toolset-forms/classes/class.video.php +1 -1
  52. embedded/common/toolset-forms/classes/class.wysiwyg.php +1 -1
  53. embedded/common/toolset-forms/external/autocompleter.php +1 -1
  54. embedded/common/toolset-forms/js/colorpicker.js +1 -0
  55. embedded/common/toolset-forms/js/conditional.js +431 -402
  56. embedded/common/toolset-forms/js/date.js +7 -1
  57. embedded/common/toolset-forms/js/file.js +1 -1
  58. embedded/common/toolset-forms/js/main.js +69 -73
  59. embedded/common/toolset-forms/js/repetitive.js +1 -1
  60. embedded/common/toolset-forms/js/validation.js +25 -5
  61. embedded/common/toolset-forms/lib/CakePHP-Validation.php +12 -1
  62. embedded/common/toolset-forms/readme.txt +6 -0
  63. embedded/common/toolset-forms/templates/metaform-item.php +1 -1
  64. embedded/common/toolset-forms/templates/metaform.php +1 -1
  65. embedded/common/utility/css/notifications.css +344 -0
  66. embedded/common/utility/css/select2/select2-overrides.css +26 -0
  67. embedded/common/utility/css/select2/select2-spinner.gif +0 -0
  68. embedded/common/utility/css/select2/select2.css +611 -0
  69. embedded/common/utility/css/select2/select2.png +0 -0
  70. embedded/common/utility/css/select2/select2x2.png +0 -0
  71. embedded/common/utility/img/icon-help-message.png +0 -0
  72. embedded/common/utility/js/select2.min.js +22 -0
  73. embedded/common/utility/js/utils.js +946 -0
  74. embedded/common/utility/utils.php +111 -0
  75. embedded/common/visual-editor/editor-addon-generic.class.php +56 -13
  76. embedded/common/visual-editor/editor-addon.class.php +7 -27
  77. embedded/common/visual-editor/res/js/icl_editor_addon_plugin.js +130 -22
  78. embedded/common/visual-editor/res/js/icl_media_manager.js +260 -0
  79. embedded/frontend.php +14 -20
  80. embedded/functions.php +738 -713
  81. embedded/includes/ajax.php +3 -3
  82. embedded/includes/custom-types.php +1 -1
  83. embedded/includes/fields-post.php +1 -1
  84. embedded/includes/fields/audio.php +1 -1
  85. embedded/includes/fields/checkbox.php +1 -1
  86. embedded/includes/fields/file.php +1 -1
  87. embedded/includes/fields/image.php +10 -7
  88. embedded/includes/fields/skype.php +1 -1
  89. embedded/includes/fields/textarea.php +1 -1
  90. embedded/includes/fields/video.php +1 -1
  91. embedded/includes/import-export.php +1 -1
  92. embedded/includes/module-manager.php +1 -1
  93. embedded/includes/post-relationship.php +20 -17
  94. embedded/includes/usermeta-post.php +2 -1
  95. embedded/includes/wpml.php +19 -14
  96. embedded/onthego-resources/loader.php +84 -0
  97. embedded/onthego-resources/readme.txt +0 -11
  98. embedded/plugin.php +62 -0
  99. embedded/resources/css/basic.css +108 -3
  100. embedded/resources/css/dashicons.css +1 -1
  101. embedded/resources/images/types-toolset-component.png +0 -0
  102. embedded/resources/js/basic.js +20 -5
  103. embedded/resources/js/custom-fields-form-filter.js +178 -75
  104. embedded/resources/js/editor.js +1 -0
  105. embedded/resources/js/fields-form.js +1 -1
  106. embedded/resources/js/jquery-form-validation/jquery.validate-1.11.1.min.js +0 -2
  107. embedded/resources/js/modal.js +152 -0
  108. embedded/resources/js/post-relationship.js +12 -0
  109. embedded/usermeta-init.php +1 -1
  110. help.php +1 -1
  111. includes/ajax.php +18 -16
  112. includes/common-functions.php +68 -0
  113. includes/custom-taxonomies-form.php +411 -238
  114. includes/custom-types-form.php +573 -418
  115. includes/fields-control.php +10 -5
  116. includes/fields-form.php +14 -30
  117. includes/fields-list.php +19 -6
  118. includes/fields.php +1 -1
  119. includes/import-export.php +1 -1
  120. includes/introduction.php +0 -41
  121. includes/migration.php +1 -1
  122. includes/post-relationship.php +30 -15
  123. includes/settings.php +20 -3
  124. includes/usermeta-control.php +10 -5
  125. includes/usermeta-form.php +9 -13
  126. marketing.php +0 -10
  127. marketing/assets/images/access.png +0 -0
  128. marketing/assets/images/cred.png +0 -0
  129. marketing/assets/images/views.png +0 -0
  130. marketing/assets/images/wait.gif +0 -0
  131. marketing/congrats-post-types/index.php +51 -74
  132. marketing/congrats-post-types/style.css +42 -1
  133. marketing/etc/types-site-kinds.php +36 -0
  134. marketing/etc/types.php +168 -0
  135. marketing/getting-started/assets/css/getting-started.css +156 -0
  136. marketing/getting-started/assets/images/arrow.png +0 -0
  137. marketing/getting-started/assets/scripts/getting-started.js +46 -0
  138. marketing/getting-started/index.php +32 -0
  139. marketing/types_marketing_message_survey_2014_09.php +0 -105
  140. marketing/types_marketing_message_survey_2014_09_admin_notice.js +0 -24
  141. plus/installer/changelog.txt +44 -0
  142. plus/installer/includes/deps-loader.class.php +557 -0
  143. plus/installer/includes/installer-api.php +25 -0
  144. {embedded/common → plus}/installer/includes/installer-upgrader-skins.php +4 -0
  145. {embedded/common → plus}/installer/includes/installer.class.php +435 -102
  146. {embedded/common → plus}/installer/installer.php +3 -1
  147. {embedded/common → plus}/installer/loader.php +7 -8
  148. {embedded/common → plus}/installer/repositories.xml +0 -0
  149. {embedded/common → plus}/installer/res/css/admin.css +13 -0
  150. {embedded/common → plus}/installer/res/img/complete.png +0 -0
  151. {embedded/common → plus}/installer/res/img/computer.png +0 -0
  152. {embedded/common → plus}/installer/res/img/dn.gif +0 -0
  153. {embedded/common → plus}/installer/res/img/dn2.gif +0 -0
  154. {embedded/common → plus}/installer/res/img/globe.png +0 -0
  155. {embedded/common → plus}/installer/res/img/icon_error.gif +0 -0
  156. {embedded/common → plus}/installer/res/img/on.png +0 -0
  157. {embedded/common → plus}/installer/res/js/admin.js +65 -6
  158. {embedded/common → plus}/installer/res/js/iframeResizer.min.js +0 -0
  159. {embedded/common → plus}/installer/templates/downloads-list-compact.php +21 -4
  160. {embedded/common → plus}/installer/templates/downloads-list.php +22 -6
  161. {embedded/common → plus}/installer/templates/products-compact.php +3 -2
  162. {embedded/common → plus}/installer/templates/repository-listing.php +13 -14
  163. plus/types-access.php +34 -13
  164. readme.txt +26 -10
  165. resources/js/basic.js +22 -7
  166. resources/js/custom-types-form.js +1 -1
  167. wpcf.php +72 -95
admin.php CHANGED
@@ -1,223 +1,185 @@
1
- <?php
2
- /**
3
- *
4
- * Admin functions
5
- *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/admin.php $
7
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
- * $LastChangedRevision: 1027712 $
9
- * $LastChangedBy: iworks $
10
- *
11
- */
12
- require_once WPCF_ABSPATH . '/marketing.php';
13
- /*
14
- * This needs to be called after main 'init' hook.
15
- * Main init hook calls required Types code for frontend.
16
- * Admin init hook only in admin area.
17
- *
18
- * TODO Revise it to change to 'admin_init'
19
- */
20
- add_action( 'admin_init', 'wpcf_admin_init_hook', 11 );
21
- add_action( 'admin_menu', 'wpcf_admin_menu_hook' );
22
- add_action( 'wpcf_admin_page_init', 'wpcf_enqueue_scripts' );
23
-
24
- wpcf_admin_load_teasers( array('types-access.php') );
25
- if ( defined( 'DOING_AJAX' ) ) {
26
- require_once WPCF_INC_ABSPATH . '/ajax.php';
27
- }
28
-
29
- /**
30
- * admin_init hook.
31
- */
32
- function wpcf_admin_init_hook() {
33
- wpcf_types_plugin_redirect();
34
- wp_enqueue_style( 'wpcf-promo-tabs',
35
- WPCF_EMBEDDED_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION );
36
- /* wp_enqueue_style('wpcf-promo-tabs',
37
- WPCF_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION); */
38
- wp_enqueue_style('toolset-dashicons');
39
- types_marketing_message_survey_2014_09_helper();
40
- }
41
-
42
- /**
43
- * admin_menu hook.
44
- */
45
- function wpcf_admin_menu_hook()
46
- {
47
- $wpcf_capability = apply_filters( 'wpcf_capability', 'manage_options' );
48
-
49
- add_menu_page(
50
- __( 'Types', 'wpcf' ),
51
- __( 'Types', 'wpcf' ),
52
- $wpcf_capability,
53
- 'wpcf',
54
- 'wpcf_admin_menu_summary',
55
- 'none'
56
- );
57
-
58
- $subpages = array(
59
-
60
- // Custom types and tax
61
- 'wpcf-ctt' => array(
62
- 'page_title' => __( 'Custom Types and Taxonomies', 'wpcf' ),
63
- 'menu_title' => __( 'Types &amp; Taxonomies', 'wpcf' ),
64
- 'function' => 'wpcf_admin_menu_summary_ctt',
65
- ),
66
-
67
- // Custom fields
68
- 'wpcf-cf' => array(
69
- 'page_title' => __( 'Custom Fields', 'wpcf' ),
70
- 'menu_title' => __( 'Custom Fields', 'wpcf' ),
71
- 'function' => 'wpcf_admin_menu_summary',
72
- ),
73
- // Custom Fields Control
74
- 'wpcf-custom-fields-control' => array(
75
- 'page_title' => __( 'Custom Fields Control', 'wpcf' ),
76
- 'menu_title' => __( 'Custom Fields Control', 'wpcf' ),
77
- 'function' => 'wpcf_admin_menu_custom_fields_control',
78
- ),
79
- // User Meta
80
- 'wpcf-um' => array(
81
- 'page_title' => __( 'User Fields', 'wpcf' ),
82
- 'menu_title' => __( 'User Fields', 'wpcf' ),
83
- 'function' => 'wpcf_usermeta_summary',
84
- 'load-hook' => 'wpcf_admin_menu_summary_hook',
85
- ),
86
- // User Fields Control
87
- 'wpcf-user-fields-control' => array(
88
- 'page_title' => __( 'User Fields Control', 'wpcf' ),
89
- 'menu_title' => __( 'User Fields Control', 'wpcf' ),
90
- 'function' => 'wpcf_admin_menu_user_fields_control',
91
- ),
92
-
93
- // Import/Export
94
- 'wpcf-import-export' => array(
95
- 'page_title' => __( 'Import/Export', 'wpcf' ),
96
- 'menu_title' => __( 'Import/Export', 'wpcf' ),
97
- 'function' => 'wpcf_admin_menu_import_export',
98
- ),
99
- // Settings
100
- 'wpcf-custom-settings' => array(
101
- 'page_title' => __( 'Settings', 'wpcf' ),
102
- 'menu_title' => __( 'Settings', 'wpcf' ),
103
- 'function' => 'wpcf_admin_menu_settings',
104
- ),
105
-
106
- // Introduction
107
- 'wpcf-help' => array(
108
- 'page_title' => __( 'Help', 'wpcf' ),
109
- 'menu_title' => __( 'Help', 'wpcf' ),
110
- 'function' => 'wpcf_admin_menu_introduction',
111
- 'submenu' => array(
112
- 'wpcf-debug-information' => array(
113
- 'page_title' => __( 'Debug information', 'wpcf' ),
114
- 'menu_title' => __( 'Debug information', 'wpcf' ),
115
- 'function' => 'wpcf_admin_menu_debug_information',
116
- ),
 
117
  ),
118
  ),
119
-
120
  );
121
 
122
- foreach( $subpages as $menu_slug => $data ) {
123
- $hook = add_submenu_page(
124
- 'wpcf',
125
- $data['page_title'],
126
- $data['menu_title'],
127
- $wpcf_capability,
128
- $menu_slug,
129
- $data['function']
130
- );
131
- if ( array_key_exists('submenu', $data ) ) {
132
- foreach( $data['submenu'] as $submenu_slug => $submenu ) {
133
- add_submenu_page(
134
- $hook,
135
- $submenu['page_title'],
136
- $submenu['menu_title'],
137
- $wpcf_capability,
138
- $submenu_slug,
139
- $submenu['function']
140
- );
141
- }
142
- }
143
- if ( !array_key_exists('load-hook', $data ) ) {
144
- $data['load-hook'] = sprintf( '%s_hook', $data['function'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  }
146
- wpcf_admin_plugin_help( $hook, $menu_slug );
147
- add_action( 'load-' . $hook, $data['load-hook'] );
148
- }
149
-
150
- if ( isset( $_GET['page'] ) ) {
151
- switch ( $_GET['page'] ) {
152
- case 'wpcf-edit':
153
- $title = isset( $_GET['group_id'] ) ? __( 'Edit Group', 'wpcf' ) : __( 'Add New Group',
154
- 'wpcf' );
155
- $hook = add_submenu_page( 'wpcf', $title, $title,
156
- 'manage_options', 'wpcf-edit',
157
- 'wpcf_admin_menu_edit_fields' );
158
- add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_fields_hook' );
159
- wpcf_admin_plugin_help( $hook, 'wpcf-edit' );
160
- break;
161
-
162
- case 'wpcf-edit-type':
163
- $title = isset( $_GET['wpcf-post-type'] ) ? __( 'Edit Custom Post Type',
164
- 'wpcf' ) : __( 'Add New Custom Post Type',
165
- 'wpcf' );
166
- $hook = add_submenu_page( 'wpcf', $title, $title,
167
- 'manage_options', 'wpcf-edit-type',
168
- 'wpcf_admin_menu_edit_type' );
169
- add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_type_hook' );
170
- wpcf_admin_plugin_help( $hook, 'wpcf-edit-type' );
171
- break;
172
-
173
- case 'wpcf-edit-tax':
174
- $title = isset( $_GET['wpcf-tax'] ) ? __( 'Edit Taxonomy',
175
- 'wpcf' ) : __( 'Add New Taxonomy', 'wpcf' );
176
- $hook = add_submenu_page( 'wpcf', $title, $title,
177
- 'manage_options', 'wpcf-edit-tax',
178
- 'wpcf_admin_menu_edit_tax' );
179
- add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_tax_hook' );
180
- wpcf_admin_plugin_help( $hook, 'wpcf-edit-tax' );
181
- break;
182
- case 'wpcf-edit-usermeta':
183
- $title = isset( $_GET['group_id'] ) ? __( 'Edit User Fields Group', 'wpcf' ) : __( 'Add New User Fields Group',
184
- 'wpcf' );
185
- $hook = add_submenu_page( 'wpcf', $title, $title,
186
- 'manage_options', 'wpcf-edit-usermeta',
187
- 'wpcf_admin_menu_edit_user_fields' );
188
- add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_user_fields_hook' );
189
- wpcf_admin_plugin_help( $hook, 'wpcf-edit-usermeta' );
190
- break;
191
- }
192
- }
193
-
194
- // Check if migration from other plugin is needed
195
- if ( class_exists( 'Acf' ) || defined( 'CPT_VERSION' ) ) {
196
- $hook = add_submenu_page( 'wpcf', __( 'Migration', 'wpcf' ),
197
- __( 'Migration', 'wpcf' ), 'manage_options', 'wpcf-migration',
198
- 'wpcf_admin_menu_migration' );
199
- add_action( 'load-' . $hook, 'wpcf_admin_menu_migration_hook' );
200
- wpcf_admin_plugin_help( $hook, 'wpcf-migration' );
201
- }
202
-
203
- do_action( 'wpcf_menu_plus' );
204
-
205
- // remove the repeating Types submenu
206
- remove_submenu_page( 'wpcf', 'wpcf' );
207
- }
208
-
209
- /**
210
- * Menu page hook.
211
- */
212
- function wpcf_admin_menu_introduction_hook() {
213
- do_action( 'wpcf_admin_page_init' );
214
- }
215
-
216
- /**
217
- * Menu page display.
218
- */
219
- function wpcf_admin_menu_introduction() {
220
- require_once WPCF_INC_ABSPATH . '/introduction.php';
221
  }
222
 
223
  /**
@@ -231,769 +193,875 @@ function wpcf_admin_menu_debug_information()
231
  /**
232
  * Menu page hook.
233
  */
234
- function wpcf_admin_menu_summary_hook() {
235
- do_action( 'wpcf_admin_page_init' );
236
- wpcf_admin_load_collapsible();
237
- }
238
-
239
- /**
240
- * Menu page display.
241
- */
242
- function wpcf_admin_menu_summary() {
243
- echo wpcf_add_admin_header( __( 'Custom Fields', 'wpcf' ) );
244
- require_once WPCF_INC_ABSPATH . '/fields.php';
245
- require_once WPCF_INC_ABSPATH . '/fields-list.php';
246
- $to_display = wpcf_admin_fields_get_fields();
247
- if ( !empty( $to_display ) ) {
248
- add_action( 'wpcf_groups_list_table_after',
249
- 'wpcf_admin_promotional_text' );
250
- }
251
- wpcf_admin_fields_list();
252
- echo wpcf_add_admin_footer();
253
- }
254
-
255
- /**
256
- * Menu page hook.
257
- */
258
- function wpcf_admin_menu_edit_fields_hook() {
259
- do_action( 'wpcf_admin_page_init' );
260
-
261
- /*
262
- * Enqueue scripts
263
- */
264
- // Group filter
265
- wp_enqueue_script( 'wpcf-filter-js',
266
- WPCF_EMBEDDED_RES_RELPATH
267
- . '/js/custom-fields-form-filter.js', array('jquery'), WPCF_VERSION );
268
- // Form
269
- wp_enqueue_script( 'wpcf-form-validation',
270
- WPCF_EMBEDDED_RES_RELPATH . '/js/'
271
- . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
272
- WPCF_VERSION );
273
- wp_enqueue_script( 'wpcf-form-validation-additional',
274
- WPCF_EMBEDDED_RES_RELPATH . '/js/'
275
- . 'jquery-form-validation/additional-methods.min.js',
276
- array('jquery'), WPCF_VERSION );
277
- // Scroll
278
- wp_enqueue_script( 'wpcf-scrollbar',
279
- WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/scrollbar.js',
280
- array('jquery') );
281
- wp_enqueue_script( 'wpcf-mousewheel',
282
- WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/mousewheel.js',
283
- array('wpcf-scrollbar') );
284
- // MAIN
285
- wp_enqueue_script( 'wpcf-fields-form',
286
- WPCF_EMBEDDED_RES_RELPATH
287
- . '/js/fields-form.js', array('wpcf-js') );
288
-
289
- /*
290
- * Enqueue styles
291
- */
292
- wp_enqueue_style( 'wpcf-scroll',
293
- WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/css/scroll.css' );
294
-
295
- //Css editor
296
- wp_enqueue_script( 'wpcf-form-codemirror' ,
297
- WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.js', array('wpcf-js'));
298
- wp_enqueue_script( 'wpcf-form-codemirror-css-editor' ,
299
- WPCF_RELPATH . '/resources/js/codemirror234/mode/css/css.js', array('wpcf-js'));
300
- wp_enqueue_script( 'wpcf-form-codemirror-html-editor' ,
301
- WPCF_RELPATH . '/resources/js/codemirror234/mode/xml/xml.js', array('wpcf-js'));
302
- wp_enqueue_script( 'wpcf-form-codemirror-html-editor2' ,
303
- WPCF_RELPATH . '/resources/js/codemirror234/mode/htmlmixed/htmlmixed.js', array('wpcf-js'));
304
- wp_enqueue_script( 'wpcf-form-codemirror-editor-resize' ,
305
- WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.resizable.min.js', array('wpcf-js'));
306
-
307
-
308
-
309
- wp_enqueue_style( 'wpcf-css-editor',
310
- WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.css' );
311
- wp_enqueue_style( 'wpcf-css-editor-resize',
312
- WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.theme.min.css' );
313
- wp_enqueue_style( 'wpcf-usermeta',
314
- WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css' );
315
-
316
- add_action( 'admin_footer', 'wpcf_admin_fields_form_js_validation' );
317
- require_once WPCF_INC_ABSPATH . '/fields.php';
318
- require_once WPCF_INC_ABSPATH . '/fields-form.php';
319
- $form = wpcf_admin_fields_form();
320
- wpcf_form( 'wpcf_form_fields', $form );
321
- }
322
-
323
- /**
324
- * Menu page display.
325
- */
326
- function wpcf_admin_menu_edit_fields() {
327
- if ( isset( $_GET['group_id'] ) ) {
328
- $title = __( 'Edit Group', 'wpcf' );
329
- } else {
330
- $title = __( 'Add New Group', 'wpcf' );
331
- }
332
- echo wpcf_add_admin_header( $title );
333
- wpcf_wpml_warning();
334
- $form = wpcf_form( 'wpcf_form_fields' );
335
-
336
- ?>
337
- <script type="text/javascript">
338
- function wpcf_group_submit() {
339
- if (jQuery('#wpcf-group-name').val() == '<?php _e('Enter group title', 'wpcf'); ?>') {
340
- jQuery('#wpcf-group-name').val('');
341
- }
342
- if (jQuery('#wpcf-group-description').val() == '<?php _e('Enter a description for this group', 'wpcf'); ?>') {
343
- jQuery('#wpcf-group-description').val('');
344
- }
345
- jQuery('.wpcf-forms-set-legend').each(function(){
346
- if (jQuery(this).val() == '<?php _e('Enter field name', 'wpcf'); ?>') {
347
- jQuery(this).val('');
348
- }
349
- if (jQuery(this).next().val() == '<?php _e('Enter field slug', 'wpcf'); ?>') {
350
- jQuery(this).next().val('');
351
- }
352
- if (jQuery(this).next().next().val() == '<?php _e('Describe this field', 'wpcf'); ?>') {
353
- jQuery(this).next().next().val('');
354
- }
355
- });
356
- }
357
- </script>
358
-
359
- <br /><form method="post" action="" class="wpcf-fields-form wpcf-form-validate" onsubmit="wpcf_group_submit()">
360
- <?php echo $form->renderForm(); ?>
361
- </form>
362
- <?php
363
- echo wpcf_add_admin_footer();
364
- }
365
-
366
- /**
367
- * Menu page hook.
368
- */
369
- function wpcf_admin_menu_summary_ctt_hook() {
370
- do_action( 'wpcf_admin_page_init' );
371
- wp_enqueue_style( 'wpcf-promo-tabs', WPCF_RES_RELPATH . '/css/tabs.css',
372
- array(), WPCF_VERSION );
373
- wpcf_admin_load_collapsible();
374
- require_once WPCF_INC_ABSPATH . '/custom-types.php';
375
- require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
376
- require_once WPCF_INC_ABSPATH . '/custom-types-taxonomies-list.php';
377
- }
378
-
379
- /**
380
- * Menu page display.
381
- */
382
- function wpcf_admin_menu_summary_ctt() {
383
- echo wpcf_add_admin_header( __( 'Custom Post Types and Taxonomies', 'wpcf' ) );
384
- $to_display_posts = get_option( 'wpcf-custom-types', array() );
385
- $to_display_tax = get_option( 'wpcf-custom-taxonomies', array() );
386
- if ( !empty( $to_display_posts ) || !empty( $to_display_tax ) ) {
387
- add_action( 'wpcf_types_tax_list_table_after',
388
- 'wpcf_admin_promotional_text' );
389
- }
390
- wpcf_admin_ctt_list();
391
- echo wpcf_add_admin_footer();
392
- }
393
-
394
- /**
395
- * Menu page hook.
396
- */
397
- function wpcf_admin_menu_edit_type_hook() {
398
- do_action( 'wpcf_admin_page_init' );
399
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-types.php';
400
- require_once WPCF_INC_ABSPATH . '/custom-types-form.php';
401
- require_once WPCF_INC_ABSPATH . '/post-relationship.php';
402
- wp_enqueue_script( 'wpcf-custom-types-form',
403
- WPCF_RES_RELPATH . '/js/'
404
- . 'custom-types-form.js', array('jquery'), WPCF_VERSION );
405
- wp_enqueue_script( 'wpcf-form-validation',
406
- WPCF_RES_RELPATH . '/js/'
407
- . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
408
- WPCF_VERSION );
409
- wp_enqueue_script( 'wpcf-form-validation-additional',
410
- WPCF_RES_RELPATH . '/js/'
411
- . 'jquery-form-validation/additional-methods.min.js',
412
- array('jquery'), WPCF_VERSION );
413
- add_action( 'admin_footer', 'wpcf_admin_types_form_js_validation' );
414
- wpcf_post_relationship_init();
415
- $form = wpcf_admin_custom_types_form();
416
- wpcf_form( 'wpcf_form_types', $form );
417
- }
418
-
419
- /**
420
- * Menu page display.
421
- */
422
- function wpcf_admin_menu_edit_type() {
423
- if ( isset( $_GET['wpcf-post-type'] ) ) {
424
- $title = __( 'Edit Custom Post Type', 'wpcf' );
425
- } else {
426
- $title = __( 'Add New Custom Post Type', 'wpcf' );
427
- }
428
- echo wpcf_add_admin_header( $title );
429
- wpcf_wpml_warning();
430
- $form = wpcf_form( 'wpcf_form_types' );
431
- echo '<br /><form method="post" action="" class="wpcf-types-form '
432
- . 'wpcf-form-validate">';
433
- echo $form->renderForm();
434
- echo '</form>';
435
- echo wpcf_add_admin_footer();
436
- }
437
-
438
- /**
439
- * Menu page hook.
440
- */
441
- function wpcf_admin_menu_edit_tax_hook() {
442
- do_action( 'wpcf_admin_page_init' );
443
- wp_enqueue_script( 'wpcf-form-validation',
444
- WPCF_RES_RELPATH . '/js/'
445
- . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
446
- WPCF_VERSION );
447
- wp_enqueue_script( 'wpcf-form-validation-additional',
448
- WPCF_RES_RELPATH . '/js/'
449
- . 'jquery-form-validation/additional-methods.min.js',
450
- array('jquery'), WPCF_VERSION );
451
- add_action( 'admin_footer', 'wpcf_admin_tax_form_js_validation' );
452
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
453
- require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
454
- $form = wpcf_admin_custom_taxonomies_form();
455
- wpcf_form( 'wpcf_form_tax', $form );
456
- }
457
-
458
- /**
459
- * Menu page display.
460
- */
461
- function wpcf_admin_menu_edit_tax() {
462
- if ( isset( $_GET['wpcf-tax'] ) ) {
463
- $title = __( 'Edit Taxonomy', 'wpcf' );
464
- } else {
465
- $title = __( 'Add New Taxonomy', 'wpcf' );
466
- }
467
- echo wpcf_add_admin_header( $title );
468
- wpcf_wpml_warning();
469
- $form = wpcf_form( 'wpcf_form_tax' );
470
- echo '<br /><form method="post" action="" class="wpcf-tax-form '
471
- . 'wpcf-form-validate">';
472
- echo $form->renderForm();
473
- echo '</form>';
474
- echo wpcf_add_admin_footer();
475
- }
476
-
477
- /**
478
- * Menu page hook.
479
- */
480
- function wpcf_admin_menu_import_export_hook() {
481
- do_action( 'wpcf_admin_page_init' );
482
- require_once WPCF_INC_ABSPATH . '/fields.php';
483
- require_once WPCF_INC_ABSPATH . '/import-export.php';
484
- if ( extension_loaded( 'simplexml' ) && isset( $_POST['export'] )
485
- && wp_verify_nonce( $_POST['_wpnonce'], 'wpcf_import' ) ) {
486
- wpcf_admin_export_data();
487
- die();
488
- }
489
- }
490
-
491
- /**
492
- * Menu page display.
493
- */
494
- function wpcf_admin_menu_import_export() {
495
- echo wpcf_add_admin_header( __( 'Import/Export', 'wpcf' ) );
496
- echo '<br /><form method="post" action="" class="wpcf-import-export-form '
497
- . 'wpcf-form-validate" enctype="multipart/form-data">';
498
- echo wpcf_form_simple( wpcf_admin_import_export_form() );
499
- echo '</form>';
500
- echo wpcf_add_admin_footer();
501
- }
502
-
503
- /**
504
- * Menu page hook.
505
- */
506
- function wpcf_admin_menu_custom_fields_control_hook() {
507
- do_action( 'wpcf_admin_page_init' );
508
- add_action( 'admin_head', 'wpcf_admin_custom_fields_control_js' );
509
- add_thickbox();
510
- require_once WPCF_INC_ABSPATH . '/fields.php';
511
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
512
- require_once WPCF_INC_ABSPATH . '/fields-control.php';
513
-
514
- if ( isset( $_REQUEST['_wpnonce'] )
515
- && wp_verify_nonce( $_REQUEST['_wpnonce'],
516
- 'custom_fields_control_bulk' )
517
- && (isset( $_POST['action'] ) || isset( $_POST['action2'] )) && !empty( $_POST['fields'] ) ) {
518
- $action = $_POST['action'] == '-1' ? $_POST['action2'] : $_POST['action'];
519
- wpcf_admin_custom_fields_control_bulk_actions( $action );
520
- }
521
-
522
- global $wpcf_control_table;
523
- $wpcf_control_table = new WPCF_Custom_Fields_Control_Table( array(
524
- 'ajax' => true,
525
- 'singular' => __( 'Custom Field', 'wpcf' ),
526
- 'plural' => __( 'Custom Fields', 'wpcf' ),
527
- ) );
528
- $wpcf_control_table->prepare_items();
529
- }
530
-
531
- /**
532
- * Menu page display.
533
- */
534
- function wpcf_admin_menu_custom_fields_control() {
535
- global $wpcf_control_table;
536
- echo wpcf_add_admin_header( __( 'Custom Fields Control', 'wpcf' ) );
537
- echo '<form method="post" action="" id="wpcf-custom-fields-control-form" class="wpcf-custom-fields-control-form '
538
- . 'wpcf-form-validate" enctype="multipart/form-data">';
539
- echo wpcf_admin_custom_fields_control_form( $wpcf_control_table );
540
- wp_nonce_field( 'custom_fields_control_bulk' );
541
- echo '</form>';
542
- echo wpcf_add_admin_footer();
543
- }
544
-
545
- /**
546
- * Menu page hook.
547
- */
548
- function wpcf_admin_menu_migration_hook() {
549
- do_action( 'wpcf_admin_page_init' );
550
- require_once WPCF_INC_ABSPATH . '/fields.php';
551
- require_once WPCF_INC_ABSPATH . '/custom-types.php';
552
- require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
553
- require_once WPCF_INC_ABSPATH . '/migration.php';
554
- $form = wpcf_admin_migration_form();
555
- wpcf_form( 'wpcf_form_migration', $form );
556
- }
557
-
558
- /**
559
- * Menu page display.
560
- */
561
- function wpcf_admin_menu_migration() {
562
- echo wpcf_add_admin_header( __( 'Migration', 'wpcf' ) );
563
- echo '<br /><form method="post" action="" id="wpcf-migration-form" class="wpcf-migration-form '
564
- . 'wpcf-form-validate" enctype="multipart/form-data">';
565
- $form = wpcf_form( 'wpcf_form_migration' );
566
- echo $form->renderForm();
567
- echo '</form>';
568
- echo wpcf_add_admin_footer();
569
- }
570
-
571
- /**
572
- * Menu page hook.
573
- */
574
- function wpcf_admin_menu_settings_hook() {
575
- do_action( 'wpcf_admin_page_init' );
576
- require_once WPCF_INC_ABSPATH . '/settings.php';
577
- $form = wpcf_admin_image_settings_form();
578
- wpcf_form( 'wpcf_form_image_settings', $form );
579
- $form = wpcf_admin_general_settings_form();
580
- wpcf_form( 'wpcf_form_general_settings', $form );
581
- }
582
-
583
- /**
584
- * Menu page display.
585
- */
586
- function wpcf_admin_menu_settings() {
587
- ob_start();
588
- echo wpcf_add_admin_header( __( 'Settings', 'wpcf' ) );
589
-
590
- ?>
591
- <p style="font-weight: bold;"><?php
592
- _e( 'This screen contains the Types settings for your site.', 'wpcf' );
593
-
594
- ?></p>
595
- <ul class="horlist">
596
- <li><a href="#types-image-settings"><?php
597
- _e( 'Image Settings', 'wpcf' );
598
-
599
- ?></a></li>
600
- <li><a href="#types-general-settings"><?php
601
- _e( 'General Setings', 'wpcf' );
602
-
603
- ?></a></li>
604
- </ul>
605
- <br style='clear:both'/><br /><br />
606
- <a id="types-image-settings"></a>
607
- <table class="widefat" id="types_image_settings_table">
608
- <thead>
609
- <tr>
610
- <th><?php
611
- _e( 'Image Settings', 'wpcf' );
612
-
613
- ?></th>
614
- </tr>
615
- </thead>
616
- <tbody>
617
- <tr>
618
- <td>
619
- <?php
620
- echo '<br /><form method="post" action="" id="wpcf-image-settings-form" class="wpcf-settings-form '
621
- . 'wpcf-form-validate">';
622
- $form = wpcf_form( 'wpcf_form_image_settings' );
623
- echo $form->renderForm();
624
- echo '</form>';
625
-
626
- ?>
627
- </td>
628
- </tr>
629
- </tbody>
630
- </table>
631
- <br /><br />
632
- <a id="types-general-settings"></a>
633
- <table class="widefat" id="types_general_settings_table">
634
- <thead>
635
- <tr>
636
- <th><?php
637
- _e( 'General Settings', 'wpcf' );
638
-
639
- ?></th>
640
- </tr>
641
- </thead>
642
- <tbody>
643
- <tr>
644
- <td>
645
- <?php
646
- echo '<br /><form method="post" action="" id="wpcf-general-settings-form" class="wpcf-settings-form '
647
- . 'wpcf-form-validate">';
648
- $form = wpcf_form( 'wpcf_form_general_settings' );
649
- echo $form->renderForm();
650
- echo '</form>';
651
-
652
- ?>
653
- </td>
654
- </tr>
655
- </tbody>
656
- </table>
657
- <?php
658
- echo wpcf_add_admin_footer();
659
-
660
- echo ob_get_clean();
661
- }
662
-
663
- /**
664
- * Adds typical header on admin pages.
665
- *
666
- * @param string $title
667
- * @param string $icon_id Custom icon
668
- * @return string
669
- */
670
- function wpcf_add_admin_header( $title, $icon_id = 'icon-wpcf' )
671
- {
672
- global $wp_version;
673
- if ( version_compare( '3.8', $wp_version ) ) {
674
- echo PHP_EOL;
675
- printf('<div class="wrap"><div id="%s" class="icon32"><br /></div>', $icon_id );
676
- }
677
- printf('<h2>%s</h2>', $title );
678
- do_action( 'wpcf_admin_header' );
679
- do_action( 'wpcf_admin_header_' . $_GET['page'] );
680
- }
681
-
682
- /**
683
- * Adds footer on admin pages.
684
- *
685
- * <b>Strongly recomended</b> if wpcf_add_admin_header() is called before.
686
- * Otherwise invalid HTML formatting will occur.
687
- */
688
- function wpcf_add_admin_footer() {
689
- do_action( 'wpcf_admin_footer_' . $_GET['page'] );
690
- do_action( 'wpcf_admin_footer' );
691
- echo "\r\n" . '</div>' . "\r\n";
692
- }
693
-
694
- /**
695
- * Returns HTML formatted 'widefat' table.
696
- *
697
- * @param type $ID
698
- * @param type $header
699
- * @param type $rows
700
- * @param type $empty_message
701
- */
702
- function wpcf_admin_widefat_table( $ID, $header, $rows = array(),
703
- $empty_message = 'No results' ) {
704
- $head = '';
705
- $footer = '';
706
- foreach ( $header as $key => $value ) {
707
- $head .= '<th id="wpcf-table-' . $key . '">' . $value . '</th>' . "\r\n";
708
- $footer .= '<th>' . $value . '</th>' . "\r\n";
709
- }
710
- echo '<table id="' . $ID . '" class="widefat" cellspacing="0">
711
- <thead>
712
- <tr>
713
- ' . $head . '
714
- </tr>
715
- </thead>
716
- <tfoot>
717
- <tr>
718
- ' . $footer . '
719
- </tr>
720
- </tfoot>
721
- <tbody>
722
- ';
723
- $row = '';
724
- if ( empty( $rows ) ) {
725
- echo '<tr><td colspan="' . count( $header ) . '">' . $empty_message
726
- . '</td></tr>';
727
- } else {
728
- foreach ( $rows as $row ) {
729
- echo '<tr>';
730
- foreach ( $row as $column_name => $column_value ) {
731
- echo '<td class="wpcf-table-column-' . $column_name . '">';
732
- echo $column_value;
733
- echo '</td>' . "\r\n";
734
- }
735
- echo '</tr>' . "\r\n";
736
- }
737
- }
738
- echo '
739
- </tbody>
740
- </table>' . "\r\n";
741
- }
742
-
743
- /**
744
- * Admin tabs.
745
- *
746
- * @param type $tabs
747
- * @param type $page
748
- * @param type $default
749
- * @param type $current
750
- * @return string
751
- */
752
- function wpcf_admin_tabs( $tabs, $page, $default = '', $current = '' ) {
753
- if ( empty( $current ) && isset( $_GET['tab'] ) ) {
754
- $current = $_GET['tab'];
755
- } else {
756
- $current = $default;
757
- }
758
- $output = '<h2 class="nav-tab-wrapper">';
759
- foreach ( $tabs as $tab => $name ) {
760
- $class = ( $tab == $current ) ? ' nav-tab-active' : '';
761
- $output .= "<a class='nav-tab$class' href='?page=$page&tab=$tab'>$name</a>";
762
- }
763
- $output .= '</h2>';
764
- return $output;
765
- }
766
-
767
- /**
768
- * Saves open fieldsets.
769
- *
770
- * @param type $action
771
- * @param type $fieldset
772
- */
773
- function wpcf_admin_form_fieldset_save_toggle( $action, $fieldset ) {
774
- $data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
775
- true );
776
- if ( $action == 'open' ) {
777
- $data[$fieldset] = 1;
778
- } else if ( $action == 'close' ) {
779
- unset( $data[$fieldset] );
780
- }
781
- update_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle', $data );
782
- }
783
-
784
- /**
785
- * Check if fieldset is saved as open.
786
- *
787
- * @param type $fieldset
788
- */
789
- function wpcf_admin_form_fieldset_is_collapsed( $fieldset ) {
790
- $data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
791
- true );
792
- if ( empty( $data ) ) {
793
- return true;
794
- }
795
- return array_key_exists( $fieldset, $data ) ? false : true;
796
- }
797
-
798
- /**
799
- * Adds help on admin pages.
800
- *
801
- * @param type $contextual_help
802
- * @param type $screen_id
803
- * @param type $screen
804
- * @return type
805
- */
806
- function wpcf_admin_plugin_help( $hook, $page ) {
807
- global $wp_version;
808
- $call = false;
809
- $contextual_help = '';
810
- $page = $page;
811
- if ( isset( $page ) && isset( $_GET['page'] ) && $_GET['page'] == $page ) {
812
- switch ( $page ) {
813
- case 'wpcf-cf':
814
- $call = 'custom_fields';
815
- break;
816
-
817
- case 'wpcf-ctt':
818
- $call = 'custom_types_and_taxonomies';
819
- break;
820
-
821
- case 'wpcf-import-export':
822
- $call = 'import_export';
823
- break;
824
-
825
- case 'wpcf-edit':
826
- $call = 'edit_group';
827
- break;
828
-
829
- case 'wpcf-edit-type':
830
- $call = 'edit_type';
831
- break;
832
-
833
- case 'wpcf-edit-tax':
834
- $call = 'edit_tax';
835
- break;
836
- case 'wpcf':
837
- $call = 'wpcf';
838
- break;
839
- }
840
- }
841
- if ( $call ) {
842
- require_once WPCF_ABSPATH . '/help.php';
843
- $contextual_help = wpcf_admin_help( $call, $contextual_help );
844
- // WP 3.3 changes
845
- if ( version_compare( $wp_version, '3.2.1', '>' ) ) {
846
- set_current_screen( $hook );
847
- $screen = get_current_screen();
848
- if ( !is_null( $screen ) ) {
849
- $args = array(
850
- 'title' => __( 'Types', 'wpcf' ),
851
- 'id' => 'wpcf',
852
- 'content' => $contextual_help,
853
- 'callback' => false,
854
- );
855
- $screen->add_help_tab( $args );
856
- }
857
- } else {
858
- add_contextual_help( $hook, $contextual_help );
859
- }
860
- }
861
- }
862
-
863
- /**
864
- * Promo texts
865
- *
866
- * @todo Move!
867
- */
868
- function wpcf_admin_promotional_text() {
869
- $promo_tabs = get_option( '_wpcf_promo_tabs', false );
870
- // random selection every one hour
871
- if ( $promo_tabs ) {
872
- $time = time();
873
- $time_check = intval( $promo_tabs['time'] ) + 60 * 60;
874
- if ( $time > $time_check ) {
875
- $selected = mt_rand( 0, 3 );
876
- $promo_tabs['selected'] = $selected;
877
- $promo_tabs['time'] = $time;
878
- update_option( '_wpcf_promo_tabs', $promo_tabs );
879
- } else {
880
- $selected = $promo_tabs['selected'];
881
- }
882
- } else {
883
- $promo_tabs = array();
884
- $selected = mt_rand( 0, 3 );
885
- $promo_tabs['selected'] = $selected;
886
- $promo_tabs['time'] = time();
887
- update_option( '_wpcf_promo_tabs', $promo_tabs );
888
- }
889
- include WPCF_ABSPATH . '/marketing/helpful-links.php';
890
- }
891
-
892
- /**
893
- * Collapsible scripts.
894
- */
895
- function wpcf_admin_load_collapsible() {
896
- wp_enqueue_script( 'wpcf-collapsible',
897
- WPCF_RES_RELPATH . '/js/collapsible.js', array('jquery'),
898
- WPCF_VERSION );
899
- wp_enqueue_style( 'wpcf-collapsible',
900
- WPCF_RES_RELPATH . '/css/collapsible.css', array(), WPCF_VERSION );
901
- $option = get_option( 'wpcf_toggle', array() );
902
- if ( !empty( $option ) ) {
903
- $setting = 'new Array("' . implode( '", "', array_keys( $option ) ) . '")';
904
- wpcf_admin_add_js_settings( 'wpcf_collapsed', $setting );
905
- }
906
- }
907
-
908
- /**
909
- * Toggle button.
910
- *
911
- * @param type $div_id
912
- * @return type
913
- */
914
- function wpcf_admin_toggle_button( $div_id ) {
915
- return '<a href="'
916
- . admin_url( 'admin-ajax.php?action=wpcf_ajax&wpcf_action=toggle&div='
917
- . $div_id . '-toggle&_wpnonce='
918
- . wp_create_nonce( 'toggle' ) )
919
- . '" id="' . $div_id
920
- . '" class="wpcf-collapsible-button"></a>';
921
- }
922
-
923
- /**
924
- * Various delete/deactivate content actions.
925
- *
926
- * @param type $type
927
- * @param type $arg
928
- * @param type $action
929
- */
930
- function wpcf_admin_deactivate_content( $type, $arg, $action = 'delete' ) {
931
- switch ( $type ) {
932
- case 'post_type':
933
- // Clean tax relations
934
- if ( $action == 'delete' ) {
935
- $custom = get_option( 'wpcf-custom-taxonomies', array() );
936
- foreach ( $custom as $post_type => $data ) {
937
- if ( empty( $data['supports'] ) ) {
938
- continue;
939
- }
940
- if ( array_key_exists( $arg, $data['supports'] ) ) {
941
- unset( $custom[$post_type]['supports'][$arg] );
942
- }
943
- }
944
- update_option( 'wpcf-custom-taxonomies', $custom );
945
- }
946
- break;
947
-
948
- case 'taxonomy':
949
- // Clean post relations
950
- if ( $action == 'delete' ) {
951
- $custom = get_option( 'wpcf-custom-types', array() );
952
- foreach ( $custom as $post_type => $data ) {
953
- if ( empty( $data['taxonomies'] ) ) {
954
- continue;
955
- }
956
- if ( array_key_exists( $arg, $data['taxonomies'] ) ) {
957
- unset( $custom[$post_type]['taxonomies'][$arg] );
958
- }
959
- }
960
- update_option( 'wpcf-custom-types', $custom );
961
- }
962
- break;
963
-
964
- default:
965
- break;
966
- }
967
- }
968
-
969
- /**
970
- * Loads teasers.
971
- *
972
- * @param type $teasers
973
- */
974
- function wpcf_admin_load_teasers( $teasers ) {
975
- foreach ( $teasers as $teaser ) {
976
- $file = WPCF_ABSPATH . '/plus/' . $teaser;
977
- if ( file_exists( $file ) ) {
978
- require_once $file;
979
- }
980
- }
981
- }
982
-
983
- /**
984
- * Get temporary directory
985
- *
986
- * @return
987
- */
988
-
989
- function wpcf_get_temporary_directory()
990
- {
991
- $dir = sys_get_temp_dir();
992
- if ( !empty( $dir ) && is_dir( $dir ) && is_writable( $dir ) ) {
993
- return $dir;
994
- }
995
- $dir = wp_upload_dir();
996
- $dir = $dir['basedir'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
997
  return $dir;
998
  }
999
 
@@ -1017,6 +1085,37 @@ function wpcf_welcome_panel()
1017
  </div>
1018
  <?php
1019
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1020
 
1021
  /**
1022
  * add types configuration to debug
@@ -1031,3 +1130,48 @@ function wpcf_get_extra_debug_info($extra_debug)
1031
  add_action( 'wpcf_admin_header', 'wpcf_welcome_panel', PHP_INT_SIZE );
1032
  add_filter( 'icl_get_extra_debug_info', 'wpcf_get_extra_debug_info' );
1033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Admin functions
5
+ *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/admin.php $
7
+ * $LastChangedDate: 2015-02-04 13:43:06 +0000 (Wed, 04 Feb 2015) $
8
+ * $LastChangedRevision: 1082328 $
9
+ * $LastChangedBy: iworks $
10
+ *
11
+ */
12
+ require_once WPCF_ABSPATH . '/marketing.php';
13
+ /*
14
+ * This needs to be called after main 'init' hook.
15
+ * Main init hook calls required Types code for frontend.
16
+ * Admin init hook only in admin area.
17
+ *
18
+ * TODO Revise it to change to 'admin_init'
19
+ */
20
+ add_action( 'admin_init', 'wpcf_admin_init_hook', 11 );
21
+ add_action( 'admin_menu', 'wpcf_admin_menu_hook' );
22
+ add_action( 'wpcf_admin_page_init', 'wpcf_enqueue_scripts' );
23
+ add_action( 'admin_enqueue_scripts', 'wpcf_admin_enqueue_scripts' );
24
+
25
+ wpcf_admin_load_teasers( array('types-access.php') );
26
+ if ( defined( 'DOING_AJAX' ) ) {
27
+ require_once WPCF_INC_ABSPATH . '/ajax.php';
28
+ }
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');
42
+ }
43
+
44
+ /**
45
+ * admin_menu hook.
46
+ */
47
+ function wpcf_admin_menu_hook()
48
+ {
49
+ $wpcf_capability = apply_filters( 'wpcf_capability', 'manage_options' );
50
+
51
+ add_menu_page(
52
+ __( 'Types', 'wpcf' ),
53
+ __( 'Types', 'wpcf' ),
54
+ $wpcf_capability,
55
+ 'wpcf',
56
+ 'wpcf_admin_menu_summary',
57
+ 'none'
58
+ );
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 &amp; 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
+ );
97
+
98
+ if ( !empty($kind ) ) {
99
+ }
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
  ),
119
  ),
 
120
  );
121
 
122
+ foreach( $subpages as $menu_slug => $menu ) {
123
+ wpcf_admin_add_submenu_page($menu, $menu_slug);
124
+ }
125
+
126
+ if ( isset( $_GET['page'] ) ) {
127
+ switch ( $_GET['page'] ) {
128
+ case 'wpcf-edit':
129
+ $title = isset( $_GET['group_id'] ) ? __( 'Edit Group', 'wpcf' ) : __( 'Add New Group',
130
+ 'wpcf' );
131
+ $hook = add_submenu_page( 'wpcf', $title, $title,
132
+ 'manage_options', 'wpcf-edit',
133
+ 'wpcf_admin_menu_edit_fields' );
134
+ add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_fields_hook' );
135
+ wpcf_admin_plugin_help( $hook, 'wpcf-edit' );
136
+ break;
137
+
138
+ case 'wpcf-edit-type':
139
+ $title = isset( $_GET['wpcf-post-type'] ) ? __( 'Edit Custom Post Type',
140
+ 'wpcf' ) : __( 'Add New Custom Post Type',
141
+ 'wpcf' );
142
+ $hook = add_submenu_page( 'wpcf', $title, $title,
143
+ 'manage_options', 'wpcf-edit-type',
144
+ 'wpcf_admin_menu_edit_type' );
145
+ add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_type_hook' );
146
+ wpcf_admin_plugin_help( $hook, 'wpcf-edit-type' );
147
+ break;
148
+
149
+ case 'wpcf-edit-tax':
150
+ $title = isset( $_GET['wpcf-tax'] ) ? __( 'Edit Taxonomy',
151
+ 'wpcf' ) : __( 'Add New Taxonomy', 'wpcf' );
152
+ $hook = add_submenu_page( 'wpcf', $title, $title,
153
+ 'manage_options', 'wpcf-edit-tax',
154
+ 'wpcf_admin_menu_edit_tax' );
155
+ add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_tax_hook' );
156
+ wpcf_admin_plugin_help( $hook, 'wpcf-edit-tax' );
157
+ break;
158
+ case 'wpcf-edit-usermeta':
159
+ $title = isset( $_GET['group_id'] ) ? __( 'Edit User Fields Group', 'wpcf' ) : __( 'Add New User Fields Group',
160
+ 'wpcf' );
161
+ $hook = add_submenu_page( 'wpcf', $title, $title,
162
+ 'manage_options', 'wpcf-edit-usermeta',
163
+ 'wpcf_admin_menu_edit_user_fields' );
164
+ add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_user_fields_hook' );
165
+ wpcf_admin_plugin_help( $hook, 'wpcf-edit-usermeta' );
166
+ break;
167
  }
168
+ }
169
+
170
+ // Check if migration from other plugin is needed
171
+ if ( class_exists( 'Acf' ) || defined( 'CPT_VERSION' ) ) {
172
+ $hook = add_submenu_page( 'wpcf', __( 'Migration', 'wpcf' ),
173
+ __( 'Migration', 'wpcf' ), 'manage_options', 'wpcf-migration',
174
+ 'wpcf_admin_menu_migration' );
175
+ add_action( 'load-' . $hook, 'wpcf_admin_menu_migration_hook' );
176
+ wpcf_admin_plugin_help( $hook, 'wpcf-migration' );
177
+ }
178
+
179
+ do_action( 'wpcf_menu_plus' );
180
+
181
+ // remove the repeating Types submenu
182
+ remove_submenu_page( 'wpcf', 'wpcf' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  }
184
 
185
  /**
193
  /**
194
  * Menu page hook.
195
  */
196
+ function wpcf_admin_menu_summary_hook()
197
+ {
198
+ do_action( 'wpcf_admin_page_init' );
199
+ wpcf_admin_load_collapsible();
200
+ }
201
+
202
+ /**
203
+ * Menu page display.
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
+ /**
220
+ * Menu page hook.
221
+ */
222
+ function wpcf_admin_menu_edit_fields_hook()
223
+ {
224
+ do_action( 'wpcf_admin_page_init' );
225
+
226
+ /*
227
+ * Enqueue scripts
228
+ */
229
+ // Group filter
230
+ wp_enqueue_script( 'wpcf-filter-js',
231
+ WPCF_EMBEDDED_RES_RELPATH
232
+ . '/js/custom-fields-form-filter.js', array('jquery'), WPCF_VERSION );
233
+ // Form
234
+ wp_enqueue_script( 'wpcf-form-validation',
235
+ WPCF_EMBEDDED_RES_RELPATH . '/js/'
236
+ . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
237
+ WPCF_VERSION );
238
+ wp_enqueue_script( 'wpcf-form-validation-additional',
239
+ WPCF_EMBEDDED_RES_RELPATH . '/js/'
240
+ . 'jquery-form-validation/additional-methods.min.js',
241
+ array('jquery'), WPCF_VERSION );
242
+ // Scroll
243
+ wp_enqueue_script( 'wpcf-scrollbar',
244
+ WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/scrollbar.js',
245
+ array('jquery') );
246
+ wp_enqueue_script( 'wpcf-mousewheel',
247
+ WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/mousewheel.js',
248
+ array('wpcf-scrollbar') );
249
+ // MAIN
250
+ wp_enqueue_script( 'wpcf-fields-form',
251
+ WPCF_EMBEDDED_RES_RELPATH
252
+ . '/js/fields-form.js', array('wpcf-js') );
253
+
254
+ /*
255
+ * Enqueue styles
256
+ */
257
+ wp_enqueue_style( 'wpcf-scroll',
258
+ WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/css/scroll.css' );
259
+
260
+ //Css editor
261
+ wp_enqueue_script( 'wpcf-form-codemirror' ,
262
+ WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.js', array('wpcf-js'));
263
+ wp_enqueue_script( 'wpcf-form-codemirror-css-editor' ,
264
+ WPCF_RELPATH . '/resources/js/codemirror234/mode/css/css.js', array('wpcf-js'));
265
+ wp_enqueue_script( 'wpcf-form-codemirror-html-editor' ,
266
+ WPCF_RELPATH . '/resources/js/codemirror234/mode/xml/xml.js', array('wpcf-js'));
267
+ wp_enqueue_script( 'wpcf-form-codemirror-html-editor2' ,
268
+ WPCF_RELPATH . '/resources/js/codemirror234/mode/htmlmixed/htmlmixed.js', array('wpcf-js'));
269
+ wp_enqueue_script( 'wpcf-form-codemirror-editor-resize' ,
270
+ WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.resizable.min.js', array('wpcf-js'));
271
+
272
+ wp_enqueue_style( 'wpcf-css-editor',
273
+ WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.css' );
274
+ wp_enqueue_style( 'wpcf-css-editor-resize',
275
+ WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.theme.min.css' );
276
+ wp_enqueue_style( 'wpcf-usermeta',
277
+ WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css' );
278
+
279
+ add_action( 'admin_footer', 'wpcf_admin_fields_form_js_validation' );
280
+ require_once WPCF_INC_ABSPATH . '/fields.php';
281
+ require_once WPCF_INC_ABSPATH . '/fields-form.php';
282
+ $form = wpcf_admin_fields_form();
283
+ wpcf_form( 'wpcf_form_fields', $form );
284
+ }
285
+
286
+ /**
287
+ * Menu page display.
288
+ */
289
+ function wpcf_admin_menu_edit_fields()
290
+ {
291
+ if ( isset( $_GET['group_id'] ) ) {
292
+ $title = __( 'Edit Group', 'wpcf' );
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
+ /**
362
+ * Menu page hook.
363
+ */
364
+ function wpcf_admin_menu_edit_type_hook()
365
+ {
366
+ do_action( 'wpcf_admin_page_init' );
367
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-types.php';
368
+ require_once WPCF_INC_ABSPATH . '/custom-types-form.php';
369
+ require_once WPCF_INC_ABSPATH . '/post-relationship.php';
370
+ wp_enqueue_script( 'wpcf-custom-types-form',
371
+ WPCF_RES_RELPATH . '/js/'
372
+ . 'custom-types-form.js', array('jquery'), WPCF_VERSION );
373
+ wp_enqueue_script( 'wpcf-form-validation',
374
+ WPCF_RES_RELPATH . '/js/'
375
+ . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
376
+ WPCF_VERSION );
377
+ wp_enqueue_script( 'wpcf-form-validation-additional',
378
+ WPCF_RES_RELPATH . '/js/'
379
+ . 'jquery-form-validation/additional-methods.min.js',
380
+ array('jquery'), WPCF_VERSION );
381
+ add_action( 'admin_footer', 'wpcf_admin_types_form_js_validation' );
382
+ wpcf_post_relationship_init();
383
+ $form = wpcf_admin_custom_types_form();
384
+ wpcf_form( 'wpcf_form_types', $form );
385
+ }
386
+
387
+ /**
388
+ * Menu page display.
389
+ */
390
+ function wpcf_admin_menu_edit_type()
391
+ {
392
+ if ( isset( $_GET['wpcf-post-type'] ) ) {
393
+ $title = __( 'Edit Custom Post Type', 'wpcf' );
394
+ /**
395
+ * add new CPT link
396
+ */
397
+ $title .= sprintf(
398
+ '<a href="%s" class="add-new-h2">%s</a>',
399
+ add_query_arg( 'page', 'wpcf-edit-type', admin_url('admin.php')),
400
+ __('Add New')
401
+ );
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
+ /**
416
+ * Menu page hook.
417
+ */
418
+ function wpcf_admin_menu_edit_tax_hook()
419
+ {
420
+ do_action( 'wpcf_admin_page_init' );
421
+ wp_enqueue_script( 'wpcf-form-validation',
422
+ WPCF_RES_RELPATH . '/js/'
423
+ . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
424
+ WPCF_VERSION );
425
+ wp_enqueue_script( 'wpcf-form-validation-additional',
426
+ WPCF_RES_RELPATH . '/js/'
427
+ . 'jquery-form-validation/additional-methods.min.js',
428
+ array('jquery'), WPCF_VERSION );
429
+ add_action( 'admin_footer', 'wpcf_admin_tax_form_js_validation' );
430
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
431
+ require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
432
+ $form = wpcf_admin_custom_taxonomies_form();
433
+ wpcf_form( 'wpcf_form_tax', $form );
434
+ }
435
+
436
+ /**
437
+ * Menu page display.
438
+ */
439
+ function wpcf_admin_menu_edit_tax()
440
+ {
441
+ if ( isset( $_GET['wpcf-tax'] ) ) {
442
+ $title = __( 'Edit Taxonomy', 'wpcf' );
443
+ /**
444
+ * add new CPT link
445
+ */
446
+ $title .= sprintf(
447
+ '<a href="%s" class="add-new-h2">%s</a>',
448
+ add_query_arg( 'page', 'wpcf-edit-tax', admin_url('admin.php')),
449
+ __('Add New')
450
+ );
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
+ /**
465
+ * Menu page hook.
466
+ */
467
+ function wpcf_admin_menu_import_export_hook()
468
+ {
469
+ do_action( 'wpcf_admin_page_init' );
470
+ require_once WPCF_INC_ABSPATH . '/fields.php';
471
+ require_once WPCF_INC_ABSPATH . '/import-export.php';
472
+ if ( extension_loaded( 'simplexml' ) && isset( $_POST['export'] )
473
+ && wp_verify_nonce( $_POST['_wpnonce'], 'wpcf_import' ) ) {
474
+ wpcf_admin_export_data();
475
+ die();
476
+ }
477
+ }
478
+
479
+ /**
480
+ * Menu page display.
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
+ /**
493
+ * Menu page hook.
494
+ */
495
+ function wpcf_admin_menu_custom_fields_control_hook()
496
+ {
497
+ do_action( 'wpcf_admin_page_init' );
498
+ add_action( 'admin_head', 'wpcf_admin_custom_fields_control_js' );
499
+ add_thickbox();
500
+ require_once WPCF_INC_ABSPATH . '/fields.php';
501
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
502
+ require_once WPCF_INC_ABSPATH . '/fields-control.php';
503
+
504
+ if ( isset( $_REQUEST['_wpnonce'] )
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
+
512
+ global $wpcf_control_table;
513
+ $wpcf_control_table = new WPCF_Custom_Fields_Control_Table( array(
514
+ 'ajax' => true,
515
+ 'singular' => __( 'Custom Field', 'wpcf' ),
516
+ 'plural' => __( 'Custom Fields', 'wpcf' ),
517
+ ) );
518
+ $wpcf_control_table->prepare_items();
519
+ }
520
+
521
+ /**
522
+ * Menu page display.
523
+ */
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
+ /**
537
+ * Menu page hook.
538
+ */
539
+ function wpcf_admin_menu_migration_hook()
540
+ {
541
+ do_action( 'wpcf_admin_page_init' );
542
+ require_once WPCF_INC_ABSPATH . '/fields.php';
543
+ require_once WPCF_INC_ABSPATH . '/custom-types.php';
544
+ require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
545
+ require_once WPCF_INC_ABSPATH . '/migration.php';
546
+ $form = wpcf_admin_migration_form();
547
+ wpcf_form( 'wpcf_form_migration', $form );
548
+ }
549
+
550
+ /**
551
+ * Menu page display.
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
+ /**
565
+ * Menu page hook.
566
+ */
567
+ function wpcf_admin_menu_settings_hook()
568
+ {
569
+ do_action( 'wpcf_admin_page_init' );
570
+ require_once WPCF_INC_ABSPATH . '/settings.php';
571
+ $form = wpcf_admin_image_settings_form();
572
+ wpcf_form( 'wpcf_form_image_settings', $form );
573
+ $form = wpcf_admin_general_settings_form();
574
+ wpcf_form( 'wpcf_form_general_settings', $form );
575
+ $form = wpcf_admin_toolset_messages_form();
576
+ wpcf_form( 'wpcf_form_toolset_messages', $form );
577
+ }
578
+
579
+ /**
580
+ * Menu page display.
581
+ */
582
+ 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
590
+ _e( 'This screen contains the Types settings for your site.', 'wpcf' );
591
+
592
+ ?></p>
593
+ <ul class="horlist">
594
+ <li><a href="#types-image-settings"><?php _e( 'Image Settings', 'wpcf' ); ?></a></li>
595
+ <li><a href="#types-general-settings"><?php _e( 'General Setings', 'wpcf' ); ?></a></li>
596
+ <?php if ( $show_toolset_messages ) { ?><li><a href="#toolset-messages"><?php _e( 'Toolset Messages', 'wpcf' ); ?></a></li><?php } ?>
597
+ <li><a href="#debug"><?php _e( 'Debug Information', 'wpcf' ); ?></a></li>
598
+ </ul>
599
+ <br style='clear:both'/><br /><br />
600
+ <a id="types-image-settings"></a>
601
+ <table class="widefat" id="types_image_settings_table">
602
+ <thead>
603
+ <tr>
604
+ <th><?php
605
+ _e( 'Image Settings', 'wpcf' );
606
+
607
+ ?></th>
608
+ </tr>
609
+ </thead>
610
+ <tbody>
611
+ <tr>
612
+ <td>
613
+ <?php
614
+ echo '<br /><form method="post" action="" id="wpcf-image-settings-form" class="wpcf-settings-form '
615
+ . 'wpcf-form-validate">';
616
+ $form = wpcf_form( 'wpcf_form_image_settings' );
617
+ echo $form->renderForm();
618
+ echo '</form>';
619
+
620
+ ?>
621
+ </td>
622
+ </tr>
623
+ </tbody>
624
+ </table>
625
+ <br /><br />
626
+ <a id="types-general-settings"></a>
627
+ <table class="widefat" id="types_general_settings_table">
628
+ <thead>
629
+ <tr>
630
+ <th><?php
631
+ _e( 'General Settings', 'wpcf' );
632
+
633
+ ?></th>
634
+ </tr>
635
+ </thead>
636
+ <tbody>
637
+ <tr>
638
+ <td>
639
+ <?php
640
+ echo '<br /><form method="post" action="" id="wpcf-general-settings-form" class="wpcf-settings-form '
641
+ . 'wpcf-form-validate">';
642
+ $form = wpcf_form( 'wpcf_form_general_settings' );
643
+ echo $form->renderForm();
644
+ echo '</form>';
645
+ ?>
646
+ </td>
647
+ </tr>
648
+ </tbody>
649
+ </table>
650
+ <br /><br />
651
+ <?php
652
+ /**
653
+ * Toolset Messages
654
+ */
655
+ if ( $show_toolset_messages ) {
656
+ ?>
657
+ <a id="toolset-messages"></a>
658
+ <table class="widefat" id="toolset_messages">
659
+ <thead>
660
+ <tr>
661
+ <th><?php _e( 'Toolset Messages', 'wpcf' ); ?></th>
662
+ </tr>
663
+ </thead>
664
+ <tbody>
665
+ <tr>
666
+ <td>
667
+ <?php
668
+ echo '<br /><form method="post" action="" id="wpcf-toolset-messages-form" class="wpcf-settings-form '
669
+ . 'wpcf-form-validate">';
670
+ $form = wpcf_form( 'wpcf_form_toolset_messages' );
671
+ echo $form->renderForm();
672
+ echo '</form>';
673
+ ?>
674
+ </td>
675
+ </tr>
676
+ </tbody>
677
+ </table>
678
+ <br /><br />
679
+ <?php } ?>
680
+ <?php
681
+ /**
682
+ * Debug Information
683
+ */
684
+ ?>
685
+ <a id="debug"></a>
686
+ <table class="widefat" id="debug_table">
687
+ <thead>
688
+ <tr>
689
+ <th><?php _e( 'Debug Information', 'wpcf' ); ?></th>
690
+ </tr>
691
+ </thead>
692
+ <tbody>
693
+ <tr>
694
+ <td>
695
+ <?php
696
+ printf(
697
+ __( 'For retrieving debug information if asked by a support person, use the <a href="%s">debug information</a> page.', 'wpcf' ),
698
+ admin_url('admin.php?page=wpcf-debug-information')
699
+ );
700
+ ?>
701
+ </td>
702
+ </tr>
703
+ </tbody>
704
+ </table>
705
+ <?php
706
+ echo wpcf_add_admin_footer();
707
+
708
+ echo ob_get_clean();
709
+ }
710
+
711
+ /**
712
+ * Adds typical header on admin pages.
713
+ *
714
+ * @param string $title
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
+ /**
727
+ * Adds footer on admin pages.
728
+ *
729
+ * <b>Strongly recomended</b> if wpcf_add_admin_header() is called before.
730
+ * Otherwise invalid HTML formatting will occur.
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
+ }
738
+
739
+ /**
740
+ * Returns HTML formatted 'widefat' table.
741
+ *
742
+ * @param type $ID
743
+ * @param type $header
744
+ * @param type $rows
745
+ * @param type $empty_message
746
+ */
747
+ function wpcf_admin_widefat_table( $ID, $header, $rows = array(), $empty_message = 'No results' )
748
+ {
749
+ if ( 'No results' == $empty_message ) {
750
+ $empty_message = __('No results', 'wpcf');
751
+ }
752
+ $head = '';
753
+ $footer = '';
754
+ foreach ( $header as $key => $value ) {
755
+ $head .= '<th id="wpcf-table-' . $key . '">' . $value . '</th>' . "\r\n";
756
+ $footer .= '<th>' . $value . '</th>' . "\r\n";
757
+ }
758
+ echo '<table id="' . $ID . '" class="widefat" cellspacing="0">
759
+ <thead>
760
+ <tr>
761
+ ' . $head . '
762
+ </tr>
763
+ </thead>
764
+ <tfoot>
765
+ <tr>
766
+ ' . $footer . '
767
+ </tr>
768
+ </tfoot>
769
+ <tbody>
770
+ ';
771
+ $row = '';
772
+ if ( empty( $rows ) ) {
773
+ echo '<tr><td colspan="' . count( $header ) . '">' . $empty_message
774
+ . '</td></tr>';
775
+ } else {
776
+ $i = 0;
777
+ foreach ( $rows as $row ) {
778
+ $classes = array();
779
+ if ( $i++%2 ) {
780
+ $classes[] = 'alternate';
781
+ }
782
+ if ( isset($row['status']) && 'inactive' == $row['status'] ) {
783
+ $classes[] = sprintf('status-%s', $row['status']);
784
+ };
785
+ printf('<tr class="%s">', implode(' ', $classes ));
786
+ foreach ( $row as $column_name => $column_value ) {
787
+ if ( preg_match( '/^(status|raw_name)$/', $column_name )) {
788
+ continue;
789
+ }
790
+ echo '<td class="wpcf-table-column-' . $column_name . '">';
791
+ echo $column_value;
792
+ echo '</td>' . "\r\n";
793
+ }
794
+ echo '</tr>' . "\r\n";
795
+ }
796
+ }
797
+ echo '
798
+ </tbody>
799
+ </table>' . "\r\n";
800
+ }
801
+
802
+ /**
803
+ * Admin tabs.
804
+ *
805
+ * @param type $tabs
806
+ * @param type $page
807
+ * @param type $default
808
+ * @param type $current
809
+ * @return string
810
+ */
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
+ }
818
+ $output = '<h2 class="nav-tab-wrapper">';
819
+ foreach ( $tabs as $tab => $name ) {
820
+ $class = ( $tab == $current ) ? ' nav-tab-active' : '';
821
+ $output .= "<a class='nav-tab$class' href='?page=$page&tab=$tab'>$name</a>";
822
+ }
823
+ $output .= '</h2>';
824
+ return $output;
825
+ }
826
+
827
+ /**
828
+ * Saves open fieldsets.
829
+ *
830
+ * @param type $action
831
+ * @param type $fieldset
832
+ */
833
+ function wpcf_admin_form_fieldset_save_toggle($action, $fieldset)
834
+ {
835
+ $data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
836
+ true );
837
+ if ( $action == 'open' ) {
838
+ $data[$fieldset] = 1;
839
+ } elseif ( $action == 'close' ) {
840
+ unset( $data[$fieldset] );
841
+ }
842
+ update_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle', $data );
843
+ }
844
+
845
+ /**
846
+ * Check if fieldset is saved as open.
847
+ *
848
+ * @param type $fieldset
849
+ */
850
+ function wpcf_admin_form_fieldset_is_collapsed($fieldset)
851
+ {
852
+ $data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
853
+ true );
854
+ if ( empty( $data ) ) {
855
+ return true;
856
+ }
857
+ return array_key_exists( $fieldset, $data ) ? false : true;
858
+ }
859
+
860
+ /**
861
+ * Adds help on admin pages.
862
+ *
863
+ * @param type $contextual_help
864
+ * @param type $screen_id
865
+ * @param type $screen
866
+ * @return type
867
+ */
868
+ function wpcf_admin_plugin_help($hook, $page)
869
+ {
870
+ global $wp_version;
871
+ $call = false;
872
+ $contextual_help = '';
873
+ $page = $page;
874
+ if ( isset( $page ) && isset( $_GET['page'] ) && $_GET['page'] == $page ) {
875
+ switch ( $page ) {
876
+ case 'wpcf-cf':
877
+ $call = 'custom_fields';
878
+ break;
879
+
880
+ case 'wpcf-ctt':
881
+ $call = 'custom_types_and_taxonomies';
882
+ break;
883
+
884
+ case 'wpcf-import-export':
885
+ $call = 'import_export';
886
+ break;
887
+
888
+ case 'wpcf-edit':
889
+ $call = 'edit_group';
890
+ break;
891
+
892
+ case 'wpcf-edit-type':
893
+ $call = 'edit_type';
894
+ break;
895
+
896
+ case 'wpcf-edit-tax':
897
+ $call = 'edit_tax';
898
+ break;
899
+ case 'wpcf':
900
+ $call = 'wpcf';
901
+ break;
902
+ }
903
+ }
904
+ if ( $call ) {
905
+ require_once WPCF_ABSPATH . '/help.php';
906
+ $contextual_help = wpcf_admin_help( $call, $contextual_help );
907
+ // WP 3.3 changes
908
+ if ( version_compare( $wp_version, '3.2.1', '>' ) ) {
909
+ set_current_screen( $hook );
910
+ $screen = get_current_screen();
911
+ if ( !is_null( $screen ) ) {
912
+ $args = array(
913
+ 'title' => __( 'Types', 'wpcf' ),
914
+ 'id' => 'wpcf',
915
+ 'content' => $contextual_help,
916
+ 'callback' => false,
917
+ );
918
+ $screen->add_help_tab( $args );
919
+ }
920
+ } else {
921
+ add_contextual_help( $hook, $contextual_help );
922
+ }
923
+ }
924
+ }
925
+
926
+ /**
927
+ * Promo texts
928
+ *
929
+ * @todo Move!
930
+ */
931
+ function wpcf_admin_promotional_text()
932
+ {
933
+ $promo_tabs = get_option( '_wpcf_promo_tabs', false );
934
+ // random selection every one hour
935
+ if ( $promo_tabs ) {
936
+ $time = time();
937
+ $time_check = intval( $promo_tabs['time'] ) + 60 * 60;
938
+ if ( $time > $time_check ) {
939
+ $selected = mt_rand( 0, 3 );
940
+ $promo_tabs['selected'] = $selected;
941
+ $promo_tabs['time'] = $time;
942
+ update_option( '_wpcf_promo_tabs', $promo_tabs );
943
+ } else {
944
+ $selected = $promo_tabs['selected'];
945
+ }
946
+ } else {
947
+ $promo_tabs = array();
948
+ $selected = mt_rand( 0, 3 );
949
+ $promo_tabs['selected'] = $selected;
950
+ $promo_tabs['time'] = time();
951
+ update_option( '_wpcf_promo_tabs', $promo_tabs );
952
+ }
953
+ include WPCF_ABSPATH . '/marketing/helpful-links.php';
954
+ }
955
+
956
+ /**
957
+ * Collapsible scripts.
958
+ */
959
+ function wpcf_admin_load_collapsible()
960
+ {
961
+ wp_enqueue_script( 'wpcf-collapsible',
962
+ WPCF_RES_RELPATH . '/js/collapsible.js', array('jquery'),
963
+ WPCF_VERSION );
964
+ wp_enqueue_style( 'wpcf-collapsible',
965
+ WPCF_RES_RELPATH . '/css/collapsible.css', array(), WPCF_VERSION );
966
+ $option = get_option( 'wpcf_toggle', array() );
967
+ if ( !empty( $option ) ) {
968
+ $setting = 'new Array("' . implode( '", "', array_keys( $option ) ) . '")';
969
+ wpcf_admin_add_js_settings( 'wpcf_collapsed', $setting );
970
+ }
971
+ }
972
+
973
+ /**
974
+ * Toggle button.
975
+ *
976
+ * @param type $div_id
977
+ * @return type
978
+ */
979
+ function wpcf_admin_toggle_button($div_id)
980
+ {
981
+ return '<a href="'
982
+ . admin_url( 'admin-ajax.php?action=wpcf_ajax&wpcf_action=toggle&div='
983
+ . $div_id . '-toggle&_wpnonce='
984
+ . wp_create_nonce( 'toggle' ) )
985
+ . '" id="' . $div_id
986
+ . '" class="wpcf-collapsible-button"></a>';
987
+ }
988
+
989
+ /**
990
+ * Various delete/deactivate content actions.
991
+ *
992
+ * @param type $type
993
+ * @param type $arg
994
+ * @param type $action
995
+ */
996
+ function wpcf_admin_deactivate_content($type, $arg, $action = 'delete')
997
+ {
998
+ switch ( $type ) {
999
+ case 'post_type':
1000
+ // Clean tax relations
1001
+ if ( $action == 'delete' ) {
1002
+ $custom = get_option( 'wpcf-custom-taxonomies', array() );
1003
+ foreach ( $custom as $post_type => $data ) {
1004
+ if ( empty( $data['supports'] ) ) {
1005
+ continue;
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 );
1012
+ }
1013
+ break;
1014
+
1015
+ case 'taxonomy':
1016
+ // Clean post relations
1017
+ if ( $action == 'delete' ) {
1018
+ $custom = get_option( 'wpcf-custom-types', array() );
1019
+ foreach ( $custom as $post_type => $data ) {
1020
+ if ( empty( $data['taxonomies'] ) ) {
1021
+ continue;
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 );
1028
+ }
1029
+ break;
1030
+
1031
+ default:
1032
+ break;
1033
+ }
1034
+ }
1035
+
1036
+ /**
1037
+ * Loads teasers.
1038
+ *
1039
+ * @param type $teasers
1040
+ */
1041
+ function wpcf_admin_load_teasers($teasers)
1042
+ {
1043
+ foreach ( $teasers as $teaser ) {
1044
+ $file = WPCF_ABSPATH . '/plus/' . $teaser;
1045
+ if ( file_exists( $file ) ) {
1046
+ require_once $file;
1047
+ }
1048
+ }
1049
+ }
1050
+
1051
+ /**
1052
+ * Get temporary directory
1053
+ *
1054
+ * @return
1055
+ */
1056
+
1057
+ function wpcf_get_temporary_directory()
1058
+ {
1059
+ $dir = sys_get_temp_dir();
1060
+ if ( !empty( $dir ) && is_dir( $dir ) && is_writable( $dir ) ) {
1061
+ return $dir;
1062
+ }
1063
+ $dir = wp_upload_dir();
1064
+ $dir = $dir['basedir'];
1065
  return $dir;
1066
  }
1067
 
1085
  </div>
1086
  <?php
1087
  }
1088
+ /**
1089
+ *
1090
+ */
1091
+
1092
+ function wpcf_admin_enqueue_scripts($hook)
1093
+ {
1094
+ wp_register_script(
1095
+ 'marketing-getting-started',
1096
+ plugin_dir_url( __FILE__ ).'/marketing/getting-started/assets/scripts/getting-started.js',
1097
+ array('jquery'),
1098
+ WPCF_VERSION,
1099
+ true
1100
+ );
1101
+ if ( preg_match( '@/marketing/getting-started/[^/]+.php$@', $hook ) ) {
1102
+ $marketing = new WPCF_Types_Marketing_Messages();
1103
+ wp_localize_script(
1104
+ 'marketing-getting-started',
1105
+ 'marketing_getting_started',
1106
+ array( 'id' => $marketing->get_option_name() )
1107
+ );
1108
+ wp_enqueue_script('marketing-getting-started');
1109
+ wp_enqueue_style(
1110
+ 'marketing-getting-started',
1111
+ plugin_dir_url( __FILE__ ).'/marketing/getting-started/assets/css/getting-started.css',
1112
+ array(),
1113
+ WPCF_VERSION,
1114
+ 'all'
1115
+ );
1116
+ }
1117
+ }
1118
+
1119
 
1120
  /**
1121
  * add types configuration to debug
1130
  add_action( 'wpcf_admin_header', 'wpcf_welcome_panel', PHP_INT_SIZE );
1131
  add_filter( 'icl_get_extra_debug_info', 'wpcf_get_extra_debug_info' );
1132
 
1133
+ function wpcf_admin_add_submenu_page($menu, $menu_slug = null, $menu_parent = 'wpcf')
1134
+ {
1135
+ if ( !is_admin() ) {
1136
+ return;
1137
+ }
1138
+ $wpcf_capability = apply_filters( 'wpcf_capability', 'manage_options' );
1139
+ $menu_slug = array_key_exists('menu_slug', $menu)? $menu['menu_slug']:$menu_slug;
1140
+ /**
1141
+ * add submenu
1142
+ */
1143
+ $hook = add_submenu_page(
1144
+ $menu_parent,
1145
+ $menu['page_title'],
1146
+ $menu['menu_title'],
1147
+ $wpcf_capability,
1148
+ $menu_slug,
1149
+ array_key_exists('function', $menu)? $menu['function']:null
1150
+ );
1151
+ if ( !empty($menu_slug) ) {
1152
+ wpcf_admin_plugin_help( $hook, $menu_slug );
1153
+ }
1154
+ /**
1155
+ * add action
1156
+ */
1157
+ if ( !array_key_exists('load_hook', $menu) && array_key_exists('function', $menu) ) {
1158
+ $menu['load_hook'] = sprintf( '%s_hook', $menu['function'] );
1159
+ }
1160
+ if ( !empty($menu['load_hook']) && function_exists( $menu['load_hook'] ) ) {
1161
+ $action = sprintf(
1162
+ 'load-%s',
1163
+ array_key_exists('hook', $menu)? $menu['hook']:$hook
1164
+ );
1165
+ add_action( $action, $menu['load_hook'] );
1166
+ }
1167
+ /**
1168
+ * add submenu to submenu
1169
+ */
1170
+ if ( array_key_exists('submenu', $menu) ) {
1171
+ foreach( $menu['submenu'] as $submenu_slug => $submenu ) {
1172
+ wpcf_admin_add_submenu_page($submenu, $submenu_slug, $hook);
1173
+ }
1174
+ }
1175
+ return $hook;
1176
+ }
1177
+
classes/class.wpcf-marketing-messages.php ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Types Marketing Class
5
+ *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/classes/class.wpcf-marketing-messages.php $
7
+ * $LastChangedDate: 2015-01-28 06:42:34 +0000 (Wed, 28 Jan 2015) $
8
+ * $LastChangedRevision: 1077234 $
9
+ * $LastChangedBy: iworks $
10
+ *
11
+ */
12
+
13
+ include_once dirname(__FILE__).'/class.wpcf-marketing.php';
14
+
15
+ /**
16
+ * Types Marketing Class
17
+ *
18
+ * @since Types 1.6.5
19
+ * @package Types
20
+ * @subpackage Classes
21
+ * @version 0.1
22
+ * @category Help
23
+ * @author marcin <marcin.p@icanlocalize.com>
24
+ */
25
+ class WPCF_Types_Marketing_Messages extends WPCF_Types_Marketing
26
+ {
27
+ private $state;
28
+
29
+ public function __construct()
30
+ {
31
+ parent::__construct();
32
+ add_action('admin_enqueue_scripts', array($this, 'register_scripts'), 1);
33
+ add_action('wp_ajax_toolset_messages', array( $this, 'update_toolset_messages' ));
34
+ add_action('admin_notices', array($this, 'add_message_after_activate'));
35
+ $this->set_state();
36
+ }
37
+
38
+ private function set_state()
39
+ {
40
+ $this->state = '0' == get_option($this->option_disable, '0')? 'endabled':'disabled';
41
+
42
+ if ('disabled' == $this->state) {
43
+ return;
44
+ }
45
+ if ( self::check_register() ) {
46
+
47
+ $this->state = 'disabled';
48
+ }
49
+ }
50
+
51
+ public static function check_register()
52
+ {
53
+ if(!function_exists('WP_Installer')){
54
+ return false;
55
+ }
56
+ $repos = array(
57
+ 'toolset'
58
+ );
59
+ foreach( $repos as $repository_id ) {
60
+ $key = WP_Installer()->repository_has_subscription($repository_id);
61
+ if ( empty($key) ) {
62
+ continue;
63
+ }
64
+ return true;
65
+ }
66
+ return false;
67
+ }
68
+
69
+ private function get_data()
70
+ {
71
+ /**
72
+ * check kind
73
+ */
74
+ $kind = $this->get_kind();
75
+ /**
76
+ * get default
77
+ */
78
+ if ( empty($kind) ) {
79
+ $kind = $this->get_default_kind();
80
+ }
81
+ /**
82
+ * check exists?
83
+ */
84
+ if ( empty($kind) || !array_key_exists($kind, $this->adverts ) ) {
85
+ return;
86
+ }
87
+
88
+ /**
89
+ * check type
90
+ */
91
+ $type = $this->get_page_type();
92
+ if ( empty($type) || !array_key_exists($type, $this->adverts[$kind]) ) {
93
+ return;
94
+ }
95
+ if ( !is_array($this->adverts[$kind][$type]) ) {
96
+ return;
97
+ }
98
+ /**
99
+ * get number
100
+ */
101
+ $number = intval(get_user_option('types-modal'));
102
+ if ( !isset($this->adverts[$kind][$type][$number]) ) {
103
+ if ( empty($this->adverts[$kind][$type]) ) {
104
+ return;
105
+ }
106
+ $number = 0;
107
+ }
108
+
109
+ $data = $this->adverts[$kind][$type][$number];
110
+ $data['number'] = $number;
111
+ $data['count'] = count($this->adverts[$kind][$type]);
112
+ return $data;
113
+ }
114
+
115
+ private function replace_placeholders($text)
116
+ {
117
+ $type = $this->get_page_type();
118
+ switch($type) {
119
+ case 'cpt':
120
+ if (
121
+ is_array($_GET)
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;
130
+
131
+ case 'taxonomy':
132
+ if (
133
+ is_array($_GET)
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
+ }
149
+ }
150
+ break;
151
+ }
152
+ /**
153
+ * defaults
154
+ */
155
+ $text = preg_replace( '/PPP/', __('Posts'), $text);
156
+ $text = preg_replace( '/TTT/', __('Tags'), $text);
157
+
158
+ return $text;
159
+ }
160
+
161
+ public function register_scripts()
162
+ {
163
+
164
+ $data = $this->get_data();
165
+ if ( empty($data) ) {
166
+ return;
167
+ }
168
+ /**
169
+ * common question
170
+ */
171
+ $data['message'] = __('Saving your changes', 'wpcf');
172
+ $data['spinner'] = apply_filters('wpcf_marketing_message', admin_url('/images/spinner.gif'), $data, 'spinner');
173
+ $data['question'] = apply_filters('wpcf_marketing_message', __('Did you know?', 'wcpf'), $data, 'question');
174
+ /**
175
+ * random image & class
176
+ */
177
+ $image = isset($data['image'])? $data['image']:'views';
178
+ $src = sprintf(
179
+ '%s/marketing/assets/images/%s.png',
180
+ WPCF_RELPATH,
181
+ $image
182
+ );
183
+ $data['image'] = apply_filters('wpcf_marketing_message', $src, $data, 'image');
184
+ $data['class'] = apply_filters('wpcf_marketing_message', $image, $data, 'class');
185
+ /**
186
+ * values depend on type
187
+ */
188
+ foreach ( array('header', 'description') as $key ) {
189
+ $value = '';
190
+ if ( isset($data[$key]) && $data[$key] ) {
191
+ $value = $this->replace_placeholders($data[$key]);
192
+ }
193
+ $data[$key] = apply_filters('wpcf_marketing_message', $value, $data, $key );
194
+ $data['state'] = $this->state;
195
+ }
196
+ wp_register_script( 'types-modal', WPCF_EMBEDDED_RES_RELPATH.'/js/modal.js', array('jquery'), WPCF_VERSION, true);
197
+ wp_localize_script( 'types-modal', 'types_modal', $data);
198
+ wp_enqueue_script('types-modal');
199
+ }
200
+
201
+ public function update_message($message = false)
202
+ {
203
+ if (empty($message)) {
204
+ return;
205
+ }
206
+ echo '<div class="updated"><p>', $message, '</p></div>';
207
+ }
208
+
209
+ public function update_options()
210
+ {
211
+ if(!isset($_POST['marketing'])) {
212
+ return;
213
+ }
214
+ if ( !wp_verify_nonce($_POST['marketing'], 'update')) {
215
+ return;
216
+ }
217
+ if (
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
+ }
224
+ }
225
+ $this->set_state();
226
+ }
227
+
228
+ public function delete_option_kind()
229
+ {
230
+ delete_option($this->option_name);
231
+ }
232
+
233
+ public function get_kind_list()
234
+ {
235
+ $type = get_option($this->option_name);
236
+ $content = '<ul class="marketing-kind-list">';
237
+ foreach( $this->options as $key => $one ) {
238
+ $content .= '<li>';
239
+ $content .= sprintf(
240
+ '<input type="radio" name="%s" value="%s" id="getting_started_%s" %s/>',
241
+ $this->get_option_name(),
242
+ $key,
243
+ $key,
244
+ $type == $key? ' checked="checked" ':''
245
+ );
246
+ $content .= sprintf(
247
+ '<label for="getting_started_%s"> <strong>%s</strong>%s%s</label>',
248
+ $key,
249
+ $one['title'],
250
+ array_key_exists('description', $one)? ' | ':'',
251
+ array_key_exists('description', $one)? $one['description']:''
252
+ );
253
+ $content .= '</li>';
254
+ }
255
+ $content .= '</ul>';
256
+ return $content;
257
+ }
258
+
259
+ public function kind_list()
260
+ {
261
+ echo $this->get_kind_list();
262
+ }
263
+
264
+ public function show_top($update = true)
265
+ {
266
+ $data = $this->get_data();
267
+ if ( empty($data) ) {
268
+ return false;
269
+ }
270
+ $content = '<div class="icon-toolset-logo icon-toolset">';
271
+ $content .= sprintf('<p class="wpcf-notif-header">%s</p>', $update? __('Updated!', 'wpcf'):__('Created!', 'wpcf') );
272
+ if ( 'endabled' == $this->state) {
273
+ $content .= '<p class="wpcf-notif-description">';
274
+ if ( isset($data['link']) ) {
275
+ $content .= sprintf(
276
+ '<a href="%s">%s</a>',
277
+ $this->add_ga_campain($data['link']),
278
+ $data['description']
279
+ );
280
+ } else {
281
+ $content .= $data['description'];
282
+ }
283
+ $content .= '</p>';
284
+ }
285
+ $content .= '</div>';
286
+
287
+ $content = $this->replace_placeholders($content);
288
+
289
+ /**
290
+ * after all set up types-modal for next time
291
+ */
292
+ $key = rand( 0, $data['count']-1 );
293
+ $user_id = get_current_user_id();
294
+ update_user_option($user_id, 'types-modal', $key);
295
+
296
+ return $content;
297
+ }
298
+
299
+ public function get_content()
300
+ {
301
+ if ( $url = $this->get_kind_url() ) {
302
+ include_once dirname(__FILE__).'/class.wpcf-marketing-tutorial.php';
303
+ $tutorial = new WPCF_Types_Marketing_Tutorial();
304
+ return $tutorial->get_content('kind');
305
+ }
306
+ return;
307
+ }
308
+
309
+ public function update_toolset_messages()
310
+ {
311
+ $settings = wpcf_get_settings();
312
+ if (
313
+ array_key_exists('value', $_POST)
314
+ && 'checked' == $_POST['value']
315
+ ) {
316
+ if ( !add_option($this->option_disable, '1', '', 'no') ) {
317
+ update_option($this->option_disable, '1');
318
+ }
319
+ $settings['toolset_messages'] = true;
320
+ } else {
321
+ delete_option($this->option_disable);
322
+ $settings['toolset_messages'] = false;
323
+ }
324
+ update_option('wpcf_settings', $settings);
325
+ echo '<div class="updated"><p>';
326
+ _e('Toolset Messages state saved!', 'wpcf');
327
+ echo '</p></div>';
328
+ die;
329
+ }
330
+
331
+ public function add_message_after_activate()
332
+ {
333
+ if ( !isset($_GET['activate']) ) {
334
+ return;
335
+ }
336
+ if ( is_multisite() ) {
337
+ return;
338
+ }
339
+ if ( 'show' != get_option('types_show_on_activate') ) {
340
+ return;
341
+ }
342
+ wp_enqueue_style('onthego-admin-styles');
343
+ wp_enqueue_style('wpcf-css-embedded');
344
+ $data = array(
345
+ 'header' => __('Need help with <em>Types</em>?', 'wpcf'),
346
+ 'text' => __('Types plugin includes a lot of options. Tell us what kind of site you are building and we\'ll show you how to use Types in the best way.', 'wpcf'),
347
+ 'button_primary_url' => add_query_arg( 'page', basename(dirname(dirname(__FILE__))).'/marketing/getting-started/index.php', admin_url('admin.php') ),
348
+ 'button_primary_text' => __('Get Started', 'wpcf'),
349
+ 'button_dismiss_url' => '',
350
+ 'button_dismiss_text' => __('Dismiss', 'wpcf'),
351
+ );
352
+ wp_localize_script('marketing-getting-started', 'types_activate', $data);
353
+ wp_enqueue_script('marketing-getting-started');
354
+ update_option('types_show_on_activate', 'hide');
355
+ }
356
+
357
+ }
358
+
classes/class.wpcf-marketing-tutorial.php ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Types Tutorial Class
5
+ *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/classes/class.wpcf-marketing-tutorial.php $
7
+ * $LastChangedDate: 2015-01-28 06:42:34 +0000 (Wed, 28 Jan 2015) $
8
+ * $LastChangedRevision: 1077234 $
9
+ * $LastChangedBy: iworks $
10
+ *
11
+ */
12
+
13
+ include_once dirname(__FILE__).'/class.wpcf-marketing.php';
14
+
15
+ /**
16
+ * Types Tutorial Class
17
+ *
18
+ * @since Types 1.6.5
19
+ * @package Types
20
+ * @subpackage Classes
21
+ * @version 0.1
22
+ * @category Help
23
+ * @author marcin <marcin.p@icanlocalize.com>
24
+ */
25
+ class WPCF_Types_Marketing_Tutorial extends WPCF_Types_Marketing
26
+ {
27
+ private $id;
28
+ private $cache;
29
+ private $tutorials;
30
+
31
+ public function __construct()
32
+ {
33
+ parent::__construct();
34
+ }
35
+
36
+ private function error($error_id, $message = false)
37
+ {
38
+ $content = wpcf_add_admin_header(__('Tutorial error', 'wpcf'));
39
+ $content .= '<div class="error settings-error"><p><strong>';
40
+ switch( $error_id ) {
41
+ case 'no id':
42
+ case 'wrong id':
43
+ $content .= __('Wrong tutorial id.', 'wpcf');
44
+ break;
45
+ case 'empty url':
46
+ case 'wrong response status':
47
+ case 'http request failed':
48
+ $content .= __('There is a problem with tutorial url.', 'wpcf');
49
+ break;
50
+ case 'empty body':
51
+ $content .= __('Selected tutorial is empty.', 'wpcf');
52
+ if ( current_user_can('manage_options') ) {
53
+ }
54
+ break;
55
+ default:
56
+ if ( $message ) {
57
+ $content .= $message;
58
+ } else {
59
+ $content .= __('Some error occured.', 'wpcf');
60
+ }
61
+ }
62
+ $content .= '</strong></p></div>';
63
+ return $content;
64
+ }
65
+
66
+ private function produce($url = false)
67
+ {
68
+ if ( empty( $url ) ) {
69
+ $url = $this->get('url');
70
+ }
71
+ if ( empty($url) ) {
72
+ return $this->error('empty url');
73
+ }
74
+ $url = $this->add_ga_campain($url);
75
+
76
+ $resp = wp_remote_get($url);
77
+
78
+ if ( is_wp_error( $resp ) ) {
79
+ /**
80
+ * if user can manage_options then display a real error message
81
+ */
82
+ if( current_user_can('manage_options') ) {
83
+ return $this->error(false, $resp->get_error_message());
84
+ } else {
85
+ return $this->error('http request failed');
86
+ }
87
+ }
88
+
89
+ if ( 200 != $resp['response']['code'] ) {
90
+ return $this->error('wrong response status');
91
+ }
92
+
93
+ $title = preg_split('/<header class="masthead">/', $resp['body']);
94
+ $title = preg_split('/<h1>/', $title[1]);
95
+ $title = preg_split('@</h1>@', $title[1]);
96
+ $title = $title[0];
97
+
98
+ $body = '';
99
+ $containers = preg_split( '/<div class="container">/', $resp['body'] );
100
+ foreach( $containers as $container ) {
101
+ if ( !preg_match('/<div class="col-sm-[\d]+ post-content[^>]+>/', $container) ) {
102
+ continue;
103
+ }
104
+ $body = $container;
105
+
106
+ }
107
+ if ( empty( $body ) ) {
108
+ return $this->error('empty body');
109
+ }
110
+ $body = preg_split('/<aside/', $body);
111
+ $body = $body[0];
112
+ if ( empty( $body ) ) {
113
+ return $this->error('empty body');
114
+ }
115
+ $body = sprintf(
116
+ '<h1 class="title">%s</h1><div class="container"><div class="post-content">%s',
117
+ $title,
118
+ $body
119
+ );
120
+ set_transient( $this->cache, $body, 14 * DAY_IN_SECONDS);
121
+ return $body;
122
+ }
123
+
124
+ private function add_select_site_kind_intruction()
125
+ {
126
+ $kind = $this->get_kind();
127
+ if ( empty($kind) ) {
128
+ return;
129
+ }
130
+ $content = '';
131
+ /**
132
+ * current url
133
+ */
134
+ $current_url = add_query_arg(
135
+ array( 'page' => basename(WPCF_ABSPATH).'/marketing/getting-started/index.php',),
136
+ admin_url('admin.php')
137
+ );
138
+ /**
139
+ * add button to change site kind
140
+ */
141
+ $content .= sprintf(
142
+ '<a class="button" href="%s">%s</a>',
143
+ add_query_arg( array( 'kind' => 'choose',), $current_url),
144
+ __('Select instructions for other kinds of sites', 'wpcf')
145
+ );
146
+ /**
147
+ * add reload link
148
+ */
149
+ $content .= sprintf(
150
+ ' <a class="alignright" href="%s">%s</a>',
151
+ wp_nonce_url($current_url, 'reload', 'toolset'),
152
+ __('Reload', 'wpcf')
153
+ );
154
+ return sprintf( '<div class="container wpcf-tutorial-other wpcf-notif"><p>%s</p></div>', $content);
155
+ }
156
+
157
+ public function get_content()
158
+ {
159
+ $class = ' class="wp-types-icon-external" ';
160
+ $target = ' target="_blank" ';
161
+
162
+ $url = $this->get_kind_url();
163
+ $this->cache = md5($url);
164
+ $content = get_transient($this->cache);
165
+ /**
166
+ * check force reload
167
+ */
168
+ $force_reload = isset($_GET['toolset']) && wp_verify_nonce($_GET['toolset'], 'reload');
169
+ if ( $force_reload || false === apply_filters( 'tooleset_messages_get_transient', $content ) ) {
170
+ $content = $this->produce($url);
171
+ }
172
+ /**
173
+ * create array to replace
174
+ */
175
+ $replces = array(
176
+ 'from' => array(),
177
+ 'to' => array(),
178
+ );
179
+
180
+ $content = preg_replace('/(<a.*?)[ ]?target="_blank"(.*?)/', '$1$2', $content);
181
+
182
+ /**
183
+ * with '
184
+ */
185
+ preg_match_all('/href=\'([^\']+)\'/', $content, $matches );
186
+ if ( $matches ) {
187
+ foreach ( $matches[1] as $url ) {
188
+ if ( !preg_match('/wp-types.com/', $url ) ) {
189
+ continue;
190
+ }
191
+ $replces['from'][] = sprintf("|'%s'|", $url);
192
+ $replces['to'][] = sprintf( "'%s'", $this->add_ga_campain($url).$class.$target);
193
+ }
194
+ }
195
+ /**
196
+ * with "
197
+ */
198
+ preg_match_all('/href="([^"]+)"/', $content, $matches );
199
+ if ( $matches ) {
200
+ foreach ( $matches[1] as $url ) {
201
+ if ( !preg_match('/wp-types.com/', $url ) ) {
202
+ continue;
203
+ }
204
+ $replces['from'][] = sprintf('|"%s"|', $url);
205
+ $replces['to'][] = sprintf( '"%s"', $this->add_ga_campain($url)).$class.$target;
206
+ }
207
+ }
208
+
209
+ //WP-Types External
210
+
211
+ /**
212
+ * with '
213
+ */
214
+ preg_match_all('/href=\'([^\']+)\'/', $content, $matches );
215
+ if ( $matches ) {
216
+ foreach ( $matches[1] as $url ) {
217
+ if ( preg_match('/wp-types.com/', $url ) ) {
218
+ continue;
219
+ }
220
+ $replces['from'][] = sprintf("|'%s'|", $url);
221
+ $replces['to'][] = sprintf( "'%s'", $this->add_ga_campain($url).$class.$target);
222
+ }
223
+ }
224
+ /**
225
+ * with "
226
+ */
227
+ preg_match_all('/href="([^"]+)"/', $content, $matches );
228
+ if ( $matches ) {
229
+ foreach ( $matches[1] as $url ) {
230
+ if ( preg_match('/wp-types.com/', $url ) ) {
231
+ continue;
232
+ }
233
+ $replces['from'][] = sprintf('|"%s"|', $url);
234
+ $replces['to'][] = sprintf( '"%s"', $this->add_ga_campain($url)).$class.$target;
235
+ }
236
+ }
237
+
238
+
239
+
240
+ if (count($replces['from'])) {
241
+ $content = preg_replace( $replces['from'], $replces['to'], $content );
242
+ }
243
+ $content .= $this->add_select_site_kind_intruction();
244
+ return $content;
245
+ }
246
+
247
+ }
classes/class.wpcf-marketing.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Types Marketing Class
5
+ *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/classes/class.wpcf-marketing.php $
7
+ * $LastChangedDate: 2015-02-04 13:43:06 +0000 (Wed, 04 Feb 2015) $
8
+ * $LastChangedRevision: 1082328 $
9
+ * $LastChangedBy: iworks $
10
+ *
11
+ */
12
+
13
+ /**
14
+ * Types Marketing Class
15
+ *
16
+ * @since Types 1.6.5
17
+ * @package Types
18
+ * @subpackage Classes
19
+ * @version 0.1
20
+ * @category Help
21
+ * @author marcin <marcin.p@icanlocalize.com>
22
+ */
23
+ class WPCF_Types_Marketing
24
+ {
25
+ protected $option_name = 'types-site-kind';
26
+ protected $option_disable = 'types-site-kind-disable';
27
+ protected $options;
28
+ protected $adverts;
29
+
30
+ public function __construct()
31
+ {
32
+ $this->options = include WPCF_ABSPATH.'/marketing/etc/types-site-kinds.php';
33
+ $this->adverts = include WPCF_ABSPATH.'/marketing/etc/types.php';
34
+ add_filter('admin_body_class', array($this, 'admin_body_class'));
35
+ add_action( 'wpcf_menu_plus', array( $this, 'add_getting_started_to_admin_menu'), PHP_INT_MAX);
36
+ }
37
+
38
+ public function admin_body_class($classes)
39
+ {
40
+ $screen = get_current_screen();
41
+ if ( isset($screen->id) && preg_match( '@marketing/getting-started/index$@', $screen->id ) ) {
42
+ if ( !isset($_GET['kind'] )) {
43
+ $classes = 'wpcf-marketing';
44
+ }
45
+ else if ( isset($_POST['marketing'])) {
46
+ $classes = 'wpcf-marketing';
47
+ }
48
+ }
49
+
50
+ return $classes;
51
+ }
52
+
53
+ protected function get_page_type()
54
+ {
55
+ $screen = get_current_screen();
56
+ switch($screen->id) {
57
+ case 'types_page_wpcf-edit-type':
58
+ return 'cpt';
59
+ case 'types_page_wpcf-edit-tax':
60
+ return 'taxonomy';
61
+ case 'types_page_wpcf-edit':
62
+ case 'types_page_wpcf-edit-usermeta':
63
+ return 'fields';
64
+ }
65
+ return false;
66
+ }
67
+
68
+ public function get_options()
69
+ {
70
+ return $this->options;
71
+ }
72
+
73
+ public function get_option_name()
74
+ {
75
+ return $this->option_name;
76
+ }
77
+
78
+ public function get_default_kind()
79
+ {
80
+ if ( isset($this->options) && is_array($this->options) ) {
81
+ foreach ( $this->options as $kind => $options ) {
82
+ if ( array_key_exists('default', $options ) && $options['default']) {
83
+ return $kind;
84
+ }
85
+ }
86
+ }
87
+ return false;
88
+ }
89
+
90
+ public function get_kind()
91
+ {
92
+ $kind = get_option($this->option_name, false);
93
+ if (
94
+ $kind
95
+ && isset($this->options)
96
+ && is_array($this->options)
97
+ && array_key_exists( $kind, $this->options )
98
+ ) {
99
+ return $kind;
100
+ }
101
+ return false;
102
+ }
103
+
104
+ public function get_kind_url($kind = false)
105
+ {
106
+ if ( empty($kind) ) {
107
+ $kind = $this->get_kind();
108
+ }
109
+ if (
110
+ $kind
111
+ && isset($this->options)
112
+ && is_array($this->options)
113
+ && array_key_exists('url', $this->options[$kind] )
114
+ ) {
115
+ return $this->options[$kind]['url'];
116
+ }
117
+ return;
118
+ }
119
+
120
+ public function get_option_disiable_value()
121
+ {
122
+ return get_option($this->option_disable, 0);
123
+ }
124
+
125
+ public function get_option_disiable_name()
126
+ {
127
+ return $this->option_disable;
128
+ }
129
+
130
+ protected function add_ga_campain($url)
131
+ {
132
+ $url = add_query_arg(
133
+ array(
134
+ 'utm_source' => 'typesplugin',
135
+ 'utm_medium' => 'save-updated',
136
+ 'utm_campaig' => sprintf('%s-howto', $this->get_kind() ),
137
+ ),
138
+ $url
139
+ );
140
+ return $url;
141
+ }
142
+
143
+ /**
144
+ * add Getting Started to menu
145
+ */
146
+ public function add_getting_started_to_admin_menu()
147
+ {
148
+ $menu = array(
149
+ 'page_title' => __( 'What kind of site are you building?', 'wpcf' ),
150
+ 'menu_title' => __( 'Getting Started', 'wpcf' ),
151
+ 'menu_slug' => basename(dirname(dirname(__FILE__))).'/marketing/getting-started/index.php',
152
+ 'hook' => 'wpcf_marketing',
153
+ 'load_hook' => 'wpcf_marketing_hook',
154
+ );
155
+ wpcf_admin_add_submenu_page($menu);
156
+ }
157
+
158
+
159
+ }
embedded/admin.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/admin.php $
5
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
6
- * $LastChangedRevision: 970205 $
7
- * $LastChangedBy: brucepearson $
8
  *
9
  */
10
  require_once(WPCF_EMBEDDED_ABSPATH . '/common/visual-editor/editor-addon.class.php');
@@ -187,42 +187,6 @@ function wpcf_form( $id, $form = array() ) {
187
  return $wpcf_forms[$id];
188
  }
189
 
190
- /**
191
- * Add submit button, cancel button and help link to the popup.
192
- *
193
- */
194
- function wpcf_form_popup_helper( $form, $submit_text = '', $cancel_text = '',
195
- $help = array() ) {
196
- if ( $submit_text ) {
197
- $form['submit'] = array(
198
- '#type' => 'submit',
199
- '#name' => 'submit',
200
- '#value' => $submit_text,
201
- '#attributes' => array('class' => 'button-primary'),
202
- );
203
- }
204
- if ( $cancel_text ) {
205
- $form['cancel'] = array(
206
- '#type' => 'button',
207
- '#name' => 'cancel',
208
- '#value' => $cancel_text,
209
- '#attributes' => array('class' => 'button-secondary',
210
- 'onclick' => 'window.parent.jQuery(\'#TB_closeWindowButton\').click();return true;'),
211
- '#before' => ' ',
212
- );
213
- }
214
- if ( $help ) {
215
- $form = array_reverse( $form, true );
216
- $form['help'] = array(
217
- '#type' => 'markup',
218
- '#markup' => '<a class="wpcf-help-link" href="' . $help['url'] . '" target="_blank">' . $help['text'] . '</a>',
219
- );
220
- $form = array_reverse( $form, true );
221
- }
222
-
223
- return $form;
224
- }
225
-
226
  /**
227
  * Renders form elements.
228
  *
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/embedded/admin.php $
5
+ * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
6
+ * $LastChangedRevision: 1069430 $
7
+ * $LastChangedBy: iworks $
8
  *
9
  */
10
  require_once(WPCF_EMBEDDED_ABSPATH . '/common/visual-editor/editor-addon.class.php');
187
  return $wpcf_forms[$id];
188
  }
189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  /**
191
  * Renders form elements.
192
  *
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.4/embedded/bootstrap.php $
11
- * $LastChangedDate: 2014-11-18 06:52:14 +0000 (Tue, 18 Nov 2014) $
12
- * $LastChangedRevision: 1027716 $
13
  * $LastChangedBy: iworks $
14
  *
15
  */
@@ -131,7 +131,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.4' );
135
  define( 'WPCF_META_PREFIX', 'wpcf-' );
136
  }
137
 
@@ -300,7 +300,15 @@ function wpcf_embedded_init() {
300
  // 'attachment' = Media
301
  //
302
  $wpcf->excluded_post_types = array(
303
- 'revision', 'view', 'view-template', 'cred-form', 'nav_menu_item', 'mediapage',
 
 
 
 
 
 
 
 
304
  );
305
 
306
  // Init loader
7
  *
8
  * @since Types 1.2
9
  *
10
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/embedded/bootstrap.php $
11
+ * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
12
+ * $LastChangedRevision: 1069430 $
13
  * $LastChangedBy: iworks $
14
  *
15
  */
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' );
135
  define( 'WPCF_META_PREFIX', 'wpcf-' );
136
  }
137
 
300
  // 'attachment' = Media
301
  //
302
  $wpcf->excluded_post_types = array(
303
+ 'dd_layouts',
304
+ 'cred-form',
305
+ 'mediapage',
306
+ 'nav_menu_item',
307
+ 'revision',
308
+ 'view',
309
+ 'view-template',
310
+ 'wp-types-group',
311
+ 'wp-types-user-group',
312
  );
313
 
314
  // Init loader
embedded/classes/class.wpcf-post-types.php CHANGED
@@ -3,7 +3,7 @@
3
  *
4
  * Post Types Class
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
3
  *
4
  * Post Types Class
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/classes/field.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Field class.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/classes/field.php $
6
  * $LastChangedDate: 2014-10-23 10:33:39 +0000 (Thu, 23 Oct 2014) $
7
  * $LastChangedRevision: 1012677 $
8
  * $LastChangedBy: iworks $
2
  /*
3
  * Field class.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/embedded/classes/field.php $
6
  * $LastChangedDate: 2014-10-23 10:33:39 +0000 (Thu, 23 Oct 2014) $
7
  * $LastChangedRevision: 1012677 $
8
  * $LastChangedBy: iworks $
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.4/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.5/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,7 +4,7 @@
4
  *
5
  * Returns HTML formatted output for elements and handles form submission.
6
  *
7
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/classes/forms.php $
8
  * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
9
  * $LastChangedRevision: 970205 $
10
  * $LastChangedBy: brucepearson $
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/embedded/classes/forms.php $
8
  * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
9
  * $LastChangedRevision: 970205 $
10
  * $LastChangedBy: brucepearson $
embedded/classes/loader.php CHANGED
@@ -3,7 +3,7 @@
3
  *
4
  * Loader class
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/classes/loader.php $
7
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
  * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
3
  *
4
  * Loader class
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/embedded/classes/loader.php $
7
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
  * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
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.4/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.5/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.4/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.5/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.4/embedded/classes/relationship.php $
6
- * $LastChangedDate: 2014-10-23 10:33:39 +0000 (Thu, 23 Oct 2014) $
7
- * $LastChangedRevision: 1012677 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -387,30 +387,40 @@ class WPCF_Relationship
387
  function add_new_child($parent_id, $post_type)
388
  {
389
  global $wpdb;
390
-
391
  $parent = get_post( $parent_id );
392
  if ( empty( $parent ) ) {
393
  return new WP_Error( 'wpcf-relationship-no-parent', 'No parent' );
394
  }
395
  $new_post = array(
396
- 'post_title' => ' ', // WP requires at least title with space
397
  'post_type' => $post_type,
398
  'post_status' => 'draft',
399
  );
400
  $id = wp_insert_post( $new_post, true );
401
- if ( !is_wp_error( $id ) ) {
402
- // Mark that it is new post
403
- update_post_meta( $id, '_wpcf_relationship_new', 1 );
404
- // Save relationship
405
- update_post_meta( $id,
406
- '_wpcf_belongs_' . $parent->post_type . '_id', $parent->ID );
407
- // Fix title
408
- $wpdb->update( $wpdb->posts,
409
- array('post_title' => $post_type . ' ' . $id),
410
- array('ID' => $id), array('%s'), array('%d') );
411
- do_action( 'wpcf_relationship_add_child', get_post( $id ), $parent );
412
- wp_cache_flush();
413
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  return $id;
415
  }
416
 
@@ -507,4 +517,45 @@ class WPCF_Relationship
507
  die();
508
  }
509
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
  }
2
  /*
3
  * Post relationship class.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
387
  function add_new_child($parent_id, $post_type)
388
  {
389
  global $wpdb;
 
390
  $parent = get_post( $parent_id );
391
  if ( empty( $parent ) ) {
392
  return new WP_Error( 'wpcf-relationship-no-parent', 'No parent' );
393
  }
394
  $new_post = array(
395
+ 'post_title' => __('New'). ': '.$post_type,
396
  'post_type' => $post_type,
397
  'post_status' => 'draft',
398
  );
399
  $id = wp_insert_post( $new_post, true );
400
+ /**
401
+ * return wp_error
402
+ */
403
+ if ( is_wp_error( $id ) ) {
404
+ return $id;
 
 
 
 
 
 
 
405
  }
406
+ /**
407
+ * Mark that it is new post
408
+ */
409
+ update_post_meta( $id, '_wpcf_relationship_new', 1 );
410
+ /**
411
+ * Save relationship
412
+ */
413
+ update_post_meta( $id, '_wpcf_belongs_' . $parent->post_type . '_id', $parent->ID );
414
+ /**
415
+ * Fix title
416
+ */
417
+ $wpdb->update(
418
+ $wpdb->posts,
419
+ array('post_title' => $post_type . ' ' . $id),
420
+ array('ID' => $id), array('%s'), array('%d')
421
+ );
422
+ do_action( 'wpcf_relationship_add_child', get_post( $id ), $parent );
423
+ wp_cache_flush();
424
  return $id;
425
  }
426
 
517
  die();
518
  }
519
 
520
+ /**
521
+ * Meta box form on post edit page.
522
+ *
523
+ * @param type $parent Parent post
524
+ * @param type $post_type Child post type
525
+ * @return type string HTML formatted list
526
+ */
527
+ function child_list($parent, $post_type)
528
+ {
529
+ if ( is_integer( $parent ) ) {
530
+ $parent = get_post( $parent );
531
+ }
532
+ $output = '';
533
+ require_once dirname( __FILE__ ) . '/relationship/form-child.php';
534
+ $this->child_form = new WPCF_Relationship_Child_Form(
535
+ $parent,
536
+ $post_type,
537
+ $this->settings( $parent->post_type, $post_type )
538
+ );
539
+ foreach($this->child_form->children as $child) {
540
+ $output .= sprintf(
541
+ '<li>%s</li>',
542
+ apply_filters('post_title', $child->post_title)
543
+ );
544
+ }
545
+ if ( $output ) {
546
+ $output = sprintf(
547
+ '<ul>%s</ul>',
548
+ $output
549
+ );
550
+ } else {
551
+ $output = sprintf(
552
+ '<p class="info">%s</p>',
553
+ $this->child_form->child_post_type_object->labels->not_found
554
+ );
555
+ }
556
+
557
+ return $output;
558
+ }
559
+
560
+
561
  }
embedded/common/changelog.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
4
+ - Updated Installer to 1.5
5
+
6
+ -------------------------------------------------------------------------------------------------------------------
7
+ Common 1.3.1 (Dec 16 2014)
8
+ - Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
9
+ - Fixed issue about Editor addon and ACF compatibility
10
+ - Fixed issue about branding loader
11
+
12
+ -------------------------------------------------------------------------------------------------------------------
13
+ Common 1.3 (Dec 15 2014)
14
+ - Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
embedded/common/classes/forms.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Returns HTML formatted output for elements and handles form submission.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/common/classes/forms.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
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/embedded/common/classes/forms.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
embedded/common/classes/validation-cakephp.php CHANGED
@@ -754,6 +754,17 @@ if (!class_exists('Wpcf_Cake_Validation')) {
754
  function integer($check) {
755
  return is_int(intval($check));
756
  }
 
 
 
 
 
 
 
 
 
 
 
757
 
758
  /**
759
  * Check that a value is a valid phone number.
754
  function integer($check) {
755
  return is_int(intval($check));
756
  }
757
+
758
+ /**
759
+ * Checks if a value is valid hexadecimal.
760
+ *
761
+ * @param string $check Value to check
762
+ * @return boolean Succcess
763
+ * @access public
764
+ */
765
+ function hexadecimal($check) {
766
+ return preg_match('/^#[a-f0-9]{6}$/i', $check);
767
+ }
768
 
769
  /**
770
  * Check that a value is a valid phone number.
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.4/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.5/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,7 +2,7 @@
2
  /**
3
  * produce debug information
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
2
  /**
3
  * produce debug information
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/common/installer/changelog.txt DELETED
@@ -1,17 +0,0 @@
1
- = 1.3 =
2
- * Added a new repository: Toolset
3
- * The product packages can be displayed hierarchically and ordered
4
- * The link to automatically create site keys will follow through login on the account site (e.g. wpml.org, wp-types.com)
5
- * Fixed animination issues (not showing in most browsers) when downloading plugins.
6
- * Created an admin screen on the repository end (icl-mpp) to sho registration stats (site keys, site keys usage, components usage etc..).
7
- * Bug fix: Renew and Upgrade buttons were not entirely clickable
8
- * Bug fix: Action buttons (buy, renew, upgrade) were not displayed correctly when WPML was not active (Installer embedded in theme)
9
- * Support for site-wide registration. Products can be registered on the network instead of on each site separately.
10
- * Users are able to add either http or https version for any site urls. There will be one site key that will work with both http and https versions.
11
-
12
- = 1.2 =
13
- * Added pagination for site keys list of Account -> My Sites
14
- * Reversed the order in which the site keys are displayed.
15
- * Fixed problem with WPML registration information (site key) not being saved when the option_value field in the wp_options table used a different charset than the default WordPress charset defined in wp-config.php
16
- * Allow registering new sites by clicking a link in the WordPress admin instead of copying and pasting the site url in the Account -> My Sites section
17
- * Display more detailed debug information related to connectivity issues with the WPML repository
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
embedded/common/res/css/toolset-common.css CHANGED
@@ -11,7 +11,7 @@ Toolset Primary Button Style - use with .button.button-primary-toolset classname
11
  border-color: #EF6223;
12
  -webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
13
  box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
14
- color: #fff;
15
  text-decoration: none;
16
  }
17
 
@@ -23,7 +23,7 @@ Toolset Primary Button Style - use with .button.button-primary-toolset classname
23
  border-color: #EF6223;
24
  -webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
25
  box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
26
- color: #fff;
27
  }
28
 
29
  .wp-core-ui .button-primary-toolset.focus,
11
  border-color: #EF6223;
12
  -webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
13
  box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
14
+ color: #fff !important;
15
  text-decoration: none;
16
  }
17
 
23
  border-color: #EF6223;
24
  -webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
25
  box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
26
+ color: #fff !important;
27
  }
28
 
29
  .wp-core-ui .button-primary-toolset.focus,
embedded/common/toolset-forms/api.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
2
 
3
  /**
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/common/toolset-forms/bootstrap.php CHANGED
@@ -2,9 +2,9 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/common/toolset-forms/bootstrap.php $
6
- * $LastChangedDate: 2014-10-23 10:33:39 +0000 (Thu, 23 Oct 2014) $
7
- * $LastChangedRevision: 1012677 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -39,11 +39,11 @@ class WPToolset_Forms_Bootstrap
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' ) );
@@ -51,7 +51,7 @@ class WPToolset_Forms_Bootstrap
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') );
@@ -76,10 +76,10 @@ class WPToolset_Forms_Bootstrap
76
  }
77
 
78
  // returns HTML
79
- // public function fieldEdit($form_id, $config) {
80
- // $form = $this->form( $form_id, array() );
81
- // return $form->editform( $config );
82
- // }
83
 
84
  public function form( $form_id, $config = array() )
85
  {
@@ -212,55 +212,57 @@ class WPToolset_Forms_Bootstrap
212
  if (!$query->is_main_query()) {
213
  return;
214
  }
215
-
 
 
 
 
 
 
 
 
 
 
 
 
216
  $types_cpt = get_option( 'wpcf-custom-types');
217
  if (!is_array($types_cpt) || empty($types_cpt)) {
218
  return;
219
  }
220
- $cpt_to_add = array();
221
  /**
222
- * check category
223
  */
224
- if ( is_category() ) {
225
- foreach($types_cpt as $cpt_slug => $cpt) {
226
- if (array_key_exists('taxonomies', $cpt) && is_array($cpt['taxonomies'])) {
227
- foreach($cpt['taxonomies'] as $tax_slug => $value) {
228
- if ('category' == $tax_slug && $value) {
229
- $cpt_to_add[] = $cpt_slug;
230
- }
 
 
231
  }
232
  }
233
  }
234
  }
235
  /**
236
- * check tags
237
  */
238
- if ( is_tag() ) {
239
- foreach($types_cpt as $cpt_slug => $cpt) {
240
- if (array_key_exists('taxonomies', $cpt) && is_array($cpt['taxonomies'])) {
241
- foreach($cpt['taxonomies'] as $tax_slug => $value) {
242
- if ('post_tag' == $tax_slug && $value) {
243
- $cpt_to_add[] = $cpt_slug;
244
- }
245
- }
246
- }
247
- }
248
  }
249
  /**
250
- * change query if some CPT use this
251
  */
252
- if (!empty($cpt_to_add)) {
253
- /**
254
- * remeber if is empty, then is post
255
- */
256
- $current_types = $query->get('post_type');
257
- if(empty($current_types)) {
258
- $cpt_to_add[] = 'post';
259
- } else {
260
- $cpt_to_add = array_merge($current_types, $cpt_to_add);
261
- }
262
- $query->set('post_type', $cpt_to_add);
263
  }
 
264
  }
265
  }
266
 
2
 
3
  /**
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
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' ) );
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') );
76
  }
77
 
78
  // returns HTML
79
+ // public function fieldEdit($form_id, $config) {
80
+ // $form = $this->form( $form_id, array() );
81
+ // return $form->editform( $config );
82
+ // }
83
 
84
  public function form( $form_id, $config = array() )
85
  {
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
 
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.4/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.5/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,9 +1,9 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/common/toolset-forms/classes/class.checkbox.php $
5
- * $LastChangedDate: 2014-10-23 10:33:39 +0000 (Thu, 23 Oct 2014) $
6
- * $LastChangedRevision: 1012677 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -20,7 +20,7 @@ class WPToolset_Field_Checkbox extends FieldFactory
20
  {
21
  global $post;
22
  $value = $this->getValue();
23
- $data = $this->getData();
24
  $checked = null;
25
 
26
  /**
@@ -34,13 +34,13 @@ class WPToolset_Field_Checkbox extends FieldFactory
34
  */
35
  if ( isset($data['options']) && array_key_exists( 'checked', $data['options'] ) ) {
36
  $checked = $data['options']['checked'];
37
- }
38
  /**
39
  * if is a default value, there value is 1 or default_value
40
  */
41
  if (
42
  array_key_exists('default_value', $data)
43
- && ( '1' === $value || $value == $data['default_value'] )
44
  ) {
45
  $checked = true;
46
  }
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
8
  *
9
  */
20
  {
21
  global $post;
22
  $value = $this->getValue();
23
+ $data = $this->getData();
24
  $checked = null;
25
 
26
  /**
34
  */
35
  if ( isset($data['options']) && array_key_exists( 'checked', $data['options'] ) ) {
36
  $checked = $data['options']['checked'];
37
+ }
38
  /**
39
  * if is a default value, there value is 1 or default_value
40
  */
41
  if (
42
  array_key_exists('default_value', $data)
43
+ && ( 'y' === $value || $value === $data['default_value'])
44
  ) {
45
  $checked = true;
46
  }
embedded/common/toolset-forms/classes/class.checkboxes.php CHANGED
@@ -4,9 +4,9 @@
4
  *
5
  * @author Srdjan
6
  *
7
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/common/toolset-forms/classes/class.checkboxes.php $
8
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
9
- * $LastChangedRevision: 1027712 $
10
  * $LastChangedBy: iworks $
11
  *
12
  */
@@ -20,7 +20,8 @@ class WPToolset_Field_Checkboxes extends FieldFactory
20
  global $post;
21
  $value = $this->getValue();
22
  $data = $this->getData();
23
- $name = $this->getName();
 
24
  $form = array();
25
  $_options = array();
26
  if (isset($data['options'])) {
4
  *
5
  * @author Srdjan
6
  *
7
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
11
  *
12
  */
20
  global $post;
21
  $value = $this->getValue();
22
  $data = $this->getData();
23
+ $name = $this->getName();
24
+
25
  $form = array();
26
  $_options = array();
27
  if (isset($data['options'])) {
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.4/embedded/common/toolset-forms/classes/class.colorpicker.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
@@ -62,9 +62,23 @@ class WPToolset_Field_Colorpicker extends FieldFactory
62
  {
63
 
64
  }
 
 
 
 
 
 
 
 
 
 
65
 
66
  public function metaform()
67
  {
 
 
 
 
68
  $classes = array();
69
  $classes[] = 'js-wpt-colorpicker';
70
  $form = array();
@@ -75,7 +89,7 @@ class WPToolset_Field_Colorpicker extends FieldFactory
75
  '#value' => $this->getValue(),
76
  '#name' => $this->getName(),
77
  '#attributes' => array('class' => implode(' ', $classes )),
78
- '#validate' => $this->getValidationData(),
79
  '#after' => '',
80
  '#repetitive' => $this->isRepetitive(),
81
  );
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
62
  {
63
 
64
  }
65
+
66
+ public function addTypeValidation($validation) {
67
+ $validation['hexadecimal'] = array(
68
+ 'args' => array(
69
+ 'hexadecimal'
70
+ ),
71
+ 'message' => __( 'You can add valid hexadecimal.', 'wpv-views' ),
72
+ );
73
+ return $validation;
74
+ }
75
 
76
  public function metaform()
77
  {
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();
89
  '#value' => $this->getValue(),
90
  '#name' => $this->getName(),
91
  '#attributes' => array('class' => implode(' ', $classes )),
92
+ '#validate' => $validation,
93
  '#after' => '',
94
  '#repetitive' => $this->isRepetitive(),
95
  );
embedded/common/toolset-forms/classes/class.conditional.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /*
3
  * - Checks conditionals when form is displayed and values changed
4
  * - Checks simple conditionals using JS
@@ -40,11 +41,11 @@
40
  * 'custom' => '($wpcf-text = show) OR ($wpcf-date > '21-01-2014')'
41
  * );
42
  */
43
- if ( !defined( 'ICL_COMMON_FUNCTIONS' ) ) {
44
- require_once WPTOOLSET_COMMON_PATH . '/functions.php';
45
  }
46
  if (!function_exists('wpv_filter_parse_date')) {
47
- require_once WPTOOLSET_COMMON_PATH . '/wpv-filter-date-embedded.php';
48
  }
49
 
50
  require_once WPTOOLSET_COMMON_PATH . '/expression-parser/parser.php';
@@ -57,9 +58,7 @@ require_once WPTOOLSET_COMMON_PATH . '/expression-parser/parser.php';
57
  *
58
  * @author Srdjan
59
  */
60
-
61
- class WPToolset_Forms_Conditional
62
- {
63
 
64
  private $__formID;
65
  protected $_collected = array(), $_triggers = array(), $_fields = array(), $_custom_triggers = array(), $_custom_fields = array();
@@ -69,30 +68,26 @@ class WPToolset_Forms_Conditional
69
  *
70
  * @param type $formID
71
  */
72
- public function __construct( $formID ) {
73
- $this->__formID = trim( $formID, '#' );
74
  // Register and enqueue
75
- wp_register_script( 'wptoolset-form-conditional',
76
- WPTOOLSET_FORMS_RELPATH . '/js/conditional.js', array('jquery', 'jquery-effects-scale'),
77
- WPTOOLSET_FORMS_VERSION, true );
78
- wp_enqueue_script( 'wptoolset-form-conditional' );
79
  $js_data = array(
80
- 'ajaxurl' => admin_url('admin-ajax.php', null),
81
  );
82
- wp_localize_script( 'wptoolset-form-conditional', 'wptConditional', $js_data );
83
 
84
- wp_register_script( 'wptoolset-parser',
85
- icl_get_file_relpath( dirname( dirname(__FILE__) ) ) . '/expression-parser/js/parser.js', array('jquery'),
86
- WPTOOLSET_FORMS_VERSION, true );
87
- wp_enqueue_script( 'wptoolset-parser' );
88
  $js_data = array(
89
- 'ajaxurl' => admin_url('admin-ajax.php', null),
90
  );
91
  // Render settings
92
- add_action( 'admin_print_footer_scripts', array($this, 'renderJsonData'), 30 );
93
- add_action( 'wp_footer', array($this, 'renderJsonData'), 30 );
94
  // Check conditional and hide field
95
- add_action('wptoolset_field_class', array($this, 'actionFieldClass') );
96
  }
97
 
98
  /**
@@ -102,8 +97,8 @@ class WPToolset_Forms_Conditional
102
  *
103
  * @param type $config
104
  */
105
- public function add( $config ) {
106
- if ( !empty( $config['conditional'] ) ) {
107
  $this->_collected[$config['id']] = $config['conditional'];
108
  return;
109
  }
@@ -113,38 +108,44 @@ class WPToolset_Forms_Conditional
113
  * Sets JSON data to be used with conditional.js
114
  */
115
  protected function _parseData() {
116
- foreach ( $this->_collected as $id => $config ) {
117
- if ( !empty( $config['custom'] ) ) {
118
-
119
- $evaluate = wpv_filter_parse_date($config['custom']);
120
- $evaluate = self::handle_user_function( $evaluate );
121
- $fields = self::extractFields( $evaluate );
122
-
123
- foreach ( $fields as $field ) {
 
 
 
 
 
 
 
124
  $this->_custom_fields[$id]['custom'] = $evaluate;
125
  $this->_custom_fields[$id]['triggers'][] = $field;
126
  $this->_custom_triggers[$field][] = $id;
127
  }
128
  } else {
129
- if (isset($config)&&isset($config['conditions'])) {
130
- if (isset($config)&&isset($config['relation']))
131
- $this->_fields[$id]['relation'] = $config['relation'];
132
-
133
- foreach ( $config['conditions'] as &$c ) {
134
- /*
135
- * $c[id] - field id
136
- * $c[type] - field type
137
- * $c[operator] - operator
138
- * $c[args] - array(value, [value2]...)
139
- */
140
- if ( !isset( $this->_triggers[$c['id']] ) )
141
- $this->_triggers[$c['id']] = array();
142
- $c['args'] = apply_filters( 'wptoolset_conditional_args_js',
143
- $c['args'], $c['type'] );
144
- $this->_fields[$id]['conditions'][] = $c;
145
- if ( !in_array( $id, $this->_triggers[$c['id']] ) )
146
- $this->_triggers[$c['id']][] = $id;
147
- }
148
  }
149
  }
150
  }
@@ -155,21 +156,21 @@ class WPToolset_Forms_Conditional
155
  */
156
  public function renderJsonData() {
157
  $this->_parseData();
158
- if ( !empty( $this->_triggers ) ) {
159
  echo '<script type="text/javascript">wptCondTriggers["#'
160
- . $this->__formID . '"] = ' . json_encode( $this->_triggers ) . ';</script>';
161
  }
162
- if ( !empty( $this->_fields ) ) {
163
  echo '<script type="text/javascript">wptCondFields["#'
164
- . $this->__formID . '"] = ' . json_encode( $this->_fields ) . ';</script>';
165
  }
166
- if ( !empty( $this->_custom_triggers ) ) {
167
  echo '<script type="text/javascript">wptCondCustomTriggers["#'
168
- . $this->__formID . '"] = ' . json_encode( $this->_custom_triggers ) . ';</script>';
169
  }
170
- if ( !empty( $this->_custom_fields ) ) {
171
  echo '<script type="text/javascript">wptCondCustomFields["#'
172
- . $this->__formID . '"] = ' . json_encode( $this->_custom_fields ) . ';</script>';
173
  }
174
  }
175
 
@@ -180,16 +181,16 @@ class WPToolset_Forms_Conditional
180
  * @param array $values
181
  * @return type
182
  */
183
- public static function evaluate( $config ) {
184
  // Custom conditional
185
- if ( !empty( $config['custom'] ) ) {
186
- return self::evaluateCustom( $config['custom'], $config['values'] );
187
  }
188
 
189
  /**
190
  * check conditions
191
  */
192
- if ( !array_key_exists( 'conditions', $config ) ) {
193
  return true;
194
  }
195
 
@@ -197,34 +198,33 @@ class WPToolset_Forms_Conditional
197
  $passedAll = true;
198
  $relation = $config['relation'];
199
 
200
- foreach ( $config['conditions'] as $c ) {
201
  // Add filters
202
- wptoolset_form_field_add_filters( $c['type'] );
203
- $c['args'] = apply_filters( 'wptoolset_conditional_args_php',
204
- $c['args'], $c['type'] );
205
- $value = isset( $config['values'][$c['id']] ) ? $config['values'][$c['id']] : null;
206
- $value = apply_filters( 'wptoolset_conditional_value_php', $value, $c['type'] );
207
  $compare = $c['args'][0];
208
- switch ( $c['operator'] ) {
209
  case '=':
210
  case '==':
211
  $passed = $value == $compare;
212
  break;
213
 
214
  case '>':
215
- $passed = floatval( $value ) > floatval( $compare );
216
  break;
217
 
218
  case '>=':
219
- $passed = floatval( $value ) >= floatval( $compare );
220
  break;
221
 
222
  case '<':
223
- $passed = floatval( $value ) < floatval( $compare );
224
  break;
225
 
226
  case '<=':
227
- $passed = floatval( $value ) <= floatval( $compare );
228
  break;
229
 
230
  case '===':
@@ -240,23 +240,23 @@ class WPToolset_Forms_Conditional
240
  break;
241
 
242
  case 'between':
243
- $passed = floatval( $value ) > floatval( $compare ) && floatval( $value ) < floatval( $c['args'][1] );
244
  break;
245
 
246
  default:
247
  $passed = false;
248
  break;
249
  }
250
- if ( !$passed ) {
251
  $passedAll = false;
252
  } else {
253
  $passedOne = true;
254
  }
255
  }
256
- if ( $relation == 'AND' && $passedAll ) {
257
  return true;
258
  }
259
- if ( $relation == 'OR' && $passedOne ) {
260
  return true;
261
  }
262
  return false;
@@ -271,88 +271,81 @@ class WPToolset_Forms_Conditional
271
  * @param type $evaluate
272
  * @return boolean
273
  */
274
- public static function evaluateCustom( $evaluate, $values ) {
275
- $evaluate = trim( stripslashes( $evaluate ) );
276
- // Check dates
277
- $evaluate = wpv_filter_parse_date( $evaluate );
278
- $evaluate = self::handle_user_function( $evaluate );
279
- $fields = self::extractFields( $evaluate );
280
- $evaluate = self::_update_values_in_expression($evaluate, $fields, $values);
281
-
282
- $check = false;
283
- try {
284
- $parser = new Toolset_Parser($evaluate);
285
- $parser->parse();
286
- $check = $parser->evaluate();
287
- } catch (Exception $e) {
288
- $check = false;
289
- }
290
- return $check;
291
- }
292
 
293
- static function sortByLength ($a, $b) {
294
- return strlen($b) - strlen($a);
295
- }
296
 
 
 
 
 
 
 
 
 
 
 
297
 
298
- private static function _update_values_in_expression($evaluate, $fields, $values) {
 
 
299
 
300
- // use string replace to replace any fields with their values.
301
 
302
- // Sort by length just in case a field name contians a shorter version of another field name.
303
- // eg. $my-field and $my-field-2
 
304
 
305
- $keys = array_keys($fields);
306
- usort($keys, 'WPToolset_Forms_Conditional::sortByLength');
307
 
308
- foreach($keys as $key) {
309
- $value = isset($values[$fields[$key]]) ? $values[$fields[$key]] : '';
310
- if ($value == '') {
311
- $value = "''";
312
- }
313
- if (is_numeric($value)) {
314
- $value = '\'' . $value . '\'';
315
- }
316
 
317
- if( 'array' === gettype($value) )
318
- {
319
  // workaround for datepicker data to cover all cases
320
- if( array_key_exists ( 'timestamp' , $value ) )
321
- {
322
- if ( is_numeric( $value['timestamp'] ) )
323
- {
324
- $value = $value['timestamp'];
325
- }
326
- else if ( is_array( $value['timestamp'] ) )
327
- {
328
- $value = implode(',', array_values ( $value['timestamp'] ) );
329
- }
330
- }
331
- else if( array_key_exists('datepicker', $value ) )
332
- {
333
- if ( is_numeric( $value['datepicker'] ) )
334
- {
335
- $value = $value['datepicker'];
336
- }
337
- else if ( is_array( $value['datepicker'] ) )
338
- {
339
- $value = implode(',', array_values ( $value['datepicker'] ) );
340
- }
341
- }
342
- else{
343
- $value = implode(',', array_values ( $value ) );
344
  }
345
  }
346
 
347
 
348
- // First replace the $(field_name) format
349
- $evaluate = str_replace('$(' . $fields[$key] . ')', $value, $evaluate);
350
- // next replace the $field_name format
351
- $evaluate = str_replace('$' . $fields[$key], $value, $evaluate);
352
- }
353
 
354
- return $evaluate;
355
- }
356
 
357
  /**
358
  * Extracts fields from custom conditional statement.
@@ -360,62 +353,62 @@ class WPToolset_Forms_Conditional
360
  * @param type $evaluate
361
  * @return type
362
  */
363
- public static function extractFields( $evaluate ) {
364
- $evaluate = trim( stripslashes( $evaluate ) );
365
- // Check dates
366
- $evaluate = wpv_filter_parse_date( $evaluate );
367
- $evaluate = self::handle_user_function($evaluate);
 
 
 
 
 
368
 
369
  // Add quotes = > < >= <= === <> !==
370
- $strings_count = preg_match_all( '/[=|==|===|<=|<==|<===|>=|>==|>===|\!===|\!==|\!=|<>]\s(?!\$)(\w*)[\)|\$|\W]/',
371
- $evaluate, $matches );
372
-
373
- if ( !empty( $matches[1] ) ) {
374
- foreach ( $matches[1] as $temp_match ) {
375
- $temp_replace = is_numeric( $temp_match ) ? $temp_match : '\'' . $temp_match . '\'';
376
- $evaluate = str_replace( ' ' . $temp_match . ')',
377
- ' ' . $temp_replace . ')', $evaluate );
378
  }
379
  }
380
  // if new version $(field-value) use this regex
381
- if( preg_match('/\$\(([^()]+)\)/', $evaluate) ){
382
- preg_match_all( '/\$\(([^()]+)\)/', $evaluate, $matches );
383
  }
384
  // if old version $field-value use this other
385
- else{
386
- preg_match_all( '/\$([^\s]*)/', $evaluate, $matches );
387
  }
388
 
389
 
390
  $fields = array();
391
- if ( !empty( $matches ) ) {
392
- foreach ( $matches[1] as $field_name ) {
393
- $fields[trim($field_name, '()')] = trim($field_name,'()');
394
  }
395
  }
396
 
397
  return $fields;
398
  }
399
 
400
- public static function handle_user_function( $evaluate )
401
- {
402
- $evaluate = stripcslashes( $evaluate );
403
  $occurrences = preg_match_all('/(\\w+)\(([^\)]*)\)/', $evaluate, $matches);
404
 
405
- if( $occurrences > 0 )
406
- {
407
  for ($i = 0; $i < $occurrences; $i++) {
408
  $result = false;
409
  $function = $matches[1][$i];
410
- $field = isset( $matches[2] ) ? rtrim( $matches[2][$i], ',' ) : '';
411
 
412
- if( $function === 'USER' )
413
- {
414
- $result = WPV_Handle_Users_Functions::get_user_field( $field );
415
  }
416
 
417
- if( $result ){
418
- $evaluate = str_replace( $matches[0][$i], $result, $evaluate );
419
  }
420
  }
421
  }
@@ -428,26 +421,25 @@ class WPToolset_Forms_Conditional
428
  */
429
  public static function ajaxCustomConditional() {
430
  $res = array('passed' => array(), 'failed' => array());
431
- $conditional = stripslashes_deep($_POST['conditions']);
432
- foreach ($conditional as $k => $c ) {
433
- $post_values = stripslashes_deep($_POST['values']);
434
  $values = array();
435
- foreach ( $post_values as $fid => $value ) {
436
- if ( isset( $_POST['field_types'][$fid] ) ) {
437
  $field_type = stripslashes_deep($_POST['field_types'][$fid]);
438
- wptoolset_form_field_add_filters( $field_type );
439
- $value = apply_filters( 'wptoolset_conditional_value_php',
440
- $value, $field_type );
441
  }
442
  $values[$fid] = $value;
443
  }
444
- if ( $passed = self::evaluateCustom( $c, $values ) ) {
445
  $res['passed'][] = $k;
446
  } else {
447
  $res['failed'][] = $k;
448
  }
449
  }
450
- echo json_encode( $res );
451
  die();
452
  }
453
 
@@ -456,11 +448,9 @@ class WPToolset_Forms_Conditional
456
  *
457
  * @param type $config
458
  */
459
- public function actionFieldClass( $config ) {
460
  if (
461
- !empty( $config['conditional'] )
462
- && array_key_exists( 'conditions', $config['conditional'] )
463
- && !self::evaluate( $config['conditional'] )
464
  ) {
465
  echo ' wpt-hidden js-wpt-remove-on-submit js-wpt-validation-ignore';
466
  }
@@ -471,7 +461,7 @@ class WPToolset_Forms_Conditional
471
  *
472
  * @return type
473
  */
474
- public function getData(){
475
  $this->_parseData();
476
  return array(
477
  'triggers' => $this->_triggers,
@@ -483,35 +473,32 @@ class WPToolset_Forms_Conditional
483
 
484
  }
485
 
 
486
 
487
-
488
- if( !class_exists('WPV_Handle_Users_Functions') )
489
- {
490
- class WPV_Handle_Users_Functions{
491
 
492
  private static $field;
493
 
494
- public static function get_user_field( $field )
495
- {
496
- if( !$field ) return false;
497
 
498
  self::$field = str_replace("'", '', $field);
499
 
500
- $ret = self::get_info( );
501
 
502
- if( $ret !== false ) return "'".$ret."'";
 
503
 
504
  return false;
505
  }
506
 
507
- private static function get_info( )
508
- {
509
  global $current_user;
510
 
511
  get_currentuserinfo();
512
 
513
- switch( self::$field )
514
- {
515
  case 'role':
516
  return isset($current_user->roles[0]) ? $current_user->roles[0] : 'Subscriber';
517
  break;
@@ -531,5 +518,7 @@ if( !class_exists('WPV_Handle_Users_Functions') )
531
 
532
  return false;
533
  }
 
534
  }
 
535
  }
1
  <?php
2
+
3
  /*
4
  * - Checks conditionals when form is displayed and values changed
5
  * - Checks simple conditionals using JS
41
  * 'custom' => '($wpcf-text = show) OR ($wpcf-date > '21-01-2014')'
42
  * );
43
  */
44
+ if (!defined('ICL_COMMON_FUNCTIONS')) {
45
+ require_once WPTOOLSET_COMMON_PATH . '/functions.php';
46
  }
47
  if (!function_exists('wpv_filter_parse_date')) {
48
+ require_once WPTOOLSET_COMMON_PATH . '/wpv-filter-date-embedded.php';
49
  }
50
 
51
  require_once WPTOOLSET_COMMON_PATH . '/expression-parser/parser.php';
58
  *
59
  * @author Srdjan
60
  */
61
+ class WPToolset_Forms_Conditional {
 
 
62
 
63
  private $__formID;
64
  protected $_collected = array(), $_triggers = array(), $_fields = array(), $_custom_triggers = array(), $_custom_fields = array();
68
  *
69
  * @param type $formID
70
  */
71
+ public function __construct($formID) {
72
+ $this->__formID = trim($formID, '#');
73
  // Register and enqueue
74
+ wp_register_script('wptoolset-form-conditional', WPTOOLSET_FORMS_RELPATH . '/js/conditional.js', array('jquery', 'jquery-effects-scale'), WPTOOLSET_FORMS_VERSION, true);
75
+ wp_enqueue_script('wptoolset-form-conditional');
 
 
76
  $js_data = array(
77
+ 'ajaxurl' => admin_url('admin-ajax.php', null),
78
  );
79
+ wp_localize_script('wptoolset-form-conditional', 'wptConditional', $js_data);
80
 
81
+ wp_register_script('wptoolset-parser', icl_get_file_relpath(dirname(dirname(__FILE__))) . '/expression-parser/js/parser.js', array('jquery'), WPTOOLSET_FORMS_VERSION, true);
82
+ wp_enqueue_script('wptoolset-parser');
 
 
83
  $js_data = array(
84
+ 'ajaxurl' => admin_url('admin-ajax.php', null),
85
  );
86
  // Render settings
87
+ add_action('admin_print_footer_scripts', array($this, 'renderJsonData'), 30);
88
+ add_action('wp_footer', array($this, 'renderJsonData'), 30);
89
  // Check conditional and hide field
90
+ add_action('wptoolset_field_class', array($this, 'actionFieldClass'));
91
  }
92
 
93
  /**
97
  *
98
  * @param type $config
99
  */
100
+ public function add($config) {
101
+ if (!empty($config['conditional'])) {
102
  $this->_collected[$config['id']] = $config['conditional'];
103
  return;
104
  }
108
  * Sets JSON data to be used with conditional.js
109
  */
110
  protected function _parseData() {
111
+ foreach ($this->_collected as $id => $config) {
112
+ if (!empty($config['custom'])) {
113
+
114
+ $evaluate = $config['custom'];
115
+ //###############################################################################################
116
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193583580/comments
117
+ //Fix REGEX conditions that contains \ that is stripped out
118
+ if (strpos($evaluate, "REGEX") === false) {
119
+ $evaluate = wpv_filter_parse_date($evaluate);
120
+ $evaluate = self::handle_user_function($evaluate);
121
+ }
122
+ //###############################################################################################
123
+ $fields = self::extractFields($evaluate);
124
+
125
+ foreach ($fields as $field) {
126
  $this->_custom_fields[$id]['custom'] = $evaluate;
127
  $this->_custom_fields[$id]['triggers'][] = $field;
128
  $this->_custom_triggers[$field][] = $id;
129
  }
130
  } else {
131
+ if (isset($config) && isset($config['conditions'])) {
132
+ if (isset($config) && isset($config['relation']))
133
+ $this->_fields[$id]['relation'] = $config['relation'];
134
+
135
+ foreach ($config['conditions'] as &$c) {
136
+ /*
137
+ * $c[id] - field id
138
+ * $c[type] - field type
139
+ * $c[operator] - operator
140
+ * $c[args] - array(value, [value2]...)
141
+ */
142
+ if (!isset($this->_triggers[$c['id']]))
143
+ $this->_triggers[$c['id']] = array();
144
+ $c['args'] = apply_filters('wptoolset_conditional_args_js', $c['args'], $c['type']);
145
+ $this->_fields[$id]['conditions'][] = $c;
146
+ if (!in_array($id, $this->_triggers[$c['id']]))
147
+ $this->_triggers[$c['id']][] = $id;
148
+ }
 
149
  }
150
  }
151
  }
156
  */
157
  public function renderJsonData() {
158
  $this->_parseData();
159
+ if (!empty($this->_triggers)) {
160
  echo '<script type="text/javascript">wptCondTriggers["#'
161
+ . $this->__formID . '"] = ' . json_encode($this->_triggers) . ';</script>';
162
  }
163
+ if (!empty($this->_fields)) {
164
  echo '<script type="text/javascript">wptCondFields["#'
165
+ . $this->__formID . '"] = ' . json_encode($this->_fields) . ';</script>';
166
  }
167
+ if (!empty($this->_custom_triggers)) {
168
  echo '<script type="text/javascript">wptCondCustomTriggers["#'
169
+ . $this->__formID . '"] = ' . json_encode($this->_custom_triggers) . ';</script>';
170
  }
171
+ if (!empty($this->_custom_fields)) {
172
  echo '<script type="text/javascript">wptCondCustomFields["#'
173
+ . $this->__formID . '"] = ' . json_encode($this->_custom_fields) . ';</script>';
174
  }
175
  }
176
 
181
  * @param array $values
182
  * @return type
183
  */
184
+ public static function evaluate($config) {
185
  // Custom conditional
186
+ if (!empty($config['custom'])) {
187
+ return self::evaluateCustom($config['custom'], $config['values']);
188
  }
189
 
190
  /**
191
  * check conditions
192
  */
193
+ if (!array_key_exists('conditions', $config)) {
194
  return true;
195
  }
196
 
198
  $passedAll = true;
199
  $relation = $config['relation'];
200
 
201
+ foreach ($config['conditions'] as $c) {
202
  // Add filters
203
+ wptoolset_form_field_add_filters($c['type']);
204
+ $c['args'] = apply_filters('wptoolset_conditional_args_php', $c['args'], $c['type']);
205
+ $value = isset($config['values'][$c['id']]) ? $config['values'][$c['id']] : null;
206
+ $value = apply_filters('wptoolset_conditional_value_php', $value, $c['type']);
 
207
  $compare = $c['args'][0];
208
+ switch ($c['operator']) {
209
  case '=':
210
  case '==':
211
  $passed = $value == $compare;
212
  break;
213
 
214
  case '>':
215
+ $passed = floatval($value) > floatval($compare);
216
  break;
217
 
218
  case '>=':
219
+ $passed = floatval($value) >= floatval($compare);
220
  break;
221
 
222
  case '<':
223
+ $passed = floatval($value) < floatval($compare);
224
  break;
225
 
226
  case '<=':
227
+ $passed = floatval($value) <= floatval($compare);
228
  break;
229
 
230
  case '===':
240
  break;
241
 
242
  case 'between':
243
+ $passed = floatval($value) > floatval($compare) && floatval($value) < floatval($c['args'][1]);
244
  break;
245
 
246
  default:
247
  $passed = false;
248
  break;
249
  }
250
+ if (!$passed) {
251
  $passedAll = false;
252
  } else {
253
  $passedOne = true;
254
  }
255
  }
256
+ if ($relation == 'AND' && $passedAll) {
257
  return true;
258
  }
259
+ if ($relation == 'OR' && $passedOne) {
260
  return true;
261
  }
262
  return false;
271
  * @param type $evaluate
272
  * @return boolean
273
  */
274
+ public static function evaluateCustom($evaluate, $values) {
275
+ //###############################################################################################
276
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193583580/comments
277
+ //Fix REGEX conditions that contains \ that is stripped out
278
+ if (strpos($evaluate, "REGEX") === false) {
279
+ $evaluate = trim(stripslashes($evaluate));
280
+ // Check dates
281
+ $evaluate = wpv_filter_parse_date($evaluate);
282
+ $evaluate = self::handle_user_function($evaluate);
283
+ }
 
 
 
 
 
 
 
 
284
 
285
+ $fields = self::extractFields($evaluate);
286
+ $evaluate = self::_update_values_in_expression($evaluate, $fields, $values);
 
287
 
288
+ $check = false;
289
+ try {
290
+ $parser = new Toolset_Parser($evaluate);
291
+ $parser->parse();
292
+ $check = $parser->evaluate();
293
+ } catch (Exception $e) {
294
+ $check = false;
295
+ }
296
+ return $check;
297
+ }
298
 
299
+ static function sortByLength($a, $b) {
300
+ return strlen($b) - strlen($a);
301
+ }
302
 
303
+ private static function _update_values_in_expression($evaluate, $fields, $values) {
304
 
305
+ // use string replace to replace any fields with their values.
306
+ // Sort by length just in case a field name contians a shorter version of another field name.
307
+ // eg. $my-field and $my-field-2
308
 
309
+ $keys = array_keys($fields);
310
+ usort($keys, 'WPToolset_Forms_Conditional::sortByLength');
311
 
312
+ foreach ($keys as $key) {
313
+ $value = isset($values[$fields[$key]]) ? $values[$fields[$key]] : '';
314
+ if ($value == '') {
315
+ $value = "''";
316
+ }
317
+ if (is_numeric($value)) {
318
+ $value = '\'' . $value . '\'';
319
+ }
320
 
321
+ if ('array' === gettype($value)) {
 
322
  // workaround for datepicker data to cover all cases
323
+ if (array_key_exists('timestamp', $value)) {
324
+ if (is_numeric($value['timestamp'])) {
325
+ $value = $value['timestamp'];
326
+ } else if (is_array($value['timestamp'])) {
327
+ $value = implode(',', array_values($value['timestamp']));
328
+ }
329
+ } else if (array_key_exists('datepicker', $value)) {
330
+ if (is_numeric($value['datepicker'])) {
331
+ $value = $value['datepicker'];
332
+ } else if (is_array($value['datepicker'])) {
333
+ $value = implode(',', array_values($value['datepicker']));
334
+ }
335
+ } else {
336
+ $value = implode(',', array_values($value));
 
 
 
 
 
 
 
 
 
 
337
  }
338
  }
339
 
340
 
341
+ // First replace the $(field_name) format
342
+ $evaluate = str_replace('$(' . $fields[$key] . ')', $value, $evaluate);
343
+ // next replace the $field_name format
344
+ $evaluate = str_replace('$' . $fields[$key], $value, $evaluate);
345
+ }
346
 
347
+ return $evaluate;
348
+ }
349
 
350
  /**
351
  * Extracts fields from custom conditional statement.
353
  * @param type $evaluate
354
  * @return type
355
  */
356
+ public static function extractFields($evaluate) {
357
+ //###############################################################################################
358
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193583580/comments
359
+ //Fix REGEX conditions that contains \ that is stripped out
360
+ if (strpos($evaluate, "REGEX") === false) {
361
+ $evaluate = trim(stripslashes($evaluate));
362
+ // Check dates
363
+ $evaluate = wpv_filter_parse_date($evaluate);
364
+ $evaluate = self::handle_user_function($evaluate);
365
+ }
366
 
367
  // Add quotes = > < >= <= === <> !==
368
+ $strings_count = preg_match_all('/[=|==|===|<=|<==|<===|>=|>==|>===|\!===|\!==|\!=|<>]\s(?!\$)(\w*)[\)|\$|\W]/', $evaluate, $matches);
369
+
370
+ if (!empty($matches[1])) {
371
+ foreach ($matches[1] as $temp_match) {
372
+ $temp_replace = is_numeric($temp_match) ? $temp_match : '\'' . $temp_match . '\'';
373
+ $evaluate = str_replace(' ' . $temp_match . ')', ' ' . $temp_replace . ')', $evaluate);
 
 
374
  }
375
  }
376
  // if new version $(field-value) use this regex
377
+ if (preg_match('/\$\(([^()]+)\)/', $evaluate)) {
378
+ preg_match_all('/\$\(([^()]+)\)/', $evaluate, $matches);
379
  }
380
  // if old version $field-value use this other
381
+ else {
382
+ preg_match_all('/\$([^\s]*)/', $evaluate, $matches);
383
  }
384
 
385
 
386
  $fields = array();
387
+ if (!empty($matches)) {
388
+ foreach ($matches[1] as $field_name) {
389
+ $fields[trim($field_name, '()')] = trim($field_name, '()');
390
  }
391
  }
392
 
393
  return $fields;
394
  }
395
 
396
+ public static function handle_user_function($evaluate) {
397
+ $evaluate = stripcslashes($evaluate);
 
398
  $occurrences = preg_match_all('/(\\w+)\(([^\)]*)\)/', $evaluate, $matches);
399
 
400
+ if ($occurrences > 0) {
 
401
  for ($i = 0; $i < $occurrences; $i++) {
402
  $result = false;
403
  $function = $matches[1][$i];
404
+ $field = isset($matches[2]) ? rtrim($matches[2][$i], ',') : '';
405
 
406
+ if ($function === 'USER') {
407
+ $result = WPV_Handle_Users_Functions::get_user_field($field);
 
408
  }
409
 
410
+ if ($result) {
411
+ $evaluate = str_replace($matches[0][$i], $result, $evaluate);
412
  }
413
  }
414
  }
421
  */
422
  public static function ajaxCustomConditional() {
423
  $res = array('passed' => array(), 'failed' => array());
424
+ $conditional = stripslashes_deep($_POST['conditions']);
425
+ foreach ($conditional as $k => $c) {
426
+ $post_values = stripslashes_deep($_POST['values']);
427
  $values = array();
428
+ foreach ($post_values as $fid => $value) {
429
+ if (isset($_POST['field_types'][$fid])) {
430
  $field_type = stripslashes_deep($_POST['field_types'][$fid]);
431
+ wptoolset_form_field_add_filters($field_type);
432
+ $value = apply_filters('wptoolset_conditional_value_php', $value, $field_type);
 
433
  }
434
  $values[$fid] = $value;
435
  }
436
+ if ($passed = self::evaluateCustom($c, $values)) {
437
  $res['passed'][] = $k;
438
  } else {
439
  $res['failed'][] = $k;
440
  }
441
  }
442
+ echo json_encode($res);
443
  die();
444
  }
445
 
448
  *
449
  * @param type $config
450
  */
451
+ public function actionFieldClass($config) {
452
  if (
453
+ !empty($config['conditional']) && array_key_exists('conditions', $config['conditional']) && !self::evaluate($config['conditional'])
 
 
454
  ) {
455
  echo ' wpt-hidden js-wpt-remove-on-submit js-wpt-validation-ignore';
456
  }
461
  *
462
  * @return type
463
  */
464
+ public function getData() {
465
  $this->_parseData();
466
  return array(
467
  'triggers' => $this->_triggers,
473
 
474
  }
475
 
476
+ if (!class_exists('WPV_Handle_Users_Functions')) {
477
 
478
+ class WPV_Handle_Users_Functions {
 
 
 
479
 
480
  private static $field;
481
 
482
+ public static function get_user_field($field) {
483
+ if (!$field)
484
+ return false;
485
 
486
  self::$field = str_replace("'", '', $field);
487
 
488
+ $ret = self::get_info();
489
 
490
+ if ($ret !== false)
491
+ return "'" . $ret . "'";
492
 
493
  return false;
494
  }
495
 
496
+ private static function get_info() {
 
497
  global $current_user;
498
 
499
  get_currentuserinfo();
500
 
501
+ switch (self::$field) {
 
502
  case 'role':
503
  return isset($current_user->roles[0]) ? $current_user->roles[0] : 'Subscriber';
504
  break;
518
 
519
  return false;
520
  }
521
+
522
  }
523
+
524
  }
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.4/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.5/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.4/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.5/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.4/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.5/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.4/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.5/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.scripts.php CHANGED
@@ -121,7 +121,7 @@ class WPToolset_Field_Date_Scripts
121
  'yearMin' => intval( self::timetodate( self::$_mintimestamp, 'Y' ) ) + 1,
122
  'yearMax' => self::timetodate( self::$_maxtimestamp, 'Y' ),
123
  'ajaxurl' => admin_url('admin-ajax.php', null),
124
- 'readonly' => esc_js( __( 'This is a readonly date input', 'wpv-views' ) ),
125
  'readonly_image' => $calendar_image_readonly,
126
  );
127
  wp_localize_script( 'wptoolset-field-date', 'wptDateData', $js_data );
121
  'yearMin' => intval( self::timetodate( self::$_mintimestamp, 'Y' ) ) + 1,
122
  'yearMax' => self::timetodate( self::$_maxtimestamp, 'Y' ),
123
  'ajaxurl' => admin_url('admin-ajax.php', null),
124
+ 'readonly' => esc_js( __( 'This is a read-only date input', 'wpv-views' ) ),
125
  'readonly_image' => $calendar_image_readonly,
126
  );
127
  wp_localize_script( 'wptoolset-field-date', 'wptDateData', $js_data );
embedded/common/toolset-forms/classes/class.eforms.php CHANGED
@@ -1,19 +1,20 @@
1
  <?php
 
2
  /* Copyright 2011 enlimbo lancers (email : lancers@enlimbo.net)
3
 
4
- This program is free software; you can redistribute it and/or
5
- modify it under the terms of the GNU General Public License
6
- as published by the Free Software Foundation; either version 2
7
- of the License, or (at your option) any later version.
8
 
9
- This program is distributed in the hope that it will be useful,
10
- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- GNU General Public License for more details.
13
 
14
- You should have received a copy of the GNU General Public License
15
- along with this program; if not, write to the Free Software
16
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
  */
18
 
19
  /**
@@ -27,22 +28,20 @@
27
  * @link http://enlimbo.net/forms
28
  * @author srdjan <srdjan@enlimbo.net>
29
  *
30
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/common/toolset-forms/classes/class.eforms.php $
31
- * $LastChangedDate: 2014-10-29 15:57:36 +0000 (Wed, 29 Oct 2014) $
32
- * $LastChangedRevision: 1016002 $
33
  * $LastChangedBy: iworks $
34
  *
35
  */
36
-
37
- /*
38
- Element attributes
39
-
40
- General rules when adding attributes to an element using strings in chunks
41
- * always start the chunk with a space and do not end the chunk with another space
42
- * mind the closing tags and add a space when needed
43
  */
44
- class Enlimbo_Forms
45
- {
46
 
47
  /**
48
  * @var string
@@ -79,8 +78,7 @@ class Enlimbo_Forms
79
  */
80
  public $form_settings = array();
81
 
82
- public function __construct( $id )
83
- {
84
  /**
85
  * default settings
86
  */
@@ -89,21 +87,23 @@ class Enlimbo_Forms
89
  'use_bootstrap' => false,
90
  );
91
  $this->_id = $id;
92
- if ( !is_admin() ) {// TODO check also doing_ajax as this gives false positives
93
- $cred_form_id = preg_replace( '/^cred_form_(\d+)_\d+$/', "$1", $this->_id );
94
- $form_settings = get_post_meta( $cred_form_id, '_cred_form_settings', true );
95
- if ( isset($form_settings->form) ) {
 
96
  $this->form_settings = $form_settings->form;
97
  }
98
  unset($form_settings);
99
- /**
100
- * check CRED setting for bootstrap: only on frontend
101
- */
102
- $cred_cred_settings = get_option( 'cred_cred_settings' );
103
- if ( is_array($cred_cred_settings) ) {
104
- $this->form_settings['use_bootstrap'] = array_key_exists( 'use_bootstrap', $cred_cred_settings ) && $cred_cred_settings['use_bootstrap'];;
105
- }
106
- }
 
107
  }
108
 
109
  /**
@@ -114,8 +114,7 @@ class Enlimbo_Forms
114
  * @param array $element
115
  * @return HTML formatted output
116
  */
117
- public function autoHandle($id, $form)
118
- {
119
  // Auto-add nonce field
120
  $form['nonce'] = array(
121
  '#type' => 'hidden',
@@ -167,13 +166,11 @@ class Enlimbo_Forms
167
  * @param type $id
168
  * @return type
169
  */
170
- public function isSubmitted($id = '')
171
- {
172
  if (empty($id)) {
173
  $id = $this->_id;
174
  }
175
- return (isset($_REQUEST['_nonce'])
176
- && md5($_REQUEST['_nonce']) == $id);
177
  }
178
 
179
  /**
@@ -191,23 +188,18 @@ class Enlimbo_Forms
191
  *
192
  * @param type $elements
193
  */
194
- public function validate(&$elements)
195
- {
196
  foreach ($elements as $key => &$element) {
197
- if (!isset($element['#type'])
198
- || !$this->_isValidType($element['#type'])) {
199
  continue;
200
  }
201
  if ($element['#type'] != 'fieldset') {
202
- if (isset($element['#name'])
203
- && !in_array($element['#type'], array('submit', 'reset'))) {
204
  if ($this->isSubmitted()) {
205
  // Set submitted data
206
- if (!in_array($element['#type'], array('checkboxes'))
207
- && empty($element['#forced_value'])) {
208
  $element['#value'] = $this->getSubmittedData($element);
209
- } else if (!empty($element['#options'])
210
- && empty($element['#forced_value'])) {
211
  foreach ($element['#options'] as $option_key => $option) {
212
  $option['#type'] = 'checkbox';
213
  $element['#options'][$option_key]['#value'] = $this->getSubmittedData($option);
@@ -219,8 +211,7 @@ class Enlimbo_Forms
219
  if (isset($element['#validate'])) {
220
  $this->validateElement($element);
221
  }
222
- } else if (isset($element['#type'])
223
- && $element['#type'] == 'fieldset') {
224
  $this->validate($element);
225
  } else if (is_array($element)) {
226
  $this->validate($element);
@@ -233,15 +224,13 @@ class Enlimbo_Forms
233
  *
234
  * @param type $element
235
  */
236
- public function validateElement( &$element )
237
- {
238
- $value = isset( $element['#value'] ) ? $element['#value'] : null;
239
- if ( is_null( $value ) && isset( $element['#default_value'] ) ) {
240
  $value = $element['#default_value'];
241
  }
242
- $element = apply_filters( 'wptoolset_form_' . $this->_id . '_validate_field',
243
- $element, $value );
244
- if ( isset( $element['error'] ) ) {
245
  $this->_errors = true;
246
  $_errors = $element['error']->get_error_data();
247
  $element['#error'] = $_errors[0];
@@ -253,16 +242,14 @@ class Enlimbo_Forms
253
  *
254
  * @return type
255
  */
256
- public function isError()
257
- {
258
  return $this->_errors;
259
  }
260
 
261
  /**
262
  * Sets errors to true.
263
  */
264
- public function triggerError()
265
- {
266
  $this->_errors = true;
267
  }
268
 
@@ -271,8 +258,7 @@ class Enlimbo_Forms
271
  *
272
  * @return type
273
  */
274
- public function renderForm()
275
- {
276
  // loop over elements and render them
277
  return $this->renderElements($this->_elements);
278
  }
@@ -297,12 +283,10 @@ class Enlimbo_Forms
297
  * @param string $type
298
  * @return boolean
299
  */
300
- private function _isValidType($type)
301
- {
302
- return in_array($type,
303
- array('select', 'checkboxes', 'checkbox', 'radios',
304
- 'radio', 'textfield', 'textarea', 'file', 'submit', 'reset',
305
- 'hidden', 'fieldset', 'markup', 'button', 'password' ));
306
  }
307
 
308
  /**
@@ -311,31 +295,31 @@ class Enlimbo_Forms
311
  * @param type $elements
312
  * @return type
313
  */
314
- public function renderElements($elements)
315
- {
316
  $output = '';
317
- if (!isset($elements)) return $output;
318
- foreach ($elements as $key => $element) {
 
319
  if (!isset($element['#type']) || !$this->_isValidType($element['#type'])) {
320
  continue;
321
  }
322
  if ($element['#type'] != 'fieldset') {
323
-
324
  /**
325
- * Temporary fixing validation for checkbox/radios/skype because _cakeValidation is not working for thats
326
- * https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/186243370/comments
327
- */
328
  if (!is_admin()) {
329
- if ($element['#type']=='radios') {
330
  if (isset($element['#error'])) {
331
- if (isset($element['#options'])&&count($element['#options'])>0&&!isset($element['#options'][0]['#error']))
332
- $element['#options'][0]['#error']=$element['#error'];
333
  }
334
  }
335
  }
336
  //##################################################################################################
337
-
338
- $output .= $this->renderElement($element);
339
  } else if (isset($element['#type']) && $element['#type'] == 'fieldset') {
340
  $buffer = $this->renderElements($element);
341
  $output .= $this->fieldset($element, 'wrap', $buffer);
@@ -354,10 +338,9 @@ class Enlimbo_Forms
354
  * @param array $element
355
  * @return HTML formatted output
356
  */
357
- public function renderElement($element)
358
- {
359
  $method = $element['#type'];
360
- if (!isset($element['#name']) && !in_array( $element['#type'], array('markup', 'checkboxes'))) {
361
  if (!isset($element['#attributes']['name'])) {
362
  return '#name or #attributes[\'name\'] required!';
363
  } else {
@@ -366,55 +349,49 @@ class Enlimbo_Forms
366
  }
367
  if (is_callable(array($this, $method))) {
368
  $custom_field_title = '';
369
- if ( isset($element['#title']) && !empty($element['#title']) ){
370
- $custom_field_title = $element['#title'];
371
  }
372
 
373
- if ( empty($custom_field_title) && isset($element['#name']) && !empty($element['#name']) ){
374
- $custom_field_title = $element['#name'];
375
  }
376
  if (!isset($element['#id'])) {
377
  if (isset($element['#attributes']['id'])) {
378
  $element['#id'] = $element['#attributes']['id'];
379
  } else {
380
- $_id = isset( $this->_id ) ? $this->_id . '-' : '';
381
  $element['#id'] = "{$_id}{$element['#type']}-"
382
  . $this->_count($element['#type']) . '-' . time();
383
  }
384
  }
385
-
386
  if (isset($this->_errors[$element['#id']])) {
387
  $element['#error'] = $this->_errors[$element['#id']];
388
  }
389
  // Add JS validation
390
- if ( !empty( $element['#validate'] ) ) {
391
- if ( isset( $element['#validate']['required'] )
392
- && !empty( $element['#title'] ) ) {
393
  // Asterisk
394
  $element['#title'] .= '&#42;';
395
  }
396
- $element['#attributes']['data-wpt-validate'] = esc_html( self::json_encode( apply_filters( 'wptoolset_forms_field_js_validation_data_' . $this->_id,
397
- $element['#validate'] ) ) );
398
- $element['#attributes']['data-wpt-field-title'] = esc_js( $custom_field_title );
399
  }
400
- if ( $element['#type'] == 'radios' && !empty( $element['#options'] ) ) {
401
- foreach ( $element['#options'] as &$option ) {
402
- if ( !empty( $option['#validate'] ) ) {
403
- $option['#attributes']['data-wpt-validate'] = esc_html( self::json_encode( apply_filters( 'wptoolset_forms_field_js_validation_data_' . $this->_id,
404
- $option['#validate'] ) ) );
405
- $option['#attributes']['data-wpt-field-title'] = esc_js( $custom_field_title );
406
  }
407
  }
408
  }
409
  /**
410
  * WPML - lock CF is has option "copy from original".
411
  */
412
- if ( is_admin() && function_exists('wpcf_wpml_field_is_copied') && wpcf_wpml_field_is_copied($element) ) {
413
  $element['#title'] .= sprintf(
414
- '<img src="%s/images/locked.png" alt="%s" title="%s" style="position:relative;left:2px;top:2px;" />',
415
- WPCF_EMBEDDED_RES_RELPATH,
416
- __( 'This field is locked for editing because WPML will copy its value from the original language.', 'wpcf' ),
417
- __( 'This field is locked for editing because WPML will copy its value from the original language.', 'wpcf' )
418
  );
419
  $element['#attributes']['readonly'] = true;
420
  }
@@ -428,58 +405,56 @@ class Enlimbo_Forms
428
  * @param array $element
429
  * @return string
430
  */
431
- private function _setElementAttributes($element)
432
- {
433
  $attributes = '';
434
 
435
  $classes = array();
436
  $classes[] = $this->css_class . '-' . $element['#type'];
437
  $classes[] = 'form-' . $element['#type'];
438
 
439
- if ( $this->form_settings['use_bootstrap'] ) {
440
- switch( $element['#type'] ) {
441
- case 'hidden':
442
- case 'button':
443
- case 'submit':
444
- case 'radio':
445
- case 'checkbox':
446
- case 'file':
447
- break;
448
- default:
449
- $classes[] = 'form-control';
450
  }
451
  } else {
452
- if ( 'hidden' != $element['#type'] ) {
453
  $classes[] = $element['#type'];
454
  }
455
  }
456
 
457
- if ( isset( $element['#attributes'] )
458
- && !empty( $element['#attributes'] )
459
- ) {
460
- if ( isset( $element['#attributes']['class'] ) ) {
461
- $element['#attributes']['class'] .= ' ' . implode( ' ', $classes );
462
- } else {
463
- $element['#attributes']['class'] = implode( ' ', $classes );
464
- }
465
- } else {
466
- $element['#attributes'] = array(
467
- 'class' => implode( ' ', $classes )
468
- );
469
  }
470
 
471
-
472
- foreach ($element['#attributes'] as $attribute => $value) {
473
- // Prevent undesired elements
474
- if (in_array($attribute, array('id', 'name'))) {
475
- continue;
476
- }
477
- // Don't set disabled for checkbox
478
- if ($attribute == 'disabled' && $element['#type'] == 'checkbox') {
479
- continue;
480
- }
481
- // Set return string
482
- $attributes .= ' ' . $attribute . '="' . $value . '"';
483
  }
484
 
485
  return $attributes;
@@ -490,8 +465,7 @@ class Enlimbo_Forms
490
  *
491
  * @param array $element
492
  */
493
- private function _setRender($element)
494
- {
495
  if (!isset($element['#id'])) {
496
  if (isset($element['#attributes']['id'])) {
497
  $element['#id'] = $element['#attributes']['id'];
@@ -512,22 +486,20 @@ class Enlimbo_Forms
512
  * label
513
  */
514
  $element['_render']['label'] = '';
515
- if ( isset($element['#title']) ) {
516
  $classes = array();
517
  $classes[] = sprintf('%s-label', $this->css_class);
518
  $classes[] = sprintf('%s-%s-label', $this->css_class, $element['#type']);
519
- if ( $this->form_settings['use_bootstrap']) {
520
- switch( $element['#type'] ) {
521
- case 'checkbox':
522
- case 'radio':
523
- $classes[] = 'control-label';
524
- break;
525
  }
526
  }
527
  $element['_render']['label'] .= sprintf(
528
- '<label class="%s" for="%s">',
529
- implode(' ', $classes),
530
- $element['#id']
531
  );
532
  $element['_render']['label'] .= stripslashes($element['#title']);
533
  $element['_render']['label'] .= '</label>';
@@ -544,8 +516,7 @@ class Enlimbo_Forms
544
  * Accepts: <prefix><suffix><label><title><desription><error>
545
  * @param array $element
546
  */
547
- private function _pattern($pattern, $element)
548
- {
549
  $pattern = strtolower($pattern);
550
  foreach ($element['_render'] as $key => $value) {
551
  $pattern = str_replace('<' . strtolower($key) . '>', $value, $pattern);
@@ -560,28 +531,24 @@ class Enlimbo_Forms
560
  * @param string $output
561
  * @return string
562
  */
563
- private function _wrapElement($element, $output)
564
- {
565
  if (!empty($element['#inline'])) {
566
  return $output;
567
  }
568
  $classes = array();
569
  $classes[] = 'form-item';
570
  $classes[] = 'form-item-' . $element['#type'];
571
- $classes[] = $this->css_class . '-item';
572
- $classes[] = $this->css_class . '-item-' . $element['#type'];
573
- if ( $this->form_settings['use_bootstrap'] ) {
574
  $classes[] = 'form-group';
575
  }
576
- if ( preg_match( '/_hidden$/', $element['#id'] ) && !is_admin() ) {
577
  $classes[] = 'wpt-form-hide-container';
578
  }
579
- if ( is_admin() ) {
580
  return sprintf(
581
- '<div id="%s-wrapper" class="%s">%s</div>',
582
- $element['#id'],
583
- implode( ' ', $classes ),
584
- $output
585
  );
586
  }
587
  return $output;
@@ -593,8 +560,7 @@ class Enlimbo_Forms
593
  * @param string $element
594
  * @return string
595
  */
596
- private function _setElementTitle($element)
597
- {
598
  $output = '';
599
  if (isset($element['#title'])) {
600
  $output .= '<div class="title '
@@ -613,9 +579,9 @@ class Enlimbo_Forms
613
  * @param array $element
614
  * @return string
615
  */
616
- private function _setElementDescription($element)
617
- {
618
- if ( empty( $element['#description'] ) ) return '';
619
  $element['#description'] = stripslashes($element['#description']);
620
  $output = "\r\n"
621
  . '<div class="description '
@@ -634,8 +600,7 @@ class Enlimbo_Forms
634
  * @param array $element
635
  * @return string
636
  */
637
- public function renderError($element)
638
- {
639
  if (!isset($element['#error'])) {
640
  return '';
641
  }
@@ -660,8 +625,7 @@ class Enlimbo_Forms
660
  * @param string $wrap_content HTML formatted output of child elements
661
  * @return string
662
  */
663
- public function fieldset($element, $action = 'open', $wrap_content = '')
664
- {
665
  $collapsible_open = '<div class="fieldset-wrapper">';
666
  $collapsible_close = '</div>';
667
  $legend_class = '';
@@ -671,15 +635,13 @@ class Enlimbo_Forms
671
  if (!isset($element['_attributes_string'])) {
672
  $element['_attributes_string'] = $this->_setElementAttributes($element);
673
  }
674
- if ((isset($element['#collapsible']) && $element['#collapsible'])
675
- || (isset($element['#collapsed']) && $element['#collapsed'])) {
676
  $collapsible_open = '<div class="collapsible fieldset-wrapper">';
677
  $collapsible_close = '</div>';
678
  $legend_class = ' class="legend-expanded"';
679
  }
680
  if (isset($element['#collapsed']) && $element['#collapsed']) {
681
- $collapsible_open = str_replace('class="', 'class="collapsed ',
682
- $collapsible_open);
683
  $legend_class = ' class="legend-collapsed"';
684
  }
685
  $output = '';
@@ -733,19 +695,18 @@ class Enlimbo_Forms
733
  * @param array $element
734
  * @return string
735
  */
736
- public function checkbox($element)
737
- {
738
  $element['#type'] = 'checkbox';
739
  $element = $this->_setRender($element);
740
  $element['_render']['element'] = '<input type="checkbox"';
741
- foreach( array( 'id', 'name' ) as $key ) {
742
- $element['_render']['element'] .= sprintf( ' %s="%s"', $key, $element['#'.$key] );
743
  }
744
  /**
745
  * type and data_id
746
  */
747
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
748
- $element['_render']['element'] .= $this->_getDataWptId( $element );
749
 
750
  $element['_render']['element'] .= ' value="';
751
  /**
@@ -753,19 +714,17 @@ class Enlimbo_Forms
753
  * but if is defined default value, use default
754
  */
755
  $value = 1;
756
- if ( array_key_exists( '#default_value', $element ) ) {
757
  $value = $element['#default_value'];
758
  }
759
- $element['_render']['element'] .= ( empty($element['#value']) && !preg_match( '/^0$/', $element['#value']) )? $value:esc_attr($element['#value']);
760
  $element['_render']['element'] .= '"' . $element['_attributes_string'];
761
  if (
762
- (
763
  !$this->isSubmitted() && (
764
- ( !empty($element['#default_value']) && $element['#default_value'] == $element['#value'] )
765
- || ( isset($element['#checked']) && $element['#checked'] )
766
  )
767
- )
768
- || ($this->isSubmitted() && !empty($element['#value']))
769
  ) {
770
  $element['_render']['element'] .= ' checked="checked"';
771
  }
@@ -774,7 +733,7 @@ class Enlimbo_Forms
774
  }
775
  $element['_render']['element'] .= ' />';
776
 
777
- $pattern = $this->_getStatndardPatern( $element, '<BEFORE><PREFIX><ELEMENT>&nbsp;<LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>');
778
  $output = $this->_pattern($pattern, $element);
779
  $output = $this->_wrapElement($element, $output);
780
  return $output . "\r\n";
@@ -789,8 +748,7 @@ class Enlimbo_Forms
789
  * @param array $element
790
  * @return string
791
  */
792
- public function checkboxes($element)
793
- {
794
  $element['#type'] = 'checkboxes';
795
  $element = $this->_setRender($element);
796
  $clone = $element;
@@ -802,7 +760,7 @@ class Enlimbo_Forms
802
  }
803
  $element['_render']['element'] .= $this->checkbox($value);
804
  }
805
- $pattern = $this->_getStatndardPatern( $element, '<BEFORE><PREFIX><TITLE><DESCRIPTION><ELEMENT><SUFFIX><AFTER>' );
806
  $output = $this->_pattern($pattern, $element);
807
  $output = $this->_wrapElement($element, $output);
808
  return $output;
@@ -814,8 +772,7 @@ class Enlimbo_Forms
814
  * @param array $element
815
  * @return string
816
  */
817
- public function radio($element)
818
- {
819
  $element['#type'] = 'radio';
820
  $element = $this->_setRender($element);
821
  $element['_render']['element'] = '<input type="radio" id="'
@@ -824,22 +781,21 @@ class Enlimbo_Forms
824
  $element['_render']['element'] .= isset($element['#value']) ? htmlspecialchars($element['#value']) : $this->_count['radio'];
825
  $element['_render']['element'] .= '"';
826
  $element['_render']['element'] .= $element['_attributes_string'];
827
- $element['_render']['element'] .= ( isset($element['#value'])
828
- && $element['#value'] === $element['#default_value']) ? ' checked="checked"' : '';
829
  if (isset($element['#disable']) && $element['#disable']) {
830
  $element['_render']['element'] .= ' disabled="disabled"';
831
  }
832
- if ( array_key_exists( '#types-value', $element ) ) {
833
- $element['_render']['element'] .= sprintf( ' data-types-value="%s"', $element['#types-value'] );
834
  }
835
  /**
836
  * type and data_id
837
  */
838
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
839
- $element['_render']['element'] .= $this->_getDataWptId( $element );
840
 
841
  $element['_render']['element'] .= ' />';
842
-
843
  $pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><PREFIX><ELEMENT>&nbsp;<LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
844
  $output = $this->_pattern($pattern, $element);
845
  $output = $this->_wrapElement($element, $output);
@@ -855,8 +811,7 @@ class Enlimbo_Forms
855
  * @param array $element
856
  * @return string
857
  */
858
- public function radios($element)
859
- {
860
  if (!isset($element['#name']) || empty($element['#name'])) {
861
  return FALSE;
862
  }
@@ -880,7 +835,7 @@ class Enlimbo_Forms
880
  } else {
881
  $pattern = '<BEFORE><PREFIX><DESCRIPTION><ELEMENT><SUFFIX><AFTER>';
882
  }
883
-
884
  $pattern = $this->_getStatndardPatern($element, $pattern);
885
  $output = $this->_pattern($pattern, $element);
886
  $output = $this->_wrapElement($element, $output);
@@ -893,24 +848,23 @@ class Enlimbo_Forms
893
  * @param array $element
894
  * @return string
895
  */
896
- public function select($element)
897
- {
898
  $element = $this->_setRender($element);
899
 
900
  $element['_render']['element'] = '';
901
  $element['_render']['element'] .= '<select id="' . $element['#id'] . '" ';
902
  $element['_render']['element'] .= $element['_attributes_string'];
903
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
904
  /**
905
  * multiple
906
  */
907
- if ( array_key_exists( '#multiple', $element ) && $element['#multiple'] ) {
908
  $element['_render']['element'] .= ' multiple="multiple"';
909
  $element['_render']['element'] .= ' name="' . $element['#name'] . '[]"';
910
  } else {
911
  $element['_render']['element'] .= ' name="' . $element['#name'] . '"';
912
  }
913
- $element['_render']['element'] .= ">\r\n";
914
  $count = 1;
915
  foreach ($element['#options'] as $id => $value) {
916
  if (!is_array($value)) {
@@ -923,22 +877,22 @@ class Enlimbo_Forms
923
  }
924
  $element['_render']['element'] .= '<option value="' . htmlspecialchars($value['#value']) . '"';
925
  $element['_render']['element'] .= $this->_setElementAttributes($value);
926
- if ( array_key_exists( '#types-value', $value ) ) {
927
- $element['_render']['element'] .= sprintf( ' data-types-value="%s"', $value['#types-value'] );
928
  }
929
  /**
930
  * type and data_id
931
  */
932
  $element['_render']['element'] .= ' data-wpt-type="option"';
933
- $element['_render']['element'] .= $this->_getDataWptId( $element );
934
  /**
935
  * selected
936
  */
937
- if ( array_key_exists( '#multiple', $element ) && $element['#multiple'] ) {
938
- if ( is_array( $element['#default_value'] ) && in_array( $value['#value'], $element['#default_value'] ) ) {
939
  $element['_render']['element'] .= ' selected="selected"';
940
  }
941
- } elseif ( $element['#default_value'] == $value['#value']) {
942
  $element['_render']['element'] .= ' selected="selected"';
943
  }
944
  $element['_render']['element'] .= '>';
@@ -948,7 +902,7 @@ class Enlimbo_Forms
948
  $element['_render']['element'] .= '</select>';
949
  $element['_render']['element'] .= PHP_EOL;
950
 
951
- $pattern = $this->_getStatndardPatern( $element );
952
  $output = $this->_pattern($pattern, $element);
953
  $output = $this->_wrapElement($element, $output);
954
 
@@ -961,16 +915,15 @@ class Enlimbo_Forms
961
  * @param array $element
962
  * @return string
963
  */
964
- public function textfield($element)
965
- {
966
  $element['#type'] = 'textfield';
967
  $element = $this->_setRender($element);
968
 
969
  $element['_render']['element'] = '<input type="text"';
970
  //$element['_render']['element'] .= sprintf( ' data-wpt-type="%s" ', __FUNCTION__ );
971
- $element['_render']['element'] .= sprintf( ' id="%s"', $element['#id']);
972
- $element['_render']['element'] .= sprintf( ' name="%s"', $element['#name']);
973
- $element['_render']['element'] .= sprintf( ' value="%s"', isset($element['#value']) ? esc_attr($element['#value']) : '' );
974
  $element['_render']['element'] .= $element['_attributes_string'];
975
  if (isset($element['#disable']) && $element['#disable']) {
976
  $element['_render']['element'] .= ' disabled="disabled"';
@@ -978,11 +931,11 @@ class Enlimbo_Forms
978
  /**
979
  * type and data_id
980
  */
981
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
982
- $element['_render']['element'] .= $this->_getDataWptId( $element );
983
 
984
  $element['_render']['element'] .= ' />';
985
- $pattern = $this->_getStatndardPatern( $element );
986
  $output = $this->_pattern($pattern, $element);
987
  $output = $this->_wrapElement($element, $output);
988
  return $output . "\r\n";
@@ -994,8 +947,7 @@ class Enlimbo_Forms
994
  * @param array $element
995
  * @return string
996
  */
997
- public function password($element)
998
- {
999
  $element['#type'] = 'password';
1000
  $element = $this->_setRender($element);
1001
  $element['_render']['element'] = '<input type="password" id="'
@@ -1008,8 +960,8 @@ class Enlimbo_Forms
1008
  /**
1009
  * type and data_id
1010
  */
1011
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
1012
- $element['_render']['element'] .= $this->_getDataWptId( $element );
1013
 
1014
  $element['_render']['element'] .= ' />';
1015
  $pattern = $this->_getStatndardPatern($element);
@@ -1024,8 +976,7 @@ class Enlimbo_Forms
1024
  * @param array $element
1025
  * @return string
1026
  */
1027
- public function textarea($element)
1028
- {
1029
  $element['#type'] = 'textarea';
1030
  if (!isset($element['#attributes']['rows'])) {
1031
  $element['#attributes']['rows'] = 5;
@@ -1040,14 +991,14 @@ class Enlimbo_Forms
1040
  /**
1041
  * type and data_id
1042
  */
1043
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
1044
- $element['_render']['element'] .= $this->_getDataWptId( $element );
1045
 
1046
  $element['_render']['element'] .= '>';
1047
 
1048
  $element['_render']['element'] .= isset($element['#value']) ? esc_attr($element['#value']) : '';
1049
  $element['_render']['element'] .= '</textarea>' . "\r\n";
1050
- $pattern = $this->_getStatndardPatern( $element );
1051
  $output = $this->_pattern($pattern, $element);
1052
  $output = $this->_wrapElement($element, $output);
1053
  return $output . "\r\n";
@@ -1059,8 +1010,7 @@ class Enlimbo_Forms
1059
  * @param array $element
1060
  * @return string
1061
  */
1062
- public function file($element)
1063
- {
1064
  $element['#type'] = 'file';
1065
  $element = $this->_setRender($element);
1066
  $element['_render']['element'] = '<input type="file" id="'
@@ -1072,11 +1022,11 @@ class Enlimbo_Forms
1072
  /**
1073
  * type and data_id
1074
  */
1075
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
1076
- $element['_render']['element'] .= $this->_getDataWptId( $element );
1077
 
1078
  $element['_render']['element'] .= ' />';
1079
- $pattern = $this->_getStatndardPatern( $element );
1080
  $output = $this->_pattern($pattern, $element);
1081
  $output = $this->_wrapElement($element, $output);
1082
  return $output;
@@ -1088,8 +1038,7 @@ class Enlimbo_Forms
1088
  * @param array $element
1089
  * @return string
1090
  */
1091
- public function markup($element)
1092
- {
1093
  return $element['#markup'];
1094
  }
1095
 
@@ -1099,14 +1048,13 @@ class Enlimbo_Forms
1099
  * @param array $element
1100
  * @return string
1101
  */
1102
- public function hidden($element)
1103
- {
1104
  $element['#type'] = 'hidden';
1105
  $element = $this->_setRender($element);
1106
  $output = '<input type="hidden" id="' . $element['#id'] . '" name="'
1107
  . $element['#name'] . '" value="';
1108
  $output .= isset($element['#value']) ? $element['#value'] : 1;
1109
- $output .= '"' . $element['_attributes_string'] . $this->_getDataWptId( $element ) . ' />';
1110
  return $output;
1111
  }
1112
 
@@ -1116,8 +1064,7 @@ class Enlimbo_Forms
1116
  * @param array $element
1117
  * @return string
1118
  */
1119
- public function reset($element)
1120
- {
1121
  return $this->submit($element, 'reset', 'Reset');
1122
  }
1123
 
@@ -1127,8 +1074,7 @@ class Enlimbo_Forms
1127
  * @param array $element
1128
  * @return string
1129
  */
1130
- public function button($element)
1131
- {
1132
  return $this->submit($element, 'button', 'Button');
1133
  }
1134
 
@@ -1142,8 +1088,7 @@ class Enlimbo_Forms
1142
  * @param string $title
1143
  * @return string
1144
  */
1145
- public function submit($element, $type = 'submit', $title = 'Submit')
1146
- {
1147
  $element['#type'] = $type;
1148
  $element = $this->_setRender($element);
1149
  $element['_render']['element'] = '<input type="' . $type . '" id="'
@@ -1151,7 +1096,7 @@ class Enlimbo_Forms
1151
  $element['_render']['element'] .= isset($element['#value']) ? $element['#value'] : $title;
1152
  $element['_render']['element'] .= '"' . $element['_attributes_string']
1153
  . ' />';
1154
- $pattern = $this->_getStatndardPatern( $element, '<BEFORE><PREFIX><ELEMENT><SUFFIX><AFTER>' );
1155
  $output = $this->_pattern($pattern, $element);
1156
  return $output;
1157
  }
@@ -1162,20 +1107,17 @@ class Enlimbo_Forms
1162
  * @param type $element
1163
  * @return type mixed
1164
  */
1165
- public function getSubmittedData($element)
1166
- {
1167
  $name = $element['#name'];
1168
  if (strpos($name, '[') === false) {
1169
  if ($element['#type'] == 'file') {
1170
  return $_FILES[$name]['tmp_name'];
1171
  }
1172
- return isset($_REQUEST[$name]) ? $_REQUEST[$name] : in_array($element['#type'],
1173
- array('textfield', 'textarea')) ? '' : 0;
1174
  }
1175
 
1176
  $parts = explode('[', $name);
1177
- $parts = array_map(create_function('&$a', 'return trim($a, \']\');'),
1178
- $parts);
1179
  if (!isset($_REQUEST[$parts[0]])) {
1180
  return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
1181
  }
@@ -1184,14 +1126,12 @@ class Enlimbo_Forms
1184
  $key = $parts[$index];
1185
  // We're at the end but no data retrieved
1186
  if (!isset($parts[$index + 1])) {
1187
- return in_array($element['#type'],
1188
- array('textfield', 'textarea')) ? '' : 0;
1189
  }
1190
  $key_next = $parts[$index + 1];
1191
  if ($index > 0) {
1192
  if (!isset($search[$key])) {
1193
- return in_array($element['#type'],
1194
- array('textfield', 'textarea')) ? '' : 0;
1195
  } else {
1196
  $search = $search[$key];
1197
  }
@@ -1205,25 +1145,23 @@ class Enlimbo_Forms
1205
  return 0;
1206
  }
1207
 
1208
- private function _getDataWptId($element)
1209
- {
1210
  $html = '';
1211
- if ( array_key_exists( '#id', $element ) ) {
1212
- if ( is_admin() ) {
1213
- $html .= sprintf( ' data-wpt-id="%s"', preg_replace( '/\[/', '-', preg_replace( '/\]/', '', $element['#name'] ) ) );
1214
  } else {
1215
- $html .= sprintf( ' data-wpt-id="%s_%s"', $this->_id, $element['#id'] );
1216
  }
1217
- if ( array_key_exists( '#name', $element ) && $element['#name'] ) {
1218
- if ( !is_admin() && $this->_isRepetitive($element)) {
1219
- $html .= sprintf( ' data-wpt-name="%s"', preg_replace( '/\[.+$/', '', $element['#name'] ) );
1220
  } else {
1221
- if ( preg_match( '/^wpcf_post_relationship\[\d+\]\[\d+\]\[[^\]]+\]/', $element['#name'] ) ) {
1222
  $html .= sprintf(
1223
- ' data-wpt-name="%s"',
1224
- preg_replace( '/^wpcf_post_relationship\[\d+\]\[(\d+)\]\[wpcf-([^\]]+)\]/', "wpcf[$2-$1]", $element['#name'] ) );
1225
  } else {
1226
- $html .= sprintf( ' data-wpt-name="%s"', $element['#name'] );
1227
  }
1228
  }
1229
  }
@@ -1231,63 +1169,60 @@ class Enlimbo_Forms
1231
  return $html;
1232
  }
1233
 
1234
- private function _getStatndardPatern($element, $default = false )
1235
- {
1236
- if ( isset($element['#pattern'] ) ) {
1237
  return $element['#pattern'];
1238
  }
1239
- if ( $default ) {
1240
  return $default;
1241
  }
1242
- if ( is_admin() ) {
1243
  return '<BEFORE><LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
1244
  }
1245
  return '<BEFORE><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
1246
  }
1247
 
1248
- private function _isRepetitive($element)
1249
- {
1250
- if ( !is_array($element) ) {
1251
  return false;
1252
  }
1253
- return array_key_exists( '#repetitive', $element ) && $element['#repetitive'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1254
  }
1255
-
1256
- static function json_encode( $array )
1257
- {
1258
- // php > 5.3 do not escape utf-8 characters using native constant argument
1259
- if( defined('JSON_UNESCAPED_UNICODE') )
1260
- {
1261
- return json_encode($array, JSON_UNESCAPED_UNICODE );
1262
- }
1263
- // fallback for php < 5.3 to support unicode characters in json string
1264
- else
1265
- {
1266
- if (function_exists('mb_decode_numericentity')) {
1267
- return self::json_encode_unescaped_unicode( $array );
1268
- } else {
1269
- return json_encode( $array );
1270
- }
1271
- }
1272
- }
1273
-
1274
- /**
1275
- * @param $arr
1276
- * @return string
1277
- * courtesy from: http://www.php.net/manual/ru/function.json-encode.php#105789
1278
- */
1279
- public static function json_encode_unescaped_unicode($arr)
1280
- {
1281
-
1282
- array_walk_recursive($arr, array(__CLASS__, 'json_unescaped_unicode_walk_callback' ));
1283
-
1284
- return mb_decode_numericentity(json_encode($arr), array (0x80, 0xffff, 0, 0xffff), 'UTF-8');
1285
- }
1286
 
1287
  /*
1288
  * Helper function to json_encode with UTF-8 support for php < 5.3
1289
  */
1290
- public static function json_unescaped_unicode_walk_callback (&$item, $key){
1291
- if (is_string($item)) $item = mb_encode_numericentity($item, array (0x80, 0xffff, 0, 0xffff), 'UTF-8');
1292
- }
 
 
 
1293
  }
1
  <?php
2
+
3
  /* Copyright 2011 enlimbo lancers (email : lancers@enlimbo.net)
4
 
5
+ This program is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU General Public License
7
+ as published by the Free Software Foundation; either version 2
8
+ of the License, or (at your option) any later version.
9
 
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
 
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
  */
19
 
20
  /**
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/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
  */
37
+ /*
38
+ Element attributes
39
+
40
+ General rules when adding attributes to an element using strings in chunks
41
+ * always start the chunk with a space and do not end the chunk with another space
42
+ * mind the closing tags and add a space when needed
 
43
  */
44
+ class Enlimbo_Forms {
 
45
 
46
  /**
47
  * @var string
78
  */
79
  public $form_settings = array();
80
 
81
+ public function __construct($id) {
 
82
  /**
83
  * default settings
84
  */
87
  'use_bootstrap' => false,
88
  );
89
  $this->_id = $id;
90
+ if (!is_admin()|| (defined( 'DOING_AJAX' ) && DOING_AJAX)) {
91
+ // TODO check also doing_ajax as this gives false positives
92
+ $cred_form_id = preg_replace('/^cred_form_(\d+)_\d+$/', "$1", $this->_id);
93
+ $form_settings = get_post_meta($cred_form_id, '_cred_form_settings', true);
94
+ if (isset($form_settings->form)) {
95
  $this->form_settings = $form_settings->form;
96
  }
97
  unset($form_settings);
98
+ /**
99
+ * check CRED setting for bootstrap: only on frontend
100
+ */
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
  }
108
 
109
  /**
114
  * @param array $element
115
  * @return HTML formatted output
116
  */
117
+ public function autoHandle($id, $form) {
 
118
  // Auto-add nonce field
119
  $form['nonce'] = array(
120
  '#type' => 'hidden',
166
  * @param type $id
167
  * @return type
168
  */
169
+ public function isSubmitted($id = '') {
 
170
  if (empty($id)) {
171
  $id = $this->_id;
172
  }
173
+ return (isset($_REQUEST['_nonce']) && md5($_REQUEST['_nonce']) == $id);
 
174
  }
175
 
176
  /**
188
  *
189
  * @param type $elements
190
  */
191
+ public function validate(&$elements) {
 
192
  foreach ($elements as $key => &$element) {
193
+ if (!isset($element['#type']) || !$this->_isValidType($element['#type'])) {
 
194
  continue;
195
  }
196
  if ($element['#type'] != 'fieldset') {
197
+ if (isset($element['#name']) && !in_array($element['#type'], array('submit', 'reset'))) {
 
198
  if ($this->isSubmitted()) {
199
  // Set submitted data
200
+ if (!in_array($element['#type'], array('checkboxes')) && empty($element['#forced_value'])) {
 
201
  $element['#value'] = $this->getSubmittedData($element);
202
+ } else if (!empty($element['#options']) && empty($element['#forced_value'])) {
 
203
  foreach ($element['#options'] as $option_key => $option) {
204
  $option['#type'] = 'checkbox';
205
  $element['#options'][$option_key]['#value'] = $this->getSubmittedData($option);
211
  if (isset($element['#validate'])) {
212
  $this->validateElement($element);
213
  }
214
+ } else if (isset($element['#type']) && $element['#type'] == 'fieldset') {
 
215
  $this->validate($element);
216
  } else if (is_array($element)) {
217
  $this->validate($element);
224
  *
225
  * @param type $element
226
  */
227
+ public function validateElement(&$element) {
228
+ $value = isset($element['#value']) ? $element['#value'] : null;
229
+ if (is_null($value) && isset($element['#default_value'])) {
 
230
  $value = $element['#default_value'];
231
  }
232
+ $element = apply_filters('wptoolset_form_' . $this->_id . '_validate_field', $element, $value);
233
+ if (isset($element['error'])) {
 
234
  $this->_errors = true;
235
  $_errors = $element['error']->get_error_data();
236
  $element['#error'] = $_errors[0];
242
  *
243
  * @return type
244
  */
245
+ public function isError() {
 
246
  return $this->_errors;
247
  }
248
 
249
  /**
250
  * Sets errors to true.
251
  */
252
+ public function triggerError() {
 
253
  $this->_errors = true;
254
  }
255
 
258
  *
259
  * @return type
260
  */
261
+ public function renderForm() {
 
262
  // loop over elements and render them
263
  return $this->renderElements($this->_elements);
264
  }
283
  * @param string $type
284
  * @return boolean
285
  */
286
+ private function _isValidType($type) {
287
+ return in_array($type, array('select', 'checkboxes', 'checkbox', 'radios',
288
+ 'radio', 'textfield', 'textarea', 'file', 'submit', 'reset',
289
+ 'hidden', 'fieldset', 'markup', 'button', 'password'));
 
 
290
  }
291
 
292
  /**
295
  * @param type $elements
296
  * @return type
297
  */
298
+ public function renderElements($elements) {
 
299
  $output = '';
300
+ if (!isset($elements))
301
+ return $output;
302
+ foreach ($elements as $key => $element) {
303
  if (!isset($element['#type']) || !$this->_isValidType($element['#type'])) {
304
  continue;
305
  }
306
  if ($element['#type'] != 'fieldset') {
307
+
308
  /**
309
+ * Temporary fixing validation for checkbox/radios/skype because _cakeValidation is not working for thats
310
+ * https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/186243370/comments
311
+ */
312
  if (!is_admin()) {
313
+ if ($element['#type'] == 'radios') {
314
  if (isset($element['#error'])) {
315
+ if (isset($element['#options']) && count($element['#options']) > 0 && !isset($element['#options'][0]['#error']))
316
+ $element['#options'][0]['#error'] = $element['#error'];
317
  }
318
  }
319
  }
320
  //##################################################################################################
321
+
322
+ $output .= $this->renderElement($element);
323
  } else if (isset($element['#type']) && $element['#type'] == 'fieldset') {
324
  $buffer = $this->renderElements($element);
325
  $output .= $this->fieldset($element, 'wrap', $buffer);
338
  * @param array $element
339
  * @return HTML formatted output
340
  */
341
+ public function renderElement($element) {
 
342
  $method = $element['#type'];
343
+ if (!isset($element['#name']) && !in_array($element['#type'], array('markup', 'checkboxes'))) {
344
  if (!isset($element['#attributes']['name'])) {
345
  return '#name or #attributes[\'name\'] required!';
346
  } else {
349
  }
350
  if (is_callable(array($this, $method))) {
351
  $custom_field_title = '';
352
+ if (isset($element['#title']) && !empty($element['#title'])) {
353
+ $custom_field_title = $element['#title'];
354
  }
355
 
356
+ if (empty($custom_field_title) && isset($element['#name']) && !empty($element['#name'])) {
357
+ $custom_field_title = $element['#name'];
358
  }
359
  if (!isset($element['#id'])) {
360
  if (isset($element['#attributes']['id'])) {
361
  $element['#id'] = $element['#attributes']['id'];
362
  } else {
363
+ $_id = isset($this->_id) ? $this->_id . '-' : '';
364
  $element['#id'] = "{$_id}{$element['#type']}-"
365
  . $this->_count($element['#type']) . '-' . time();
366
  }
367
  }
368
+
369
  if (isset($this->_errors[$element['#id']])) {
370
  $element['#error'] = $this->_errors[$element['#id']];
371
  }
372
  // Add JS validation
373
+ if (!empty($element['#validate'])) {
374
+ if (isset($element['#validate']['required']) && !empty($element['#title'])) {
 
375
  // Asterisk
376
  $element['#title'] .= '&#42;';
377
  }
378
+ $element['#attributes']['data-wpt-validate'] = esc_html(self::json_encode(apply_filters('wptoolset_forms_field_js_validation_data_' . $this->_id, $element['#validate'])));
379
+ $element['#attributes']['data-wpt-field-title'] = esc_js($custom_field_title);
 
380
  }
381
+ if ($element['#type'] == 'radios' && !empty($element['#options'])) {
382
+ foreach ($element['#options'] as &$option) {
383
+ if (!empty($option['#validate'])) {
384
+ $option['#attributes']['data-wpt-validate'] = esc_html(self::json_encode(apply_filters('wptoolset_forms_field_js_validation_data_' . $this->_id, $option['#validate'])));
385
+ $option['#attributes']['data-wpt-field-title'] = esc_js($custom_field_title);
 
386
  }
387
  }
388
  }
389
  /**
390
  * WPML - lock CF is has option "copy from original".
391
  */
392
+ if (is_admin() && function_exists('wpcf_wpml_field_is_copied') && wpcf_wpml_field_is_copied($element)) {
393
  $element['#title'] .= sprintf(
394
+ '<img src="%s/images/locked.png" alt="%s" title="%s" style="position:relative;left:2px;top:2px;" />', WPCF_EMBEDDED_RES_RELPATH, __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf'), __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf')
 
 
 
395
  );
396
  $element['#attributes']['readonly'] = true;
397
  }
405
  * @param array $element
406
  * @return string
407
  */
408
+ private function _setElementAttributes($element) {
 
409
  $attributes = '';
410
 
411
  $classes = array();
412
  $classes[] = $this->css_class . '-' . $element['#type'];
413
  $classes[] = 'form-' . $element['#type'];
414
 
415
+ if ($this->form_settings['use_bootstrap']) {
416
+ switch ($element['#type']) {
417
+ case 'hidden':
418
+ case 'button':
419
+ case 'submit':
420
+ case 'radio':
421
+ case 'checkbox':
422
+ case 'file':
423
+ break;
424
+ default:
425
+ $classes[] = 'form-control';
426
  }
427
  } else {
428
+ if ('hidden' != $element['#type']) {
429
  $classes[] = $element['#type'];
430
  }
431
  }
432
 
433
+ if (isset($element['#attributes']) && !empty($element['#attributes'])
434
+ ) {
435
+ if (isset($element['#attributes']['class'])) {
436
+ $element['#attributes']['class'] .= ' ' . implode(' ', $classes);
437
+ } else {
438
+ $element['#attributes']['class'] = implode(' ', $classes);
439
+ }
440
+ } else {
441
+ $element['#attributes'] = array(
442
+ 'class' => implode(' ', $classes)
443
+ );
 
444
  }
445
 
446
+
447
+ foreach ($element['#attributes'] as $attribute => $value) {
448
+ // Prevent undesired elements
449
+ if (in_array($attribute, array('id', 'name'))) {
450
+ continue;
451
+ }
452
+ // Don't set disabled for checkbox
453
+ if ($attribute == 'disabled' && $element['#type'] == 'checkbox') {
454
+ continue;
455
+ }
456
+ // Set return string
457
+ $attributes .= ' ' . $attribute . '="' . $value . '"';
458
  }
459
 
460
  return $attributes;
465
  *
466
  * @param array $element
467
  */
468
+ private function _setRender($element) {
 
469
  if (!isset($element['#id'])) {
470
  if (isset($element['#attributes']['id'])) {
471
  $element['#id'] = $element['#attributes']['id'];
486
  * label
487
  */
488
  $element['_render']['label'] = '';
489
+ if (isset($element['#title'])) {
490
  $classes = array();
491
  $classes[] = sprintf('%s-label', $this->css_class);
492
  $classes[] = sprintf('%s-%s-label', $this->css_class, $element['#type']);
493
+ if ($this->form_settings['use_bootstrap']) {
494
+ switch ($element['#type']) {
495
+ case 'checkbox':
496
+ case 'radio':
497
+ $classes[] = 'control-label';
498
+ break;
499
  }
500
  }
501
  $element['_render']['label'] .= sprintf(
502
+ '<label class="%s" for="%s">', implode(' ', $classes), $element['#id']
 
 
503
  );
504
  $element['_render']['label'] .= stripslashes($element['#title']);
505
  $element['_render']['label'] .= '</label>';
516
  * Accepts: <prefix><suffix><label><title><desription><error>
517
  * @param array $element
518
  */
519
+ private function _pattern($pattern, $element) {
 
520
  $pattern = strtolower($pattern);
521
  foreach ($element['_render'] as $key => $value) {
522
  $pattern = str_replace('<' . strtolower($key) . '>', $value, $pattern);
531
  * @param string $output
532
  * @return string
533
  */
534
+ private function _wrapElement($element, $output) {
 
535
  if (!empty($element['#inline'])) {
536
  return $output;
537
  }
538
  $classes = array();
539
  $classes[] = 'form-item';
540
  $classes[] = 'form-item-' . $element['#type'];
541
+ $classes[] = $this->css_class . '-item';
542
+ $classes[] = $this->css_class . '-item-' . $element['#type'];
543
+ if ($this->form_settings['use_bootstrap']) {
544
  $classes[] = 'form-group';
545
  }
546
+ if (preg_match('/_hidden$/', $element['#id']) && !is_admin()) {
547
  $classes[] = 'wpt-form-hide-container';
548
  }
549
+ if (is_admin()) {
550
  return sprintf(
551
+ '<div id="%s-wrapper" class="%s">%s</div>', $element['#id'], implode(' ', $classes), $output
 
 
 
552
  );
553
  }
554
  return $output;
560
  * @param string $element
561
  * @return string
562
  */
563
+ private function _setElementTitle($element) {
 
564
  $output = '';
565
  if (isset($element['#title'])) {
566
  $output .= '<div class="title '
579
  * @param array $element
580
  * @return string
581
  */
582
+ private function _setElementDescription($element) {
583
+ if (empty($element['#description']))
584
+ return '';
585
  $element['#description'] = stripslashes($element['#description']);
586
  $output = "\r\n"
587
  . '<div class="description '
600
  * @param array $element
601
  * @return string
602
  */
603
+ public function renderError($element) {
 
604
  if (!isset($element['#error'])) {
605
  return '';
606
  }
625
  * @param string $wrap_content HTML formatted output of child elements
626
  * @return string
627
  */
628
+ public function fieldset($element, $action = 'open', $wrap_content = '') {
 
629
  $collapsible_open = '<div class="fieldset-wrapper">';
630
  $collapsible_close = '</div>';
631
  $legend_class = '';
635
  if (!isset($element['_attributes_string'])) {
636
  $element['_attributes_string'] = $this->_setElementAttributes($element);
637
  }
638
+ if ((isset($element['#collapsible']) && $element['#collapsible']) || (isset($element['#collapsed']) && $element['#collapsed'])) {
 
639
  $collapsible_open = '<div class="collapsible fieldset-wrapper">';
640
  $collapsible_close = '</div>';
641
  $legend_class = ' class="legend-expanded"';
642
  }
643
  if (isset($element['#collapsed']) && $element['#collapsed']) {
644
+ $collapsible_open = str_replace('class="', 'class="collapsed ', $collapsible_open);
 
645
  $legend_class = ' class="legend-collapsed"';
646
  }
647
  $output = '';
695
  * @param array $element
696
  * @return string
697
  */
698
+ public function checkbox($element) {
 
699
  $element['#type'] = 'checkbox';
700
  $element = $this->_setRender($element);
701
  $element['_render']['element'] = '<input type="checkbox"';
702
+ foreach (array('id', 'name') as $key) {
703
+ $element['_render']['element'] .= sprintf(' %s="%s"', $key, $element['#' . $key]);
704
  }
705
  /**
706
  * type and data_id
707
  */
708
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
709
+ $element['_render']['element'] .= $this->_getDataWptId($element);
710
 
711
  $element['_render']['element'] .= ' value="';
712
  /**
714
  * but if is defined default value, use default
715
  */
716
  $value = 1;
717
+ if (array_key_exists('#default_value', $element)) {
718
  $value = $element['#default_value'];
719
  }
720
+ $element['_render']['element'] .= ( empty($element['#value']) && !preg_match('/^0$/', $element['#value']) ) ? $value : esc_attr($element['#value']);
721
  $element['_render']['element'] .= '"' . $element['_attributes_string'];
722
  if (
723
+ (
724
  !$this->isSubmitted() && (
725
+ (!empty($element['#default_value']) && $element['#default_value'] == $element['#value'] ) || ( isset($element['#checked']) && $element['#checked'] )
 
726
  )
727
+ ) || ($this->isSubmitted() && !empty($element['#value']))
 
728
  ) {
729
  $element['_render']['element'] .= ' checked="checked"';
730
  }
733
  }
734
  $element['_render']['element'] .= ' />';
735
 
736
+ $pattern = $this->_getStatndardPatern($element, '<BEFORE><PREFIX><ELEMENT>&nbsp;<LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>');
737
  $output = $this->_pattern($pattern, $element);
738
  $output = $this->_wrapElement($element, $output);
739
  return $output . "\r\n";
748
  * @param array $element
749
  * @return string
750
  */
751
+ public function checkboxes($element) {
 
752
  $element['#type'] = 'checkboxes';
753
  $element = $this->_setRender($element);
754
  $clone = $element;
760
  }
761
  $element['_render']['element'] .= $this->checkbox($value);
762
  }
763
+ $pattern = $this->_getStatndardPatern($element, '<BEFORE><PREFIX><TITLE><DESCRIPTION><ELEMENT><SUFFIX><AFTER>');
764
  $output = $this->_pattern($pattern, $element);
765
  $output = $this->_wrapElement($element, $output);
766
  return $output;
772
  * @param array $element
773
  * @return string
774
  */
775
+ public function radio($element) {
 
776
  $element['#type'] = 'radio';
777
  $element = $this->_setRender($element);
778
  $element['_render']['element'] = '<input type="radio" id="'
781
  $element['_render']['element'] .= isset($element['#value']) ? htmlspecialchars($element['#value']) : $this->_count['radio'];
782
  $element['_render']['element'] .= '"';
783
  $element['_render']['element'] .= $element['_attributes_string'];
784
+ $element['_render']['element'] .= ( isset($element['#value']) && $element['#value'] === $element['#default_value']) ? ' checked="checked"' : '';
 
785
  if (isset($element['#disable']) && $element['#disable']) {
786
  $element['_render']['element'] .= ' disabled="disabled"';
787
  }
788
+ if (array_key_exists('#types-value', $element)) {
789
+ $element['_render']['element'] .= sprintf(' data-types-value="%s"', $element['#types-value']);
790
  }
791
  /**
792
  * type and data_id
793
  */
794
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
795
+ $element['_render']['element'] .= $this->_getDataWptId($element);
796
 
797
  $element['_render']['element'] .= ' />';
798
+
799
  $pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><PREFIX><ELEMENT>&nbsp;<LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
800
  $output = $this->_pattern($pattern, $element);
801
  $output = $this->_wrapElement($element, $output);
811
  * @param array $element
812
  * @return string
813
  */
814
+ public function radios($element) {
 
815
  if (!isset($element['#name']) || empty($element['#name'])) {
816
  return FALSE;
817
  }
835
  } else {
836
  $pattern = '<BEFORE><PREFIX><DESCRIPTION><ELEMENT><SUFFIX><AFTER>';
837
  }
838
+
839
  $pattern = $this->_getStatndardPatern($element, $pattern);
840
  $output = $this->_pattern($pattern, $element);
841
  $output = $this->_wrapElement($element, $output);
848
  * @param array $element
849
  * @return string
850
  */
851
+ public function select($element) {
 
852
  $element = $this->_setRender($element);
853
 
854
  $element['_render']['element'] = '';
855
  $element['_render']['element'] .= '<select id="' . $element['#id'] . '" ';
856
  $element['_render']['element'] .= $element['_attributes_string'];
857
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
858
  /**
859
  * multiple
860
  */
861
+ if (array_key_exists('#multiple', $element) && $element['#multiple']) {
862
  $element['_render']['element'] .= ' multiple="multiple"';
863
  $element['_render']['element'] .= ' name="' . $element['#name'] . '[]"';
864
  } else {
865
  $element['_render']['element'] .= ' name="' . $element['#name'] . '"';
866
  }
867
+ $element['_render']['element'] .= ">\r\n";
868
  $count = 1;
869
  foreach ($element['#options'] as $id => $value) {
870
  if (!is_array($value)) {
877
  }
878
  $element['_render']['element'] .= '<option value="' . htmlspecialchars($value['#value']) . '"';
879
  $element['_render']['element'] .= $this->_setElementAttributes($value);
880
+ if (array_key_exists('#types-value', $value)) {
881
+ $element['_render']['element'] .= sprintf(' data-types-value="%s"', $value['#types-value']);
882
  }
883
  /**
884
  * type and data_id
885
  */
886
  $element['_render']['element'] .= ' data-wpt-type="option"';
887
+ $element['_render']['element'] .= $this->_getDataWptId($element);
888
  /**
889
  * selected
890
  */
891
+ if (array_key_exists('#multiple', $element) && $element['#multiple']) {
892
+ if (is_array($element['#default_value']) && in_array($value['#value'], $element['#default_value'])) {
893
  $element['_render']['element'] .= ' selected="selected"';
894
  }
895
+ } elseif ($element['#default_value'] == $value['#value']) {
896
  $element['_render']['element'] .= ' selected="selected"';
897
  }
898
  $element['_render']['element'] .= '>';
902
  $element['_render']['element'] .= '</select>';
903
  $element['_render']['element'] .= PHP_EOL;
904
 
905
+ $pattern = $this->_getStatndardPatern($element);
906
  $output = $this->_pattern($pattern, $element);
907
  $output = $this->_wrapElement($element, $output);
908
 
915
  * @param array $element
916
  * @return string
917
  */
918
+ public function textfield($element) {
 
919
  $element['#type'] = 'textfield';
920
  $element = $this->_setRender($element);
921
 
922
  $element['_render']['element'] = '<input type="text"';
923
  //$element['_render']['element'] .= sprintf( ' data-wpt-type="%s" ', __FUNCTION__ );
924
+ $element['_render']['element'] .= sprintf(' id="%s"', $element['#id']);
925
+ $element['_render']['element'] .= sprintf(' name="%s"', $element['#name']);
926
+ $element['_render']['element'] .= sprintf(' value="%s"', isset($element['#value']) ? esc_attr($element['#value']) : '' );
927
  $element['_render']['element'] .= $element['_attributes_string'];
928
  if (isset($element['#disable']) && $element['#disable']) {
929
  $element['_render']['element'] .= ' disabled="disabled"';
931
  /**
932
  * type and data_id
933
  */
934
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
935
+ $element['_render']['element'] .= $this->_getDataWptId($element);
936
 
937
  $element['_render']['element'] .= ' />';
938
+ $pattern = $this->_getStatndardPatern($element);
939
  $output = $this->_pattern($pattern, $element);
940
  $output = $this->_wrapElement($element, $output);
941
  return $output . "\r\n";
947
  * @param array $element
948
  * @return string
949
  */
950
+ public function password($element) {
 
951
  $element['#type'] = 'password';
952
  $element = $this->_setRender($element);
953
  $element['_render']['element'] = '<input type="password" id="'
960
  /**
961
  * type and data_id
962
  */
963
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
964
+ $element['_render']['element'] .= $this->_getDataWptId($element);
965
 
966
  $element['_render']['element'] .= ' />';
967
  $pattern = $this->_getStatndardPatern($element);
976
  * @param array $element
977
  * @return string
978
  */
979
+ public function textarea($element) {
 
980
  $element['#type'] = 'textarea';
981
  if (!isset($element['#attributes']['rows'])) {
982
  $element['#attributes']['rows'] = 5;
991
  /**
992
  * type and data_id
993
  */
994
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
995
+ $element['_render']['element'] .= $this->_getDataWptId($element);
996
 
997
  $element['_render']['element'] .= '>';
998
 
999
  $element['_render']['element'] .= isset($element['#value']) ? esc_attr($element['#value']) : '';
1000
  $element['_render']['element'] .= '</textarea>' . "\r\n";
1001
+ $pattern = $this->_getStatndardPatern($element);
1002
  $output = $this->_pattern($pattern, $element);
1003
  $output = $this->_wrapElement($element, $output);
1004
  return $output . "\r\n";
1010
  * @param array $element
1011
  * @return string
1012
  */
1013
+ public function file($element) {
 
1014
  $element['#type'] = 'file';
1015
  $element = $this->_setRender($element);
1016
  $element['_render']['element'] = '<input type="file" id="'
1022
  /**
1023
  * type and data_id
1024
  */
1025
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
1026
+ $element['_render']['element'] .= $this->_getDataWptId($element);
1027
 
1028
  $element['_render']['element'] .= ' />';
1029
+ $pattern = $this->_getStatndardPatern($element);
1030
  $output = $this->_pattern($pattern, $element);
1031
  $output = $this->_wrapElement($element, $output);
1032
  return $output;
1038
  * @param array $element
1039
  * @return string
1040
  */
1041
+ public function markup($element) {
 
1042
  return $element['#markup'];
1043
  }
1044
 
1048
  * @param array $element
1049
  * @return string
1050
  */
1051
+ public function hidden($element) {
 
1052
  $element['#type'] = 'hidden';
1053
  $element = $this->_setRender($element);
1054
  $output = '<input type="hidden" id="' . $element['#id'] . '" name="'
1055
  . $element['#name'] . '" value="';
1056
  $output .= isset($element['#value']) ? $element['#value'] : 1;
1057
+ $output .= '"' . $element['_attributes_string'] . $this->_getDataWptId($element) . ' />';
1058
  return $output;
1059
  }
1060
 
1064
  * @param array $element
1065
  * @return string
1066
  */
1067
+ public function reset($element) {
 
1068
  return $this->submit($element, 'reset', 'Reset');
1069
  }
1070
 
1074
  * @param array $element
1075
  * @return string
1076
  */
1077
+ public function button($element) {
 
1078
  return $this->submit($element, 'button', 'Button');
1079
  }
1080
 
1088
  * @param string $title
1089
  * @return string
1090
  */
1091
+ public function submit($element, $type = 'submit', $title = 'Submit') {
 
1092
  $element['#type'] = $type;
1093
  $element = $this->_setRender($element);
1094
  $element['_render']['element'] = '<input type="' . $type . '" id="'
1096
  $element['_render']['element'] .= isset($element['#value']) ? $element['#value'] : $title;
1097
  $element['_render']['element'] .= '"' . $element['_attributes_string']
1098
  . ' />';
1099
+ $pattern = $this->_getStatndardPatern($element, '<BEFORE><PREFIX><ELEMENT><SUFFIX><AFTER>');
1100
  $output = $this->_pattern($pattern, $element);
1101
  return $output;
1102
  }
1107
  * @param type $element
1108
  * @return type mixed
1109
  */
1110
+ public function getSubmittedData($element) {
 
1111
  $name = $element['#name'];
1112
  if (strpos($name, '[') === false) {
1113
  if ($element['#type'] == 'file') {
1114
  return $_FILES[$name]['tmp_name'];
1115
  }
1116
+ return isset($_REQUEST[$name]) ? $_REQUEST[$name] : in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
 
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
  }
1126
  $key = $parts[$index];
1127
  // We're at the end but no data retrieved
1128
  if (!isset($parts[$index + 1])) {
1129
+ return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
 
1130
  }
1131
  $key_next = $parts[$index + 1];
1132
  if ($index > 0) {
1133
  if (!isset($search[$key])) {
1134
+ return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
 
1135
  } else {
1136
  $search = $search[$key];
1137
  }
1145
  return 0;
1146
  }
1147
 
1148
+ private function _getDataWptId($element) {
 
1149
  $html = '';
1150
+ if (array_key_exists('#id', $element)) {
1151
+ if (is_admin()) {
1152
+ $html .= sprintf(' data-wpt-id="%s"', preg_replace('/\[/', '-', preg_replace('/\]/', '', $element['#name'])));
1153
  } else {
1154
+ $html .= sprintf(' data-wpt-id="%s_%s"', $this->_id, $element['#id']);
1155
  }
1156
+ if (array_key_exists('#name', $element) && $element['#name']) {
1157
+ if (!is_admin() && $this->_isRepetitive($element)) {
1158
+ $html .= sprintf(' data-wpt-name="%s"', preg_replace('/\[.+$/', '', $element['#name']));
1159
  } else {
1160
+ if (preg_match('/^wpcf_post_relationship\[\d+\]\[\d+\]\[[^\]]+\]/', $element['#name'])) {
1161
  $html .= sprintf(
1162
+ ' data-wpt-name="%s"', preg_replace('/^wpcf_post_relationship\[\d+\]\[(\d+)\]\[wpcf-([^\]]+)\]/', "wpcf[$2-$1]", $element['#name']));
 
1163
  } else {
1164
+ $html .= sprintf(' data-wpt-name="%s"', $element['#name']);
1165
  }
1166
  }
1167
  }
1169
  return $html;
1170
  }
1171
 
1172
+ private function _getStatndardPatern($element, $default = false) {
1173
+ if (isset($element['#pattern'])) {
 
1174
  return $element['#pattern'];
1175
  }
1176
+ if ($default) {
1177
  return $default;
1178
  }
1179
+ if (is_admin()) {
1180
  return '<BEFORE><LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
1181
  }
1182
  return '<BEFORE><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
1183
  }
1184
 
1185
+ private function _isRepetitive($element) {
1186
+ if (!is_array($element)) {
 
1187
  return false;
1188
  }
1189
+ return array_key_exists('#repetitive', $element) && $element['#repetitive'];
1190
+ }
1191
+
1192
+ static function json_encode($array) {
1193
+ // php > 5.3 do not escape utf-8 characters using native constant argument
1194
+ if (defined('JSON_UNESCAPED_UNICODE')) {
1195
+ return json_encode($array, JSON_UNESCAPED_UNICODE);
1196
+ }
1197
+ // fallback for php < 5.3 to support unicode characters in json string
1198
+ else {
1199
+ if (function_exists('mb_decode_numericentity')) {
1200
+ return self::json_encode_unescaped_unicode($array);
1201
+ } else {
1202
+ return json_encode($array);
1203
+ }
1204
+ }
1205
+ }
1206
+
1207
+ /**
1208
+ * @param $arr
1209
+ * @return string
1210
+ * courtesy from: http://www.php.net/manual/ru/function.json-encode.php#105789
1211
+ */
1212
+ public static function json_encode_unescaped_unicode($arr) {
1213
+
1214
+ array_walk_recursive($arr, array(__CLASS__, 'json_unescaped_unicode_walk_callback'));
1215
+
1216
+ return mb_decode_numericentity(json_encode($arr), array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
1217
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1218
 
1219
  /*
1220
  * Helper function to json_encode with UTF-8 support for php < 5.3
1221
  */
1222
+
1223
+ public static function json_unescaped_unicode_walk_callback(&$item, $key) {
1224
+ if (is_string($item))
1225
+ $item = mb_encode_numericentity($item, array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
1226
+ }
1227
+
1228
  }
embedded/common/toolset-forms/classes/class.field_factory.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
2
 
3
  /**
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/common/toolset-forms/classes/class.fieldconfig.php CHANGED
@@ -1,13 +1,15 @@
1
  <?php
 
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/common/toolset-forms/classes/class.fieldconfig.php $
5
- * $LastChangedDate: 2014-09-18 09:37:16 +0000 (Thu, 18 Sep 2014) $
6
- * $LastChangedRevision: 992466 $
7
- * $LastChangedBy: brucepearson $
8
  *
9
  */
10
  if (!class_exists("FieldConfig")) {
 
11
  /**
12
  * Description of FieldConfig
13
  *
@@ -28,10 +30,10 @@ if (!class_exists("FieldConfig")) {
28
  private $default_value = '';
29
  private $validation = array();
30
  private $attr;
31
-
32
  private $add_time = false;
33
 
34
  public function __construct() {
 
35
  }
36
 
37
  public function setRepetitive($repetitive) {
@@ -45,76 +47,77 @@ if (!class_exists("FieldConfig")) {
45
  public function set_add_time($addtime) {
46
  $this->add_time = $addtime;
47
  }
48
-
49
  public function setAttr($attr) {
50
  $this->attr = $attr;
51
  }
52
-
53
  public function getAttr() {
54
  return $this->attr;
55
  }
56
 
57
- public function setDefaultValue($type,$field_arr)
58
- {
59
  switch ($type) {
60
  case 'date':
61
  $this->add_time = false;
62
- if ( isset( $field_arr['data']['date_and_time'] ) && 'and_time' == $field_arr['data']['date_and_time'] ) {
63
- $this->add_time = true;
64
- }
65
  break;
66
  case 'checkboxes':
67
- if ( is_array( $field_arr['attr']['default'] ) && count( $field_arr['attr']['default'] ) ) {
68
  $this->default_value = $field_arr['attr']['default'][0];
69
  }
70
  break;
71
-
72
  case 'select':
73
  if (isset($field_arr['attr']['multiple'])) {
74
  //Multiselect
75
  if (isset($field_arr['value']))
76
- foreach ($field_arr['value'] as $value) {
77
- if (isset($value[0])) {
78
- $this->default_value = $value;
79
- break;
 
80
  }
81
- }
82
  } else
83
- $this->default_value = isset( $field_arr['attr']['actual_value'][0] )? $field_arr['attr']['actual_value'][0] : null;
84
- break;
85
-
86
  case 'radios':
87
  $this->default_value = $field_arr['attr']['default'];
88
  break;
89
 
90
  case 'checkbox':
91
- $this->default_value = isset($field_arr['data']['checked'])?$field_arr['data']['checked']:0;
 
 
92
  break;
93
-
94
  default:
95
  $this->default_value = "";
96
  break;
97
  }
98
  }
99
 
100
- public function setOptions($name,$type,$values,$attrs) {
101
  $arr = array();
102
  switch ($type) {
103
  case 'checkbox':
104
- $arr=$attrs;
105
  break;
106
  case 'checkboxes':
107
- foreach ($attrs['actual_titles'] as $refvalue=>$title) {
108
  $value = $attrs['actual_values'][$refvalue];
109
- $arr[$refvalue] = array('value'=>$refvalue,'title'=>$title,'name'=>$name,'data-value'=>$value);
110
- if ( in_array($refvalue, $attrs['default']) ) {
111
  $arr[$refvalue]['checked'] = true;
112
  }
113
  }
114
  break;
115
  case 'select':
116
  $values = $attrs['options'];
117
- foreach ($values as $refvalue=>$title) {
118
  $arr[$refvalue] = array(
119
  'value' => $refvalue,
120
  'title' => $title,
@@ -123,7 +126,7 @@ if (!class_exists("FieldConfig")) {
123
  }
124
  break;
125
  case 'radios':
126
- foreach ($attrs['actual_titles'] as $refvalue=>$title) {
127
  $arr[$refvalue] = array(
128
  'value' => $refvalue,
129
  'title' => $title,
@@ -132,10 +135,10 @@ if (!class_exists("FieldConfig")) {
132
  'types-value' => $attrs['actual_values'][$refvalue],
133
  );
134
  }
135
- break;
136
  default:
137
  return;
138
- break;
139
  }
140
  $this->options = $arr;
141
  }
@@ -150,13 +153,13 @@ if (!class_exists("FieldConfig")) {
150
  'default_value' => $this->getDefaultValue(),
151
  'description' => $this->getDescription(),
152
  'repetitive' => $this->isRepetitive(),
153
- /*'name' => $base_name."[".$this->getType()."]",*/
154
  'name' => $this->getName(),
155
  'value' => $this->getValue(),
156
  'add_time' => $this->getAddTime(),
157
  'validation' => array(),
158
  'display' => $this->getDisplay(),
159
- 'attribute' => $this->getAttr()
160
  );
161
  return $this->config;
162
  }
@@ -185,8 +188,7 @@ if (!class_exists("FieldConfig")) {
185
  return $this->title;
186
  }
187
 
188
- public function getDisplay()
189
- {
190
  return $this->display;
191
  }
192
 
@@ -242,10 +244,11 @@ if (!class_exists("FieldConfig")) {
242
  $this->id = $id;
243
  }
244
 
245
- public function setDisplay($display)
246
- {
247
  $this->display = $display;
248
  }
 
249
  }
 
250
  }
251
 
1
  <?php
2
+
3
  /**
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
9
  *
10
  */
11
  if (!class_exists("FieldConfig")) {
12
+
13
  /**
14
  * Description of FieldConfig
15
  *
30
  private $default_value = '';
31
  private $validation = array();
32
  private $attr;
 
33
  private $add_time = false;
34
 
35
  public function __construct() {
36
+
37
  }
38
 
39
  public function setRepetitive($repetitive) {
47
  public function set_add_time($addtime) {
48
  $this->add_time = $addtime;
49
  }
50
+
51
  public function setAttr($attr) {
52
  $this->attr = $attr;
53
  }
54
+
55
  public function getAttr() {
56
  return $this->attr;
57
  }
58
 
59
+ public function setDefaultValue($type, $field_arr) {
 
60
  switch ($type) {
61
  case 'date':
62
  $this->add_time = false;
63
+ if (isset($field_arr['data']['date_and_time']) && 'and_time' == $field_arr['data']['date_and_time']) {
64
+ $this->add_time = true;
65
+ }
66
  break;
67
  case 'checkboxes':
68
+ if (is_array($field_arr['attr']['default']) && count($field_arr['attr']['default'])) {
69
  $this->default_value = $field_arr['attr']['default'][0];
70
  }
71
  break;
72
+
73
  case 'select':
74
  if (isset($field_arr['attr']['multiple'])) {
75
  //Multiselect
76
  if (isset($field_arr['value']))
77
+ foreach ($field_arr['value'] as $value) {
78
+ if (isset($value[0])) {
79
+ $this->default_value = $value;
80
+ break;
81
+ }
82
  }
 
83
  } else
84
+ $this->default_value = isset($field_arr['attr']['actual_value'][0]) ? $field_arr['attr']['actual_value'][0] : null;
85
+ break;
86
+
87
  case 'radios':
88
  $this->default_value = $field_arr['attr']['default'];
89
  break;
90
 
91
  case 'checkbox':
92
+ $this->default_value = isset($field_arr['data']['checked']) ? $field_arr['data']['checked'] : false;
93
+ /*if (!$this->default_value)
94
+ $this->default_value = isset($field_arr['data']['set_value']) && $field_arr['data']['set_value'] == 'y' ? true : false;*/
95
  break;
96
+
97
  default:
98
  $this->default_value = "";
99
  break;
100
  }
101
  }
102
 
103
+ public function setOptions($name, $type, $values, $attrs) {
104
  $arr = array();
105
  switch ($type) {
106
  case 'checkbox':
107
+ $arr = $attrs;
108
  break;
109
  case 'checkboxes':
110
+ foreach ($attrs['actual_titles'] as $refvalue => $title) {
111
  $value = $attrs['actual_values'][$refvalue];
112
+ $arr[$refvalue] = array('value' => $refvalue, 'title' => $title, 'name' => $name, 'data-value' => $value);
113
+ if (in_array($refvalue, $attrs['default'])) {
114
  $arr[$refvalue]['checked'] = true;
115
  }
116
  }
117
  break;
118
  case 'select':
119
  $values = $attrs['options'];
120
+ foreach ($values as $refvalue => $title) {
121
  $arr[$refvalue] = array(
122
  'value' => $refvalue,
123
  'title' => $title,
126
  }
127
  break;
128
  case 'radios':
129
+ foreach ($attrs['actual_titles'] as $refvalue => $title) {
130
  $arr[$refvalue] = array(
131
  'value' => $refvalue,
132
  'title' => $title,
135
  'types-value' => $attrs['actual_values'][$refvalue],
136
  );
137
  }
138
+ break;
139
  default:
140
  return;
141
+ break;
142
  }
143
  $this->options = $arr;
144
  }
153
  'default_value' => $this->getDefaultValue(),
154
  'description' => $this->getDescription(),
155
  'repetitive' => $this->isRepetitive(),
156
+ /* 'name' => $base_name."[".$this->getType()."]", */
157
  'name' => $this->getName(),
158
  'value' => $this->getValue(),
159
  'add_time' => $this->getAddTime(),
160
  'validation' => array(),
161
  'display' => $this->getDisplay(),
162
+ 'attribute' => $this->getAttr()
163
  );
164
  return $this->config;
165
  }
188
  return $this->title;
189
  }
190
 
191
+ public function getDisplay() {
 
192
  return $this->display;
193
  }
194
 
244
  $this->id = $id;
245
  }
246
 
247
+ public function setDisplay($display) {
 
248
  $this->display = $display;
249
  }
250
+
251
  }
252
+
253
  }
254
 
embedded/common/toolset-forms/classes/class.file.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
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.4/embedded/common/toolset-forms/classes/class.form_factory.php $
14
- * $LastChangedDate: 2014-10-23 10:33:39 +0000 (Thu, 23 Oct 2014) $
15
- * $LastChangedRevision: 1012677 $
16
  * $LastChangedBy: iworks $
17
  *
18
  *
@@ -189,10 +189,17 @@ class FormFactory extends FormAbstract
189
  if ( empty( $value ) ) $value = array(null);
190
  elseif ( !is_array( $value ) ) $value = array($value);
191
  $count = 0;
192
- foreach ( $value as $val ) {
 
 
 
 
 
 
 
193
  if ( !empty( $config['repetitive'] ) ) {
194
  $_gnf = $_cfg['name'] = "{$global_name_field}[{$count}]";
195
- }
196
  //CHECKGEN
197
  if ( isset($_cfg['validation']) &&
198
  is_array($_cfg['validation']) &&
@@ -200,7 +207,7 @@ class FormFactory extends FormAbstract
200
  !is_admin() && $_SERVER['REQUEST_METHOD'] == 'POST' &&
201
  isset( $_GET['_tt'] ) &&
202
  !isset( $_GET['_success'] ) &&
203
- !isset( $_GET['_success_message'] ) )
204
  {
205
  $_cfg['validate'] = 1;
206
  }
@@ -224,7 +231,7 @@ class FormFactory extends FormAbstract
224
  }
225
  $this->form[$global_name_field] = $form;
226
  $this->field_count++;
227
- $htmlArray[] = $this->theForm->renderElements( $form );
228
  if ( empty( $config['repetitive'] ) ) break;
229
  $count++;
230
  } else {
@@ -239,7 +246,7 @@ class FormFactory extends FormAbstract
239
  $field->get_error_message()
240
  );
241
  }
242
- }
243
  }
244
  if ( !empty( $htmlArray ) && isset($config['repetitive']) && $config['repetitive'] ) {
245
  $_gnf = $_cfg['name'] = "{$global_name_field}[%%{$count}%%]";
@@ -378,7 +385,7 @@ class FormFactory extends FormAbstract
378
  {
379
  $mess = $field->getTitle().' Field is required';
380
  return new WP_Error( 'wptoolset_forms', $mess,
381
- array($field->getTitle().' Field is required') );;
382
  }
383
  }
384
  }
10
  * Creation Form Class
11
  * @author onTheGo System
12
  *
13
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  *
189
  if ( empty( $value ) ) $value = array(null);
190
  elseif ( !is_array( $value ) ) $value = array($value);
191
  $count = 0;
192
+
193
+ //Fix if i get skype i receive skype i have 2 elements array in $value !!
194
+ if ($config['type']=='skype') {
195
+ if (isset($value['style'])) unset($value['style']);
196
+ if (isset($value['button_style'])) unset($value['button_style']);
197
+ }
198
+
199
+ foreach ( $value as $val ) {
200
  if ( !empty( $config['repetitive'] ) ) {
201
  $_gnf = $_cfg['name'] = "{$global_name_field}[{$count}]";
202
+ }
203
  //CHECKGEN
204
  if ( isset($_cfg['validation']) &&
205
  is_array($_cfg['validation']) &&
207
  !is_admin() && $_SERVER['REQUEST_METHOD'] == 'POST' &&
208
  isset( $_GET['_tt'] ) &&
209
  !isset( $_GET['_success'] ) &&
210
+ !isset( $_GET['_success_message'] ) )
211
  {
212
  $_cfg['validate'] = 1;
213
  }
231
  }
232
  $this->form[$global_name_field] = $form;
233
  $this->field_count++;
234
+ $htmlArray[] = $this->theForm->renderElements( $form );
235
  if ( empty( $config['repetitive'] ) ) break;
236
  $count++;
237
  } else {
246
  $field->get_error_message()
247
  );
248
  }
249
+ }
250
  }
251
  if ( !empty( $htmlArray ) && isset($config['repetitive']) && $config['repetitive'] ) {
252
  $_gnf = $_cfg['name'] = "{$global_name_field}[%%{$count}%%]";
385
  {
386
  $mess = $field->getTitle().' Field is required';
387
  return new WP_Error( 'wptoolset_forms', $mess,
388
+ array($field->getTitle().' Field is required') );
389
  }
390
  }
391
  }
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.4/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.5/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,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
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.4/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.5/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,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/common/toolset-forms/classes/class.skype.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/common/toolset-forms/classes/class.submit.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/common/toolset-forms/classes/class.taxonomy.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
2
 
3
  /**
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
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.4/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.5/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,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/common/toolset-forms/classes/class.types.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Types fields specific
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
2
  /**
3
  * Types fields specific
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/common/toolset-forms/classes/class.validation.php CHANGED
@@ -3,7 +3,7 @@
3
  * Libraries
4
  * - CakePHP library for PHP validation
5
  * - jQuery Validation plugin for JS validation
6
- *
7
  * Flow
8
  * - Hooks to form filtering to collect data
9
  * - Filters data-wpt-validation (adds array of rules) to form element
@@ -15,7 +15,7 @@
15
 
16
  /**
17
  * Class description
18
- *
19
  * @author Srdjan
20
  */
21
  class WPToolset_Forms_Validation
@@ -50,7 +50,7 @@ class WPToolset_Forms_Validation
50
  array($this, 'filterFormField'), 10, 2 );
51
  // Render classes
52
  add_action('wptoolset_field_class', array($this, 'actionFieldClass') );
53
-
54
  // Render settings
55
  add_action( 'admin_print_footer_scripts', array($this, 'renderJsonData'), 30 );
56
  add_action( 'wp_footer', array($this, 'renderJsonData'), 30 );
@@ -60,7 +60,7 @@ class WPToolset_Forms_Validation
60
 
61
  /**
62
  * Adjusts validation data for JS processing (data-wpt-validate HTML attribute)
63
- *
64
  * @param type $rules
65
  * @return type
66
  */
@@ -91,11 +91,11 @@ class WPToolset_Forms_Validation
91
 
92
  /**
93
  * Form PHP validation.
94
- *
95
  * Called from Form_Factory or save_post hook.
96
  * Form Factory should check if element has 'error' property (WP_Error)
97
  * and use WP_Error::get_error_message() to display error message
98
- *
99
  * @param type $element
100
  * @param type $value
101
  * @return type
@@ -126,7 +126,7 @@ class WPToolset_Forms_Validation
126
 
127
  /**
128
  * Bulk PHP validation.
129
- *
130
  * @param type $field Field class instance
131
  * @param type $value
132
  * @return \WP_Error|boolean
@@ -141,11 +141,12 @@ class WPToolset_Forms_Validation
141
  && ( is_null( $value ) || $value === false || $value === '' ) ) {
142
  return true;
143
  }
 
144
  try {
145
- $errors = array();
146
  foreach ( $rules as $rule => $args ) {
147
  if ( !$this->validate( $rule, $args['args'] ) ) {
148
- $errors[] = $field->getTitle() . ' ' . $args['message'];
149
  }
150
  }
151
  if ( !empty( $errors ) ) {
@@ -157,7 +158,7 @@ class WPToolset_Forms_Validation
157
  }
158
  return true;
159
  }
160
-
161
  protected function _parseRules( $rules, $value ) {
162
  $_rules = array();
163
  foreach ( $rules as $rule => $args ) {
@@ -178,9 +179,9 @@ class WPToolset_Forms_Validation
178
 
179
  /**
180
  * Single rule PHP validation.
181
- *
182
  * Accepts e.g. validate('maxlength', array($value, '15'))
183
- *
184
  * @param type $method
185
  * @param type $args
186
  * @return boolean
@@ -196,7 +197,7 @@ class WPToolset_Forms_Validation
196
 
197
  /**
198
  * Loads CakePHP Validation class.
199
- *
200
  * @return type
201
  */
202
  protected function _cake() {
@@ -209,7 +210,7 @@ class WPToolset_Forms_Validation
209
 
210
  /**
211
  * Maps rules between JS and PHP.
212
- *
213
  * @param type $rule
214
  * @return type
215
  */
@@ -221,10 +222,9 @@ class WPToolset_Forms_Validation
221
  * Renders JSON data.
222
  */
223
  public function renderJsonData() {
224
- echo '<script type="text/javascript">wptValidationForms.push("#'
225
- . $this->__formID . '");</script>';
226
  }
227
-
228
  public function actionFieldClass( $config ) {
229
  if ( !empty( $config['validation'] ) ) {
230
  foreach ($config['validation'] as $rule => $data) {
3
  * Libraries
4
  * - CakePHP library for PHP validation
5
  * - jQuery Validation plugin for JS validation
6
+ *
7
  * Flow
8
  * - Hooks to form filtering to collect data
9
  * - Filters data-wpt-validation (adds array of rules) to form element
15
 
16
  /**
17
  * Class description
18
+ *
19
  * @author Srdjan
20
  */
21
  class WPToolset_Forms_Validation
50
  array($this, 'filterFormField'), 10, 2 );
51
  // Render classes
52
  add_action('wptoolset_field_class', array($this, 'actionFieldClass') );
53
+
54
  // Render settings
55
  add_action( 'admin_print_footer_scripts', array($this, 'renderJsonData'), 30 );
56
  add_action( 'wp_footer', array($this, 'renderJsonData'), 30 );
60
 
61
  /**
62
  * Adjusts validation data for JS processing (data-wpt-validate HTML attribute)
63
+ *
64
  * @param type $rules
65
  * @return type
66
  */
91
 
92
  /**
93
  * Form PHP validation.
94
+ *
95
  * Called from Form_Factory or save_post hook.
96
  * Form Factory should check if element has 'error' property (WP_Error)
97
  * and use WP_Error::get_error_message() to display error message
98
+ *
99
  * @param type $element
100
  * @param type $value
101
  * @return type
126
 
127
  /**
128
  * Bulk PHP validation.
129
+ *
130
  * @param type $field Field class instance
131
  * @param type $value
132
  * @return \WP_Error|boolean
141
  && ( is_null( $value ) || $value === false || $value === '' ) ) {
142
  return true;
143
  }
144
+
145
  try {
146
+ $errors = array();
147
  foreach ( $rules as $rule => $args ) {
148
  if ( !$this->validate( $rule, $args['args'] ) ) {
149
+ $errors[] = $field->getTitle() . ' ' . $args['message'];
150
  }
151
  }
152
  if ( !empty( $errors ) ) {
158
  }
159
  return true;
160
  }
161
+
162
  protected function _parseRules( $rules, $value ) {
163
  $_rules = array();
164
  foreach ( $rules as $rule => $args ) {
179
 
180
  /**
181
  * Single rule PHP validation.
182
+ *
183
  * Accepts e.g. validate('maxlength', array($value, '15'))
184
+ *
185
  * @param type $method
186
  * @param type $args
187
  * @return boolean
197
 
198
  /**
199
  * Loads CakePHP Validation class.
200
+ *
201
  * @return type
202
  */
203
  protected function _cake() {
210
 
211
  /**
212
  * Maps rules between JS and PHP.
213
+ *
214
  * @param type $rule
215
  * @return type
216
  */
222
  * Renders JSON data.
223
  */
224
  public function renderJsonData() {
225
+ printf('<script type="text/javascript">wptValidationForms.push("#%s");</script>', $this->__formID);
 
226
  }
227
+
228
  public function actionFieldClass( $config ) {
229
  if ( !empty( $config['validation'] ) ) {
230
  foreach ($config['validation'] as $rule => $data) {
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.4/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.5/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.4/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.5/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/external/autocompleter.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/common/toolset-forms/js/colorpicker.js CHANGED
@@ -5,6 +5,7 @@ var wptColorpicker = (function($) {
5
  if ( 'function' == typeof ( $(event.target).data('_bindChange') ) ) {
6
  $(event.target).data('_bindChange')();
7
  }
 
8
  }
9
  });
10
  $(document).click(function (e) {
5
  if ( 'function' == typeof ( $(event.target).data('_bindChange') ) ) {
6
  $(event.target).data('_bindChange')();
7
  }
8
+
9
  }
10
  });
11
  $(document).click(function (e) {
embedded/common/toolset-forms/js/conditional.js CHANGED
@@ -1,35 +1,35 @@
1
  /**
2
  * @see WPToolset_Forms_Conditional (classes/conditional.php)
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/common/toolset-forms/js/conditional.js $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
- * $LastChangedBy: iworks $ Riccardo
8
  *
9
  */
10
  var wptCondTriggers = {}
11
- ,wptCondFields = {}
12
- ,wptCondCustomTriggers = {}
13
- ,wptCondCustomFields = {}
14
- ,wptCondDebug = false;
15
 
16
- var wptCond = (function($) {
17
 
18
  function init()
19
  {
20
- _.each(wptCondTriggers, function(triggers, formID) {
21
- _.each(triggers, function(fields, trigger) {
22
  var $trigger = _getTrigger(trigger, formID);
23
- _bindChange(formID, $trigger, function(e) {
24
  _check(formID, fields);
25
  });
26
  _check(formID, fields); // Check conditional on init
27
  });
28
  });
29
- _.each(wptCondCustomTriggers, function(triggers, formID) {
30
- _.each(triggers, function(fields, trigger) {
31
  var $trigger = _getTrigger(trigger, formID);
32
- _bindChange(formID, $trigger, function(e) {
33
  _custom(formID, fields);
34
  });
35
  _custom(formID, fields); // Check conditional on init
@@ -37,231 +37,242 @@ var wptCond = (function($) {
37
  });
38
  // Fire validation after init conditional
39
  wptCallbacks.validationInit.fire();
40
- // check initial custom NOTE this might be deprecated and not needed anymore
41
- _init_custom();
 
42
  }
43
-
44
- // hide / show effects
45
-
46
- $.fn.condSlideFadeDown = function(speed, easing, callback) {
47
  easing = easing || 'linear';
48
- return this.each(function(){$(this).animate({opacity: 'show', height: 'show'}, speed, easing, function() {
49
- $(this).css('height', 'auto');
50
- if ($.browser.msie) { this.style.removeAttribute('filter'); }
51
- if ($.isFunction(callback)) { callback.call(this); }
52
- });
53
- });
 
 
 
 
 
54
  };
55
-
56
- $.fn.condSlideFadeUp = function(speed, easing, callback) {
57
  easing = easing || 'linear';
58
- return this.each(function(){$(this).animate({opacity: 'hide', height: 'hide'}, speed, easing, function() {
59
- $(this).css('height', 'auto');
60
- if ($.browser.msie) { this.style.removeAttribute('filter'); }
61
- if ($.isFunction(callback)) { callback.call(this); }
62
- });
63
- });
 
 
 
 
 
64
  };
65
 
66
  function _getTrigger(trigger, formID)
67
  {
68
- var $trigger = $('[data-wpt-name="'+ trigger + '"]', formID);
69
  /**
70
  * wp-admin
71
  */
72
- if ( $('body').hasClass('wp-admin') ) {
73
- trigger = trigger.replace( /wpcf\-/, 'wpcf[' ) + ']';
74
- $trigger = $('[data-wpt-name="'+ trigger + '"]', formID);
75
 
76
  }
77
  /**
78
  * handle skype field
79
  */
80
- if ( $trigger.length < 1 ) {
81
- $trigger = $('[data-wpt-name="'+ trigger + '[skypename]"]', formID);
82
  }
83
  /**
84
  * handle date field
85
  */
86
- if ( $trigger.length < 1 ) {
87
- $trigger = $('[data-wpt-name="'+ trigger + '[datepicker]"]', formID);
88
  }
89
- /**
90
  * handle checkboxes and multiselect
91
  */
92
- if ( $trigger.length < 1 ) {
93
- $trigger = $('[data-wpt-name="'+ trigger + '[]"]', formID);
94
  }
95
  /**
96
  * handle select
97
  */
98
- if ( $trigger.length > 0 && 'option' == $trigger.data('wpt-type') ) {
99
  $trigger = $trigger.parent();
100
  }
101
  /**
102
  * debug
103
  */
104
- if ( wptCondDebug ) {
105
  console.info('_getTrigger');
106
- console.log( 'trigger', trigger );
107
- console.log( '$trigger', $trigger );
108
- console.log( 'formID', formID );
109
  }
110
  return $trigger;
111
  }
112
 
113
  function _getTriggerValue($trigger, formID)
114
  {
115
- if ( wptCondDebug ) {
116
  console.info('_getTriggerValue');
117
- console.log( '$trigger', $trigger );
118
- console.log( '$trigger.type', $trigger.data('wpt-type') );
119
  }
120
  // Do not add specific filtering for fields here
121
  // Use add_filter() to apply filters from /js/$type.js
122
  var val = null;
123
- // NOTE we might want to set val = ''; by default?
124
- switch( $trigger.data('wpt-type') ) {
125
  case 'radio':
126
  case 'radios':
127
  radio = $('[name="' + $trigger.attr('name') + '"]:checked', formID);
128
- // If no option was selected, the value should be empty
129
- val = '';
130
- if ( 'undefined' == typeof( radio.data('types-value' ) ) ) {
131
  val = radio.val();
132
  } else {
133
  val = radio.data('types-value');
134
  }
135
- if ( wptCondDebug ) {
136
- console.log( 'radio', radio );
137
  }
138
  break;
139
  case 'select':
140
- option = $('[name="' + $trigger.attr('name') + '"] option:selected', formID);
141
- // If no option was selected, the value should be empty
142
- val = '';
143
- if ( wptCondDebug ) {
144
- console.log( 'option', option );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  }
146
- if ( option.length == 1 ) {
147
- if ( 'undefined' == typeof( option.data('types-value' ) ) ) {
148
- val = option.val();
149
- } else {
150
- val = option.data('types-value');
151
- }
152
- } else if ( option.length > 1 ) {
153
- val = [];
154
- option.each(function() {
155
- if ( 'undefined' == typeof( $(this).data('types-value' ) ) ) {
156
- val.push($(this).val());
157
- } else {
158
- val.push($(this).data('types-value'));
159
- }
160
- });
161
- }
162
  break;
163
  case 'checkbox':
164
  var $trigger_checked = $trigger.filter(':checked');
165
- // If no checkbox was checked, the value should be empty
166
  val = '';
167
  //added data-value checking in order to fix
168
  //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188528502/comments
169
- if ( $trigger_checked.length == 1 ) {
170
- val = ($trigger_checked.attr('data-value'))?$trigger_checked.attr('data-value'):$trigger_checked.val();
171
- } else if ( $trigger_checked.length > 1 ) {
172
- val = [];
173
- $trigger_checked.each(function() {
174
- val.push(($(this).attr('data-value'))?$(this).attr('data-value'):$(this).val());
175
- });
176
  }
177
  //#########################################################################################
178
  break;
179
  case 'file':
180
- var $trigger_checked = $trigger.filter(':not([disabled])');
181
- val = $trigger_checked.val();
182
- break;
183
  default:
184
  val = $trigger.val();
185
  }
186
- if ( wptCondDebug ) {
187
- console.log( 'val', val );
188
  }
189
  return val;
190
  }
191
 
192
  function _getAffected(affected, formID)
193
  {
194
- if ( wptCondDebug ) {
195
  console.info('_getAffected');
196
  }
197
  var $el = $('[data-wpt-id="' + affected + '"]', formID);
198
- if ( $('body').hasClass('wp-admin') ) {
199
  $el = $el.closest('.wpt-field');
200
  if ($el.length < 1) {
201
  $el = $('#' + affected, formID).closest('.form-item');
202
  }
203
  } else {
204
- if ( $el.length < 1 ) {
205
- /**
206
- * get pure field name, without form prefix
207
- */
208
- re = new RegExp(formID+'_');
209
- name = '#'+affected;
210
- name = name.replace( re, '' );
211
- /**
212
- * try get element
213
- */
214
- $obj = $('[data-wpt-id="' + affected + '_file"]', formID);
215
- /**
216
- * handle by wpt field name
217
- */
218
- if ( $obj.length < 1 ) {
219
- $obj = $('[data-wpt-name="'+ name + '"]', formID);
220
- }
221
- /**
222
- * handle date field
223
- */
224
- if ( $obj.length < 1 ) {
225
- $obj = $('[data-wpt-name="'+ name + '[datepicker]"]', formID);
226
- }
227
- /**
228
- * handle skype field
229
- */
230
- if ( $obj.length < 1 ) {
231
- $obj = $('[data-wpt-name="'+ name + '[skypename]"]', formID);
232
- }
233
- /**
234
- * handle checkboxes field
235
- */
236
- if ( $obj.length < 1 ) {
237
- $obj = $('[data-wpt-name="'+ name + '[]"]', formID);
238
- }
239
- /**
240
- * catch by id
241
- */
242
- if ($obj.length < 1) {
243
- $obj = $('#' + affected, formID);
244
- }
245
-
246
- } else {
247
- $obj = $el;
248
- }
249
  /**
250
  * finally catch parent: we should have catched the $obj
251
  */
252
  if ($obj.length > 0) {
253
  $el = $obj.closest('.js-wpt-conditional-field');
254
- if ( $el.length < 1 ) {
255
- $el = $obj.closest('.cred-field');// This for backwards compatibility
256
- if ( $el.length < 1 ) {
257
- $el = $obj.closest('.js-wpt-field-items');
258
- }
259
- }
260
  }
261
  /**
262
  * debug
263
  */
264
- if ( wptCondDebug ) {
265
  console.log('$obj', $obj);
266
  }
267
  }
@@ -277,7 +288,7 @@ var wptCond = (function($) {
277
  /**
278
  * debug
279
  */
280
- if ( wptCondDebug ) {
281
  console.log('affected', affected);
282
  console.log('$el', $el);
283
  }
@@ -290,24 +301,24 @@ var wptCond = (function($) {
290
  var c = wptCondFields[formID][field];
291
  var passedOne = false, passedAll = true, passed = false;
292
  var $trigger;
293
- _.each(c.conditions, function(data) {
294
  if (__ignore) {
295
  return;
296
  }
297
  $trigger = _getTrigger(data.id, formID);
298
  var val = _getTriggerValue($trigger, formID);
299
- if ( wptCondDebug ) {
300
- console.log( 'formID', formID );
301
- console.log( '$trigger', $trigger );
302
  console.log('val', 1, val);
303
  }
304
 
305
- var field_type = $trigger.data('wpt-type');
306
- if ( data.type == 'date' ) {
307
- field_type = 'date';
308
- }
309
  val = apply_filters('conditional_value_' + field_type, val, $trigger);
310
- if ( wptCondDebug ) {
311
  console.log('val', 2, val);
312
  }
313
  do_action('conditional_check_' + data.type, formID, c, field);
@@ -315,92 +326,92 @@ var wptCond = (function($) {
315
  /**
316
  * handle types
317
  */
318
- // Not needed anymore
319
- // NEVER Date.parse timestamps coming from adodb_xxx functions
320
- /*
321
- switch(data.type) {
322
- case 'date'://alert(_val);alert(val);
323
- if ( _val ) {//alert('this is _val ' + _val);
324
- // _val = Date.parse(_val);//alert('this is _val after parse ' + _val);
325
- }//alert('val is ' + val);
326
- //val = Date.parse(val);//alert('parsed val is ' + val);
327
- break;
328
- }
329
- */
330
- if ('__ignore' == val ) {
331
  __ignore = true;
332
  return;
333
  }
334
  /**
335
  * debug
336
  */
337
- if ( wptCondDebug ) {
338
  console.log('val', 3, val);
339
  console.log('_val', _val);
340
  }
341
  /**
342
  * for __ignore_negative set some dummy operator
343
  */
344
- if ( 0 && '__ignore_negative' == val ) {
345
  operator = '__ignore';
346
  }
347
-
348
- if ( $.isArray( val ) ) {
349
- // If the selected value is an array, we just can check == and != operators, which means in_array and not_in_array
350
- // We return false in any other scenario
351
- switch (operator) {
352
- case '===':
353
- case '==':
354
- case '=':
355
- passed_single = jQuery.inArray( _val, val ) !== -1;
356
- break;
357
- case '!==':
358
- case '!=':
359
- case '<>':
360
- passed_single = jQuery.inArray( _val, val ) == -1;
361
- break;
362
- default:
363
- passed_single = false;
364
- break;
365
- }
366
- } else {
367
- // Note: we can use parseInt here although we are dealing with extended timestamps coming from adodb_xxx functions
368
- // Because javascript parseInt can deal with integers up to ±1e+21
369
- switch (operator) {
370
- case '===':
371
- case '==':
372
- case '=':
373
- if ( $.isArray( val ) ) {
374
-
375
- } else {
376
- passed_single = val == _val;
377
- }
378
- break;
379
- case '!==':
380
- case '!=':
381
- case '<>':
382
- passed_single = val != _val;
383
- break;
384
- case '>':
385
- passed_single = parseInt(val) > parseInt(_val);
386
- break;
387
- case '<':
388
- passed_single = parseInt(val) < parseInt(_val);
389
- break;
390
- case '>=':
391
- passed_single = parseInt(val) >= parseInt(_val);
392
- break;
393
- case '<=':
394
- passed_single = parseInt(val) <= parseInt(_val);
395
- break;
396
- case 'between':
397
- passed_single = parseInt(val) > parseInt(_val) && parseInt(val) < parseInt(data.args[1]);
398
- break;
399
- default:
400
- passed_single = false;
401
- break;
402
- }
403
- }
404
  if (!passed_single) {
405
  passedAll = false;
406
  } else {
@@ -417,14 +428,14 @@ var wptCond = (function($) {
417
  /**
418
  * debug
419
  */
420
- if ( wptCondDebug ) {
421
  console.log('passedAll', passedAll, 'passedOne', passedOne, 'passed', passed, '__ignore', __ignore);
422
  console.log('field', field);
423
  }
424
  if (!__ignore) {
425
  _showHide(passed, _getAffected(field, formID));
426
  }
427
- // No need to set a timeout anymore
428
  //if ( $trigger.length && next && $trigger.hasClass('js-wpt-date' ) ) {
429
  // setTimeout(function() {
430
  // _checkOneField( formID, field, false );
@@ -434,10 +445,10 @@ var wptCond = (function($) {
434
 
435
  function _check(formID, fields)
436
  {
437
- if ( wptCondDebug ) {
438
  console.info('_check');
439
  }
440
- _.each(fields, function(field) {
441
  _checkOneField(formID, field, true);
442
  });
443
  wptCallbacks.conditionalCheck.fire(formID);
@@ -455,12 +466,12 @@ var wptCond = (function($) {
455
  /**
456
  * debug
457
  */
458
- if ( wptCondDebug ) {
459
  console.info('_bindChange');
460
  console.log('$trigger', $trigger);
461
  console.log('wpt-type', $trigger.data('wpt-type'));
462
  }
463
- switch( $trigger.data('wpt-type') ) {
464
  case 'checkbox':
465
  $trigger.on('click', func);
466
  break;
@@ -474,18 +485,18 @@ var wptCond = (function($) {
474
  case 'select':
475
  $trigger.on('change', func);
476
  break;
477
- case 'date':
 
 
 
478
  $trigger.on('change', func);
479
  break;
480
- case 'file':
481
- $trigger.on('change', func);
482
- break;
483
  default:
484
- if ( $trigger.hasClass('js-wpt-colorpicker') ) {
485
  $trigger.data('_bindChange', func)
486
  }
487
  $($trigger).on('blur', func);
488
- break;
489
  }
490
  }
491
 
@@ -494,181 +505,195 @@ var wptCond = (function($) {
494
  /**
495
  * debug
496
  */
497
- if ( wptCondDebug ) {
498
  console.log('_custom');
499
  console.log('formID', formID);
500
  console.log('fields', fields);
501
  }
502
- _.each(fields, function(field) {
503
  var c = wptCondCustomFields[formID][field];
504
- var expression = c.custom;
505
 
506
- // Get the values and update the expression.
507
- _.each(c.triggers, function(t) {
508
  var $trigger = _getTrigger(t, formID),
509
- value = _getTriggerValue($trigger, formID),
510
- is_array = $trigger.length > 1 ? true : false;
511
- if ( wptCondDebug ) {
512
- console.log("The value is ", value, " for element: ", t, $trigger );
513
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
514
 
515
- if (typeof value != 'undefined') {
 
 
516
 
517
- // make it a string by wrapping in quotes if
518
- // 1. the value is an empty string
519
- // 2. or it's not a number
520
-
521
- // if the trigger is an array, eg checkboxes
522
- // then convert value to ARRAY(...)
523
-
524
 
525
- if( is_array === true ) {
 
526
 
527
  var val_array = '';
528
 
529
- if ( wptCondDebug ) {
530
  console.log();
531
  }
532
 
533
- if (value instanceof Array) {
534
- for(var i = 0; i < value.length; i++) {
535
- var val = value[i];
536
- if (val === '' || isNaN(val)) {
537
- val = '\'' + val + '\'';
538
- }
539
-
540
- if (val_array == '') {
541
- val_array = val;
542
- } else {
543
- val_array += ',' + val;
544
- }
545
- }
546
- } else {
547
- if (isNaN(value)) {
548
- value = '\'' + value + '\'';
549
- }
550
- val_array = value;
551
- }
552
-
553
- value = 'ARRAY(' + val_array + ')';
554
-
 
 
 
 
 
 
555
  }
556
- else
557
- {
558
- if (value === '' || isNaN(value)) {
559
- value = '\'' + value + '\'';
560
- }
561
- }
562
 
563
- // First replace the $(field_name) format
564
- var replace = new RegExp( '\\$\\(' + t + '\\)', 'g' );
565
 
566
- expression = expression.replace( replace, value );
567
 
568
- // next replace the $field_name format
569
- var replace_old = new RegExp( '\\$' + t, 'g' );
570
 
571
- expression = expression.replace( replace_old, value );
572
 
573
- }
574
 
575
  });
576
-
577
- var result = false;
578
-
579
- try {
580
- var parser = new ToolsetParser.Expression(expression);
581
- parser.parse();
582
- result = parser.eval();
583
- }
584
- catch(e) {
585
- console.info( "Error in Tokenizer", e, expression, " there may be an error in your expression syntax" );
586
- }
587
-
588
-
589
-
590
- _showHide(result, _getAffected(field, formID));
591
-
592
  });
593
- wptCallbacks.conditionalCheck.fire(formID);
594
  }
595
 
596
  function _showHide(show, $el)
597
  {
598
- if ( wptCondDebug ) {
 
 
 
 
 
599
  console.info('_showHide');
600
  console.log(show, $el);
601
  }
602
-
603
- var effectmode = '',
604
- dur = 'slow',
605
- delay = 50;
606
-
607
- if ( $el.attr( 'data-effectmode' ) ) {
608
- effectmode = $el.data( 'effectmode' );
609
- } else {
610
- effectmode = 'slide';
611
- }
612
-
613
- if ( show ) {
614
- $el.addClass( 'wpt-conditional-visible' ).removeClass( 'wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore' );
615
- switch( effectmode ) {
616
- case 'fade-slide':
617
- setTimeout( function() {
618
- $el.stop( true ).condSlideFadeDown( dur, 'linear' );
619
- }, delay );
620
- break;
621
- case 'slide':
622
- setTimeout( function() {
623
- $el.stop( true ).slideDown( dur, 'linear', function() {
624
- $el.css('height', 'auto');
625
- });
626
- }, delay );
627
- break;
628
- case 'fade':
629
- setTimeout( function() {
630
- $el.stop( true ).fadeIn( dur );
631
- }, delay );
632
- break;
633
- case 'none':
634
- break;
635
- default:
636
- $el.show();
637
- break;
638
- }
639
- } else {
640
- $el.addClass( 'wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore' ).removeClass( 'wpt-conditional-visible' );
641
- switch( effectmode ) {
642
- case 'fade-slide':
643
- setTimeout( function() {
644
- $el.stop( true ).condSlideFadeUp( dur, 'linear' );
645
- }, delay );
646
- break;
647
- case 'slide':
648
- setTimeout( function() {
649
- $el.stop( true ).slideUp( dur, 'linear', function() {
650
- $el.css('height', 'auto');
651
- });
652
- }, delay );
653
- break;
654
- case 'fade':
655
- setTimeout( function() {
656
- $el.stop( true ).fadeOut( dur );
657
- }, delay );
658
- break;
659
- case 'none':
660
- break;
661
- default:
662
- $el.hide();
663
- break;
664
- }
665
- }
666
  }
667
 
668
  function ajaxCheck(formID, field, conditions)
669
  {
670
  var values = {};
671
- _.each(conditions.conditions, function(c) {
672
  var $trigger = _getTrigger(c.id, formID);
673
  values[c.id] = _getTriggerValue($trigger);
674
  });
@@ -677,63 +702,67 @@ var wptCond = (function($) {
677
  'conditions': conditions,
678
  'values': values
679
  };
680
- $.post(wptConditional.ajaxurl, data, function(passed) {
681
  _showHide(passed, _getAffected(field, formID));
682
  wptCallbacks.conditionalCheck.fire(formID);
683
- }).fail(function(data) {
684
  //alert(data);
685
  });
686
  }
687
 
688
  function addConditionals(data)
689
  {
690
- _.each(data, function(c, formID) {
691
  if (typeof c.triggers != 'undefined'
692
  && typeof wptCondTriggers[formID] != 'undefined') {
693
- _.each(c.triggers, function(fields, trigger) {
694
  wptCondTriggers[formID][trigger] = fields;
695
  var $trigger = _getTrigger(trigger, formID);
696
- _bindChange(formID, $trigger, function() {
697
  _check(formID, fields);
698
  });
699
  });
700
  }
701
  if (typeof c.fields != 'undefined'
702
  && typeof wptCondFields[formID] != 'undefined') {
703
- _.each(c.fields, function(conditionals, field) {
704
  wptCondFields[formID][field] = conditionals;
705
  });
706
  }
707
  if (typeof c.custom_triggers != 'undefined'
708
  && typeof wptCondCustomTriggers[formID] != 'undefined') {
709
- _.each(c.custom_triggers, function(fields, trigger) {
710
  wptCondCustomTriggers[formID][trigger] = fields;
711
  var $trigger = _getTrigger(trigger, formID);
712
- _bindChange(formID, $trigger, function() {
713
  _custom(formID, fields);
714
  });
715
  });
716
  }
717
  if (typeof c.custom_fields != 'undefined'
718
  && typeof wptCondCustomFields[formID] != 'undefined') {
719
- _.each(c.custom_fields, function(conditionals, field) {
720
  wptCondCustomFields[formID][field] = conditionals;
721
  });
722
  }
723
  });
724
  }
725
-
726
- function _init_custom() {
727
- $('.js-wpt-field-items').each( function () {
728
- var init_custom = $(this).data('initial-conditional');
729
- if (init_custom) {
730
- var field = $(this).closest('.cred-field');
731
- if (field.length) {
732
- _showHide(false, field);
733
- }
734
- }
735
- })
736
- }
 
 
 
 
737
 
738
  return {
739
  init: init,
1
  /**
2
  * @see WPToolset_Forms_Conditional (classes/conditional.php)
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 = {}
11
+ , wptCondFields = {}
12
+ , wptCondCustomTriggers = {}
13
+ , wptCondCustomFields = {}
14
+ , wptCondDebug = false;
15
 
16
+ var wptCond = (function ($) {
17
 
18
  function init()
19
  {
20
+ _.each(wptCondTriggers, function (triggers, formID) {
21
+ _.each(triggers, function (fields, trigger) {
22
  var $trigger = _getTrigger(trigger, formID);
23
+ _bindChange(formID, $trigger, function (e) {
24
  _check(formID, fields);
25
  });
26
  _check(formID, fields); // Check conditional on init
27
  });
28
  });
29
+ _.each(wptCondCustomTriggers, function (triggers, formID) {
30
+ _.each(triggers, function (fields, trigger) {
31
  var $trigger = _getTrigger(trigger, formID);
32
+ _bindChange(formID, $trigger, function (e) {
33
  _custom(formID, fields);
34
  });
35
  _custom(formID, fields); // Check conditional on init
37
  });
38
  // Fire validation after init conditional
39
  wptCallbacks.validationInit.fire();
40
+ // check initial custom NOTE this might be deprecated and not needed anymore
41
+ //Fix double showHide on submition failed: commenting this
42
+ //_init_custom();
43
  }
44
+
45
+ // hide / show effects
46
+
47
+ $.fn.condSlideFadeDown = function (speed, easing, callback) {
48
  easing = easing || 'linear';
49
+ return this.each(function () {
50
+ $(this).animate({opacity: 'show', height: 'show'}, speed, easing, function () {
51
+ $(this).css('height', 'auto');
52
+ if ($.browser.msie) {
53
+ this.style.removeAttribute('filter');
54
+ }
55
+ if ($.isFunction(callback)) {
56
+ callback.call(this);
57
+ }
58
+ });
59
+ });
60
  };
61
+
62
+ $.fn.condSlideFadeUp = function (speed, easing, callback) {
63
  easing = easing || 'linear';
64
+ return this.each(function () {
65
+ $(this).animate({opacity: 'hide', height: 'hide'}, speed, easing, function () {
66
+ $(this).css('height', 'auto');
67
+ if ($.browser.msie) {
68
+ this.style.removeAttribute('filter');
69
+ }
70
+ if ($.isFunction(callback)) {
71
+ callback.call(this);
72
+ }
73
+ });
74
+ });
75
  };
76
 
77
  function _getTrigger(trigger, formID)
78
  {
79
+ var $trigger = $('[data-wpt-name="' + trigger + '"]', formID);
80
  /**
81
  * wp-admin
82
  */
83
+ if ($('body').hasClass('wp-admin')) {
84
+ trigger = trigger.replace(/wpcf\-/, 'wpcf[') + ']';
85
+ $trigger = $('[data-wpt-name="' + trigger + '"]', formID);
86
 
87
  }
88
  /**
89
  * handle skype field
90
  */
91
+ if ($trigger.length < 1) {
92
+ $trigger = $('[data-wpt-name="' + trigger + '[skypename]"]', formID);
93
  }
94
  /**
95
  * handle date field
96
  */
97
+ if ($trigger.length < 1) {
98
+ $trigger = $('[data-wpt-name="' + trigger + '[datepicker]"]', formID);
99
  }
100
+ /**
101
  * handle checkboxes and multiselect
102
  */
103
+ if ($trigger.length < 1) {
104
+ $trigger = $('[data-wpt-name="' + trigger + '[]"]', formID);
105
  }
106
  /**
107
  * handle select
108
  */
109
+ if ($trigger.length > 0 && 'option' == $trigger.data('wpt-type')) {
110
  $trigger = $trigger.parent();
111
  }
112
  /**
113
  * debug
114
  */
115
+ if (wptCondDebug) {
116
  console.info('_getTrigger');
117
+ console.log('trigger', trigger);
118
+ console.log('$trigger', $trigger);
119
+ console.log('formID', formID);
120
  }
121
  return $trigger;
122
  }
123
 
124
  function _getTriggerValue($trigger, formID)
125
  {
126
+ if (wptCondDebug) {
127
  console.info('_getTriggerValue');
128
+ console.log('$trigger', $trigger);
129
+ console.log('$trigger.type', $trigger.data('wpt-type'));
130
  }
131
  // Do not add specific filtering for fields here
132
  // Use add_filter() to apply filters from /js/$type.js
133
  var val = null;
134
+ // NOTE we might want to set val = ''; by default?
135
+ switch ($trigger.data('wpt-type')) {
136
  case 'radio':
137
  case 'radios':
138
  radio = $('[name="' + $trigger.attr('name') + '"]:checked', formID);
139
+ // If no option was selected, the value should be empty
140
+ val = '';
141
+ if ('undefined' == typeof (radio.data('types-value'))) {
142
  val = radio.val();
143
  } else {
144
  val = radio.data('types-value');
145
  }
146
+ if (wptCondDebug) {
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();
160
+ } else {
161
+ val = option.data('types-value');
162
+ }
163
+ } else if (option.length > 1) {
164
+ val = [];
165
+ option.each(function () {
166
+ if ('undefined' == typeof ($(this).data('types-value'))) {
167
+ val.push($(this).val());
168
+ } else {
169
+ val.push($(this).data('types-value'));
170
+ }
171
+ });
172
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  break;
174
  case 'checkbox':
175
  var $trigger_checked = $trigger.filter(':checked');
176
+ // If no checkbox was checked, the value should be empty
177
  val = '';
178
  //added data-value checking in order to fix
179
  //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188528502/comments
180
+ if ($trigger_checked.length == 1) {
181
+ val = ($trigger_checked.attr('data-value')) ? $trigger_checked.attr('data-value') : $trigger_checked.val();
182
+ } else if ($trigger_checked.length > 1) {
183
+ val = [];
184
+ $trigger_checked.each(function () {
185
+ val.push(($(this).attr('data-value')) ? $(this).attr('data-value') : $(this).val());
186
+ });
187
  }
188
  //#########################################################################################
189
  break;
190
  case 'file':
191
+ var $trigger_checked = $trigger.filter(':not([disabled])');
192
+ val = $trigger_checked.val();
193
+ break;
194
  default:
195
  val = $trigger.val();
196
  }
197
+ if (wptCondDebug) {
198
+ console.log('val', val);
199
  }
200
  return val;
201
  }
202
 
203
  function _getAffected(affected, formID)
204
  {
205
+ if (wptCondDebug) {
206
  console.info('_getAffected');
207
  }
208
  var $el = $('[data-wpt-id="' + affected + '"]', formID);
209
+ if ($('body').hasClass('wp-admin')) {
210
  $el = $el.closest('.wpt-field');
211
  if ($el.length < 1) {
212
  $el = $('#' + affected, formID).closest('.form-item');
213
  }
214
  } else {
215
+ if ($el.length < 1) {
216
+ /**
217
+ * get pure field name, without form prefix
218
+ */
219
+ re = new RegExp(formID + '_');
220
+ name = '#' + affected;
221
+ name = name.replace(re, '');
222
+ /**
223
+ * try get element
224
+ */
225
+ $obj = $('[data-wpt-id="' + affected + '_file"]', formID);
226
+ /**
227
+ * handle by wpt field name
228
+ */
229
+ if ($obj.length < 1) {
230
+ $obj = $('[data-wpt-name="' + name + '"]', formID);
231
+ }
232
+ /**
233
+ * handle date field
234
+ */
235
+ if ($obj.length < 1) {
236
+ $obj = $('[data-wpt-name="' + name + '[datepicker]"]', formID);
237
+ }
238
+ /**
239
+ * handle skype field
240
+ */
241
+ if ($obj.length < 1) {
242
+ $obj = $('[data-wpt-name="' + name + '[skypename]"]', formID);
243
+ }
244
+ /**
245
+ * handle checkboxes field
246
+ */
247
+ if ($obj.length < 1) {
248
+ $obj = $('[data-wpt-name="' + name + '[]"]', formID);
249
+ }
250
+ /**
251
+ * catch by id
252
+ */
253
+ if ($obj.length < 1) {
254
+ $obj = $('#' + affected, formID);
255
+ }
256
+
257
+ } else {
258
+ $obj = $el;
259
+ }
260
  /**
261
  * finally catch parent: we should have catched the $obj
262
  */
263
  if ($obj.length > 0) {
264
  $el = $obj.closest('.js-wpt-conditional-field');
265
+ if ($el.length < 1) {
266
+ $el = $obj.closest('.cred-field');// This for backwards compatibility
267
+ if ($el.length < 1) {
268
+ $el = $obj.closest('.js-wpt-field-items');
269
+ }
270
+ }
271
  }
272
  /**
273
  * debug
274
  */
275
+ if (wptCondDebug) {
276
  console.log('$obj', $obj);
277
  }
278
  }
288
  /**
289
  * debug
290
  */
291
+ if (wptCondDebug) {
292
  console.log('affected', affected);
293
  console.log('$el', $el);
294
  }
301
  var c = wptCondFields[formID][field];
302
  var passedOne = false, passedAll = true, passed = false;
303
  var $trigger;
304
+ _.each(c.conditions, function (data) {
305
  if (__ignore) {
306
  return;
307
  }
308
  $trigger = _getTrigger(data.id, formID);
309
  var val = _getTriggerValue($trigger, formID);
310
+ if (wptCondDebug) {
311
+ console.log('formID', formID);
312
+ console.log('$trigger', $trigger);
313
  console.log('val', 1, val);
314
  }
315
 
316
+ var field_type = $trigger.data('wpt-type');
317
+ if (data.type == 'date') {
318
+ field_type = 'date';
319
+ }
320
  val = apply_filters('conditional_value_' + field_type, val, $trigger);
321
+ if (wptCondDebug) {
322
  console.log('val', 2, val);
323
  }
324
  do_action('conditional_check_' + data.type, formID, c, field);
326
  /**
327
  * handle types
328
  */
329
+ // Not needed anymore
330
+ // NEVER Date.parse timestamps coming from adodb_xxx functions
331
+ /*
332
+ switch(data.type) {
333
+ case 'date'://alert(_val);alert(val);
334
+ if ( _val ) {//alert('this is _val ' + _val);
335
+ // _val = Date.parse(_val);//alert('this is _val after parse ' + _val);
336
+ }//alert('val is ' + val);
337
+ //val = Date.parse(val);//alert('parsed val is ' + val);
338
+ break;
339
+ }
340
+ */
341
+ if ('__ignore' == val) {
342
  __ignore = true;
343
  return;
344
  }
345
  /**
346
  * debug
347
  */
348
+ if (wptCondDebug) {
349
  console.log('val', 3, val);
350
  console.log('_val', _val);
351
  }
352
  /**
353
  * for __ignore_negative set some dummy operator
354
  */
355
+ if (0 && '__ignore_negative' == val) {
356
  operator = '__ignore';
357
  }
358
+
359
+ if ($.isArray(val)) {
360
+ // If the selected value is an array, we just can check == and != operators, which means in_array and not_in_array
361
+ // We return false in any other scenario
362
+ switch (operator) {
363
+ case '===':
364
+ case '==':
365
+ case '=':
366
+ passed_single = jQuery.inArray(_val, val) !== -1;
367
+ break;
368
+ case '!==':
369
+ case '!=':
370
+ case '<>':
371
+ passed_single = jQuery.inArray(_val, val) == -1;
372
+ break;
373
+ default:
374
+ passed_single = false;
375
+ break;
376
+ }
377
+ } else {
378
+ // Note: we can use parseInt here although we are dealing with extended timestamps coming from adodb_xxx functions
379
+ // Because javascript parseInt can deal with integers up to ±1e+21
380
+ switch (operator) {
381
+ case '===':
382
+ case '==':
383
+ case '=':
384
+ if ($.isArray(val)) {
385
+
386
+ } else {
387
+ passed_single = val == _val;
388
+ }
389
+ break;
390
+ case '!==':
391
+ case '!=':
392
+ case '<>':
393
+ passed_single = val != _val;
394
+ break;
395
+ case '>':
396
+ passed_single = parseInt(val) > parseInt(_val);
397
+ break;
398
+ case '<':
399
+ passed_single = parseInt(val) < parseInt(_val);
400
+ break;
401
+ case '>=':
402
+ passed_single = parseInt(val) >= parseInt(_val);
403
+ break;
404
+ case '<=':
405
+ passed_single = parseInt(val) <= parseInt(_val);
406
+ break;
407
+ case 'between':
408
+ passed_single = parseInt(val) > parseInt(_val) && parseInt(val) < parseInt(data.args[1]);
409
+ break;
410
+ default:
411
+ passed_single = false;
412
+ break;
413
+ }
414
+ }
415
  if (!passed_single) {
416
  passedAll = false;
417
  } else {
428
  /**
429
  * debug
430
  */
431
+ if (wptCondDebug) {
432
  console.log('passedAll', passedAll, 'passedOne', passedOne, 'passed', passed, '__ignore', __ignore);
433
  console.log('field', field);
434
  }
435
  if (!__ignore) {
436
  _showHide(passed, _getAffected(field, formID));
437
  }
438
+ // No need to set a timeout anymore
439
  //if ( $trigger.length && next && $trigger.hasClass('js-wpt-date' ) ) {
440
  // setTimeout(function() {
441
  // _checkOneField( formID, field, false );
445
 
446
  function _check(formID, fields)
447
  {
448
+ if (wptCondDebug) {
449
  console.info('_check');
450
  }
451
+ _.each(fields, function (field) {
452
  _checkOneField(formID, field, true);
453
  });
454
  wptCallbacks.conditionalCheck.fire(formID);
466
  /**
467
  * debug
468
  */
469
+ if (wptCondDebug) {
470
  console.info('_bindChange');
471
  console.log('$trigger', $trigger);
472
  console.log('wpt-type', $trigger.data('wpt-type'));
473
  }
474
+ switch ($trigger.data('wpt-type')) {
475
  case 'checkbox':
476
  $trigger.on('click', func);
477
  break;
485
  case 'select':
486
  $trigger.on('change', func);
487
  break;
488
+ case 'date':
489
+ $trigger.on('change', func);
490
+ break;
491
+ case 'file':
492
  $trigger.on('change', func);
493
  break;
 
 
 
494
  default:
495
+ if ($trigger.hasClass('js-wpt-colorpicker')) {
496
  $trigger.data('_bindChange', func)
497
  }
498
  $($trigger).on('blur', func);
499
+ break;
500
  }
501
  }
502
 
505
  /**
506
  * debug
507
  */
508
+ if (wptCondDebug) {
509
  console.log('_custom');
510
  console.log('formID', formID);
511
  console.log('fields', fields);
512
  }
513
+ _.each(fields, function (field) {
514
  var c = wptCondCustomFields[formID][field];
515
+ var expression = c.custom;
516
 
517
+ // Get the values and update the expression.
518
+ _.each(c.triggers, function (t) {
519
  var $trigger = _getTrigger(t, formID),
520
+ value = _getTriggerValue($trigger, formID),
521
+ is_array = $trigger.length > 1 ? true : false;
522
+ if (wptCondDebug) {
523
+ console.log("The value is ", value, " for element: ", t, $trigger);
524
+ }
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
+
537
+ if (typeof value != 'undefined') {
538
 
539
+ // make it a string by wrapping in quotes if
540
+ // 1. the value is an empty string
541
+ // 2. or it's not a number
542
 
543
+ // if the trigger is an array, eg checkboxes
544
+ // then convert value to ARRAY(...)
 
 
 
 
 
545
 
546
+
547
+ if (is_array === true) {
548
 
549
  var val_array = '';
550
 
551
+ if (wptCondDebug) {
552
  console.log();
553
  }
554
 
555
+ if (value instanceof Array) {
556
+ for (var i = 0; i < value.length; i++) {
557
+ var val = value[i];
558
+ if (val === '' || isNaN(val)) {
559
+ val = '\'' + val + '\'';
560
+ }
561
+
562
+ if (val_array == '') {
563
+ val_array = val;
564
+ } else {
565
+ val_array += ',' + val;
566
+ }
567
+ }
568
+ } else {
569
+ if (isNaN(value)) {
570
+ value = '\'' + value + '\'';
571
+ }
572
+ val_array = value;
573
+ }
574
+
575
+ value = 'ARRAY(' + val_array + ')';
576
+
577
+ }
578
+ else
579
+ {
580
+ if (value === '' || isNaN(value)) {
581
+ value = '\'' + value + '\'';
582
+ }
583
  }
 
 
 
 
 
 
584
 
585
+ // First replace the $(field_name) format
586
+ var replace = new RegExp('\\$\\(' + t + '\\)', 'g');
587
 
588
+ expression = expression.replace(replace, value);
589
 
590
+ // next replace the $field_name format
591
+ var replace_old = new RegExp('\\$' + t, 'g');
592
 
593
+ expression = expression.replace(replace_old, value);
594
 
595
+ }
596
 
597
  });
598
+
599
+ var result = false;
600
+
601
+ try {
602
+ var parser = new ToolsetParser.Expression(expression);
603
+ parser.parse();
604
+ result = parser.eval();
605
+ }
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);
614
  }
615
 
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');
625
  console.log(show, $el);
626
  }
627
+
628
+ var effectmode = '',
629
+ dur = 'slow',
630
+ delay = 50;
631
+
632
+ if ($el.attr('data-effectmode')) {
633
+ effectmode = $el.data('effectmode');
634
+ } else {
635
+ effectmode = 'slide';
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':
642
+ setTimeout(function () {
643
+ $el.stop(true).condSlideFadeDown(dur, 'linear');
644
+ }, delay);
645
+ break;
646
+ case 'slide':
647
+ setTimeout(function () {
648
+ $el.stop(true).slideDown(dur, 'linear', function () {
649
+ $el.css('height', 'auto');
650
+ });
651
+ }, delay);
652
+ break;
653
+ case 'fade':
654
+ setTimeout(function () {
655
+ $el.stop(true).fadeIn(dur);
656
+ }, delay);
657
+ break;
658
+ case 'none':
659
+ break;
660
+ default:
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) {
667
+ case 'fade-slide':
668
+ setTimeout(function () {
669
+ $el.stop(true).condSlideFadeUp(dur, 'linear');
670
+ }, delay);
671
+ break;
672
+ case 'slide':
673
+ setTimeout(function () {
674
+ $el.stop(true).slideUp(dur, 'linear', function () {
675
+ $el.css('height', 'auto');
676
+ });
677
+ }, delay);
678
+ break;
679
+ case 'fade':
680
+ setTimeout(function () {
681
+ $el.stop(true).fadeOut(dur);
682
+ }, delay);
683
+ break;
684
+ case 'none':
685
+ break;
686
+ default:
687
+ $el.hide();
688
+ break;
689
+ }
690
+ }
691
  }
692
 
693
  function ajaxCheck(formID, field, conditions)
694
  {
695
  var values = {};
696
+ _.each(conditions.conditions, function (c) {
697
  var $trigger = _getTrigger(c.id, formID);
698
  values[c.id] = _getTriggerValue($trigger);
699
  });
702
  'conditions': conditions,
703
  'values': values
704
  };
705
+ $.post(wptConditional.ajaxurl, data, function (passed) {
706
  _showHide(passed, _getAffected(field, formID));
707
  wptCallbacks.conditionalCheck.fire(formID);
708
+ }).fail(function (data) {
709
  //alert(data);
710
  });
711
  }
712
 
713
  function addConditionals(data)
714
  {
715
+ _.each(data, function (c, formID) {
716
  if (typeof c.triggers != 'undefined'
717
  && typeof wptCondTriggers[formID] != 'undefined') {
718
+ _.each(c.triggers, function (fields, trigger) {
719
  wptCondTriggers[formID][trigger] = fields;
720
  var $trigger = _getTrigger(trigger, formID);
721
+ _bindChange(formID, $trigger, function () {
722
  _check(formID, fields);
723
  });
724
  });
725
  }
726
  if (typeof c.fields != 'undefined'
727
  && typeof wptCondFields[formID] != 'undefined') {
728
+ _.each(c.fields, function (conditionals, field) {
729
  wptCondFields[formID][field] = conditionals;
730
  });
731
  }
732
  if (typeof c.custom_triggers != 'undefined'
733
  && typeof wptCondCustomTriggers[formID] != 'undefined') {
734
+ _.each(c.custom_triggers, function (fields, trigger) {
735
  wptCondCustomTriggers[formID][trigger] = fields;
736
  var $trigger = _getTrigger(trigger, formID);
737
+ _bindChange(formID, $trigger, function () {
738
  _custom(formID, fields);
739
  });
740
  });
741
  }
742
  if (typeof c.custom_fields != 'undefined'
743
  && typeof wptCondCustomFields[formID] != 'undefined') {
744
+ _.each(c.custom_fields, function (conditionals, field) {
745
  wptCondCustomFields[formID][field] = conditionals;
746
  });
747
  }
748
  });
749
  }
750
+
751
+ /**
752
+ * deprecated
753
+ * @returns {undefined}
754
+ */
755
+ function _init_custom() {
756
+ $('.js-wpt-field-items').each(function () {
757
+ var init_custom = $(this).data('initial-conditional');
758
+ if (init_custom) {
759
+ var field = $(this).closest('.cred-field');
760
+ if (field.length) {
761
+ _showHide(false, field);
762
+ }
763
+ }
764
+ })
765
+ }
766
 
767
  return {
768
  init: init,
embedded/common/toolset-forms/js/date.js CHANGED
@@ -33,10 +33,12 @@ var wptDate = (function ($) {
33
  el = thiz.closest('.js-wpt-date');
34
  el_select = thiz.closest('select');
35
  }
36
- el_aux.val('').trigger('change');
 
37
  el.val('');
38
  el_select.val('0');
39
  thiz.hide();
 
40
  });
41
  }
42
 
@@ -79,6 +81,7 @@ var wptDate = (function ($) {
79
  var data = 'date=' + dateText;
80
  data += '&date-format=' + wptDateData.dateFormatPhp;
81
  data += '&action=wpt_localize_extended_date';
 
82
  $.post(wptDateData.ajaxurl, data, function (response) {
83
  response = $.parseJSON(response);
84
  if (el_aux.length > 0) {
@@ -86,6 +89,9 @@ var wptDate = (function ($) {
86
  }
87
  el.val(response['display']);
88
  el_clear.show();
 
 
 
89
  });
90
  //el.trigger('wptDateSelect');
91
  },
33
  el = thiz.closest('.js-wpt-date');
34
  el_select = thiz.closest('select');
35
  }
36
+ //Added trigger('wptDateSelect'); fix trigger validation and condition on click of clear
37
+ el_aux.val('').trigger('change').trigger('wptDateSelect');
38
  el.val('');
39
  el_select.val('0');
40
  thiz.hide();
41
+
42
  });
43
  }
44
 
81
  var data = 'date=' + dateText;
82
  data += '&date-format=' + wptDateData.dateFormatPhp;
83
  data += '&action=wpt_localize_extended_date';
84
+
85
  $.post(wptDateData.ajaxurl, data, function (response) {
86
  response = $.parseJSON(response);
87
  if (el_aux.length > 0) {
89
  }
90
  el.val(response['display']);
91
  el_clear.show();
92
+
93
+ //Fix adding remove label on date
94
+ el.prev('label.wpt-form-error').remove();
95
  });
96
  //el.trigger('wptDateSelect');
97
  },
embedded/common/toolset-forms/js/file.js CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  *
3
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
1
  /**
2
  *
3
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/common/toolset-forms/js/main.js CHANGED
@@ -69,12 +69,11 @@ function do_action(name) {
69
  /**
70
  * flat taxonomies functions
71
  */
72
- function showHideMostPopularButton(taxonomy)
73
  {
74
-
75
- var $button = jQuery('[name="sh_' + taxonomy + '"]')
76
- , $taxonomy_box = jQuery('.shmpt-' + taxonomy)
77
- , $tag_list = $taxonomy_box.find('.js-wpt-taxonomy-popular-add');
78
 
79
  if( !$button.hasClass('js-wpt-taxonomy-popular-show-hide') ) return true;
80
 
@@ -89,28 +88,29 @@ function showHideMostPopularButton(taxonomy)
89
  }
90
 
91
  jQuery(document).on('click', '.js-wpt-taxonomy-popular-show-hide', function() {
92
- showHideMostPopularTaxonomy(this);
93
  });
94
 
95
  function showHideMostPopularTaxonomy(el)
96
  {
97
  var taxonomy = jQuery(el).data('taxonomy');
98
- jQuery('.shmpt-'+taxonomy, jQuery(el).closest('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')).addClass('btn-cancel');
102
  } else {
103
- jQuery(el).val(jQuery(el).data('show-popular-text')).removeClass('btn-cancel');
104
  }
105
  }
106
 
107
  jQuery(document).on('click', '.js-wpt-taxonomy-popular-add', function() {
108
- var thiz = jQuery(this),
109
- taxonomy = thiz.data( 'taxonomy' );
110
- slug = thiz.data( 'slug' );
111
- _name = thiz.data( 'name' );
112
- addTaxonomy(_name, taxonomy, this);
113
- return false;
114
  });
115
 
116
  function addTaxonomy(slug, taxonomy, el)
@@ -127,8 +127,6 @@ function addTaxonomy(slug, taxonomy, el)
127
  }
128
  }
129
  jQuery('input[name=tmp_'+taxonomy+']', form).val('');
130
-
131
-
132
  }
133
 
134
  jQuery(document).on('click', '.js-wpt-taxonomy-add-new', function() {
@@ -254,11 +252,11 @@ toolsetForms.CRED_taxonomy = function () {
254
  jQuery('input[name="' + taxonomy + '\[\]"]').each (function () {
255
  var id = jQuery(this).attr('id');
256
  var label = jQuery(this).next('label');
257
- var level = jQuery(this).closest('ul').data('level');
258
- var prefix = '';
259
- if ( level ) {
260
- prefix = "\xA0\xA0" + Array(level).join("\xA0\xA0");
261
- }
262
  select.append('<option value="' + jQuery(this).val() + '">' + prefix + label.text() + '</option>');
263
  })
264
 
@@ -277,21 +275,22 @@ toolsetForms.CRED_taxonomy = function () {
277
  self._initialize_taxonomy_buttons = function () {
278
  // replace the taxonomy button placeholders with the actual buttons.
279
  jQuery('.js-taxonomy-button-placeholder').each(function () {
280
- var placeholder = jQuery(this),
281
- taxonomy = jQuery(this).data('taxonomy'),
282
- buttons = jQuery('[name="sh_' + taxonomy + '"],[name="btn_' + taxonomy + '"]'),
283
- selectors = [];
 
284
 
285
  if (buttons.length) {
286
 
287
  buttons.each(function () {
288
- var button = jQuery(this);
289
 
290
  button.detach();
291
  placeholder.replaceWith(button);
292
 
293
  if (button.hasClass('js-wpt-taxonomy-popular-show-hide')) {
294
- if( showHideMostPopularButton(taxonomy) ) {
295
  button.show();
296
  }
297
  } else {
@@ -326,7 +325,8 @@ toolsetForms.CRED_taxonomy = function () {
326
  });
327
 
328
  self.add_new_show_hide = function ( taxonomy, button ) {
329
- jQuery('.js-wpt-hierarchical-taxonomy-add-new-' + taxonomy).toggle();
 
330
  self.hide_parent_button_if_no_terms( taxonomy, button );
331
  }
332
 
@@ -348,39 +348,40 @@ toolsetForms.CRED_taxonomy = function () {
348
 
349
  self.terms_exist = function( taxonomy, button )
350
  {
351
- var build_what = jQuery(button).data('build_what'), parent = jQuery('[name="new_tax_select_' + taxonomy + '"]').val();
 
352
  if ( build_what === 'checkboxes' ){
353
- var first_checkbox = jQuery('input[name="' + taxonomy + '\[\]"][data-parent="' + parent + '"]:first');
354
  return first_checkbox.length > 0;
355
- }
356
- else
357
- {
358
- var first_option = jQuery('select[name="' + taxonomy + '\[\]"]').find('option[data-parent="' + parent + '"]:first');
359
  return first_option.length > 0;
360
  }
361
 
362
  return false;
363
  };
364
 
365
- self._add_new_flag = false;
366
  self.hide_parent_button_if_no_terms = function( taxonomy, button )
367
  {
368
- self._add_new_flag=!self._add_new_flag;
369
- //if( self.terms_exist(taxonomy, button) === false ) {
370
- if( self._add_new_flag === false ) {
371
- jQuery('[name="new_tax_select_' + taxonomy + '"]').hide();
372
  }
373
- else
374
- {
375
- jQuery('[name="new_tax_select_' + taxonomy + '"]').show();
 
 
376
  }
377
  };
378
 
379
-
380
- self.add_taxonomy = function ( taxonomy, button ) {
381
-
382
- var new_taxonomy = jQuery('[name="new_tax_text_' + taxonomy + '"]').val()
383
- , build_what = jQuery(button).data('build_what');
384
  new_taxonomy = new_taxonomy.trim();
385
 
386
  if (new_taxonomy == '') {
@@ -391,7 +392,7 @@ toolsetForms.CRED_taxonomy = function () {
391
  var exists = false;
392
  jQuery('input[name="' + taxonomy + '\[\]"]').each (function () {
393
  var id = jQuery(this).attr('id');
394
- var label = jQuery('label[for="' + id + '"]');
395
 
396
  if (new_taxonomy == label.text()) {
397
  exists = true
@@ -399,7 +400,7 @@ toolsetForms.CRED_taxonomy = function () {
399
  }
400
  });
401
 
402
- jQuery('select[name="' + taxonomy + '\[\]"]').find('option').each (function () {
403
  if (new_taxonomy == jQuery(this).text()) {
404
  exists = true;
405
  self._flash_it(jQuery(this));
@@ -407,20 +408,20 @@ toolsetForms.CRED_taxonomy = function () {
407
  });
408
 
409
  if (exists) {
410
- jQuery('[name="new_tax_text_' + taxonomy + '"]').val('');
411
  return;
412
  }
413
 
414
- var parent = jQuery('[name="new_tax_select_' + taxonomy + '"]').val(),
415
  add_position = null,
416
  add_before = true,
417
- div_fields_wrap = jQuery('div[data-item_name="taxonomyhierarchical-'+taxonomy+'"]'),
418
  level = 0;
419
 
420
  if ( build_what === 'checkboxes' ){
421
  //Fix add new leaf
422
  //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188589136/comments
423
- jQuery('div[data-item_name="taxonomyhierarchical-'+taxonomy+'"] li input[type=checkbox]').each(function() {
424
  if (this.value==parent || this.value==new_taxonomy) {
425
  div_fields_wrap = jQuery(this).parent();
426
  }
@@ -429,12 +430,12 @@ toolsetForms.CRED_taxonomy = function () {
429
 
430
  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>';
431
  // find the first checkbox sharing parent
432
- var first_checkbox = jQuery('input[name="' + taxonomy + '\[\]"][data-parent="' + parent + '"]:first');
433
  if (first_checkbox.length == 0) {
434
  // there are no existing brothers
435
  // so we need to compose the ul wrapper and append to the parent li
436
  //add_position = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]').closest('li');
437
- level = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]').closest('ul').data( 'level' );
438
  level++;
439
  new_checkbox = '<ul class="wpt-form-set-children" data-level="' + level + '">' + new_checkbox + '</ul>';
440
  //first_checkbox = ;
@@ -447,17 +448,17 @@ toolsetForms.CRED_taxonomy = function () {
447
  add_position = first_checkbox.closest('li');
448
  jQuery(new_checkbox).insertBefore(add_position);
449
  }
450
- jQuery('[name="new_tax_select_' + taxonomy + '"]').show();
451
  } else if( build_what === 'select' ) {
452
  // Select control
453
 
454
  jQuery('select[name="' + taxonomy + '\[\]"]').show();
455
 
456
  var indent = '';
457
- var first_option = jQuery('select[name="' + taxonomy + '\[\]"]').find('option[data-parent="' + parent + '"]:first');
458
  if (first_option.length == 0) {
459
  // there a no children of this parent
460
- first_option = jQuery('select[name="' + taxonomy + '\[\]"]').find('option[value="' + parent + '"]:first');
461
  add_before = false;
462
  var label = first_option.text();
463
  for (var i = 0; i < label.length; i++) {
@@ -469,8 +470,7 @@ toolsetForms.CRED_taxonomy = function () {
469
  }
470
  indent += '\xA0';
471
  indent += '\xA0';
472
- add_position = jQuery('select[name="' + taxonomy + '\[\]"]');
473
-
474
  } else {
475
  add_position = first_option;
476
  var label = first_option.text();
@@ -491,30 +491,26 @@ toolsetForms.CRED_taxonomy = function () {
491
  jQuery(new_option).appendTo(add_position);
492
  }
493
  }
494
- jQuery('[name="new_tax_select_' + taxonomy + '"]').show()
495
  }
496
 
 
497
 
498
-
499
-
500
- self._update_hierachy(taxonomy, new_taxonomy);
501
-
502
- jQuery('[name="new_tax_text_' + taxonomy + '"]').val('');
503
 
504
  self._fill_parent_drop_down();
505
 
506
-
507
  }
508
 
509
- self._update_hierachy = function (taxonomy, new_taxonomy) {
510
- var new_taxonomy_input = jQuery('input[name="' + taxonomy + '_hierarchy"]');
511
  if (!new_taxonomy_input.length) {
512
  // add a hidden field for the hierarchy
513
- jQuery('<input name="' + taxonomy + '_hierarchy" style="display:none" type="hidden">').insertAfter(jQuery('[name="new_tax_text_' + taxonomy + '"]'));
514
- new_taxonomy_input = jQuery('input[name="' + taxonomy + '_hierarchy"]');
515
  }
516
 
517
- var parent = jQuery('[name="new_tax_select_' + taxonomy + '"]').val();
518
  self._new_taxonomy.push(parent + ',' + new_taxonomy);
519
 
520
  var value = '';
69
  /**
70
  * flat taxonomies functions
71
  */
72
+ function showHideMostPopularButton(taxonomy, form)
73
  {
74
+ var $button = jQuery('[name="sh_' + 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
 
88
  }
89
 
90
  jQuery(document).on('click', '.js-wpt-taxonomy-popular-show-hide', function() {
91
+ showHideMostPopularTaxonomy(this);
92
  });
93
 
94
  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
  });
115
 
116
  function addTaxonomy(slug, 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() {
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
 
275
  self._initialize_taxonomy_buttons = 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);
282
+ var selectors = [];
283
 
284
  if (buttons.length) {
285
 
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 {
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
 
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 {
357
+ var first_option = jQuery('select[name="' + taxonomy + '\[\]"]', form).find('option[data-parent="' + parent + '"]:first');
 
 
358
  return first_option.length > 0;
359
  }
360
 
361
  return false;
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();
384
+ var build_what = jQuery(button).data('build_what');
385
  new_taxonomy = new_taxonomy.trim();
386
 
387
  if (new_taxonomy == '') {
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
 
397
  if (new_taxonomy == label.text()) {
398
  exists = true
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));
408
  });
409
 
410
  if (exists) {
411
+ jQuery('[name="new_tax_text_' + taxonomy + '"]', form).val('');
412
  return;
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
  }
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 = ;
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();
456
 
457
  var indent = '';
458
+ var first_option = jQuery('select[name="' + taxonomy + '\[\]"]').find('option[data-parent="' + parent + '"]:first', form);
459
  if (first_option.length == 0) {
460
  // there a no children of this parent
461
+ first_option = jQuery('select[name="' + taxonomy + '\[\]"]').find('option[value="' + parent + '"]:first', form);
462
  add_before = false;
463
  var label = first_option.text();
464
  for (var i = 0; i < label.length; i++) {
470
  }
471
  indent += '\xA0';
472
  indent += '\xA0';
473
+ add_position = jQuery('select[name="' + taxonomy + '\[\]"]', form);
 
474
  } else {
475
  add_position = first_option;
476
  var label = first_option.text();
491
  jQuery(new_option).appendTo(add_position);
492
  }
493
  }
494
+ jQuery('[name="new_tax_select_' + taxonomy + '"]', form).show()
495
  }
496
 
497
+ self._update_hierachy(taxonomy, new_taxonomy, form);
498
 
499
+ jQuery('[name="new_tax_text_' + taxonomy + '"]', form).val('');
 
 
 
 
500
 
501
  self._fill_parent_drop_down();
502
 
 
503
  }
504
 
505
+ self._update_hierachy = function (taxonomy, new_taxonomy, form) {
506
+ var new_taxonomy_input = jQuery('input[name="' + taxonomy + '_hierarchy"]', form);
507
  if (!new_taxonomy_input.length) {
508
  // add a hidden field for the hierarchy
509
+ jQuery('<input name="' + taxonomy + '_hierarchy" style="display:none" type="hidden">').insertAfter(jQuery('[name="new_tax_text_' + taxonomy + '"]', form));
510
+ new_taxonomy_input = jQuery('input[name="' + taxonomy + '_hierarchy"]', form);
511
  }
512
 
513
+ var parent = jQuery('[name="new_tax_select_' + taxonomy + '"]', form).val();
514
  self._new_taxonomy.push(parent + ',' + new_taxonomy);
515
 
516
  var value = '';
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.4/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.5/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/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.4/embedded/common/toolset-forms/js/validation.js $
11
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
12
- * $LastChangedRevision: 1027712 $
13
  * $LastChangedBy: iworks $
14
  *
15
  */
@@ -17,7 +17,7 @@
17
 
18
  var wptValidationForms = [];
19
  var wptValidation = (function($) {
20
- function init() {
21
  /**
22
  * add extension to validator method
23
  */
@@ -26,6 +26,13 @@ var wptValidation = (function($) {
26
  return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
27
  });
28
 
 
 
 
 
 
 
 
29
  /**
30
  * add extension to validator method require
31
  */
@@ -33,6 +40,7 @@ var wptValidation = (function($) {
33
  // check if dependency is met
34
  if ( !this.depend(param, element) )
35
  return "dependency-mismatch";
 
36
  switch( element.nodeName.toLowerCase() ) {
37
  case 'select':
38
  var val = $(element).val();
@@ -47,7 +55,19 @@ var wptValidation = (function($) {
47
  });
48
  //#########################################################################
49
  return val && $.trim(val).length > 0;
50
- case 'input':
 
 
 
 
 
 
 
 
 
 
 
 
51
  if ( this.checkable(element) )
52
  return this.getLength(value, element) > 0;
53
  default:
7
  *
8
  * @see class WPToolset_Validation
9
  *
10
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
 
18
  var wptValidationForms = [];
19
  var wptValidation = (function($) {
20
+ function init() {
21
  /**
22
  * add extension to validator method
23
  */
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
  */
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();
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
+ // }
66
+
67
+ if (jQuery(element).hasClass("hasDatepicker")) {
68
+ return false;
69
+ }
70
+
71
  if ( this.checkable(element) )
72
  return this.getLength(value, element) > 0;
73
  default:
embedded/common/toolset-forms/lib/CakePHP-Validation.php CHANGED
@@ -136,6 +136,17 @@ class WPToolset_Cake_Validation {
136
  return $_this->_check();
137
  }
138
 
 
 
 
 
 
 
 
 
 
 
 
139
  /**
140
  * Checks that a string contains only integer or letters
141
  *
@@ -760,7 +771,7 @@ class WPToolset_Cake_Validation {
760
  * @return boolean Succcess
761
  * @access public
762
  */
763
- function integer($check) {
764
  return is_int(intval($check));
765
  }
766
 
136
  return $_this->_check();
137
  }
138
 
139
+ /**
140
+ * Checks if a value is valid hexadecimal.
141
+ *
142
+ * @param string $check Value to check
143
+ * @return boolean Succcess
144
+ * @access public
145
+ */
146
+ function hexadecimal($check) {
147
+ return preg_match('/^#[a-f0-9]{6}$/i', $check);
148
+ }
149
+
150
  /**
151
  * Checks that a string contains only integer or letters
152
  *
771
  * @return boolean Succcess
772
  * @access public
773
  */
774
+ function integer($check) {
775
  return is_int(intval($check));
776
  }
777
 
embedded/common/toolset-forms/readme.txt CHANGED
@@ -30,6 +30,12 @@ function my_toolset_valid_image_extentions($valid_extensions)
30
 
31
  = Changelog =
32
 
 
 
 
 
 
 
33
  2014-11-13
34
 
35
  - Fixed a problem with missing taxonomies after form fail:
30
 
31
  = Changelog =
32
 
33
+ 2014-12-29
34
+
35
+ - fixed display CPT in CT
36
+
37
+ 2014-11-18 - plugins release - CRED 1.3.4, Types 1.6.4
38
+
39
  2014-11-13
40
 
41
  - Fixed a problem with missing taxonomies after form fail:
embedded/common/toolset-forms/templates/metaform-item.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
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.4/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.5/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/utility/css/notifications.css ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Globals */
2
+ .toolset-help,
3
+ .toolset-alert {
4
+ position: relative;
5
+ clear: both;
6
+ margin: 20px 0;
7
+ border: 1px solid;
8
+ -webkit-border-radius: 4px;
9
+ -moz-border-radius: 4px;
10
+ border-radius: 4px;
11
+ }
12
+
13
+ /* Validation messages */
14
+
15
+ .toolset-alert {
16
+ padding: 10px 20px 10px 10px;
17
+ border-color: #fbeed5;
18
+ background-color: #fcf8e3;
19
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
20
+ line-height: 1;
21
+ }
22
+
23
+ span.toolset-alert {
24
+ display: inline-block;
25
+ clear: none;
26
+ margin: 2px 1px;
27
+ padding: 4px 6px;
28
+ cursor: pointer;
29
+ }
30
+
31
+ .toolset-alert,
32
+ .toolset-alert .toolset-alert-header {
33
+ color: #c09853;
34
+ }
35
+
36
+ .toolset-alert .toolset-alert-header {
37
+ margin: 0;
38
+ }
39
+
40
+ .toolset-alert .toolset-alert-close {
41
+ position: absolute;
42
+ top: 9px;
43
+ right: 5px;
44
+ color: #999;
45
+ cursor:pointer;
46
+ }
47
+
48
+ .toolset-alert .button {
49
+ text-shadow: none;
50
+ }
51
+
52
+ .toolset-alert-success {
53
+ border-color: #d6e9c6;
54
+ background-color: #dff0d8;
55
+ color: #468847;
56
+ }
57
+
58
+ .toolset-alert-success .toolset-alert-header {
59
+ color: #468847;
60
+ }
61
+
62
+ .toolset-alert-error {
63
+ border-color: #eed3d7;
64
+ background-color: #f2dede;
65
+ color: #b94a48;
66
+ }
67
+
68
+ .toolset-alert-error .toolset-alert-header {
69
+ color: #b94a48;
70
+ }
71
+
72
+ .toolset-alert-info {
73
+ border-color: #bce8f1;
74
+ background-color: #d9edf7;
75
+ color: #3a87ad;
76
+ }
77
+
78
+ .toolset-alert-info .toolset-alert-header {
79
+ color: #3a87ad;
80
+ }
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 {
97
+ display: none;
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 {
107
+ display: inline-block;
108
+ line-height: 18px;
109
+ text-decoration: underline;
110
+ }
111
+ .toolset-help-content p,
112
+ .toolset-help-content ul,
113
+ .toolset-help-content ol {
114
+ line-height: 1.6;
115
+ }
116
+ .toolset-help-content ul,
117
+ .toolset-help-content ol {
118
+ margin-left: 0;
119
+ list-style-position: inside;
120
+ }
121
+ .toolset-help-content ul li {
122
+ list-style-type: disc;
123
+ }
124
+ .toolset-help-content ol li {
125
+ list-style-type: decimal;
126
+ }
127
+ .toolset-help-content p:first-child {
128
+ margin-top: 0;
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
+
178
+ .toolset-help-footer [class^="button-"] {
179
+ margin-left: 5px;
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 {
200
+ display: inline-block;
201
+ }
202
+
203
+ /* TOOLTIP */
204
+ .toolset-tooltip {
205
+ position: absolute;
206
+ z-index: 999;
207
+ display: inline-block;
208
+ display: none;
209
+ padding: 3px 6px;
210
+ max-width: 300px;
211
+ background: #000;
212
+ background: rgba(0,0,0,.8);
213
+ color: #fff;
214
+ text-align: center;
215
+ }
216
+
217
+ .toolset-tooltip:after {
218
+ position: absolute;
219
+ bottom: -5px;
220
+ left: 50%;
221
+ margin-left: -5px;
222
+ width: 0;
223
+ height: 0;
224
+ border-width: 5px 5px 0 5px;
225
+ border-style: solid;
226
+ border-color: rgba(0,0,0,.8) transparent transparent transparent;
227
+ content: '';
228
+ }
229
+
230
+ /*highlight search */
231
+ .highlighted {
232
+ font-weight:bold;
233
+
234
+ }
235
+
236
+ .highlighted {
237
+ padding:1px 4px;
238
+ margin:0 -4px;
239
+ }
240
+
241
+ /* ---------------- */
242
+ /* TOOLSET POINTERS */
243
+ /* ---------------- */
244
+
245
+ .wp-toolset-pointer .wp-pointer-content {
246
+ border: 1px solid #EF6223;
247
+ background: #e9e9e9;
248
+ box-shadow: 0 0 5px #666;
249
+ }
250
+
251
+ .wp-toolset-pointer .wp-pointer-content h3 {
252
+ margin: 0 0 5px;
253
+ background: #ed8027;
254
+ border: none;
255
+ border-bottom: 1px solid #EF6223;
256
+ }
257
+
258
+ .wp-toolset-pointer .wp-pointer-content h3:before {
259
+ color: #ed8027;
260
+ content: "\f11a";
261
+ font-family: "onthegosystems-icons";
262
+ font: 28px/1.1;
263
+ border-radius: 5px;
264
+ }
265
+
266
+ .wp-toolset-pointer.wp-toolset-types-pointer .wp-pointer-content h3:before {
267
+ content: "\f11c";
268
+ }
269
+
270
+ .wp-toolset-pointer.wp-toolset-views-pointer .wp-pointer-content h3:before {
271
+ content: "\f11e";
272
+ }
273
+
274
+ .wp-toolset-pointer.wp-toolset-cred-pointer .wp-pointer-content h3:before {
275
+ content: "\f115";
276
+ }
277
+
278
+ .wp-toolset-pointer.wp-toolset-access-pointer .wp-pointer-content h3:before {
279
+ content: "\f111";
280
+ }
281
+
282
+ .wp-toolset-pointer.wp-toolset-layouts-pointer .wp-pointer-content h3:before {
283
+ content: "\f117";
284
+ }
285
+
286
+ .wp-toolset-pointer.wp-toolset-module-pointer .wp-pointer-content h3:before {
287
+ content: "\f119";
288
+ }
289
+
290
+ .wp-toolset-pointer.wp-toolset-bootstrap-pointer .wp-pointer-content h3:before {
291
+ content: "\f113";
292
+ }
293
+
294
+ .wp-toolset-pointer.wp-toolset-wpml-pointer .wp-pointer-content h3:before {
295
+ content: "\f11f";
296
+ }
297
+
298
+ .wp-toolset-pointer .wp-pointer-buttons {
299
+
300
+ }
301
+
302
+ .wp-toolset-pointer .wp-pointer-buttons button.alignright {
303
+ margin: 0 0 0 10px;
304
+ }
305
+
306
+ .wp-toolset-pointer .wp-pointer-buttons button.alignleft {
307
+ margin: 0 10px 0 0;
308
+ }
309
+
310
+ .wp-toolset-pointer.wp-pointer-top .wp-pointer-arrow-inner {
311
+ top: 2px;
312
+ border-color: transparent transparent #ed8027;
313
+ }
314
+
315
+ .wp-toolset-pointer.wp-pointer-top .wp-pointer-arrow {
316
+ border-bottom-color: #EF6223;
317
+ }
318
+
319
+ .wp-toolset-pointer.wp-pointer-right .wp-pointer-arrow-inner {
320
+ right: 2px;
321
+ border-color: transparent transparent transparent #e9e9e9;
322
+ }
323
+
324
+ .wp-toolset-pointer.wp-pointer-right .wp-pointer-arrow {
325
+ border-left-color: #EF6223;
326
+ }
327
+
328
+ .wp-toolset-pointer.wp-pointer-bottom .wp-pointer-arrow-inner {
329
+ bottom: 2px;
330
+ border-color: #e9e9e9 transparent transparent;
331
+ }
332
+
333
+ .wp-toolset-pointer.wp-pointer-bottom .wp-pointer-arrow {
334
+ border-top-color: #EF6223;
335
+ }
336
+
337
+ .wp-toolset-pointer.wp-pointer-left .wp-pointer-arrow-inner {
338
+ left: 2px;
339
+ border-color: transparent #e9e9e9 transparent transparent;
340
+ }
341
+
342
+ .wp-toolset-pointer.wp-pointer-left .wp-pointer-arrow {
343
+ border-right-color: #EF6223;
344
+ }
embedded/common/utility/css/select2/select2-overrides.css ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* These are overrides to get the select2 to behave how we
2
+ * want in the css editor
3
+ */
4
+
5
+ .select2-drop-mask {
6
+
7
+ z-index: 19998;
8
+ }
9
+
10
+ .select2-drop {
11
+ z-index: 19999;
12
+ }
13
+
14
+
15
+ .select2-search {
16
+ z-index: 20000;
17
+ }
18
+
19
+ .select2-results li {
20
+ margin-bottom: 0px !important;
21
+ }
22
+
23
+ .select2-results {
24
+ padding-left: 0px !important;
25
+ }
26
+
embedded/common/utility/css/select2/select2-spinner.gif ADDED
Binary file
embedded/common/utility/css/select2/select2.css ADDED
@@ -0,0 +1,611 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
3
+ */
4
+ .select2-container {
5
+ margin: 0;
6
+ position: relative;
7
+ display: inline-block;
8
+ /* inline-block for ie7 */
9
+ zoom: 1;
10
+ *display: inline;
11
+ vertical-align: middle;
12
+ }
13
+
14
+ .select2-container,
15
+ .select2-drop,
16
+ .select2-search,
17
+ .select2-search input {
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 */
25
+ -moz-box-sizing: border-box; /* firefox */
26
+ box-sizing: border-box; /* css3 */
27
+ }
28
+
29
+ .select2-container .select2-choice {
30
+ display: block;
31
+ height: 26px;
32
+ padding: 0 0 0 8px;
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;
45
+ -webkit-user-select: none;
46
+ -moz-user-select: none;
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 {
70
+ margin-right: 42px;
71
+ }
72
+
73
+ .select2-container .select2-choice > .select2-chosen {
74
+ margin-right: 26px;
75
+ display: block;
76
+ overflow: hidden;
77
+
78
+ white-space: nowrap;
79
+ text-overflow: ellipsis;
80
+ }
81
+
82
+ .select2-container .select2-choice abbr {
83
+ display: none;
84
+ width: 12px;
85
+ height: 12px;
86
+ position: absolute;
87
+ right: 24px;
88
+ top: 8px;
89
+
90
+ font-size: 1px;
91
+ text-decoration: none;
92
+
93
+ border: 0;
94
+ background: url('select2.png') right top no-repeat;
95
+ cursor: pointer;
96
+ outline: 0;
97
+ }
98
+
99
+ .select2-container.select2-allowclear .select2-choice abbr {
100
+ display: inline-block;
101
+ }
102
+
103
+ .select2-container .select2-choice abbr:hover {
104
+ background-position: right -11px;
105
+ cursor: pointer;
106
+ }
107
+
108
+ .select2-drop-mask {
109
+ border: 0;
110
+ margin: 0;
111
+ padding: 0;
112
+ position: fixed;
113
+ left: 0;
114
+ top: 0;
115
+ min-height: 100%;
116
+ min-width: 100%;
117
+ height: auto;
118
+ width: auto;
119
+ opacity: 0;
120
+ z-index: 9998;
121
+ /* styles required for IE to work */
122
+ background-color: #fff;
123
+ filter: alpha(opacity=0);
124
+ }
125
+
126
+ .select2-drop {
127
+ width: 100%;
128
+ margin-top: -1px;
129
+ position: absolute;
130
+ z-index: 9999;
131
+ top: 100%;
132
+
133
+ background: #fff;
134
+ color: #000;
135
+ border: 1px solid #aaa;
136
+ border-top: 0;
137
+
138
+ border-radius: 0 0 4px 4px;
139
+
140
+ -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
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;
156
+ border-bottom: 0;
157
+
158
+ border-radius: 4px 4px 0 0;
159
+
160
+ -webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
161
+ box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
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 {
174
+ display: inline-block;
175
+ width: 18px;
176
+ height: 100%;
177
+ position: absolute;
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
+
186
+ background: #ccc;
187
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
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 {
195
+ display: block;
196
+ width: 100%;
197
+ height: 100%;
198
+ background: url('select2.png') no-repeat 0 1px;
199
+ }
200
+
201
+ .select2-search {
202
+ display: inline-block;
203
+ width: 100%;
204
+ min-height: 26px;
205
+ margin: 0;
206
+ padding-left: 4px;
207
+ padding-right: 4px;
208
+
209
+ position: relative;
210
+ z-index: 10000;
211
+
212
+ white-space: nowrap;
213
+ }
214
+
215
+ .select2-search input {
216
+ width: 100%;
217
+ height: auto !important;
218
+ min-height: 26px;
219
+ padding: 4px 20px 4px 5px;
220
+ margin: 0;
221
+
222
+ outline: 0;
223
+ font-family: sans-serif;
224
+ font-size: 1em;
225
+
226
+ border: 1px solid #aaa;
227
+ border-radius: 0;
228
+
229
+ -webkit-box-shadow: none;
230
+ box-shadow: none;
231
+
232
+ background: #fff url('select2.png') no-repeat 100% -22px;
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 {
240
+ margin-top: 4px;
241
+ }
242
+
243
+ .select2-search input.select2-active {
244
+ background: #fff url('select2-spinner.gif') no-repeat 100%;
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);
257
+ box-shadow: 0 0 5px rgba(0, 0, 0, .3);
258
+ }
259
+
260
+ .select2-dropdown-open .select2-choice {
261
+ border-bottom-color: transparent;
262
+ -webkit-box-shadow: 0 1px 0 #fff inset;
263
+ box-shadow: 0 1px 0 #fff inset;
264
+
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 {
289
+ background: transparent;
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;
300
+ padding: 0 0 0 4px;
301
+ margin: 4px 4px 4px 0;
302
+ position: relative;
303
+ overflow-x: hidden;
304
+ overflow-y: auto;
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;
324
+ background-image: none;
325
+ }
326
+
327
+ .select2-results li.select2-result-with-children > .select2-result-label {
328
+ font-weight: bold;
329
+ }
330
+
331
+ .select2-results .select2-result-label {
332
+ padding: 3px 7px 4px;
333
+ margin: 0;
334
+ cursor: pointer;
335
+
336
+ min-height: 1em;
337
+
338
+ -webkit-touch-callout: none;
339
+ -webkit-user-select: none;
340
+ -moz-user-select: none;
341
+ -ms-user-select: none;
342
+ user-select: none;
343
+ }
344
+
345
+ .select2-results .select2-highlighted {
346
+ background: #3875d7;
347
+ color: #fff;
348
+ }
349
+
350
+ .select2-results li em {
351
+ background: #feffde;
352
+ font-style: normal;
353
+ }
354
+
355
+ .select2-results .select2-highlighted em {
356
+ background: transparent;
357
+ }
358
+
359
+ .select2-results .select2-highlighted ul {
360
+ background: #fff;
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
+ /*
373
+ disabled look for disabled choices in the results dropdown
374
+ */
375
+ .select2-results .select2-disabled.select2-highlighted {
376
+ color: #666;
377
+ background: #f4f4f4;
378
+ display: list-item;
379
+ cursor: default;
380
+ }
381
+ .select2-results .select2-disabled {
382
+ background: #f4f4f4;
383
+ display: list-item;
384
+ cursor: default;
385
+ }
386
+
387
+ .select2-results .select2-selected {
388
+ display: none;
389
+ }
390
+
391
+ .select2-more-results.select2-active {
392
+ background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%;
393
+ }
394
+
395
+ .select2-more-results {
396
+ background: #f4f4f4;
397
+ display: list-item;
398
+ }
399
+
400
+ /* disabled styles */
401
+
402
+ .select2-container.select2-container-disabled .select2-choice {
403
+ background-color: #f4f4f4;
404
+ background-image: none;
405
+ border: 1px solid #ddd;
406
+ cursor: default;
407
+ }
408
+
409
+ .select2-container.select2-container-disabled .select2-choice .select2-arrow {
410
+ background-color: #f4f4f4;
411
+ background-image: none;
412
+ border-left: 0;
413
+ }
414
+
415
+ .select2-container.select2-container-disabled .select2-choice abbr {
416
+ display: none;
417
+ }
418
+
419
+
420
+ /* multiselect */
421
+
422
+ .select2-container-multi .select2-choices {
423
+ height: auto !important;
424
+ height: 1%;
425
+ margin: 0;
426
+ padding: 0;
427
+ position: relative;
428
+
429
+ border: 1px solid #aaa;
430
+ cursor: text;
431
+ overflow: hidden;
432
+
433
+ background-color: #fff;
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 {
441
+ padding: 3px 5px 3px 5px !important;
442
+ }
443
+
444
+ .select2-container-multi .select2-choices {
445
+ min-height: 26px;
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);
453
+ box-shadow: 0 0 5px rgba(0, 0, 0, .3);
454
+ }
455
+ .select2-container-multi .select2-choices li {
456
+ float: left;
457
+ list-style: none;
458
+ }
459
+ .select2-container-multi .select2-choices .select2-search-field {
460
+ margin: 0;
461
+ padding: 0;
462
+ white-space: nowrap;
463
+ }
464
+
465
+ .select2-container-multi .select2-choices .select2-search-field input {
466
+ padding: 5px;
467
+ margin: 1px 0;
468
+
469
+ font-family: sans-serif;
470
+ font-size: 100%;
471
+ color: #666;
472
+ outline: 0;
473
+ border: 0;
474
+ -webkit-box-shadow: none;
475
+ box-shadow: none;
476
+ background: transparent !important;
477
+ }
478
+
479
+ .select2-container-multi .select2-choices .select2-search-field input.select2-active {
480
+ background: #fff url('select2-spinner.gif') no-repeat 100% !important;
481
+ }
482
+
483
+ .select2-default {
484
+ color: #999 !important;
485
+ }
486
+
487
+ .select2-container-multi .select2-choices .select2-search-choice {
488
+ padding: 3px 5px 3px 18px;
489
+ margin: 3px 0 3px 5px;
490
+ position: relative;
491
+
492
+ line-height: 13px;
493
+ color: #333;
494
+ cursor: default;
495
+ border: 1px solid #aaaaaa;
496
+
497
+ border-radius: 3px;
498
+
499
+ -webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
500
+ box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
501
+
502
+ background-clip: padding-box;
503
+
504
+ -webkit-touch-callout: none;
505
+ -webkit-user-select: none;
506
+ -moz-user-select: none;
507
+ -ms-user-select: none;
508
+ user-select: none;
509
+
510
+ background-color: #e4e4e4;
511
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0);
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;
519
+ }
520
+ .select2-container-multi .select2-choices .select2-search-choice-focus {
521
+ background: #d4d4d4;
522
+ }
523
+
524
+ .select2-search-choice-close {
525
+ display: block;
526
+ width: 12px;
527
+ height: 13px;
528
+ position: absolute;
529
+ right: 3px;
530
+ top: 4px;
531
+
532
+ font-size: 1px;
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
+ }
544
+ .select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close {
545
+ background-position: right -11px;
546
+ }
547
+
548
+ /* disabled styles */
549
+ .select2-container-multi.select2-container-disabled .select2-choices {
550
+ background-color: #f4f4f4;
551
+ background-image: none;
552
+ border: 1px solid #ddd;
553
+ cursor: default;
554
+ }
555
+
556
+ .select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice {
557
+ padding: 3px 5px 3px 5px;
558
+ border: 1px solid #ddd;
559
+ background-image: none;
560
+ background-color: #f4f4f4;
561
+ }
562
+
563
+ .select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none;
564
+ background: none;
565
+ }
566
+ /* end multiselect */
567
+
568
+
569
+ .select2-result-selectable .select2-match,
570
+ .select2-result-unselectable .select2-match {
571
+ text-decoration: underline;
572
+ }
573
+
574
+ .select2-offscreen, .select2-offscreen:focus {
575
+ clip: rect(0 0 0 0) !important;
576
+ width: 1px !important;
577
+ height: 1px !important;
578
+ border: 0 !important;
579
+ margin: 0 !important;
580
+ padding: 0 !important;
581
+ overflow: hidden !important;
582
+ position: absolute !important;
583
+ outline: 0 !important;
584
+ left: 0px !important;
585
+ top: 0px !important;
586
+ }
587
+
588
+ .select2-display-none {
589
+ display: none;
590
+ }
591
+
592
+ .select2-measure-scrollbar {
593
+ position: absolute;
594
+ top: -10000px;
595
+ left: -10000px;
596
+ width: 100px;
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
+ }
embedded/common/utility/css/select2/select2.png ADDED
Binary file
embedded/common/utility/css/select2/select2x2.png ADDED
Binary file
embedded/common/utility/img/icon-help-message.png ADDED
Binary file
embedded/common/utility/js/select2.min.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
8
+ use of this software only upon the condition that you accept all of the terms of either the Apache
9
+ License or the GPL License.
10
+
11
+ You may obtain a copy of the Apache License and the GPL License at:
12
+
13
+ http://www.apache.org/licenses/LICENSE-2.0
14
+ http://www.gnu.org/licenses/gpl-2.0.html
15
+
16
+ Unless required by applicable law or agreed to in writing, software distributed under the Apache License
17
+ or the GPL Licesnse is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
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);
embedded/common/utility/js/utils.js ADDED
@@ -0,0 +1,946 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ if( typeof WPV_Toolset == 'undefined' )
2
+ {
3
+ var WPV_Toolset = {};
4
+ WPV_Toolset.message = {};
5
+ WPV_Toolset.message.container = null;
6
+ }
7
+
8
+ if( typeof WPV_Toolset.Utils == 'undefined' ) WPV_Toolset.Utils = {};
9
+
10
+ WPV_Toolset.Utils.eventDispatcher = _.extend({}, Backbone.Events);
11
+
12
+ WPV_Toolset.Utils.do_ajax_post = function( params, callback_object )
13
+ {
14
+ jQuery.post(ajaxurl, params, function (response) {
15
+
16
+ if ( (typeof(response) !== 'undefined') && response !== null && ( response.message || response.Data ) ) {
17
+
18
+ if( callback_object && callback_object.success && typeof callback_object.success == 'function' )
19
+ callback_object.success.call( this, response, params );
20
+ WPV_Toolset.Utils.eventDispatcher.trigger('on_ajax_success_'+params.action, response, params);
21
+ }
22
+ else if( (typeof(response) !== 'undefined') && response !== null && response.error )
23
+ {
24
+
25
+ if( callback_object && callback_object.error && typeof callback_object.error == 'function' )
26
+ callback_object.error.call(this);
27
+ WPV_Toolset.Utils.eventDispatcher.trigger('on_ajax_error_'+params.action, response, params);
28
+ }
29
+ }, 'json')
30
+ .fail(function (jqXHR, textStatus, errorThrown) {
31
+ console.log('Ajax call failed', textStatus, errorThrown)
32
+ if( callback_object && callback_object.fail && typeof callback_object.fail == 'function' )
33
+ callback_object.fail.call(this, errorThrown);
34
+ WPV_Toolset.Utils.eventDispatcher.trigger('on_ajax_fail_'+params.action, textStatus, errorThrown, params );
35
+ })
36
+ .always(function () {
37
+ //console.log( arguments );
38
+ WPV_Toolset.Utils.eventDispatcher.trigger('on_ajax_complete_'+params.action, arguments, params);
39
+ });
40
+ };
41
+
42
+ ;(function ( $, window, document, undefined ) {
43
+
44
+ // Create the defaults once
45
+ var pluginName = "wpvToolsetMessage",
46
+ dataPlugin = "plugin_" + pluginName,
47
+ defaults = {
48
+ text : "Enter a customized text to be displayed",
49
+ type: '',
50
+ inline: false,
51
+ position : "after",
52
+ header: false,
53
+ headerText: false,
54
+ close: false,
55
+ use_this: true,
56
+ fadeIn: 100,
57
+ fadeOut: 100,
58
+ stay: false,
59
+ onClose: false,
60
+ onOpen: false,
61
+ onDestroy:false,
62
+ args:[],
63
+ referTo: null,
64
+ offestX: -20,
65
+ offsetY: 0,
66
+ classname: '',
67
+ stay_for: 1200, // Ignored when 'msPerCharacter is given.
68
+ msPerCharacter: 50 // Ignered when 'stay_for' is given. This value is multiplied by the number of defaults.text characters count.
69
+ },
70
+ has_stay = false,
71
+ is_open = false,
72
+ prev = null,
73
+ prev_text = '';
74
+
75
+ // The actual plugin constructor
76
+ function Plugin(element, options) {
77
+ var self = this;
78
+
79
+ self.container = $(element);
80
+
81
+ self.prms = $.extend({}, defaults, options);
82
+ self._defaults = defaults;
83
+ self._name = pluginName;
84
+
85
+ self.box = null;
86
+ self.header = null;
87
+ self.remove = null;
88
+ self.tag = self.prms.inline ? 'span' : 'p';
89
+ self.bool = false;
90
+
91
+ if ( typeof (options.stay_for) === 'undefined' && typeof(self.prms.msPerCharacter) === 'number' ) { // If stay_for parameter wasn't passes when the plugin wass called AND msPerCharacter has correct type
92
+ self.prms.stay_for = self.prms.text.length * self.prms.msPerCharacter;
93
+ }
94
+
95
+ }
96
+
97
+ Plugin.prototype = {
98
+ init: function () {
99
+ var self = this;
100
+
101
+ if( self.container.data('has_message' ) )
102
+ {
103
+ self.destroy();
104
+ }
105
+
106
+ if( self.container.children().length > 0 )
107
+ {
108
+ self.container.children().each(function(i){
109
+ if( $(this).text() == self.prms.text )
110
+ {
111
+ self.bool = true;
112
+ }
113
+ });
114
+ }
115
+
116
+ if( self.bool ) return;
117
+
118
+ if( has_stay )
119
+ {
120
+ if( prev )
121
+ {
122
+ var rem = prev;
123
+ prev = null;
124
+ has_stay = false;
125
+ is_open = false;
126
+ rem.fadeTo( 0, 0, function(){
127
+ rem.remove();
128
+ rem = null;
129
+ });
130
+ }
131
+ }
132
+
133
+ if( self.prms.header && self.prms.headerText )
134
+ {
135
+ self.box = $('<div class="toolset-alert toolset-alert-'+self.prms.type+' '+self.prms.classname+'" />');
136
+ self.header = $('<h2 class="toolset-alert-self.header" />');
137
+ self.box.append(self.header);
138
+ self.header.text(self.prms.headerText);
139
+ self.box.append('<'+self.tag+'></'+self.tag+'>');
140
+ self.box.find(self.tag).html( self.prms.text );
141
+ }
142
+ else
143
+ {
144
+ self.box = $('<'+self.tag+' class="toolset-alert toolset-alert-'+self.prms.type+' '+self.prms.classname+'" />');
145
+ self.box.html( self.prms.text );
146
+ }
147
+
148
+ if( self.prms.close ){
149
+ self.remove = $('<i class="toolset-alert-close icon-remove-sign js-icon-remove-sign"></i>');
150
+ self.box.append( self.remove );
151
+ self.remove.on('click', function(event){
152
+ self.wpvMessageRemove();
153
+ });
154
+ }
155
+
156
+
157
+ //if( is_open ) self.wpvMessageRemove();
158
+ if ( self.prms.position == 'before' ) {
159
+ self.container.prepend( self.box );
160
+ } else {
161
+ self.container.append( self.box );
162
+ }
163
+ self.container.data('has_message', true );
164
+ self.box.hide();
165
+
166
+ if( null !== self.prms.referTo )
167
+ {
168
+ self.box.css({
169
+ "position":"absolute",
170
+ "z-index":10000,
171
+ "top": self.prms.referTo.position().top + self.prms.offestY + "px",
172
+ "left": self.prms.referTo.position().left + self.prms.referTo.width() + self.prms.offestX + "px"
173
+ });
174
+ }
175
+
176
+ self.container.data( 'message-box', self.box );
177
+
178
+ self.box.fadeTo( null != prev ? 0 : self.prms.fadeIn, 1, function(){
179
+ $(this).trigger('wpv-message-open');
180
+ prev = $(this);
181
+ prev_text = self.prms.text;
182
+ is_open = true;
183
+ if( self.prms.onOpen && typeof self.prms.onOpen == 'function' )
184
+ {
185
+ self.prms.onOpen.apply( self, self.prms.args );
186
+ }
187
+ if( self.prms.stay ){
188
+ has_stay = true;
189
+ }
190
+ else
191
+ {
192
+ var remove_message = _.bind(self.wpvMessageRemove, self);
193
+ _.delay( remove_message, self.prms.stay_for );
194
+ //self.wpvMessageRemove();
195
+ }
196
+ });
197
+
198
+ return self;
199
+ },
200
+ wpvMessageRemove: function () {
201
+
202
+ var self = this;
203
+
204
+ if( self.box || self.container.data( 'message-box') )
205
+ {
206
+ var box = self.box || self.container.data( 'message-box');
207
+
208
+ box.fadeTo( self.prms.fadeOut, 0, function(){
209
+ $(this).trigger('wpv-message-remove');
210
+ is_open = false;
211
+ prev = null;
212
+ prev_text = '';
213
+ has_stay = false;
214
+ if( self.prms.onClose && typeof self.prms.onClose == 'function' )
215
+ {
216
+ self.prms.onClose.apply( self, self.prms.args );
217
+ }
218
+
219
+ $( this ).remove();
220
+ self.container.data('has_message', false );
221
+ self.container.data( 'message-box', null );
222
+ self.box = null;
223
+ });
224
+ }
225
+
226
+ return self;
227
+ },
228
+ destroy:function()
229
+ {
230
+ $(this).trigger('wpv-message-remove');
231
+ this.container.empty();
232
+ if( this.prms.onDestroy && typeof this.prms.onDestroy == 'function' )
233
+ {
234
+ this.prms.onDestroy.apply( this, this.prms.args );
235
+ }
236
+ this.box = null;
237
+ this.container.data( 'message-box', null );
238
+ this.container.data('has_message', false );
239
+ },
240
+ has_message:function(){
241
+ return this.container.data('has_message');
242
+ }
243
+ };
244
+
245
+
246
+ $.fn[ pluginName ] = function ( arg ) {
247
+
248
+ return this.each(function(){
249
+ var args, instance;
250
+
251
+ if ( !( $(this).data( dataPlugin ) instanceof Plugin ) ) {
252
+ // if no instance, create one
253
+ $(this).data( dataPlugin, new Plugin( $(this), arg ) );
254
+ }
255
+ // do not use this one if you want the plugin to be a singleton bound to the DOM element
256
+ else
257
+ {
258
+ // if instance delete reference and do another one
259
+ $(this).data( dataPlugin, null );
260
+ $(this).data( dataPlugin, new Plugin( $(this), arg ) );
261
+ }
262
+
263
+ instance = $(this).data( dataPlugin );
264
+
265
+ instance.element = $(this);
266
+
267
+ // call Plugin.init( arg )
268
+ if (typeof arg === 'undefined' || typeof arg === 'object') {
269
+
270
+ if ( typeof instance['init'] === 'function' ) {
271
+ instance.init( arg );
272
+ }
273
+
274
+ // checks that the requested public method exists
275
+ } else if ( typeof arg === 'string' && typeof instance[arg] === 'function' ) {
276
+
277
+ // copy arguments & remove function name
278
+ args = Array.prototype.slice.call( arguments, 1 );
279
+
280
+ // call the method
281
+ return instance[arg].apply( instance, args );
282
+
283
+ } else {
284
+
285
+ $.error('Method ' + arg + ' does not exist on jQuery.' + pluginName);
286
+
287
+ }
288
+ });
289
+ };
290
+ })( jQuery, window, document );
291
+
292
+ (function ($) {
293
+ $.fn.insertAtIndex = function(index,selector){
294
+ var opts = $.extend({
295
+ index: 0,
296
+ selector: '<div/>'
297
+ }, {index: index, selector: selector});
298
+ return this.each(function() {
299
+ var p = $(this);
300
+ var i = ($.isNumeric(opts.index) ? parseInt(opts.index,10) : 0);
301
+ if (i <= 0)
302
+ p.prepend(opts.selector);
303
+ else if( i > p.children().length-1 )
304
+ p.append(opts.selector);
305
+ else
306
+ p.children().eq(i).before(opts.selector);
307
+ });
308
+ };
309
+ })( jQuery );
310
+
311
+ (function ($) {
312
+
313
+ $.fn.loaderOverlay = function( action,options )
314
+ // action: 'show'|'hide' attributes are optional.
315
+ // options: fadeInSpeed, fadeOutSpeed, displayOverlay, class. attributes are optional
316
+ {
317
+
318
+ var defaults = {
319
+ fadeInSpeed : 'fast',
320
+ fadeOutSpeed : 'fast',
321
+ displayLoader: true,
322
+ class: null
323
+ };
324
+
325
+ var prms = $.extend( defaults, options );
326
+ var $overlayContainer = this;
327
+ var $overlayEl = $('<div class="loader-overlay" />');
328
+
329
+ var showOverlay = function() {
330
+ if ( ! $overlayContainer.data('has-overlay') ) {
331
+ $overlayEl
332
+ .appendTo($overlayContainer)
333
+ .hide()
334
+ .fadeIn(prms.fadeInSpeed, function() {
335
+ $overlayContainer.data('has-overlay', true);
336
+ $overlayContainer.data('overlay-el', $overlayEl);
337
+ } );
338
+ }
339
+ };
340
+
341
+ var hideOverlay = function() {
342
+ if ( $overlayContainer.data('has-overlay') ) {
343
+ $overlayContainer.data('overlay-el')
344
+ .fadeOut(prms.fadeOutSpeed, function() {
345
+ $overlayEl.remove();
346
+ $overlayContainer.data('has-overlay', false);
347
+ } );
348
+ }
349
+ };
350
+
351
+ if ( prms.class !== null ) {
352
+ $overlayEl.addClass(prms.class);
353
+ }
354
+ if ( prms.displayLoader ) {
355
+ $('<div class="preloader" />').appendTo($overlayEl);
356
+ }
357
+
358
+ if ( typeof(action) !== 'undefined' ) { // When 'action' parameter is given
359
+
360
+ if ( action === 'show' ) {
361
+ showOverlay();
362
+ }
363
+ else if ( action === 'hide' ) {
364
+ hideOverlay();
365
+ }
366
+
367
+ }
368
+ else { // when the method is called without 'action' parameter
369
+
370
+ if ( $overlayContainer.data('has-overlay') ) { // hide overlay if it's displayed
371
+ hideOverlay();
372
+ }
373
+ else { // show overlay if not
374
+ showOverlay();
375
+ }
376
+
377
+ }
378
+
379
+ return this;
380
+ };
381
+
382
+ })( jQuery );
383
+
384
+ (function ($) {
385
+ /*
386
+ Basic usage:
387
+ $element.ddlWpPointer(); // will show a pointer if it's hidden OR hide a pointer if it's shown
388
+
389
+ 1. $element have to be valid jQuery selector
390
+ 2. data-toolipt-header HTML attribute is required to display the header
391
+ 3. data-tooltip-content HTML attribute is required to display the content
392
+
393
+ Customization:
394
+ $element.ddlWpPointer('action', // action: 'show' | 'hide'
395
+ {
396
+ content: $element // $element have to be valid jQuery selector content element should contain H3 for the header and P for the content. Example: <div><h3>Header</h3><p>Content</p></div>
397
+ edge: 'left' // 'left' | 'right' | 'top' | 'bottom'
398
+ align: 'center' // 'center' | 'right' | 'left'
399
+ offset: 'x y' // example: '0 15'
400
+ })
401
+
402
+ */
403
+ $.fn.ddlWpPointer = function( action, options )
404
+ {
405
+ var $el = this;
406
+
407
+ //$.jStorage.flush();
408
+
409
+ var defaults = {
410
+ headerText: function() {
411
+ var header = $el.data('tooltip-header');
412
+ if ( header ) {
413
+ return header;
414
+ }
415
+ else {
416
+ return 'use <b>data-tooltip-header="header text"</b> attribute to create a header';
417
+ }
418
+ },
419
+ contentText : function() {
420
+ var content = $el.data('tooltip-content');
421
+ if ( content ) {
422
+ return content;
423
+ }
424
+ else {
425
+ return 'use <b>data-tooltip-content="content text"</b> attribute to create a content';
426
+ }
427
+ },
428
+ content: function() { // returns string by default (data-tooltip-header and data-tooltip-content attibutes), but can be overridden by jQuery obj
429
+ return '<h3>'+ defaults.headerText() +'</h3><p>'+ defaults.contentText() +'</p>';
430
+ },
431
+ edge : 'left',
432
+ align : 'center',
433
+ offset: '0 0',
434
+ stay_hidden: false
435
+ };
436
+
437
+ var prms = $.extend( defaults, options );
438
+
439
+ var showPointer = function() {
440
+
441
+ if ( ! $el.data('has-wppointer') ) {
442
+ $el
443
+ .pointer({
444
+ content: function() {
445
+ return prms.content;
446
+ },
447
+ position: {
448
+ edge: prms.edge,
449
+ align: prms.align,
450
+ offset: prms.offset
451
+ },
452
+ close: function() {
453
+
454
+ $el.data('has-wppointer', false);
455
+ $el.trigger('help_tooltip_closes', options );
456
+ }
457
+ })
458
+ .pointer('open');
459
+
460
+ $el.data('has-wppointer', true);
461
+ }
462
+ };
463
+
464
+ var hidePointer = function() {
465
+
466
+ if ( $el.data('has-wppointer') ) {
467
+
468
+ $el.pointer('close');
469
+ $el.data('has-wppointer', false);
470
+
471
+ }
472
+
473
+ };
474
+
475
+ if ( typeof(action) !== 'undefined' ) { // When 'action' parameter is given
476
+
477
+ if ( action === 'show' && prms.stay_hidden !== true ) {
478
+ showPointer();
479
+ }
480
+ else if ( action === 'hide' ) {
481
+ hidePointer();
482
+ }
483
+
484
+ }
485
+ else { // when the method is called without 'action' parameter
486
+
487
+ if ( $el.data('has-wppointer') ) { // hide pointer if it's displayed
488
+ hidePointer();
489
+ }
490
+ else if( prms.stay_hidden !== true ) { // show it if not
491
+ showPointer();
492
+ }
493
+
494
+ }
495
+
496
+ return this;
497
+ };
498
+
499
+ })( jQuery );
500
+
501
+ WPV_Toolset.Utils.Loader = function()
502
+ {
503
+ //fake comment
504
+ var self = this;
505
+
506
+ self.loading = false; self.el = null;
507
+
508
+ self.loader = jQuery('<div class="ajax-loader spinner"></div>');
509
+
510
+ self.loadShow = function( el, after )
511
+ {
512
+ self.el = el;
513
+ self.loading = true;
514
+
515
+ if( typeof after === 'undefined' )
516
+ {
517
+ self.loader.prependTo( self.el ).show();
518
+ }
519
+ else{
520
+ self.loader.insertAfter( self.el ).show();
521
+ }
522
+
523
+ return self.loader;
524
+ };
525
+ self.loadHide = function()
526
+ {
527
+ self.loader.fadeOut(400, function(){
528
+
529
+ self.loading = false;
530
+ jQuery(this).remove();
531
+ });
532
+
533
+ return self.loader;
534
+ };
535
+ };
536
+
537
+ if( typeof _ != 'undefined' )
538
+ {
539
+ WPV_Toolset.Utils.flatten = function(x, result, prefix) {
540
+ if(_.isObject(x)) {
541
+ _.each(x, function(v, k) {
542
+ WPV_Toolset.Utils.flatten(v, result, prefix ? prefix + '_' + k : k)
543
+ })
544
+ } else {
545
+ result[prefix] = x
546
+ }
547
+ return result
548
+ };
549
+ WPV_Toolset.Utils.flatten_filter_by_key = function( x, result, prefix, filter )
550
+ {
551
+ var res = [],
552
+ find = WPV_Toolset.Utils.flatten( x, result, prefix );
553
+
554
+ if ( !filter ) return _.values( find );
555
+
556
+ _.each(find, function( element, index, list ){
557
+ if( index.indexOf( prefix ? prefix + '_'+filter : filter ) !== -1 || filter === index )
558
+ res.push( element );
559
+ });
560
+
561
+ return res;
562
+ }
563
+ WPV_Toolset.Utils.containsObject = function (obj, list) {
564
+ var res = _.find(list, function(val){
565
+ return _.isEqual(obj, val);
566
+ });
567
+ return (_.isObject(res))? true:false;
568
+ };
569
+ };
570
+
571
+
572
+
573
+ (function($) {
574
+ $.fn.textWidth = function() {
575
+ var text = this.html() || this.text() || this.val();
576
+ return( $.textWidth( text ) );
577
+ };
578
+ $.textWidth = function(text) {
579
+ var div = $('#textWidth');
580
+ if (div.length === 0)
581
+ div = $('<div id="textWidth" style="display: none;"></div>').appendTo($('body'));
582
+ div.html(text);
583
+ return(div.width());
584
+ };
585
+ })(jQuery);
586
+
587
+ //Courtesy from http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
588
+ WPV_Toolset.Utils.escapeHtml = function(str) {
589
+ if (typeof(str) == "string"){
590
+ try{
591
+ var newStr = "";
592
+ var nextCode = 0;
593
+ for (var i = 0;i < str.length;i++){
594
+ nextCode = str.charCodeAt(i);
595
+ if (nextCode > 0 && nextCode < 128){
596
+ newStr += "&#"+nextCode+";";
597
+ }
598
+ else{
599
+ newStr += "?";
600
+ }
601
+ }
602
+ return newStr;
603
+ }
604
+ catch(err){
605
+ }
606
+ }
607
+ else{
608
+ return str;
609
+ }
610
+ };
611
+
612
+ WPV_Toolset.Utils.editor_decode64 = function(input) {
613
+ var output = "",
614
+ chr1, chr2, chr3 = "",
615
+ enc1, enc2, enc3, enc4 = "",
616
+ i = 0,
617
+ keyStr = "ABCDEFGHIJKLMNOP" +
618
+ "QRSTUVWXYZabcdef" +
619
+ "ghijklmnopqrstuv" +
620
+ "wxyz0123456789+/" +
621
+ "=";
622
+
623
+ // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
624
+ var base64test = /[^A-Za-z0-9\+\/\=]/g;
625
+ if (base64test.exec(input)) {
626
+ alert("There were invalid base64 characters in the input text.\n" +
627
+ "Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" +
628
+ "Expect errors in decoding.");
629
+ }
630
+ input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
631
+
632
+ do {
633
+ enc1 = keyStr.indexOf(input.charAt(i++));
634
+ enc2 = keyStr.indexOf(input.charAt(i++));
635
+ enc3 = keyStr.indexOf(input.charAt(i++));
636
+ enc4 = keyStr.indexOf(input.charAt(i++));
637
+
638
+ chr1 = (enc1 << 2) | (enc2 >> 4);
639
+ chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
640
+ chr3 = ((enc3 & 3) << 6) | enc4;
641
+
642
+ output = output + String.fromCharCode(chr1);
643
+
644
+ if (enc3 != 64) {
645
+ output = output + String.fromCharCode(chr2);
646
+ }
647
+ if (enc4 != 64) {
648
+ output = output + String.fromCharCode(chr3);
649
+ }
650
+
651
+ chr1 = chr2 = chr3 = "";
652
+ enc1 = enc2 = enc3 = enc4 = "";
653
+
654
+ } while (i < input.length);
655
+
656
+ return WPV_Toolset.Utils.editor_utf8_decode( output );
657
+ };
658
+
659
+ WPV_Toolset.Utils.editor_utf8_decode = function (utftext) {
660
+ var string = "";
661
+ var i = 0;
662
+ var c = c1 = c2 = 0;
663
+
664
+ while ( i < utftext.length ) {
665
+
666
+ c = utftext.charCodeAt(i);
667
+
668
+ if (c < 128) {
669
+ string += String.fromCharCode(c);
670
+ i++;
671
+ }
672
+ else if((c > 191) && (c < 224)) {
673
+ c2 = utftext.charCodeAt(i+1);
674
+ string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
675
+ i += 2;
676
+ }
677
+ else {
678
+ c2 = utftext.charCodeAt(i+1);
679
+ c3 = utftext.charCodeAt(i+2);
680
+ string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
681
+ i += 3;
682
+ }
683
+
684
+ }
685
+
686
+ return string;
687
+ };
688
+
689
+ // convert unicode character to its corrsponding numeric entity
690
+ WPV_Toolset.Utils.fixedCharCodeAt = function (str, idx) {
691
+ // ex. fixedCharCodeAt ('\uD800\uDC00', 0); // 65536
692
+ // ex. fixedCharCodeAt ('\uD800\uDC00', 1); // 65536
693
+ idx = idx || 0;
694
+ var code = str.charCodeAt(idx);
695
+ var hi, low;
696
+ if (0xD800 <= code && code <= 0xDBFF) { // High surrogate (could change last hex to 0xDB7F to treat high private surrogates as single characters)
697
+ hi = code;
698
+ low = str.charCodeAt(idx+1);
699
+ if (isNaN(low)) {
700
+ throw 'High surrogate not followed by low surrogate in fixedCharCodeAt()';
701
+ }
702
+ return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
703
+ }
704
+ if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
705
+ // We return false to allow loops to skip this iteration since should have already handled high surrogate above in the previous iteration
706
+ return false;
707
+ /*hi = str.charCodeAt(idx-1);
708
+ low = code;
709
+ return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;*/
710
+ }
711
+ return code;
712
+ };
713
+
714
+ WPV_Toolset.replace_unicode_characters = function(string)
715
+ {
716
+ // remove accents, swap ñ for n, etc
717
+ var from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;",
718
+ to = "aaaaaeeeeeiiiiooooouuuunc------";
719
+ for (var i=0, l=from.length ; i<l ; i++) {
720
+ string = string.replace( new RegExp(from.charAt(i), 'g'), to.charAt(i) );
721
+ }
722
+
723
+ var unicode = '!£$%&()=?^|#§';
724
+
725
+ for( var i=0; i<unicode.length; i++ )
726
+ {
727
+ string = string.replace( new RegExp(unicode.charAt(i).regexEscape(), 'g'), WPV_Toolset.Utils.fixedCharCodeAt( unicode.charAt(i) ) );
728
+ }
729
+
730
+ return string;
731
+ };
732
+
733
+ // escapes regex characters for use in regex constructor
734
+ String.prototype.regexEscape = function regexEscape() {
735
+ return this.replace(/[\.\?\+\*\^\$\|\(\{\[\]\\)]/g, '\\$&');
736
+ };
737
+
738
+ // THE TOOLTIP //
739
+ ;
740
+ (function ($, window, document, undefined) {
741
+
742
+ // Create the defaults once
743
+ var pluginName = "toolsetTooltip",
744
+ dataPlugin = "plugin_" + pluginName,
745
+ undefined,
746
+ defaults = {
747
+ top: undefined,
748
+ text:'',
749
+ close:null,
750
+ open:null
751
+ };
752
+
753
+ // The actual plugin constructor
754
+ function Plugin(element, options) {
755
+
756
+ this.$element = element;
757
+ this.settings = $.extend({}, defaults, options);
758
+ this._defaults = defaults;
759
+ this._name = pluginName;
760
+ this._remove_tooltip = null;
761
+ }
762
+
763
+ // Avoid Plugin.prototype conflicts
764
+ $.extend(Plugin.prototype, {
765
+ init: function () {
766
+ var self = this;
767
+ this.$element.on('mouseenter', function(event) {
768
+ self.show(event);
769
+ });
770
+ this.$element.on('mouseleave', function(event) {
771
+ self.hide(event);
772
+ });
773
+ },
774
+ show: function (event) {
775
+ var self = this,
776
+ $tooltip = $('<div class="toolset-tooltip" />'),
777
+ offset = self.$element.offset(),
778
+ offset_top = typeof self.settings.top === 'undefined' ? 20 : self.settings.top;
779
+
780
+ self._remove_tooltip = $tooltip;
781
+
782
+ $tooltip
783
+ .appendTo('body')
784
+ .text( this.settings.text || self.$element.data('tooltip-text') )
785
+ .css({
786
+ 'top': offset.top - $tooltip.height() - offset_top,
787
+ 'left': offset.left - ($tooltip.outerWidth() / 2) + (self.$element.outerWidth() / 2),
788
+ 'zIndex': '9999999'
789
+ })
790
+ .fadeIn(100);
791
+
792
+ // Probably $elem doesn't is removed before 'click' event takes place
793
+ // So we need to call _manageCellTooltip( $elem, 'hide') somewhere... but i don't know where ;)
794
+
795
+ self.$element.on('mousedown', function () {
796
+
797
+ if ( self._remove_tooltip ){
798
+ self._remove_tooltip.remove();
799
+ self._remove_tooltip = null;
800
+ }
801
+ });
802
+
803
+ if( self.settings.open !== null && self.settings.open instanceof Function ){
804
+ self.settings.open.call(self);
805
+ }
806
+
807
+ return $tooltip;
808
+ },
809
+ hide: function (event) {
810
+ var self = this;
811
+
812
+ if ( self._remove_tooltip ) {
813
+ if( self.settings.close !== null && self.settings.close instanceof Function ){
814
+ self.settings.close.call(self);
815
+ }
816
+ self._remove_tooltip.remove();
817
+ self._remove_tooltip = null;
818
+ }
819
+ }
820
+ });
821
+
822
+ $.fn[ pluginName ] = function ( arg ) {
823
+
824
+ return this.each(function(){
825
+ var args, instance;
826
+
827
+ if ( !( $(this).data( dataPlugin ) instanceof Plugin ) ) {
828
+ // if no instance, create one
829
+ $(this).data( dataPlugin, new Plugin( $(this), arg ) );
830
+ }
831
+
832
+ instance = $(this).data( dataPlugin );
833
+ instance.element = $(this);
834
+
835
+ // call Plugin.init( arg )
836
+ if (typeof arg === 'undefined' || typeof arg === 'object') {
837
+
838
+ if ( typeof instance['init'] === 'function' ) {
839
+ instance.init( arg );
840
+ }
841
+
842
+ // checks that the requested public method exists
843
+ } else if ( typeof arg === 'string' && typeof instance[arg] === 'function' ) {
844
+
845
+ // copy arguments & remove function name
846
+ args = Array.prototype.slice.call( arguments, 1 );
847
+
848
+ // call the method
849
+ return instance[arg].apply( instance, args );
850
+
851
+ } else {
852
+
853
+ $.error('Method ' + arg + ' does not exist on jQuery.' + pluginName);
854
+
855
+ }
856
+ });
857
+
858
+ return this;
859
+ };
860
+
861
+ })(jQuery, window, document);
862
+
863
+ ;(function($, window, document, undefined){
864
+ /*
865
+
866
+ highlight v3 !! Modified by Jon Raasch (http://jonraasch.com) to fix IE6 bug !!
867
+
868
+ Highlights arbitrary terms.
869
+
870
+ <http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
871
+
872
+ MIT license.
873
+
874
+ Johann Burkard
875
+ <http://johannburkard.de>
876
+ <mailto:jb@eaio.com>
877
+
878
+ */
879
+ var defaults = {
880
+ className:'highlighted'
881
+ },
882
+ options = {
883
+
884
+ };
885
+
886
+ jQuery.fn.highlight = function(pat, option) {
887
+
888
+ options = jQuery.extend( options, defaults, option )
889
+
890
+ function innerHighlight(node, pat) {
891
+ var skip = 0;
892
+
893
+ if ( node.nodeType == 3 ) {
894
+ var pos = node.data.toUpperCase().indexOf(pat);
895
+ if (pos >= 0) {
896
+ var spannode = document.createElement('span');
897
+ spannode.className = options.className;
898
+ var middlebit = node.splitText(pos);
899
+ var endbit = middlebit.splitText(pat.length);
900
+ var middleclone = middlebit.cloneNode(true);
901
+ spannode.appendChild(middleclone);
902
+ middlebit.parentNode.replaceChild(spannode, middlebit);
903
+ skip = 1;
904
+ }
905
+ }
906
+ else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
907
+ for (var i = 0; i < node.childNodes.length; ++i) {
908
+ i += innerHighlight(node.childNodes[i], pat);
909
+ }
910
+ }
911
+ return skip;
912
+ }
913
+ return this.each(function() {
914
+ innerHighlight(this, pat.toUpperCase());
915
+ });
916
+ };
917
+
918
+ jQuery.fn.removeHighlight = function() {
919
+ function newNormalize(node) {
920
+ for (var i = 0, children = node.childNodes, nodeCount = children.length; i < nodeCount; i++) {
921
+ var child = children[i];
922
+ if (child.nodeType == 1) {
923
+ newNormalize(child);
924
+ continue;
925
+ }
926
+ if (child.nodeType != 3) { continue; }
927
+ var next = child.nextSibling;
928
+ if (next == null || next.nodeType != 3) { continue; }
929
+ var combined_text = child.nodeValue + next.nodeValue;
930
+ new_node = node.ownerDocument.createTextNode(combined_text);
931
+ node.insertBefore(new_node, child);
932
+ node.removeChild(child);
933
+ node.removeChild(next);
934
+ i--;
935
+ nodeCount--;
936
+ }
937
+ }
938
+
939
+ return this.find("span."+options.className).each(function() {
940
+ var thisParent = this.parentNode;
941
+ thisParent.replaceChild(this.firstChild, this);
942
+ newNormalize(thisParent);
943
+ }).end();
944
+ };
945
+
946
+ }(jQuery, window, document))
embedded/common/utility/utils.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * a collection of .php utility functions for common use
5
+ */
6
+
7
+ if ( ! function_exists( 'wp_json_encode' ) ) {
8
+ function wp_json_encode( $data, $options = 0, $depth = 512 ) {
9
+ /*
10
+ * json_encode() has had extra params added over the years.
11
+ * $options was added in 5.3, and $depth in 5.5.
12
+ * We need to make sure we call it with the correct arguments.
13
+ */
14
+ if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) {
15
+ $args = array( $data, $options, $depth );
16
+ } elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
17
+ $args = array( $data, $options );
18
+ } else {
19
+ $args = array( $data );
20
+ }
21
+
22
+ $json = call_user_func_array( 'json_encode', $args );
23
+
24
+ // If json_encode() was successful, no need to do more sanity checking.
25
+ // ... unless we're in an old version of PHP, and json_encode() returned
26
+ // a string containing 'null'. Then we need to do more sanity checking.
27
+ if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) ) {
28
+ return $json;
29
+ }
30
+
31
+ try {
32
+ $args[0] = _wp_json_sanity_check( $data, $depth );
33
+ } catch ( Exception $e ) {
34
+ return false;
35
+ }
36
+
37
+ return call_user_func_array( 'json_encode', $args );
38
+ }
39
+
40
+ if ( ! function_exists( '_wp_json_sanity_check' ) ) {
41
+ function _wp_json_sanity_check( $data, $depth ) {
42
+ if ( $depth < 0 ) {
43
+ throw new Exception( 'Reached depth limit' );
44
+ }
45
+
46
+ if ( is_array( $data ) ) {
47
+ $output = array();
48
+ foreach ( $data as $id => $el ) {
49
+ // Don't forget to sanitize the ID!
50
+ if ( is_string( $id ) ) {
51
+ $clean_id = _wp_json_convert_string( $id );
52
+ } else {
53
+ $clean_id = $id;
54
+ }
55
+
56
+ // Check the element type, so that we're only recursing if we really have to.
57
+ if ( is_array( $el ) || is_object( $el ) ) {
58
+ $output[ $clean_id ] = _wp_json_sanity_check( $el, $depth - 1 );
59
+ } elseif ( is_string( $el ) ) {
60
+ $output[ $clean_id ] = _wp_json_convert_string( $el );
61
+ } else {
62
+ $output[ $clean_id ] = $el;
63
+ }
64
+ }
65
+ } elseif ( is_object( $data ) ) {
66
+ $output = new stdClass;
67
+ foreach ( $data as $id => $el ) {
68
+ if ( is_string( $id ) ) {
69
+ $clean_id = _wp_json_convert_string( $id );
70
+ } else {
71
+ $clean_id = $id;
72
+ }
73
+
74
+ if ( is_array( $el ) || is_object( $el ) ) {
75
+ $output->$clean_id = _wp_json_sanity_check( $el, $depth - 1 );
76
+ } elseif ( is_string( $el ) ) {
77
+ $output->$clean_id = _wp_json_convert_string( $el );
78
+ } else {
79
+ $output->$clean_id = $el;
80
+ }
81
+ }
82
+ } elseif ( is_string( $data ) ) {
83
+ return _wp_json_convert_string( $data );
84
+ } else {
85
+ return $data;
86
+ }
87
+
88
+ return $output;
89
+ }
90
+ }
91
+
92
+ if(!function_exists('_wp_json_convert_string')) {
93
+ function _wp_json_convert_string( $string ) {
94
+ static $use_mb = null;
95
+ if ( is_null( $use_mb ) ) {
96
+ $use_mb = function_exists( 'mb_convert_encoding' );
97
+ }
98
+
99
+ if ( $use_mb ) {
100
+ $encoding = mb_detect_encoding( $string, mb_detect_order(), true );
101
+ if ( $encoding ) {
102
+ return mb_convert_encoding( $string, 'UTF-8', $encoding );
103
+ } else {
104
+ return mb_convert_encoding( $string, 'UTF-8', 'UTF-8' );
105
+ }
106
+ } else {
107
+ return wp_check_invalid_utf8( $string, true );
108
+ }
109
+ }
110
+ }
111
+ }
embedded/common/visual-editor/editor-addon-generic.class.php CHANGED
@@ -11,19 +11,23 @@ if( !class_exists( 'Editor_addon_generic' ) )
11
  define( 'EDITOR_ADDON_RELPATH', icl_get_file_relpath( __FILE__ ) );
12
  }
13
 
14
- add_action( 'admin_print_styles', 'add_menu_css' );
15
 
16
- if( !function_exists('add_menu_css') )
17
- {
18
- function add_menu_css() {
19
  global $pagenow;
20
-
21
- if ( $pagenow == 'post.php' ||
22
- $pagenow == 'post-new.php' ||
23
- ( $pagenow == 'admin.php' && ( isset( $_GET['page'] ) &&
24
- ( $_GET['page'] == 'views-editor' ||
25
- $_GET['page'] == 'view-archives-editor' ||
26
- $_GET['page'] == 'dd_layouts_edit') ) ) // add the new Views edit screens
 
 
 
 
 
27
  ) {
28
  wp_enqueue_style( 'editor_addon_menu',
29
  EDITOR_ADDON_RELPATH . '/res/css/pro_dropdown_2.css' );
@@ -34,8 +38,47 @@ if( !class_exists( 'Editor_addon_generic' ) )
34
  }
35
 
36
 
37
- if ( is_admin() ) {
38
- add_action( 'admin_print_scripts', 'editor_add_js' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  }
40
 
41
  class Editor_addon_generic
11
  define( 'EDITOR_ADDON_RELPATH', icl_get_file_relpath( __FILE__ ) );
12
  }
13
 
14
+ add_action( 'admin_enqueue_scripts', 'icl_editor_admin_enqueue_styles' );
15
 
16
+ if ( ! function_exists( 'icl_editor_admin_enqueue_styles' ) ) {
17
+ function icl_editor_admin_enqueue_styles() {
 
18
  global $pagenow;
19
+ if (
20
+ $pagenow == 'post.php'
21
+ || $pagenow == 'post-new.php'
22
+ || (
23
+ $pagenow == 'admin.php'
24
+ && isset( $_GET['page'] )
25
+ && (
26
+ $_GET['page'] == 'views-editor'
27
+ || $_GET['page'] == 'view-archives-editor'
28
+ || $_GET['page'] == 'dd_layouts_edit'
29
+ )
30
+ ) // add the new Views edit screens
31
  ) {
32
  wp_enqueue_style( 'editor_addon_menu',
33
  EDITOR_ADDON_RELPATH . '/res/css/pro_dropdown_2.css' );
38
  }
39
 
40
 
41
+ add_action( 'admin_enqueue_scripts', 'icl_editor_admin_enqueue_scripts' );
42
+
43
+ if ( ! function_exists( 'icl_editor_admin_enqueue_scripts' ) ) {
44
+ function icl_editor_admin_enqueue_scripts() {
45
+ global $pagenow;
46
+ if (
47
+ $pagenow == 'post.php'
48
+ || $pagenow == 'post-new.php'
49
+ || (
50
+ $pagenow == 'admin.php'
51
+ && isset( $_GET['page'] )
52
+ && (
53
+ $_GET['page'] == 'views-editor'
54
+ || $_GET['page'] == 'view-archives-editor'
55
+ || $_GET['page'] == 'dd_layouts_edit'
56
+ )
57
+ )
58
+ ) {
59
+ wp_register_script( 'icl_editor-script', EDITOR_ADDON_RELPATH . '/res/js/icl_editor_addon_plugin.js', array( 'jquery', 'quicktags', 'wplink' ) );
60
+ wp_enqueue_script( 'icl_editor-script' );
61
+ }
62
+ if (
63
+ $pagenow == 'admin.php'
64
+ && isset( $_GET['page'] )
65
+ && (
66
+ $_GET['page'] == 'views-editor'
67
+ || $_GET['page'] == 'view-archives-editor'
68
+ || $_GET['page'] == 'dd_layouts_edit'
69
+ )
70
+ && !wp_script_is( 'views-redesign-media-manager-js', 'enqueued' )
71
+ ) {
72
+ $media_manager_translations = array(
73
+ 'only_img_allowed_here' => __( "You can only use an image file here", 'wpv-views' )
74
+ );
75
+ wp_enqueue_media();
76
+ wp_enqueue_script( 'icl_media-manager-js',
77
+ EDITOR_ADDON_RELPATH . '/res/js/icl_media_manager.js',
78
+ array( 'jquery', 'icl_editor-script' ) );
79
+ wp_localize_script( 'icl_media-manager-js', 'icl_media_manager', $media_manager_translations );
80
+ }
81
+ }
82
  }
83
 
84
  class Editor_addon_generic
embedded/common/visual-editor/editor-addon.class.php CHANGED
@@ -17,9 +17,12 @@ 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 = 'textarea#content', $standard_v = true, $add_views = false, $codemirror_button = false ) {
21
  global $wp_version;
22
-
 
 
 
23
  // WP 3.3 changes ($context arg is actually a editor ID now)
24
  if ( version_compare( $wp_version, '3.1.4', '>' ) && !empty( $context ) ) {
25
  $text_area = $context;
@@ -90,7 +93,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
90
  $dropdown_class = 'js-editor_addon_dropdown-'.$this->name;
91
  $icon_class = 'js-wpv-shortcode-post-icon-'.$this->name;
92
  if ( $this->name == 'wpv-views' ) {
93
- $button_label = __( 'Views', 'wpv-views' );
94
  } else if ( $this->name == 'types' ) {
95
  $button_label = __( 'Types', 'wpv-views' );
96
  } else {
@@ -318,7 +321,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
318
  $dropdown_class = 'js-editor_addon_dropdown-'.$this->name;
319
  $icon_class = 'js-wpv-shortcode-post-icon-'.$this->name;
320
  if ( $this->name == 'wpv-views' ) {
321
- $button_label = __( 'Views', 'wpv-views' );
322
  } else if ( $this->name == 'types' ) {
323
  $button_label = __( 'Types', 'wpv-views' );
324
  } else {
@@ -744,29 +747,6 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
744
  return $plugin_array;
745
  }
746
  }
747
-
748
- if( !function_exists('editor_add_js') )
749
- {
750
- function editor_add_js() {
751
- global $pagenow;
752
-
753
- if (
754
- $pagenow == 'post.php' ||
755
- $pagenow == 'post-new.php' ||
756
- ( $pagenow == 'admin.php' && ( isset( $_GET['page'] ) &&
757
- ( $_GET['page'] == 'views-editor' ||
758
- $_GET['page'] == 'view-archives-editor' ||
759
- $_GET['page'] == 'dd_layouts_edit') ) ) // add the new Views edit screens
760
- ) {
761
-
762
-
763
- wp_enqueue_script( 'icl_editor-script',
764
- EDITOR_ADDON_RELPATH . '/res/js/icl_editor_addon_plugin.js',
765
- array() );
766
- }
767
- }
768
- }
769
-
770
 
771
  /**
772
  * Renders JS for inserting shortcode from thickbox popup to editor.
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
+ }
26
  // WP 3.3 changes ($context arg is actually a editor ID now)
27
  if ( version_compare( $wp_version, '3.1.4', '>' ) && !empty( $context ) ) {
28
  $text_area = $context;
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 {
321
  $dropdown_class = 'js-editor_addon_dropdown-'.$this->name;
322
  $icon_class = 'js-wpv-shortcode-post-icon-'.$this->name;
323
  if ( $this->name == 'wpv-views' ) {
324
+ $button_label = __( 'Fields and Views', 'wpv-views' );
325
  } else if ( $this->name == 'types' ) {
326
  $button_label = __( 'Types', 'wpv-views' );
327
  } else {
747
  return $plugin_array;
748
  }
749
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
750
 
751
  /**
752
  * Renders JS for inserting shortcode from thickbox popup to editor.
embedded/common/visual-editor/res/js/icl_editor_addon_plugin.js CHANGED
@@ -1,3 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
  var iclEditorWidth = 550;
3
  var iclEditorWidthMin = 195;
@@ -292,20 +390,6 @@ jQuery(document).ready(function(){
292
  });
293
  });
294
 
295
-
296
- /*
297
- *
298
- *
299
- *
300
- *
301
- *
302
- *
303
- *
304
- *
305
- *
306
- * FUNCTIONS
307
- */
308
-
309
  /**
310
  *
311
  * Main popup function
@@ -535,8 +619,8 @@ function insert_b64_shortcode_to_editor(b64_shortcode, text_area) {
535
  if(shortcode.indexOf('[types') == 0 && shortcode.indexOf('[/types') === false) {
536
  shortcode += '[/types]';
537
  }
538
-
539
  window.wpcfActiveEditor = text_area;
 
540
  icl_editor.insert(shortcode);
541
  }
542
 
@@ -717,17 +801,40 @@ var icl_editor = (function(window, $){
717
  };
718
 
719
  function isCodeMirror($textarea)
720
- {
721
- //console.log(typeof($textarea[0]));
722
- var textareaNext = $textarea[0].nextSibling;
723
- // if CodeMirror
 
 
724
  if (
725
- textareaNext && $textarea.is('textarea')&&
726
- //$(textareaNext).is('textarea')&&
727
  textareaNext.CodeMirror &&
728
  $textarea[0]==textareaNext.CodeMirror.getTextArea()
729
- )
730
  return textareaNext.CodeMirror;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
731
  return false;
732
  };
733
 
@@ -910,5 +1017,6 @@ var icl_editor = (function(window, $){
910
  return window.iclCodemirror[textarea];
911
  }
912
  };
 
913
 
914
  })(window, jQuery, undefined);
1
+ var WPV_Toolset = WPV_Toolset || {};
2
+ if ( typeof WPV_Toolset.CodeMirror_instance === "undefined" ) {
3
+ WPV_Toolset.CodeMirror_instance = [];
4
+ }
5
+
6
+ if ( WPV_Toolset.add_qt_editor_buttons !== 'function' ) {
7
+ WPV_Toolset.add_qt_editor_buttons = function( qt_instance, editor_instance ) {
8
+ QTags._buttonsInit();
9
+ WPV_Toolset.CodeMirror_instance[qt_instance.id] = editor_instance;
10
+
11
+ for ( var button_name in qt_instance.theButtons ) {
12
+ if ( qt_instance.theButtons.hasOwnProperty( button_name ) ) {
13
+ qt_instance.theButtons[button_name].old_callback = qt_instance.theButtons[button_name].callback;
14
+ if ( qt_instance.theButtons[button_name].id == 'img' ){
15
+ qt_instance.theButtons[button_name].callback = function( element, canvas, ed ) {
16
+ var t = this,
17
+ id = jQuery( canvas ).attr( 'id' ),
18
+ selection = WPV_Toolset.CodeMirror_instance[id].getSelection(),
19
+ e = "http://",
20
+ g = prompt( quicktagsL10n.enterImageURL, e ),
21
+ f = prompt( quicktagsL10n.enterImageDescription, "" );
22
+ t.tagStart = '<img src="'+g+'" alt="'+f+'" />';
23
+ selection = t.tagStart;
24
+ t.closeTag( element, ed );
25
+ WPV_Toolset.CodeMirror_instance[id].replaceSelection( selection, 'end' );
26
+ WPV_Toolset.CodeMirror_instance[id].focus();
27
+ }
28
+ } else if ( qt_instance.theButtons[button_name].id == 'close' ) {
29
+
30
+ } else if ( qt_instance.theButtons[button_name].id == 'link' ) {
31
+ var t = this;
32
+ qt_instance.theButtons[button_name].callback =
33
+ function ( b, c, d, e ) {
34
+ activeUrlEditor = c;var f,g=this;return"undefined"!=typeof wpLink?void wpLink.open(d.id):(e||(e="http://"),void(g.isOpen(d)===!1?(f=prompt(quicktagsL10n.enterURL,e),f&&(g.tagStart='<a href="'+f+'">',a.TagButton.prototype.callback.call(g,b,c,d))):a.TagButton.prototype.callback.call(g,b,c,d)))
35
+ }
36
+ ;
37
+ jQuery( '#wp-link-submit' ).off();
38
+ jQuery( '#wp-link-submit' ).on( 'click', function() {
39
+ var id = jQuery( activeUrlEditor ).attr('id'),
40
+ selection = WPV_Toolset.CodeMirror_instance[id].getSelection(),
41
+ target = '';
42
+ if ( jQuery( '#link-target-checkbox' ).prop('checked') ) {
43
+ target = '_blank';
44
+ }
45
+ html = '<a href="' + jQuery('#url-field').val() + '"';
46
+ title = '';
47
+ if ( jQuery( '#link-title-field' ).val() ) {
48
+ title = jQuery( '#link-title-field' ).val().replace( /</g, '&lt;' ).replace( />/g, '&gt;' ).replace( /"/g, '&quot;' );
49
+ html += ' title="' + title + '"';
50
+ }
51
+ if ( target ) {
52
+ html += ' target="' + target + '"';
53
+ }
54
+ html += '>';
55
+ if ( selection === '' ) {
56
+ html += title;
57
+ } else {
58
+ html += selection;
59
+ }
60
+ html += '</a>';
61
+ t.tagStart = html;
62
+ selection = t.tagStart;
63
+ WPV_Toolset.CodeMirror_instance[id].replaceSelection( selection, 'end' );
64
+ WPV_Toolset.CodeMirror_instance[id].focus();
65
+ jQuery( '#wp-link-backdrop,#wp-link-wrap' ).hide();
66
+ jQuery( document.body ).removeClass( 'modal-open' );
67
+ return false;
68
+ });
69
+ } else {
70
+ qt_instance.theButtons[button_name].callback = function( element, canvas, ed ) {
71
+ var id = jQuery( canvas ).attr( 'id' ),
72
+ t = this,
73
+ selection = WPV_Toolset.CodeMirror_instance[id].getSelection();
74
+ if ( selection.length > 0 ) {
75
+ if ( !t.tagEnd ) {
76
+ selection = selection + t.tagStart;
77
+ } else {
78
+ selection = t.tagStart + selection + t.tagEnd;
79
+ }
80
+ } else {
81
+ if ( !t.tagEnd ) {
82
+ selection = t.tagStart;
83
+ } else if ( t.isOpen( ed ) === false ) {
84
+ selection = t.tagStart;
85
+ t.openTag( element, ed );
86
+ } else {
87
+ selection = t.tagEnd;
88
+ t.closeTag( element, ed );
89
+ }
90
+ }
91
+ WPV_Toolset.CodeMirror_instance[id].replaceSelection(selection, 'end');
92
+ WPV_Toolset.CodeMirror_instance[id].focus();
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
 
100
  var iclEditorWidth = 550;
101
  var iclEditorWidthMin = 195;
390
  });
391
  });
392
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
393
  /**
394
  *
395
  * Main popup function
619
  if(shortcode.indexOf('[types') == 0 && shortcode.indexOf('[/types') === false) {
620
  shortcode += '[/types]';
621
  }
 
622
  window.wpcfActiveEditor = text_area;
623
+
624
  icl_editor.insert(shortcode);
625
  }
626
 
801
  };
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
 
1017
  return window.iclCodemirror[textarea];
1018
  }
1019
  };
1020
+
1021
 
1022
  })(window, jQuery, undefined);
embedded/common/visual-editor/res/js/icl_media_manager.js ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Thanks to Thomas Griffin for his super useful example on Github
3
+ *
4
+ * https://github.com/thomasgriffin/New-Media-Image-Uploader
5
+ */
6
+ jQuery(document).ready(function($){
7
+
8
+ // Prepare the variable that holds our custom media manager.
9
+ var wpv_media_frame;
10
+ // var wp_media_post_id = wp.media.model.settings.post.id; // Store the old id
11
+ var toolset_edit_data = jQuery( '#toolset-edit-data' ),
12
+ set_to_post_id = toolset_edit_data.val(),
13
+ toolset_edit_plugin = toolset_edit_data.data( 'plugin' );
14
+
15
+ // Bind to our click event in order to open up the new media experience.
16
+ $(document.body).on('click', '.js-wpv-media-manager', function(e){ //mojo-open-media is the class of our form button
17
+ // Prevent the default action from occuring.
18
+ e.preventDefault(toolset_edit_data);
19
+
20
+ var referred_id = $(this).attr('data-id');
21
+ if (typeof referred_id !== 'undefined' && referred_id !== false) {
22
+ set_to_post_id = referred_id;
23
+ }
24
+
25
+ var active_textarea = $(this).data('content');
26
+ window.wpcfActiveEditor = active_textarea;
27
+ // If the frame already exists, re-open it.
28
+ if ( wpv_media_frame ) {
29
+ wpv_media_frame.uploader.uploader.param( 'post_id', set_to_post_id );
30
+ wpv_media_frame.open();
31
+ return;
32
+ } else {
33
+ // Set the wp.media post id so the uploader grabs the ID we want when initialised
34
+ wp.media.model.settings.post.id = set_to_post_id;
35
+ }
36
+ wpv_media_frame = wp.media.frames.wpv_media_frame = wp.media({
37
+ //Create our media frame
38
+ className: 'media-frame mojo-media-frame js-wpv-media-frame',
39
+ frame: 'post',
40
+ multiple: false, //Disallow Mulitple selections
41
+ library: {
42
+ type: 'image' //Only allow images
43
+ }
44
+ });
45
+
46
+
47
+ wpv_media_frame.on('open', function(event){
48
+ var media_button_insert = $('.media-button-insert'),
49
+ media_frame = $('.js-wpv-media-frame');
50
+ $('li.selected').removeClass('selected').find('a.check').trigger('click');
51
+ media_button_insert.addClass('button-secondary').removeClass('button-primary');
52
+ media_frame.find('.media-menu').html('');
53
+ media_button_insert.live("attributeChanged", function(event, args, val ){
54
+
55
+ if( args == 'disabled' && val == true )
56
+ {
57
+ $(event.target).addClass('button-secondary').removeClass('button-primary');
58
+ }
59
+ else if( args == 'disabled' && val == false )
60
+ {
61
+ $(event.target).removeClass('button-secondary').addClass('button-primary');
62
+ }
63
+ });
64
+ $('.clear-selection').on('click', function() {
65
+ media_button_insert.parent().find('.js-wpv-media-type-not-insertable').remove();
66
+ media_button_insert.addClass('button-secondary').removeClass('button-primary').show();
67
+ });
68
+ });
69
+
70
+ wpv_media_frame.on('insert', function(){
71
+ // Watch changes in wp-includes/js/media-editor.js
72
+ var media_attachment = wpv_media_frame.state().get('selection').first().toJSON(),
73
+ filetype = media_attachment.type;
74
+ if ( filetype == 'image' ) {
75
+ var size = $('.attachment-display-settings .size').val(),// WARNING size might be undefined for some image types, like BMP or TIFF, that do not generate thumbnails
76
+ only_img_src_allowed_here = [
77
+ 'wpv-pagination-spinner-image',
78
+ 'wpv-dps-spinner-image',
79
+ 'wpv_filter_meta_html_css',
80
+ 'wpv_filter_meta_html_js',
81
+ 'wpv_layout_meta_html_css',
82
+ 'wpv_layout_meta_html_js'
83
+ ],
84
+ shortcode,
85
+ code,
86
+ options,
87
+ classes,
88
+ align,
89
+ target_url;
90
+ if ( $.inArray( window.wpcfActiveEditor, only_img_src_allowed_here ) !== -1 ) {
91
+ if ( size ) {
92
+ code = media_attachment.sizes[size].url;
93
+ } else {
94
+ code = media_attachment.url;
95
+ }
96
+ $('.js-' + window.wpcfActiveEditor).val('');
97
+ $('.js-' + window.wpcfActiveEditor + '-preview').attr("src",code).show();
98
+ } else {
99
+ // Basic img tag options
100
+ if ( size ) {
101
+ options = {
102
+ tag:'img',
103
+ attrs: {
104
+ src: media_attachment.sizes[size].url
105
+ },
106
+ single: true
107
+ };
108
+ } else {
109
+ options = {
110
+ tag:'img',
111
+ attrs: {
112
+ src: media_attachment.url
113
+ },
114
+ single: true
115
+ };
116
+ }
117
+ if ( media_attachment.hasOwnProperty( 'alt' ) && media_attachment.alt ) {
118
+ options.attrs.alt = media_attachment.alt;
119
+ }
120
+ if ( size ) {
121
+ options.attrs.width = media_attachment.sizes[size].width;
122
+ options.attrs.height = media_attachment.sizes[size].height;
123
+ } else {
124
+ options.attrs.width = 1;
125
+ }
126
+ classes = [];
127
+ align = $('.alignment').val();
128
+ if ( align == 'none' ) {
129
+ align = false;
130
+ }
131
+ // Only assign the align class to the image if we're not printing a caption, since the alignment is sent to the shortcode.
132
+ if ( align && ! media_attachment.caption ) {
133
+ classes.push( 'align' + align );
134
+ }
135
+ if ( size ) {
136
+ classes.push( 'size-' + size );
137
+ }
138
+ options.attrs['class'] = _.compact( classes ).join(' ');
139
+ // Generate the `a` element options, if they exist.
140
+ if ( $('select.link-to').val() == 'file' ) {
141
+ target_url = media_attachment.url;
142
+ } else if ( $('select.link-to').val() == 'custom' ) {
143
+ target_url = $('.link-to-custom').val();
144
+ } else {
145
+ target_url = false;
146
+ }
147
+ if ( target_url ) {
148
+ options = {
149
+ tag: 'a',
150
+ attrs: {
151
+ href: target_url
152
+ },
153
+ content: options
154
+ };
155
+ }
156
+ code = wp.html.string( options );
157
+ // Generate the caption shortcode if needed
158
+ if ( media_attachment.caption ) {
159
+ shortcode = {};
160
+ if (size ) {
161
+ if ( media_attachment.sizes[size].width ) {
162
+ shortcode.width = media_attachment.sizes[size].width;
163
+ }
164
+ } else {
165
+ shortcode.width = 1;
166
+ }
167
+ if ( align ) {
168
+ shortcode.align = 'align' + align;
169
+ }
170
+ code = wp.shortcode.string({
171
+ tag: 'caption',
172
+ attrs: shortcode,
173
+ content: code + ' ' + media_attachment.caption
174
+ });
175
+ }
176
+ }
177
+ icl_editor.insert(code);
178
+ if ( $.inArray( window.wpcfActiveEditor, only_img_src_allowed_here ) !== -1 ) {
179
+ $('.js-' + window.wpcfActiveEditor).trigger('keyup');
180
+ }
181
+ } else {
182
+ var options,
183
+ media_shrtcode = '';
184
+ if ( $('select.link-to').val() == 'embed' ) {
185
+ options = {
186
+ tag: filetype,
187
+ attrs: {
188
+ src: media_attachment.url
189
+ },
190
+ type: true,
191
+ content: ''
192
+ };
193
+ if ( media_attachment.hasOwnProperty( 'caption' ) && media_attachment.caption ) {
194
+ options.attrs.caption = media_attachment.caption;
195
+ }
196
+ media_shrtcode = wp.shortcode.string( options );
197
+ } else {
198
+ options = {
199
+ tag: 'a',
200
+ attrs: {
201
+ href: media_attachment.url
202
+ },
203
+ content: media_attachment.title
204
+ };
205
+ media_shrtcode = wp.html.string( options );
206
+ /*
207
+ media_shrtcode = '<a href="' + media_attachment.url + '">' + media_attachment.title + '</a>';
208
+ */
209
+ }
210
+ icl_editor.insert(media_shrtcode);
211
+ }
212
+ });
213
+
214
+ var _AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay;
215
+ wp.media.view.Settings.AttachmentDisplay = _AttachmentDisplay.extend({
216
+ render: function() {
217
+ _AttachmentDisplay.prototype.render.apply(this, arguments);
218
+ var attachment = this.options.attachment,
219
+ attach_type = '',
220
+ insert_button = $('.media-button-insert').show(),
221
+ only_img_src_allowed_here = [
222
+ 'wpv-pagination-spinner-image',
223
+ 'wpv-dps-spinner-image',
224
+ 'wpv_filter_meta_html_css',
225
+ 'wpv_filter_meta_html_js',
226
+ 'wpv_layout_meta_html_css',
227
+ 'wpv_layout_meta_html_js'
228
+ ];
229
+ insert_button.parent().find('.js-wpv-media-type-not-insertable').remove();
230
+ if ( attachment ) {
231
+ attach_type = attachment.get('type');
232
+ }
233
+ if ( attach_type == 'image' && $.inArray( window.wpcfActiveEditor, only_img_src_allowed_here ) !== -1 ) {
234
+ this.$el.find('select.link-to').parent().remove();
235
+ this.model.set('link', 'none');
236
+ this.$el.find('select.alignment').parent().remove();
237
+ } else {
238
+ this.$el.find('select.link-to').find('option[value="post"]').remove();
239
+ if ( $.inArray( window.wpcfActiveEditor, only_img_src_allowed_here ) !== -1 ) {
240
+ insert_button.hide().parent().append('<button disabled="disabled" class="media-button button-large button-secondary js-wpv-media-type-not-insertable">' + icl_media_manager.only_img_allowed_here + '</button>');
241
+ }
242
+ }
243
+ this.updateLinkTo();
244
+ }
245
+ });
246
+
247
+ // Now that everything has been set, let's open up the frame.
248
+ wpv_media_frame.open();
249
+ });
250
+ });
251
+
252
+
253
+ jQuery(document).on("DOMNodeInserted", function(){
254
+ var toolset_edit_plugin = jQuery( '#toolset-edit-data' ).data( 'plugin' );
255
+ if ( toolset_edit_plugin === 'views' ){
256
+ // Lock uploads to "Uploaded to this post"
257
+ jQuery('select.attachment-filters [value="uploaded"]').attr( 'selected', true ).parent().trigger('change');
258
+ jQuery('.attachments-browser .media-toolbar-secondary .attachment-filters').addClass('hidden');
259
+ }
260
+ });
embedded/frontend.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Frontend functions.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/frontend.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -49,7 +49,7 @@ add_shortcode( 'types', 'wpcf_shortcode' );
49
  function wpcf_shortcode( $atts, $content = null, $code = '' ) {
50
 
51
  global $wpcf;
52
-
53
  // Switch the post if there is an attribute of 'id' in the shortcode.
54
  $post_id_atts = new WPV_wpcf_switch_post_from_attr_id( $atts );
55
 
@@ -522,6 +522,10 @@ function wpcf_views_query( $query, $view_settings ) {
522
  $field_name = $meta['key'];
523
  if ( _wpcf_is_checkboxes_field( $field_name ) ) {
524
 
 
 
 
 
525
  // We'll use SQL regexp to find the checked items.
526
  // Note that we are creating something here that
527
  // then gets modified to a proper SQL REGEXP in
@@ -530,7 +534,6 @@ function wpcf_views_query( $query, $view_settings ) {
530
  $field_name = substr( $field_name, 5 );
531
 
532
  $meta_filter_required = true;
533
- $meta['compare'] = '=';
534
 
535
  /* According to http://codex.wordpress.org/Class_Reference/WP_Meta_Query#Accepted_Arguments,
536
  * $meta['value'] can be an array or a string. In case of a string we additionally allow
@@ -543,29 +546,21 @@ function wpcf_views_query( $query, $view_settings ) {
543
  // This can happen if $meta['value'] is a number, for example.
544
  $values = array( $meta['value'] );
545
  }
546
-
547
- $meta['value'] = ' REGEXP(';
548
-
549
  $options = $opt[$field_name]['data']['options'];
550
 
551
- $count = 0;
552
  foreach ( $values as $value ) {
553
-
554
  foreach ( $options as $key => $option ) {
555
  if ( $option['title'] == $value ) {
556
- if ( $count > 0 ) {
557
- $meta['value'] .= '|';
558
- }
559
- $meta['value'] .= $key;
 
 
560
  break;
561
  }
562
  }
563
- $count++;
564
  }
565
-
566
- $meta['value'] .= ')';
567
-
568
- $query['meta_query'][$index] = $meta;
569
  }
570
  }
571
  }
@@ -574,7 +569,6 @@ function wpcf_views_query( $query, $view_settings ) {
574
  if ( $meta_filter_required ) {
575
  add_filter( 'get_meta_sql', 'wpcf_views_get_meta_sql', 10, 6 );
576
  }
577
-
578
  return $query;
579
  }
580
 
2
  /*
3
  * Frontend functions.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/embedded/frontend.php $
6
+ * $LastChangedDate: 2015-01-28 06:42:34 +0000 (Wed, 28 Jan 2015) $
7
+ * $LastChangedRevision: 1077234 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
49
  function wpcf_shortcode( $atts, $content = null, $code = '' ) {
50
 
51
  global $wpcf;
52
+
53
  // Switch the post if there is an attribute of 'id' in the shortcode.
54
  $post_id_atts = new WPV_wpcf_switch_post_from_attr_id( $atts );
55
 
522
  $field_name = $meta['key'];
523
  if ( _wpcf_is_checkboxes_field( $field_name ) ) {
524
 
525
+ $orginal = $query['meta_query'][$index];
526
+
527
+ unset($query['meta_query'][$index]);
528
+
529
  // We'll use SQL regexp to find the checked items.
530
  // Note that we are creating something here that
531
  // then gets modified to a proper SQL REGEXP in
534
  $field_name = substr( $field_name, 5 );
535
 
536
  $meta_filter_required = true;
 
537
 
538
  /* According to http://codex.wordpress.org/Class_Reference/WP_Meta_Query#Accepted_Arguments,
539
  * $meta['value'] can be an array or a string. In case of a string we additionally allow
546
  // This can happen if $meta['value'] is a number, for example.
547
  $values = array( $meta['value'] );
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
  }
569
  if ( $meta_filter_required ) {
570
  add_filter( 'get_meta_sql', 'wpcf_views_get_meta_sql', 10, 6 );
571
  }
 
572
  return $query;
573
  }
574
 
embedded/functions.php CHANGED
@@ -1,713 +1,738 @@
1
- <?php
2
- /*
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.4/embedded/functions.php $
7
- * $LastChangedDate: 2014-10-23 10:33:39 +0000 (Thu, 23 Oct 2014) $
8
- * $LastChangedRevision: 1012677 $
9
- * $LastChangedBy: iworks $
10
- *
11
- */
12
-
13
- /**
14
- * Caches get_post_meta() calls.
15
- *
16
- * @staticvar array $cache
17
- * @param type $post_id
18
- * @param type $meta_key
19
- * @param type $single
20
- * @return string
21
- */
22
- function wpcf_get_post_meta( $post_id, $meta_key, $single ) {
23
-
24
- static $cache = array();
25
-
26
- if ( !isset( $cache[$post_id] ) ) {
27
- $cache[$post_id] = get_post_custom( $post_id );
28
- }
29
- if ( isset( $cache[$post_id][$meta_key] ) ) {
30
- if ( $single && isset( $cache[$post_id][$meta_key][0] ) ) {
31
- return maybe_unserialize( $cache[$post_id][$meta_key][0] );
32
- } else if ( !$single && !empty( $cache[$post_id][$meta_key] ) ) {
33
- return maybe_unserialize( $cache[$post_id][$meta_key] );
34
- }
35
- }
36
- return '';
37
- }
38
-
39
- /**
40
- * Calculates relative path for given file.
41
- *
42
- * @param type $file Absolute path to file
43
- * @return string Relative path
44
- */
45
- function wpcf_get_file_relpath( $file ) {
46
- $is_https = isset( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) == 'on';
47
- $http_protocol = $is_https ? 'https' : 'http';
48
- $base_root = $http_protocol . '://' . $_SERVER['HTTP_HOST'];
49
- $base_url = $base_root;
50
- $dir = rtrim( dirname( $file ), '\/' );
51
- if ( $dir ) {
52
- $base_path = $dir;
53
- $base_url .= $base_path;
54
- $base_path .= '/';
55
- } else {
56
- $base_path = '/';
57
- }
58
- $relpath = $base_root
59
- . str_replace(
60
- str_replace( '\\', '/',
61
- realpath( $_SERVER['DOCUMENT_ROOT'] ) )
62
- , '', str_replace( '\\', '/', dirname( $file ) )
63
- );
64
- return $relpath;
65
- }
66
-
67
- /**
68
- * after_setup_theme hook.
69
- */
70
- function wpcf_embedded_after_setup_theme_hook() {
71
- $custom_types = get_option( 'wpcf-custom-types', array() );
72
- if ( !empty( $custom_types ) ) {
73
- foreach ( $custom_types as $post_type => $data ) {
74
- if ( !empty( $data['supports']['thumbnail'] ) ) {
75
- if ( !current_theme_supports( 'post-thumbnails' ) ) {
76
- add_theme_support( 'post-thumbnails' );
77
- remove_post_type_support( 'post', 'thumbnail' );
78
- remove_post_type_support( 'page', 'thumbnail' );
79
- } else {
80
- add_post_type_support( $post_type, 'thumbnail' );
81
- }
82
- }
83
- }
84
- }
85
- }
86
-
87
- /**
88
- * Inits custom types and taxonomies.
89
- */
90
- function wpcf_init_custom_types_taxonomies() {
91
- $custom_taxonomies = get_option( 'wpcf-custom-taxonomies', array() );
92
- if ( !empty( $custom_taxonomies ) ) {
93
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
94
- wpcf_custom_taxonomies_init();
95
- }
96
- $custom_types = get_option( 'wpcf-custom-types', array() );
97
- if ( !empty( $custom_types ) ) {
98
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-types.php';
99
- wpcf_custom_types_init();
100
- }
101
- }
102
-
103
- /**
104
- * Returns meta_key type for specific field type.
105
- *
106
- * @param type $type
107
- * @return type
108
- */
109
- function types_get_field_type( $type ) {
110
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
111
- $data = wpcf_fields_type_action( $type );
112
- if ( !empty( $data['meta_key_type'] ) ) {
113
- return $data['meta_key_type'];
114
- }
115
- return 'CHAR';
116
- }
117
-
118
- /**
119
- * Imports settings.
120
- */
121
- function wpcf_embedded_check_import() {
122
- if ( file_exists( WPCF_EMBEDDED_ABSPATH . '/settings.php' ) ) {
123
- require_once WPCF_EMBEDDED_ABSPATH . '/admin.php';
124
- require_once WPCF_EMBEDDED_ABSPATH . '/settings.php';
125
- $dismissed = get_option( 'wpcf_dismissed_messages', array() );
126
- if ( in_array( $timestamp, $dismissed ) ) {
127
- return false;
128
- }
129
- if ( $timestamp > get_option( 'wpcf-types-embedded-import', 0 ) ) {
130
- if ( !$auto_import ) {
131
- $link = "<a href=\"" . admin_url( '?types-embedded-import=1&amp;_wpnonce=' . wp_create_nonce( 'embedded-import' ) ) . "\">";
132
- $text = sprintf( __( 'You have Types import pending. %sClick here to import.%s %sDismiss message.%s',
133
- 'wpcf' ), $link, '</a>',
134
- "<a onclick=\"jQuery(this).parent().parent().fadeOut();\" class=\"wpcf-ajax-link\" href=\""
135
- . admin_url( 'admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=dismiss_message&amp;id='
136
- . $timestamp . '&amp;_wpnonce=' . wp_create_nonce( 'dismiss_message' ) ) . "\">",
137
- '</a>' );
138
- wpcf_admin_message( $text );
139
- }
140
- if ( $auto_import || (isset( $_GET['types-embedded-import'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'],
141
- 'embedded-import' )) ) {
142
- if ( file_exists( WPCF_EMBEDDED_ABSPATH . '/settings.xml' ) ) {
143
- $_POST['overwrite-groups'] = 1;
144
- $_POST['overwrite-fields'] = 1;
145
- $_POST['overwrite-types'] = 1;
146
- $_POST['overwrite-tax'] = 1;
147
- // $_POST['delete-groups'] = 0;
148
- // $_POST['delete-fields'] = 0;
149
- // $_POST['delete-types'] = 0;
150
- // $_POST['delete-tax'] = 0;
151
- $_POST['post_relationship'] = 1;
152
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
153
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/import-export.php';
154
- $data = @file_get_contents( WPCF_EMBEDDED_ABSPATH . '/settings.xml' );
155
- wpcf_admin_import_data( $data, false, 'types-auto-import' );
156
- update_option( 'wpcf-types-embedded-import', $timestamp );
157
- wp_redirect( admin_url() );
158
- } else {
159
- $code = __( 'settings.xml file missing', 'wpcf' );
160
- wpcf_admin_message( $code, 'error' );
161
- }
162
- }
163
- }
164
- }
165
- }
166
-
167
- /**
168
- * Display information about upgrading to the plugin version of types.
169
- *
170
- */
171
- function wpcf_promote_types_admin() {
172
- $custom_types = get_option( 'wpcf-custom-types', array() );
173
-
174
- ?>
175
-
176
- <?php
177
- if ( sizeof( $custom_types ) > 0 ) {
178
- echo '<p>' . __( 'Types creates Custom Post Types. These are user-defined WordPress content types. On your theme the following types are defined:',
179
- 'wpcf' ) . "</p>\n";
180
- echo "<ul style='margin-left:20px;'>\n";
181
- foreach ( $custom_types as $type ) {
182
- echo "<li>" . $type['labels']['name'] . "</li>\n";
183
- }
184
- echo "</ul>\n";
185
- }
186
-
187
- ?>
188
- <p><?php
189
- 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>',
190
- 'wpcf' ), 'http://wordpress.org/extend/plugins/types/',
191
- 'http://wordpress.org/extend/plugins/types/' );
192
-
193
- ?></p>
194
-
195
- <?php
196
- }
197
-
198
- /**
199
- * Actions for outside fields control.
200
- *
201
- * @param type $action
202
- */
203
- function wpcf_types_cf_under_control( $action = 'add', $args = array(),
204
- $post_type = 'wp-types-group', $meta_name = 'wpcf-fields' ) {
205
- global $wpcf_types_under_control;
206
- $wpcf_types_under_control['errors'] = array();
207
- switch ( $action ) {
208
- case 'add':
209
- $fields = wpcf_admin_fields_get_fields( false, true, false,
210
- $meta_name, false );
211
- foreach ( $args['fields'] as $field_id ) {
212
- $field_type = !empty( $args['type'] ) ? $args['type'] : 'textfield';
213
- if ( strpos( $field_id, md5( 'wpcf_not_controlled' ) ) !== false ) {
214
- $field_id_name = str_replace( '_' . md5( 'wpcf_not_controlled' ), '', $field_id );
215
- $field_id_add = preg_replace( '/^wpcf\-/', '', $field_id_name );
216
- $adding_field_with_wpcf_prefix = $field_id_add != $field_id_name;
217
-
218
- // Activating field that previously existed in Types
219
- if ( array_key_exists( $field_id_add, $fields ) ) {
220
- $fields[$field_id_add]['data']['disabled'] = 0;
221
- } else { // Adding from outside
222
- $fields[$field_id_add]['id'] = $field_id_add;
223
- $fields[$field_id_add]['type'] = $field_type;
224
- if ($adding_field_with_wpcf_prefix) {
225
- $fields[$field_id_add]['name'] = $field_id_add;
226
- $fields[$field_id_add]['slug'] = $field_id_add;
227
- } else {
228
- $fields[$field_id_add]['name'] = $field_id_name;
229
- $fields[$field_id_add]['slug'] = $field_id_name;
230
- }
231
- $fields[$field_id_add]['description'] = '';
232
- $fields[$field_id_add]['data'] = array();
233
- if ($adding_field_with_wpcf_prefix) {
234
- // This was most probably a previous Types field
235
- // let's take full control
236
- $fields[$field_id_add]['data']['controlled'] = 0;
237
- } else {
238
- // @TODO WATCH THIS! MUST NOT BE DROPPED IN ANY CASE
239
- $fields[$field_id_add]['data']['controlled'] = 1;
240
- }
241
- }
242
- $unset_key = array_search( $field_id, $args['fields'] );
243
- if ( $unset_key !== false ) {
244
- unset( $args['fields'][$unset_key] );
245
- $args['fields'][$unset_key] = $field_id_add;
246
- }
247
- }
248
- }
249
- wpcf_admin_fields_save_fields( $fields, true, $meta_name );
250
- return $args['fields'];
251
- break;
252
-
253
- case 'check_exists':
254
- $fields = wpcf_admin_fields_get_fields( false, true, false,
255
- $meta_name, false );
256
- $field = $args;
257
- if ( array_key_exists( $field, $fields ) && empty( $fields[$field]['data']['disabled'] ) ) {
258
- return true;
259
- }
260
- return false;
261
- break;
262
-
263
- case 'check_outsider':
264
- $fields = wpcf_admin_fields_get_fields( false, true, false,
265
- $meta_name, false );
266
- $field = $args;
267
- if ( array_key_exists( $field, $fields ) && !empty( $fields[$field]['data']['controlled'] ) ) {
268
- return true;
269
- }
270
- return false;
271
- break;
272
-
273
- default:
274
- break;
275
- }
276
- }
277
-
278
- /**
279
- * Controlls meta prefix.
280
- *
281
- * @param array $field
282
- */
283
- function wpcf_types_get_meta_prefix( $field = array() ) {
284
- if ( empty( $field ) ) {
285
- return WPCF_META_PREFIX;
286
- }
287
- if ( !empty( $field['data']['controlled'] ) ) {
288
- return '';
289
- }
290
- return WPCF_META_PREFIX;
291
- }
292
-
293
- /**
294
- * Compares WP versions
295
- * @global type $wp_version
296
- * @param type $version
297
- * @param type $operator
298
- * @return type
299
- */
300
- function wpcf_compare_wp_version( $version = '3.2.1', $operator = '>' ) {
301
- global $wp_version;
302
- return version_compare( $wp_version, $version, $operator );
303
- }
304
-
305
- /**
306
- * Gets post type with data to which belongs.
307
- *
308
- * @param type $post_type
309
- * @return type
310
- */
311
- function wpcf_pr_get_belongs( $post_type ) {
312
- require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
313
- return wpcf_pr_admin_get_belongs( $post_type );
314
- }
315
-
316
- /**
317
- * Gets all post types and data that owns.
318
- *
319
- * @param type $post_type
320
- * @return type
321
- */
322
- function wpcf_pr_get_has( $post_type ) {
323
- require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
324
- return wpcf_pr_admin_get_has( $post_type );
325
- }
326
-
327
- /**
328
- * Gets individual post ID to which queried post belongs.
329
- *
330
- * @param type $post_id
331
- * @param type $post_type Post type of owner
332
- * @return type
333
- */
334
- function wpcf_pr_post_get_belongs( $post_id, $post_type ) {
335
- return get_post_meta( $post_id, '_wpcf_belongs_' . $post_type . '_id', true );
336
- }
337
-
338
- /**
339
- * Gets all posts that belong to queried post, grouped by post type.
340
- *
341
- * @param type $post_id
342
- * @param type $post_type
343
- * @return type
344
- */
345
- function wpcf_pr_post_get_has( $post_id, $post_type_q = null ) {
346
- $post_type = get_post_type( $post_id );
347
- $has = array_keys( wpcf_pr_get_has( $post_type ) );
348
- $add = is_null( $post_type_q ) ? '&post_type=any' : '&post_type=' . $post_type_q;
349
- $posts = get_posts( 'numberposts=-1&post_status=null&meta_key=_wpcf_belongs_'
350
- . $post_type . '_id&meta_value=' . $post_id . $add );
351
-
352
- $results = array();
353
- foreach ( $posts as $post ) {
354
- if ( !in_array( $post->post_type, $has ) ) {
355
- continue;
356
- }
357
- $results[$post->post_type][] = $post;
358
- }
359
- return is_null( $post_type_q ) ? $results : array_shift( $results );
360
- }
361
-
362
- /**
363
- * Gets settings.
364
- */
365
- function wpcf_get_settings( $specific = false ) {
366
- $defaults = array(
367
- 'add_resized_images_to_library' => 0,
368
- 'register_translations_on_import' => 1,
369
- 'images_remote' => 0,
370
- 'images_remote_cache_time' => '36',
371
- 'help_box' => 'by_types',
372
- );
373
- $settings = wp_parse_args( get_option( 'wpcf_settings', array() ), $defaults );
374
- $settings = apply_filters( 'types_settings', $settings );
375
- if ( $specific ) {
376
- return isset( $settings[$specific] ) ? $settings[$specific] : false;
377
- }
378
- return $settings;
379
- }
380
-
381
- /**
382
- * Saves settings.
383
- */
384
- function wpcf_save_settings( $settings ) {
385
- update_option( 'wpcf_settings', $settings );
386
- }
387
-
388
- /**
389
- * Check if it can be repetitive
390
- * @param type $field
391
- * @return type
392
- */
393
- function wpcf_admin_can_be_repetitive( $type ) {
394
- return !in_array( $type,
395
- array('checkbox', 'checkboxes', 'wysiwyg', 'radio', 'select') );
396
- }
397
-
398
- /**
399
- * Check if field is repetitive
400
- * @param type $type
401
- * @return type
402
- */
403
- function wpcf_admin_is_repetitive( $field ) {
404
- if ( !isset( $field['data']['repetitive'] ) || !isset( $field['type'] ) ) {
405
- return false;
406
- }
407
- $check = intval( $field['data']['repetitive'] );
408
- return !empty( $check ) && wpcf_admin_can_be_repetitive( $field['type'] );
409
- }
410
-
411
- /**
412
- * Returns unique ID.
413
- *
414
- * @staticvar array $cache
415
- * @param type $cache_key
416
- * @return type
417
- */
418
- function wpcf_unique_id( $cache_key ) {
419
- $cache_key = md5( strval( $cache_key ) . strval( time() ) . rand() );
420
- static $cache = array();
421
- if ( !isset( $cache[$cache_key] ) ) {
422
- $cache[$cache_key] = 1;
423
- } else {
424
- $cache[$cache_key] += 1;
425
- }
426
- return $cache_key . '-' . $cache[$cache_key];
427
- }
428
-
429
- /**
430
- * Determine if platform is Win
431
- *
432
- * @return type
433
- */
434
- function wpcf_is_windows() {
435
- global $wpcf;
436
- $is_windows = PHP_OS == "WIN32" || PHP_OS == "WINNT";
437
- if ( isset( $wpcf->debug ) ) {
438
- $wpcf->debug->is_windows = $is_windows;
439
- }
440
- return $is_windows;
441
- }
442
-
443
- /**
444
- * Parses array as string
445
- *
446
- * @param type $array
447
- */
448
- function wpcf_parse_array_to_string( $array ) {
449
- $s = '';
450
- foreach ( (array) $array as $param => $value ) {
451
- $s .= strval( $param ) . '=' . urlencode( strval( $value ) ) . '&';
452
- }
453
- return trim( $s, '&' );
454
- }
455
-
456
- /**
457
- * Get main post ID.
458
- *
459
- * @param type $context
460
- * @return type
461
- */
462
- function wpcf_get_post_id( $context = 'group' ) {
463
- if ( !is_admin() ) {
464
- /*
465
- *
466
- * TODO Check if frontend is fine (rendering children).
467
- * get_post() previously WP 3.5 requires $post_id
468
- */
469
- $post_id = null;
470
- if ( wpcf_compare_wp_version( '3.5', '<' ) ) {
471
- global $post;
472
- $post_id = !empty( $post->ID ) ? $post->ID : -1;
473
- }
474
- $_post = get_post( $post_id );
475
- return !empty( $_post->ID ) ? $_post->ID : -1;
476
- }
477
- /*
478
- * TODO Explore possible usage for $context
479
- */
480
- $post = wpcf_admin_get_edited_post();
481
- return empty( $post->ID ) ? -1 : $post->ID;
482
- }
483
-
484
- /**
485
- * Basic scripts
486
- */
487
- function wpcf_enqueue_scripts() {
488
-
489
- if ( !wpcf_is_embedded() ) {
490
- /*
491
- *
492
- * Basic JS
493
- */
494
- wp_enqueue_script( 'wpcf-js', WPCF_RES_RELPATH . '/js/basic.js',
495
- array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs'),
496
- WPCF_VERSION );
497
- /*
498
- *
499
- * Basic CSS
500
- */
501
- wp_enqueue_style( 'wpcf-css', WPCF_RES_RELPATH . '/css/basic.css',
502
- array(), WPCF_VERSION );
503
- }
504
- /*
505
- *
506
- * Basic JS
507
- */
508
- wp_enqueue_script( 'wpcf-js-embedded',
509
- WPCF_EMBEDDED_RES_RELPATH . '/js/basic.js',
510
- array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs'),
511
- WPCF_VERSION );
512
- /*
513
- *
514
- * Basic CSS
515
- */
516
- wp_enqueue_style( 'wpcf-css-embedded',
517
- WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION );
518
-
519
- /*
520
- *
521
- * Other components
522
- */
523
- if ( !defined( 'WPTOOLSET_FORMS_ABSPATH' ) ) {
524
- // Repetitive
525
- wp_enqueue_script(
526
- 'wpcf-repeater',
527
- WPCF_EMBEDDED_RES_RELPATH . '/js/repetitive.js',
528
- array('wpcf-js-embedded'), WPCF_VERSION
529
- );
530
- wp_enqueue_style(
531
- 'wpcf-repeater',
532
- WPCF_EMBEDDED_RES_RELPATH . '/css/repetitive.css',
533
- array('wpcf-css-embedded'), WPCF_VERSION
534
- );
535
- }
536
-
537
- // Conditional
538
- wp_enqueue_script( 'types-conditional' );
539
- wpcf_admin_add_js_settings( 'wpcfConditionalVerify_nonce',
540
- wp_create_nonce( 'cd_verify' )
541
- );
542
- wpcf_admin_add_js_settings( 'wpcfConditionalVerifyGroup',
543
- wp_create_nonce( 'cd_group_verify' ) );
544
-
545
- // RTL
546
- if ( is_rtl() ) {
547
- wp_enqueue_style(
548
- 'wpcf-rtl', WPCF_EMBEDDED_RES_RELPATH . '/css/rtl.css',
549
- array('wpcf-css-embedded'), WPCF_VERSION
550
- );
551
- }
552
- }
553
-
554
- /**
555
- * Load all scripts required on edit post screen.
556
- *
557
- * @since 1.2.1
558
- * @todo Make loading JS more clear for all components.
559
- */
560
- function wpcf_edit_post_screen_scripts() {
561
- wpcf_enqueue_scripts();
562
- wp_enqueue_script( 'wpcf-fields-post',
563
- WPCF_EMBEDDED_RES_RELPATH . '/js/fields-post.js', array('jquery'),
564
- WPCF_VERSION );
565
- // TODO Switch to 1.11.1 jQuery Validation
566
- // wp_enqueue_script( 'types-js-validation' );
567
- if ( !defined( 'WPTOOLSET_FORMS_ABSPATH' ) ) {
568
- wp_enqueue_script( 'wpcf-form-validation',
569
- WPCF_EMBEDDED_RES_RELPATH . '/js/'
570
- . 'jquery-form-validation/jquery.validate.js', array('jquery'),
571
- WPCF_VERSION );
572
- wp_enqueue_script( 'wpcf-form-validation-additional',
573
- WPCF_EMBEDDED_RES_RELPATH . '/js/'
574
- . 'jquery-form-validation/additional-methods.min.js',
575
- array('jquery'), WPCF_VERSION );
576
- }
577
- wp_enqueue_style( 'wpcf-fields-basic',
578
- WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION );
579
- wp_enqueue_style( 'wpcf-fields-post',
580
- WPCF_EMBEDDED_RES_RELPATH . '/css/fields-post.css',
581
- array('wpcf-fields-basic'), WPCF_VERSION );
582
- wp_enqueue_style( 'wpcf-usermeta',
583
- WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css',
584
- array('wpcf-fields-basic'), WPCF_VERSION );
585
- wp_enqueue_script( 'toolset-colorbox' );
586
- wp_enqueue_style( 'toolset-colorbox' );
587
- wp_enqueue_style( 'toolset-font-awesome' );
588
- }
589
-
590
- /**
591
- * Check if running embedded version.
592
- *
593
- * @return type
594
- */
595
- function wpcf_is_embedded() {
596
- return defined( 'WPCF_RUNNING_EMBEDDED' ) && WPCF_RUNNING_EMBEDDED;
597
- }
598
-
599
- /**
600
- * Returns custom post type settings.
601
- *
602
- * @param type $post_type
603
- * @return type
604
- */
605
- function wpcf_get_custom_post_type_settings( $item ) {
606
- $custom = get_option( 'wpcf-custom-types', array() );
607
- return !empty( $custom[$item] ) ? $custom[$item] : array();
608
- }
609
-
610
- /**
611
- * Returns taxonomy settings.
612
- *
613
- * @param type $taxonomy
614
- * @return type
615
- */
616
- function wpcf_get_custom_taxonomy_settings( $item ) {
617
- $custom = get_option( 'wpcf-custom-taxonomies', array() );
618
- return !empty( $custom[$item] ) ? $custom[$item] : array();
619
- }
620
-
621
- /**
622
- * Load JS and CSS for field type.
623
- *
624
- * Core function. Works and stable. Do not move or change.
625
- * If required, add hooks only.
626
- *
627
- * @staticvar array $cache
628
- * @param string $type
629
- * @return string
630
- */
631
- function wpcf_field_enqueue_scripts( $type ) {
632
-
633
- global $wpcf;
634
- static $cache = array();
635
-
636
- $config = wpcf_fields_type_action( $type );
637
-
638
- if ( !empty( $config ) ) {
639
-
640
- // Check if cached
641
- if ( isset( $cache[$config['id']] ) ) {
642
- return $cache[$config['id']];
643
- }
644
-
645
- // Use field object
646
- $wpcf->field->enqueue_script( $config );
647
- $wpcf->field->enqueue_style( $config );
648
-
649
- $cache[$config['id']] = $config;
650
-
651
- return $config;
652
- } else {
653
- $wpcf->debug->errors['missing_type_config'][] = $type;
654
- return array();
655
- }
656
-
657
- }
658
-
659
- /**
660
- * Get file URL.
661
- *
662
- * @uses WPCF_Path (functions taken from CRED_Loader)
663
- * @param type $file
664
- * @return type
665
- */
666
- function wpcf_get_file_url( $file, $use_baseurl = true ) {
667
- WPCF_Loader::loadClass( 'path' );
668
- return WPCF_Path::getFileUrl( $file, $use_baseurl );
669
- }
670
-
671
- /**
672
- * Checks if timestamp supports negative values.
673
- *
674
- * @return type
675
- */
676
- function fields_date_timestamp_neg_supported() {
677
- return strtotime( 'Fri, 13 Dec 1950 20:45:54 UTC' ) === -601010046;
678
- }
679
-
680
- /**
681
- * Returns media size.
682
- *
683
- * @global type $content_width
684
- * @param type $widescreen
685
- * @return type
686
- */
687
- function wpcf_media_size( $widescreen = false ) {
688
- global $content_width;
689
- if ( !empty( $content_width ) ) {
690
- $height = $widescreen ? round( $content_width * 9 / 16 ) : round( $content_width * 3 / 4 );
691
- return array($content_width, $height);
692
- }
693
- return $widescreen ? array(450, 253) : array(450, 320);
694
- }
695
-
696
- /**
697
- * Validation wrapper.
698
- *
699
- * @param type $method
700
- * @param type $args
701
- * @return boolean
702
- */
703
- function types_validate( $method, $args ) {
704
- WPCF_Loader::loadClass( 'validation-cakephp' );
705
- if ( is_callable( array('Wpcf_Cake_Validation', $method) ) ) {
706
- if ( !is_array( $args ) ) {
707
- $args = array($args);
708
- }
709
- return @call_user_func_array( array('Wpcf_Cake_Validation', $method),
710
- $args );
711
- }
712
- return false;
713
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
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/embedded/functions.php $
7
+ * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
8
+ * $LastChangedRevision: 1069430 $
9
+ * $LastChangedBy: iworks $
10
+ *
11
+ */
12
+
13
+ /**
14
+ * Caches get_post_meta() calls.
15
+ *
16
+ * @staticvar array $cache
17
+ * @param type $post_id
18
+ * @param type $meta_key
19
+ * @param type $single
20
+ * @return string
21
+ */
22
+ function wpcf_get_post_meta($post_id, $meta_key, $single)
23
+ {
24
+ static $cache = array();
25
+
26
+ if ( !isset( $cache[$post_id] ) ) {
27
+ $cache[$post_id] = get_post_custom( $post_id );
28
+ }
29
+ if ( isset( $cache[$post_id][$meta_key] ) ) {
30
+ if ( $single && isset( $cache[$post_id][$meta_key][0] ) ) {
31
+ return maybe_unserialize( $cache[$post_id][$meta_key][0] );
32
+ } elseif ( !$single && !empty( $cache[$post_id][$meta_key] ) ) {
33
+ return maybe_unserialize( $cache[$post_id][$meta_key] );
34
+ }
35
+ }
36
+ return '';
37
+ }
38
+
39
+ /**
40
+ * Calculates relative path for given file.
41
+ *
42
+ * @param type $file Absolute path to file
43
+ * @return string Relative path
44
+ */
45
+ function wpcf_get_file_relpath($file)
46
+ {
47
+ $is_https = isset( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) == 'on';
48
+ $http_protocol = $is_https ? 'https' : 'http';
49
+ $base_root = $http_protocol . '://' . $_SERVER['HTTP_HOST'];
50
+ $base_url = $base_root;
51
+ $dir = rtrim( dirname( $file ), '\/' );
52
+ if ( $dir ) {
53
+ $base_path = $dir;
54
+ $base_url .= $base_path;
55
+ $base_path .= '/';
56
+ } else {
57
+ $base_path = '/';
58
+ }
59
+ $relpath = $base_root
60
+ . str_replace(
61
+ str_replace( '\\', '/',
62
+ realpath( $_SERVER['DOCUMENT_ROOT'] ) )
63
+ , '', str_replace( '\\', '/', dirname( $file ) )
64
+ );
65
+ return $relpath;
66
+ }
67
+
68
+ /**
69
+ * after_setup_theme hook.
70
+ */
71
+ function wpcf_embedded_after_setup_theme_hook()
72
+ {
73
+ $custom_types = get_option( 'wpcf-custom-types', array() );
74
+ if ( !empty( $custom_types ) ) {
75
+ foreach ( $custom_types as $post_type => $data ) {
76
+ if ( !empty( $data['supports']['thumbnail'] ) ) {
77
+ if ( !current_theme_supports( 'post-thumbnails' ) ) {
78
+ add_theme_support( 'post-thumbnails' );
79
+ remove_post_type_support( 'post', 'thumbnail' );
80
+ remove_post_type_support( 'page', 'thumbnail' );
81
+ } else {
82
+ add_post_type_support( $post_type, 'thumbnail' );
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Inits custom types and taxonomies.
91
+ */
92
+ function wpcf_init_custom_types_taxonomies()
93
+ {
94
+ $custom_taxonomies = get_option( 'wpcf-custom-taxonomies', array() );
95
+ if ( !empty( $custom_taxonomies ) ) {
96
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
97
+ wpcf_custom_taxonomies_init();
98
+ }
99
+ $custom_types = get_option( 'wpcf-custom-types', array() );
100
+ if ( !empty( $custom_types ) ) {
101
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-types.php';
102
+ wpcf_custom_types_init();
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Returns meta_key type for specific field type.
108
+ *
109
+ * @param type $type
110
+ * @return type
111
+ */
112
+ function types_get_field_type($type)
113
+ {
114
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
115
+ $data = wpcf_fields_type_action( $type );
116
+ if ( !empty( $data['meta_key_type'] ) ) {
117
+ return $data['meta_key_type'];
118
+ }
119
+ return 'CHAR';
120
+ }
121
+
122
+ /**
123
+ * Imports settings.
124
+ */
125
+ function wpcf_embedded_check_import()
126
+ {
127
+ if ( file_exists( WPCF_EMBEDDED_ABSPATH . '/settings.php' ) ) {
128
+ require_once WPCF_EMBEDDED_ABSPATH . '/admin.php';
129
+ require_once WPCF_EMBEDDED_ABSPATH . '/settings.php';
130
+ $dismissed = get_option( 'wpcf_dismissed_messages', array() );
131
+ if ( in_array( $timestamp, $dismissed ) ) {
132
+ return false;
133
+ }
134
+ if ( $timestamp > get_option( 'wpcf-types-embedded-import', 0 ) ) {
135
+ if ( !$auto_import ) {
136
+ $link = "<a href=\"" . admin_url( '?types-embedded-import=1&amp;_wpnonce=' . wp_create_nonce( 'embedded-import' ) ) . "\">";
137
+ $text = sprintf( __( 'You have Types import pending. %sClick here to import.%s %sDismiss message.%s',
138
+ 'wpcf' ), $link, '</a>',
139
+ "<a onclick=\"jQuery(this).parent().parent().fadeOut();\" class=\"wpcf-ajax-link\" href=\""
140
+ . admin_url( 'admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=dismiss_message&amp;id='
141
+ . $timestamp . '&amp;_wpnonce=' . wp_create_nonce( 'dismiss_message' ) ) . "\">",
142
+ '</a>' );
143
+ wpcf_admin_message( $text );
144
+ }
145
+ if ( $auto_import || (isset( $_GET['types-embedded-import'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'],
146
+ 'embedded-import' )) ) {
147
+ if ( file_exists( WPCF_EMBEDDED_ABSPATH . '/settings.xml' ) ) {
148
+ $_POST['overwrite-groups'] = 1;
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';
159
+ $data = @file_get_contents( WPCF_EMBEDDED_ABSPATH . '/settings.xml' );
160
+ wpcf_admin_import_data( $data, false, 'types-auto-import' );
161
+ update_option( 'wpcf-types-embedded-import', $timestamp );
162
+ wp_redirect( admin_url() );
163
+ } else {
164
+ $code = __( 'settings.xml file missing', 'wpcf' );
165
+ wpcf_admin_message( $code, 'error' );
166
+ }
167
+ }
168
+ }
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
+ *
207
+ * @param type $action
208
+ */
209
+ function wpcf_types_cf_under_control( $action = 'add', $args = array(),
210
+ $post_type = 'wp-types-group', $meta_name = 'wpcf-fields' ) {
211
+ global $wpcf_types_under_control;
212
+ $wpcf_types_under_control['errors'] = array();
213
+ switch ( $action ) {
214
+ case 'add':
215
+ $fields = wpcf_admin_fields_get_fields( false, true, false,
216
+ $meta_name, false );
217
+ foreach ( $args['fields'] as $field_id ) {
218
+ $field_type = !empty( $args['type'] ) ? $args['type'] : 'textfield';
219
+ if ( strpos( $field_id, md5( 'wpcf_not_controlled' ) ) !== false ) {
220
+ $field_id_name = str_replace( '_' . md5( 'wpcf_not_controlled' ), '', $field_id );
221
+ $field_id_add = preg_replace( '/^wpcf\-/', '', $field_id_name );
222
+ $adding_field_with_wpcf_prefix = $field_id_add != $field_id_name;
223
+
224
+ // Activating field that previously existed in Types
225
+ if ( array_key_exists( $field_id_add, $fields ) ) {
226
+ $fields[$field_id_add]['data']['disabled'] = 0;
227
+ } else { // Adding from outside
228
+ $fields[$field_id_add]['id'] = $field_id_add;
229
+ $fields[$field_id_add]['type'] = $field_type;
230
+ if ($adding_field_with_wpcf_prefix) {
231
+ $fields[$field_id_add]['name'] = $field_id_add;
232
+ $fields[$field_id_add]['slug'] = $field_id_add;
233
+ } else {
234
+ $fields[$field_id_add]['name'] = $field_id_name;
235
+ $fields[$field_id_add]['slug'] = $field_id_name;
236
+ }
237
+ $fields[$field_id_add]['description'] = '';
238
+ $fields[$field_id_add]['data'] = array();
239
+ if ($adding_field_with_wpcf_prefix) {
240
+ // This was most probably a previous Types field
241
+ // let's take full control
242
+ $fields[$field_id_add]['data']['controlled'] = 0;
243
+ } else {
244
+ // @TODO WATCH THIS! MUST NOT BE DROPPED IN ANY CASE
245
+ $fields[$field_id_add]['data']['controlled'] = 1;
246
+ }
247
+ }
248
+ $unset_key = array_search( $field_id, $args['fields'] );
249
+ if ( $unset_key !== false ) {
250
+ unset( $args['fields'][$unset_key] );
251
+ $args['fields'][$unset_key] = $field_id_add;
252
+ }
253
+ }
254
+ }
255
+ wpcf_admin_fields_save_fields( $fields, true, $meta_name );
256
+ return $args['fields'];
257
+ break;
258
+
259
+ case 'check_exists':
260
+ $fields = wpcf_admin_fields_get_fields( false, true, false,
261
+ $meta_name, false );
262
+ $field = $args;
263
+ if ( array_key_exists( $field, $fields ) && empty( $fields[$field]['data']['disabled'] ) ) {
264
+ return true;
265
+ }
266
+ return false;
267
+ break;
268
+
269
+ case 'check_outsider':
270
+ $fields = wpcf_admin_fields_get_fields( false, true, false,
271
+ $meta_name, false );
272
+ $field = $args;
273
+ if ( array_key_exists( $field, $fields ) && !empty( $fields[$field]['data']['controlled'] ) ) {
274
+ return true;
275
+ }
276
+ return false;
277
+ break;
278
+
279
+ default:
280
+ break;
281
+ }
282
+ }
283
+
284
+ /**
285
+ * Controlls meta prefix.
286
+ *
287
+ * @param array $field
288
+ */
289
+ function wpcf_types_get_meta_prefix( $field = array() )
290
+ {
291
+ if ( empty( $field ) ) {
292
+ return WPCF_META_PREFIX;
293
+ }
294
+ if ( !empty( $field['data']['controlled'] ) ) {
295
+ return '';
296
+ }
297
+ return WPCF_META_PREFIX;
298
+ }
299
+
300
+ /**
301
+ * Compares WP versions
302
+ * @global type $wp_version
303
+ * @param type $version
304
+ * @param type $operator
305
+ * @return type
306
+ */
307
+ function wpcf_compare_wp_version($version = '3.2.1', $operator = '>')
308
+ {
309
+ global $wp_version;
310
+ return version_compare( $wp_version, $version, $operator );
311
+ }
312
+
313
+ /**
314
+ * Gets post type with data to which belongs.
315
+ *
316
+ * @param type $post_type
317
+ * @return type
318
+ */
319
+ function wpcf_pr_get_belongs($post_type)
320
+ {
321
+ require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
322
+ return wpcf_pr_admin_get_belongs( $post_type );
323
+ }
324
+
325
+ /**
326
+ * Gets all post types and data that owns.
327
+ *
328
+ * @param type $post_type
329
+ * @return type
330
+ */
331
+ function wpcf_pr_get_has($post_type)
332
+ {
333
+ require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
334
+ return wpcf_pr_admin_get_has( $post_type );
335
+ }
336
+
337
+ /**
338
+ * Gets individual post ID to which queried post belongs.
339
+ *
340
+ * @param type $post_id
341
+ * @param type $post_type Post type of owner
342
+ * @return type
343
+ */
344
+ function wpcf_pr_post_get_belongs($post_id, $post_type)
345
+ {
346
+ return get_post_meta( $post_id, '_wpcf_belongs_' . $post_type . '_id', true );
347
+ }
348
+
349
+ /**
350
+ * Gets all posts that belong to queried post, grouped by post type.
351
+ *
352
+ * @param type $post_id
353
+ * @param type $post_type
354
+ * @return type
355
+ */
356
+ function wpcf_pr_post_get_has($post_id, $post_type_q = null)
357
+ {
358
+ $post_type = get_post_type( $post_id );
359
+ $has = array_keys( wpcf_pr_get_has( $post_type ) );
360
+ $add = is_null( $post_type_q ) ? '&post_type=any' : '&post_type=' . $post_type_q;
361
+ $posts = get_posts( 'numberposts=-1&post_status=null&meta_key=_wpcf_belongs_'
362
+ . $post_type . '_id&meta_value=' . $post_id . $add );
363
+
364
+ $results = array();
365
+ foreach ( $posts as $post ) {
366
+ if ( !in_array( $post->post_type, $has ) ) {
367
+ continue;
368
+ }
369
+ $results[$post->post_type][] = $post;
370
+ }
371
+ return is_null( $post_type_q ) ? $results : array_shift( $results );
372
+ }
373
+
374
+ /**
375
+ * Gets settings.
376
+ */
377
+ function wpcf_get_settings($specific = false)
378
+ {
379
+ $defaults = array(
380
+ 'add_resized_images_to_library' => 0,
381
+ 'register_translations_on_import' => 1,
382
+ 'images_remote' => 0,
383
+ 'images_remote_cache_time' => '36',
384
+ 'help_box' => 'by_types',
385
+ );
386
+ $settings = wp_parse_args( get_option( 'wpcf_settings', array() ), $defaults );
387
+ $settings = apply_filters( 'types_settings', $settings );
388
+ if ( $specific ) {
389
+ return isset( $settings[$specific] ) ? $settings[$specific] : false;
390
+ }
391
+ return $settings;
392
+ }
393
+
394
+ /**
395
+ * Saves settings.
396
+ */
397
+ function wpcf_save_settings($settings)
398
+ {
399
+ update_option( 'wpcf_settings', $settings );
400
+ }
401
+
402
+ /**
403
+ * Check if it can be repetitive
404
+ * @param type $field
405
+ * @return type
406
+ */
407
+ function wpcf_admin_can_be_repetitive($type)
408
+ {
409
+ return !in_array( $type,
410
+ array('checkbox', 'checkboxes', 'wysiwyg', 'radio', 'select') );
411
+ }
412
+
413
+ /**
414
+ * Check if field is repetitive
415
+ * @param type $type
416
+ * @return type
417
+ */
418
+ function wpcf_admin_is_repetitive($field)
419
+ {
420
+ if ( !isset( $field['data']['repetitive'] ) || !isset( $field['type'] ) ) {
421
+ return false;
422
+ }
423
+ $check = intval( $field['data']['repetitive'] );
424
+ return !empty( $check ) && wpcf_admin_can_be_repetitive( $field['type'] );
425
+ }
426
+
427
+ /**
428
+ * Returns unique ID.
429
+ *
430
+ * @staticvar array $cache
431
+ * @param type $cache_key
432
+ * @return type
433
+ */
434
+ function wpcf_unique_id($cache_key)
435
+ {
436
+ $cache_key = md5( strval( $cache_key ) . strval( time() ) . rand() );
437
+ static $cache = array();
438
+ if ( !isset( $cache[$cache_key] ) ) {
439
+ $cache[$cache_key] = 1;
440
+ } else {
441
+ $cache[$cache_key] += 1;
442
+ }
443
+ return $cache_key . '-' . $cache[$cache_key];
444
+ }
445
+
446
+ /**
447
+ * Determine if platform is Win
448
+ *
449
+ * @return type
450
+ */
451
+ function wpcf_is_windows()
452
+ {
453
+ global $wpcf;
454
+ $is_windows = PHP_OS == "WIN32" || PHP_OS == "WINNT";
455
+ if ( isset( $wpcf->debug ) ) {
456
+ $wpcf->debug->is_windows = $is_windows;
457
+ }
458
+ return $is_windows;
459
+ }
460
+
461
+ /**
462
+ * Parses array as string
463
+ *
464
+ * @param type $array
465
+ */
466
+ function wpcf_parse_array_to_string($array)
467
+ {
468
+ $s = '';
469
+ foreach ( (array) $array as $param => $value ) {
470
+ $s .= strval( $param ) . '=' . urlencode( strval( $value ) ) . '&';
471
+ }
472
+ return trim( $s, '&' );
473
+ }
474
+
475
+ /**
476
+ * Get main post ID.
477
+ *
478
+ * @param type $context
479
+ * @return type
480
+ */
481
+ function wpcf_get_post_id($context = 'group')
482
+ {
483
+ if ( !is_admin() ) {
484
+ /*
485
+ *
486
+ * TODO Check if frontend is fine (rendering children).
487
+ * get_post() previously WP 3.5 requires $post_id
488
+ */
489
+ $post_id = null;
490
+ if ( wpcf_compare_wp_version( '3.5', '<' ) ) {
491
+ global $post;
492
+ $post_id = !empty( $post->ID ) ? $post->ID : -1;
493
+ }
494
+ $_post = get_post( $post_id );
495
+ return !empty( $_post->ID ) ? $_post->ID : -1;
496
+ }
497
+ /*
498
+ * TODO Explore possible usage for $context
499
+ */
500
+ $post = wpcf_admin_get_edited_post();
501
+ return empty( $post->ID ) ? -1 : $post->ID;
502
+ }
503
+
504
+ /**
505
+ * Basic scripts
506
+ */
507
+ function wpcf_enqueue_scripts()
508
+ {
509
+ if ( !wpcf_is_embedded() ) {
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
523
+ */
524
+ wp_enqueue_script(
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
+ *
532
+ * Basic CSS
533
+ */
534
+ wp_enqueue_style( 'wpcf-css-embedded' );
535
+
536
+ /*
537
+ *
538
+ * Other components
539
+ */
540
+ if ( !defined( 'WPTOOLSET_FORMS_ABSPATH' ) ) {
541
+ // Repetitive
542
+ wp_enqueue_script(
543
+ 'wpcf-repeater',
544
+ WPCF_EMBEDDED_RES_RELPATH . '/js/repetitive.js',
545
+ array('wpcf-js-embedded'), WPCF_VERSION
546
+ );
547
+ wp_enqueue_style(
548
+ 'wpcf-repeater',
549
+ WPCF_EMBEDDED_RES_RELPATH . '/css/repetitive.css',
550
+ array('wpcf-css-embedded'), WPCF_VERSION
551
+ );
552
+ }
553
+
554
+ // Conditional
555
+ wp_enqueue_script( 'types-conditional' );
556
+ wpcf_admin_add_js_settings( 'wpcfConditionalVerify_nonce',
557
+ wp_create_nonce( 'cd_verify' )
558
+ );
559
+ wpcf_admin_add_js_settings( 'wpcfConditionalVerifyGroup',
560
+ wp_create_nonce( 'cd_group_verify' ) );
561
+
562
+ // RTL
563
+ if ( is_rtl() ) {
564
+ wp_enqueue_style(
565
+ 'wpcf-rtl', WPCF_EMBEDDED_RES_RELPATH . '/css/rtl.css',
566
+ array('wpcf-css-embedded'), WPCF_VERSION
567
+ );
568
+ }
569
+ }
570
+
571
+ /**
572
+ * Load all scripts required on edit post screen.
573
+ *
574
+ * @since 1.2.1
575
+ * @todo Make loading JS more clear for all components.
576
+ */
577
+ function wpcf_edit_post_screen_scripts()
578
+ {
579
+ wpcf_enqueue_scripts();
580
+ wp_enqueue_script( 'wpcf-fields-post',
581
+ WPCF_EMBEDDED_RES_RELPATH . '/js/fields-post.js', array('jquery'),
582
+ WPCF_VERSION );
583
+ // TODO Switch to 1.11.1 jQuery Validation
584
+ // wp_enqueue_script( 'types-js-validation' );
585
+ if ( !defined( 'WPTOOLSET_FORMS_ABSPATH' ) ) {
586
+ wp_enqueue_script( 'wpcf-form-validation',
587
+ WPCF_EMBEDDED_RES_RELPATH . '/js/'
588
+ . 'jquery-form-validation/jquery.validate.js', array('jquery'),
589
+ WPCF_VERSION );
590
+ wp_enqueue_script( 'wpcf-form-validation-additional',
591
+ WPCF_EMBEDDED_RES_RELPATH . '/js/'
592
+ . 'jquery-form-validation/additional-methods.min.js',
593
+ array('jquery'), WPCF_VERSION );
594
+ }
595
+ wp_enqueue_style( 'wpcf-fields-basic',
596
+ WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION );
597
+ wp_enqueue_style( 'wpcf-fields-post',
598
+ WPCF_EMBEDDED_RES_RELPATH . '/css/fields-post.css',
599
+ array('wpcf-fields-basic'), WPCF_VERSION );
600
+ wp_enqueue_style( 'wpcf-usermeta',
601
+ WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css',
602
+ array('wpcf-fields-basic'), WPCF_VERSION );
603
+ wp_enqueue_script( 'toolset-colorbox' );
604
+ wp_enqueue_style( 'toolset-colorbox' );
605
+ wp_enqueue_style( 'toolset-font-awesome' );
606
+ }
607
+
608
+ /**
609
+ * Check if running embedded version.
610
+ *
611
+ * @return type
612
+ */
613
+ function wpcf_is_embedded()
614
+ {
615
+ return defined( 'WPCF_RUNNING_EMBEDDED' ) && WPCF_RUNNING_EMBEDDED;
616
+ }
617
+
618
+ /**
619
+ * Returns custom post type settings.
620
+ *
621
+ * @param type $post_type
622
+ * @return type
623
+ */
624
+ function wpcf_get_custom_post_type_settings($item)
625
+ {
626
+ $custom = get_option( 'wpcf-custom-types', array() );
627
+ return !empty( $custom[$item] ) ? $custom[$item] : array();
628
+ }
629
+
630
+ /**
631
+ * Returns taxonomy settings.
632
+ *
633
+ * @param type $taxonomy
634
+ * @return type
635
+ */
636
+ function wpcf_get_custom_taxonomy_settings($item)
637
+ {
638
+ $custom = get_option( 'wpcf-custom-taxonomies', array() );
639
+ return !empty( $custom[$item] ) ? $custom[$item] : array();
640
+ }
641
+
642
+ /**
643
+ * Load JS and CSS for field type.
644
+ *
645
+ * Core function. Works and stable. Do not move or change.
646
+ * If required, add hooks only.
647
+ *
648
+ * @staticvar array $cache
649
+ * @param string $type
650
+ * @return string
651
+ */
652
+ function wpcf_field_enqueue_scripts($type)
653
+ {
654
+ global $wpcf;
655
+ static $cache = array();
656
+
657
+ $config = wpcf_fields_type_action( $type );
658
+
659
+ if ( !empty( $config ) ) {
660
+
661
+ // Check if cached
662
+ if ( isset( $cache[$config['id']] ) ) {
663
+ return $cache[$config['id']];
664
+ }
665
+
666
+ // Use field object
667
+ $wpcf->field->enqueue_script( $config );
668
+ $wpcf->field->enqueue_style( $config );
669
+
670
+ $cache[$config['id']] = $config;
671
+
672
+ return $config;
673
+ } else {
674
+ $wpcf->debug->errors['missing_type_config'][] = $type;
675
+ return array();
676
+ }
677
+
678
+ }
679
+
680
+ /**
681
+ * Get file URL.
682
+ *
683
+ * @uses WPCF_Path (functions taken from CRED_Loader)
684
+ * @param type $file
685
+ * @return type
686
+ */
687
+ function wpcf_get_file_url($file, $use_baseurl = true)
688
+ {
689
+ WPCF_Loader::loadClass( 'path' );
690
+ return WPCF_Path::getFileUrl( $file, $use_baseurl );
691
+ }
692
+
693
+ /**
694
+ * Checks if timestamp supports negative values.
695
+ *
696
+ * @return type
697
+ */
698
+ function fields_date_timestamp_neg_supported()
699
+ {
700
+ return strtotime( 'Fri, 13 Dec 1950 20:45:54 UTC' ) === -601010046;
701
+ }
702
+
703
+ /**
704
+ * Returns media size.
705
+ *
706
+ * @global type $content_width
707
+ * @param type $widescreen
708
+ * @return type
709
+ */
710
+ function wpcf_media_size($widescreen = false)
711
+ {
712
+ global $content_width;
713
+ if ( !empty( $content_width ) ) {
714
+ $height = $widescreen ? round( $content_width * 9 / 16 ) : round( $content_width * 3 / 4 );
715
+ return array($content_width, $height);
716
+ }
717
+ return $widescreen ? array(450, 253) : array(450, 320);
718
+ }
719
+
720
+ /**
721
+ * Validation wrapper.
722
+ *
723
+ * @param type $method
724
+ * @param type $args
725
+ * @return boolean
726
+ */
727
+ function types_validate($method, $args)
728
+ {
729
+ WPCF_Loader::loadClass( 'validation-cakephp' );
730
+ if ( is_callable( array('Wpcf_Cake_Validation', $method) ) ) {
731
+ if ( !is_array( $args ) ) {
732
+ $args = array($args);
733
+ }
734
+ return @call_user_func_array( array('Wpcf_Cake_Validation', $method),
735
+ $args );
736
+ }
737
+ return false;
738
+ }
embedded/includes/ajax.php CHANGED
@@ -98,7 +98,9 @@ function wpcf_ajax_embedded() {
98
  $id = $wpcf->relationship->add_new_child( $post->ID,
99
  $post_type );
100
 
101
- if ( !is_wp_error( $id ) ) {
 
 
102
  /*
103
  * Here we set Relationship
104
  * CHECKPOINT
@@ -120,8 +122,6 @@ function wpcf_ajax_embedded() {
120
  $output = __( 'Error creating post relationship',
121
  'wpcf' );
122
  }
123
- } else {
124
- $output = $id->get_error_message();
125
  }
126
  } else {
127
  $output = __( 'Error getting parent post', 'wpcf' );
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();
103
+ } else {
104
  /*
105
  * Here we set Relationship
106
  * CHECKPOINT
122
  $output = __( 'Error creating post relationship',
123
  'wpcf' );
124
  }
 
 
125
  }
126
  } else {
127
  $output = __( 'Error getting parent post', 'wpcf' );
embedded/includes/custom-types.php CHANGED
@@ -3,7 +3,7 @@
3
  *
4
  * Custom Post Types embedded code.
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/includes/custom-types.php $
7
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
  * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
3
  *
4
  * Custom Post Types embedded code.
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/embedded/includes/custom-types.php $
7
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
  * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
embedded/includes/fields-post.php CHANGED
@@ -4,7 +4,7 @@
4
  * Edit post page functions
5
  *
6
  *
7
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/includes/fields-post.php $
8
  * $LastChangedDate: 2014-10-29 15:57:36 +0000 (Wed, 29 Oct 2014) $
9
  * $LastChangedRevision: 1016002 $
10
  * $LastChangedBy: iworks $
4
  * Edit post page functions
5
  *
6
  *
7
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/embedded/includes/fields-post.php $
8
  * $LastChangedDate: 2014-10-29 15:57:36 +0000 (Wed, 29 Oct 2014) $
9
  * $LastChangedRevision: 1016002 $
10
  * $LastChangedBy: iworks $
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.4/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.5/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.4/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.5/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/file.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/includes/fields/file.php $
5
  * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
6
  * $LastChangedRevision: 970205 $
7
  * $LastChangedBy: brucepearson $
1
  <?php
2
  /*
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/embedded/includes/fields/file.php $
5
  * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
6
  * $LastChangedRevision: 970205 $
7
  * $LastChangedBy: brucepearson $
embedded/includes/fields/image.php CHANGED
@@ -1,15 +1,15 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/includes/fields/image.php $
5
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
- * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
 
10
  add_filter( 'wpcf_fields_type_image_value_get', 'wpcf_fields_image_value_filter' );
11
- add_filter( 'wpcf_fields_type_image_value_save',
12
- 'wpcf_fields_image_value_filter' );
13
 
14
  // Do not wrap if 'url' is TRUE
15
  add_filter( 'types_view', 'wpcf_fields_image_view_filter', 10, 6 );
@@ -585,7 +585,9 @@ function wpcf_fields_image_get_data( $image ) {
585
  );
586
 
587
  // Strip GET vars
588
- $image = strtok( $image, '?' );
 
 
589
 
590
  // Basic URL check
591
  if ( strpos( $image, 'http' ) != 0 ) {
@@ -661,9 +663,10 @@ function wpcf_fields_image_get_data( $image ) {
661
  * @return type
662
  */
663
  function wpcf_fields_image_value_filter( $value ) {
664
- if ( is_string( $value ) ) {
665
  return strtok( $value, '?' );
666
  }
 
667
  }
668
 
669
  /**
1
  <?php
2
  /**
3
  *
4
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
10
+
11
  add_filter( 'wpcf_fields_type_image_value_get', 'wpcf_fields_image_value_filter' );
12
+ add_filter( 'wpcf_fields_type_image_value_save', 'wpcf_fields_image_value_filter' );
 
13
 
14
  // Do not wrap if 'url' is TRUE
15
  add_filter( 'types_view', 'wpcf_fields_image_view_filter', 10, 6 );
585
  );
586
 
587
  // Strip GET vars
588
+ if ( !apply_filters('wpcf_allow_questionmark_in_image_url', false) ) {
589
+ $image = strtok( $image, '?' );
590
+ }
591
 
592
  // Basic URL check
593
  if ( strpos( $image, 'http' ) != 0 ) {
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) ) {
667
  return strtok( $value, '?' );
668
  }
669
+ return $value;
670
  }
671
 
672
  /**
embedded/includes/fields/skype.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/includes/fields/skype.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.5/embedded/includes/fields/skype.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
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.4/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.5/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,7 +1,7 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/includes/fields/video.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.5/embedded/includes/fields/video.php $
5
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
6
  * $LastChangedRevision: 1027712 $
7
  * $LastChangedBy: iworks $
embedded/includes/import-export.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Import/export data.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/includes/import-export.php $
6
  * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
7
  * $LastChangedRevision: 970205 $
8
  * $LastChangedBy: brucepearson $
2
  /*
3
  * Import/export data.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/embedded/includes/import-export.php $
6
  * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
7
  * $LastChangedRevision: 970205 $
8
  * $LastChangedBy: brucepearson $
embedded/includes/module-manager.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * Since Types 1.2
6
  *
7
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/includes/module-manager.php $
8
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
9
  * $LastChangedRevision: 1027712 $
10
  * $LastChangedBy: iworks $
4
  *
5
  * Since Types 1.2
6
  *
7
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/embedded/includes/module-manager.php $
8
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
9
  * $LastChangedRevision: 1027712 $
10
  * $LastChangedBy: iworks $
embedded/includes/post-relationship.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  * Post relationship code.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/includes/post-relationship.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -200,7 +200,7 @@ function wpcf_admin_notice_post_locked_no_parent() {
200
  */
201
  function wpcf_pr_admin_post_meta_box_output( $post, $args )
202
  {
203
- if ( empty( $post->ID ) ) {
204
  return array();
205
  }
206
 
@@ -210,12 +210,17 @@ function wpcf_pr_admin_post_meta_box_output( $post, $args )
210
  $relationships = $args;
211
  $post_id = !empty( $post->ID ) ? $post->ID : -1;
212
  $current_post_type = wpcf_admin_get_edited_post_type( $post );
 
213
  /*
214
  * Render has form (child form)
215
  */
216
  if ( !empty( $relationships['has'] ) ) {
217
  foreach ( $relationships['has'] as $post_type => $data ) {
218
- $output .= $wpcf->relationship->child_meta_form( $post, $post_type, $data );
 
 
 
 
219
  }
220
  }
221
  /*
@@ -233,20 +238,18 @@ function wpcf_pr_admin_post_meta_box_output( $post, $args )
233
  }
234
  }
235
  }
236
- $output_temp = '';
237
  foreach ( $relationships['belongs'] as $post_type => $data ) {
238
- $output_temp .= wpcf_form_simple(
239
- wpcf_pr_admin_post_meta_box_belongs_form( $post, $post_type, $belongs )
240
- );
241
- }
242
- if ( !empty( $output_temp ) ) {
243
- $types_existing = get_option( 'wpcf-custom-types', array() );
244
  $output .= '<div style="margin: 20px 0 10px 0">';
245
- $output .= sprintf(
246
- __( 'This <i>%s</i> belongs to:', 'wpcf' ),
247
- $types_existing[$current_post_type]['labels']['singular_name']
248
- );
249
- $output .= '</div>' . $output_temp;
 
 
 
 
 
250
  }
251
  }
252
  return $output;
2
  /*
3
  * Post relationship code.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
200
  */
201
  function wpcf_pr_admin_post_meta_box_output( $post, $args )
202
  {
203
+ if ( empty($post) || empty( $post->ID ) ) {
204
  return array();
205
  }
206
 
210
  $relationships = $args;
211
  $post_id = !empty( $post->ID ) ? $post->ID : -1;
212
  $current_post_type = wpcf_admin_get_edited_post_type( $post );
213
+
214
  /*
215
  * Render has form (child form)
216
  */
217
  if ( !empty( $relationships['has'] ) ) {
218
  foreach ( $relationships['has'] as $post_type => $data ) {
219
+ if ( isset($data['fields_setting']) && 'only_list' == $data['fields_setting'] ) {
220
+ $output .= $wpcf->relationship->child_list( $post, $post_type, $data );
221
+ } else {
222
+ $output .= $wpcf->relationship->child_meta_form( $post, $post_type, $data );
223
+ }
224
  }
225
  }
226
  /*
238
  }
239
  }
240
  }
 
241
  foreach ( $relationships['belongs'] as $post_type => $data ) {
 
 
 
 
 
 
242
  $output .= '<div style="margin: 20px 0 10px 0">';
243
+ if ( $x = wpcf_form_simple( wpcf_pr_admin_post_meta_box_belongs_form( $post, $post_type, $belongs ) ) ) {
244
+ $output .= sprintf(
245
+ __( 'This <i>%s</i> belongs to:', 'wpcf' ),
246
+ get_post_type_object($current_post_type)->labels->singular_name
247
+ );
248
+ $output .= $x;
249
+ } else {
250
+ $output .= get_post_type_object($post_type)->labels->not_found;
251
+ }
252
+ $output .= '</div>';
253
  }
254
  }
255
  return $output;
embedded/includes/usermeta-post.php CHANGED
@@ -113,7 +113,8 @@ function wpcf_admin_userprofile_init($user_id){
113
  );
114
  }
115
  $config['title'] = $config['description'] = '';
116
- $output .= wptoolset_form_field( 'your-profile', $config, $meta );
 
117
  if ( $description ) {
118
  $output .= $description;
119
  }
113
  );
114
  }
115
  $config['title'] = $config['description'] = '';
116
+ $form_name = $user_id->ID? 'your-profile':'createuser';
117
+ $output .= wptoolset_form_field( $form_name, $config, $meta );
118
  if ( $description ) {
119
  $output .= $description;
120
  }
embedded/includes/wpml.php CHANGED
@@ -8,10 +8,10 @@
8
  * Values:
9
  * 0 nothing (ignore), 1 copy, 2 translate
10
  *
11
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/embedded/includes/wpml.php $
12
- * $LastChangedDate: 2014-08-27 08:49:51 +0000 (Wed, 27 Aug 2014) $
13
- * $LastChangedRevision: 973824 $
14
- * $LastChangedBy: brucepearson $
15
  *
16
  */
17
 
@@ -1194,18 +1194,23 @@ function wpcf_wpml_warnings_init()
1194
  * check is configuration done?!
1195
  */
1196
  global $sitepress, $sitepress_settings;
1197
- if ( !array_key_exists( 'st', $sitepress_settings ) ) {
1198
  return;
1199
  }
1200
 
1201
- if ( $sitepress->get_default_language() != $sitepress_settings[ 'st' ][ 'strings_language' ] ) {
1202
- wp_types_default_language_warning();
1203
- } elseif ( $sitepress_settings[ 'st' ][ 'strings_language' ] != 'en' ) {
1204
- wp_types_st_language_warning();
1205
- } else {
1206
- ICL_AdminNotifier::removeMessage( 'wp_types_default_language_warning' );
1207
- ICL_AdminNotifier::removeMessage( 'wp_types_st_language_warning' );
1208
- }
 
 
 
 
 
1209
  }
1210
 
1211
  function wpcf_wpml_warning()
@@ -1261,7 +1266,7 @@ function wp_types_st_language_warning()
1261
  if ( class_exists( 'ICL_AdminNotifier' ) && defined( 'ICL_SITEPRESS_VERSION' ) ) {
1262
  ICL_AdminNotifier::removeMessage( 'wp_types_default_language_warning' );
1263
  static $called = false;
1264
- if ( !$called ) {
1265
  $st_language_code = $sitepress_settings[ 'st' ][ 'strings_language' ];
1266
  $st_language = $sitepress->get_display_language_name($st_language_code, $sitepress->get_admin_language());
1267
 
8
  * Values:
9
  * 0 nothing (ignore), 1 copy, 2 translate
10
  *
11
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
17
 
1194
  * check is configuration done?!
1195
  */
1196
  global $sitepress, $sitepress_settings;
1197
+ if ( icl_get_setting('st') ) {
1198
  return;
1199
  }
1200
 
1201
+ /**
1202
+ * do that only when version of WPML is lower then 3.2
1203
+ */
1204
+ if ( defined('ICL_SITEPRESS_VERSION') && version_compare( ICL_SITEPRESS_VERSION, '3.2', '<' ) ) {
1205
+ if (isset($sitepress_settings[ 'st' ]) && $sitepress->get_default_language() != $sitepress_settings[ 'st' ][ 'strings_language' ] ) {
1206
+ wp_types_default_language_warning();
1207
+ } elseif (isset($sitepress_settings[ 'st' ]) && $sitepress_settings[ 'st' ][ 'strings_language' ] != 'en' ) {
1208
+ wp_types_st_language_warning();
1209
+ } else {
1210
+ ICL_AdminNotifier::removeMessage( 'wp_types_default_language_warning' );
1211
+ ICL_AdminNotifier::removeMessage( 'wp_types_st_language_warning' );
1212
+ }
1213
+ }
1214
  }
1215
 
1216
  function wpcf_wpml_warning()
1266
  if ( class_exists( 'ICL_AdminNotifier' ) && defined( 'ICL_SITEPRESS_VERSION' ) ) {
1267
  ICL_AdminNotifier::removeMessage( 'wp_types_default_language_warning' );
1268
  static $called = false;
1269
+ if ( !$called && isset($sitepress_settings[ 'st' ])) {
1270
  $st_language_code = $sitepress_settings[ 'st' ][ 'strings_language' ];
1271
  $st_language = $sitepress->get_display_language_name($st_language_code, $sitepress->get_admin_language());
1272
 
embedded/onthego-resources/loader.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // This file is responsible for loading the latest version of the on the
4
+ // go system branding resources.
5
+ //
6
+ // To use it in a plugin or theme you should include this file early in the
7
+ // plugin loader and then call the onthego_initialize function.
8
+ // The onthego_initialize should be passed the file path to the directory
9
+ // where this file is located and also the url to this directory.
10
+
11
+ //
12
+
13
+ // -----------------------------------------------------------------------//
14
+
15
+ // This version number should always be incremented by 1 whenever a change
16
+ // is made to the onthego-resources code.
17
+ // The version number will then be used to work out which plugin has the latest
18
+ // version of the code.
19
+
20
+ $onthegosystems_branding_version = 1;
21
+
22
+
23
+ // ----------------------------------------------------------------------//
24
+ // WARNING * WARNING *WARNING
25
+ // ----------------------------------------------------------------------//
26
+
27
+ // Don't modify or add to this code.
28
+ // This is only responsible for making sure the latest version of the resources
29
+ // is loaded.
30
+
31
+ global $onthegosystems_branding_paths;
32
+
33
+ if (!isset($onthegosystems_branding_paths)) {
34
+ $onthegosystems_branding_paths = array();
35
+ }
36
+
37
+ if (!isset($onthegosystems_branding_paths[$onthegosystems_branding_version])) {
38
+ // Save the path to this version.
39
+ $onthegosystems_branding_paths[$onthegosystems_branding_version]['path'] = str_replace('\\', '/', dirname(__FILE__));
40
+ }
41
+
42
+ if( !function_exists('on_the_go_systems_branding_plugins_loaded') ) {
43
+ function on_the_go_systems_branding_plugins_loaded()
44
+ {
45
+ global $onthegosystems_branding_paths;
46
+
47
+ // find the latest version
48
+ $latest = 0;
49
+ foreach ($onthegosystems_branding_paths as $key => $data) {
50
+ if ($key > $latest) {
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') ) {
65
+
66
+ function onthego_initialize($path, $url) {
67
+ global $onthegosystems_branding_paths;
68
+
69
+ $path = str_replace('\\', '/', $path);
70
+
71
+ if (substr($path, strlen($path) - 1) == '/') {
72
+ $path = substr($path, 0, strlen($path) - 1);
73
+ }
74
+
75
+ // Save the url in the matching path
76
+ foreach ($onthegosystems_branding_paths as $key => $data) {
77
+ if ($onthegosystems_branding_paths[$key]['path'] == $path) {
78
+ $onthegosystems_branding_paths[$key]['url'] = $url;
79
+ break;
80
+ }
81
+ }
82
+ }
83
+ }
84
+
embedded/onthego-resources/readme.txt DELETED
@@ -1,11 +0,0 @@
1
- Usage:
2
-
3
- cd "to a folder of your choice"
4
-
5
- mkdir onthegosystems-icons
6
-
7
- svn checkout https://www.onthegosystems.com/misc_svn/onthegosystems-branding/trunk/ onthegosystems-icons
8
-
9
- cd onthegosystems-icons
10
-
11
- fontcustom compile
 
 
 
 
 
 
 
 
 
 
 
embedded/plugin.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/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
+
19
+ add_action( 'plugins_loaded', 'wpcf_embedded_load_or_deactivate' );
20
+
21
+ function wpcf_embedded_load_or_deactivate()
22
+ {
23
+ if ( function_exists('wpcf_activation_hook') ) {
24
+ add_action( 'admin_init', 'wpcf_embedded_deactivate' );
25
+ add_action( 'admin_notices', 'wpcf_embedded_deactivate_notice' );
26
+ } else {
27
+ require_once 'types.php';
28
+ }
29
+ }
30
+
31
+ /**
32
+ * wpcf_embedded_deactivate
33
+ *
34
+ * Deactivate this plugin
35
+ *
36
+ * @since 1.6.2
37
+ */
38
+
39
+ function wpcf_embedded_deactivate()
40
+ {
41
+ $plugin = plugin_basename( __FILE__ );
42
+ deactivate_plugins( $plugin );
43
+ }
44
+
45
+ /**
46
+ * wpcf_embedded_deactivate_notice
47
+ *
48
+ * Deactivate notice for this plugin
49
+ *
50
+ * @since 1.6.2
51
+ */
52
+
53
+ function wpcf_embedded_deactivate_notice()
54
+ {
55
+ ?>
56
+ <div class="error">
57
+ <p>
58
+ <?php _e( 'WP Types Embedded was <strong>deactivated</strong>! You are already running the complete WP Types plugin, so this one is not needed anymore.', 'wpcf' ); ?>
59
+ </p>
60
+ </div>
61
+ <?php
62
+ }
embedded/resources/css/basic.css CHANGED
@@ -91,9 +91,6 @@ NO DUPLICATES
91
  font-style: normal;
92
  margin-bottom: 5px;
93
  }
94
- .wpcf-form-label {
95
- white-space: nowrap;
96
- }
97
  .wpcf-form-fieldset .wpcf-form-label
98
  {
99
  white-space: normal;
@@ -462,3 +459,111 @@ input.wpcf-form-error {
462
  .types-help-content p, .toolset-help-content ul, .toolset-help-content ol {
463
  line-height: 1.6;
464
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  font-style: normal;
92
  margin-bottom: 5px;
93
  }
 
 
 
94
  .wpcf-form-fieldset .wpcf-form-label
95
  {
96
  white-space: normal;
459
  .types-help-content p, .toolset-help-content ul, .toolset-help-content ol {
460
  line-height: 1.6;
461
  }
462
+
463
+ /**
464
+ * message after active plugin
465
+ */
466
+
467
+ .toolset-message-after-activate
468
+ ,.toolset-message-after-activate h2
469
+ {
470
+ color: #4d4d4d;
471
+ }
472
+
473
+ .toolset-message-after-activate
474
+ {
475
+ background-color: #fffce1;
476
+ border: 2px solid #fffe38;
477
+ padding: 15px 20px;
478
+ margin-bottom: 10px;
479
+
480
+ -webkit-border-radius: 5px;
481
+ -moz-border-radius: 5px;
482
+ border-radius: 5px;
483
+ }
484
+
485
+ .toolset-message-after-activate span:before
486
+ {
487
+ color:#f05a28;
488
+ font-size:70px;
489
+ }
490
+
491
+ .toolset-message-after-activate .button-dismiss:hover
492
+ {
493
+ text-decoration: underline;
494
+ }
495
+
496
+ .toolset-message-after-activate .button-dismiss
497
+ {
498
+ cursor: pointer;
499
+ font-size: 14px;
500
+ }
501
+
502
+ .toolset-message-after-activate .button-primary
503
+ {
504
+ font-size: 18px;
505
+ font-weight: 900;
506
+ font-style: italic;
507
+ }
508
+
509
+ .toolset-message-after-activate p.buttons
510
+ {
511
+ margin-bottom: 0;
512
+ }
513
+
514
+ .toolset-message-after-activate p
515
+ {
516
+ font-size: 16px;
517
+ }
518
+
519
+ .toolset-message-after-activate h2 em
520
+ {
521
+ font-weight: 900;
522
+ }
523
+
524
+ .toolset-message-after-activate h2
525
+ {
526
+ font-size: 40px;
527
+ }
528
+
529
+ .toolset-message-after-activate div
530
+ {
531
+ border-right: 2px solid #f05a28;
532
+ max-width: 500px;
533
+ padding-right: 60px;
534
+ float: left;
535
+ }
536
+
537
+ .wp-core-ui .toolset-message-after-activate .button-primary
538
+ {
539
+ background-color:#f05a28;
540
+ border-color:#ed4e26;
541
+ }
542
+
543
+ .toolset-message-after-activate:after
544
+ {
545
+ content: " ";
546
+ display: block;
547
+ clear: both;
548
+ }
549
+
550
+ .toolset-message-after-activate .logo
551
+ {
552
+ background: transparent url(../images/types-toolset-component.png) no-repeat 73px 50%;
553
+ display: block;
554
+ height: 70px;
555
+ width: 158px;
556
+ float: left;
557
+ margin: 35px 0 0 20px;
558
+ }
559
+
560
+ .status-inactive:hover
561
+ {
562
+ opacity: 1;
563
+ }
564
+
565
+ .status-inactive
566
+ {
567
+ opacity: .5;
568
+ transition: all .4s;
569
+ }
embedded/resources/css/dashicons.css CHANGED
@@ -1,6 +1,6 @@
1
  /**
2
  *
3
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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.5/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/images/types-toolset-component.png ADDED
Binary file
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.4/embedded/resources/js/basic.js $
8
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
9
- * $LastChangedRevision: 1027712 $
10
  * $LastChangedBy: iworks $
11
  *
12
  */
@@ -19,6 +19,15 @@ var wpcfFormGroupsSupportTemplatesState = new Array();
19
  var wpcfFieldsEditorCallback_redirect = null;
20
 
21
  jQuery(document).ready(function(){
 
 
 
 
 
 
 
 
 
22
  //user suggestion
23
  if(jQuery.isFunction(jQuery.suggest)) {
24
  jQuery('.input').suggest("admin-ajax.php?action=wpcf_types_suggest_user&tax=post_tag", {
@@ -155,7 +164,6 @@ jQuery(document).ready(function(){
155
  jQuery('#'+parentID).append('<div class="wpcf-form-error-unique-value wpcf-form-error">'+wpcfFormUniqueValuesCheckText+'</div>');
156
  jQuery(this).parents('fieldset').children('.fieldset-wrapper').slideDown();
157
  jQuery(this).focus();
158
-
159
  }
160
 
161
  checkedArr[parentID].push(currentValue);
@@ -500,7 +508,9 @@ function wpcfCdCheckDateCustomized(object) {
500
  */
501
  function wpcfLoadingButton() {
502
  jQuery('.wpcf-disabled-on-submit').attr('disabled', 'disabled').each(function(){
503
- jQuery(this).after('<div id="'+jQuery(this).attr('id')+'-loading" class="wpcf-loading">&nbsp;</div>');
 
 
504
  });
505
  }
506
  /**
@@ -509,6 +519,11 @@ function wpcfLoadingButton() {
509
  function wpcfLoadingButtonStop() {
510
  jQuery('.wpcf-disabled-on-submit').removeAttr('disabled');
511
  jQuery('.wpcf-loading').fadeOut();
 
 
 
 
 
512
  }
513
 
514
  /**
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/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
  */
19
  var wpcfFieldsEditorCallback_redirect = null;
20
 
21
  jQuery(document).ready(function(){
22
+ /**
23
+ * modal advertising
24
+ */
25
+ if(jQuery.isFunction(jQuery.fn.types_modal_box)) {
26
+ jQuery('.wpcf-disabled-on-submit').types_modal_box();
27
+ }
28
+ jQuery('.wpcf-notif-description a').on('click', function() {
29
+ jQuery(this).attr('target', '_blank');
30
+ });
31
  //user suggestion
32
  if(jQuery.isFunction(jQuery.suggest)) {
33
  jQuery('.input').suggest("admin-ajax.php?action=wpcf_types_suggest_user&tax=post_tag", {
164
  jQuery('#'+parentID).append('<div class="wpcf-form-error-unique-value wpcf-form-error">'+wpcfFormUniqueValuesCheckText+'</div>');
165
  jQuery(this).parents('fieldset').children('.fieldset-wrapper').slideDown();
166
  jQuery(this).focus();
 
167
  }
168
 
169
  checkedArr[parentID].push(currentValue);
508
  */
509
  function wpcfLoadingButton() {
510
  jQuery('.wpcf-disabled-on-submit').attr('disabled', 'disabled').each(function(){
511
+ if ( 'undefined' == typeof(types_modal) ) {
512
+ jQuery(this).after('<div id="'+jQuery(this).attr('id')+'-loading" class="wpcf-loading">&nbsp;</div>');
513
+ }
514
  });
515
  }
516
  /**
519
  function wpcfLoadingButtonStop() {
520
  jQuery('.wpcf-disabled-on-submit').removeAttr('disabled');
521
  jQuery('.wpcf-loading').fadeOut();
522
+ //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/194177056/comments
523
+ //type modal didnt disappeared
524
+ jQuery('.types_modal_box').remove();
525
+ jQuery('.types_block_page').remove();
526
+
527
  }
528
 
529
  /**
embedded/resources/js/custom-fields-form-filter.js CHANGED
@@ -1,11 +1,11 @@
1
- /*
2
  * Filter box on fields edit page.
3
  */
4
  jQuery(document).ready(function(){
5
  wpcfFieldsFormFiltersSummary();
6
  //jQuery('#wpfooter').css({'position':'relative'});
7
  });
8
-
9
  function wpcfFieldsFormFiltersSummary() {
10
  if (jQuery('#wpcf-fields-form-filters-association-form').find("input:checked").val() == 'all') {
11
  var string = wpcf_filters_association_and;
@@ -38,7 +38,7 @@ function wpcfFieldsFormFiltersSummary() {
38
  string = string.replace('%vt%', vt.join(', '));
39
  jQuery('#wpcf-fields-form-filters-association-summary').html(string);
40
  }
41
-
42
  // Title func
43
  function _wpcfFilterTitle(e, title, title_not_empty, title_empty) {
44
  if (e == 'empty') {
@@ -54,13 +54,15 @@ jQuery('input.wpcf-forms-field-slug').live('blur focus click', function(){
54
  var slug_name = jQuery(this).attr('name');
55
  var name = '';
56
  if (slug == '' || slug == 'Enter field slug'){
57
-
58
  //wpcf-forms-field-name
59
- name = jQuery(this).parent().find('input.wpcf-forms-field-name');
60
- jQuery(this).val(jQuery(name).val().toLowerCase().split(' ').join('-').split('\'').join(''));
61
- //jQuery(this).trigger('keyup');
62
-
63
-
 
 
64
  }
65
  });
66
  var CSSLayoutEditor = '';
@@ -73,14 +75,14 @@ function wpcfFilterEditClick(object, edit, title, title_not_empty, title_empty)
73
  var parent = object.parents('.wpcf-filter-wrap');
74
  var toggle = parent.next();
75
  /*
76
- *
77
  * Built-in filters
78
- *
79
- *
80
  * Custom types
81
  */
82
  if (edit == 'custom_post_types') {
83
-
84
  /*
85
  *
86
  * Take a snapshot
@@ -129,10 +131,10 @@ function wpcfFilterEditClick(object, edit, title, title_not_empty, title_empty)
129
  else if (edit == 'admin_styles') {
130
  toggle.slideToggle();
131
  //.CodeMirror-scroll{
132
- //width:713px;
133
  //}
134
  jQuery("#wpcf-admin-styles-box").css({width:'700px','border-color':'#808080','box-shadow':'5px 5px 10px #888888','z-index':'10000'});
135
-
136
  if (CSSLayoutEditor == ''){
137
  jQuery("#wpcf-update-preview-div").resizable({});
138
  document.getElementById("wpcf-form-groups-admin-html-preview").innerHTML = wpcfEditMode;
@@ -140,7 +142,7 @@ function wpcfFilterEditClick(object, edit, title, title_not_empty, title_empty)
140
  lineWrapping: true, lineNumbers: true});
141
  HTMMLLayoutEditor = CodeMirror.fromTextArea(document.getElementById("wpcf-form-groups-admin-html-preview"), {mode: "text/html", tabMode: "indent",
142
  readOnly:true, lineWrapping: true, lineNumbers: true});
143
- wpcfPreviewHtml();
144
  jQuery(".CodeMirror-scroll").css({width:'675px'});
145
  jQuery(".CodeMirror").resizable({
146
  stop: function() { CSSLayoutEditor.refresh(); HTMMLLayoutEditor.refresh(); },
@@ -150,12 +152,12 @@ function wpcfFilterEditClick(object, edit, title, title_not_empty, title_empty)
150
  CSSLayoutEditor.refresh();HTMMLLayoutEditor.refresh();
151
  }
152
  });
153
-
154
  }
155
-
156
-
157
  }
158
-
159
  // Hide until OK or Cancel
160
  object.css('visibility', 'hidden');
161
 
@@ -177,13 +179,13 @@ function changePreviewHtml(mode){
177
  HTMMLLayoutEditor.setValue(wpcfEditMode);
178
  }
179
  HTMMLLayoutEditor.refresh();
180
- wpcfPreviewHtml();
181
  }
182
  function wpcfPreviewHtml(){
183
  jQuery("#wpcf-update-preview-div").resizable( "destroy" );
184
  jQuery("<style type='text/css'> "+ CSSLayoutEditor.getValue() +" </style>").appendTo("head");
185
  document.getElementById("wpcf-update-preview-div").innerHTML = HTMMLLayoutEditor.getValue();
186
- jQuery("#wpcf-update-preview-div").resizable({});
187
  }
188
 
189
 
@@ -196,18 +198,18 @@ function wpcfFilterOkClick(object, edit, title, title_not_empty, title_empty) {
196
  var toggle = object.parent();
197
  var parent = toggle.prev('.wpcf-filter-wrap');
198
  /*
199
- *
200
  * Built-in filters
201
- *
202
- *
203
- *
204
- *
205
  * Do custom post types
206
  */
207
  if (edit == 'custom_post_types') {
208
-
209
  /*
210
- *
211
  * Take a snapshot of current state
212
  */
213
  window.wpcfPostTypesText = new Array();
@@ -218,39 +220,39 @@ function wpcfFilterOkClick(object, edit, title, title_not_empty, title_empty) {
218
  window.wpcfFormGroupsSupportPostTypesState.push(jQuery(this).attr('id'));
219
  }
220
  });
221
-
222
  /*
223
- *
224
- *
225
  * Set TEXT
226
  */
227
- if (window.wpcfPostTypesText.length < 1) {
228
  parent.find('.wpcf-filter-ajax-response').html(
229
  _wpcfFilterTitle('empty', title, title_not_empty, title_empty)
230
  );
231
  } else {
232
  var title_not_empty = wpcfPostTypesText.join(', ');
233
  parent.find('.wpcf-filter-ajax-response').html(
234
- _wpcfFilterTitle('has', title, title_not_empty, title_empty)
235
  );
236
  };
237
-
238
  /*
239
- *
240
- *
241
- *
242
- *
243
- *
244
- *
245
- *
246
- *
247
- *
248
  * Now do taxonomies
249
  */
250
 
251
  } else if (edit == 'custom_taxonomies') {
252
  /*
253
- *
254
  * Take a snapshot of current state
255
  */
256
  window.wpcfTaxText = new Array();
@@ -261,7 +263,7 @@ function wpcfFilterOkClick(object, edit, title, title_not_empty, title_empty) {
261
  window.wpcfFormGroupsSupportTaxState.push(jQuery(this).attr('id'));
262
  }
263
  });
264
-
265
  /*
266
  *
267
  * Set TEXT
@@ -273,7 +275,7 @@ function wpcfFilterOkClick(object, edit, title, title_not_empty, title_empty) {
273
  } else {
274
  title_not_empty = window.wpcfTaxText.join(', ');
275
  parent.find('.wpcf-filter-ajax-response').html(
276
- _wpcfFilterTitle('has', title, title_not_empty, title_empty)
277
  );
278
  }
279
  /*
@@ -310,17 +312,17 @@ function wpcfFilterOkClick(object, edit, title, title_not_empty, title_empty) {
310
  } else {
311
  title_not_empty = window.wpcfTemplatesText.join(', ');
312
  parent.find('.wpcf-filter-ajax-response').html(
313
- _wpcfFilterTitle('has', title, title_not_empty, title_empty)
314
  );
315
  }
316
-
317
  }
318
  else if (edit == 'admin_styles') {
319
  jQuery("#wpcf-admin-styles-box").css({width:'400px','border-color':'#dfdfdf','box-shadow':'none','z-index':'0'});
320
  jQuery('html, body').animate({scrollTop:jQuery('#wpcf-admin-styles-box').position().top}, 'fast');
321
  toggle.slideUp();
322
  }
323
-
324
  parent.children('a').css('visibility', 'visible');
325
  }
326
 
@@ -333,12 +335,12 @@ function wpcfFilterCancelClick(object, edit, title, title_not_empty, title_empty
333
  var toggle = object.parent();
334
  var parent = toggle.prev('.wpcf-filter-wrap');
335
  /*
336
- *
337
  * Built-in filters
338
- *
339
- *
340
- *
341
- *
342
  * Do custom post types
343
  */
344
  if (edit == 'custom_post_types') {
@@ -370,16 +372,16 @@ function wpcfFilterCancelClick(object, edit, title, title_not_empty, title_empty
370
  );
371
  }
372
  /*
373
- *
374
- *
375
- *
376
- *
377
- *
378
- *
379
- *
380
- *
381
- *
382
- *
383
  * Now do taxonomies
384
  */
385
  } else if (edit == 'custom_taxonomies') {
@@ -411,13 +413,13 @@ function wpcfFilterCancelClick(object, edit, title, title_not_empty, title_empty
411
  );
412
  }
413
  /*
414
- *
415
- *
416
- *
417
- *
418
- *
419
- *
420
- *
421
  * Do templates
422
  */
423
  } else if (edit == 'templates') {
@@ -441,10 +443,111 @@ function wpcfFilterCancelClick(object, edit, title, title_not_empty, title_empty
441
  else if (edit == 'admin_styles') {
442
  jQuery("#wpcf-admin-styles-box").css({width:'400px','border-color':'#dfdfdf','box-shadow':'none','z-index':'0'});
443
  jQuery('html, body').animate({scrollTop:jQuery('#wpcf-admin-styles-box').position().top}, 'fast');
444
- CSSLayoutEditor.setValue(wpcfDefaultCss);
445
  toggle.slideUp();
446
  }
447
-
448
-
449
  parent.children('a').css('visibility', 'visible');
450
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
  * Filter box on fields edit page.
3
  */
4
  jQuery(document).ready(function(){
5
  wpcfFieldsFormFiltersSummary();
6
  //jQuery('#wpfooter').css({'position':'relative'});
7
  });
8
+
9
  function wpcfFieldsFormFiltersSummary() {
10
  if (jQuery('#wpcf-fields-form-filters-association-form').find("input:checked").val() == 'all') {
11
  var string = wpcf_filters_association_and;
38
  string = string.replace('%vt%', vt.join(', '));
39
  jQuery('#wpcf-fields-form-filters-association-summary').html(string);
40
  }
41
+
42
  // Title func
43
  function _wpcfFilterTitle(e, title, title_not_empty, title_empty) {
44
  if (e == 'empty') {
54
  var slug_name = jQuery(this).attr('name');
55
  var name = '';
56
  if (slug == '' || slug == 'Enter field slug'){
57
+
58
  //wpcf-forms-field-name
59
+ val = jQuery(this).parent().find('input.wpcf-forms-field-name').val().toLowerCase();
60
+ val = removeDiacritics(val);
61
+ val = val.replace(/[^a-z0-9A-Z]+/g, '-');
62
+ val = val.replace(/\-+/g, '-');
63
+ val = val.replace(/^\-/g, '');
64
+ val = val.replace(/\-$/g, '');
65
+ jQuery(this).val(val);
66
  }
67
  });
68
  var CSSLayoutEditor = '';
75
  var parent = object.parents('.wpcf-filter-wrap');
76
  var toggle = parent.next();
77
  /*
78
+ *
79
  * Built-in filters
80
+ *
81
+ *
82
  * Custom types
83
  */
84
  if (edit == 'custom_post_types') {
85
+
86
  /*
87
  *
88
  * Take a snapshot
131
  else if (edit == 'admin_styles') {
132
  toggle.slideToggle();
133
  //.CodeMirror-scroll{
134
+ //width:713px;
135
  //}
136
  jQuery("#wpcf-admin-styles-box").css({width:'700px','border-color':'#808080','box-shadow':'5px 5px 10px #888888','z-index':'10000'});
137
+
138
  if (CSSLayoutEditor == ''){
139
  jQuery("#wpcf-update-preview-div").resizable({});
140
  document.getElementById("wpcf-form-groups-admin-html-preview").innerHTML = wpcfEditMode;
142
  lineWrapping: true, lineNumbers: true});
143
  HTMMLLayoutEditor = CodeMirror.fromTextArea(document.getElementById("wpcf-form-groups-admin-html-preview"), {mode: "text/html", tabMode: "indent",
144
  readOnly:true, lineWrapping: true, lineNumbers: true});
145
+ wpcfPreviewHtml();
146
  jQuery(".CodeMirror-scroll").css({width:'675px'});
147
  jQuery(".CodeMirror").resizable({
148
  stop: function() { CSSLayoutEditor.refresh(); HTMMLLayoutEditor.refresh(); },
152
  CSSLayoutEditor.refresh();HTMMLLayoutEditor.refresh();
153
  }
154
  });
155
+
156
  }
157
+
158
+
159
  }
160
+
161
  // Hide until OK or Cancel
162
  object.css('visibility', 'hidden');
163
 
179
  HTMMLLayoutEditor.setValue(wpcfEditMode);
180
  }
181
  HTMMLLayoutEditor.refresh();
182
+ wpcfPreviewHtml();
183
  }
184
  function wpcfPreviewHtml(){
185
  jQuery("#wpcf-update-preview-div").resizable( "destroy" );
186
  jQuery("<style type='text/css'> "+ CSSLayoutEditor.getValue() +" </style>").appendTo("head");
187
  document.getElementById("wpcf-update-preview-div").innerHTML = HTMMLLayoutEditor.getValue();
188
+ jQuery("#wpcf-update-preview-div").resizable({});
189
  }
190
 
191
 
198
  var toggle = object.parent();
199
  var parent = toggle.prev('.wpcf-filter-wrap');
200
  /*
201
+ *
202
  * Built-in filters
203
+ *
204
+ *
205
+ *
206
+ *
207
  * Do custom post types
208
  */
209
  if (edit == 'custom_post_types') {
210
+
211
  /*
212
+ *
213
  * Take a snapshot of current state
214
  */
215
  window.wpcfPostTypesText = new Array();
220
  window.wpcfFormGroupsSupportPostTypesState.push(jQuery(this).attr('id'));
221
  }
222
  });
223
+
224
  /*
225
+ *
226
+ *
227
  * Set TEXT
228
  */
229
+ if (window.wpcfPostTypesText.length < 1) {
230
  parent.find('.wpcf-filter-ajax-response').html(
231
  _wpcfFilterTitle('empty', title, title_not_empty, title_empty)
232
  );
233
  } else {
234
  var title_not_empty = wpcfPostTypesText.join(', ');
235
  parent.find('.wpcf-filter-ajax-response').html(
236
+ _wpcfFilterTitle('has', title, title_not_empty, title_empty)
237
  );
238
  };
239
+
240
  /*
241
+ *
242
+ *
243
+ *
244
+ *
245
+ *
246
+ *
247
+ *
248
+ *
249
+ *
250
  * Now do taxonomies
251
  */
252
 
253
  } else if (edit == 'custom_taxonomies') {
254
  /*
255
+ *
256
  * Take a snapshot of current state
257
  */
258
  window.wpcfTaxText = new Array();
263
  window.wpcfFormGroupsSupportTaxState.push(jQuery(this).attr('id'));
264
  }
265
  });
266
+
267
  /*
268
  *
269
  * Set TEXT
275
  } else {
276
  title_not_empty = window.wpcfTaxText.join(', ');
277
  parent.find('.wpcf-filter-ajax-response').html(
278
+ _wpcfFilterTitle('has', title, title_not_empty, title_empty)
279
  );
280
  }
281
  /*
312
  } else {
313
  title_not_empty = window.wpcfTemplatesText.join(', ');
314
  parent.find('.wpcf-filter-ajax-response').html(
315
+ _wpcfFilterTitle('has', title, title_not_empty, title_empty)
316
  );
317
  }
318
+
319
  }
320
  else if (edit == 'admin_styles') {
321
  jQuery("#wpcf-admin-styles-box").css({width:'400px','border-color':'#dfdfdf','box-shadow':'none','z-index':'0'});
322
  jQuery('html, body').animate({scrollTop:jQuery('#wpcf-admin-styles-box').position().top}, 'fast');
323
  toggle.slideUp();
324
  }
325
+
326
  parent.children('a').css('visibility', 'visible');
327
  }
328
 
335
  var toggle = object.parent();
336
  var parent = toggle.prev('.wpcf-filter-wrap');
337
  /*
338
+ *
339
  * Built-in filters
340
+ *
341
+ *
342
+ *
343
+ *
344
  * Do custom post types
345
  */
346
  if (edit == 'custom_post_types') {
372
  );
373
  }
374
  /*
375
+ *
376
+ *
377
+ *
378
+ *
379
+ *
380
+ *
381
+ *
382
+ *
383
+ *
384
+ *
385
  * Now do taxonomies
386
  */
387
  } else if (edit == 'custom_taxonomies') {
413
  );
414
  }
415
  /*
416
+ *
417
+ *
418
+ *
419
+ *
420
+ *
421
+ *
422
+ *
423
  * Do templates
424
  */
425
  } else if (edit == 'templates') {
443
  else if (edit == 'admin_styles') {
444
  jQuery("#wpcf-admin-styles-box").css({width:'400px','border-color':'#dfdfdf','box-shadow':'none','z-index':'0'});
445
  jQuery('html, body').animate({scrollTop:jQuery('#wpcf-admin-styles-box').position().top}, 'fast');
446
+ CSSLayoutEditor.setValue(wpcfDefaultCss);
447
  toggle.slideUp();
448
  }
449
+
 
450
  parent.children('a').css('visibility', 'visible');
451
  }
452
+
453
+ /**
454
+ * removeDiacritics
455
+ */
456
+
457
+ var defaultDiacriticsRemovalMap = [
458
+ {'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},
459
+ {'base':'AA','letters':/[\uA732]/g},
460
+ {'base':'AE','letters':/[\u00C6\u01FC\u01E2]/g},
461
+ {'base':'AO','letters':/[\uA734]/g},
462
+ {'base':'AU','letters':/[\uA736]/g},
463
+ {'base':'AV','letters':/[\uA738\uA73A]/g},
464
+ {'base':'AY','letters':/[\uA73C]/g},
465
+ {'base':'B', 'letters':/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},
466
+ {'base':'C', 'letters':/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},
467
+ {'base':'D', 'letters':/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},
468
+ {'base':'DZ','letters':/[\u01F1\u01C4]/g},
469
+ {'base':'Dz','letters':/[\u01F2\u01C5]/g},
470
+ {'base':'E', 'letters':/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},
471
+ {'base':'F', 'letters':/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},
472
+ {'base':'G', 'letters':/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},
473
+ {'base':'H', 'letters':/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},
474
+ {'base':'I', 'letters':/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},
475
+ {'base':'J', 'letters':/[\u004A\u24BF\uFF2A\u0134\u0248]/g},
476
+ {'base':'K', 'letters':/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},
477
+ {'base':'L', 'letters':/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},
478
+ {'base':'LJ','letters':/[\u01C7]/g},
479
+ {'base':'Lj','letters':/[\u01C8]/g},
480
+ {'base':'M', 'letters':/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},
481
+ {'base':'N', 'letters':/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},
482
+ {'base':'NJ','letters':/[\u01CA]/g},
483
+ {'base':'Nj','letters':/[\u01CB]/g},
484
+ {'base':'O', 'letters':/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},
485
+ {'base':'OI','letters':/[\u01A2]/g},
486
+ {'base':'OO','letters':/[\uA74E]/g},
487
+ {'base':'OU','letters':/[\u0222]/g},
488
+ {'base':'P', 'letters':/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},
489
+ {'base':'Q', 'letters':/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},
490
+ {'base':'R', 'letters':/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},
491
+ {'base':'S', 'letters':/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},
492
+ {'base':'T', 'letters':/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},
493
+ {'base':'TZ','letters':/[\uA728]/g},
494
+ {'base':'U', 'letters':/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},
495
+ {'base':'V', 'letters':/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},
496
+ {'base':'VY','letters':/[\uA760]/g},
497
+ {'base':'W', 'letters':/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},
498
+ {'base':'X', 'letters':/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},
499
+ {'base':'Y', 'letters':/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},
500
+ {'base':'Z', 'letters':/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},
501
+ {'base':'a', 'letters':/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},
502
+ {'base':'aa','letters':/[\uA733]/g},
503
+ {'base':'ae','letters':/[\u00E6\u01FD\u01E3]/g},
504
+ {'base':'ao','letters':/[\uA735]/g},
505
+ {'base':'au','letters':/[\uA737]/g},
506
+ {'base':'av','letters':/[\uA739\uA73B]/g},
507
+ {'base':'ay','letters':/[\uA73D]/g},
508
+ {'base':'b', 'letters':/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},
509
+ {'base':'c', 'letters':/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},
510
+ {'base':'d', 'letters':/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},
511
+ {'base':'dz','letters':/[\u01F3\u01C6]/g},
512
+ {'base':'e', 'letters':/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},
513
+ {'base':'f', 'letters':/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},
514
+ {'base':'g', 'letters':/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},
515
+ {'base':'h', 'letters':/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},
516
+ {'base':'hv','letters':/[\u0195]/g},
517
+ {'base':'i', 'letters':/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},
518
+ {'base':'j', 'letters':/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},
519
+ {'base':'k', 'letters':/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},
520
+ {'base':'l', 'letters':/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},
521
+ {'base':'lj','letters':/[\u01C9]/g},
522
+ {'base':'m', 'letters':/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},
523
+ {'base':'n', 'letters':/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},
524
+ {'base':'nj','letters':/[\u01CC]/g},
525
+ {'base':'o', 'letters':/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},
526
+ {'base':'oi','letters':/[\u01A3]/g},
527
+ {'base':'ou','letters':/[\u0223]/g},
528
+ {'base':'oo','letters':/[\uA74F]/g},
529
+ {'base':'p','letters':/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},
530
+ {'base':'q','letters':/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},
531
+ {'base':'r','letters':/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},
532
+ {'base':'s','letters':/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},
533
+ {'base':'t','letters':/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},
534
+ {'base':'tz','letters':/[\uA729]/g},
535
+ {'base':'u','letters':/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},
536
+ {'base':'v','letters':/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},
537
+ {'base':'vy','letters':/[\uA761]/g},
538
+ {'base':'w','letters':/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},
539
+ {'base':'x','letters':/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},
540
+ {'base':'y','letters':/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},
541
+ {'base':'z','letters':/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}
542
+ ];
543
+ var changes;
544
+ function removeDiacritics (str) {
545
+ if(!changes) {
546
+ changes = defaultDiacriticsRemovalMap;
547
+ }
548
+ for(var i=0; i<changes.length; i++) {
549
+ str = str.replace(changes[i].letters, changes[i].base);
550
+ }
551
+ return str;
552
+ }
553
+
embedded/resources/js/editor.js CHANGED
@@ -159,6 +159,7 @@ var tedFrame = (function(window, $){
159
  window.parent.wpcfFieldsEditorCallback_redirect = null;
160
  } else {
161
  // Use default handler
 
162
  window.parent.icl_editor.insert(shortcode);
163
  }
164
  window.parent.jQuery.colorbox.close();
159
  window.parent.wpcfFieldsEditorCallback_redirect = null;
160
  } else {
161
  // Use default handler
162
+
163
  window.parent.icl_editor.insert(shortcode);
164
  }
165
  window.parent.jQuery.colorbox.close();
embedded/resources/js/fields-form.js CHANGED
@@ -9,7 +9,7 @@
9
  * @since Types 1.1.5
10
  * @autor srdjan
11
  *
12
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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 $
9
  * @since Types 1.1.5
10
  * @autor srdjan
11
  *
12
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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 $
embedded/resources/js/jquery-form-validation/jquery.validate-1.11.1.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! jQuery Validation Plugin - v1.11.1 - 3/22/2013\n* https://github.com/jzaefferer/jquery-validation
2
- * Copyright (c) 2013 Jörn Zaefferer; Licensed MIT */(function(t){t.extend(t.fn,{validate:function(e){if(!this.length)return e&&e.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing."),void 0;var i=t.data(this[0],"validator");return i?i:(this.attr("novalidate","novalidate"),i=new t.validator(e,this[0]),t.data(this[0],"validator",i),i.settings.onsubmit&&(this.validateDelegate(":submit","click",function(e){i.settings.submitHandler&&(i.submitButton=e.target),t(e.target).hasClass("cancel")&&(i.cancelSubmit=!0),void 0!==t(e.target).attr("formnovalidate")&&(i.cancelSubmit=!0)}),this.submit(function(e){function s(){var s;return i.settings.submitHandler?(i.submitButton&&(s=t("<input type='hidden'/>").attr("name",i.submitButton.name).val(t(i.submitButton).val()).appendTo(i.currentForm)),i.settings.submitHandler.call(i,i.currentForm,e),i.submitButton&&s.remove(),!1):!0}return i.settings.debug&&e.preventDefault(),i.cancelSubmit?(i.cancelSubmit=!1,s()):i.form()?i.pendingRequest?(i.formSubmitted=!0,!1):s():(i.focusInvalid(),!1)})),i)},valid:function(){if(t(this[0]).is("form"))return this.validate().form();var e=!0,i=t(this[0].form).validate();return this.each(function(){e=e&&i.element(this)}),e},removeAttrs:function(e){var i={},s=this;return t.each(e.split(/\s/),function(t,e){i[e]=s.attr(e),s.removeAttr(e)}),i},rules:function(e,i){var s=this[0];if(e){var r=t.data(s.form,"validator").settings,n=r.rules,a=t.validator.staticRules(s);switch(e){case"add":t.extend(a,t.validator.normalizeRule(i)),delete a.messages,n[s.name]=a,i.messages&&(r.messages[s.name]=t.extend(r.messages[s.name],i.messages));break;case"remove":if(!i)return delete n[s.name],a;var u={};return t.each(i.split(/\s/),function(t,e){u[e]=a[e],delete a[e]}),u}}var o=t.validator.normalizeRules(t.extend({},t.validator.classRules(s),t.validator.attributeRules(s),t.validator.dataRules(s),t.validator.staticRules(s)),s);if(o.required){var l=o.required;delete o.required,o=t.extend({required:l},o)}return o}}),t.extend(t.expr[":"],{blank:function(e){return!t.trim(""+t(e).val())},filled:function(e){return!!t.trim(""+t(e).val())},unchecked:function(e){return!t(e).prop("checked")}}),t.validator=function(e,i){this.settings=t.extend(!0,{},t.validator.defaults,e),this.currentForm=i,this.init()},t.validator.format=function(e,i){return 1===arguments.length?function(){var i=t.makeArray(arguments);return i.unshift(e),t.validator.format.apply(this,i)}:(arguments.length>2&&i.constructor!==Array&&(i=t.makeArray(arguments).slice(1)),i.constructor!==Array&&(i=[i]),t.each(i,function(t,i){e=e.replace(RegExp("\\{"+t+"\\}","g"),function(){return i})}),e)},t.extend(t.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:!0,errorContainer:t([]),errorLabelContainer:t([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(t){this.lastActive=t,this.settings.focusCleanup&&!this.blockFocusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,t,this.settings.errorClass,this.settings.validClass),this.addWrapper(this.errorsFor(t)).hide())},onfocusout:function(t){this.checkable(t)||!(t.name in this.submitted)&&this.optional(t)||this.element(t)},onkeyup:function(t,e){(9!==e.which||""!==this.elementValue(t))&&(t.name in this.submitted||t===this.lastElement)&&this.element(t)},onclick:function(t){t.name in this.submitted?this.element(t):t.parentNode.name in this.submitted&&this.element(t.parentNode)},highlight:function(e,i,s){"radio"===e.type?this.findByName(e.name).addClass(i).removeClass(s):t(e).addClass(i).removeClass(s)},unhighlight:function(e,i,s){"radio"===e.type?this.findByName(e.name).removeClass(i).addClass(s):t(e).removeClass(i).addClass(s)}},setDefaults:function(e){t.extend(t.validator.defaults,e)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",maxlength:t.validator.format("Please enter no more than {0} characters."),minlength:t.validator.format("Please enter at least {0} characters."),rangelength:t.validator.format("Please enter a value between {0} and {1} characters long."),range:t.validator.format("Please enter a value between {0} and {1}."),max:t.validator.format("Please enter a value less than or equal to {0}."),min:t.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:!1,prototype:{init:function(){function e(e){var i=t.data(this[0].form,"validator"),s="on"+e.type.replace(/^validate/,"");i.settings[s]&&i.settings[s].call(i,this[0],e)}this.labelContainer=t(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||t(this.currentForm),this.containers=t(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var i=this.groups={};t.each(this.settings.groups,function(e,s){"string"==typeof s&&(s=s.split(/\s/)),t.each(s,function(t,s){i[s]=e})});var s=this.settings.rules;t.each(s,function(e,i){s[e]=t.validator.normalizeRule(i)}),t(this.currentForm).validateDelegate(":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",e).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",e),this.settings.invalidHandler&&t(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),t.extend(this.submitted,this.errorMap),this.invalid=t.extend({},this.errorMap),this.valid()||t(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var t=0,e=this.currentElements=this.elements();e[t];t++)this.check(e[t]);return this.valid()},element:function(e){e=this.validationTargetFor(this.clean(e)),this.lastElement=e,this.prepareElement(e),this.currentElements=t(e);var i=this.check(e)!==!1;return i?delete this.invalid[e.name]:this.invalid[e.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),i},showErrors:function(e){if(e){t.extend(this.errorMap,e),this.errorList=[];for(var i in e)this.errorList.push({message:e[i],element:this.findByName(i)[0]});this.successList=t.grep(this.successList,function(t){return!(t.name in e)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){t.fn.resetForm&&t(this.currentForm).resetForm(),this.submitted={},this.lastElement=null,this.prepareForm(),this.hideErrors(),this.elements().removeClass(this.settings.errorClass).removeData("previousValue")},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(t){var e=0;for(var i in t)e++;return e},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{t(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(e){}},findLastActive:function(){var e=this.lastActive;return e&&1===t.grep(this.errorList,function(t){return t.element.name===e.name}).length&&e},elements:function(){var e=this,i={};return t(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){return!this.name&&e.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.name in i||!e.objectLength(t(this).rules())?!1:(i[this.name]=!0,!0)})},clean:function(e){return t(e)[0]},errors:function(){var e=this.settings.errorClass.replace(" ",".");return t(this.settings.errorElement+"."+e,this.errorContext)},reset:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=t([]),this.toHide=t([]),this.currentElements=t([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(t){this.reset(),this.toHide=this.errorsFor(t)},elementValue:function(e){var i=t(e).attr("type"),s=t(e).val();return"radio"===i||"checkbox"===i?t("input[name='"+t(e).attr("name")+"']:checked").val():"string"==typeof s?s.replace(/\r/g,""):s},check:function(e){e=this.validationTargetFor(this.clean(e));var i,s=t(e).rules(),r=!1,n=this.elementValue(e);for(var a in s){var u={method:a,parameters:s[a]};try{if(i=t.validator.methods[a].call(this,n,e,u.parameters),"dependency-mismatch"===i){r=!0;continue}if(r=!1,"pending"===i)return this.toHide=this.toHide.not(this.errorsFor(e)),void 0;if(!i)return this.formatAndAdd(e,u),!1}catch(o){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+e.id+", check the '"+u.method+"' method.",o),o}}return r?void 0:(this.objectLength(s)&&this.successList.push(e),!0)},customDataMessage:function(e,i){return t(e).data("msg-"+i.toLowerCase())||e.attributes&&t(e).attr("data-msg-"+i.toLowerCase())},customMessage:function(t,e){var i=this.settings.messages[t];return i&&(i.constructor===String?i:i[e])},findDefined:function(){for(var t=0;arguments.length>t;t++)if(void 0!==arguments[t])return arguments[t];return void 0},defaultMessage:function(e,i){return this.findDefined(this.customMessage(e.name,i),this.customDataMessage(e,i),!this.settings.ignoreTitle&&e.title||void 0,t.validator.messages[i],"<strong>Warning: No message defined for "+e.name+"</strong>")},formatAndAdd:function(e,i){var s=this.defaultMessage(e,i.method),r=/\$?\{(\d+)\}/g;"function"==typeof s?s=s.call(this,i.parameters,e):r.test(s)&&(s=t.validator.format(s.replace(r,"{$1}"),i.parameters)),this.errorList.push({message:s,element:e}),this.errorMap[e.name]=s,this.submitted[e.name]=s},addWrapper:function(t){return this.settings.wrapper&&(t=t.add(t.parent(this.settings.wrapper))),t},defaultShowErrors:function(){var t,e;for(t=0;this.errorList[t];t++){var i=this.errorList[t];this.settings.highlight&&this.settings.highlight.call(this,i.element,this.settings.errorClass,this.settings.validClass),this.showLabel(i.element,i.message)}if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(t=0;this.successList[t];t++)this.showLabel(this.successList[t]);if(this.settings.unhighlight)for(t=0,e=this.validElements();e[t];t++)this.settings.unhighlight.call(this,e[t],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return t(this.errorList).map(function(){return this.element})},showLabel:function(e,i){var s=this.errorsFor(e);s.length?(s.removeClass(this.settings.validClass).addClass(this.settings.errorClass),s.html(i)):(s=t("<"+this.settings.errorElement+">").attr("for",this.idOrName(e)).addClass(this.settings.errorClass).html(i||""),this.settings.wrapper&&(s=s.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.append(s).length||(this.settings.errorPlacement?this.settings.errorPlacement(s,t(e)):s.insertAfter(e))),!i&&this.settings.success&&(s.text(""),"string"==typeof this.settings.success?s.addClass(this.settings.success):this.settings.success(s,e)),this.toShow=this.toShow.add(s)},errorsFor:function(e){var i=this.idOrName(e);return this.errors().filter(function(){return t(this).attr("for")===i})},idOrName:function(t){return this.groups[t.name]||(this.checkable(t)?t.name:t.id||t.name)},validationTargetFor:function(t){return this.checkable(t)&&(t=this.findByName(t.name).not(this.settings.ignore)[0]),t},checkable:function(t){return/radio|checkbox/i.test(t.type)},findByName:function(e){return t(this.currentForm).find("[name='"+e+"']")},getLength:function(e,i){switch(i.nodeName.toLowerCase()){case"select":return t("option:selected",i).length;case"input":if(this.checkable(i))return this.findByName(i.name).filter(":checked").length}return e.length},depend:function(t,e){return this.dependTypes[typeof t]?this.dependTypes[typeof t](t,e):!0},dependTypes:{"boolean":function(t){return t},string:function(e,i){return!!t(e,i.form).length},"function":function(t,e){return t(e)}},optional:function(e){var i=this.elementValue(e);return!t.validator.methods.required.call(this,i,e)&&"dependency-mismatch"},startRequest:function(t){this.pending[t.name]||(this.pendingRequest++,this.pending[t.name]=!0)},stopRequest:function(e,i){this.pendingRequest--,0>this.pendingRequest&&(this.pendingRequest=0),delete this.pending[e.name],i&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(t(this.currentForm).submit(),this.formSubmitted=!1):!i&&0===this.pendingRequest&&this.formSubmitted&&(t(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(e){return t.data(e,"previousValue")||t.data(e,"previousValue",{old:null,valid:!0,message:this.defaultMessage(e,"remote")})}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(e,i){e.constructor===String?this.classRuleSettings[e]=i:t.extend(this.classRuleSettings,e)},classRules:function(e){var i={},s=t(e).attr("class");return s&&t.each(s.split(" "),function(){this in t.validator.classRuleSettings&&t.extend(i,t.validator.classRuleSettings[this])}),i},attributeRules:function(e){var i={},s=t(e),r=s[0].getAttribute("type");for(var n in t.validator.methods){var a;"required"===n?(a=s.get(0).getAttribute(n),""===a&&(a=!0),a=!!a):a=s.attr(n),/min|max/.test(n)&&(null===r||/number|range|text/.test(r))&&(a=Number(a)),a?i[n]=a:r===n&&"range"!==r&&(i[n]=!0)}return i.maxlength&&/-1|2147483647|524288/.test(i.maxlength)&&delete i.maxlength,i},dataRules:function(e){var i,s,r={},n=t(e);for(i in t.validator.methods)s=n.data("rule-"+i.toLowerCase()),void 0!==s&&(r[i]=s);return r},staticRules:function(e){var i={},s=t.data(e.form,"validator");return s.settings.rules&&(i=t.validator.normalizeRule(s.settings.rules[e.name])||{}),i},normalizeRules:function(e,i){return t.each(e,function(s,r){if(r===!1)return delete e[s],void 0;if(r.param||r.depends){var n=!0;switch(typeof r.depends){case"string":n=!!t(r.depends,i.form).length;break;case"function":n=r.depends.call(i,i)}n?e[s]=void 0!==r.param?r.param:!0:delete e[s]}}),t.each(e,function(s,r){e[s]=t.isFunction(r)?r(i):r}),t.each(["minlength","maxlength"],function(){e[this]&&(e[this]=Number(e[this]))}),t.each(["rangelength","range"],function(){var i;e[this]&&(t.isArray(e[this])?e[this]=[Number(e[this][0]),Number(e[this][1])]:"string"==typeof e[this]&&(i=e[this].split(/[\s,]+/),e[this]=[Number(i[0]),Number(i[1])]))}),t.validator.autoCreateRanges&&(e.min&&e.max&&(e.range=[e.min,e.max],delete e.min,delete e.max),e.minlength&&e.maxlength&&(e.rangelength=[e.minlength,e.maxlength],delete e.minlength,delete e.maxlength)),e},normalizeRule:function(e){if("string"==typeof e){var i={};t.each(e.split(/\s/),function(){i[this]=!0}),e=i}return e},addMethod:function(e,i,s){t.validator.methods[e]=i,t.validator.messages[e]=void 0!==s?s:t.validator.messages[e],3>i.length&&t.validator.addClassRules(e,t.validator.normalizeRule(e))},methods:{required:function(e,i,s){if(!this.depend(s,i))return"dependency-mismatch";if("select"===i.nodeName.toLowerCase()){var r=t(i).val();return r&&r.length>0}return this.checkable(i)?this.getLength(e,i)>0:t.trim(e).length>0},email:function(t,e){return this.optional(e)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(t)},url:function(t,e){return this.optional(e)||/^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(t)},date:function(t,e){return this.optional(e)||!/Invalid|NaN/.test(""+new Date(t))},dateISO:function(t,e){return this.optional(e)||/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(t)},number:function(t,e){return this.optional(e)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(t)},digits:function(t,e){return this.optional(e)||/^\d+$/.test(t)},creditcard:function(t,e){if(this.optional(e))return"dependency-mismatch";if(/[^0-9 \-]+/.test(t))return!1;var i=0,s=0,r=!1;t=t.replace(/\D/g,"");for(var n=t.length-1;n>=0;n--){var a=t.charAt(n);s=parseInt(a,10),r&&(s*=2)>9&&(s-=9),i+=s,r=!r}return 0===i%10},minlength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||r>=s},maxlength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||s>=r},rangelength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||r>=s[0]&&s[1]>=r},min:function(t,e,i){return this.optional(e)||t>=i},max:function(t,e,i){return this.optional(e)||i>=t},range:function(t,e,i){return this.optional(e)||t>=i[0]&&i[1]>=t},equalTo:function(e,i,s){var r=t(s);return this.settings.onfocusout&&r.unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){t(i).valid()}),e===r.val()},remote:function(e,i,s){if(this.optional(i))return"dependency-mismatch";var r=this.previousValue(i);if(this.settings.messages[i.name]||(this.settings.messages[i.name]={}),r.originalMessage=this.settings.messages[i.name].remote,this.settings.messages[i.name].remote=r.message,s="string"==typeof s&&{url:s}||s,r.old===e)return r.valid;r.old=e;var n=this;this.startRequest(i);var a={};return a[i.name]=e,t.ajax(t.extend(!0,{url:s,mode:"abort",port:"validate"+i.name,dataType:"json",data:a,success:function(s){n.settings.messages[i.name].remote=r.originalMessage;var a=s===!0||"true"===s;if(a){var u=n.formSubmitted;n.prepareElement(i),n.formSubmitted=u,n.successList.push(i),delete n.invalid[i.name],n.showErrors()}else{var o={},l=s||n.defaultMessage(i,"remote");o[i.name]=r.message=t.isFunction(l)?l(e):l,n.invalid[i.name]=!0,n.showErrors(o)}r.valid=a,n.stopRequest(i,a)}},s)),"pending"}}}),t.format=t.validator.format})(jQuery),function(t){var e={};if(t.ajaxPrefilter)t.ajaxPrefilter(function(t,i,s){var r=t.port;"abort"===t.mode&&(e[r]&&e[r].abort(),e[r]=s)});else{var i=t.ajax;t.ajax=function(s){var r=("mode"in s?s:t.ajaxSettings).mode,n=("port"in s?s:t.ajaxSettings).port;return"abort"===r?(e[n]&&e[n].abort(),e[n]=i.apply(this,arguments),e[n]):i.apply(this,arguments)}}}(jQuery),function(t){t.extend(t.fn,{validateDelegate:function(e,i,s){return this.bind(i,function(i){var r=t(i.target);return r.is(e)?s.apply(r,arguments):void 0})}})}(jQuery);
 
 
embedded/resources/js/modal.js ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($){
2
+
3
+ $.fn.types_modal_box = function(prop){
4
+
5
+ // Default parameters
6
+
7
+ var options = $.extend({
8
+ height : 364,
9
+ width : 525
10
+ },prop);
11
+
12
+ return this.click(function(e){
13
+ add_block_page();
14
+ add_popup_box();
15
+ add_styles();
16
+
17
+ $('.types_modal_box').fadeIn();
18
+ });
19
+
20
+ function add_styles(){
21
+ $('.types_modal_box').css({
22
+ position: "absolute",
23
+ display: "none",
24
+ height: options.height.toString() + "px",
25
+ width: options.width.toString() + "px",
26
+ background: "#fff none no-repeat 0 0",
27
+ zIndex: 151,
28
+ border: "1px solid #888",
29
+ boxShadow: "7px 7px 20px 0px rgba(50, 50, 50, 0.75)",
30
+ });
31
+ /*Block page overlay*/
32
+ var pageHeight = $(document).height();
33
+ var pageWidth = $(window).width();
34
+
35
+ $('.types_block_page').css({
36
+ position: "absolute",
37
+ top: 0,
38
+ left: 0,
39
+ backgroundColor: "transparent",
40
+ height: pageHeight,
41
+ width: pageWidth,
42
+ zIndex: 101
43
+ });
44
+
45
+ $('.types_modal_box .message').css({
46
+ color: "#f05a28",
47
+ fontFamily: "'Open Sans', Helvetica, Arial, sans-serif",
48
+ fontSize: "25px",
49
+ padding: "0 10px",
50
+ textAlign: "center"
51
+ });
52
+ $('.types_modal_box .message span').css({
53
+ background: "transparent url("+types_modal.spinner+") no-repeat 0 50%",
54
+ paddingLeft: "30px",
55
+ lineHeight: "105px"
56
+ });
57
+ }
58
+
59
+ function add_block_page(){
60
+ var block_page = $('<div class="types_block_page"></div>');
61
+ $(block_page).appendTo('body');
62
+ }
63
+
64
+ function add_popup_box(){
65
+ var marginLeft, height, paddingTop, width;
66
+ var header = types_modal.header;
67
+
68
+ if ( !header ) {
69
+ return;
70
+ }
71
+
72
+ var html = '<div class="types_modal_box '+types_modal.class+'">';
73
+ html += '<div class="message"><span>'+types_modal.message+'</span></div>';
74
+ if ( 'endabled' == types_modal.state ) {
75
+ html += '<div class="header"><div>';
76
+ if ( types_modal.question ) {
77
+ html += '<span class="question">';
78
+ html += types_modal.question;
79
+ html += '</span>';
80
+ }
81
+ html += '<p>'+header+'</p></div></div>';
82
+ } else {
83
+ options.height = 106;
84
+ }
85
+ html += '</div>';
86
+ var pop_up = $(html);
87
+
88
+ pop_up.appendTo('.types_block_page');
89
+ $('#post-body .wpcf-loading').detach();
90
+
91
+ pop_up.css({
92
+ top: ($('body').scrollTop() + $('body').height()/2 - options.height/2).toString()+"px",
93
+ left: ($('body').width()/2 - options.width/2).toString()+"px",
94
+ });
95
+ $('.header', pop_up).css({
96
+ height: "259px",
97
+ textAlign: "center",
98
+ color: "#fff",
99
+ fontSize:"15px",
100
+ backgroundImage: 'url('+types_modal.image+'?v=2)',
101
+ backgroundRepeat: "no-repeat",
102
+ });
103
+ /**
104
+ * header div
105
+ */
106
+ marginLeft = "290px";
107
+ width = "220px";
108
+ paddingTop = "50px";
109
+ height = "150px";
110
+ switch(types_modal.class) {
111
+ case 'cred':
112
+ paddingTop = "77px";
113
+ marginLeft = "260px";
114
+ width = "250px";
115
+ height = "100px";
116
+ break;
117
+ case 'access':
118
+ marginLeft = "270px";
119
+ width = "250px";
120
+ paddingTop = "25px";
121
+ height = "120px";
122
+ break;
123
+ }
124
+ $('.header div', pop_up).css({
125
+ float: "left",
126
+ height: height,
127
+ marginLeft: marginLeft,
128
+ paddingTop: paddingTop,
129
+ textAlign: "left",
130
+ width: width
131
+
132
+ });
133
+ /**
134
+ * header p
135
+ */
136
+ $('.header p', pop_up).css({
137
+ fontFamily: "'Open Sans', Helvetica, Arial, sans-serif",
138
+ fontSize: "18px",
139
+ lineHeight: "1.2em",
140
+ margin: 0
141
+ });
142
+ $('.header .question', pop_up).css({
143
+ display: "block",
144
+ fontSize: "14px",
145
+ marginBottom: "5px"
146
+ });
147
+ }
148
+
149
+ return this;
150
+ };
151
+
152
+ })(jQuery);
embedded/resources/js/post-relationship.js CHANGED
@@ -426,6 +426,7 @@ jQuery(document).ready(function($) {
426
  return false;
427
  });
428
  jQuery('.wpcf-pr-delete-ajax').live('click', function() {
 
429
  var answer = confirm(wpcf_pr_del_warning);
430
  if (answer == false) {
431
  return false;
@@ -452,6 +453,17 @@ jQuery(document).ready(function($) {
452
  object.next().fadeOut(function() {
453
  jQuery(this).remove();
454
  });
 
 
 
 
 
 
 
 
 
 
 
455
  }
456
  });
457
  return false;
426
  return false;
427
  });
428
  jQuery('.wpcf-pr-delete-ajax').live('click', function() {
429
+ var $button = $(this), $table = $button.parents('.js-types-relationship-child-posts').find('table');
430
  var answer = confirm(wpcf_pr_del_warning);
431
  if (answer == false) {
432
  return false;
453
  object.next().fadeOut(function() {
454
  jQuery(this).remove();
455
  });
456
+ /**
457
+ * reload
458
+ */
459
+ selectedIndex = $('#wpcf-post-relationship .wpcf-pr-pagination-select').prop('selectedIndex');
460
+ if ( $('tbody tr', $table).length < 2 ) {
461
+ if ( selectedIndex ) {
462
+ selectedIndex--;
463
+ $('#wpcf-post-relationship .wpcf-pr-pagination-select').prop( 'selectedIndex', selectedIndex);
464
+ }
465
+ }
466
+ $('#wpcf-post-relationship .wpcf-pr-pagination-select').trigger('change');
467
  }
468
  });
469
  return false;
embedded/usermeta-init.php CHANGED
@@ -10,7 +10,7 @@ $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.4/embedded/usermeta-init.php $
14
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
15
  * $LastChangedRevision: 1027712 $
16
  * $LastChangedBy: iworks $
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/embedded/usermeta-init.php $
14
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
15
  * $LastChangedRevision: 1027712 $
16
  * $LastChangedBy: iworks $
help.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Plugin contextual help
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/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.5/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
@@ -32,7 +32,7 @@ function wpcf_ajax() {
32
  'output' => ''
33
  ));
34
  break;
35
-
36
  case 'remove_from_history2':
37
  require_once WPCF_INC_ABSPATH . '/fields.php';
38
  $fields = wpcf_admin_fields_get_fields( true, true,false,'wpcf-usermeta');
@@ -43,8 +43,8 @@ function wpcf_ajax() {
43
  echo json_encode(array(
44
  'output' => ''
45
  ));
46
- break;
47
-
48
  case 'deactivate_user_group':
49
  require_once WPCF_INC_ABSPATH . '/fields.php';
50
  require_once WPCF_INC_ABSPATH . '/usermeta.php';
@@ -65,7 +65,7 @@ function wpcf_ajax() {
65
  ));
66
  }
67
  break;
68
-
69
  case 'activate_user_group':
70
  require_once WPCF_INC_ABSPATH . '/fields.php';
71
  require_once WPCF_INC_ABSPATH . '/usermeta.php';
@@ -85,8 +85,8 @@ function wpcf_ajax() {
85
  'output' => __('Error occured', 'wpcf')
86
  ));
87
  }
88
- break;
89
-
90
  case 'delete_usermeta_group':
91
  require_once WPCF_INC_ABSPATH . '/fields.php';
92
  require_once WPCF_INC_ABSPATH . '/usermeta.php';
@@ -98,8 +98,8 @@ function wpcf_ajax() {
98
  . '").parents("tr").css("background-color", "#FF0000").fadeOut();',
99
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
100
  ));
101
- break;
102
-
103
  case 'usermeta_insert_existing':
104
  require_once WPCF_INC_ABSPATH . '/fields.php';
105
  require_once WPCF_INC_ABSPATH . '/fields-form.php';
@@ -108,10 +108,10 @@ function wpcf_ajax() {
108
  wpcf_form_render_js_validation();
109
  break;
110
  /* End Usertmeta actions*/
111
-
112
-
113
-
114
-
115
  case 'fields_insert':
116
  require_once WPCF_INC_ABSPATH . '/fields.php';
117
  require_once WPCF_INC_ABSPATH . '/fields-form.php';
@@ -564,20 +564,22 @@ function wpcf_ajax() {
564
  break;
565
 
566
  case 'cb_save_empty_migrate':
567
- $output = '<span style="color:red;">'
568
- . __('Wrong field specified', 'wpcf') . '</div>';
 
 
569
  if (isset($_GET['field']) && isset($_GET['subaction'])) {
570
  require_once WPCF_INC_ABSPATH . '/fields.php';
571
  $option = $_GET['meta_type'] == 'usermeta' ? 'wpcf-usermeta' : 'wpcf-fields';
572
  $meta_type = $_GET['meta_type'];
573
  $field = wpcf_admin_fields_get_field($_GET['field'], false, false,
574
  false, $option);
575
-
576
  $_txt_updates = $meta_type == 'usermeta' ? __( '%d users require update',
577
  'wpcf' ) : __( '%d posts require update', 'wpcf' );
578
  $_txt_no_updates = $meta_type == 'usermeta' ? __('No users require update', 'wpcf') : __('No posts require update', 'wpcf');
579
  $_txt_updated = $meta_type == 'usermeta' ? __('Users updated', 'wpcf') : __('Posts updated', 'wpcf');
580
-
581
  if (!empty($field)) {
582
  if ($_GET['subaction'] == 'save_check'
583
  || $_GET['subaction'] == 'do_not_save_check') {
32
  'output' => ''
33
  ));
34
  break;
35
+
36
  case 'remove_from_history2':
37
  require_once WPCF_INC_ABSPATH . '/fields.php';
38
  $fields = wpcf_admin_fields_get_fields( true, true,false,'wpcf-usermeta');
43
  echo json_encode(array(
44
  'output' => ''
45
  ));
46
+ break;
47
+
48
  case 'deactivate_user_group':
49
  require_once WPCF_INC_ABSPATH . '/fields.php';
50
  require_once WPCF_INC_ABSPATH . '/usermeta.php';
65
  ));
66
  }
67
  break;
68
+
69
  case 'activate_user_group':
70
  require_once WPCF_INC_ABSPATH . '/fields.php';
71
  require_once WPCF_INC_ABSPATH . '/usermeta.php';
85
  'output' => __('Error occured', 'wpcf')
86
  ));
87
  }
88
+ break;
89
+
90
  case 'delete_usermeta_group':
91
  require_once WPCF_INC_ABSPATH . '/fields.php';
92
  require_once WPCF_INC_ABSPATH . '/usermeta.php';
98
  . '").parents("tr").css("background-color", "#FF0000").fadeOut();',
99
  'wpcf_nonce_ajax_callback' => wp_create_nonce('execute'),
100
  ));
101
+ break;
102
+
103
  case 'usermeta_insert_existing':
104
  require_once WPCF_INC_ABSPATH . '/fields.php';
105
  require_once WPCF_INC_ABSPATH . '/fields-form.php';
108
  wpcf_form_render_js_validation();
109
  break;
110
  /* End Usertmeta actions*/
111
+
112
+
113
+
114
+
115
  case 'fields_insert':
116
  require_once WPCF_INC_ABSPATH . '/fields.php';
117
  require_once WPCF_INC_ABSPATH . '/fields-form.php';
564
  break;
565
 
566
  case 'cb_save_empty_migrate':
567
+ $output = sprintf(
568
+ '<span style="color:red;">%s</div>',
569
+ __('Migration process is not yet finished - please save group first, then change settings of this field.', 'wpcf')
570
+ );
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',
579
  'wpcf' ) : __( '%d posts require update', 'wpcf' );
580
  $_txt_no_updates = $meta_type == 'usermeta' ? __('No users require update', 'wpcf') : __('No posts require update', 'wpcf');
581
  $_txt_updated = $meta_type == 'usermeta' ? __('Users updated', 'wpcf') : __('Posts updated', 'wpcf');
582
+
583
  if (!empty($field)) {
584
  if ($_GET['subaction'] == 'save_check'
585
  || $_GET['subaction'] == 'do_not_save_check') {
includes/common-functions.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Custom types form - common functions
5
+ *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/includes/common-functions.php $
7
+ * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
8
+ * $LastChangedRevision: 1069430 $
9
+ * $LastChangedBy: iworks $
10
+ *
11
+ */
12
+
13
+ function wpcf_admin_metabox_end($table_show = true)
14
+ {
15
+ $markup = '';
16
+ if ( $table_show ) {
17
+ $markup .= '</td></tr></tbody></table>';
18
+ }
19
+ $markup .= '</div></div>';
20
+ return array(
21
+ '#type' => 'markup',
22
+ '#markup' => $markup,
23
+ );
24
+ }
25
+
26
+ function wpcf_admin_metabox_begin($title, $id = false, $table_id = false, $table_show = true)
27
+ {
28
+ $screen = get_current_screen();
29
+ $markup = sprintf(
30
+ '<div class="postbox %s" %s><div title="%s" class="handlediv"><br></div><h3 class="hndle">%s</h3><div class="inside">',
31
+ postbox_classes($id, $screen->id),
32
+ $id? sprintf('id="%s"', $id):'',
33
+ __('Click to toggle'),
34
+ $title
35
+ );
36
+ if ( $table_show ) {
37
+ $markup .= sprintf(
38
+ '<table %s class="wpcf-types-form-table widefat"><tbody><tr><td>',
39
+ $table_id? sprintf( 'id="%s"', $table_id):''
40
+ );
41
+ }
42
+ return array(
43
+ '#type' => 'markup',
44
+ '#markup' => $markup,
45
+ );
46
+ }
47
+
48
+ function wpcf_admin_common_metabox_save($cf, $button_text)
49
+ {
50
+ $form = array();
51
+ $form['submit-open'] = wpcf_admin_metabox_begin(__( 'Save', 'wpcf' ), 'submitdiv', false, false);
52
+ $form['submit-div-open'] = array(
53
+ '#type' => 'markup',
54
+ '#markup' => '<div class="submitbox" id="submitpost"><div id="major-publishing-actions"><div id="publishing-action"><span class="spinner"></span>',
55
+ );
56
+ $form['submit'] = array(
57
+ '#type' => 'submit',
58
+ '#name' => 'submit',
59
+ '#value' => $button_text,
60
+ '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'),
61
+ );
62
+ $form['submit-div-close'] = array(
63
+ '#type' => 'markup',
64
+ '#markup' => '</div><div class="clear"></div></div></div>',
65
+ );
66
+ $form['submit-close'] = wpcf_admin_metabox_end();
67
+ return $form;
68
+ }
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.4/includes/custom-taxonomies-form.php $
7
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
- * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
@@ -17,6 +17,8 @@ function wpcf_admin_custom_taxonomies_form() {
17
 
18
  global $wpcf;
19
 
 
 
20
  $ct = array();
21
  $id = false;
22
  $update = false;
@@ -46,6 +48,19 @@ function wpcf_admin_custom_taxonomies_form() {
46
  }
47
 
48
  $form = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  $form['#form']['callback'] = 'wpcf_admin_custom_taxonomies_form_submit';
50
  $form['#form']['redirection'] = false;
51
 
@@ -57,6 +72,28 @@ function wpcf_admin_custom_taxonomies_form() {
57
  );
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  $form['table-1-open'] = array(
61
  '#type' => 'markup',
62
  '#markup' => '<table id="wpcf-types-form-name-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="2">' . __( 'Name and description',
@@ -149,252 +186,99 @@ function wpcf_admin_custom_taxonomies_form() {
149
  '#type' => 'markup',
150
  '#markup' => '</tbody></table>',
151
  );
152
- $form['table-2-open'] = array(
153
- '#type' => 'markup',
154
- '#markup' => '<table id="wpcf-types-form-visibility-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __( 'Visibility',
155
- 'wpcf' ) . '</th></tr></thead><tbody><tr><td>',
156
- );
157
- $form['public'] = array(
158
- '#type' => 'radios',
159
- '#name' => 'ct[public]',
160
- '#options' => array(
161
- __( 'Make this taxonomy public (will appear in the WordPress Admin menu)',
162
- 'wpcf' ) => 'public',
163
- __( 'Hidden - users cannot directly edit data in this taxonomy',
164
- 'wpcf' ) => 'hidden',
165
- ),
166
- '#default_value' => (isset( $ct['public'] ) && strval( $ct['public'] ) == 'hidden') ? 'hidden' : 'public',
167
- '#inline' => true,
168
- );
169
- $form['table-2-close'] = array(
170
  '#type' => 'markup',
171
- '#markup' => '</td></tr></tbody></table>',
172
  );
173
 
174
- $post_types = get_post_types( '', 'objects' );
175
- $options = array();
176
 
177
- foreach ( $post_types as $post_type_slug => $post_type ) {
178
- if ( in_array( $post_type_slug, $wpcf->excluded_post_types )
179
- || !$post_type->show_ui ) {
180
- continue;
181
- }
182
- $options[$post_type_slug]['#name'] = 'ct[supports][' . $post_type_slug . ']';
183
- $options[$post_type_slug]['#title'] = $post_type->labels->singular_name;
184
- $options[$post_type_slug]['#default_value'] = !empty( $ct['supports'][$post_type_slug] );
185
- $options[$post_type_slug]['#inline'] = true;
186
- $options[$post_type_slug]['#after'] = '&nbsp;&nbsp;';
187
- if ( is_rtl() ) {
188
- $options[$post_type_slug]['#before'] = '<div style="float:right;margin-left:10px;">';
189
- $options[$post_type_slug]['#after'] .= '</div>';
190
  }
191
  }
192
 
193
- $form['table-3-open'] = array(
194
- '#type' => 'markup',
195
- '#markup' => '<table id="wpcf-types-form-taxonomies-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __( 'Select Post Types',
196
- 'wpcf' ) . '</th></tr></thead><tbody><tr><td>',
 
 
197
  );
198
- $form['types'] = array(
199
- '#type' => 'checkboxes',
200
- '#options' => $options,
201
- '#description' => __( 'Registered post types that will be used with this taxonomy.',
202
- 'wpcf' ),
203
- '#name' => 'ct[supports]',
204
- '#inline' => true,
205
- );
206
- $form['table-3-close'] = array(
207
- '#type' => 'markup',
208
- '#markup' => '</td></tr></tbody></table>',
209
- );
210
- $form['table-4-open'] = array(
211
  '#type' => 'markup',
212
- '#markup' => '<table id="wpcf-types-form-labels-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="3">' . __( 'Labels',
213
- 'wpcf' ) . '</th></tr></thead><tbody>',
214
  );
215
- $labels = array(
216
- 'search_items' => array('title' => __( 'Search %s', 'wpcf' ), 'description' => __( "The search items text. Default is __( 'Search Tags' ) or __( 'Search Categories' ).",
217
- 'wpcf' )),
218
- 'popular_items' => array('title' => __( 'Popular %s', 'wpcf' ), 'description' => __( "The popular items text. Default is __( 'Popular Tags' ) or null.",
219
- 'wpcf' )),
220
- 'all_items' => array('title' => __( 'All %s', 'wpcf' ), 'description' => __( "The all items text. Default is __( 'All Tags' ) or __( 'All Categories' ).",
221
- 'wpcf' )),
222
- 'parent_item' => array('title' => __( 'Parent %s', 'wpcf' ), 'description' => __( "The parent item text. This string is not used on non-hierarchical taxonomies such as post tags. Default is null or __( 'Parent Category' ).",
223
- 'wpcf' )),
224
- 'parent_item_colon' => array('title' => __( 'Parent %s:', 'wpcf' ), 'description' => __( "The same as parent_item, but with colon : in the end null, __( 'Parent Category:' ).",
225
- 'wpcf' )),
226
- 'edit_item' => array('title' => __( 'Edit %s', 'wpcf' ), 'description' => __( "The edit item text. Default is __( 'Edit Tag' ) or __( 'Edit Category' ).",
227
- 'wpcf' )),
228
- 'update_item' => array('title' => __( 'Update %s', 'wpcf' ), 'description' => __( "The update item text. Default is __( 'Update Tag' ) or __( 'Update Category' ).",
229
- 'wpcf' )),
230
- 'add_new_item' => array('title' => __( 'Add New %s', 'wpcf' ), 'description' => __( "The add new item text. Default is __( 'Add New Tag' ) or __( 'Add New Category' ).",
231
- 'wpcf' )),
232
- 'new_item_name' => array('title' => __( 'New %s Name', 'wpcf' ), 'description' => __( "The new item name text. Default is __( 'New Tag Name' ) or __( 'New Category Name' ).",
233
- 'wpcf' )),
234
- 'separate_items_with_commas' => array('title' => __( 'Separate %s with commas',
235
- 'wpcf' ), 'description' => __( "The separate item with commas text used in the taxonomy meta box. This string isn't used on hierarchical taxonomies. Default is __( 'Separate tags with commas' ), or null.",
236
- 'wpcf' )),
237
- 'add_or_remove_items' => array('title' => __( 'Add or remove %s', 'wpcf' ), 'description' => __( "the add or remove items text used in the meta box when JavaScript is disabled. This string isn't used on hierarchical taxonomies. Default is __( 'Add or remove tags' ) or null.",
238
- 'wpcf' )),
239
- 'choose_from_most_used' => array('title' => __( 'Choose from the most used %s',
240
- 'wpcf' ), 'description' => __( "The choose from most used text used in the taxonomy meta box. This string isn't used on hierarchical taxonomies. Default is __( 'Choose from the most used tags' ) or null.",
241
- 'wpcf' )),
242
- 'menu_name' => array('title' => __( 'Menu Name', 'wpcf' ), 'description' => __( "The menu name text. This string is the name to give menu items. Defaults to value of name.",
243
- 'wpcf' )),
244
- );
245
- foreach ( $labels as $name => $data ) {
246
- $form['labels-' . $name] = array(
247
- '#type' => 'textfield',
248
- '#name' => 'ct[labels][' . $name . ']',
249
- '#title' => ucwords( str_replace( '_', ' ', $name ) ),
250
- '#description' => $data['description'],
251
- '#value' => isset( $ct['labels'][$name] ) ? $ct['labels'][$name] : '',
252
- '#inline' => true,
253
- '#pattern' => '<tr><td><LABEL></td><td><ELEMENT></td><td><DESCRIPTION></td>',
254
- );
255
  }
256
- $form['table-4-close'] = array(
 
257
  '#type' => 'markup',
258
- '#markup' => '</tbody></table>',
259
  );
260
- $form['table-6-open'] = array(
 
 
 
 
 
261
  '#type' => 'markup',
262
- '#markup' => '<table id="wpcf-types-form-supports-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __( 'Options', 'wpcf' ) . '</th></tr></thead><tbody><tr><td>',
263
  );
264
- $form['make-hierarchical'] = array(
265
- '#type' => 'radios',
266
- '#name' => 'ct[hierarchical]',
267
- '#default_value' => (empty( $ct['hierarchical'] ) || $ct['hierarchical'] == 'flat') ? 'flat' : 'hierarchical',
268
- // '#title' => __('hierarchical', 'wpcf'),
269
- // '#description' => __('Is this taxonomy hierarchical (have descendants) like categories or not hierarchical like tags.',
270
- // 'wpcf') . '<br />' . __('Default: false.', 'wpcf'),
271
- '#inline' => true,
272
- '#options' => array(
273
- __( 'Hierarchical - like post categories, with parent / children relationship and checkboxes to select taxonomy',
274
- 'wpcf' ) => 'hierarchical',
275
- __( 'Flat - like post tags, with a text input to enter terms',
276
- 'wpcf' ) => 'flat'
277
- ),
278
- '#after' => '<br /><br />',
279
- );
280
- $form['rewrite-enabled'] = array(
281
- '#type' => 'checkbox',
282
- '#force_boolean' => true,
283
- '#title' => __( 'Rewrite', 'wpcf' ),
284
- '#name' => 'ct[rewrite][enabled]',
285
- '#description' => __( 'Rewrite permalinks with this format. Default will use $taxonomy as query var.',
286
- 'wpcf' ),
287
- '#default_value' => !empty( $ct['rewrite']['enabled'] ),
288
- '#inline' => true,
289
- );
290
- $hidden = empty( $ct['rewrite']['enabled'] ) ? ' class="hidden"' : '';
291
- $form['rewrite-slug'] = array(
292
- '#type' => 'textfield',
293
- '#name' => 'ct[rewrite][slug]',
294
- '#title' => __( 'Prepend posts with this slug', 'wpcf' ),
295
- '#description' => __( 'Optional', 'wpcf' ) . '. ' . __( "Prepend posts with this slug - defaults to taxonomy's name.",
296
- 'wpcf' ),
297
- '#value' => isset( $ct['rewrite']['slug'] ) ? $ct['rewrite']['slug'] : '',
298
- '#inline' => true,
299
- '#before' => '<div id="wpcf-types-form-rewrite-toggle"' . $hidden . '>',
300
- '#after' => '</div>',
301
- '#validate' => array('rewriteslug' => array('value' => 'true')),
302
- );
303
- $form['rewrite-with_front'] = array(
304
- '#type' => 'checkbox',
305
- '#force_boolean' => true,
306
- '#title' => __( 'Allow permalinks to be prepended with front base',
307
- 'wpcf' ),
308
- '#name' => 'ct[rewrite][with_front]',
309
- '#description' => __( 'Defaults to true.', 'wpcf' ),
310
- '#default_value' => !empty( $ct['rewrite']['with_front'] ),
311
- '#inline' => true,
312
- );
313
- $form['rewrite-hierarchical'] = array(
314
- '#type' => 'checkbox',
315
- '#name' => 'ct[rewrite][hierarchical]',
316
- '#title' => __( 'Hierarchical URLs', 'wpcf' ),
317
- '#description' => sprintf( __( 'True or false allow hierarchical urls (implemented in %sVersion 3.1%s).',
318
- 'wpcf' ),
319
- '<a href="http://codex.wordpress.org/Version_3.1" title="Version 3.1" target="_blank">',
320
- '</a>' ),
321
- '#default_value' => !empty( $ct['rewrite']['hierarchical'] ),
322
- '#inline' => true,
323
- );
324
- $form['vars'] = array(
325
- '#type' => 'checkboxes',
326
- '#name' => 'ct[advanced]',
327
- '#inline' => true,
328
- '#options' => array(
329
- 'show_ui' => array(
330
- '#name' => 'ct[show_ui]',
331
- '#default_value' => !empty( $ct['show_ui'] ),
332
- '#title' => __( 'show_ui', 'wpcf' ),
333
- '#description' => __( 'Whether to generate a default UI for managing this taxonomy.',
334
- 'wpcf' ) . '<br />' . __( 'Default: if not set, defaults to value of public argument.',
335
- 'wpcf' ),
336
- '#inline' => true,
337
- ),
338
- 'show_in_nav_menus' => array(
339
- '#name' => 'ct[show_in_nav_menus]',
340
- '#default_value' => !empty( $ct['show_in_nav_menus'] ),
341
- '#title' => __( 'show_in_nav_menus', 'wpcf' ),
342
- '#description' => __( 'True makes this taxonomy available for selection in navigation menus.',
343
- 'wpcf' ) . '<br />' . __( 'Default: if not set, defaults to value of public argument.',
344
- 'wpcf' ),
345
- '#inline' => true,
346
- ),
347
- 'show_tagcloud' => array(
348
- '#name' => 'ct[show_tagcloud]',
349
- '#default_value' => !empty( $ct['show_tagcloud'] ),
350
- '#title' => __( 'show_tagcloud', 'wpcf' ),
351
- '#description' => __( 'Whether to allow the Tag Cloud widget to use this taxonomy.',
352
- 'wpcf' ) . '<br />' . __( 'Default: if not set, defaults to value of show_ui argument.',
353
- 'wpcf' ),
354
- '#inline' => true,
355
- ),
356
- ),
357
- );
358
- if ( wpcf_compare_wp_version( '3.5', '>=' )) {
359
- $form['vars']['#options']['show_admin_column'] = array(
360
- '#name' => 'ct[show_admin_column]',
361
- '#default_value' => !empty( $ct['show_admin_column'] ),
362
- '#title' => __( 'show_admin_column', 'wpcf' ),
363
- '#description' => __( 'Whether to allow automatic creation of taxonomy columns on associated post-types.', 'wpcf' ) . '<br />' . __( 'Default: false.', 'wpcf' ),
364
- '#inline' => true,
365
- );
366
  }
367
- $query_var = isset( $ct['query_var'] ) ? $ct['query_var'] : '';
368
- $hidden = !empty( $ct['query_var_enabled'] ) ? '' : ' class="hidden"';
369
- $form['query_var'] = array(
370
- '#type' => 'checkbox',
371
- '#name' => 'ct[query_var_enabled]',
372
- '#title' => 'query_var',
373
- '#description' => __( 'False to prevent queries, or string to customize query var. Default will use $taxonomy as query var.',
374
- 'wpcf' ) . '<br />' . __( 'Default: $taxonomy.', 'wpcf' ),
375
- '#default_value' => !empty( $ct['query_var_enabled'] ),
376
- '#after' => '<div id="wpcf-types-form-queryvar-toggle"' . $hidden . '><input type="text" name="ct[query_var]" value="' . $query_var . '" class="wpcf-form-textfield form-textfield textfield" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __( 'Optional',
377
- 'wpcf' ) . '. ' . __( 'String to customize query var', 'wpcf' ) . '</div></div>',
378
- '#inline' => true,
379
- );
380
- $form['update_count_callback'] = array(
381
- '#type' => 'textfield',
382
- '#name' => 'ct[update_count_callback]',
383
- '#title' => 'update_count_callback', 'wpcf',
384
- '#description' => __( 'Function name that will be called to update the count of an associated $object_type, such as post, is updated.',
385
- 'wpcf' ) . '<br />' . __( 'Default: None.', 'wpcf' ),
386
- '#value' => !empty( $ct['update_count_callback'] ) ? $ct['update_count_callback'] : '',
387
- '#inline' => true,
388
- );
389
- $form['table-6-close'] = array(
390
  '#type' => 'markup',
391
- '#markup' => '</td></tr></tbody></table>',
392
  );
393
- $form['submit'] = array(
394
- '#type' => 'submit',
395
- '#name' => 'submit',
396
- '#value' => __( 'Save Taxonomy', 'wpcf' ),
397
- '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'),
398
  );
399
 
400
  return $form;
@@ -403,14 +287,16 @@ function wpcf_admin_custom_taxonomies_form() {
403
  /**
404
  * Adds JS validation script.
405
  */
406
- function wpcf_admin_tax_form_js_validation() {
 
407
  wpcf_form_render_js_validation();
408
  }
409
 
410
  /**
411
  * Submit function
412
  */
413
- function wpcf_admin_custom_taxonomies_form_submit( $form ) {
 
414
  if ( !isset( $_POST['ct'] ) ) {
415
  return false;
416
  }
@@ -462,15 +348,13 @@ function wpcf_admin_custom_taxonomies_form_submit( $form ) {
462
 
463
  // Check if exists
464
  if ( $update && !array_key_exists( $data['wpcf-tax'], $custom_taxonomies ) ) {
465
- wpcf_admin_message( __( "Custom taxonomy do not exist", 'wpcf' ),
466
- 'error' );
467
  return false;
468
  }
469
 
470
  // Check overwriting
471
  if ( !$update && array_key_exists( $tax, $custom_taxonomies ) ) {
472
- wpcf_admin_message( __( 'Custom taxonomy already exists', 'wpcf' ),
473
- 'error' );
474
  return false;
475
  }
476
 
@@ -526,6 +410,295 @@ function wpcf_admin_custom_taxonomies_form_submit( $form ) {
526
  flush_rewrite_rules();
527
 
528
  // Redirect
529
- wp_redirect( admin_url( 'admin.php?page=wpcf-edit-tax&wpcf-tax=' . $tax . '&wpcf-rewrite=1' ) );
 
 
 
 
 
 
 
 
 
 
530
  die();
531
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  *
4
  * Custom taxonomies form
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
17
 
18
  global $wpcf;
19
 
20
+ include_once dirname(__FILE__).'/common-functions.php';
21
+
22
  $ct = array();
23
  $id = false;
24
  $update = false;
48
  }
49
 
50
  $form = array();
51
+ /**
52
+ * postbox-controll
53
+ */
54
+ $markup = wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false, false );
55
+ $markup.= wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false, false );
56
+ $form['postbox-controll'] = array(
57
+ '#type' => 'markup',
58
+ '#markup' => $markup,
59
+ );
60
+
61
+ /**
62
+ * form setup
63
+ */
64
  $form['#form']['callback'] = 'wpcf_admin_custom_taxonomies_form_submit';
65
  $form['#form']['redirection'] = false;
66
 
72
  );
73
  }
74
 
75
+ /**
76
+ * WP control for meta boxes
77
+ */
78
+ include_once ABSPATH.'/wp-admin/includes/meta-boxes.php';
79
+ wp_enqueue_script( 'post' );
80
+
81
+ $form['form-open'] = array(
82
+ '#type' => 'markup',
83
+ '#markup' => '<div id="poststuff">',
84
+ );
85
+
86
+ $form['form-metabox-holder-columns-2-open'] = array(
87
+ '#type' => 'markup',
88
+ '#markup' => '<div id="post-body" class="metabox-holder columns-2">',
89
+ );
90
+
91
+ $form['post-body-content-open'] = array(
92
+ '#type' => 'markup',
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',
186
  '#type' => 'markup',
187
  '#markup' => '</tbody></table>',
188
  );
189
+ $form['post-body-content-close'] = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  '#type' => 'markup',
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) )) {
204
+ $meta_box_order = $meta_box_order_defaults;
205
+ } else {
206
+ if ( isset($meta_box_order[0]) && !isset($meta_box_order['normal']) ) {
207
+ $meta_box_order['normal'] = $meta_box_order[0];
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
221
+ */
222
+
223
+ $form['postbox-container-1-open'] = array(
 
 
 
 
 
 
 
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');
231
+ unset($meta_boxes[$key]);
232
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  }
234
+ /* close side container */
235
+ $form['postbox-container-1-close'] = array(
236
  '#type' => 'markup',
237
+ '#markup' => '</div></div>',
238
  );
239
+
240
+ /**
241
+ * normal container
242
+ */
243
+
244
+ $form['postbox-container-2-open'] = array(
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]);
252
+ unset($meta_boxes[$key]);
253
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  }
255
+ /**
256
+ * grab missing meta-boxes
257
+ */
258
+ foreach( array_keys($meta_boxes) as $key ) {
259
+ $function = sprintf('wpcf_admin_metabox_%s', $key);
260
+ if ( is_callable($function) ) {
261
+ $form += $function($meta_boxes[$key]);
262
+ }
263
+ }
264
+
265
+ /**
266
+ * filter wpcf_post_type_form
267
+ */
268
+
269
+ $form = $form + apply_filters( 'wpcf_post_type_form', array(), $ct );
270
+
271
+ /**
272
+ * container-2 close
273
+ */
274
+ $form['postbox-container-2-close'] = array(
 
 
 
275
  '#type' => 'markup',
276
+ '#markup' => '</div></div>',
277
  );
278
+
279
+ $form['form-close'] = array(
280
+ '#type' => 'markup',
281
+ '#markup' => '</div></div>',
 
282
  );
283
 
284
  return $form;
287
  /**
288
  * Adds JS validation script.
289
  */
290
+ function wpcf_admin_tax_form_js_validation()
291
+ {
292
  wpcf_form_render_js_validation();
293
  }
294
 
295
  /**
296
  * Submit function
297
  */
298
+ function wpcf_admin_custom_taxonomies_form_submit( $form )
299
+ {
300
  if ( !isset( $_POST['ct'] ) ) {
301
  return false;
302
  }
348
 
349
  // Check if exists
350
  if ( $update && !array_key_exists( $data['wpcf-tax'], $custom_taxonomies ) ) {
351
+ wpcf_admin_message( __( "Custom taxonomy do not exist", 'wpcf' ), 'error' );
 
352
  return false;
353
  }
354
 
355
  // Check overwriting
356
  if ( !$update && array_key_exists( $tax, $custom_taxonomies ) ) {
357
+ wpcf_admin_message( __( 'Custom taxonomy already exists', 'wpcf' ), 'error' );
 
358
  return false;
359
  }
360
 
410
  flush_rewrite_rules();
411
 
412
  // Redirect
413
+ wp_redirect(
414
+ add_query_arg(
415
+ array(
416
+ 'page' => 'wpcf-edit-tax',
417
+ 'wpcf-tax' => $tax,
418
+ 'wpcf-rewrite' => 1,
419
+ 'wpcf-message' => get_user_option('types-modal')
420
+ ),
421
+ admin_url( 'admin.php' )
422
+ )
423
+ );
424
  die();
425
  }
426
+
427
+ /**
428
+ * components
429
+ */
430
+
431
+ /**
432
+ * save button
433
+ */
434
+ function wpcf_admin_metabox_submitdiv($cf)
435
+ {
436
+ $button_text = __( 'Save Custom Taxonomy', 'wpcf' );
437
+ return wpcf_admin_common_metabox_save($cf, $button_text);
438
+ }
439
+
440
+ /**
441
+ * Visibility
442
+ */
443
+ function wpcf_admin_metabox_wpcf_visibility($data)
444
+ {
445
+ $form = array();
446
+ $form['table-'.__FUNCTION__.'-open'] = wpcf_admin_metabox_begin(__( 'Visibility', 'wpcf' ), 'wpcf_visibility', 'wpcf-types-form-visibility-table', false);
447
+ $form['public'] = array(
448
+ '#type' => 'radios',
449
+ '#name' => 'ct[public]',
450
+ '#options' => array(
451
+ __( 'Make this taxonomy public (will appear in the WordPress Admin menu)', 'wpcf' ) => 'public',
452
+ __( 'Hidden - users cannot directly edit data in this taxonomy', 'wpcf' ) => 'hidden',
453
+ ),
454
+ '#default_value' => (isset( $data['public'] ) && strval( $data['public'] ) == 'hidden') ? 'hidden' : 'public',
455
+ '#inline' => true,
456
+ );
457
+ $form['table-'.__FUNCTION__.'-close'] = wpcf_admin_metabox_end();
458
+ return $form;
459
+ }
460
+
461
+ /**
462
+ * post types
463
+ */
464
+ function wpcf_admin_metabox_post_types($data, $context = 'normal' )
465
+ {
466
+ global $wpcf;
467
+ $form = array();
468
+ $post_types = get_post_types( '', 'objects' );
469
+ $options = array();
470
+
471
+ foreach ( $post_types as $post_type_slug => $post_type ) {
472
+ if ( in_array( $post_type_slug, $wpcf->excluded_post_types ) || !$post_type->show_ui ) {
473
+ continue;
474
+ }
475
+ $options[$post_type_slug]['#name'] = 'ct[supports][' . $post_type_slug . ']';
476
+ $options[$post_type_slug]['#title'] = $post_type->labels->singular_name;
477
+ $options[$post_type_slug]['#default_value'] = !empty( $data['supports'][$post_type_slug] );
478
+ $options[$post_type_slug]['#inline'] = true;
479
+ $options[$post_type_slug]['#after'] = '&nbsp;&nbsp;';
480
+ if ( is_rtl() ) {
481
+ $options[$post_type_slug]['#before'] = '<div style="float:right;margin-left:10px;">';
482
+ $options[$post_type_slug]['#after'] .= '</div>';
483
+ }
484
+ if ( 'side' == $context ) {
485
+ $options[$post_type_slug]['#before'] = '<li>';
486
+ $options[$post_type_slug]['#after'] .= '</li>';
487
+ }
488
+ }
489
+
490
+ $form['table-'.__FUNCTION__.'-open'] = wpcf_admin_metabox_begin(__( 'Select Post Types', 'wpcf' ), 'post_types', 'wpcf-types-form-post-types-table', false);
491
+ $form['types'] = array(
492
+ '#type' => 'checkboxes',
493
+ '#options' => $options,
494
+ '#description' => __( 'Registered post types that will be used with this taxonomy.', 'wpcf' ),
495
+ '#name' => 'ct[supports]',
496
+ '#inline' => true,
497
+ );
498
+ if ( 'side' == $context ) {
499
+ $form['types']['#before'] = '<ul>';
500
+ $form['types']['#after'] = '</ul>';
501
+ }
502
+ $form['table-'.__FUNCTION__.'-close'] = wpcf_admin_metabox_end();
503
+ return $form;
504
+ }
505
+
506
+ /**
507
+ * Labels
508
+ */
509
+ function wpcf_admin_metabox_labels($data)
510
+ {
511
+ $labels = array(
512
+ 'search_items' => array(
513
+ 'title' => __( 'Search %s', 'wpcf' ),
514
+ 'description' => __( "The search items text. Default is __( 'Search Tags' ) or __( 'Search Categories' ).", 'wpcf' ),
515
+ ),
516
+ 'popular_items' => array(
517
+ 'title' => __( 'Popular %s', 'wpcf' ),
518
+ 'description' => __( "The popular items text. Default is __( 'Popular Tags' ) or null.", 'wpcf' ),
519
+ ),
520
+ 'all_items' => array(
521
+ 'title' => __( 'All %s', 'wpcf' ),
522
+ 'description' => __( "The all items text. Default is __( 'All Tags' ) or __( 'All Categories' ).", 'wpcf' ),
523
+ ),
524
+ 'parent_item' => array(
525
+ 'title' => __( 'Parent %s', 'wpcf' ),
526
+ 'description' => __( "The parent item text. This string is not used on non-hierarchical taxonomies such as post tags. Default is null or __( 'Parent Category' ).", 'wpcf' ),
527
+ ),
528
+ 'parent_item_colon' => array(
529
+ 'title' => __( 'Parent %s:', 'wpcf' ),
530
+ 'description' => __( "The same as parent_item, but with colon : in the end null, __( 'Parent Category:' ).", 'wpcf' ),
531
+ ),
532
+ 'edit_item' => array(
533
+ 'title' => __( 'Edit %s', 'wpcf' ),
534
+ 'description' => __( "The edit item text. Default is __( 'Edit Tag' ) or __( 'Edit Category' ).", 'wpcf' ),
535
+ ),
536
+ 'update_item' => array(
537
+ 'title' => __( 'Update %s', 'wpcf' ),
538
+ 'description' => __( "The update item text. Default is __( 'Update Tag' ) or __( 'Update Category' ).", 'wpcf' ),
539
+ ),
540
+ 'add_new_item' => array(
541
+ 'title' => __( 'Add New %s', 'wpcf' ),
542
+ 'description' => __( "The add new item text. Default is __( 'Add New Tag' ) or __( 'Add New Category' ).", 'wpcf' ),
543
+ ),
544
+ 'new_item_name' => array(
545
+ 'title' => __( 'New %s Name', 'wpcf' ),
546
+ 'description' => __( "The new item name text. Default is __( 'New Tag Name' ) or __( 'New Category Name' ).", 'wpcf' ),
547
+ ),
548
+ 'separate_items_with_commas' => array(
549
+ 'title' => __( 'Separate %s with commas', 'wpcf' ),
550
+ 'description' => __( "The separate item with commas text used in the taxonomy meta box. This string isn't used on hierarchical taxonomies. Default is __( 'Separate tags with commas' ), or null.", 'wpcf' ),
551
+ ),
552
+ 'add_or_remove_items' => array(
553
+ 'title' => __( 'Add or remove %s', 'wpcf' ),
554
+ 'description' => __( "the add or remove items text used in the meta box when JavaScript is disabled. This string isn't used on hierarchical taxonomies. Default is __( 'Add or remove tags' ) or null.", 'wpcf' ),
555
+ ),
556
+ 'choose_from_most_used' => array(
557
+ 'title' => __( 'Choose from the most used %s', 'wpcf' ),
558
+ 'description' => __( "The choose from most used text used in the taxonomy meta box. This string isn't used on hierarchical taxonomies. Default is __( 'Choose from the most used tags' ) or null.", 'wpcf' ),
559
+ ),
560
+ 'menu_name' => array(
561
+ 'title' => __( 'Menu Name', 'wpcf' ),
562
+ 'description' => __( "The menu name text. This string is the name to give menu items. Defaults to value of name.", 'wpcf' ),
563
+ ),
564
+ );
565
+
566
+ $form = array();
567
+ $form['table-'.__FUNCTION__.'-open'] = wpcf_admin_metabox_begin(__( 'Labels', 'wpcf' ), 'labels', 'wpcf-types-form-labels-table');
568
+ foreach ( $labels as $name => $label ) {
569
+ $form['labels-' . $name] = array(
570
+ '#type' => 'textfield',
571
+ '#name' => 'ct[labels][' . $name . ']',
572
+ '#title' => ucwords( str_replace( '_', ' ', $name ) ),
573
+ '#description' => $label['description'],
574
+ '#value' => isset( $data['labels'][$name] ) ? $data['labels'][$name] : '',
575
+ '#inline' => true,
576
+ '#pattern' => '<tr><td><LABEL></td><td><ELEMENT></td><td><DESCRIPTION></td>',
577
+ );
578
+ }
579
+ $form['table-'.__FUNCTION__.'-close'] = wpcf_admin_metabox_end();
580
+ return $form;
581
+ }
582
+
583
+ /**
584
+ * Options
585
+ */
586
+ function wpcf_admin_metabox_options($data)
587
+ {
588
+ $form = array();
589
+ $form['table-'.__FUNCTION__.'-open'] = wpcf_admin_metabox_begin( __( 'Options', 'wpcf' ), 'options', 'wpcf-types-form-options-table');
590
+ $form['make-hierarchical'] = array(
591
+ '#type' => 'radios',
592
+ '#name' => 'ct[hierarchical]',
593
+ '#default_value' => (empty( $data['hierarchical'] ) || $data['hierarchical'] == 'flat') ? 'flat' : 'hierarchical',
594
+ // '#title' => __('hierarchical', 'wpcf'),
595
+ // '#description' => __('Is this taxonomy hierarchical (have descendants) like categories or not hierarchical like tags.',
596
+ // 'wpcf') . '<br />' . __('Default: false.', 'wpcf'),
597
+ '#inline' => true,
598
+ '#options' => array(
599
+ __( 'Hierarchical - like post categories, with parent / children relationship and checkboxes to select taxonomy', 'wpcf' ) => 'hierarchical',
600
+ __( 'Flat - like post tags, with a text input to enter terms', 'wpcf' ) => 'flat'
601
+ ),
602
+ '#after' => '<br /><br />',
603
+ );
604
+ $form['rewrite-enabled'] = array(
605
+ '#type' => 'checkbox',
606
+ '#force_boolean' => true,
607
+ '#title' => __( 'Rewrite', 'wpcf' ),
608
+ '#name' => 'ct[rewrite][enabled]',
609
+ '#description' => __( 'Rewrite permalinks with this format. Default will use $taxonomy as query var.', 'wpcf' ),
610
+ '#default_value' => !empty( $data['rewrite']['enabled'] ),
611
+ '#inline' => true,
612
+ );
613
+ $hidden = empty( $data['rewrite']['enabled'] ) ? ' class="hidden"' : '';
614
+ $form['rewrite-slug'] = array(
615
+ '#type' => 'textfield',
616
+ '#name' => 'ct[rewrite][slug]',
617
+ '#title' => __( 'Prepend posts with this slug', 'wpcf' ),
618
+ '#description' => __( 'Optional', 'wpcf' ) . '. ' . __( "Prepend posts with this slug - defaults to taxonomy's name.", 'wpcf' ),
619
+ '#value' => isset( $data['rewrite']['slug'] ) ? $data['rewrite']['slug'] : '',
620
+ '#inline' => true,
621
+ '#before' => '<div id="wpcf-types-form-rewrite-toggle"' . $hidden . '>',
622
+ '#after' => '</div>',
623
+ '#validate' => array('rewriteslug' => array('value' => 'true')),
624
+ );
625
+ $form['rewrite-with_front'] = array(
626
+ '#type' => 'checkbox',
627
+ '#force_boolean' => true,
628
+ '#title' => __( 'Allow permalinks to be prepended with front base', 'wpcf' ),
629
+ '#name' => 'ct[rewrite][with_front]',
630
+ '#description' => __( 'Defaults to true.', 'wpcf' ),
631
+ '#default_value' => !empty( $data['rewrite']['with_front'] ),
632
+ '#inline' => true,
633
+ );
634
+ $form['rewrite-hierarchical'] = array(
635
+ '#type' => 'checkbox',
636
+ '#name' => 'ct[rewrite][hierarchical]',
637
+ '#title' => __( 'Hierarchical URLs', 'wpcf' ),
638
+ '#description' => sprintf( __( 'True or false allow hierarchical urls (implemented in %sVersion 3.1%s).', 'wpcf' ), '<a href="http://codex.wordpress.org/Version_3.1" title="Version 3.1" target="_blank">', '</a>' ),
639
+ '#default_value' => !empty( $data['rewrite']['hierarchical'] ),
640
+ '#inline' => true,
641
+ );
642
+ $form['vars'] = array(
643
+ '#type' => 'checkboxes',
644
+ '#name' => 'ct[advanced]',
645
+ '#inline' => true,
646
+ '#options' => array(
647
+ 'show_ui' => array(
648
+ '#name' => 'ct[show_ui]',
649
+ '#default_value' => !empty( $data['show_ui'] ),
650
+ '#title' => __( 'show_ui', 'wpcf' ),
651
+ '#description' => __( 'Whether to generate a default UI for managing this taxonomy.', 'wpcf' ) . '<br />' . __( 'Default: if not set, defaults to value of public argument.', 'wpcf' ),
652
+ '#inline' => true,
653
+ ),
654
+ 'show_in_nav_menus' => array(
655
+ '#name' => 'ct[show_in_nav_menus]',
656
+ '#default_value' => !empty( $data['show_in_nav_menus'] ),
657
+ '#title' => __( 'show_in_nav_menus', 'wpcf' ),
658
+ '#description' => __( 'True makes this taxonomy available for selection in navigation menus.', 'wpcf' ) . '<br />' . __( 'Default: if not set, defaults to value of public argument.', 'wpcf' ),
659
+ '#inline' => true,
660
+ ),
661
+ 'show_tagcloud' => array(
662
+ '#name' => 'ct[show_tagcloud]',
663
+ '#default_value' => !empty( $data['show_tagcloud'] ),
664
+ '#title' => __( 'show_tagcloud', 'wpcf' ),
665
+ '#description' => __( 'Whether to allow the Tag Cloud widget to use this taxonomy.', 'wpcf' ) . '<br />' . __( 'Default: if not set, defaults to value of show_ui argument.', 'wpcf' ),
666
+ '#inline' => true,
667
+ ),
668
+ ),
669
+ );
670
+ if ( wpcf_compare_wp_version( '3.5', '>=' )) {
671
+ $form['vars']['#options']['show_admin_column'] = array(
672
+ '#name' => 'ct[show_admin_column]',
673
+ '#default_value' => !empty( $data['show_admin_column'] ),
674
+ '#title' => __( 'show_admin_column', 'wpcf' ),
675
+ '#description' => __( 'Whether to allow automatic creation of taxonomy columns on associated post-types.', 'wpcf' ) . '<br />' . __( 'Default: false.', 'wpcf' ),
676
+ '#inline' => true,
677
+ );
678
+ }
679
+ $query_var = isset( $data['query_var'] ) ? $data['query_var'] : '';
680
+ $hidden = !empty( $data['query_var_enabled'] ) ? '' : ' class="hidden"';
681
+ $form['query_var'] = array(
682
+ '#type' => 'checkbox',
683
+ '#name' => 'ct[query_var_enabled]',
684
+ '#title' => 'query_var',
685
+ '#description' => __( 'False to prevent queries, or string to customize query var. Default will use $taxonomy as query var.', 'wpcf' ) . '<br />' . __( 'Default: $taxonomy.', 'wpcf' ),
686
+ '#default_value' => !empty( $data['query_var_enabled'] ),
687
+ '#after' => '<div id="wpcf-types-form-queryvar-toggle"' . $hidden . '><input type="text" name="ct[query_var]" value="' . $query_var . '" class="wpcf-form-textfield form-textfield textfield" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __( 'Optional', 'wpcf' ) . '. ' . __( 'String to customize query var', 'wpcf' ) . '</div></div>',
688
+ '#inline' => true,
689
+ );
690
+ $form['update_count_callback'] = array(
691
+ '#type' => 'textfield',
692
+ '#name' => 'ct[update_count_callback]',
693
+ '#title' => 'update_count_callback', 'wpcf',
694
+ '#description' => __( 'Function name that will be called to update the count of an associated $object_type, such as post, is updated.', 'wpcf' ) . '<br />' . __( 'Default: None.', 'wpcf' ),
695
+ '#value' => !empty( $data['update_count_callback'] ) ? $data['update_count_callback'] : '',
696
+ '#inline' => true,
697
+ );
698
+ /**
699
+ * close
700
+ */
701
+ $form['table-'.__FUNCTION__.'-close'] = wpcf_admin_metabox_end();
702
+ return $form;
703
+ }
704
+
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.4/includes/custom-types-form.php $
7
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
- * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
@@ -13,17 +13,19 @@
13
  /**
14
  * Add/edit form
15
  */
16
- function wpcf_admin_custom_types_form() {
17
-
18
  global $wpcf;
19
 
 
 
20
  $ct = array();
21
  $id = false;
22
  $update = false;
23
 
24
  if ( isset( $_GET['wpcf-post-type'] ) ) {
25
  $id = $_GET['wpcf-post-type'];
26
- } else if ( isset( $_POST['wpcf-post-type'] ) ) {
27
  $id = $_POST['wpcf-post-type'];
28
  }
29
 
@@ -46,6 +48,19 @@ function wpcf_admin_custom_types_form() {
46
  }
47
 
48
  $form = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  $form['#form']['callback'] = 'wpcf_admin_custom_types_form_submit';
50
  $form['#form']['redirection'] = false;
51
 
@@ -77,6 +92,27 @@ function wpcf_admin_custom_types_form() {
77
  update_option( 'wpcf-custom-taxonomies', $custom_taxonomies);
78
  }
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  $form['table-1-open'] = array(
81
  '#type' => 'markup',
82
  '#markup' => '<table id="wpcf-types-form-name-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="2">' . __( 'Name and description',
@@ -124,7 +160,7 @@ function wpcf_admin_custom_types_form() {
124
  );
125
 
126
  /*
127
- *
128
  * IF isset $_POST['slug'] it means form is not submitted
129
  */
130
  $attributes = array();
@@ -390,429 +426,101 @@ function wpcf_admin_custom_types_form() {
390
  && version_compare( ICL_SITEPRESS_VERSION, '2.6.2', '>=' )
391
  && function_exists( 'wpml_custom_post_translation_options' ) ) {
392
  $form['table-1-close']['#markup'] .= wpml_custom_post_translation_options( $ct['slug'] );
393
- }
394
 
395
- $form['table-2-open'] = array(
396
- '#type' => 'markup',
397
- '#markup' => '<table id="wpcf-types-form-visibility-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __( 'Visibility',
398
- 'wpcf' ) . '</th></tr></thead><tbody><tr><td>',
399
- );
400
- $form['public'] = array(
401
- '#type' => 'radios',
402
- '#name' => 'ct[public]',
403
- '#options' => array(
404
- __( 'Make this type public (will appear in the WordPress Admin menu)',
405
- 'wpcf' ) => 'public',
406
- __( 'Hidden - users cannot directly edit data in this type', 'wpcf' ) => 'hidden',
407
- ),
408
- '#default_value' => (isset( $ct['public'] ) && strval( $ct['public'] ) == 'hidden') ? 'hidden' : 'public',
409
- '#inline' => true,
410
- );
411
- $hidden = (isset( $ct['public'] ) && strval( $ct['public'] ) == 'hidden') ? ' class="hidden"' : '';
412
- $form['menu_position'] = array(
413
- '#type' => 'textfield',
414
- '#name' => 'ct[menu_position]',
415
- '#title' => __( 'Menu position', 'wpcf' ),
416
- '#value' => isset( $ct['menu_position'] ) ? $ct['menu_position'] : '',
417
- '#validate' => array('number' => array('value' => true)),
418
- '#inline' => true,
419
- '#pattern' => '<div' . $hidden . ' id="wpcf-types-form-visiblity-toggle"><table><tr><td><LABEL></td><td><ELEMENT><ERROR></td></tr>',
420
- );
421
- $form['menu_icon'] = array(
422
- '#type' => 'textfield',
423
- '#name' => 'ct[menu_icon]',
424
- '#title' => __( 'Menu icon', 'wpcf' ),
425
- '#description' => __( 'The url to the icon to be used for this menu. Default: null - defaults to the posts icon.',
426
- 'wpcf' ),
427
- '#value' => isset( $ct['menu_icon'] ) ? $ct['menu_icon'] : '',
428
- '#inline' => true,
429
- '#pattern' => '<tr><td><LABEL></td><td><ELEMENT><ERROR></td></tr></table></div>',
430
- );
431
- $form['table-2-close'] = array(
432
  '#type' => 'markup',
433
- '#markup' => '</td></tr></tbody></table>',
434
  );
435
 
436
- $taxonomies = get_taxonomies( '', 'objects' );
437
- $options = array();
438
-
439
- foreach ( $taxonomies as $category_slug => $category ) {
440
- if ( $category_slug == 'nav_menu' || $category_slug == 'link_category'
441
- || $category_slug == 'post_format' ) {
442
- continue;
443
- }
444
- $options[$category_slug]['#name'] = 'ct[taxonomies][' . $category_slug . ']';
445
- $options[$category_slug]['#title'] = $category->labels->name;
446
- $options[$category_slug]['#default_value'] = !empty( $ct['taxonomies'][$category_slug] );
447
- $options[$category_slug]['#inline'] = true;
448
- $options[$category_slug]['#after'] = '&nbsp;&nbsp;';
449
- if ( is_rtl() ) {
450
- $options[$category_slug]['#before'] = '<div style="float:right;margin-left:10px;">';
451
- $options[$category_slug]['#after'] .= '</div>';
452
  }
453
  }
454
 
455
- $form['table-3-open'] = array(
456
- '#type' => 'markup',
457
- '#markup' => '<table id="wpcf-types-form-taxonomies-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __( 'Select Taxonomies',
458
- 'wpcf' ) . '</th></tr></thead><tbody><tr><td>',
459
- );
460
- $form['taxonomies'] = array(
461
- '#type' => 'checkboxes',
462
- '#options' => $options,
463
- '#description' => __( 'Registered taxonomies that will be used with this post type.',
464
- 'wpcf' ),
465
- '#name' => 'ct[taxonomies]',
466
- '#inline' => true,
467
- );
468
- $form['table-3-close'] = array(
469
- '#type' => 'markup',
470
- '#markup' => '</td></tr></tbody></table>',
471
  );
472
 
473
- $form['table-4-open'] = array(
 
 
 
 
474
  '#type' => 'markup',
475
- '#markup' => '<table id="wpcf-types-form-labels-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="3">' . __( 'Labels',
476
- 'wpcf' ) . '</th></tr></thead><tbody>',
477
- );
478
- $labels = array(
479
- 'add_new' => array('title' => __( 'Add New', 'wpcf' ), 'description' => __( 'The add new text. The default is Add New for both hierarchical and non-hierarchical types.',
480
- 'wpcf' )),
481
- 'add_new_item' => array('title' => __( 'Add New %s', 'wpcf' ), 'description' => __( 'The add new item text. Default is Add New Post/Add New Page.',
482
- 'wpcf' )),
483
- // 'edit' => array('title' => __('Edit', 'wpcf'), 'description' => __('The edit item text. Default is Edit Post/Edit Page.', 'wpcf')),
484
- 'edit_item' => array('title' => __( 'Edit %s', 'wpcf' ), 'description' => __( 'The edit item text. Default is Edit Post/Edit Page.',
485
- 'wpcf' )),
486
- 'new_item' => array('title' => __( 'New %s', 'wpcf' ), 'description' => __( 'The view item text. Default is View Post/View Page.',
487
- 'wpcf' )),
488
- // 'view' => array('title' => __('View', 'wpcf'), 'description' => __('', 'wpcf')),
489
- 'view_item' => array('title' => __( 'View %s', 'wpcf' ), 'description' => __( 'The view item text. Default is View Post/View Page.',
490
- 'wpcf' )),
491
- 'search_items' => array('title' => __( 'Search %s', 'wpcf' ), 'description' => __( 'The search items text. Default is Search Posts/Search Pages.',
492
- 'wpcf' )),
493
- 'not_found' => array('title' => __( 'No %s found', 'wpcf' ), 'description' => __( 'The not found text. Default is No posts found/No pages found.',
494
- 'wpcf' )),
495
- 'not_found_in_trash' => array('title' => __( 'No %s found in Trash',
496
- 'wpcf' ), 'description' => __( 'The not found in trash text. Default is No posts found in Trash/No pages found in Trash.',
497
- 'wpcf' )),
498
- 'parent_item_colon' => array('title' => __( 'Parent text', 'wpcf' ), 'description' => __( "The parent text. This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page.",
499
- 'wpcf' )),
500
- 'all_items' => array('title' => __( 'All items', 'wpcf' ), 'description' => __( 'The all items text used in the menu. Default is the Name label.',
501
- 'wpcf' )),
502
  );
503
- foreach ( $labels as $name => $data ) {
504
- $form['labels-' . $name] = array(
505
- '#type' => 'textfield',
506
- '#name' => 'ct[labels][' . $name . ']',
507
- '#title' => ucwords( str_replace( '_', ' ', $name ) ),
508
- '#description' => $data['description'],
509
- '#value' => empty($ct['slug'])? $data['title']:(isset( $ct['labels'][$name] ) ? $ct['labels'][$name] : ''),
510
- '#inline' => true,
511
- '#pattern' => '<tr><td><LABEL></td><td><ELEMENT></td><td><DESCRIPTION></td>',
512
- );
513
  }
514
- $form['table-4-close'] = array(
 
515
  '#type' => 'markup',
516
- '#markup' => '</tbody></table>',
517
- );
518
- $form['table-5-open'] = array(
519
- '#type' => 'markup',
520
- '#markup' => '<table id="wpcf-types-form-supports-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __( 'Display Sections',
521
- 'wpcf' ) . '</th></tr></thead><tbody><tr><td>',
522
  );
523
- $form['title-editor-warning'] = array(
 
 
 
 
 
524
  '#type' => 'markup',
525
- '#markup' => '<div id="wpcf-types-title-editor-warning" class="wpcf-form-error" style="display:none;">'
526
- . __( 'WordPress does not allow disabling both the title and the editor. Please enable at least one of these.',
527
- 'wpcf' ) . '</div>',
528
- );
529
- $options = array(
530
- 'title' => array(
531
- '#name' => 'ct[supports][title]',
532
- '#default_value' => !empty( $ct['supports']['title'] ),
533
- '#title' => __( 'Title', 'wpcf' ),
534
- '#description' => __( 'Text input field to create a post title.',
535
- 'wpcf' ),
536
- '#inline' => true,
537
- '#id' => 'wpcf-supports-title',
538
- '#attributes' => array(
539
- 'onclick' => 'wpcfTitleEditorCheck();',
540
- ),
541
- ),
542
- 'editor' => array(
543
- '#name' => 'ct[supports][editor]',
544
- '#default_value' => !empty( $ct['supports']['editor'] ),
545
- '#title' => __( 'Editor', 'wpcf' ),
546
- '#description' => __( 'Content input box for writing.', 'wpcf' ),
547
- '#inline' => true,
548
- '#id' => 'wpcf-supports-editor',
549
- '#attributes' => array(
550
- 'onclick' => 'wpcfTitleEditorCheck();',
551
- ),
552
- ),
553
- 'comments' => array(
554
- '#name' => 'ct[supports][comments]',
555
- '#default_value' => !empty( $ct['supports']['comments'] ),
556
- '#title' => __( 'Comments', 'wpcf' ),
557
- '#description' => __( 'Ability to turn comments on/off.', 'wpcf' ),
558
- '#inline' => true,
559
- ),
560
- 'trackbacks' => array(
561
- '#name' => 'ct[supports][trackbacks]',
562
- '#default_value' => !empty( $ct['supports']['trackbacks'] ),
563
- '#title' => __( 'Trackbacks', 'wpcf' ),
564
- '#description' => __( 'Ability to turn trackbacks and pingbacks on/off.',
565
- 'wpcf' ),
566
- '#inline' => true,
567
- ),
568
- 'revisions' => array(
569
- '#name' => 'ct[supports][revisions]',
570
- '#default_value' => !empty( $ct['supports']['revisions'] ),
571
- '#title' => __( 'Revisions', 'wpcf' ),
572
- '#description' => __( 'Allows revisions to be made of your post.',
573
- 'wpcf' ),
574
- '#inline' => true,
575
- ),
576
- 'author' => array(
577
- '#name' => 'ct[supports][author]',
578
- '#default_value' => !empty( $ct['supports']['author'] ),
579
- '#title' => __( 'Author', 'wpcf' ),
580
- '#description' => __( 'Displays a dropdown menu for changing the post author.',
581
- 'wpcf' ),
582
- '#inline' => true,
583
- ),
584
- 'excerpt' => array(
585
- '#name' => 'ct[supports][excerpt]',
586
- '#default_value' => !empty( $ct['supports']['excerpt'] ),
587
- '#title' => __( 'Excerpt', 'wpcf' ),
588
- '#description' => __( 'A text area for writing a custom excerpt.',
589
- 'wpcf' ),
590
- '#inline' => true,
591
- ),
592
- 'thumbnail' => array(
593
- '#name' => 'ct[supports][thumbnail]',
594
- '#default_value' => !empty( $ct['supports']['thumbnail'] ),
595
- '#title' => __( 'Thumbnail', 'wpcf' ),
596
- '#description' => __( 'Add a box for uploading a featured image.',
597
- 'wpcf' ),
598
- '#inline' => true,
599
- ),
600
- 'custom-fields' => array(
601
- '#name' => 'ct[supports][custom-fields]',
602
- '#default_value' => !empty( $ct['supports']['custom-fields'] ),
603
- '#title' => __( 'custom-fields', 'wpcf' ),
604
- '#description' => __( 'Custom fields input area.', 'wpcf' ),
605
- '#inline' => true,
606
- ),
607
- 'page-attributes' => array(
608
- '#name' => 'ct[supports][page-attributes]',
609
- '#default_value' => !empty( $ct['supports']['page-attributes'] ),
610
- '#title' => __( 'page-attributes', 'wpcf' ),
611
- '#description' => __( 'Menu order, hierarchical must be true to show Parent option',
612
- 'wpcf' ),
613
- '#inline' => true,
614
- ),
615
- 'post-formats' => array(
616
- '#name' => 'ct[supports][post-formats]',
617
- '#default_value' => !empty( $ct['supports']['post-formats'] ),
618
- '#title' => __( 'post-formats', 'wpcf' ),
619
- '#description' => sprintf( __( 'Add post formats, see %sPost Formats%s',
620
- 'wpcf' ),
621
- '<a href="http://codex.wordpress.org/Post_Formats" title="Post Formats" target="_blank">',
622
- '</a>' ),
623
- '#inline' => true,
624
- ),
625
- );
626
- $form['supports'] = array(
627
- '#type' => 'checkboxes',
628
- '#options' => $options,
629
- '#name' => 'ct[supports]',
630
- '#inline' => true,
631
  );
632
- $form['table-5-close'] = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
633
  '#type' => 'markup',
634
- '#markup' => '</td></tr></tbody></table>',
635
  );
636
- $form['table-6-open'] = array(
 
637
  '#type' => 'markup',
638
- '#markup' => '<table id="wpcf-types-form-supports-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __( 'Options', 'wpcf' ) . '</th></tr></thead><tbody><tr><td>',
639
- );
640
- $form['rewrite-enabled'] = array(
641
- '#type' => 'checkbox',
642
- '#title' => __( 'Rewrite', 'wpcf' ),
643
- '#name' => 'ct[rewrite][enabled]',
644
- '#description' => __( 'Rewrite permalinks with this format. False to prevent rewrite. Default: true and use post type as slug.',
645
- 'wpcf' ),
646
- '#default_value' => !empty( $ct['rewrite']['enabled'] ),
647
- '#inline' => true,
648
- );
649
- $form['rewrite-custom'] = array(
650
- '#type' => 'radios',
651
- '#name' => 'ct[rewrite][custom]',
652
- '#options' => array(
653
- __( 'Use the normal WordPress URL logic', 'wpcf' ) => 'normal',
654
- __( 'Use a custom URL format', 'wpcf' ) => 'custom',
655
- ),
656
- '#default_value' => empty( $ct['rewrite']['custom'] ) || $ct['rewrite']['custom'] != 'custom' ? 'normal' : 'custom',
657
- '#inline' => true,
658
- '#after' => '<br />',
659
- );
660
- $hidden = empty( $ct['rewrite']['custom'] ) || $ct['rewrite']['custom'] != 'custom' ? ' class="hidden"' : '';
661
- $form['rewrite-slug'] = array(
662
- '#type' => 'textfield',
663
- '#name' => 'ct[rewrite][slug]',
664
- '#description' => __( 'Optional.', 'wpcf' ) . ' ' . __( "Prepend posts with this slug - defaults to post type's name.",
665
- 'wpcf' ),
666
- '#value' => isset( $ct['rewrite']['slug'] ) ? $ct['rewrite']['slug'] : '',
667
- '#inline' => true,
668
- '#before' => '<div id="wpcf-types-form-rewrite-toggle"' . $hidden . '>',
669
- '#after' => '</div>',
670
- '#validate' => array('rewriteslug' => array('value' => 'true')),
671
- );
672
- $form['rewrite-with_front'] = array(
673
- '#type' => 'checkbox',
674
- '#title' => __( 'Allow permalinks to be prepended with front base',
675
- 'wpcf' ),
676
- '#name' => 'ct[rewrite][with_front]',
677
- '#description' => __( 'Example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/.',
678
- 'wpcf' ) . ' ' . __( 'Defaults to true.', 'wpcf' ),
679
- '#default_value' => !empty( $ct['rewrite']['with_front'] ),
680
- '#inline' => true,
681
- );
682
- $form['rewrite-feeds'] = array(
683
- '#type' => 'checkbox',
684
- '#name' => 'ct[rewrite][feeds]',
685
- '#title' => __( 'Feeds', 'wpcf' ),
686
- '#description' => __( 'Defaults to has_archive value.', 'wpcf' ),
687
- '#default_value' => !empty( $ct['rewrite']['feeds'] ),
688
- '#value' => 1,
689
- '#inline' => true,
690
- );
691
- $form['rewrite-pages'] = array(
692
- '#type' => 'checkbox',
693
- '#name' => 'ct[rewrite][pages]',
694
- '#title' => __( 'Pages', 'wpcf' ),
695
- '#description' => __( 'Defaults to true.', 'wpcf' ),
696
- '#default_value' => !empty( $ct['rewrite']['pages'] ),
697
- '#value' => 1,
698
- '#inline' => true,
699
- );
700
- $show_in_menu_page = isset( $ct['show_in_menu_page'] ) ? $ct['show_in_menu_page'] : '';
701
- $hidden = !empty( $ct['show_in_menu'] ) ? '' : ' class="hidden"';
702
- $form['vars'] = array(
703
- '#type' => 'checkboxes',
704
- '#name' => 'ct[vars]',
705
- '#inline' => true,
706
- '#options' => array(
707
- 'has_archive' => array(
708
- '#name' => 'ct[has_archive]',
709
- '#default_value' => !empty( $ct['has_archive'] ),
710
- '#title' => __( 'has_archive', 'wpcf' ),
711
- '#description' => __( 'Allow custom post type to have index page.',
712
- 'wpcf' ) . '<br />' . __( 'Default: not set.', 'wpcf' ),
713
- '#inline' => true,
714
- ),
715
- 'show_in_menu' => array(
716
- '#name' => 'ct[show_in_menu]',
717
- '#default_value' => !empty( $ct['show_in_menu'] ),
718
- '#title' => __( 'show_in_menu', 'wpcf' ),
719
- '#description' => __( 'Whether to show the post type in the admin menu and where to show that menu. Note that show_ui must be true.',
720
- 'wpcf' ) . '<br />' . __( 'Default: null.', 'wpcf' ),
721
- '#after' => '<div id="wpcf-types-form-showinmenu-toggle"' . $hidden . '><input type="text" name="ct[show_in_menu_page]" style="width:50%;" value="' . $show_in_menu_page . '" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __( 'Optional.',
722
- 'wpcf' ) . ' ' . __( "Top level page like 'tools.php' or 'edit.php?post_type=page'",
723
- 'wpcf' ) . '</div></div>',
724
- '#inline' => true,
725
- ),
726
- 'show_ui' => array(
727
- '#name' => 'ct[show_ui]',
728
- '#default_value' => !empty( $ct['show_ui'] ),
729
- '#title' => __( 'show_ui', 'wpcf' ),
730
- '#description' => __( 'Generate a default UI for managing this post type.',
731
- 'wpcf' ) . '<br />' . __( 'Default: value of public argument.',
732
- 'wpcf' ),
733
- '#inline' => true,
734
- ),
735
- 'publicly_queryable' => array(
736
- '#name' => 'ct[publicly_queryable]',
737
- '#default_value' => !empty( $ct['publicly_queryable'] ),
738
- '#title' => __( 'publicly_queryable', 'wpcf' ),
739
- '#description' => __( 'Whether post_type queries can be performed from the front end.',
740
- 'wpcf' ) . '<br />' . __( 'Default: value of public argument.',
741
- 'wpcf' ),
742
- '#inline' => true,
743
- ),
744
- 'exclude_from_search' => array(
745
- '#name' => 'ct[exclude_from_search]',
746
- '#default_value' => !empty( $ct['exclude_from_search'] ),
747
- '#title' => __( 'exclude_from_search', 'wpcf' ),
748
- '#description' => __( 'Whether to exclude posts with this post type from search results.',
749
- 'wpcf' ) . '<br />' . __( 'Default: value of the opposite of the public argument.',
750
- 'wpcf' ),
751
- '#inline' => true,
752
- ),
753
- 'hierarchical' => array(
754
- '#name' => 'ct[hierarchical]',
755
- '#default_value' => !empty( $ct['hierarchical'] ),
756
- '#title' => __( 'hierarchical', 'wpcf' ),
757
- '#description' => __( 'Whether the post type is hierarchical. Allows Parent to be specified.',
758
- 'wpcf' ) . '<br />' . __( 'Default: false.', 'wpcf' ),
759
- '#inline' => true,
760
- ),
761
- 'can_export' => array(
762
- '#name' => 'ct[can_export]',
763
- '#default_value' => !empty( $ct['can_export'] ),
764
- '#title' => __( 'can_export', 'wpcf' ),
765
- '#description' => __( 'Can this post_type be exported.', 'wpcf' ) . '<br />' . __( 'Default: true.',
766
- 'wpcf' ),
767
- '#inline' => true,
768
- ),
769
- 'show_in_nav_menus' => array(
770
- '#name' => 'ct[show_in_nav_menus]',
771
- '#default_value' => !empty( $ct['show_in_nav_menus'] ),
772
- '#title' => __( 'show_in_nav_menus', 'wpcf' ),
773
- '#description' => __( 'Whether post_type is available for selection in navigation menus.',
774
- 'wpcf' ) . '<br />' . __( 'Default: value of public argument.',
775
- 'wpcf' ),
776
- '#inline' => true,
777
- ),
778
- ),
779
- );
780
- $query_var = isset( $ct['query_var'] ) ? $ct['query_var'] : '';
781
- $hidden = !empty( $ct['query_var_enabled'] ) ? '' : ' class="hidden"';
782
- $form['query_var'] = array(
783
- '#type' => 'checkbox',
784
- '#name' => 'ct[query_var_enabled]',
785
- '#title' => 'query_var',
786
- '#description' => __( 'False to prevent queries, or string value of the query var to use for this post type.',
787
- 'wpcf' ) . '<br />' . __( 'Default: true - set to $post_type.',
788
- 'wpcf' ),
789
- '#default_value' => !empty( $ct['query_var_enabled'] ),
790
- '#after' => '<div id="wpcf-types-form-queryvar-toggle"' . $hidden . '><input type="text" name="ct[query_var]" value="' . $query_var . '" style="width:50%;" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __( 'Optional',
791
- 'wpcf' ) . '. ' . __( 'String to customize query var', 'wpcf' ) . '</div></div>',
792
- '#inline' => true,
793
- );
794
- $form['permalink_epmask'] = array(
795
- '#type' => 'textfield',
796
- '#name' => 'ct[permalink_epmask]',
797
- '#title' => __( 'Permalink epmask', 'wpcf' ),
798
- '#description' => sprintf( __( 'Default value EP_PERMALINK. More info here %s.',
799
- 'wpcf' ),
800
- '<a href="http://core.trac.wordpress.org/ticket/12605" target="_blank">link</a>' ),
801
- '#value' => isset( $ct['permalink_epmask'] ) ? $ct['permalink_epmask'] : '',
802
- '#inline' => true,
803
- );
804
- $form['table-6-close'] = array(
805
- '#type' => 'markup',
806
- '#markup' => '</td></tr></tbody></table>',
807
- );
808
-
809
- $form = $form + apply_filters( 'wpcf_post_type_form', array(), $ct );
810
-
811
- $form['submit'] = array(
812
- '#type' => 'submit',
813
- '#name' => 'submit',
814
- '#value' => __( 'Save Custom Post Type', 'wpcf' ),
815
- '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'),
816
  );
817
 
818
  return $form;
@@ -821,15 +529,16 @@ function wpcf_admin_custom_types_form() {
821
  /**
822
  * Adds JS validation script.
823
  */
824
- function wpcf_admin_types_form_js_validation() {
 
825
  wpcf_form_render_js_validation();
826
  }
827
 
828
  /**
829
  * Submit function
830
  */
831
- function wpcf_admin_custom_types_form_submit( $form ) {
832
-
833
  global $wpcf;
834
 
835
  if ( !isset( $_POST['ct'] ) ) {
@@ -860,9 +569,9 @@ function wpcf_admin_custom_types_form_submit( $form ) {
860
  $post_type = null;
861
  if ( !empty( $data['slug'] ) ) {
862
  $post_type = $data['slug'];
863
- } else if ( !empty( $data['wpcf-post-type'] ) ) {
864
  $post_type = $data['wpcf-post-type'];
865
- } else if ( !empty( $data['labels']['singular_name'] ) ) {
866
  $post_type = sanitize_title( $data['labels']['singular_name'] );
867
  }
868
 
@@ -905,7 +614,6 @@ function wpcf_admin_custom_types_form_submit( $form ) {
905
  array('%s')
906
  );
907
 
908
-
909
  /**
910
  * update post meta "_wp_types_group_post_types"
911
  */
@@ -1040,6 +748,453 @@ function wpcf_admin_custom_types_form_submit( $form ) {
1040
  do_action( 'wpcf_custom_types_save', $data );
1041
 
1042
  // Redirect
1043
- wp_redirect( admin_url( 'admin.php?page=wpcf-edit-type&wpcf-post-type=' . $post_type . '&wpcf-rewrite=1' ) );
 
 
 
 
 
 
 
 
 
 
1044
  die();
1045
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  *
4
  * Custom types form
5
  *
6
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
13
  /**
14
  * Add/edit form
15
  */
16
+ function wpcf_admin_custom_types_form()
17
+ {
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
 
48
  }
49
 
50
  $form = array();
51
+ /**
52
+ * postbox-controll
53
+ */
54
+ $markup = wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false, false );
55
+ $markup.= wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false, false );
56
+ $form['postbox-controll'] = array(
57
+ '#type' => 'markup',
58
+ '#markup' => $markup,
59
+ );
60
+
61
+ /**
62
+ * form setup
63
+ */
64
  $form['#form']['callback'] = 'wpcf_admin_custom_types_form_submit';
65
  $form['#form']['redirection'] = false;
66
 
92
  update_option( 'wpcf-custom-taxonomies', $custom_taxonomies);
93
  }
94
 
95
+ /**
96
+ * WP control for meta boxes
97
+ */
98
+ include_once ABSPATH.'/wp-admin/includes/meta-boxes.php';
99
+ wp_enqueue_script( 'post' );
100
+
101
+ $form['form-open'] = array(
102
+ '#type' => 'markup',
103
+ '#markup' => '<div id="poststuff">',
104
+ );
105
+
106
+ $form['form-metabox-holder-columns-2-open'] = array(
107
+ '#type' => 'markup',
108
+ '#markup' => '<div id="post-body" class="metabox-holder columns-2">',
109
+ );
110
+
111
+ $form['post-body-content-open'] = array(
112
+ '#type' => 'markup',
113
+ '#markup' => '<div id="post-body-content">',
114
+ );
115
+
116
  $form['table-1-open'] = array(
117
  '#type' => 'markup',
118
  '#markup' => '<table id="wpcf-types-form-name-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="2">' . __( 'Name and description',
160
  );
161
 
162
  /*
163
+ *
164
  * IF isset $_POST['slug'] it means form is not submitted
165
  */
166
  $attributes = array();
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',
433
+ '#markup' => '</div>',
434
  );
435
 
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) )) {
445
+ $meta_box_order = $meta_box_order_defaults;
446
+ } else {
447
+ if ( isset($meta_box_order[0]) && !isset($meta_box_order['normal']) ) {
448
+ $meta_box_order['normal'] = $meta_box_order[0];
 
 
 
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
463
+ */
464
+
465
+ $form['postbox-container-1-open'] = array(
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]);
473
+ unset($meta_boxes[$key]);
474
+ }
 
 
 
 
475
  }
476
+ /* close side container */
477
+ $form['postbox-container-1-close'] = array(
478
  '#type' => 'markup',
479
+ '#markup' => '</div></div>',
 
 
 
 
 
480
  );
481
+
482
+ /**
483
+ * normal container
484
+ */
485
+
486
+ $form['postbox-container-2-open'] = array(
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]);
494
+ unset($meta_boxes[$key]);
495
+ }
496
+ }
497
+ /**
498
+ * grab missing meta-boxes
499
+ */
500
+ foreach( array_keys($meta_boxes) as $key ) {
501
+ $function = sprintf('wpcf_admin_metabox_%s', $key);
502
+ if ( is_callable($function) ) {
503
+ $form += $function($meta_boxes[$key]);
504
+ }
505
+ }
506
+
507
+ /**
508
+ * filter wpcf_post_type_form
509
+ */
510
+
511
+ $form = $form + apply_filters( 'wpcf_post_type_form', array(), $ct );
512
+
513
+ /**
514
+ * container-2 close
515
+ */
516
+ $form['postbox-container-2-close'] = array(
517
  '#type' => 'markup',
518
+ '#markup' => '</div></div>',
519
  );
520
+
521
+ $form['form-close'] = array(
522
  '#type' => 'markup',
523
+ '#markup' => '</div></div>',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
524
  );
525
 
526
  return $form;
529
  /**
530
  * Adds JS validation script.
531
  */
532
+ function wpcf_admin_types_form_js_validation()
533
+ {
534
  wpcf_form_render_js_validation();
535
  }
536
 
537
  /**
538
  * Submit function
539
  */
540
+ function wpcf_admin_custom_types_form_submit($form)
541
+ {
542
  global $wpcf;
543
 
544
  if ( !isset( $_POST['ct'] ) ) {
569
  $post_type = null;
570
  if ( !empty( $data['slug'] ) ) {
571
  $post_type = $data['slug'];
572
+ } elseif ( !empty( $data['wpcf-post-type'] ) ) {
573
  $post_type = $data['wpcf-post-type'];
574
+ } elseif ( !empty( $data['labels']['singular_name'] ) ) {
575
  $post_type = sanitize_title( $data['labels']['singular_name'] );
576
  }
577
 
614
  array('%s')
615
  );
616
 
 
617
  /**
618
  * update post meta "_wp_types_group_post_types"
619
  */
748
  do_action( 'wpcf_custom_types_save', $data );
749
 
750
  // Redirect
751
+ wp_redirect(
752
+ add_query_arg(
753
+ array(
754
+ 'page' => 'wpcf-edit-type',
755
+ 'wpcf-post-type' => $post_type,
756
+ 'wpcf-rewrite' => 1,
757
+ 'wpcf-message' => 'view',
758
+ ),
759
+ admin_url( 'admin.php' )
760
+ )
761
+ );
762
  die();
763
  }
764
+
765
+ /**
766
+ * components
767
+ */
768
+
769
+ /**
770
+ * save button
771
+ */
772
+ function wpcf_admin_metabox_submitdiv($cf)
773
+ {
774
+ $button_text = __( 'Save Custom Post', 'wpcf' );
775
+ return wpcf_admin_common_metabox_save($cf, $button_text);
776
+ }
777
+
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);
785
+ $form['public'] = array(
786
+ '#type' => 'radios',
787
+ '#name' => 'ct[public]',
788
+ '#options' => array(
789
+ __( 'Make this type public (will appear in the WordPress Admin menu)', 'wpcf' ) => 'public',
790
+ __( 'Hidden - users cannot directly edit data in this type', 'wpcf' ) => 'hidden',
791
+ ),
792
+ '#default_value' => (isset( $ct['public'] ) && strval( $ct['public'] ) == 'hidden') ? 'hidden' : 'public',
793
+ '#inline' => true,
794
+ );
795
+ $hidden = (isset( $ct['public'] ) && strval( $ct['public'] ) == 'hidden') ? ' class="hidden"' : '';
796
+ $form['menu_position'] = array(
797
+ '#type' => 'textfield',
798
+ '#name' => 'ct[menu_position]',
799
+ '#title' => __( 'Menu position', 'wpcf' ),
800
+ '#value' => isset( $ct['menu_position'] ) ? $ct['menu_position'] : '',
801
+ '#validate' => array('number' => array('value' => true)),
802
+ '#inline' => true,
803
+ '#pattern' => '<BEFORE><p><LABEL><ELEMENT><ERROR></p><AFTER>',
804
+ '#before' => '<div' . $hidden . ' id="wpcf-types-form-visiblity-toggle">',
805
+ );
806
+ $form['menu_icon'] = array(
807
+ '#type' => 'textfield',
808
+ '#name' => 'ct[menu_icon]',
809
+ '#title' => __( 'Menu icon', 'wpcf' ),
810
+ '#description' => __( 'The url to the icon to be used for this menu. Default: null - defaults to the posts icon.', 'wpcf' ),
811
+ '#value' => isset( $ct['menu_icon'] ) ? $ct['menu_icon'] : '',
812
+ '#inline' => true,
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
+ }
819
+
820
+ /**
821
+ * Taxonomies
822
+ */
823
+ function wpcf_admin_metabox_taxonomies($ct)
824
+ {
825
+ $form = array();
826
+ $taxonomies = get_taxonomies( '', 'objects' );
827
+ $options = array();
828
+
829
+ foreach ( $taxonomies as $category_slug => $category ) {
830
+ if ( $category_slug == 'nav_menu' || $category_slug == 'link_category'
831
+ || $category_slug == 'post_format' ) {
832
+ continue;
833
+ }
834
+ $options[$category_slug]['#name'] = 'ct[taxonomies][' . $category_slug . ']';
835
+ $options[$category_slug]['#title'] = $category->labels->name;
836
+ $options[$category_slug]['#default_value'] = !empty( $ct['taxonomies'][$category_slug] );
837
+ $options[$category_slug]['#inline'] = true;
838
+ $options[$category_slug]['#before'] = '<li>';
839
+ $options[$category_slug]['#after'] = '</li>';
840
+ if ( is_rtl() ) {
841
+ $options[$category_slug]['#before'] = '<div style="float:right;margin-left:10px;">';
842
+ $options[$category_slug]['#after'] .= '</div>';
843
+ }
844
+ }
845
+
846
+ $form['table-3-open'] = wpcf_admin_metabox_begin(__( 'Select Taxonomies', 'wpcf' ), 'taxonomies', 'wpcf-types-form-taxonomies-table', false);
847
+ $form['taxonomies'] = array(
848
+ '#type' => 'checkboxes',
849
+ '#options' => $options,
850
+ '#description' => __( 'Registered taxonomies that will be used with this post type.', 'wpcf' ),
851
+ '#name' => 'ct[taxonomies]',
852
+ '#inline' => true,
853
+ '#before' => '<ul>',
854
+ '#after' => '</ul>',
855
+ );
856
+ $form['table-3-close'] = wpcf_admin_metabox_end(false);
857
+ return $form;
858
+ }
859
+
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');
867
+ $labels = array(
868
+ 'add_new' => array('title' => __( 'Add New', 'wpcf' ), 'description' => __( 'The add new text. The default is Add New for both hierarchical and non-hierarchical types.',
869
+ 'wpcf' )),
870
+ 'add_new_item' => array('title' => __( 'Add New %s', 'wpcf' ), 'description' => __( 'The add new item text. Default is Add New Post/Add New Page.',
871
+ 'wpcf' )),
872
+ // 'edit' => array('title' => __('Edit', 'wpcf'), 'description' => __('The edit item text. Default is Edit Post/Edit Page.', 'wpcf')),
873
+ 'edit_item' => array('title' => __( 'Edit %s', 'wpcf' ), 'description' => __( 'The edit item text. Default is Edit Post/Edit Page.',
874
+ 'wpcf' )),
875
+ 'new_item' => array('title' => __( 'New %s', 'wpcf' ), 'description' => __( 'The view item text. Default is View Post/View Page.',
876
+ 'wpcf' )),
877
+ // 'view' => array('title' => __('View', 'wpcf'), 'description' => __('', 'wpcf')),
878
+ 'view_item' => array('title' => __( 'View %s', 'wpcf' ), 'description' => __( 'The view item text. Default is View Post/View Page.',
879
+ 'wpcf' )),
880
+ 'search_items' => array('title' => __( 'Search %s', 'wpcf' ), 'description' => __( 'The search items text. Default is Search Posts/Search Pages.',
881
+ 'wpcf' )),
882
+ 'not_found' => array('title' => __( 'No %s found', 'wpcf' ), 'description' => __( 'The not found text. Default is No posts found/No pages found.',
883
+ 'wpcf' )),
884
+ 'not_found_in_trash' => array('title' => __( 'No %s found in Trash',
885
+ 'wpcf' ), 'description' => __( 'The not found in trash text. Default is No posts found in Trash/No pages found in Trash.',
886
+ 'wpcf' )),
887
+ 'parent_item_colon' => array('title' => __( 'Parent text', 'wpcf' ), 'description' => __( "The parent text. This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page.",
888
+ 'wpcf' )),
889
+ 'all_items' => array('title' => __( 'All items', 'wpcf' ), 'description' => __( 'The all items text used in the menu. Default is the Name label.',
890
+ 'wpcf' )),
891
+ );
892
+ foreach ( $labels as $name => $data ) {
893
+ $form['labels-' . $name] = array(
894
+ '#type' => 'textfield',
895
+ '#name' => 'ct[labels][' . $name . ']',
896
+ '#title' => ucwords( str_replace( '_', ' ', $name ) ),
897
+ '#description' => $data['description'],
898
+ '#value' => empty($ct['slug'])? $data['title']:(isset( $ct['labels'][$name] ) ? $ct['labels'][$name] : ''),
899
+ '#inline' => true,
900
+ '#pattern' => '<tr><td><LABEL></td><td><ELEMENT></td><td><DESCRIPTION></td>',
901
+ );
902
+ }
903
+ $form['table-4-close'] = wpcf_admin_metabox_end();
904
+ return $form;
905
+ }
906
+
907
+ /**
908
+ * Display Sections
909
+ */
910
+ 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]',
923
+ '#default_value' => !empty( $ct['supports']['title'] ),
924
+ '#title' => __( 'Title', 'wpcf' ),
925
+ '#description' => __( 'Text input field to create a post title.',
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]',
935
+ '#default_value' => !empty( $ct['supports']['editor'] ),
936
+ '#title' => __( 'Editor', 'wpcf' ),
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]',
946
+ '#default_value' => !empty( $ct['supports']['comments'] ),
947
+ '#title' => __( 'Comments', 'wpcf' ),
948
+ '#description' => __( 'Ability to turn comments on/off.', 'wpcf' ),
949
+ '#inline' => true,
950
+ ),
951
+ 'trackbacks' => array(
952
+ '#name' => 'ct[supports][trackbacks]',
953
+ '#default_value' => !empty( $ct['supports']['trackbacks'] ),
954
+ '#title' => __( 'Trackbacks', 'wpcf' ),
955
+ '#description' => __( 'Ability to turn trackbacks and pingbacks on/off.',
956
+ 'wpcf' ),
957
+ '#inline' => true,
958
+ ),
959
+ 'revisions' => array(
960
+ '#name' => 'ct[supports][revisions]',
961
+ '#default_value' => !empty( $ct['supports']['revisions'] ),
962
+ '#title' => __( 'Revisions', 'wpcf' ),
963
+ '#description' => __( 'Allows revisions to be made of your post.',
964
+ 'wpcf' ),
965
+ '#inline' => true,
966
+ ),
967
+ 'author' => array(
968
+ '#name' => 'ct[supports][author]',
969
+ '#default_value' => !empty( $ct['supports']['author'] ),
970
+ '#title' => __( 'Author', 'wpcf' ),
971
+ '#description' => __( 'Displays a dropdown menu for changing the post author.',
972
+ 'wpcf' ),
973
+ '#inline' => true,
974
+ ),
975
+ 'excerpt' => array(
976
+ '#name' => 'ct[supports][excerpt]',
977
+ '#default_value' => !empty( $ct['supports']['excerpt'] ),
978
+ '#title' => __( 'Excerpt', 'wpcf' ),
979
+ '#description' => __( 'A text area for writing a custom excerpt.',
980
+ 'wpcf' ),
981
+ '#inline' => true,
982
+ ),
983
+ 'thumbnail' => array(
984
+ '#name' => 'ct[supports][thumbnail]',
985
+ '#default_value' => !empty( $ct['supports']['thumbnail'] ),
986
+ '#title' => __( 'Thumbnail', 'wpcf' ),
987
+ '#description' => __( 'Add a box for uploading a featured image.',
988
+ 'wpcf' ),
989
+ '#inline' => true,
990
+ ),
991
+ 'custom-fields' => array(
992
+ '#name' => 'ct[supports][custom-fields]',
993
+ '#default_value' => !empty( $ct['supports']['custom-fields'] ),
994
+ '#title' => __( 'custom-fields', 'wpcf' ),
995
+ '#description' => __( 'Custom fields input area.', 'wpcf' ),
996
+ '#inline' => true,
997
+ ),
998
+ 'page-attributes' => array(
999
+ '#name' => 'ct[supports][page-attributes]',
1000
+ '#default_value' => !empty( $ct['supports']['page-attributes'] ),
1001
+ '#title' => __( 'page-attributes', 'wpcf' ),
1002
+ '#description' => __( 'Menu order, hierarchical must be true to show Parent option',
1003
+ 'wpcf' ),
1004
+ '#inline' => true,
1005
+ ),
1006
+ 'post-formats' => array(
1007
+ '#name' => 'ct[supports][post-formats]',
1008
+ '#default_value' => !empty( $ct['supports']['post-formats'] ),
1009
+ '#title' => __( 'post-formats', 'wpcf' ),
1010
+ '#description' => sprintf( __( 'Add post formats, see %sPost Formats%s',
1011
+ 'wpcf' ),
1012
+ '<a href="http://codex.wordpress.org/Post_Formats" title="Post Formats" target="_blank">',
1013
+ '</a>' ),
1014
+ '#inline' => true,
1015
+ ),
1016
+ );
1017
+ $form['supports'] = array(
1018
+ '#type' => 'checkboxes',
1019
+ '#options' => $options,
1020
+ '#name' => 'ct[supports]',
1021
+ '#inline' => true,
1022
+ );
1023
+ $form['table-5-close'] = wpcf_admin_metabox_end();
1024
+ return $form;
1025
+ }
1026
+
1027
+ /**
1028
+ * Options
1029
+ */
1030
+ function wpcf_admin_metabox_options($ct)
1031
+ {
1032
+ $form = array();
1033
+ $form['table-6-open'] = wpcf_admin_metabox_begin( __( 'Options', 'wpcf' ), 'options', 'wpcf-types-form-table');
1034
+ $form['rewrite-enabled'] = array(
1035
+ '#type' => 'checkbox',
1036
+ '#title' => __( 'Rewrite', 'wpcf' ),
1037
+ '#name' => 'ct[rewrite][enabled]',
1038
+ '#description' => __( 'Rewrite permalinks with this format. False to prevent rewrite. Default: true and use post type as slug.',
1039
+ 'wpcf' ),
1040
+ '#default_value' => !empty( $ct['rewrite']['enabled'] ),
1041
+ '#inline' => true,
1042
+ );
1043
+ $form['rewrite-custom'] = array(
1044
+ '#type' => 'radios',
1045
+ '#name' => 'ct[rewrite][custom]',
1046
+ '#options' => array(
1047
+ __( 'Use the normal WordPress URL logic', 'wpcf' ) => 'normal',
1048
+ __( 'Use a custom URL format', 'wpcf' ) => 'custom',
1049
+ ),
1050
+ '#default_value' => empty( $ct['rewrite']['custom'] ) || $ct['rewrite']['custom'] != 'custom' ? 'normal' : 'custom',
1051
+ '#inline' => true,
1052
+ '#after' => '<br />',
1053
+ );
1054
+ $hidden = empty( $ct['rewrite']['custom'] ) || $ct['rewrite']['custom'] != 'custom' ? ' class="hidden"' : '';
1055
+ $form['rewrite-slug'] = array(
1056
+ '#type' => 'textfield',
1057
+ '#name' => 'ct[rewrite][slug]',
1058
+ '#description' => __( 'Optional.', 'wpcf' ) . ' ' . __( "Prepend posts with this slug - defaults to post type's name.",
1059
+ 'wpcf' ),
1060
+ '#value' => isset( $ct['rewrite']['slug'] ) ? $ct['rewrite']['slug'] : '',
1061
+ '#inline' => true,
1062
+ '#before' => '<div id="wpcf-types-form-rewrite-toggle"' . $hidden . '>',
1063
+ '#after' => '</div>',
1064
+ '#validate' => array('rewriteslug' => array('value' => 'true')),
1065
+ );
1066
+ $form['rewrite-with_front'] = array(
1067
+ '#type' => 'checkbox',
1068
+ '#title' => __( 'Allow permalinks to be prepended with front base',
1069
+ 'wpcf' ),
1070
+ '#name' => 'ct[rewrite][with_front]',
1071
+ '#description' => __( 'Example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/.',
1072
+ 'wpcf' ) . ' ' . __( 'Defaults to true.', 'wpcf' ),
1073
+ '#default_value' => !empty( $ct['rewrite']['with_front'] ),
1074
+ '#inline' => true,
1075
+ );
1076
+ $form['rewrite-feeds'] = array(
1077
+ '#type' => 'checkbox',
1078
+ '#name' => 'ct[rewrite][feeds]',
1079
+ '#title' => __( 'Feeds', 'wpcf' ),
1080
+ '#description' => __( 'Defaults to has_archive value.', 'wpcf' ),
1081
+ '#default_value' => !empty( $ct['rewrite']['feeds'] ),
1082
+ '#value' => 1,
1083
+ '#inline' => true,
1084
+ );
1085
+ $form['rewrite-pages'] = array(
1086
+ '#type' => 'checkbox',
1087
+ '#name' => 'ct[rewrite][pages]',
1088
+ '#title' => __( 'Pages', 'wpcf' ),
1089
+ '#description' => __( 'Defaults to true.', 'wpcf' ),
1090
+ '#default_value' => !empty( $ct['rewrite']['pages'] ),
1091
+ '#value' => 1,
1092
+ '#inline' => true,
1093
+ );
1094
+ $show_in_menu_page = isset( $ct['show_in_menu_page'] ) ? $ct['show_in_menu_page'] : '';
1095
+ $hidden = !empty( $ct['show_in_menu'] ) ? '' : ' class="hidden"';
1096
+ $form['vars'] = array(
1097
+ '#type' => 'checkboxes',
1098
+ '#name' => 'ct[vars]',
1099
+ '#inline' => true,
1100
+ '#options' => array(
1101
+ 'has_archive' => array(
1102
+ '#name' => 'ct[has_archive]',
1103
+ '#default_value' => !empty( $ct['has_archive'] ),
1104
+ '#title' => __( 'has_archive', 'wpcf' ),
1105
+ '#description' => __( 'Allow custom post type to have index page.',
1106
+ 'wpcf' ) . '<br />' . __( 'Default: not set.', 'wpcf' ),
1107
+ '#inline' => true,
1108
+ ),
1109
+ 'show_in_menu' => array(
1110
+ '#name' => 'ct[show_in_menu]',
1111
+ '#default_value' => !empty( $ct['show_in_menu'] ),
1112
+ '#title' => __( 'show_in_menu', 'wpcf' ),
1113
+ '#description' => __( 'Whether to show the post type in the admin menu and where to show that menu. Note that show_ui must be true.',
1114
+ 'wpcf' ) . '<br />' . __( 'Default: null.', 'wpcf' ),
1115
+ '#after' => '<div id="wpcf-types-form-showinmenu-toggle"' . $hidden . '><input type="text" name="ct[show_in_menu_page]" style="width:50%;" value="' . $show_in_menu_page . '" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __( 'Optional.',
1116
+ 'wpcf' ) . ' ' . __( "Top level page like 'tools.php' or 'edit.php?post_type=page'",
1117
+ 'wpcf' ) . '</div></div>',
1118
+ '#inline' => true,
1119
+ ),
1120
+ 'show_ui' => array(
1121
+ '#name' => 'ct[show_ui]',
1122
+ '#default_value' => !empty( $ct['show_ui'] ),
1123
+ '#title' => __( 'show_ui', 'wpcf' ),
1124
+ '#description' => __( 'Generate a default UI for managing this post type.',
1125
+ 'wpcf' ) . '<br />' . __( 'Default: value of public argument.',
1126
+ 'wpcf' ),
1127
+ '#inline' => true,
1128
+ ),
1129
+ 'publicly_queryable' => array(
1130
+ '#name' => 'ct[publicly_queryable]',
1131
+ '#default_value' => !empty( $ct['publicly_queryable'] ),
1132
+ '#title' => __( 'publicly_queryable', 'wpcf' ),
1133
+ '#description' => __( 'Whether post_type queries can be performed from the front end.',
1134
+ 'wpcf' ) . '<br />' . __( 'Default: value of public argument.',
1135
+ 'wpcf' ),
1136
+ '#inline' => true,
1137
+ ),
1138
+ 'exclude_from_search' => array(
1139
+ '#name' => 'ct[exclude_from_search]',
1140
+ '#default_value' => !empty( $ct['exclude_from_search'] ),
1141
+ '#title' => __( 'exclude_from_search', 'wpcf' ),
1142
+ '#description' => __( 'Whether to exclude posts with this post type from search results.',
1143
+ 'wpcf' ) . '<br />' . __( 'Default: value of the opposite of the public argument.',
1144
+ 'wpcf' ),
1145
+ '#inline' => true,
1146
+ ),
1147
+ 'hierarchical' => array(
1148
+ '#name' => 'ct[hierarchical]',
1149
+ '#default_value' => !empty( $ct['hierarchical'] ),
1150
+ '#title' => __( 'hierarchical', 'wpcf' ),
1151
+ '#description' => __( 'Whether the post type is hierarchical. Allows Parent to be specified.',
1152
+ 'wpcf' ) . '<br />' . __( 'Default: false.', 'wpcf' ),
1153
+ '#inline' => true,
1154
+ ),
1155
+ 'can_export' => array(
1156
+ '#name' => 'ct[can_export]',
1157
+ '#default_value' => !empty( $ct['can_export'] ),
1158
+ '#title' => __( 'can_export', 'wpcf' ),
1159
+ '#description' => __( 'Can this post_type be exported.', 'wpcf' ) . '<br />' . __( 'Default: true.',
1160
+ 'wpcf' ),
1161
+ '#inline' => true,
1162
+ ),
1163
+ 'show_in_nav_menus' => array(
1164
+ '#name' => 'ct[show_in_nav_menus]',
1165
+ '#default_value' => !empty( $ct['show_in_nav_menus'] ),
1166
+ '#title' => __( 'show_in_nav_menus', 'wpcf' ),
1167
+ '#description' => __( 'Whether post_type is available for selection in navigation menus.',
1168
+ 'wpcf' ) . '<br />' . __( 'Default: value of public argument.',
1169
+ 'wpcf' ),
1170
+ '#inline' => true,
1171
+ ),
1172
+ ),
1173
+ );
1174
+ $query_var = isset( $ct['query_var'] ) ? $ct['query_var'] : '';
1175
+ $hidden = !empty( $ct['query_var_enabled'] ) ? '' : ' class="hidden"';
1176
+ $form['query_var'] = array(
1177
+ '#type' => 'checkbox',
1178
+ '#name' => 'ct[query_var_enabled]',
1179
+ '#title' => 'query_var',
1180
+ '#description' => __( 'False to prevent queries, or string value of the query var to use for this post type.',
1181
+ 'wpcf' ) . '<br />' . __( 'Default: true - set to $post_type.',
1182
+ 'wpcf' ),
1183
+ '#default_value' => !empty( $ct['query_var_enabled'] ),
1184
+ '#after' => '<div id="wpcf-types-form-queryvar-toggle"' . $hidden . '><input type="text" name="ct[query_var]" value="' . $query_var . '" style="width:50%;" /><div class="description wpcf-form-description wpcf-form-description-checkbox description-checkbox">' . __( 'Optional',
1185
+ 'wpcf' ) . '. ' . __( 'String to customize query var', 'wpcf' ) . '</div></div>',
1186
+ '#inline' => true,
1187
+ );
1188
+ $form['permalink_epmask'] = array(
1189
+ '#type' => 'textfield',
1190
+ '#name' => 'ct[permalink_epmask]',
1191
+ '#title' => __( 'Permalink epmask', 'wpcf' ),
1192
+ '#description' => sprintf( __( 'Default value EP_PERMALINK. More info here %s.',
1193
+ 'wpcf' ),
1194
+ '<a href="http://core.trac.wordpress.org/ticket/12605" target="_blank">link</a>' ),
1195
+ '#value' => isset( $ct['permalink_epmask'] ) ? $ct['permalink_epmask'] : '',
1196
+ '#inline' => true,
1197
+ );
1198
+ $form['table-6-close'] = wpcf_admin_metabox_end();
1199
+ return $form;
1200
+ }
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.4/includes/fields-control.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -358,8 +358,13 @@ function wpcf_admin_custom_fields_control_bulk_actions($action = '') {
358
  'wpcf'), implode(', ', $success)));
359
  }
360
  if (!empty($failed)) {
361
- wpcf_admin_message_store(sprintf(__('Fields %s are not Types fields. Types wont delete these fields.',
362
- 'wpcf'), implode(', ', $failed)));
 
 
 
 
 
363
  }
364
  }
365
  wp_redirect($_SERVER['REQUEST_URI']);
2
  /*
3
  * Custom Fields Control Screen
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
358
  'wpcf'), implode(', ', $success)));
359
  }
360
  if (!empty($failed)) {
361
+ wpcf_admin_message_store(
362
+ sprintf(
363
+ __('Fields %s are not Types fields. Types wont delete these fields.', 'wpcf'),
364
+ implode(', ', $failed)
365
+ ),
366
+ 'error'
367
+ );
368
  }
369
  }
370
  wp_redirect($_SERVER['REQUEST_URI']);
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.4/includes/fields-form.php $
6
- * $LastChangedDate: 2014-10-23 10:33:39 +0000 (Thu, 23 Oct 2014) $
7
- * $LastChangedRevision: 1012677 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -366,23 +366,20 @@ function wpcf_admin_fields_form() {
366
  )
367
  );
368
  if ( !$update ) {
369
- $form['title']['#attributes']['onfocus'] = 'if (jQuery(this).val() == \'' . __( 'Enter group title',
370
- 'wpcf' ) . '\') { jQuery(this).val(\'\'); }';
371
- $form['title']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(\'' . __( 'Enter group title',
372
- 'wpcf' ) . '\') }';
373
  }
374
  $form['description'] = array(
375
  '#type' => 'textarea',
376
  '#id' => 'wpcf-group-description',
377
  '#name' => 'wpcf[group][description]',
378
- '#value' => $update ? $update['description'] : __( 'Enter a description for this group',
379
- 'wpcf' ),
380
  );
381
  if ( !$update ) {
382
- $form['description']['#attributes']['onfocus'] = 'if (jQuery(this).val() == \''
383
- . __( 'Enter a description for this group', 'wpcf' ) . '\') { jQuery(this).val(\'\'); }';
384
- $form['description']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(\''
385
- . __( 'Enter a description for this group', 'wpcf' ) . '\') }';
386
  }
387
 
388
  /*
@@ -418,26 +415,22 @@ function wpcf_admin_fields_form() {
418
  }
419
  $options[$post_type_slug]['#name'] = 'wpcf[group][supports][' . $post_type_slug . ']';
420
  $options[$post_type_slug]['#title'] = $post_type->label;
421
- $options[$post_type_slug]['#default_value'] = ($update && !empty( $update['post_types'] ) && in_array( $post_type_slug,
422
- $update['post_types'] )) ? 1 : 0;
423
  $options[$post_type_slug]['#value'] = $post_type_slug;
424
  $options[$post_type_slug]['#inline'] = TRUE;
425
  $options[$post_type_slug]['#suffix'] = '<br />';
426
  $options[$post_type_slug]['#id'] = 'wpcf-form-groups-support-post-type-' . $post_type_slug;
427
  $options[$post_type_slug]['#attributes'] = array('class' => 'wpcf-form-groups-support-post-type');
428
- if ( $update && !empty( $update['post_types'] ) && in_array( $post_type_slug,
429
- $update['post_types'] ) ) {
430
  $post_types_currently_supported[] = $post_type->label;
431
  }
432
  }
433
 
434
  if ( empty( $post_types_currently_supported ) ) {
435
- $post_types_currently_supported[] = __( 'Displayed on all content types',
436
- 'wpcf' );
437
  }
438
 
439
 
440
-
441
  /*
442
  *
443
  *
@@ -467,14 +460,6 @@ function wpcf_admin_fields_form() {
467
  implode( ',', $post_types_currently_supported ),
468
  __( 'Displayed on all content types', 'wpcf' ), $temp );
469
 
470
-
471
-
472
-
473
-
474
-
475
-
476
-
477
-
478
  /*
479
  *
480
  *
@@ -486,8 +471,7 @@ function wpcf_admin_fields_form() {
486
  *
487
  * TAXONOMIES FILTER QUERY
488
  */
489
- $taxonomies = apply_filters( 'wpcf_group_form_filter_taxonomies',
490
- get_taxonomies( '', 'objects' ) );
491
  $options = array();
492
  $tax_currently_supported = array();
493
  $form_tax = array();
2
  /*
3
  * Fields and groups form functions.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
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
  /*
415
  }
416
  $options[$post_type_slug]['#name'] = 'wpcf[group][supports][' . $post_type_slug . ']';
417
  $options[$post_type_slug]['#title'] = $post_type->label;
418
+ $options[$post_type_slug]['#default_value'] = ($update && !empty( $update['post_types'] ) && in_array( $post_type_slug, $update['post_types'] )) ? 1 : 0;
 
419
  $options[$post_type_slug]['#value'] = $post_type_slug;
420
  $options[$post_type_slug]['#inline'] = TRUE;
421
  $options[$post_type_slug]['#suffix'] = '<br />';
422
  $options[$post_type_slug]['#id'] = 'wpcf-form-groups-support-post-type-' . $post_type_slug;
423
  $options[$post_type_slug]['#attributes'] = array('class' => 'wpcf-form-groups-support-post-type');
424
+ if ( $update && !empty( $update['post_types'] ) && in_array( $post_type_slug, $update['post_types'] ) ) {
 
425
  $post_types_currently_supported[] = $post_type->label;
426
  }
427
  }
428
 
429
  if ( empty( $post_types_currently_supported ) ) {
430
+ $post_types_currently_supported[] = __( 'Displayed on all content types', 'wpcf' );
 
431
  }
432
 
433
 
 
434
  /*
435
  *
436
  *
460
  implode( ',', $post_types_currently_supported ),
461
  __( 'Displayed on all content types', 'wpcf' ), $temp );
462
 
 
 
 
 
 
 
 
 
463
  /*
464
  *
465
  *
471
  *
472
  * TAXONOMIES FILTER QUERY
473
  */
474
+ $taxonomies = apply_filters( 'wpcf_group_form_filter_taxonomies', get_taxonomies( '', 'objects' ) );
 
475
  $options = array();
476
  $tax_currently_supported = array();
477
  $form_tax = array();
includes/fields-list.php CHANGED
@@ -2,10 +2,10 @@
2
  /*
3
  * Fields and groups list functions
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/includes/fields-list.php $
6
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
7
- * $LastChangedRevision: 970205 $
8
- * $LastChangedBy: brucepearson $
9
  *
10
  */
11
 
@@ -63,15 +63,16 @@ function wpcf_admin_fields_list() {
63
  $name .= '<div id="wpcf_list_ajax_response_' . $group['id'] . '"></div>';
64
 
65
  $rows[$group['id']]['name'] = $name;
 
66
 
67
 
68
  $rows[$group['id']]['description'] = $group['description'];
69
  $rows[$group['id']]['active-' . $group['id']] = $group['is_active'] ? __('Yes', 'wpcf') : __('No', 'wpcf');
 
70
 
71
  // Set 'post_tpes' column
72
  $post_types = wpcf_admin_get_post_types_by_group($group['id']);
73
- $rows[$group['id']]['post_types'] = empty($post_types) ? __('None',
74
- 'wpcf') : implode(', ', $post_types);
75
 
76
  // Set 'taxonomies' column
77
  $taxonomies = wpcf_admin_get_taxonomies_by_group($group['id']);
@@ -90,6 +91,7 @@ function wpcf_admin_fields_list() {
90
  }
91
  $rows[$group['id']]['tax'] = $output;
92
  }
 
93
 
94
  // Render table
95
  wpcf_admin_widefat_table('wpcf_groups_list', $header, $rows);
@@ -97,3 +99,14 @@ function wpcf_admin_fields_list() {
97
 
98
  do_action('wpcf_groups_list_table_after');
99
  }
 
 
 
 
 
 
 
 
 
 
 
2
  /*
3
  * Fields and groups list functions
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
11
 
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']);
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);
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
+ }
includes/fields.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Fields and groups functions
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/includes/fields.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
2
  /*
3
  * Fields and groups functions
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/includes/fields.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
includes/import-export.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Import/export data.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/includes/import-export.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
2
  /*
3
  * Import/export data.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/includes/import-export.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
includes/introduction.php DELETED
@@ -1,41 +0,0 @@
1
- <?php
2
- /*
3
- * Introduction page.
4
- *
5
- * $HeadURL: $
6
- * $LastChangedDate: $
7
- * $LastChangedRevision: $
8
- * $LastChangedBy: $
9
- *
10
- */
11
-
12
- echo wpcf_add_admin_header(__('Help', 'wpcf'));
13
-
14
- ?>
15
- <h3><?php _e('Start using Types', 'wpcf'); ?></h3>
16
- <p><a class="button-primary" href="<?php echo admin_url('admin.php?page=wpcf-edit-type'); ?>"><?php _e('New custom post types and taxonomy', 'wpcf'); ?></a> &nbsp; <a class="button-primary" href="<?php echo admin_url('admin.php?page=wpcf-edit'); ?>"><?php _e('New custom fields', 'wpcf'); ?></a></p>
17
-
18
- <h3 style="margin-top:3em;"><?php _e('Documentation and Support', 'wpcf'); ?></h3>
19
- <ul>
20
- <li><?php printf(__('%sUser Guides%s - everything you need to know about using Types', 'wpcf'), '<a target="_blank" href="http://wp-types.com/documentation/user-guides/?utm_source=typesplugin&utm_medium=intro&utm_campaign=types#Types"><strong>', ' &raquo;</strong></a>'); ?></li>
21
- <li><?php printf(__('%sTypes fields API%s (for developers) - Learn how to insert Types fields to PHP templates', 'wpcf'), '<a target="_blank" href="http://wp-types.com/documentation/functions/?utm_source=typesplugin&utm_medium=intro&utm_campaign=types"><strong>', ' &raquo;</strong></a>'); ?></li>
22
- <li><?php printf(__('%sSupport forum%s - register in our forum to receive support', 'wpcf'), '<a target="_blank" href="http://wp-types.com/support/register/?utm_source=typesplugin&utm_medium=intro&utm_campaign=types"><strong>', ' &raquo;</strong></a>'); ?></li>
23
- </ul>
24
-
25
- <h3 style="margin-top:3em;"><?php _e('Want to help Types?', 'wpcf'); ?></h3>
26
- <ul>
27
- <li><?php printf(__('%sRate Types on WordPress.org%s', 'wpcf'), '<a target="_blank" href="http://wordpress.org/extend/plugins/types/"><strong>', ' &raquo;</strong></a>'); ?></li>
28
- <li><?php printf(__('%sTypes press resources%s - write about Types', 'wpcf'), '<a target="_blank" href="http://wp-types.com/home/press-resources/?utm_source=typesplugin&utm_medium=intro&utm_campaign=types"><strong>', ' &raquo;</strong></a>'); ?></li>
29
- <li><?php printf(__('%sViews%s - the commercial complement of Types, which makes content display a breeze.', 'wpcf'), '<a target="_blank" href="http://wp-types.com/home/views-create-elegant-displays-for-your-content/?utm_source=typesplugin&utm_medium=intro&utm_campaign=types"><strong>', ' &raquo;</strong></a>'); ?></li>
30
- </ul>
31
-
32
- <h3 style="margin-top:3em;"><?php _e('Debug information', 'wpcf'); ?></h3>
33
-
34
- <p><?php
35
- printf(
36
- __( 'For retrieving debug information if asked by a support person, use the <a href="%s">debug information</a> page.', 'wpcf' ),
37
- admin_url('admin.php?page=wpcf-debug-information')
38
- );
39
- ?></p>
40
- <?php
41
- echo wpcf_add_admin_footer();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/migration.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  * Migration functions
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/includes/migration.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
2
  /*
3
  * Migration functions
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/includes/migration.php $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
includes/post-relationship.php CHANGED
@@ -76,10 +76,20 @@ function wpcf_pr_post_type_form_filter( $form, $post_type ) {
76
 
77
  $options = array();
78
 
 
 
 
 
 
 
79
  foreach ( $post_types as $temp_post_type_slug => $temp_post_type ) {
80
- if ( in_array( $temp_post_type_slug,
81
- array($post_type['slug']) + $wpcf->excluded_post_types )
82
- || !$temp_post_type->show_ui ) {
 
 
 
 
83
  continue;
84
  }
85
  // Check if it's in has
@@ -114,9 +124,13 @@ function wpcf_pr_post_type_form_filter( $form, $post_type ) {
114
  );
115
  $options = array();
116
  foreach ( $post_types as $temp_post_type_slug => $temp_post_type ) {
117
- if ( in_array( $temp_post_type_slug,
118
- array($post_type['slug']) + $wpcf->excluded_post_types )
119
- || !$temp_post_type->show_ui ) {
 
 
 
 
120
  continue;
121
  }
122
  // Check if it already belongs
@@ -246,8 +260,7 @@ function wpcf_pr_admin_edit_fields( $parent, $child ) {
246
  wp_enqueue_style( 'types' );
247
  wpcf_admin_ajax_head( 'Edit fields', 'wpcf' );
248
  // Process submit
249
- if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'],
250
- 'pt_edit_fields' ) ) {
251
  $relationships[$parent][$child]['fields_setting'] = $_POST['fields_setting'];
252
  $relationships[$parent][$child]['fields'] = isset( $_POST['fields'] ) ? $_POST['fields'] : array();
253
  update_option( 'wpcf_post_relationship', $relationships );
@@ -264,8 +277,7 @@ function wpcf_pr_admin_edit_fields( $parent, $child ) {
264
  $options_cf = array();
265
  $repetitive_warning = false;
266
  $repetitive_warning_markup = array();
267
- $repetitive_warning_txt = __( 'Repeating fields should not be used in child posts. Types will update all field values.',
268
- 'wpcf' );
269
  foreach ( $groups as $group ) {
270
  $fields = wpcf_admin_fields_get_fields_by_group( $group['id'] );
271
  foreach ( $fields as $key => $cf ) {
@@ -301,7 +313,8 @@ function wpcf_pr_admin_edit_fields( $parent, $child ) {
301
  '#name' => 'fields_setting',
302
  '#options' => array(
303
  __( 'Title, all custom fields and parents', 'wpcf' ) => 'all_cf',
304
- __( 'All fields, including the standard post fields', 'wpcf' ) => 'all_cf_standard',
 
305
  __( 'Specific fields', 'wpcf' ) => 'specific',
306
  ),
307
  '#default_value' => empty( $data['fields_setting'] ) ? 'all_cf' : $data['fields_setting'],
@@ -363,7 +376,9 @@ function wpcf_pr_admin_edit_fields( $parent, $child ) {
363
  if (jQuery('input[name="fields_setting"]:checked').val() == 'specific') {
364
  jQuery('#wpcf-specific').show();
365
  } else {
366
- <?php if ( $repetitive_warning ) { ?>
 
 
367
  jQuery('#wpcf-repetitive-warning').show();
368
  <?php
369
  }
@@ -375,10 +390,10 @@ function wpcf_pr_admin_edit_fields( $parent, $child ) {
375
  } else {
376
  jQuery('#wpcf-specific').slideUp();
377
  <?php if ( $repetitive_warning ) { ?>
 
378
  jQuery('#wpcf-repetitive-warning').show();
379
- <?php
380
- }
381
- ?>
382
  }
383
  });
384
  });
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
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
260
  wp_enqueue_style( 'types' );
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 );
277
  $options_cf = array();
278
  $repetitive_warning = false;
279
  $repetitive_warning_markup = array();
280
+ $repetitive_warning_txt = __( 'Repeating fields should not be used in child posts. Types will update all field values.', 'wpcf' );
 
281
  foreach ( $groups as $group ) {
282
  $fields = wpcf_admin_fields_get_fields_by_group( $group['id'] );
283
  foreach ( $fields as $key => $cf ) {
313
  '#name' => 'fields_setting',
314
  '#options' => array(
315
  __( 'Title, all custom fields and parents', 'wpcf' ) => 'all_cf',
316
+ __( 'Do not show management options for this post type', 'wpcf' ) => 'only_list',
317
+ __( 'All fields, including the standard post fields', 'wpcf' ) => 'all_cf_standardll_cf_standard',
318
  __( 'Specific fields', 'wpcf' ) => 'specific',
319
  ),
320
  '#default_value' => empty( $data['fields_setting'] ) ? 'all_cf' : $data['fields_setting'],
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();
383
  <?php
384
  }
390
  } else {
391
  jQuery('#wpcf-specific').slideUp();
392
  <?php if ( $repetitive_warning ) { ?>
393
+ if ( 'only_list' != jQuery('input[name="fields_setting"]:checked').val()) {
394
  jQuery('#wpcf-repetitive-warning').show();
395
+ }
396
+ <?php } ?>
 
397
  }
398
  });
399
  });
includes/settings.php CHANGED
@@ -142,6 +142,24 @@ function wpcf_admin_general_settings_form() {
142
  return $form;
143
  }
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  /**
146
  * Saves settings.
147
  *
@@ -177,9 +195,8 @@ function wpcf_admin_image_settings_form_submit($form) {
177
  wpcf_admin_message_store(__('Settings saved', 'wpcf'));
178
  }
179
 
180
-
181
  function wpcf_admin_general_settings_form_submit($form) {
182
-
183
  $settings = wpcf_get_settings();
184
  $data = $_POST['wpcf_settings'];
185
  foreach (array('register_translations_on_import','help_box') as $setting) {
@@ -209,4 +226,4 @@ function wpcf_admin_general_settings_form_submit($form) {
209
  // }
210
 
211
  wpcf_admin_message_store(__('Settings saved', 'wpcf'));
212
- }
142
  return $form;
143
  }
144
 
145
+ function wpcf_admin_toolset_messages_form()
146
+ {
147
+ $settings = wpcf_get_settings();
148
+ $form = array();
149
+
150
+ $form['help-box'] = array(
151
+ '#id' => 'help_box',
152
+ '#name' => 'wpcf_settings[toolset_messages]',
153
+ '#type' => 'checkbox',
154
+ '#title' => __('Disable all messages about other Toolset components', 'wpcf'),
155
+ '#default_value' => isset($settings['toolset_messages'])? $settings['toolset_messages']:0,
156
+ );
157
+ $form['spinner'] = array(
158
+ '#type' => 'markup',
159
+ '#markup' => '<span class="spinner" style="float:left;"></span>',
160
+ );
161
+ return $form;
162
+ }
163
  /**
164
  * Saves settings.
165
  *
195
  wpcf_admin_message_store(__('Settings saved', 'wpcf'));
196
  }
197
 
 
198
  function wpcf_admin_general_settings_form_submit($form) {
199
+
200
  $settings = wpcf_get_settings();
201
  $data = $_POST['wpcf_settings'];
202
  foreach (array('register_translations_on_import','help_box') as $setting) {
226
  // }
227
 
228
  wpcf_admin_message_store(__('Settings saved', 'wpcf'));
229
+ }
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.4/includes/usermeta-control.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -293,8 +293,13 @@ function wpcf_admin_user_fields_control_bulk_actions($action = '') {
293
  'wpcf'), implode(', ', $success)));
294
  }
295
  if (!empty($failed)) {
296
- wpcf_admin_message_store(sprintf(__('Fields %s are not Types fields. Types wont delete these fields.',
297
- 'wpcf'), implode(', ', $failed)));
 
 
 
 
 
298
  }
299
  }
300
  wp_redirect($_SERVER['REQUEST_URI']);
2
  /*
3
  * Custom Fields Control Screen
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
293
  'wpcf'), implode(', ', $success)));
294
  }
295
  if (!empty($failed)) {
296
+ wpcf_admin_message_store(
297
+ sprintf(
298
+ __('Fields %s are not Types fields. Types wont delete these fields.', 'wpcf'),
299
+ implode(', ', $failed)
300
+ ),
301
+ 'error'
302
+ );
303
  }
304
  }
305
  wp_redirect($_SERVER['REQUEST_URI']);
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.4/includes/usermeta-form.php $
6
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
- * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
9
  *
10
  */
@@ -344,10 +344,9 @@ function wpcf_admin_usermeta_form() {
344
  )
345
  );
346
  if (!$update) {
347
- $form['title']['#attributes']['onfocus'] = 'if (jQuery(this).val() == \'' . __('Enter group title',
348
- 'wpcf') . '\') { jQuery(this).val(\'\'); }';
349
- $form['title']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(\'' . __('Enter group title',
350
- 'wpcf') . '\') }';
351
  }
352
  $form['description'] = array(
353
  '#type' => 'textarea',
@@ -357,14 +356,11 @@ function wpcf_admin_usermeta_form() {
357
  'wpcf'),
358
  );
359
  if (!$update) {
360
- $form['description']['#attributes']['onfocus'] = 'if (jQuery(this).val() == \''
361
- . __('Enter a description for this group', 'wpcf') . '\') { jQuery(this).val(\'\'); }';
362
- $form['description']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(\''
363
- . __('Enter a description for this group', 'wpcf') . '\') }';
364
  }
365
 
366
-
367
-
368
  // Show Fields for
369
  global $wp_roles;
370
  $options = array();
2
  /*
3
  * Fields and groups form functions.
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/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
  */
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',
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();
marketing.php CHANGED
@@ -76,13 +76,3 @@ function types_marketing_message_usermeta_saved($message, $title, $update) {
76
  return $message;
77
  }
78
 
79
- /**
80
- * Ask Types users for feedback on their work
81
- * https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188885189/comments
82
- */
83
- include_once dirname(__FILE__).'/marketing/types_marketing_message_survey_2014_09.php';
84
- function types_marketing_message_survey_2014_09_helper()
85
- {
86
- new types_marketing_message_survey_2014_09();
87
- }
88
-
76
  return $message;
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
marketing/assets/images/access.png ADDED
Binary file
marketing/assets/images/cred.png ADDED
Binary file
marketing/assets/images/views.png ADDED
Binary file
marketing/assets/images/wait.gif ADDED
Binary file
marketing/congrats-post-types/index.php CHANGED
@@ -1,77 +1,52 @@
1
- <div class="wpcf-notif">
2
- <?php if ( $type == 'post_type' ): ?>
3
-
4
- <?php if ( !$update ): ?>
5
-
6
- <p class="wpcf-notif-congrats"><strong><?php
7
- printf( __( 'Congratulations! Your new custom post type %s was successfully created.',
8
- 'wpcf' ), $title );
9
-
10
- ?></strong></p>
11
- <?php else: ?>
12
-
13
- <p class="wpcf-notif-congrats"><strong><?php
14
- printf( __( 'Congratulations! Your custom post type %s was successfully updated.',
15
- 'wpcf' ), $title );
16
-
17
- ?></strong></p>
18
-
19
- <?php endif; ?>
20
-
21
- <?php elseif ( $type == 'taxonomy' ): ?>
22
-
23
- <?php if ( !$update ): ?>
24
- <p class="wpcf-notif-congrats"><strong><?php
25
- printf( __( 'Congratulations! Your new custom taxonomy %s was successfully created.',
26
- 'wpcf' ), $title );
27
-
28
- ?></strong></p>
29
- <?php else: ?>
30
-
31
- <p class="wpcf-notif-congrats"><strong><?php
32
- printf( __( 'Congratulations! Your custom taxonomy %s was successfully updated.',
33
- 'wpcf' ), $title );
34
-
35
- ?></strong></p>
36
-
37
- <?php endif; ?>
38
- <?php elseif ( $type == 'usermeta' ): ?>
39
- <?php if ( !$update ): ?>
40
- <p class="wpcf-notif-congrats"><strong><?php
41
- printf( __( 'Congratulations! Your new user meta group %s was successfully created.',
42
- 'wpcf' ), $title );
43
-
44
- ?></strong></p>
45
- <?php else: ?>
46
-
47
- <p class="wpcf-notif-congrats"><strong><?php
48
- printf( __( 'Congratulations! Your user meta group %s was successfully updated.',
49
- 'wpcf' ), $title );
50
-
51
- ?></strong></p>
52
-
53
- <?php endif; ?>
54
- <?php else: ?>
55
-
56
- <?php if ( !$update ): ?>
57
- <p class="wpcf-notif-congrats"><strong><?php
58
- printf( __( 'Congratulations! Your new custom fields group %s was successfully created.',
59
- 'wpcf' ), $title );
60
-
61
- ?></strong></p>
62
- <?php else: ?>
63
-
64
- <p class="wpcf-notif-congrats"><strong><?php
65
- printf( __( 'Congratulations! Your custom fields group %s was successfully updated.',
66
- 'wpcf' ), $title );
67
-
68
- ?></strong></p>
69
-
70
- <?php endif; ?>
71
- <?php endif; ?>
72
-
73
  <a href="javascript:void(0);" class="wpcf-button show <?php if ( $update ) echo 'wpcf-show'; else echo 'wpcf-hide'; ?>"><?php echo __( 'Show next steps and documentation' ); ?><span class="wpcf-button-arrow show"></span></a>
74
-
75
  <?php $class = $update ? ' wpcf-hide' : ' wpcf-show'; ?>
76
  <div class="wpcf-notif-dropdown<?php echo $class; ?>">
77
  <span><strong><?php echo __( 'Next, learn how to:' ); ?></strong></span>
@@ -142,6 +117,8 @@
142
 
143
  ?> &raquo;</a></li>
144
  </ul>
 
145
  <a href="javascript:void(0);" class="wpcf-button hide" style="float:right;"><?php echo __( 'Hide notifications' ); ?><span class="wpcf-button-arrow hide"></span></a>
146
  </div><!-- END .wpcf-notif-dropdown -->
147
- </div><!-- END .wpcf-notif -->
 
1
+ <?php
2
+ $marketing = new WPCF_Types_Marketing_Messages();
3
+ $show_documentation_link = false;
4
+ ?>
5
+ <?php
6
+ if ( $top = $marketing->show_top($update) ) {
7
+ echo '<div class="wpcf-notif">';
8
+ echo $top;
9
+ echo '</div>';
10
+ } else {
11
+
12
+ $message = false;
13
+
14
+ switch( $type ) {
15
+ case 'post_type':
16
+ if ( $update ) {
17
+ $message = __( 'Congratulations! Your custom post type %s was successfully updated.', 'wpcf' );
18
+ } else {
19
+ $message = __( 'congratulations! your new custom post type %s was successfully created.', 'wpcf' );
20
+ }
21
+ break;
22
+ case 'fields':
23
+ if ( $update) {
24
+ $message = __( 'Congratulations! Your custom fields group %s was successfully updated.', 'wpcf' );
25
+ } else {
26
+ $message = __( 'Congratulations! Your new custom fields group %s was successfully created.', 'wpcf' );
27
+ }
28
+ break;
29
+ case 'taxonomy':
30
+ if ( $update) {
31
+ $message = __( 'Congratulations! Your custom taxonomy %s was successfully updated.', 'wpcf' );
32
+ } else {
33
+ $message = __( 'Congratulations! Your new custom taxonomy %s was successfully created.', 'wpcf' );
34
+ }
35
+ break;
36
+ case 'usermeta':
37
+ if ( $update) {
38
+ $message = __( 'Congratulations! Your user meta group %s was successfully updated.', 'wpcf' );
39
+ } else {
40
+ $message = __( 'Congratulations! Your new user meta group %s was successfully created.', 'wpcf' );
41
+ }
42
+ break;
43
+ }
44
+ $message = sprintf($message, sprintf('<strong>%s</strong>', $title));
45
+ $marketing->update_message($message);
46
+ ?>
47
+ <?php if ( $show_documentation_link ) { ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  <a href="javascript:void(0);" class="wpcf-button show <?php if ( $update ) echo 'wpcf-show'; else echo 'wpcf-hide'; ?>"><?php echo __( 'Show next steps and documentation' ); ?><span class="wpcf-button-arrow show"></span></a>
49
+ <?php } ?>
50
  <?php $class = $update ? ' wpcf-hide' : ' wpcf-show'; ?>
51
  <div class="wpcf-notif-dropdown<?php echo $class; ?>">
52
  <span><strong><?php echo __( 'Next, learn how to:' ); ?></strong></span>
117
 
118
  ?> &raquo;</a></li>
119
  </ul>
120
+
121
  <a href="javascript:void(0);" class="wpcf-button hide" style="float:right;"><?php echo __( 'Hide notifications' ); ?><span class="wpcf-button-arrow hide"></span></a>
122
  </div><!-- END .wpcf-notif-dropdown -->
123
+ <?php } ?>
124
+ <!-- END .wpcf-notif -->
marketing/congrats-post-types/style.css CHANGED
@@ -12,6 +12,8 @@
12
  background: #ffffe0;
13
  border: 1px solid #e6db55;
14
 
 
 
15
  border-radius: 4px;
16
  -moz-border-radius: 4px;
17
  -khtml-border-radius: 4px;
@@ -105,4 +107,43 @@
105
  margin: 10px 0 0 0;
106
  padding: 15px 0 15px 0;
107
  border-top: 1px solid #f0e98d;
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  background: #ffffe0;
13
  border: 1px solid #e6db55;
14
 
15
+ width: 98%;
16
+
17
  border-radius: 4px;
18
  -moz-border-radius: 4px;
19
  -khtml-border-radius: 4px;
107
  margin: 10px 0 0 0;
108
  padding: 15px 0 15px 0;
109
  border-top: 1px solid #f0e98d;
110
+ }
111
+
112
+ .wpcf-notif .icon-toolset
113
+ {
114
+ width: 100%;
115
+ }
116
+
117
+ .wpcf-notif .icon-toolset:before
118
+ {
119
+ color: #f05a28;
120
+ float: left;
121
+ font-size: 70px;
122
+ padding: 0 15px;
123
+ }
124
+
125
+ .wpcf-notif .wpcf-notif-header
126
+ {
127
+ font-size: 30px;
128
+ color: #e25527;
129
+ font-style: italic;
130
+ font-weight: 600;
131
+ padding: 0 15px;
132
+ }
133
+
134
+ .wpcf-notif a.wpcf-notif-more
135
+ {
136
+ color: #0074a2;
137
+ float: right;
138
+ font-size: 21px;
139
+ padding-right: 15px;
140
+ text-decoration: underline;
141
+ }
142
+
143
+ .wpcf-notif .wpcf-notif-description
144
+ {
145
+ font-size: 14px;
146
+ margin-top: 0;
147
+ padding-top: 0;
148
+ }
149
+
marketing/etc/types-site-kinds.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ return array(
4
+ 'brochure' => array(
5
+ 'title' => __('Brochure', 'wcpf'),
6
+ 'description' => __('static content displayed in different ways', 'wcpf'),
7
+ 'url' => __('http://wp-types.com/develop-brochure-site-wordpress/' , 'wcpf'),
8
+ 'default' => true,
9
+ ),
10
+ // 'directory' => array(
11
+ // 'title' => __('Directory', 'wcpf'),
12
+ // 'url' => __('http://wp-types.com/how-to/develop-directory-site-toolset/', 'wcpf'),
13
+ // ),
14
+ // 'classifieds' => array(
15
+ // 'title' => __('Classifieds', 'wcpf'),
16
+ // 'description' => __('user-submitted content organized by categories', 'wcpf'),
17
+ // 'url' => __('http://wp-types.com/how-to/', 'wcpf'),
18
+ // ),
19
+ 'directory_classifieds' => array(
20
+ 'title' => __('Directory and Classifieds', 'wcpf'),
21
+ 'url' => __('http://wp-types.com/how-to/develop-directory-site-toolset/', 'wcpf'),
22
+ ),
23
+ 'e-commerce' => array(
24
+ 'title' => __('E-Commerce', 'wcpf'),
25
+ 'url' => __('http://wp-types.com/how-to/develop-e-commerce-site-toolset/', 'wcpf'),
26
+ ),
27
+ 'blog' => array(
28
+ 'title' => __('Blog / Magazine', 'wcpf'),
29
+ 'description' => __('news sites with unique layouts', 'wcpf'),
30
+ 'url' => __('http://wp-types.com/how-to/customise-wordpress-blog/', 'wcpf'),
31
+ ),
32
+ 'other' => array(
33
+ 'title' => __('Something else', 'wcpf'),
34
+ 'url' => __('http://wp-types.com/how-to/build-sites-toolset/', 'wcpf'),
35
+ ),
36
+ );
marketing/etc/types.php ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ return array(
4
+
5
+ /**
6
+ * Brochure | static content displayed in different ways
7
+ */
8
+
9
+ 'brochure' => array(
10
+ 'cpt' => array(
11
+ array(
12
+ 'header' => __( 'Toolset lets you display PPP without coding!', 'wcpf' ),
13
+ 'description' => __( 'See how Toolset can help you build custom WordPress sites without writing PHP', 'wcpf' ),
14
+ 'link' => __( 'http://wp-types.com/landing/types/', 'wcpf' ),
15
+ ),
16
+ ),
17
+ 'taxonomy' => array(
18
+ array(
19
+ 'header' => __( 'Toolset lets you display TTT without coding!', 'wcpf' ),
20
+ 'description' => __( 'See how Toolset can help you build custom WordPress sites without writing PHP', 'wcpf' ),
21
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
22
+ ),
23
+ ),
24
+ 'fields' => array(
25
+ array(
26
+ 'header' => __( 'Toolset lets you display custom fields without coding!', 'wcpf' ),
27
+ 'description' => __( 'See how Toolset can help you build custom WordPress sites without writing PHP', 'wcpf' ),
28
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
29
+ ),
30
+ ),
31
+ ),
32
+
33
+ /*
34
+ * directory | user-submitted content organized by categories E-Commerce
35
+ */
36
+
37
+ // 'directory' => array(
38
+ // 'cpt' => array(
39
+ // array(
40
+ // 'header' => __( 'You can build parametric searches for PPP using Toolset, without any PHP!', 'wcpf' ),
41
+ // 'description' => __( 'Build custom classifieds sites with Toolset, on any theme, without writing PHP', 'wcpf' ),
42
+ // 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
43
+ // ),
44
+ // ),
45
+ // 'taxonomy' => array(
46
+ // array(
47
+ // 'header' => __( 'Toolset lets you display a directory of TTT!', 'wcpf' ),
48
+ // 'description' => __( 'Build custom classifieds sites with Toolset, on any theme, without writing PHP', 'wcpf' ),
49
+ // 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
50
+ // ),
51
+ // ),
52
+ // 'fields' => array(
53
+ // array(
54
+ // 'description' => __( 'Develop flexible directory sites with Toolset, on any theme, without writing PHP', 'wcpf' ),
55
+ // 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
56
+ // ),
57
+ // ),
58
+ // ),
59
+
60
+ 'directory_classifieds' => array(
61
+ 'cpt' => array(
62
+ array(
63
+ 'header' => __( 'You can build parametric searches for PPP using Toolset, without any PHP!', 'wcpf' ),
64
+ 'description' => __( 'Build custom classifieds sites with Toolset, on any theme, without writing PHP', 'wcpf' ),
65
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
66
+ ),
67
+ ),
68
+ 'taxonomy' => array(
69
+ array(
70
+ 'header' => __( 'Toolset lets you display a directory of TTT!', 'wcpf' ),
71
+ 'description' => __( 'Build custom classifieds sites with Toolset, on any theme, without writing PHP', 'wcpf' ),
72
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
73
+ ),
74
+ ),
75
+ 'fields' => array(
76
+ array(
77
+ 'description' => __( 'Develop flexible directory sites with Toolset, on any theme, without writing PHP', 'wcpf' ),
78
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
79
+ ),
80
+ ),
81
+ ),
82
+
83
+ /*
84
+ * Classifieds/directory | user-submitted content organized by categories E-Commerce
85
+ */
86
+
87
+ 'classifieds' => array(
88
+ 'cpt' => array(
89
+ array(
90
+ 'header' => __( 'Toolset lets you build forms for editing PPP in the site’s front-end!', 'wcpf' ),
91
+ 'description' => __( 'Develop flexible directory sites with Toolset, on any theme, without writing PHP', 'wcpf' ),
92
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
93
+ ),
94
+ array(
95
+ 'header' => __( 'You can build parametric searches for PPP using Toolset, without any PHP!', 'wcpf' ),
96
+ 'description' => __( 'Develop flexible directory sites with Toolset, on any theme, without writing PHP', 'wcpf' ),
97
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
98
+ 'image' => 'cred',
99
+ ),
100
+ ),
101
+ 'taxonomy' => array(
102
+ array(
103
+ 'description' => __( 'Develop flexible directory sites with Toolset, on any theme, without writing PHP', 'wcpf' ),
104
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
105
+ ),
106
+ ),
107
+ 'fields' => array(
108
+ array(
109
+ 'description' => __( 'Develop flexible directory sites with Toolset, on any theme, without writing PHP', 'wcpf' ),
110
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
111
+ ),
112
+ ),
113
+ ),
114
+
115
+ /*
116
+ * E-Commerce
117
+ */
118
+ 'e-commerce' => array(
119
+ 'cpt' => array(
120
+ array(
121
+ 'description' => __( 'Add a WooCommerce store to any theme using Toolset and no PHP coding', 'wcpf' ),
122
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
123
+ ),
124
+ ),
125
+ 'taxonomy' => array(
126
+ array(
127
+ 'header' => __( 'Toolset lets you design product templates with fields and taxonomy, but no coding!', 'wcpf' ),
128
+ 'description' => __( 'Add a WooCommerce store to any theme using Toolset and no PHP coding', 'wcpf' ),
129
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
130
+ ),
131
+ ),
132
+ 'fields' => array(
133
+ array(
134
+ 'header' => __( 'Toolset lets you design product templates with fields and taxonomy, but no coding!', 'wcpf' ),
135
+ 'description' => __( 'Add a WooCommerce store to any theme using Toolset and no PHP coding', 'wcpf' ),
136
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
137
+ ),
138
+ ),
139
+ ),
140
+
141
+ /*
142
+ * Blog | mostly focusing around a nicely designed blog
143
+ */
144
+ 'blog' => array(
145
+ 'cpt' => array(
146
+ array(
147
+ 'description' => __( 'Display custom content inside your blog with Toolset and no PHP coding', 'wcpf' ),
148
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
149
+ ),
150
+ ),
151
+ 'taxonomy' => array(
152
+ array(
153
+ 'description' => __( 'Display custom content inside your blog with Toolset and no PHP coding', 'wcpf' ),
154
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
155
+ ),
156
+ ),
157
+ 'fields' => array(
158
+ array(
159
+ 'description' => __( 'Display custom content inside your blog with Toolset and no PHP coding', 'wcpf' ),
160
+ 'link' => __('http://wp-types.com/landing/types/', 'wcpf'),
161
+ ),
162
+ ),
163
+ ),
164
+ /*
165
+ * Other
166
+ */
167
+ );
168
+
marketing/getting-started/assets/css/getting-started.css ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body.wpcf-marketing #wpcontent
2
+ {
3
+ background-color: #fff;
4
+ }
5
+
6
+ .container:before
7
+ ,.row:after
8
+ {
9
+ content: " ";
10
+ display: table;
11
+ }
12
+
13
+ .row:aftter
14
+ {
15
+ clear: both;
16
+ }
17
+
18
+ .wp-types table
19
+ {
20
+ border-spacing: 30px 0px;
21
+ border-collapse: separate;
22
+ border-color: #666666;
23
+ margin: 30px -30px;
24
+ }
25
+
26
+ .wp-types
27
+ {
28
+ max-width: 900px;
29
+ text-rendering: optimizeSpeed;
30
+ }
31
+
32
+ .wp-types.about-wrap h1
33
+ {
34
+ margin-right: 0;
35
+ margin-bottom: 40px;
36
+ }
37
+
38
+ .wp-types h2
39
+ {
40
+ margin: 30px 0 15px;
41
+ }
42
+
43
+
44
+
45
+ .wpcf-tutorial-other
46
+ {
47
+ border: 0 solid #f05a28;
48
+ border-top-width: 1px;
49
+ margin-top: 40px;
50
+ padding: 5px 10px;
51
+ }
52
+
53
+ .wp-core-ui .wp-types.select-kind .button
54
+ {
55
+ background: #f05a28 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gwDCxgmb+ZnVQAAAWpJREFUSMetlu9RwkAQxX8wfA8dYAeJFRArEDvQCrQDSmCsIHSAHRgrIB2AFQAVPD+452TiXe5O3JkdJpe3f7K3b5eJJCJSABVQD85b4CNmPB15twQa4AxsLYiTys5kmEXQi6ShFpI2+pZGUunBOC0NI7P5hfE535uOOfYFcnZF/92kdweF1RWr94U86dvf+kq08WWQqYWkg6T1sERLq+MioRS7BMyPL3e4C11S4I6aCK5xGGeUkn1OkFLSyQW4N4PcWseCHCQtZ0aaNrNjLsAK6Oz5yYM5AtXMHs4ewDMwjwRqgcdAkBaYT7lOjr3R4RX3Bb5MXxOJ1Vq5hlIDb1PLov4jazvgLsD6G6DD2jOnTcvcNkXSe5/eCYZZRHOj4pTwFesE595R4cbF/opBNzrscuZMjN371IWz+I+FE8pkZ3eyjgSKrsxZYM482NJ/MZ50pn3mVtbrW/v99BFmkvi3pfaMA0e00dX6BUDZUDXwvghBAAAAAElFTkSuQmCC) no-repeat 98% 50%;
56
+ color: #fff;
57
+ font-weight: 600;
58
+ padding: 7px 45px 7px 11px;
59
+ height: auto;
60
+ border: 0;
61
+ }
62
+
63
+ .table>thead>tr>td
64
+ ,.table>tbody>tr>td
65
+ ,.table>tfoot>tr>td
66
+ {
67
+ padding: 15px 0;
68
+ line-height: 1.42857143;
69
+ vertical-align: top;
70
+ border-top: 2px solid #333;
71
+ }
72
+ table>thead>tr>th
73
+ ,.table>tbody>tr>th
74
+ ,.table>tfoot>tr>th {
75
+ font-weight: bold;
76
+ color: #fff;
77
+ background: #666666;
78
+ vertical-align: middle;
79
+ border: none;
80
+ padding: 8px 15px;
81
+ }
82
+
83
+ .well
84
+ {
85
+ border-color: #dcdcdc;
86
+ min-height: 20px;
87
+ padding: 19px;
88
+ margin-bottom: 20px;
89
+ background-color: #f5f5f5;
90
+ }
91
+
92
+ .post-content th
93
+ {
94
+ text-align: left;
95
+ }
96
+
97
+ .post-content img
98
+ {
99
+ margin-top: 10px;
100
+ margin-bottom: 10px;
101
+ }
102
+ .post-content img:not(.no-border) {
103
+ padding: 4px;
104
+ border: 1px solid #dcdcdc;
105
+ background-color: #fafafa;
106
+ }
107
+ .post-content figure {
108
+ margin: 0;
109
+ padding-right: 10px
110
+ }
111
+ .post-content figcaption
112
+ {
113
+ box-sizing: border-box;
114
+ color: #777;;
115
+ display: block;
116
+ font-size: 13px;
117
+ font-style: italic;
118
+ text-align: center;
119
+ margin-top: -5px;
120
+ margin-bottom: 15px;
121
+ padding-left: 10px;
122
+ }
123
+
124
+ .wp-types ul
125
+ {
126
+ padding-left: 40px;
127
+ list-style-type: disc;
128
+ overflow: auto;
129
+ }
130
+
131
+ .wp-types .marketing-kind-list
132
+ {
133
+ margin-left: 0;
134
+ list-style-type: none;
135
+ }
136
+
137
+ .wp-types .well h3
138
+ {
139
+ margin-top: 0;
140
+ }
141
+ .wp-types .alignright {
142
+ margin-left: 15px;
143
+ }
144
+ .wp-types .alignleft {
145
+ margin-right: 15px;
146
+ padding-right: 10px;
147
+ }
148
+ .wp-types .alignnone {
149
+ display: block;
150
+ }
151
+
152
+ a[target="_blank"]:after,
153
+ .wp-types-icon-external:after {
154
+ content: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAVklEQVR4Xn3PgQkAMQhDUXfqTu7kTtkpd5RA8AInfArtQ2iRXFWT2QedAfttj2FsPIOE1eCOlEuoWWjgzYaB/IkeGOrxXhqB+uA9Bfcm0lAZuh+YIeAD+cAqSz4kCMUAAAAASUVORK5CYII=");
155
+ margin: 0 0 0 5px;
156
+ }
marketing/getting-started/assets/images/arrow.png ADDED
Binary file
marketing/getting-started/assets/scripts/getting-started.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ */
4
+ jQuery( document ).ready(function($) {
5
+
6
+ if ( 'undefined' != typeof marketing_getting_started ) {
7
+ $('[name="'+marketing_getting_started.id+'"]').on('change', function() {
8
+ $('#wcpf-getting-started-button').removeClass('disabled');
9
+ });
10
+ $('#wcpf-getting-started-button').on('click', function() {
11
+ $(this).closest('form').submit();
12
+ });
13
+ }
14
+
15
+ if ( 'undefined' != typeof types_activate ) {
16
+ var html = '<div>';
17
+ html += fill_with_tag('h2',types_activate.header);
18
+ html += fill_with_tag('p',types_activate.text);
19
+ var buttons = fill_with_tag('a', types_activate.button_primary_text, 'button button-primary');
20
+ buttons += ' ';
21
+ buttons += fill_with_tag('a', types_activate.button_dismiss_text, 'button-dismiss');
22
+ html += fill_with_tag('p', buttons, 'buttons');
23
+ html += '</div>';
24
+ html += fill_with_tag('span', fill_with_tag('span', '', 'icon-types-logo'), 'logo');
25
+ var parent = $('#message').html(html).removeClass('updated').addClass('toolset-message-after-activate');
26
+ $('.button-primary', parent).on('click', function() {
27
+ document.location = types_activate.button_primary_url;
28
+ return false;
29
+ });
30
+ $('.button-dismiss', parent).on('click', function() {
31
+ $('#message').detach();
32
+ return false;
33
+ });
34
+
35
+ }
36
+
37
+ function fill_with_tag(tag, text, css_class) {
38
+ var html = '<'+tag;
39
+ if ( css_class ) {
40
+ html += ' class="'+css_class+'"';
41
+ }
42
+ html += '>'+text+'</'+tag+'>';
43
+ return html;
44
+ }
45
+ });
46
+
marketing/getting-started/index.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ include_once WPCF_ABSPATH.'/classes/class.wpcf-marketing-messages.php';
7
+ $marketing = new WPCF_Types_Marketing_Messages();
8
+ $marketing->update_options();
9
+ $content = $marketing->get_content();
10
+
11
+ if (
12
+ empty($content)
13
+ || ( isset($_GET['kind']) && !isset($_POST[$marketing->get_option_name()]) )
14
+ ) {
15
+ $marketing->delete_option_kind();
16
+ ?>
17
+ <div class="wrap wp-types select-kind">
18
+ <h2><?php _e('What kind of site are you building?', 'wcpf') ?></h2>
19
+ <?php settings_errors(); ?>
20
+ <p><?php _e('Types plugin includes a lot of features and there are many possibilities. By selecting what kind of site you are building, you allow Types to advise you about what features are needed and how to use them.', 'wcpf'); ?></p>
21
+ <form method="post">
22
+ <?php wp_nonce_field('update', 'marketing'); ?>
23
+ <?php $marketing->kind_list(); ?>
24
+ <a href="#" id="wcpf-getting-started-button" class="button"><?php _e('Continue', 'wcpf'); ?></a>
25
+ </form>
26
+ </div>
27
+ <?php } else {
28
+ echo '<div class="wrap wp-types about-wrap">';
29
+ echo $content;
30
+ echo '</div>';
31
+ }
32
+ ?>
marketing/types_marketing_message_survey_2014_09.php DELETED
@@ -1,105 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * Ask Types users for feedback on their work
5
- * https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188885189/comments
6
- *
7
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/marketing/types_marketing_message_survey_2014_09.php $
8
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
9
- * $LastChangedRevision: 1027712 $
10
- * $LastChangedBy: iworks $
11
- *
12
- */
13
-
14
- class types_marketing_message_survey_2014_09
15
- {
16
- private $option_name = 'wpcf-survey-2014-09';
17
-
18
- public function __construct()
19
- {
20
- /**
21
- * get survey status
22
- */
23
- $suvery = get_option($this->option_name);
24
- /**
25
- * if empty just create a event day
26
- */
27
- if ( empty( $suvery ) ) {
28
- add_option($this->option_name,time()+14*DAY_IN_SECONDS);
29
- return;
30
- }
31
- /**
32
- * do not show if is dismissed
33
- */
34
- if ( 'dismiss' == $suvery ) {
35
- return;
36
- }
37
- /**
38
- * do propper action
39
- */
40
- switch( $suvery ) {
41
- /**
42
- * do not show
43
- */
44
- case 'dismiss':
45
- break;
46
- /**
47
- * show
48
- */
49
- case 'show':
50
- break;
51
- default:
52
- if ( time() - $suvery > 0 ) {
53
- add_action( 'admin_notices', array($this, 'admin_notice' ) );
54
- add_action( 'wp_ajax_types_marketing_message_survey_2014_09_action', array($this,'ajax_action') );
55
- }
56
- }
57
- }
58
-
59
- public function admin_notice()
60
- {
61
- wp_enqueue_script(
62
- __FUNCTION__,
63
- plugin_dir_url(__FILE__).'types_marketing_message_survey_2014_09_admin_notice.js',
64
- array('jquery')
65
- );
66
- wp_localize_script(
67
- __FUNCTION__,
68
- 'wpcf_survey_2014_09',
69
- array(
70
- 'dismiss' => __( 'Are you sure you want to skip Types survey?', 'wpcf' ),
71
- 'done' => 'done' == get_option($this->option_name)
72
- )
73
- );
74
- echo '<div class="updated" id="types_marketing_message_survey_2014_09">';
75
- echo '<p>';
76
- _e('Types development team is working on major new features. We need your feedback, so that Types can do what you need.', 'wpcf' );
77
- echo '</p>';
78
- echo '<p>';
79
- printf(
80
- '<a href="https://www.surveymonkey.com/s/i-do-with-types" class="survey button button-primary">%s</a>',
81
- __('5 Minute Survey', 'wpcf')
82
- );
83
- printf( ' &nbsp; <a href="#" class="later">%s</a>', __('Remind me later', 'wpcf'));
84
- printf( ' | <a href="#" class="dismiss">%s</a>', __('Dismiss', 'wpcf'));
85
- echo '</p>';
86
- echo '</div>';
87
- }
88
-
89
- public function ajax_action()
90
- {
91
- switch( $_POST['do'] ) {
92
- case 'dismiss':
93
- update_option($this->option_name,'dismiss');
94
- break;
95
- case 'later':
96
- update_option($this->option_name,time()+2*DAY_IN_SECONDS);
97
- break;
98
- case 'go':
99
- update_option($this->option_name,'done');
100
- break;
101
- }
102
- die();
103
- }
104
- }
105
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
marketing/types_marketing_message_survey_2014_09_admin_notice.js DELETED
@@ -1,24 +0,0 @@
1
- jQuery( document ).ready(function($) {
2
- $('#types_marketing_message_survey_2014_09 .survey').bind('click', function() {
3
- $.post(ajaxurl,{ action: 'types_marketing_message_survey_2014_09_action', do: 'go' }, function() {
4
- wpcf_survey_2014_09.done = true;
5
- });
6
- $(this).attr('target','_new');
7
- return true;
8
- });
9
- $('#types_marketing_message_survey_2014_09 .later').bind('click', function() {
10
- $.post(ajaxurl,{ action: 'types_marketing_message_survey_2014_09_action', do: 'later' }, function() {
11
- $('#types_marketing_message_survey_2014_09').hide();
12
- });
13
- return false;
14
- });
15
- $('#types_marketing_message_survey_2014_09 .dismiss').bind('click', function() {
16
- if ( wpcf_survey_2014_09.done || confirm( wpcf_survey_2014_09.dismiss ) ) {
17
- $.post(ajaxurl,{ action: 'types_marketing_message_survey_2014_09_action', do: 'dismiss' }, function() {
18
- $('#types_marketing_message_survey_2014_09').hide();
19
- });
20
- }
21
- return false;
22
- });
23
- });
24
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
plus/installer/changelog.txt ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ = 1.5.1 =
2
+ * Fix for allowing embedded plugins to be updated
3
+ * Logic for the migration from embedded plugins to full plugins
4
+
5
+ = 1.5 =
6
+ * Support for embedded plugins
7
+ * Bug fix: When user registers site key with trailing slash, downloads might not work
8
+ * Tweak: Set a higher timeout limit for the http requests to CDN and API
9
+ * API function: link to specific repository
10
+ * API function: get product price
11
+ * New method for defining affiliate info (with backwards compatibility)
12
+
13
+ = 1.4 =
14
+ * Show explicit error in case of connectivity issues while validating a key.
15
+ * Bug fix: Downloading plugins in bulk was broken by plugin that had a redirect after activation
16
+ * Display friendly error message when WordPress does not have permissions to write to the plugins folder
17
+ * Added support for configuration files to auto-download required plugins and theme keys
18
+ * Changed the "Update this info" button to "Check for updates" (it refreshes the subscription info and checks for updates)
19
+ * Support for high_priority parameter that allows setting priority for an Installer instance when more with the same version number exist.
20
+ * Config files from different instances are combined (define repositories in different instances)
21
+ * Updated support for conditional updates display for ICL users
22
+ * More friendly error reporting and handling when using an invalid site key or the plugins archives are not valid.
23
+
24
+
25
+ = 1.3.1 =
26
+ * Support for conditional release notification (ICanLocalize)
27
+
28
+ = 1.3 =
29
+ * Added a new repository: Toolset
30
+ * The product packages can be displayed hierarchically and ordered
31
+ * The link to automatically create site keys will follow through login on the account site (e.g. wpml.org, wp-types.com)
32
+ * Fixed animation issues (not showing in most browsers) when downloading plugins.
33
+ * Created an admin screen on the repository end (icl-mpp) to sho registration stats (site keys, site keys usage, components usage etc..).
34
+ * Bug fix: Renew and Upgrade buttons were not entirely clickable
35
+ * Bug fix: Action buttons (buy, renew, upgrade) were not displayed correctly when WPML was not active (Installer embedded in theme)
36
+ * Support for site-wide registration. Products can be registered on the network instead of on each site separately.
37
+ * Users are able to add either http or https version for any site urls. There will be one site key that will work with both http and https versions.
38
+
39
+ = 1.2 =
40
+ * Added pagination for site keys list of Account -> My Sites
41
+ * Reversed the order in which the site keys are displayed.
42
+ * Fixed problem with WPML registration information (site key) not being saved when the option_value field in the wp_options table used a different charset than the default WordPress charset defined in wp-config.php
43
+ * Allow registering new sites by clicking a link in the WordPress admin instead of copying and pasting the site url in the Account -> My Sites section
44
+ * Display more detailed debug information related to connectivity issues with the WPML repository
plus/installer/includes/deps-loader.class.php ADDED
@@ -0,0 +1,557 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ if(isset($_POST['plugins_downloaded'])){
331
+ $return['plugins_downloaded'] = $_POST['plugins_downloaded'];
332
+ if(in_array($real_basename, $_POST['plugins_downloaded'])){
333
+ continue;
334
+ }
335
+ }else{
336
+ $return['plugins_downloaded'] = array();
337
+ }
338
+
339
+ if($this->is_plugin_installed($plugin['name']) && !$this->is_plugin_active($plugin['name']) && !$this->is_plugin_active($real_basename)){ // FULL PLUGIN PRESENT BUT INACTIVE
340
+ if($plugin_wp_id = $this->get_plugin_id($plugin['name'])){
341
+ //prevent redirects
342
+ add_filter('wp_redirect', '__return_false', 10000);
343
+ $ret = activate_plugin($plugin_wp_id);
344
+ $return['status_message'] = sprintf(__('Activated %s', 'installer'), $downloads[$plugin['name']]['name']);
345
+ }else{
346
+
347
+ $return['status_message'] = sprintf(__('Plugin not found: %s', 'installer'), $downloads[$plugin['name']]['name']);
348
+ $return['stop'] = 1;
349
+ }
350
+ break; // one operation at the time
351
+ }elseif(!$this->is_plugin_installed($real_basename)){
352
+ $ret = WP_Installer()->download_plugin($downloads[$plugin['name']]['basename'],
353
+ $downloads[$plugin['name']]['url']);
354
+ if($ret){
355
+ $return['status_message'] = sprintf(__('Installed %s', 'installer'), $downloads[$plugin['name']]['name']);
356
+ }else{
357
+ $return['status_message'] = sprintf(__('Failed to download %s', 'installer'), $downloads[$plugin['name']]['name']);
358
+ $return['stop'] = 1;
359
+ }
360
+ $return['plugins_downloaded'][] = $real_basename;
361
+ break; // one operation at the time
362
+
363
+ } elseif (version_compare($latest_version, $installed_version)) {
364
+
365
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
366
+ require_once WP_Installer()->plugin_path() . '/includes/installer-upgrader-skins.php';
367
+
368
+ $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
369
+ $upgrader = new Plugin_Upgrader($upgrader_skins);
370
+
371
+ remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
372
+ add_filter( 'site_transient_update_plugins', array( $this, 'plugins_upgrade_check') );
373
+
374
+ $plugin_wp_id = $this->get_plugin_id($real_basename);
375
+ $ret = $upgrader->upgrade($plugin_wp_id);
376
+
377
+ if($ret){
378
+ activate_plugin($plugin_wp_id);
379
+ $return['status_message'] = sprintf(__('Upgraded %s', 'installer'), $downloads[$plugin['name']]['name']);
380
+ }else{
381
+ $return['status_message'] = sprintf(__('Failed to upgrade %s', 'installer'), $downloads[$plugin['name']]['name']);
382
+ $return['stop'] = 1;
383
+ }
384
+
385
+ $return['plugins_downloaded'][] = $real_basename;
386
+
387
+ break; // one operation at the time
388
+
389
+ }elseif(!$this->is_plugin_active($real_basename) && !$this->is_plugin_active($plugin['name'])){
390
+
391
+ if($plugin_wp_id = $this->get_plugin_id($real_basename)){
392
+ //prevent redirects
393
+ add_filter('wp_redirect', '__return_false', 10000);
394
+
395
+ $ret = activate_plugin($plugin_wp_id);
396
+ $return['status_message'] = sprintf(__('Activated %s', 'installer'), $downloads[$plugin['name']]['name']);
397
+ }else{
398
+
399
+ $return['status_message'] = sprintf(__('Plugin not found: %s', 'installer'), $downloads[$plugin['name']]['name']);
400
+ $return['stop'] = 1;
401
+ }
402
+ break; // one operation at the time
403
+
404
+ }
405
+
406
+ }
407
+
408
+ }
409
+
410
+ }
411
+ }
412
+
413
+ if(empty($return['status_message'])){
414
+ $return['status_message'] = __('Operation complete!', 'installer');
415
+ $return['status_message'] .= '&nbsp;<a href="#" id="wp_installer_fix_deps_dismiss">'. __('Dismiss', 'installer') . '</a>';
416
+ $return['stop'] = 1;
417
+ }
418
+
419
+ echo json_encode($return);
420
+ exit;
421
+
422
+ }
423
+
424
+ public function get_repository_downloads($repository_id, $config){
425
+
426
+ if(!isset($this->repository_downloads[md5(serialize($config))][$repository_id])) {
427
+
428
+ $downloads = array();
429
+ $installer_settings = WP_Installer()->get_settings();
430
+
431
+ if (isset($installer_settings['repositories'][$repository_id])) {
432
+
433
+ foreach ($installer_settings['repositories'][$repository_id]['data']['packages'] as $package) {
434
+
435
+ foreach ($package['products'] as $product) {
436
+
437
+ $available_in_installer = WP_Installer()->is_product_available_for_download($product['name'], $repository_id);
438
+
439
+ foreach ($product['downloads'] as $download) {
440
+
441
+ if (!isset($downloads[$download['basename']]) || (empty($d['_installer_download_url']) && $available_in_installer)) {
442
+
443
+ $d['name'] = $download['name'];
444
+ $d['basename'] = $download['basename'];
445
+ $d['version'] = $download['version'];
446
+ $d['date'] = $download['date'];
447
+ $d['_installer_url'] = $available_in_installer;
448
+
449
+ /*
450
+ $format = 'standard';
451
+ foreach($config['repositories'][$repository_id]['plugins'] as $p){
452
+ if($p['name'] == $d['basename']){
453
+ if(isset($p['format'])){
454
+ $format = $p['format'];
455
+ }
456
+ break;
457
+ }
458
+ }
459
+ */
460
+
461
+ //case of valid subscription
462
+ if($available_in_installer){
463
+ $d['url'] = WP_Installer()->append_site_key_to_download_url($download['url'], WP_Installer()->get_site_key($repository_id), $repository_id);
464
+
465
+ }else{
466
+
467
+ $d['url'] = $download['url'] . '&theme_key=' . $config['repositories'][$repository_id]['key']
468
+ . '&theme_name=' . urlencode($config['name']);
469
+ //. '&format=' . $format;
470
+ }
471
+
472
+
473
+ $downloads[$d['basename']] = $d;
474
+ }
475
+
476
+ }
477
+
478
+ }
479
+
480
+ }
481
+
482
+ }
483
+
484
+ $this->repository_downloads[md5(serialize($config))][$repository_id] = $downloads;
485
+
486
+ }
487
+
488
+ return $this->repository_downloads[md5(serialize($config))][$repository_id];
489
+
490
+ }
491
+
492
+ public function get_plugin_download_url($repository_id, $basename, $config){
493
+
494
+ $downloads = $this->get_repository_downloads($repository_id, $config);
495
+
496
+ return isset($downloads[$basename]) ? $downloads[$basename]['url'] : false;
497
+
498
+ }
499
+
500
+ public function get_plugin_full_name($repository_id, $basename, $config){
501
+
502
+ $downloads = $this->get_repository_downloads($repository_id, $config);
503
+
504
+ return isset($downloads[$basename]) ? $downloads[$basename]['name'] : false;
505
+
506
+ }
507
+
508
+ public function js_footer(){
509
+ ?>
510
+ <script type='text/javascript'>
511
+ /* <![CDATA[ */
512
+
513
+ jQuery('#wp_installer_fix_deps').click(function(){
514
+
515
+ jQuery('#wp_installer_fix_deps').attr('disabled', 'disabled');
516
+ jQuery('#wp_installer_fix_deps_notice').find('.spinner').addClass('spinner-inline').show();
517
+
518
+ var plugins_downloaded = [];
519
+ wp_installer_deps_load_run(plugins_downloaded);
520
+ return false;
521
+ })
522
+
523
+ function wp_installer_deps_load_run(plugins_downloaded){
524
+
525
+ jQuery.ajax({
526
+ url: ajaxurl,
527
+ type: 'post',
528
+ dataType: 'json',
529
+ data: {action: 'wp_installer_fix_deps', plugins_downloaded: plugins_downloaded},
530
+ success: function(ret){
531
+
532
+ plugins_downloaded = ret.plugins_downloaded;
533
+ jQuery('#wp_installer_fix_deps_status').html(ret.status_message);
534
+
535
+ if(ret.stop){
536
+ jQuery('#wp_installer_fix_deps_notice').find('.spinner').removeClass('spinner-inline').hide();
537
+
538
+ }else{
539
+
540
+ wp_installer_deps_load_run(plugins_downloaded);
541
+ }
542
+
543
+ }
544
+ })
545
+ }
546
+
547
+ jQuery('#wp_installer_fix_deps_status').on('click', '#wp_installer_fix_deps_dismiss', function(){
548
+ jQuery('#wp_installer_fix_deps_notice').fadeOut();
549
+ return false;
550
+ })
551
+
552
+ /* ]]> */
553
+ </script>
554
+ <?php
555
+ }
556
+
557
+ }
plus/installer/includes/installer-api.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WP_Installer_API{
4
+
5
+ public static function get_product_installer_link($repository_id, $package_id = false){
6
+
7
+ $menu_url = WP_Installer()->menu_url();
8
+
9
+ $url = $menu_url . '#' . $repository_id;
10
+ if($package_id){
11
+ $url .= '/' . $package_id;
12
+ }
13
+
14
+ return $url;
15
+
16
+ }
17
+
18
+ public static function get_product_price($repository_id, $package_id, $product_id, $incl_discount = false){
19
+
20
+ $price = WP_Installer()->get_product_price($repository_id, $package_id, $product_id, $incl_discount);
21
+
22
+ return $price;
23
+ }
24
+
25
+ }
{embedded/common → plus}/installer/includes/installer-upgrader-skins.php RENAMED
@@ -14,6 +14,10 @@
14
 
15
  }
16
 
 
 
 
 
17
  function add_strings(){
18
 
19
  }
14
 
15
  }
16
 
17
+ function error($error){
18
+ $this->installer_error = $error;
19
+ }
20
+
21
  function add_strings(){
22
 
23
  }
{embedded/common → plus}/installer/includes/installer.class.php RENAMED
@@ -12,7 +12,7 @@ final class WP_Installer{
12
  protected $_plugins_renew_warnings = array();
13
 
14
  protected $_gz_on = false;
15
-
16
  public static function instance() {
17
 
18
  if ( is_null( self::$_instance ) ) {
@@ -35,7 +35,9 @@ final class WP_Installer{
35
  $this->config['plugins_install_tab'] = false;
36
 
37
  add_action('init', array($this, 'init'));
38
-
 
 
39
  add_action('admin_menu', array($this, 'menu_setup'));
40
  add_action('network_admin_menu', array($this, 'menu_setup'));
41
 
@@ -91,19 +93,27 @@ final class WP_Installer{
91
  add_action('wp_ajax_remove_site_key', array($this, 'remove_site_key'));
92
  add_action('wp_ajax_update_site_key', array($this, 'update_site_key'));
93
 
94
- add_action('wp_ajax_installer_download_plugin', array($this, 'download_plugin'));
95
  add_action('wp_ajax_installer_activate_plugin', array($this, 'activate_plugin'));
96
 
97
  add_action('wp_ajax_installer_dismiss_nag', array($this, 'dismiss_nag'));
98
 
99
 
100
  }
 
 
101
 
102
  }
103
-
 
 
 
 
 
 
104
  public function menu_setup(){
105
  global $pagenow;
106
-
107
  if(is_multisite() && !is_network_admin()){
108
  $this->menu_multisite_redirect();
109
  add_options_page(__('Installer', 'installer'), __('Installer', 'installer'), 'manage_options', 'installer', array($this, 'show_products')) ;
@@ -271,6 +281,7 @@ final class WP_Installer{
271
 
272
  $_settings = get_option( 'wp_installer_settings' );
273
 
 
274
  if( is_array( $_settings ) || empty( $_settings ) ){ //backward compatibility 1.1
275
  $settings = $_settings;
276
  return $settings;
@@ -293,6 +304,13 @@ final class WP_Installer{
293
  }
294
  }
295
 
 
 
 
 
 
 
 
296
  return $settings;
297
  }
298
 
@@ -360,36 +378,46 @@ final class WP_Installer{
360
  }
361
 
362
  public function load_repositories_list(){
363
-
364
- $config_file = $this->plugin_path() . '/repositories.xml';
365
-
366
- if(file_exists($this->plugin_path() . '/repositories.sandbox.xml')){
367
- $config_file = $this->plugin_path() . '/repositories.sandbox.xml';
368
- }
369
-
370
- $repos = simplexml_load_file($config_file);
371
-
372
- foreach($repos as $repo){
373
- $id = strval($repo->id);
374
-
375
- $data['api-url'] = strval($repo->apiurl);
376
- $data['products'] = strval($repo->products);
377
-
378
- // excludes rule;
379
- if(isset($this->config['repositories_exclude']) && in_array($id, $this->config['repositories_exclude'])){
380
- return;
381
- }
382
-
383
- // includes rule;
384
- if(isset($this->config['repositories_include']) && !in_array($id, $this->config['repositories_include'])){
385
- return;
 
 
 
 
 
 
 
 
 
 
 
 
386
  }
387
-
388
- $this->repositories[$id] = $data;
389
-
390
-
391
  }
392
-
 
393
  }
394
 
395
  public function filter_repositories_list(){
@@ -458,7 +486,7 @@ final class WP_Installer{
458
  unset($this->settings['repositories'][$id]);
459
  }
460
  }
461
-
462
  $this->settings['last_repositories_update']= time();
463
 
464
  $this->save_settings();
@@ -484,8 +512,9 @@ final class WP_Installer{
484
 
485
  $this->localize_strings();
486
  $this->set_filtered_prices($args);
 
487
  $this->set_hierarchy_and_order();
488
-
489
  foreach($this->settings['repositories'] as $repository_id => $repository){
490
 
491
  if($args['template'] == 'compact'){
@@ -517,7 +546,28 @@ final class WP_Installer{
517
 
518
  }
519
 
520
- private function _render_product_packages($packages, $subscription_type, $expired, $upgrade_options){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
 
522
  $data = array();
523
 
@@ -529,7 +579,7 @@ final class WP_Installer{
529
  // buy base
530
  if(empty($subscription_type) || $expired) {
531
 
532
- $p['url'] = $this->append_parameters_to_buy_url($product['url']);
533
  if (!empty($product['price_disc'])) {
534
  $p['label'] = $product['call2action'] . ' - ' . sprintf('$%s %s$%d%s (USD)', $product['price_disc'], '&nbsp;&nbsp;<del>', $product['price'], '</del>');
535
  } else {
@@ -542,7 +592,7 @@ final class WP_Installer{
542
 
543
  if($product['renewals']) {
544
  foreach ($product['renewals'] as $renewal) {
545
- $p['url'] = $this->append_parameters_to_buy_url($renewal['url']);
546
  $p['label'] = $renewal['call2action'] . ' - ' . sprintf('$%d (USD)', $renewal['price']);
547
  }
548
 
@@ -557,7 +607,7 @@ final class WP_Installer{
557
  foreach($upgrade_options[$product['subscription_type']] as $stype => $upgrade){
558
  if($stype != $subscription_type) continue;
559
 
560
- $p['url'] = $this->append_parameters_to_buy_url($upgrade['url']);
561
  if (!empty($upgrade['price_disc'])) {
562
  $p['label'] = $upgrade['call2action'] . ' - ' . sprintf('$%s %s$%d%s (USD)', $upgrade['price_disc'], '&nbsp;&nbsp;<del>', $upgrade['price'], '</del>');
563
  } else {
@@ -581,6 +631,7 @@ final class WP_Installer{
581
 
582
  }
583
 
 
584
  $row['image_url'] = $package['image_url'];
585
  $row['name'] = $package['name'];
586
  $row['description'] = $package['description'];
@@ -596,32 +647,36 @@ final class WP_Installer{
596
 
597
  }
598
 
599
- public function append_parameters_to_buy_url($url, $args = array()){
600
 
601
  $url = add_query_arg( array('icl_site_url' => $this->get_installer_site_url() ), $url );
602
 
603
  $affiliate_id = false;
604
  $affiliate_key = false;
605
 
606
- if(isset($this->config['affiliate_id']) && isset($this->config['affiliate_key'])){
607
 
608
- $affiliate_id = $this->config['affiliate_id'];
609
- $affiliate_key = $this->config['affiliate_key'];
610
 
611
- }elseif(isset($args['affiliate_id']) && isset($args['affiliate_key'])){
612
 
613
- $affiliate_id = $args['affiliate_id'];
614
- $affiliate_key = $args['affiliate_key'];
615
 
616
- }elseif(defined('ICL_AFFILIATE_ID') && defined('ICL_AFFILIATE_KEY')){
617
 
618
  $affiliate_id = ICL_AFFILIATE_ID;
619
  $affiliate_key = ICL_AFFILIATE_KEY;
620
 
 
 
 
 
621
  }
622
-
623
  if($affiliate_id && $affiliate_key){
624
- $url = add_query_arg(array('affiliate_id' => $affiliate_id, 'affiliate_key' => $affiliate_key), $url);
625
  }
626
 
627
  return $url;
@@ -642,13 +697,21 @@ final class WP_Installer{
642
 
643
  $subscription_data = $this->fetch_subscription_data($repository_id, $site_key);
644
 
645
- if($subscription_data){
 
 
 
 
 
 
 
 
 
646
  $this->settings['repositories'][$repository_id]['subscription'] = array('key' => $site_key, 'data' => $subscription_data);
647
  $this->save_settings();
648
- }else{
649
 
 
650
  $error = __('Invalid site key for the current site.', 'installer');
651
-
652
  }
653
 
654
  }
@@ -690,7 +753,7 @@ final class WP_Installer{
690
  }
691
 
692
  public function update_site_key(){
693
-
694
  $error = '';
695
 
696
  if($_POST['nonce'] == wp_create_nonce('update_site_key_' . $_POST['repository_id'])){
@@ -702,7 +765,11 @@ final class WP_Installer{
702
  $subscription_data = $this->fetch_subscription_data($repository_id, $site_key);
703
 
704
  if($subscription_data){
705
- $this->settings['repositories'][$repository_id]['subscription'] = array('key' => $site_key, 'data' => $subscription_data);
 
 
 
 
706
  }else{
707
  unset($this->settings['repositories'][$repository_id]['subscription']);
708
  $error = __('Invalid site key for the current site.', 'installer');
@@ -737,7 +804,13 @@ final class WP_Installer{
737
 
738
  $subscription_data = false;
739
 
740
- $args['body'] = array('action' => 'site_key_validation', 'site_key' => $site_key, 'site_url' => $this->get_installer_site_url($repository_id) );
 
 
 
 
 
 
741
  $response = wp_remote_post($this->repositories[$repository_id]['api-url'], $args);
742
 
743
  $this->api_debug_log("POST {$this->repositories[$repository_id]['api-url']}");
@@ -759,13 +832,23 @@ final class WP_Installer{
759
  }else{
760
 
761
  $this->api_debug_log($response);
762
-
763
  }
764
 
765
  return $subscription_data;
766
 
767
  }
768
 
 
 
 
 
 
 
 
 
 
 
769
  public function repository_has_valid_subscription($repository_id){
770
 
771
  $valid = false;
@@ -796,6 +879,12 @@ final class WP_Installer{
796
 
797
  }
798
 
 
 
 
 
 
 
799
  public function show_subscription_renew_warning($repository_id, $subscription_id){
800
 
801
  $show = false;
@@ -996,6 +1085,49 @@ final class WP_Installer{
996
  return $have;
997
  }
998
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
999
  public function get_upgrade_options($repository_id){
1000
  $all_upgrades = array();
1001
 
@@ -1047,8 +1179,8 @@ final class WP_Installer{
1047
 
1048
  foreach($plugins as $plugin_id => $plugin){
1049
 
1050
- if($plugin['Name'] == $name && dirname($plugin_id) == $folder){
1051
-
1052
  if($version){
1053
  if(version_compare($plugin['Version'], $version, '>=')){
1054
  $is = $plugin['Version'];
@@ -1064,84 +1196,248 @@ final class WP_Installer{
1064
 
1065
  return $is;
1066
  }
1067
-
1068
- public function download_plugin(){
 
 
 
 
 
 
1069
 
1070
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1071
- require_once $this->plugin_path() . '/includes/installer-upgrader-skins.php';
1072
 
1073
- if(isset($_POST['data'])){
1074
- $data = json_decode( base64_decode( $_POST['data'] ), true );
 
 
 
 
 
 
1075
  }
1076
 
1077
- $ret = false;
1078
- $plugin_id = false;
 
 
 
 
 
 
1079
 
1080
- if($data['nonce'] == wp_create_nonce('install_plugin_' . $data['url'])){
1081
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1082
  $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
1083
  $upgrader = new Plugin_Upgrader($upgrader_skins);
1084
-
1085
- remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
1086
-
1087
- $plugins = get_plugins();
1088
-
1089
- //upgrade or install?
1090
- foreach($plugins as $id => $plugin){
1091
- if(dirname($id) == $data['basename']){
1092
- $plugin_id = $id;
1093
- break;
1094
- }
1095
  }
1096
-
1097
- if($plugin_id){ //upgrade
1098
- $response['upgrade'] = 1;
1099
-
1100
- $plugin_is_active = is_plugin_active($plugin_id);
 
 
 
 
 
 
 
 
 
 
1101
 
1102
- $ret = $upgrader->upgrade($plugin_id);
 
 
 
 
 
 
 
 
 
 
1103
 
1104
- if($plugin_is_active){
1105
- activate_plugin($plugin_id);
1106
- }
1107
 
1108
- }else{ //install
1109
-
1110
- $response['install'] = 1;
1111
- $ret = $upgrader->install($data['url']);
1112
- }
1113
-
1114
- $plugins = get_plugins(); //read again
1115
- if($ret && !empty($_POST['activate'])){
1116
  foreach($plugins as $id => $plugin){
1117
  if(dirname($id) == $data['basename']){
1118
- $plugin_version = $plugin['Version'];
1119
  $plugin_id = $id;
1120
  break;
1121
  }
1122
  }
1123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1124
  }
1125
 
1126
- }
1127
 
 
 
 
 
1128
  $response['version'] = isset($plugin_version) ? $plugin_version : 0;
1129
  $response['plugin_id'] = $plugin_id;
1130
  $response['nonce'] = wp_create_nonce('activate_' . $plugin_id);
1131
  $response['success'] = $ret;
 
1132
 
1133
  echo json_encode( $response );
1134
  exit;
1135
 
1136
  }
1137
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1138
  public function activate_plugin(){
1139
 
1140
  $error = '';
1141
 
1142
  if(isset($_POST['nonce']) && isset($_POST['plugin_id']) && $_POST['nonce'] == wp_create_nonce('activate_' . $_POST['plugin_id'])){
1143
-
1144
  $plugin_id = $_POST['plugin_id'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1145
  $return = activate_plugin($plugin_id);
1146
 
1147
  if(is_wp_error($return)){
@@ -1485,8 +1781,10 @@ final class WP_Installer{
1485
  if($match['dtp'] == '%'){
1486
  $fprice = round( $product['price'] * (1 - $match['amt']/100), 2 );
1487
  $fprice = $fprice != round($fprice) ? sprintf('%.2f', $fprice) : round($fprice, 0);
1488
- }elseif($match['dpt'] == '-'){
1489
  $fprice = $product['price'] - $match['amt'];
 
 
1490
  }
1491
 
1492
  if($fprice){
@@ -1502,7 +1800,7 @@ final class WP_Installer{
1502
  if($match['dtp'] == '%'){
1503
  $fprice = round( $upgrade['price'] * (1 - $match['amt']/100), 2 );
1504
  $fprice = $fprice != round($fprice) ? sprintf('%.2f', $fprice) : round($fprice, 0);
1505
- }elseif($match['dpt'] == '-'){
1506
  $fprice = $upgrade['price'] - $match['amt'];
1507
  }
1508
  if($fprice){
@@ -1575,6 +1873,41 @@ final class WP_Installer{
1575
 
1576
  }
1577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1578
  public function get_support_tag_by_name( $name, $repository ){
1579
 
1580
  if( is_array($this->settings['repositories'][$repository]['data']['support_tags'] )){
12
  protected $_plugins_renew_warnings = array();
13
 
14
  protected $_gz_on = false;
15
+
16
  public static function instance() {
17
 
18
  if ( is_null( self::$_instance ) ) {
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
 
93
  add_action('wp_ajax_remove_site_key', array($this, 'remove_site_key'));
94
  add_action('wp_ajax_update_site_key', array($this, 'update_site_key'));
95
 
96
+ add_action('wp_ajax_installer_download_plugin', array($this, 'download_plugin_ajax_handler'));
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(){
115
  global $pagenow;
116
+
117
  if(is_multisite() && !is_network_admin()){
118
  $this->menu_multisite_redirect();
119
  add_options_page(__('Installer', 'installer'), __('Installer', 'installer'), 'manage_options', 'installer', array($this, 'show_products')) ;
281
 
282
  $_settings = get_option( 'wp_installer_settings' );
283
 
284
+
285
  if( is_array( $_settings ) || empty( $_settings ) ){ //backward compatibility 1.1
286
  $settings = $_settings;
287
  return $settings;
304
  }
305
  }
306
 
307
+ /*
308
+ echo '<pre>';
309
+ print_r($settings);
310
+ echo '</pre>';
311
+ exit;
312
+ */
313
+
314
  return $settings;
315
  }
316
 
378
  }
379
 
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(){
486
  unset($this->settings['repositories'][$id]);
487
  }
488
  }
489
+
490
  $this->settings['last_repositories_update']= time();
491
 
492
  $this->save_settings();
512
 
513
  $this->localize_strings();
514
  $this->set_filtered_prices($args);
515
+ $this->filter_downloads_by_icl(); //downloads for ICL users
516
  $this->set_hierarchy_and_order();
517
+
518
  foreach($this->settings['repositories'] as $repository_id => $repository){
519
 
520
  if($args['template'] == 'compact'){
546
 
547
  }
548
 
549
+ public function get_product_price($repository_id, $package_id, $product_id, $incl_discount = false){
550
+
551
+ $price = false;
552
+
553
+ foreach($this->settings['repositories'][$repository_id]['data']['packages'] as $package ){
554
+
555
+ if($package['id'] == $package_id){
556
+ if(isset($package['products'][$product_id])){
557
+ if($incl_discount && isset($package['products'][$product_id]['price_disc'])){
558
+ $price = $package['products'][$product_id]['price_disc'];
559
+ }elseif(isset($package['products'][$product_id]['price'])){
560
+ $price = $package['products'][$product_id]['price'];
561
+ }
562
+ }
563
+ break;
564
+ }
565
+ }
566
+
567
+ return $price;
568
+ }
569
+
570
+ private function _render_product_packages($packages, $subscription_type, $expired, $upgrade_options, $repository_id){
571
 
572
  $data = array();
573
 
579
  // buy base
580
  if(empty($subscription_type) || $expired) {
581
 
582
+ $p['url'] = $this->append_parameters_to_buy_url($product['url'], $repository_id);
583
  if (!empty($product['price_disc'])) {
584
  $p['label'] = $product['call2action'] . ' - ' . sprintf('$%s %s$%d%s (USD)', $product['price_disc'], '&nbsp;&nbsp;<del>', $product['price'], '</del>');
585
  } else {
592
 
593
  if($product['renewals']) {
594
  foreach ($product['renewals'] as $renewal) {
595
+ $p['url'] = $this->append_parameters_to_buy_url($renewal['url'], $repository_id);
596
  $p['label'] = $renewal['call2action'] . ' - ' . sprintf('$%d (USD)', $renewal['price']);
597
  }
598
 
607
  foreach($upgrade_options[$product['subscription_type']] as $stype => $upgrade){
608
  if($stype != $subscription_type) continue;
609
 
610
+ $p['url'] = $this->append_parameters_to_buy_url($upgrade['url'], $repository_id);
611
  if (!empty($upgrade['price_disc'])) {
612
  $p['label'] = $upgrade['call2action'] . ' - ' . sprintf('$%s %s$%d%s (USD)', $upgrade['price_disc'], '&nbsp;&nbsp;<del>', $upgrade['price'], '</del>');
613
  } else {
631
 
632
  }
633
 
634
+ $row['id'] = $package['id'];
635
  $row['image_url'] = $package['image_url'];
636
  $row['name'] = $package['name'];
637
  $row['description'] = $package['description'];
647
 
648
  }
649
 
650
+ public function append_parameters_to_buy_url($url, $repository_id, $args = array()){
651
 
652
  $url = add_query_arg( array('icl_site_url' => $this->get_installer_site_url() ), $url );
653
 
654
  $affiliate_id = false;
655
  $affiliate_key = false;
656
 
657
+ if(isset($this->config['affiliate_id:' . $repository_id]) && isset($this->config['affiliate_key:' . $repository_id])){
658
 
659
+ $affiliate_id = $this->config['affiliate_id:' . $repository_id];
660
+ $affiliate_key = $this->config['affiliate_key:' . $repository_id];
661
 
662
+ }elseif(isset($args['affiliate_id:' . $repository_id]) && isset($args['affiliate_key:' . $repository_id])){
663
 
664
+ $affiliate_id = $args['affiliate_id:' . $repository_id];
665
+ $affiliate_key = $args['affiliate_key:' . $repository_id];
666
 
667
+ }elseif(defined('ICL_AFFILIATE_ID') && defined('ICL_AFFILIATE_KEY')){ //support for 1 repo
668
 
669
  $affiliate_id = ICL_AFFILIATE_ID;
670
  $affiliate_key = ICL_AFFILIATE_KEY;
671
 
672
+ }elseif(isset($this->config['affiliate_id']) && isset($this->config['affiliate_key'])) {
673
+ // BACKWARDS COMPATIBILITY
674
+ $affiliate_id = $this->config['affiliate_id'];
675
+ $affiliate_key = $this->config['affiliate_key'];
676
  }
677
+
678
  if($affiliate_id && $affiliate_key){
679
+ $url = add_query_arg(array('aid' => $affiliate_id, 'affiliate_key' => $affiliate_key), $url);
680
  }
681
 
682
  return $url;
697
 
698
  $subscription_data = $this->fetch_subscription_data($repository_id, $site_key);
699
 
700
+ if(is_wp_error($subscription_data)){
701
+ $error = $subscription_data->get_error_message();
702
+ if(preg_match('#Could not resolve host: (.*)#', $error, $matches)){
703
+ $error = sprintf(__("%s cannot access %s to register. Try again to see if it's a temporary problem. If the problem continues, make sure that this site has access to the Internet. You can still use the plugin without registration, but you will not receive automated updates.", 'installer'),
704
+ '<strong><i>' . $this->get_generic_product_name($repository_id) . '</i></strong>',
705
+ '<strong><i>' . $matches[1]. '</i></strong>'
706
+ ) ;
707
+ }
708
+
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
  }
716
 
717
  }
753
  }
754
 
755
  public function update_site_key(){
756
+
757
  $error = '';
758
 
759
  if($_POST['nonce'] == wp_create_nonce('update_site_key_' . $_POST['repository_id'])){
765
  $subscription_data = $this->fetch_subscription_data($repository_id, $site_key);
766
 
767
  if($subscription_data){
768
+ $this->settings['repositories'][$repository_id]['subscription'] = array('key' => $site_key, 'data' => $subscription_data);
769
+
770
+ //also refresh products information
771
+ $this->refresh_repositories_data();
772
+
773
  }else{
774
  unset($this->settings['repositories'][$repository_id]['subscription']);
775
  $error = __('Invalid site key for the current site.', 'installer');
804
 
805
  $subscription_data = false;
806
 
807
+ $args['body'] = array(
808
+ 'action' => 'site_key_validation',
809
+ 'site_key' => $site_key,
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']}");
832
  }else{
833
 
834
  $this->api_debug_log($response);
835
+ $subscription_data = $response;
836
  }
837
 
838
  return $subscription_data;
839
 
840
  }
841
 
842
+ public function get_repository_site_key($repository_id){
843
+ $site_key = false;
844
+
845
+ if(!empty($this->settings['repositories'][$repository_id]['subscription']['key'])){
846
+ $site_key = $this->settings['repositories'][$repository_id]['subscription']['key'];
847
+ }
848
+
849
+ return $site_key;
850
+ }
851
+
852
  public function repository_has_valid_subscription($repository_id){
853
 
854
  $valid = false;
879
 
880
  }
881
 
882
+ public function get_generic_product_name($repository_id){
883
+
884
+ return $this->settings['repositories'][$repository_id]['data']['product-name'];
885
+
886
+ }
887
+
888
  public function show_subscription_renew_warning($repository_id, $subscription_id){
889
 
890
  $show = false;
1085
  return $have;
1086
  }
1087
 
1088
+ public function is_product_available_for_download($product_name, $repository_id){
1089
+
1090
+ $available = false;
1091
+
1092
+ $subscription_type = $this->get_subscription_type_for_repository($repository_id);
1093
+ $expired = $this->repository_has_expired_subscription($repository_id);
1094
+
1095
+ if($this->repository_has_subscription($repository_id) && !$expired){
1096
+
1097
+ $this->set_hierarchy_and_order();
1098
+
1099
+ foreach($this->settings['repositories'][$repository_id]['data']['packages'] as $package_id => $package){
1100
+
1101
+ $has_top_package = false;
1102
+
1103
+ foreach($package['products'] as $product){
1104
+
1105
+ if($subscription_type == $product['subscription_type']){
1106
+ $has_top_package = true;
1107
+ if($product['name'] == $product_name){
1108
+ return $available = true;
1109
+ }
1110
+ }
1111
+
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
+ }
1120
+ }
1121
+ }
1122
+ }
1123
+
1124
+ }
1125
+ }
1126
+
1127
+ return $available;
1128
+
1129
+ }
1130
+
1131
  public function get_upgrade_options($repository_id){
1132
  $all_upgrades = array();
1133
 
1179
 
1180
  foreach($plugins as $plugin_id => $plugin){
1181
 
1182
+ // Exception: embedded plugins
1183
+ if(($plugin['Name'] == $name && dirname($plugin_id) == $folder) || ($plugin['Name'] == $name . ' Embedded' && dirname($plugin_id) == $folder . '-embedded') ){
1184
  if($version){
1185
  if(version_compare($plugin['Version'], $version, '>=')){
1186
  $is = $plugin['Version'];
1196
 
1197
  return $is;
1198
  }
1199
+
1200
+ public function plugin_is_embedded_version($name, $basename){
1201
+
1202
+ $is = false;
1203
+
1204
+ if($this->plugin_is_installed($name, $basename)){
1205
+ return false;
1206
+ }
1207
 
1208
+ $plugins = get_plugins();
 
1209
 
1210
+ foreach($plugins as $plugin_id => $plugin){
1211
+
1212
+ // TBD
1213
+ if( dirname($plugin_id) == $basename . '-embedded' && $plugin['Name'] == $name . ' Embedded'){
1214
+ $is = true;
1215
+ break;
1216
+ }
1217
+
1218
  }
1219
 
1220
+ return $is;
1221
+
1222
+ }
1223
+
1224
+ //Alias for plugin_is_installed
1225
+ public function get_plugin_installed_version($name, $plugin_basename){
1226
+
1227
+ return $this->plugin_is_installed($name, $plugin_basename);
1228
 
1229
+ }
1230
+
1231
+ public function get_plugin_repository_version($repository_id, $plugin_basename){
1232
+ $version = false;
1233
+
1234
+ if(!empty($this->settings['repositories'][$repository_id]['data']['packages'])){
1235
+ foreach($this->settings['repositories'][$repository_id]['data']['packages'] as $package){
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);
1243
+ }
1244
+
1245
+ }
1246
+
1247
+ }
1248
+ }
1249
+ }
1250
+
1251
+ return $version;
1252
+ }
1253
+
1254
+ public function is_uploading_allowed(){
1255
+
1256
+ if(!isset($this->uploading_allowed)){
1257
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1258
+ require_once WP_Installer()->plugin_path() . '/includes/installer-upgrader-skins.php';
1259
+
1260
  $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
1261
  $upgrader = new Plugin_Upgrader($upgrader_skins);
1262
+
1263
+ ob_start();
1264
+ $res = $upgrader->fs_connect( array(WP_CONTENT_DIR, WP_PLUGIN_DIR) );
1265
+ ob_end_clean();
1266
+
1267
+ if ( ! $res || is_wp_error( $res ) ) {
1268
+ $this->uploading_allowed = false;
1269
+ }else{
1270
+ $this->uploading_allowed = true;
 
 
1271
  }
1272
+ }
1273
+
1274
+
1275
+ return $this->uploading_allowed;
1276
+
1277
+ }
1278
+
1279
+ public function download_plugin_ajax_handler(){
1280
+
1281
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1282
+ require_once $this->plugin_path() . '/includes/installer-upgrader-skins.php';
1283
+
1284
+ if(isset($_POST['data'])){
1285
+
1286
+ $data = json_decode( base64_decode( $_POST['data'] ), true );
1287
 
1288
+ }
1289
+
1290
+ $ret = false;
1291
+ $plugin_id = false;
1292
+ $message = '';
1293
+
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'])){
 
 
1301
 
1302
+ $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
1303
+ $upgrader = new Plugin_Upgrader($upgrader_skins);
1304
+
1305
+ remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
1306
+
1307
+ $plugins = get_plugins();
1308
+
1309
+ //upgrade or install?
1310
  foreach($plugins as $id => $plugin){
1311
  if(dirname($id) == $data['basename']){
 
1312
  $plugin_id = $id;
1313
  break;
1314
  }
1315
  }
1316
 
1317
+ if($plugin_id){ //upgrade
1318
+ $response['upgrade'] = 1;
1319
+
1320
+ $plugin_is_active = is_plugin_active($plugin_id);
1321
+
1322
+ $ret = $upgrader->upgrade($plugin_id);
1323
+
1324
+ if(!$ret && !empty($upgrader->skin->installer_error)){
1325
+ if(is_wp_error($upgrader->skin->installer_error)){
1326
+ $message = $upgrader->skin->installer_error->get_error_message() .
1327
+ ' (' . $upgrader->skin->installer_error->get_error_data() . ')';
1328
+ }
1329
+ }
1330
+
1331
+ if($plugin_is_active){
1332
+ //prevent redirects
1333
+ add_filter('wp_redirect', '__return_false');
1334
+ activate_plugin($plugin_id);
1335
+ }
1336
+
1337
+ }else{ //install
1338
+
1339
+ $response['install'] = 1;
1340
+ $ret = $upgrader->install($data['url']);
1341
+ if(!$ret && !empty($upgrader->skin->installer_error)){
1342
+ if(is_wp_error($upgrader->skin->installer_error)){
1343
+ $message = $upgrader->skin->installer_error->get_error_message() .
1344
+ ' (' . $upgrader->skin->installer_error->get_error_data() . ')';
1345
+ }
1346
+ }
1347
+ }
1348
+
1349
+ $plugins = get_plugins(); //read again
1350
+ if($ret && !empty($_POST['activate'])){
1351
+ foreach($plugins as $id => $plugin){
1352
+ if(dirname($id) == $data['basename']){
1353
+ $plugin_version = $plugin['Version'];
1354
+ $plugin_id = $id;
1355
+ break;
1356
+ }
1357
+ }
1358
+
1359
+ }
1360
+
1361
  }
1362
 
1363
+ } else { //subscription not valid
1364
 
1365
+ $ret = false;
1366
+ $message = __('Your subscription appears to no longer be valid. Please try to register again using a valid site key.', 'installer');
1367
+ }
1368
+
1369
  $response['version'] = isset($plugin_version) ? $plugin_version : 0;
1370
  $response['plugin_id'] = $plugin_id;
1371
  $response['nonce'] = wp_create_nonce('activate_' . $plugin_id);
1372
  $response['success'] = $ret;
1373
+ $response['message'] = $message;
1374
 
1375
  echo json_encode( $response );
1376
  exit;
1377
 
1378
  }
1379
+
1380
+ public function download_plugin($basename, $url){
1381
+
1382
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
1383
+ require_once $this->plugin_path() . '/includes/installer-upgrader-skins.php';
1384
+
1385
+ $upgrader_skins = new Installer_Upgrader_Skins(); //use our custom (mute) Skin
1386
+ $upgrader = new Plugin_Upgrader($upgrader_skins);
1387
+
1388
+ remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
1389
+
1390
+ $plugins = get_plugins();
1391
+
1392
+ $plugin_id = false;
1393
+
1394
+ //upgrade or install?
1395
+ foreach($plugins as $id => $plugin){
1396
+ if(dirname($id) == $basename){
1397
+ $plugin_id = $id;
1398
+ break;
1399
+ }
1400
+ }
1401
+
1402
+ if($plugin_id){ //upgrade
1403
+
1404
+ $plugin_is_active = is_plugin_active($plugin_id);
1405
+
1406
+ $ret = $upgrader->upgrade($plugin_id);
1407
+
1408
+ if($plugin_is_active){
1409
+ activate_plugin($plugin_id);
1410
+ }
1411
+
1412
+ }else{ //install
1413
+ $ret = $upgrader->install($url);
1414
+ }
1415
+
1416
+ return $ret;
1417
+
1418
+ }
1419
+
1420
  public function activate_plugin(){
1421
 
1422
  $error = '';
1423
 
1424
  if(isset($_POST['nonce']) && isset($_POST['plugin_id']) && $_POST['nonce'] == wp_create_nonce('activate_' . $_POST['plugin_id'])){
1425
+
1426
  $plugin_id = $_POST['plugin_id'];
1427
+
1428
+ // Deactivate any embedded version
1429
+ $plugin_folder = dirname($plugin_id);
1430
+ $active_plugins = get_option('active_plugins');
1431
+ foreach($active_plugins as $plugin){
1432
+ if(dirname($plugin) == $plugin_folder . '-embedded'){
1433
+ deactivate_plugins(array($plugin));
1434
+ break;
1435
+ }
1436
+ }
1437
+
1438
+ //prevent redirects
1439
+ add_filter('wp_redirect', '__return_false', 10000);
1440
+
1441
  $return = activate_plugin($plugin_id);
1442
 
1443
  if(is_wp_error($return)){
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);
1784
+ }elseif($match['dtp'] == '-'){
1785
  $fprice = $product['price'] - $match['amt'];
1786
+ }else{
1787
+ $fprice = $product['price'];
1788
  }
1789
 
1790
  if($fprice){
1800
  if($match['dtp'] == '%'){
1801
  $fprice = round( $upgrade['price'] * (1 - $match['amt']/100), 2 );
1802
  $fprice = $fprice != round($fprice) ? sprintf('%.2f', $fprice) : round($fprice, 0);
1803
+ }elseif($match['dtp'] == '-'){
1804
  $fprice = $upgrade['price'] - $match['amt'];
1805
  }
1806
  if($fprice){
1873
 
1874
  }
1875
 
1876
+ public function filter_downloads_by_icl(){
1877
+ if(function_exists('wpml_site_uses_icl') && wpml_site_uses_icl()){
1878
+
1879
+ if(!empty($this->settings['repositories'])) {
1880
+ foreach ($this->settings['repositories'] as $repository_id => $repository) {
1881
+
1882
+ if (empty($repository['data']['packages'])) continue;
1883
+
1884
+ foreach ($repository['data']['packages'] as $package_id => $package) {
1885
+ foreach($package['products'] as $product_id => $product){
1886
+
1887
+ foreach($product['downloads'] as $download_id => $download){
1888
+ $this->settings['repositories'][$repository_id]['data']['packages'][$package_id]['products'][$product_id]['downloads'][$download_id]['changelog'] = '';
1889
+ $this->settings['repositories'][$repository_id]['data']['packages'][$package_id]['products'][$product_id]['downloads'][$download_id]['description'] = '';
1890
+
1891
+ if(isset($download['version-for-icl']) && isset($download['url-for-icl'])){
1892
+ $download['version'] = $download['version-for-icl'];
1893
+ $download['url'] = $download['url-for-icl'];
1894
+ unset($download['version-for-icl']);
1895
+ unset($download['url-for-icl']);
1896
+ $this->settings['repositories'][$repository_id]['data']['packages'][$package_id]['products'][$product_id]['downloads'][$download_id] = $download;
1897
+
1898
+ }
1899
+
1900
+ }
1901
+ }
1902
+
1903
+ }
1904
+
1905
+ }
1906
+ }
1907
+
1908
+ }
1909
+ }
1910
+
1911
  public function get_support_tag_by_name( $name, $repository ){
1912
 
1913
  if( is_array($this->settings['repositories'][$repository]['data']['support_tags'] )){
{embedded/common → plus}/installer/installer.php RENAMED
@@ -1,7 +1,8 @@
1
  <?php
2
- define('WP_INSTALLER_VERSION', '1.3');
3
 
4
  include_once dirname(__FILE__) . '/includes/installer.class.php';
 
5
 
6
  function WP_Installer() {
7
  return WP_Installer::instance();
@@ -10,6 +11,7 @@ function WP_Installer() {
10
 
11
  WP_Installer();
12
 
 
13
 
14
  // Ext function
15
  function WP_Installer_Show_Products($args = array()){
1
  <?php
2
+ define('WP_INSTALLER_VERSION', '1.5.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();
11
 
12
  WP_Installer();
13
 
14
+ include_once dirname(__FILE__) . '/includes/installer-api.php';
15
 
16
  // Ext function
17
  function WP_Installer_Show_Products($args = array()){
{embedded/common → plus}/installer/loader.php RENAMED
@@ -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.3
7
  Author: OnTheGoSystems Inc.
8
  Author URI: http://www.onthegosystems.com/
9
  */
@@ -17,9 +17,10 @@ if ( ! defined( 'ABSPATH' ) ) {
17
  $wp_installer_instance = dirname(__FILE__) . '/installer.php';
18
 
19
  // Global stack of instances
 
20
  $wp_installer_instances[$wp_installer_instance] = array(
21
  'bootfile' => $wp_installer_instance,
22
- 'version' => 1.3
23
  );
24
 
25
  // Only one of these in the end
@@ -32,17 +33,17 @@ if(!function_exists('wpml_installer_instance_delegator')){
32
  global $wp_installer_instances;
33
 
34
  foreach($wp_installer_instances as $instance){
35
-
36
  if(!isset($delegate)){
37
  $delegate = $instance;
38
  continue;
39
  }
40
 
41
- if(version_compare($instance['version'], $delegate['version'], '>')){
42
  $delegate = $instance;
43
  }
44
  }
45
-
46
  include_once $delegate['bootfile'];
47
 
48
  // set configuration
@@ -70,9 +71,7 @@ if(!function_exists('WP_Installer_Setup')){
70
  function WP_Installer_Setup($wp_installer_instance, $args = array()){
71
  global $wp_installer_instances;
72
 
73
- //if(isset($wp_installer_instances[$wp_installer_instance])){
74
- $wp_installer_instances[$wp_installer_instance]['args'] = $args;
75
- //}
76
 
77
  }
78
 
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
7
  Author: OnTheGoSystems Inc.
8
  Author URI: http://www.onthegosystems.com/
9
  */
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'
24
  );
25
 
26
  // Only one of these in the end
33
  global $wp_installer_instances;
34
 
35
  foreach($wp_installer_instances as $instance){
36
+
37
  if(!isset($delegate)){
38
  $delegate = $instance;
39
  continue;
40
  }
41
 
42
+ if(version_compare($instance['version'], $delegate['version'], '>') || !empty($instance['args']['high_priority'])){
43
  $delegate = $instance;
44
  }
45
  }
46
+
47
  include_once $delegate['bootfile'];
48
 
49
  // set configuration
71
  function WP_Installer_Setup($wp_installer_instance, $args = array()){
72
  global $wp_installer_instances;
73
 
74
+ $wp_installer_instances[$wp_installer_instance]['args'] = $args;
 
 
75
 
76
  }
77
 
{embedded/common → plus}/installer/repositories.xml RENAMED
File without changes
{embedded/common → plus}/installer/res/css/admin.css RENAMED
@@ -56,6 +56,15 @@
56
  padding: 5px;
57
  }
58
 
 
 
 
 
 
 
 
 
 
59
  .spinner-inline{
60
  float: none;
61
  display: inline-block;
@@ -127,4 +136,8 @@
127
 
128
  .installer_highlight{
129
  color:#c5510b;
 
 
 
 
130
  }
56
  padding: 5px;
57
  }
58
 
59
+ .installer-error-box p{
60
+ margin: 10px 0 10px 0;
61
+ -webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;border:1px solid #962722;background-color:#F5C8C6;
62
+ color: #333;
63
+ padding: 5px;
64
+ text-align: center;
65
+ }
66
+
67
+
68
  .spinner-inline{
69
  float: none;
70
  display: inline-block;
136
 
137
  .installer_highlight{
138
  color:#c5510b;
139
+ }
140
+
141
+ .installer_highlight_package{
142
+ background-color: #fff9c0;
143
  }
{embedded/common → plus}/installer/res/img/complete.png RENAMED
File without changes
{embedded/common → plus}/installer/res/img/computer.png RENAMED
File without changes
{embedded/common → plus}/installer/res/img/dn.gif RENAMED
File without changes
{embedded/common → plus}/installer/res/img/dn2.gif RENAMED
File without changes
{embedded/common → plus}/installer/res/img/globe.png RENAMED
File without changes
{embedded/common → plus}/installer/res/img/icon_error.gif RENAMED
File without changes
{embedded/common → plus}/installer/res/img/on.png RENAMED
File without changes
{embedded/common → plus}/installer/res/js/admin.js RENAMED
@@ -16,10 +16,21 @@
16
 
17
  jQuery('.otgs_wp_installer_table').on('click', '.installer_expand_button', otgs_wp_installer.toggle_subpackages);
18
 
 
 
 
 
 
 
19
  },
20
 
 
 
 
21
 
22
  show_site_key_form: function(){
 
 
23
  var form = jQuery(this).parent().find('form.otgsi_site_key_form');
24
  jQuery(this).prev().hide();
25
  jQuery(this).hide();
@@ -51,12 +62,14 @@
51
  var spinner = jQuery('<span class="spinner"></span>');
52
  spinner.css({display: 'inline-block', float: 'none'}).prependTo(jQuery(this));
53
 
 
 
54
  jQuery.ajax({url: ajaxurl, type: 'POST', dataType:'json', data: data, success:
55
  function(ret){
56
  if(!ret.error){
57
- otgs_wp_installer.saved_site_key();
58
  }else{
59
- alert(ret.error);
60
  thisf.find('input').removeAttr('disabled');
61
  }
62
 
@@ -85,6 +98,7 @@
85
  jQuery.ajax({url: ajaxurl, type: 'POST', data: data, success: otgs_wp_installer.removed_site_key});
86
  }
87
 
 
88
  },
89
 
90
  removed_site_key: function(){
@@ -109,6 +123,8 @@
109
  otgs_wp_installer.updated_site_key(ret);
110
  }
111
  });
 
 
112
 
113
  },
114
 
@@ -175,6 +191,8 @@
175
  var spinner = this_tr.find('.installer-status-downloading');
176
  }
177
 
 
 
178
  spinner.show();
179
 
180
  installing.show();
@@ -193,11 +211,17 @@
193
  installed.addClass('installer-status-error');
194
  installed.html(installed.data('fail'));
195
 
196
- var revalidate_message = downloads_form.find('.installer-revalidate-message').html();
197
- if(confirm(revalidate_message)){
198
- downloads_form.closest('.otgs_wp_installer_table').find('.update_site_key_js').click();
 
 
 
 
 
199
  }
200
 
 
201
  }
202
 
203
  installed.show();
@@ -278,7 +302,42 @@
278
 
279
  return false;
280
 
281
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
 
283
 
284
  }
16
 
17
  jQuery('.otgs_wp_installer_table').on('click', '.installer_expand_button', otgs_wp_installer.toggle_subpackages);
18
 
19
+ otgs_wp_installer.scroll_to_repository();
20
+
21
+ },
22
+
23
+ reset_errors: function(){
24
+ jQuery('.installer-error-box').html('').hide();
25
  },
26
 
27
+ show_error: function(repo, text){
28
+ jQuery('#installer_repo_' + repo).find('.installer-error-box').html(text).show();
29
+ },
30
 
31
  show_site_key_form: function(){
32
+ otgs_wp_installer.reset_errors();
33
+
34
  var form = jQuery(this).parent().find('form.otgsi_site_key_form');
35
  jQuery(this).prev().hide();
36
  jQuery(this).hide();
62
  var spinner = jQuery('<span class="spinner"></span>');
63
  spinner.css({display: 'inline-block', float: 'none'}).prependTo(jQuery(this));
64
 
65
+ otgs_wp_installer.reset_errors();
66
+
67
  jQuery.ajax({url: ajaxurl, type: 'POST', dataType:'json', data: data, success:
68
  function(ret){
69
  if(!ret.error){
70
+ otgs_wp_installer.saved_site_key();
71
  }else{
72
+ otgs_wp_installer.show_error(thisf.find('[name=repository_id]').val(), ret.error);
73
  thisf.find('input').removeAttr('disabled');
74
  }
75
 
98
  jQuery.ajax({url: ajaxurl, type: 'POST', data: data, success: otgs_wp_installer.removed_site_key});
99
  }
100
 
101
+ return false;
102
  },
103
 
104
  removed_site_key: function(){
123
  otgs_wp_installer.updated_site_key(ret);
124
  }
125
  });
126
+
127
+ return false;
128
 
129
  },
130
 
191
  var spinner = this_tr.find('.installer-status-downloading');
192
  }
193
 
194
+ otgs_wp_installer.reset_errors();
195
+
196
  spinner.show();
197
 
198
  installing.show();
211
  installed.addClass('installer-status-error');
212
  installed.html(installed.data('fail'));
213
 
214
+ if(ret.message){
215
+
216
+ installed.closest('.otgs_wp_installer_table').find('.installer-error-box').html('<p>' + ret.message + '</p>').show();
217
+
218
+ }else{
219
+
220
+ installed.closest('.otgs_wp_installer_table').find('.installer-error-box').html('<p>' + downloads_form.find('.installer-revalidate-message').html() + '</p>').show();
221
+
222
  }
223
 
224
+
225
  }
226
 
227
  installed.show();
302
 
303
  return false;
304
 
305
+ },
306
+
307
+ scroll_to_repository: function(){
308
+
309
+ var ref = window.location.hash.replace('#', '');
310
+
311
+ if(ref) {
312
+ var split = ref.split('/');
313
+ var repo = split[0];
314
+
315
+ if(typeof split[1] != 'undefiend'){
316
+ var package = split[1];
317
+ var repo_element = jQuery('#repository-' + repo);
318
+
319
+
320
+
321
+ if(repo_element.length){
322
+
323
+ jQuery('html, body').animate({
324
+ scrollTop: repo_element.offset().top
325
+ }, 1000);
326
+
327
+ var package_element = jQuery('#repository-' + repo +'_' + package);
328
+
329
+ if(package_element.length && !package_element.is(':visible')){
330
+ package_element.parents('.otgs_wp_installer_subtable').slideDown();
331
+ package_element.addClass('installer_highlight_package');
332
+ }
333
+
334
+ package_element.find('.button-secondary').removeClass('button-secondary').addClass('button-primary');
335
+ }
336
+ }
337
+
338
+ }
339
+
340
+ }
341
 
342
 
343
  }
{embedded/common → plus}/installer/res/js/iframeResizer.min.js RENAMED
File without changes
{embedded/common → plus}/installer/templates/downloads-list-compact.php RENAMED
@@ -20,10 +20,23 @@
20
  <label>
21
  <?php
22
  $url = $this->append_site_key_to_download_url($download['url'], $site_key, $repository_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ?>
24
- <input type="checkbox" name="downloads[]" value="<?php echo base64_encode(json_encode(array('url' => $url,
25
- 'basename' => $download['basename'], 'nonce' => wp_create_nonce('install_plugin_' . $url)))); ?>" <?php
26
- if($expired || $this->plugin_is_installed($download['name'], $download['basename'], $download['version'])): ?>disabled="disabled"<?php endif; ?> />&nbsp;
27
 
28
  </label>
29
  </td>
@@ -46,7 +59,11 @@
46
  <?php endforeach; ?>
47
  </tbody>
48
  </table>
49
-
 
 
 
 
50
  <br />
51
  <input type="submit" class="button-secondary" value="<?php esc_attr_e('Download', 'installer') ?>" disabled="disabled" />
52
  &nbsp;
20
  <label>
21
  <?php
22
  $url = $this->append_site_key_to_download_url($download['url'], $site_key, $repository_id );
23
+ $download_data = array(
24
+ 'url' => $url,
25
+ 'basename' => $download['basename'],
26
+ 'nonce' => wp_create_nonce('install_plugin_' . $url),
27
+ 'repository_id' => $repository_id
28
+ );
29
+
30
+ $disabled = $expired ||
31
+ (
32
+ $this->plugin_is_installed($download['name'], $download['basename'], $download['version']) &&
33
+ !$this->plugin_is_embedded_version($download['name'], $download['basename'])
34
+ )||
35
+ !WP_Installer()->is_uploading_allowed();
36
+
37
  ?>
38
+ <input type="checkbox" name="downloads[]" value="<?php echo base64_encode(json_encode($download_data)); ?>" <?php
39
+ if($disabled): ?>disabled="disabled"<?php endif; ?> />&nbsp;
 
40
 
41
  </label>
42
  </td>
59
  <?php endforeach; ?>
60
  </tbody>
61
  </table>
62
+
63
+ <?php if(!WP_Installer()->is_uploading_allowed()): ?>
64
+ <p class="installer-error-box"><?php printf(__('Downloading is not possible because WordPress cannot write into the plugins folder. %sHow to fix%s.', 'installer'), '<a href="http://codex.wordpress.org/Changing_File_Permissions">', '</a>') ?></p>
65
+ <?php endif;?>
66
+
67
  <br />
68
  <input type="submit" class="button-secondary" value="<?php esc_attr_e('Download', 'installer') ?>" disabled="disabled" />
69
  &nbsp;
{embedded/common → plus}/installer/templates/downloads-list.php RENAMED
@@ -17,16 +17,22 @@
17
  </tr>
18
  </thead>
19
  <tbody>
20
- <?php foreach($package['downloads'] as $download): ?>
 
21
  <tr>
22
  <td>
23
  <label>
24
  <?php
25
  $url = $this->append_site_key_to_download_url($download['url'], $site_key, $repository_id);
 
 
 
 
 
 
26
  ?>
27
- <input type="checkbox" name="downloads[]" value="<?php echo base64_encode(json_encode(array('url' => $url,
28
- 'basename' => $download['basename'], 'nonce' => wp_create_nonce('install_plugin_' . $url)))); ?>" <?php
29
- if($this->plugin_is_installed($download['name'], $download['basename'], $download['version'])): ?>disabled="disabled"<?php endif; ?> />&nbsp;
30
 
31
  </label>
32
  </td>
@@ -36,6 +42,7 @@
36
  <td>
37
  <?php if($v = $this->plugin_is_installed($download['name'], $download['basename'])): $class = version_compare($v, $download['version'], '>=') ? 'installer-green-text' : 'installer-red-text'; ?>
38
  <span class="<?php echo $class ?>"><?php echo $v; ?></span>
 
39
  <?php endif; ?>
40
  </td>
41
  <td>
@@ -53,13 +60,22 @@
53
  <?php endforeach; ?>
54
  </tbody>
55
  </table>
56
-
57
  <br />
 
 
 
 
 
 
 
 
 
58
  <input type="submit" class="button-secondary" value="<?php esc_attr_e('Download', 'installer') ?>" disabled="disabled" />
59
  &nbsp;
60
  <label><input name="activate" type="checkbox" value="1" disabled="disabled" />&nbsp;<?php _e('Activate after download', 'installer') ?></label>
61
 
62
  <div class="installer-status-success"><p><?php _e('Operation complete!', 'installer') ?></p></div>
63
 
64
- <span class="installer-revalidate-message hidden"><?php _e("Download failed!\n\nClick OK to revalidate your subscription or CANCEL to try again.", 'installer') ?></span>
65
  </form>
17
  </tr>
18
  </thead>
19
  <tbody>
20
+ <?php
21
+ foreach($package['downloads'] as $download): ?>
22
  <tr>
23
  <td>
24
  <label>
25
  <?php
26
  $url = $this->append_site_key_to_download_url($download['url'], $site_key, $repository_id);
27
+ $download_data = array(
28
+ 'url' => $url,
29
+ 'basename' => $download['basename'],
30
+ 'nonce' => wp_create_nonce('install_plugin_' . $url),
31
+ 'repository_id' => $repository_id
32
+ );
33
  ?>
34
+ <input type="checkbox" name="downloads[]" value="<?php echo base64_encode(json_encode($download_data)); ?>" <?php
35
+ if($this->plugin_is_installed($download['name'], $download['basename'], $download['version']) && !$this->plugin_is_embedded_version($download['name'], $download['basename']) || !WP_Installer()->is_uploading_allowed()): ?>disabled="disabled"<?php endif; ?> />&nbsp;
 
36
 
37
  </label>
38
  </td>
42
  <td>
43
  <?php if($v = $this->plugin_is_installed($download['name'], $download['basename'])): $class = version_compare($v, $download['version'], '>=') ? 'installer-green-text' : 'installer-red-text'; ?>
44
  <span class="<?php echo $class ?>"><?php echo $v; ?></span>
45
+ <?php if($this->plugin_is_embedded_version($download['name'], $download['basename'])): ?>&nbsp;<?php _e('(embedded)', 'installer'); ?><?php endif; ?>
46
  <?php endif; ?>
47
  </td>
48
  <td>
60
  <?php endforeach; ?>
61
  </tbody>
62
  </table>
63
+
64
  <br />
65
+
66
+ <div class="installer-error-box">
67
+ <?php if(!WP_Installer()->is_uploading_allowed()): ?>
68
+ <p>
69
+ <?php printf(__('Downloading is not possible because WordPress cannot write into the plugins folder. %sHow to fix%s.', 'installer'), '<a href="http://codex.wordpress.org/Changing_File_Permissions">', '</a>') ?>
70
+ </p>
71
+ <?php endif;?>
72
+ </div>
73
+
74
  <input type="submit" class="button-secondary" value="<?php esc_attr_e('Download', 'installer') ?>" disabled="disabled" />
75
  &nbsp;
76
  <label><input name="activate" type="checkbox" value="1" disabled="disabled" />&nbsp;<?php _e('Activate after download', 'installer') ?></label>
77
 
78
  <div class="installer-status-success"><p><?php _e('Operation complete!', 'installer') ?></p></div>
79
 
80
+ <span class="installer-revalidate-message hidden"><?php _e("Download failed!\n\nPlease refresh the page and try again.", 'installer') ?></span>
81
  </form>
{embedded/common → plus}/installer/templates/products-compact.php RENAMED
@@ -62,7 +62,7 @@ if(!isset($args['product_name'])) $args['product_name'] = $product['name'];
62
  <br />
63
  <?php endif; ?>
64
 
65
- <a class="button-primary" href="<?php echo $this->append_parameters_to_buy_url($product['url'], $args) ?>"><?php printf(__('Buy %s', 'installer'), $args['product_name']) ?></a>
66
 
67
  <div>
68
  <br />
@@ -76,6 +76,7 @@ if(!isset($args['product_name'])) $args['product_name'] = $product['name'];
76
  <input type="text" size="10" name="site_key_<?php echo $repository_id ?>" />
77
  <input class="button-secondary" type="submit" value="<?php esc_attr_e('Add', 'installer') ?>" />
78
  </form>
 
79
  </div>
80
 
81
  <?php else: ?>
@@ -91,7 +92,7 @@ if(!isset($args['product_name'])) $args['product_name'] = $product['name'];
91
  <ul class="installer-products-list">
92
  <?php foreach($product['renewals'] as $renewal): ?>
93
  <li>
94
- <a href="<?php echo $this->append_parameters_to_buy_url($renewal['url'], $args) ?>"><?php printf(__('Renew %s', 'installer'), $args['product_name']) ?></a>
95
  </li>
96
  <?php endforeach; ?>
97
  </ul>
62
  <br />
63
  <?php endif; ?>
64
 
65
+ <a class="button-primary" href="<?php echo $this->append_parameters_to_buy_url($product['url'], $repository_id, $args) ?>"><?php printf(__('Buy %s', 'installer'), $args['product_name']) ?></a>
66
 
67
  <div>
68
  <br />
76
  <input type="text" size="10" name="site_key_<?php echo $repository_id ?>" />
77
  <input class="button-secondary" type="submit" value="<?php esc_attr_e('Add', 'installer') ?>" />
78
  </form>
79
+ <div class="installer-error-box hidden" style="margin-top:10px;"></div>
80
  </div>
81
 
82
  <?php else: ?>
92
  <ul class="installer-products-list">
93
  <?php foreach($product['renewals'] as $renewal): ?>
94
  <li>
95
+ <a href="<?php echo $this->append_parameters_to_buy_url($renewal['url'], $repository_id, $args) ?>"><?php printf(__('Renew %s', 'installer'), $args['product_name']) ?></a>
96
  </li>
97
  <?php endforeach; ?>
98
  </ul>
{embedded/common → plus}/installer/templates/repository-listing.php RENAMED
@@ -2,18 +2,11 @@
2
  <p class="alignright installer_highlight"><strong><?php printf('Price offers available until %s', date_i18n(get_option( 'date_format' ), $match['exp'])) ?></strong></p>
3
  <?php endif; ?>
4
 
5
- <h3><?php echo $repository['data']['name'] ?></h3>
6
-
7
  <?php
8
  $generic_product_name = $this->settings['repositories'][$repository_id]['data']['product-name'];
9
-
10
-
11
-
12
-
13
-
14
  ?>
15
-
16
- <table class="widefat otgs_wp_installer_table">
17
 
18
  <tr>
19
  <td>&nbsp;</td>
@@ -36,7 +29,12 @@
36
  <div class="alignleft" style="margin-top:6px;"><?php printf(__('1. Go to your %s%s account%s and add this site URL: %s', 'installer'),
37
  '<a href="' . $this->settings['repositories'][$repository_id]['data']['site_keys_management_url'] . '?add='.urlencode($this->get_installer_site_url()).'">',
38
  $generic_product_name, '</a>', $this->get_installer_site_url()); ?></div>
 
 
 
39
  </form>
 
 
40
  </div>
41
 
42
  <?php
@@ -61,7 +59,7 @@
61
 
62
  <div class="alignright">
63
  <a class="remove_site_key_js button-secondary" href="#" data-repository=<?php echo $repository_id ?> data-confirmation="<?php esc_attr_e('Are you sure you want to unregister?', 'installer') ?>" data-nonce="<?php echo wp_create_nonce('remove_site_key_' . $repository_id) ?>"><?php printf(__("Unregister %s from this site", 'installer'), $generic_product_name) ?></a>&nbsp;
64
- <a class="update_site_key_js button-secondary" href="#" data-repository=<?php echo $repository_id ?> data-nonce="<?php echo wp_create_nonce('update_site_key_' . $repository_id) ?>"><?php _e('Update this info', 'installer') ?></a>
65
  </div>
66
 
67
  <?php if(empty($expired)): ?>
@@ -84,16 +82,17 @@
84
  $subscription_type = isset($subscription_type) ? $subscription_type : null;
85
  $expired = isset($expired) ? $expired : null;
86
  $upgrade_options = isset($upgrade_options) ? $upgrade_options : null;
87
- $packages = $this->_render_product_packages($repository['data']['packages'], $subscription_type, $expired, $upgrade_options);
88
  if(empty($subscription_type) || $expired){
89
  $subpackages_expandable = true;
90
  }else{
91
  $subpackages_expandable = false;
92
  }
 
93
  ?>
94
 
95
  <?php foreach($packages as $package): ?>
96
- <tr>
97
  <td><img width="140" height="140" src="<?php echo $package['image_url'] ?>" /></td>
98
  <td>
99
  <p><strong><?php echo $package['name'] ?></strong></p>
@@ -115,7 +114,7 @@
115
 
116
  <?php if(!empty($package['sub-packages'])): ?>
117
 
118
- <?php $subpackages = $this->_render_product_packages($package['sub-packages'], $subscription_type, $expired, $upgrade_options); ?>
119
 
120
  <?php if($subpackages): ?>
121
 
@@ -125,7 +124,7 @@
125
 
126
  <table class="otgs_wp_installer_subtable" style="<?php if($subpackages_expandable) echo 'display:none' ?>">
127
  <?php foreach($subpackages as $package): ?>
128
- <tr>
129
  <td><img width="70" height="70" src="<?php echo $package['image_url'] ?>" /></td>
130
  <td>
131
  <p><strong><?php echo $package['name'] ?></strong></p>
2
  <p class="alignright installer_highlight"><strong><?php printf('Price offers available until %s', date_i18n(get_option( 'date_format' ), $match['exp'])) ?></strong></p>
3
  <?php endif; ?>
4
 
5
+ <h3 id="repository-<?php echo $repository_id ?>"><?php echo $repository['data']['name'] ?></h3>
 
6
  <?php
7
  $generic_product_name = $this->settings['repositories'][$repository_id]['data']['product-name'];
 
 
 
 
 
8
  ?>
9
+ <table class="widefat otgs_wp_installer_table" id="installer_repo_<?php echo $repository_id ?>">
 
10
 
11
  <tr>
12
  <td>&nbsp;</td>
29
  <div class="alignleft" style="margin-top:6px;"><?php printf(__('1. Go to your %s%s account%s and add this site URL: %s', 'installer'),
30
  '<a href="' . $this->settings['repositories'][$repository_id]['data']['site_keys_management_url'] . '?add='.urlencode($this->get_installer_site_url()).'">',
31
  $generic_product_name, '</a>', $this->get_installer_site_url()); ?></div>
32
+
33
+ <div class="installer-error-box hidden" style="margin-top:10px;"></div>
34
+
35
  </form>
36
+
37
+
38
  </div>
39
 
40
  <?php
59
 
60
  <div class="alignright">
61
  <a class="remove_site_key_js button-secondary" href="#" data-repository=<?php echo $repository_id ?> data-confirmation="<?php esc_attr_e('Are you sure you want to unregister?', 'installer') ?>" data-nonce="<?php echo wp_create_nonce('remove_site_key_' . $repository_id) ?>"><?php printf(__("Unregister %s from this site", 'installer'), $generic_product_name) ?></a>&nbsp;
62
+ <a class="update_site_key_js button-secondary" href="#" data-repository=<?php echo $repository_id ?> data-nonce="<?php echo wp_create_nonce('update_site_key_' . $repository_id) ?>"><?php _e('Check for updates', 'installer') ?></a>
63
  </div>
64
 
65
  <?php if(empty($expired)): ?>
82
  $subscription_type = isset($subscription_type) ? $subscription_type : null;
83
  $expired = isset($expired) ? $expired : null;
84
  $upgrade_options = isset($upgrade_options) ? $upgrade_options : null;
85
+ $packages = $this->_render_product_packages($repository['data']['packages'], $subscription_type, $expired, $upgrade_options, $repository_id);
86
  if(empty($subscription_type) || $expired){
87
  $subpackages_expandable = true;
88
  }else{
89
  $subpackages_expandable = false;
90
  }
91
+
92
  ?>
93
 
94
  <?php foreach($packages as $package): ?>
95
+ <tr id="repository-<?php echo $repository_id ?>_<?php echo $package['id'] ?>">
96
  <td><img width="140" height="140" src="<?php echo $package['image_url'] ?>" /></td>
97
  <td>
98
  <p><strong><?php echo $package['name'] ?></strong></p>
114
 
115
  <?php if(!empty($package['sub-packages'])): ?>
116
 
117
+ <?php $subpackages = $this->_render_product_packages($package['sub-packages'], $subscription_type, $expired, $upgrade_options, $repository_id); ?>
118
 
119
  <?php if($subpackages): ?>
120
 
124
 
125
  <table class="otgs_wp_installer_subtable" style="<?php if($subpackages_expandable) echo 'display:none' ?>">
126
  <?php foreach($subpackages as $package): ?>
127
+ <tr id="repository-<?php echo $repository_id ?>_<?php echo $package['id'] ?>">
128
  <td><img width="70" height="70" src="<?php echo $package['image_url'] ?>" /></td>
129
  <td>
130
  <p><strong><?php echo $package['name'] ?></strong></p>
plus/types-access.php CHANGED
@@ -1,12 +1,19 @@
1
  <?php
2
  /*
3
  * Types Access teaser.
 
 
 
 
 
 
4
  */
5
 
6
  add_action( 'plugins_loaded', 'wpcf_access_teaser_init', 15 );
 
7
 
8
  /**
9
- * Teaser init.
10
  */
11
  function wpcf_access_teaser_init() {
12
  global $pagenow;
@@ -22,7 +29,6 @@ function wpcf_access_teaser_init() {
22
  define( 'WPCF_ACCESS_RELPATH',
23
  plugins_url() . '/' . basename( WPCF_ABSPATH ) . '/plus/types-access' );
24
  define( 'WPCF_ACCESS_INC', WPCF_ACCESS_ABSPATH . '/includes' );
25
- add_action( 'wpcf_menu_plus', 'wpcf_access_teaser_admin_menu' );
26
  $locale = get_locale();
27
  load_textdomain( 'wpcf_access',
28
  WPCF_ACCESS_ABSPATH . '/locale/types-access-' . $locale . '.mo' );
@@ -30,18 +36,22 @@ function wpcf_access_teaser_init() {
30
  }
31
 
32
  /**
33
- * Teaser menu hook.
34
  */
35
  function wpcf_access_teaser_admin_menu() {
36
- $hook = add_submenu_page( 'wpcf',
37
- __( 'Access Control and User Roles', 'wpcf' ),
38
- __( 'Access Control and User Roles', 'wpcf' ), 'manage_options',
39
- 'wpcf-access', 'wpcf_access_teaser_admin_menu_page' );
40
- add_action( 'load-' . $hook, 'wpcf_access_teaser_admin_menu_load' );
 
 
 
 
41
  }
42
 
43
  /**
44
- * Teaser menu load.
45
  */
46
  function wpcf_access_teaser_admin_menu_load() {
47
  require_once WPCF_ACCESS_ABSPATH . '/embedded.php';
@@ -56,9 +66,20 @@ function wpcf_access_teaser_admin_menu_load() {
56
  }
57
 
58
  /**
59
- * Teaser admin screen.
60
  */
61
- function wpcf_access_teaser_admin_menu_page() {
 
 
 
 
 
 
 
 
 
 
 
62
  echo wpcf_add_admin_header( __( 'Access', 'wpcf' ), 'icon-wpcf-access' );
63
  echo '<div class="types-help"><div class="types-help-content"';
64
  echo '<p>' . sprintf(__( 'This screen shows a preview of %sAccess%s - the access control and roles management addon for Types.',
@@ -66,11 +87,11 @@ function wpcf_access_teaser_admin_menu_page() {
66
  . '</p>'
67
  . '<p>' . __('Access lets you control what content types different users can read, edit and publish on your site and create custom roles.','wpcf') . '</p>'
68
  . '<p>' . sprintf(__('%sBuy Access%s to unlock this screen and add access control management to your site.','wpcf'),
69
- '<strong><a href="http://wp-types.com/buy/?add-to-cart=38997&buy_now=1&utm_source=typesplugin&utm_medium=accessadmin&utm_term=Buy&utm_campaign=typesplugin" target="_blank">',
70
  '</a></strong>')
71
  . '</p>'
72
  . '<p><a href="http://wp-types.com/home/types-access/?utm_source=typesplugin&utm_medium=accessadmin&utm_term=AccessFeatures&utm_campaign=typesplugin" class="button-primary" target="_blank">'
73
- . __( 'Access Features' ) . '</a>&nbsp;<a href="http://wp-types.com/buy/?add-to-cart=38997&buy_now=1&utm_source=typesplugin&utm_medium=accessadmin&utm_term=Buy&utm_campaign=typesplugin" class="button-primary" target="_blank">'
74
  . __( 'Buy Access - $39 (USD)' ) . '</a>' . '</p>';
75
  echo '</div></div>';
76
  require_once WPCF_ACCESS_INC . '/admin-edit-access.php';
1
  <?php
2
  /*
3
  * Types Access teaser.
4
+ *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/plus/types-access.php $
6
+ * $LastChangedDate: 2015-02-04 13:43:06 +0000 (Wed, 04 Feb 2015) $
7
+ * $LastChangedRevision: 1082328 $
8
+ * $LastChangedBy: iworks $
9
+ *
10
  */
11
 
12
  add_action( 'plugins_loaded', 'wpcf_access_teaser_init', 15 );
13
+ add_action( 'wpcf_menu_plus', 'wpcf_access_teaser_admin_menu' );
14
 
15
  /**
16
+ * Teaser init.
17
  */
18
  function wpcf_access_teaser_init() {
19
  global $pagenow;
29
  define( 'WPCF_ACCESS_RELPATH',
30
  plugins_url() . '/' . basename( WPCF_ABSPATH ) . '/plus/types-access' );
31
  define( 'WPCF_ACCESS_INC', WPCF_ACCESS_ABSPATH . '/includes' );
 
32
  $locale = get_locale();
33
  load_textdomain( 'wpcf_access',
34
  WPCF_ACCESS_ABSPATH . '/locale/types-access-' . $locale . '.mo' );
36
  }
37
 
38
  /**
39
+ * Teaser menu hook.
40
  */
41
  function wpcf_access_teaser_admin_menu() {
42
+ $hook = wpcf_admin_add_submenu_page(
43
+ array(
44
+ 'page_title' => __( 'Access Control and User Roles', 'wpcf' ),
45
+ 'menu_title' => __( 'Access Control and User Roles', 'wpcf' ),
46
+ 'menu_slug' => 'wpcf-access',
47
+ 'function' => 'wpcf_access_teaser_admin_menu_page',
48
+ 'load_hook' => 'wpcf_access_teaser_admin_menu_load',
49
+ )
50
+ );
51
  }
52
 
53
  /**
54
+ * Teaser menu load.
55
  */
56
  function wpcf_access_teaser_admin_menu_load() {
57
  require_once WPCF_ACCESS_ABSPATH . '/embedded.php';
66
  }
67
 
68
  /**
69
+ * Teaser admin screen.
70
  */
71
+ function wpcf_access_teaser_admin_menu_page()
72
+ {
73
+ $access_buy_link = 'http://wp-types.com/buy/?add-to-cart=38997&buy_now=1&utm_source=typesplugin&utm_medium=accessadmin&utm_term=Buy&utm_campaign=typesplugin';
74
+ /**
75
+ * get link by installer
76
+ */
77
+ if ( class_exists('WP_Installer_API') && method_exists('WP_Installer_API', 'get_product_installer_link') ) {
78
+ $access_buy_link = WP_Installer_API::get_product_installer_link('toolset', 'access');
79
+ }
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.',
87
  . '</p>'
88
  . '<p>' . __('Access lets you control what content types different users can read, edit and publish on your site and create custom roles.','wpcf') . '</p>'
89
  . '<p>' . sprintf(__('%sBuy Access%s to unlock this screen and add access control management to your site.','wpcf'),
90
+ sprintf('<strong><a href="%s" target="_blank">', $access_buy_link),
91
  '</a></strong>')
92
  . '</p>'
93
  . '<p><a href="http://wp-types.com/home/types-access/?utm_source=typesplugin&utm_medium=accessadmin&utm_term=AccessFeatures&utm_campaign=typesplugin" class="button-primary" target="_blank">'
94
+ . sprintf(__( 'Access Features' ) . '</a>&nbsp;<a href="%s" class="button-primary" target="_blank">', $access_buy_link )
95
  . __( 'Buy Access - $39 (USD)' ) . '</a>' . '</p>';
96
  echo '</div></div>';
97
  require_once WPCF_ACCESS_INC . '/admin-edit-access.php';
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
8
- Stable tag: 1.6.4
9
 
10
  The complete and reliable plugin for managing custom post types, custom taxonomy and custom fields.
11
 
@@ -148,11 +148,30 @@ Additionally, Types is the only plugin that lets you define parent/child relatio
148
  3. Editing custom fields
149
  4. Inserting custom fields to content
150
  5. Bulk editing child content using Field Tables
 
 
151
 
152
  == Changelog ==
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  = 1.6.4 =
155
 
 
156
  * Fixed an issue with dependency between custom taxonomy and custom posts when importing data from the "Custom Post Type UI" plugin.
157
  * Fixed an issue with editing checkboxes with the option "save 0 to the database" selected, created for Custom Posts. http://wp-types.com/forums/topic/checkbox-custom-field-doesnt-save-value-since-upgrade-to-version-1-6-2/ http://wp-types.com/forums/topic/types-checkbox-field-not-saving-after-save-0-to-the-database/
158
  * Fixed an issue with PHP notices being thrown when relative URLs to images were used. http://wp-types.com/forums/topic/php-notice-undefined-index-host-in-image-php/
@@ -165,7 +184,7 @@ Additionally, Types is the only plugin that lets you define parent/child relatio
165
  * Fixed embedding OTGS CSS for the admin area. https://wordpress.org/support/topic/four-stylesheets-being-loaded-at-frontend
166
  * Fixed a problem with Checkbox field value not being saved. https://wp-types.com/forums/topic/checkbox-value-not-saved/
167
  * Added the option to select posts with the "Private" post status as parents in a parent-child Custom Post Types relationships. http://wp-types.com/forums/topic/cred-child-form-not-working-with-private-ctp/
168
- * Fixed a problem with the date-picker. https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/191190651/comments
169
  * Fixed a problem with label menu in wp-admin for child posts.
170
  * Fixed a problem with child table when edit parent post and children do not have title.
171
  * Prevent to chose repetitive field in child table on edit parent screen. http://wp-types.com/forums/topic/wp-types-select-child-fields-to-be-displayed-specific-fields-not-working/
@@ -175,31 +194,27 @@ Additionally, Types is the only plugin that lets you define parent/child relatio
175
 
176
  = 1.6.3 =
177
 
 
178
  * Added the message to ask users to answer a short survey for feedback on their work using the Types plugin.
179
-
180
  * Fixed a problem where the custom field group’s description was missing from the post/page editing page. http://wp-types.com/forums/topic/custom-field-group-descriptions-no-longer-visible-in-cpt-add-newedit-screen/
181
-
182
  * Fixed a problem where the field descriptions weren’t displayed on the user profile editing page. http://wp-types.com/forums/topic/checkbox-description-fields-no-longer-display-in-types-1-6-2/
183
-
184
  * Fixed a problem where users weren’t able to untick the single and multiple checkbox fields on the user profile editing page.
185
-
186
  * Fixed a problem where the value of date field couldn’t be cleared and added new button which clears the date field value. http://wp-types.com/forums/topic/problem-2-after-update/
187
-
188
  * Replaced the deprecated like_escape function with the wpdb::esc_like function.
189
-
190
  * Fixed a problem where the parent-child relations between custom post types persisted after deleting and re-creating a custom post type.
191
-
192
  * Fixed a problem where date picker scripts were being enqueued in the front end. https://wordpress.org/support/topic/datepicker-css-enqueued-on-public
193
 
194
 
195
  = 1.6.2 =
196
 
 
197
  * Fix addslashes warning
198
  * Fix display problems with Types shortcodes
199
  * Fix PHP error for checkboxes
200
 
201
  = 1.6.1 =
202
 
 
203
  * Fix Formfactory::createForm and Formfactory::displayForm errors on some systems
204
  * Fix anonymous function problem with wysiwyg field
205
  * Fix datepicker.css so it only styles the datepicker popup
@@ -207,9 +222,10 @@ Additionally, Types is the only plugin that lets you define parent/child relatio
207
 
208
  = 1.6 =
209
 
 
210
  * Added ability to add extra options by filter *wpt_field_options* to fields with "options".
211
  * Added ability to create custom post type with the same singular and plural name.
212
- * Added ability to select menu icon for custom post type.
213
  * Added delete attached repetitive files.
214
  * Added filter "wpcf_pr_belongs_post_status" that allows to change post_status for parent/child posts.
215
  * Added sanitization for uploaded file names, to remove non-latin1 characters.
5
  License: GPLv2
6
  Requires at least: 3.4
7
  Tested up to: 4.1
8
+ Stable tag: 1.6.5
9
 
10
  The complete and reliable plugin for managing custom post types, custom taxonomy and custom fields.
11
 
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 =
157
+
158
+ * Change in relationships, now all posts are showed, even those which have show_ui to false.
159
+ * Added ability to hide custom post types on post relationships list. https://wp-types.com/forums/topic/post-relationship-doesnt-show-post-type-events-created-by-events-espresso/ using filter add_filter('wpcf_show_ui_hide_in_relationships', '__return_false');
160
+ * Fixed a problem with deleting last children on post relationships table.
161
+ * Added filter to allow use "?" in image url. https://wp-types.com/forums/topic/image-custom-field-is-not-storing-image-path-with-parameters/
162
+ * Added option for child table, when editing parent to allow show only list of children instead edit form. http://wp-types.com/forums/topic/miss-settings-for-post-relationship-child-options/
163
+ * Fixed a problem with slug in custom fields, when field have special chars.
164
+ * Fixed wrong display message about custom fields not manageable by Types.
165
+ * Fixed a conflict with Formidable-Pro plugin https://wp-types.com/forums/topic/plugin-conflict/
166
+ * Fixed creating new post in relationships. WP 4.1 need real title not faked by one space.
167
+ * Fixed problem with validate fields on user create page. http://wp-types.com/forums/topic/custom-usermeta-bypassed-even-required-is-set/
168
+ * Improve Edit CPT and Edit CT screens to be more compatible with WP Admin UI
169
+ * Fixed problem with default label which contains single quote character (eg. French) https://wp-types.com/forums/topic/default-label-always-shown/
170
+ * Improve display list of custom fields groups.
171
+
172
  = 1.6.4 =
173
 
174
+ * Release date: 2014-11-17
175
  * Fixed an issue with dependency between custom taxonomy and custom posts when importing data from the "Custom Post Type UI" plugin.
176
  * Fixed an issue with editing checkboxes with the option "save 0 to the database" selected, created for Custom Posts. http://wp-types.com/forums/topic/checkbox-custom-field-doesnt-save-value-since-upgrade-to-version-1-6-2/ http://wp-types.com/forums/topic/types-checkbox-field-not-saving-after-save-0-to-the-database/
177
  * Fixed an issue with PHP notices being thrown when relative URLs to images were used. http://wp-types.com/forums/topic/php-notice-undefined-index-host-in-image-php/
184
  * Fixed embedding OTGS CSS for the admin area. https://wordpress.org/support/topic/four-stylesheets-being-loaded-at-frontend
185
  * Fixed a problem with Checkbox field value not being saved. https://wp-types.com/forums/topic/checkbox-value-not-saved/
186
  * Added the option to select posts with the "Private" post status as parents in a parent-child Custom Post Types relationships. http://wp-types.com/forums/topic/cred-child-form-not-working-with-private-ctp/
187
+ * Fixed a problem with the date-picker. https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/191190651/comments
188
  * Fixed a problem with label menu in wp-admin for child posts.
189
  * Fixed a problem with child table when edit parent post and children do not have title.
190
  * Prevent to chose repetitive field in child table on edit parent screen. http://wp-types.com/forums/topic/wp-types-select-child-fields-to-be-displayed-specific-fields-not-working/
194
 
195
  = 1.6.3 =
196
 
197
+ * Release date: 2014-10-23
198
  * Added the message to ask users to answer a short survey for feedback on their work using the Types plugin.
 
199
  * Fixed a problem where the custom field group’s description was missing from the post/page editing page. http://wp-types.com/forums/topic/custom-field-group-descriptions-no-longer-visible-in-cpt-add-newedit-screen/
 
200
  * Fixed a problem where the field descriptions weren’t displayed on the user profile editing page. http://wp-types.com/forums/topic/checkbox-description-fields-no-longer-display-in-types-1-6-2/
 
201
  * Fixed a problem where users weren’t able to untick the single and multiple checkbox fields on the user profile editing page.
 
202
  * Fixed a problem where the value of date field couldn’t be cleared and added new button which clears the date field value. http://wp-types.com/forums/topic/problem-2-after-update/
 
203
  * Replaced the deprecated like_escape function with the wpdb::esc_like function.
 
204
  * Fixed a problem where the parent-child relations between custom post types persisted after deleting and re-creating a custom post type.
 
205
  * Fixed a problem where date picker scripts were being enqueued in the front end. https://wordpress.org/support/topic/datepicker-css-enqueued-on-public
206
 
207
 
208
  = 1.6.2 =
209
 
210
+ * Release date: 2014-08-29
211
  * Fix addslashes warning
212
  * Fix display problems with Types shortcodes
213
  * Fix PHP error for checkboxes
214
 
215
  = 1.6.1 =
216
 
217
+ * Release date: 2014-08-22
218
  * Fix Formfactory::createForm and Formfactory::displayForm errors on some systems
219
  * Fix anonymous function problem with wysiwyg field
220
  * Fix datepicker.css so it only styles the datepicker popup
222
 
223
  = 1.6 =
224
 
225
+ * Release date: 2014-08-22
226
  * Added ability to add extra options by filter *wpt_field_options* to fields with "options".
227
  * Added ability to create custom post type with the same singular and plural name.
228
+ * Added ability to select menu icon (WordPress dashicon) for custom post type.
229
  * Added delete attached repetitive files.
230
  * Added filter "wpcf_pr_belongs_post_status" that allows to change post_status for parent/child posts.
231
  * Added sanitization for uploaded file names, to remove non-latin1 characters.
resources/js/basic.js CHANGED
@@ -1,11 +1,9 @@
1
- /**
2
- *
3
- * Use this file only for scripts needed in full version.
4
  * Before moving from embedded JS - make sure it's needed only here.
5
  *
6
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/resources/js/basic.js $
7
- * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
8
- * $LastChangedRevision: 1027712 $
9
  * $LastChangedBy: iworks $
10
  *
11
  */
@@ -16,8 +14,25 @@ jQuery(document).ready(function($){
16
  }
17
  });
18
  $('a.current').each( function() {
19
- if ($(this).attr('href').match(/page=wpcf\-edit(\-(type|usermeta))?/)) {
 
20
  $(this).attr('href', window.location.href);
21
  }
22
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  });
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/resources/js/basic.js $
5
+ * $LastChangedDate: 2015-01-16 14:28:15 +0000 (Fri, 16 Jan 2015) $
6
+ * $LastChangedRevision: 1069430 $
7
  * $LastChangedBy: iworks $
8
  *
9
  */
14
  }
15
  });
16
  $('a.current').each( function() {
17
+ var href = $(this).attr('href');
18
+ if ('undefined' != typeof(href) && href.match(/page=wpcf\-edit(\-(type|usermeta))?/)) {
19
  $(this).attr('href', window.location.href);
20
  }
21
  });
22
+ /**
23
+ * settings toolset messages
24
+ */
25
+ $('#wpcf-toolset-messages-form input[type=checkbox]').on('change', function() {
26
+ parent = $(this).closest('form');
27
+ $('.spinner', parent).show();
28
+ $('.updated', parent).hide();
29
+ var data = {
30
+ action: 'toolset_messages',
31
+ value: $(this).attr('checked')
32
+
33
+ };
34
+ $.post(ajaxurl, data, function(response) {
35
+ $('.spinner', parent).hide().after(response);
36
+ });
37
+ });
38
  });
resources/js/custom-types-form.js CHANGED
@@ -2,7 +2,7 @@
2
  *
3
  * Custom Types form JS
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/resources/js/custom-types-form.js $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
2
  *
3
  * Custom Types form JS
4
  *
5
+ * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.5/resources/js/custom-types-form.js $
6
  * $LastChangedDate: 2014-11-18 06:47:25 +0000 (Tue, 18 Nov 2014) $
7
  * $LastChangedRevision: 1027712 $
8
  * $LastChangedBy: iworks $
wpcf.php CHANGED
@@ -5,13 +5,13 @@
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.4
9
  */
10
  /**
11
  *
12
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.4/wpcf.php $
13
- * $LastChangedDate: 2014-11-18 06:52:14 +0000 (Tue, 18 Nov 2014) $
14
- * $LastChangedRevision: 1027716 $
15
  * $LastChangedBy: iworks $
16
  *
17
  */
@@ -20,7 +20,7 @@ if ( !defined( 'WPCF_VERSION' ) ) {
20
  /**
21
  * make sure that WPCF_VERSION in embedded/bootstrap.php is the same!
22
  */
23
- define( 'WPCF_VERSION', '1.6.4' );
24
  }
25
 
26
  define( 'WPCF_REPOSITORY', 'http://api.wp-types.com/' );
@@ -32,23 +32,23 @@ define( 'WPCF_INC_RELPATH', WPCF_RELPATH . '/includes' );
32
  define( 'WPCF_RES_ABSPATH', WPCF_ABSPATH . '/resources' );
33
  define( 'WPCF_RES_RELPATH', WPCF_RELPATH . '/resources' );
34
 
35
- //Add installer
36
- include dirname( __FILE__ ) . '/embedded/common/installer/loader.php';
37
- WP_Installer_Setup($wp_installer_instance,
38
  array(
39
  'plugins_install_tab' => '1',
40
- 'repositories_include' => array('toolset', 'wpml')
41
  ));
42
-
43
  require_once WPCF_INC_ABSPATH . '/constants.php';
44
  /*
45
  * Since Types 1.2 we load all embedded code without conflicts
46
  */
47
  require_once WPCF_ABSPATH . '/embedded/types.php';
48
 
49
- require_once WPCF_ABSPATH . '/embedded/onthego-resources/onthegosystems-branding-loader.php';
50
- ont_set_on_the_go_systems_uri_and_start(WPCF_RELPATH . '/embedded/onthego-resources/' );
51
-
52
 
53
  // Plugin mode only hooks
54
  add_action( 'plugins_loaded', 'wpcf_init' );
@@ -56,10 +56,8 @@ add_action( 'plugins_loaded', 'wpcf_init' );
56
  // init hook for module manager
57
  add_action( 'init', 'wpcf_wp_init' );
58
 
59
- register_activation_hook( __FILE__, 'wpcf_upgrade_init' );
60
  register_deactivation_hook( __FILE__, 'wpcf_deactivation_hook' );
61
-
62
- add_filter( 'plugin_action_links', 'wpcf_types_plugin_action_links', 10, 2 );
63
 
64
  /**
65
  * Deactivation hook.
@@ -68,11 +66,38 @@ add_filter( 'plugin_action_links', 'wpcf_types_plugin_action_links', 10, 2 );
68
  */
69
  function wpcf_deactivation_hook()
70
  {
71
- // Reset redirection
72
- delete_option( 'wpcf_types_plugin_do_activation_redirect', true );
73
-
74
  // Delete messages
75
  delete_option( 'wpcf-messages' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
 
78
  /**
@@ -85,19 +110,25 @@ function wpcf_init()
85
  }
86
 
87
  if ( is_admin() ) {
88
-
89
  require_once WPCF_ABSPATH . '/admin.php';
90
  }
91
-
92
-
 
 
 
 
 
 
93
  }
94
 
95
  //Render Installer packages
96
- function installer_content(){
97
- echo '<div class="wrap">';
98
- $config['repository'] = array(); // required
99
- WP_Installer_Show_Products($config);
100
- echo "</div>";
 
101
  }
102
 
103
  /**
@@ -106,74 +137,21 @@ function installer_content(){
106
  function wpcf_wp_init()
107
  {
108
  if ( is_admin() ) {
109
-
110
- require_once WPCF_ABSPATH . '/admin.php';
111
- add_action('admin_menu', 'setup_installer');
112
- //Add submenu Installer to Types
113
- function setup_installer(){
114
- add_submenu_page('wpcf', 'Installer', 'Installer', 'manage_options', 'installer', 'installer_content');
115
- }
116
- }
117
- }
118
-
119
- /**
120
- * Include embedded code if not used in theme.
121
- *
122
- * We are actually calling this hook on after_setup_theme which is called
123
- * immediatelly before 'init'. However WP issues warnings because for some
124
- * action it strictly required 'init' hook to be used.
125
- *
126
- * @todo Revise this!
127
- */
128
- /*
129
- * TODO 1.2.1 remove
130
- */
131
- //function wpcf_init_embedded_code() {
132
- // if ( !defined( 'WPCF_EMBEDDED_ABSPATH' ) ) {
133
- // require_once WPCF_ABSPATH . '/embedded/types.php';
134
- // } else {
135
- // require_once WPCF_EMBEDDED_ABSPATH . '/types.php';
136
- // }
137
- //
138
- // // TODO Better bootstrapping is ready to be added
139
- // // Make this check for now.
140
- // if ( did_action( 'init' ) > 0 ) {
141
- // wpcf_embedded_init();
142
- // } else {
143
- // add_action( 'init', 'wpcf_embedded_init' );
144
- // }
145
- //}
146
-
147
- /**
148
- * Upgrade hook.
149
- */
150
- function wpcf_upgrade_init()
151
- {
152
- wpcf_types_plugin_activate();
153
- }
154
-
155
- function wpcf_types_plugin_activate()
156
- {
157
- add_option( 'wpcf_types_plugin_do_activation_redirect', true );
158
- }
159
-
160
- function wpcf_types_plugin_redirect()
161
- {
162
- if ( get_option( 'wpcf_types_plugin_do_activation_redirect', false ) ) {
163
- delete_option( 'wpcf_types_plugin_do_activation_redirect' );
164
- wp_redirect( admin_url() . 'admin.php?page=wpcf-help' );
165
- exit;
166
- }
167
- }
168
-
169
- function wpcf_types_plugin_action_links($links, $file)
170
- {
171
- $this_plugin = basename( WPCF_ABSPATH ) . '/wpcf.php';
172
- if ( $file == $this_plugin ) {
173
- $links[] = '<a href="admin.php?page=wpcf-help">' . __( 'Getting started',
174
- 'wpcf' ) . '</a>';
175
  }
176
- return $links;
177
  }
178
 
179
  /**
@@ -333,4 +311,3 @@ function wpcf_fix_translated_post_relationships($post_id)
333
  wpcf_post_relationship_set_translated_parent( $post_id );
334
  wpcf_post_relationship_set_translated_children( $post_id );
335
  }
336
-
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/wpcf.php $
13
+ * $LastChangedDate: 2015-02-04 13:43:06 +0000 (Wed, 04 Feb 2015) $
14
+ * $LastChangedRevision: 1082328 $
15
  * $LastChangedBy: iworks $
16
  *
17
  */
20
  /**
21
  * make sure that WPCF_VERSION in embedded/bootstrap.php is the same!
22
  */
23
+ define( 'WPCF_VERSION', '1.6.5' );
24
  }
25
 
26
  define( 'WPCF_REPOSITORY', 'http://api.wp-types.com/' );
32
  define( 'WPCF_RES_ABSPATH', WPCF_ABSPATH . '/resources' );
33
  define( 'WPCF_RES_RELPATH', WPCF_RELPATH . '/resources' );
34
 
35
+ // Add installer
36
+ include dirname( __FILE__ ) . '/plus/installer/loader.php';
37
+ WP_Installer_Setup($wp_installer_instance,
38
  array(
39
  'plugins_install_tab' => '1',
40
+ 'repositories_include' => array('toolset', 'wpml')
41
  ));
42
+
43
  require_once WPCF_INC_ABSPATH . '/constants.php';
44
  /*
45
  * Since Types 1.2 we load all embedded code without conflicts
46
  */
47
  require_once WPCF_ABSPATH . '/embedded/types.php';
48
 
49
+ require_once WPCF_ABSPATH . '/embedded/onthego-resources/loader.php';
50
+ onthego_initialize(WPCF_ABSPATH . '/embedded/onthego-resources/',
51
+ WPCF_RELPATH . '/embedded/onthego-resources/' );
52
 
53
  // Plugin mode only hooks
54
  add_action( 'plugins_loaded', 'wpcf_init' );
56
  // init hook for module manager
57
  add_action( 'init', 'wpcf_wp_init' );
58
 
 
59
  register_deactivation_hook( __FILE__, 'wpcf_deactivation_hook' );
60
+ register_activation_hook( __FILE__, 'wpcf_activation_hook' );
 
61
 
62
  /**
63
  * Deactivation hook.
66
  */
67
  function wpcf_deactivation_hook()
68
  {
 
 
 
69
  // Delete messages
70
  delete_option( 'wpcf-messages' );
71
+ delete_option( 'WPCF_VERSION' );
72
+ /**
73
+ * check site kind and if do not exist, delete types_show_on_activate
74
+ */
75
+ if ( !get_option('types-site-kind') ) {
76
+ delete_option('types_show_on_activate');
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Activation hook.
82
+ *
83
+ * Reset some of data.
84
+ */
85
+ function wpcf_activation_hook()
86
+ {
87
+ $version = get_option('WPCF_VERSION');
88
+ if ( empty($version) ) {
89
+ $version = 0;
90
+ add_option('WPCF_VERSION', 0, null, 'no');
91
+ }
92
+ if ( version_compare($version, WPCF_VERSION) < 0 ) {
93
+ update_option('WPCF_VERSION', WPCF_VERSION);
94
+ }
95
+ if( 0 == version_compare(WPCF_VERSION, '1.6.5')) {
96
+ add_option('types_show_on_activate', 'show', null, 'no');
97
+ if ( get_option('types-site-kind') ) {
98
+ update_option('types_show_on_activate', 'hide');
99
+ }
100
+ }
101
  }
102
 
103
  /**
110
  }
111
 
112
  if ( is_admin() ) {
 
113
  require_once WPCF_ABSPATH . '/admin.php';
114
  }
115
+ /**
116
+ * remove unused option
117
+ */
118
+ $version_from_db = get_option('wpcf-version', 0);
119
+ if ( version_compare(WPCF_VERSION, $version_from_db) > 0 ) {
120
+ delete_option('wpcf-survey-2014-09');
121
+ update_option('wpcf-version', WPCF_VERSION);
122
+ }
123
  }
124
 
125
  //Render Installer packages
126
+ function installer_content()
127
+ {
128
+ echo '<div class="wrap">';
129
+ $config['repository'] = array(); // required
130
+ WP_Installer_Show_Products($config);
131
+ echo "</div>";
132
  }
133
 
134
  /**
137
  function wpcf_wp_init()
138
  {
139
  if ( is_admin() ) {
140
+ require_once WPCF_ABSPATH . '/admin.php';
141
+ add_action('wpcf_menu_plus', 'setup_installer');
142
+ //Add submenu Installer to Types
143
+ function setup_installer()
144
+ {
145
+ wpcf_admin_add_submenu_page(
146
+ array(
147
+ 'page_title' => __('Installer', 'wpcf'),
148
+ 'menu_title' => __('Installer', 'wpcf'),
149
+ 'menu_slug' => 'installer',
150
+ 'function' => 'installer_content'
151
+ )
152
+ );
153
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  }
 
155
  }
156
 
157
  /**
311
  wpcf_post_relationship_set_translated_parent( $post_id );
312
  wpcf_post_relationship_set_translated_children( $post_id );
313
  }