Version Description
- Fix addslashes warning
- Fix display problems with Types shortcodes
- Fix PHP error for checkboxes
Download this release
Release Info
Developer | iworks |
Plugin | Toolset Types – Custom Post Types, Custom Fields and Taxonomies |
Version | 1.6.2 |
Comparing to | |
See all releases |
Code changes from version 1.6.6.6 to 1.6.2
- admin.php +976 -1191
- classes/class.wpcf-marketing-messages.php +0 -364
- classes/class.wpcf-marketing-tutorial.php +0 -247
- classes/class.wpcf-marketing.php +0 -159
- embedded/admin.php +58 -33
- embedded/bootstrap.php +10 -21
- embedded/classes/class.wpcf-post-types.php +4 -235
- embedded/classes/editor.php +4 -2
- embedded/classes/field.php +81 -80
- embedded/classes/fields.php +3 -3
- embedded/classes/forms.php +8 -16
- embedded/classes/loader.php +18 -21
- embedded/classes/path.php +4 -4
- embedded/classes/post-types/messages.php +4 -4
- embedded/classes/relationship.php +27 -103
- embedded/classes/relationship/form-child.php +66 -129
- embedded/classes/repeater.php +55 -58
- embedded/classes/usermeta_field.php +20 -16
- embedded/classes/usermeta_repeater.php +43 -46
- embedded/classes/validate.php +1 -24
- embedded/classes/validation-cakephp.php +0 -23
- embedded/common/changelog.txt +0 -27
- embedded/common/classes/class-toolset-admin-bar-menu.php +0 -687
- embedded/common/classes/class.toolset.promo.php +0 -197
- embedded/common/classes/forms.php +10 -17
- embedded/common/classes/validation-cakephp.php +1089 -1102
- embedded/common/debug/debug-information.php +4 -4
- embedded/common/debug/functions_debug_information.php +35 -45
- embedded/common/expression-parser/js/parser.js +14 -14
- embedded/common/expression-parser/parser.php +15 -15
- embedded/common/functions.php +98 -45
- embedded/common/res/css/colorbox.css +0 -88
- embedded/common/res/css/toolset-common.css +3 -14
- embedded/common/res/css/toolset-promotion.css +0 -164
- embedded/common/res/images/toolset.promotion/full.jpg +0 -0
- embedded/common/res/images/toolset.promotion/icons.png +0 -0
- embedded/common/res/images/toolset.promotion/toolset.png +0 -0
- embedded/common/res/js/jquery.colorbox-min.js +0 -7
- embedded/common/res/js/toolset-promotion.js +0 -47
- embedded/common/toolset-forms/api.php +2 -40
- embedded/common/toolset-forms/bootstrap.php +111 -213
- embedded/common/toolset-forms/classes/class.audio.php +4 -4
- embedded/common/toolset-forms/classes/class.checkbox.php +8 -15
- embedded/common/toolset-forms/classes/class.checkboxes.php +12 -31
- embedded/common/toolset-forms/classes/class.colorpicker.php +18 -36
- embedded/common/toolset-forms/classes/class.conditional.php +205 -198
- embedded/common/toolset-forms/classes/class.credaudio.php +4 -4
- embedded/common/toolset-forms/classes/class.credfile.php +5 -5
- embedded/common/toolset-forms/classes/class.credimage.php +4 -4
- embedded/common/toolset-forms/classes/class.credvideo.php +4 -4
- embedded/common/toolset-forms/classes/class.date.php +218 -244
- embedded/common/toolset-forms/classes/class.date.scripts.php +3 -14
- embedded/common/toolset-forms/classes/class.eforms.php +329 -280
- embedded/common/toolset-forms/classes/class.field_factory.php +6 -35
- embedded/common/toolset-forms/classes/class.fieldconfig.php +30 -43
- embedded/common/toolset-forms/classes/class.file.php +116 -58
- embedded/common/toolset-forms/classes/class.form_factory.php +16 -76
- embedded/common/toolset-forms/classes/class.image.php +8 -19
- embedded/common/toolset-forms/classes/class.integer.php +0 -12
- embedded/common/toolset-forms/classes/class.radios.php +12 -37
- embedded/common/toolset-forms/classes/class.recaptcha.php +6 -7
- embedded/common/toolset-forms/classes/class.repetitive.php +4 -4
- embedded/common/toolset-forms/classes/class.select.php +8 -27
- embedded/common/toolset-forms/classes/class.skype.php +23 -32
- embedded/common/toolset-forms/classes/class.submit.php +29 -41
- embedded/common/toolset-forms/classes/class.taxonomy.php +38 -16
- embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php +133 -135
- embedded/common/toolset-forms/classes/class.textarea.php +4 -4
- embedded/common/toolset-forms/classes/class.textfield.php +7 -6
- embedded/common/toolset-forms/classes/class.types.php +15 -17
- embedded/common/toolset-forms/classes/class.validation.php +20 -24
- embedded/common/toolset-forms/classes/class.video.php +8 -44
- embedded/common/toolset-forms/classes/class.wysiwyg.php +10 -10
- embedded/common/toolset-forms/css/wpt-jquery-ui/datepicker.css +1 -1
- embedded/common/toolset-forms/css/wpt-toolset-frontend.css +31 -19
- embedded/common/toolset-forms/external/autocompleter.php +53 -0
- embedded/common/toolset-forms/js/colorpicker.js +0 -1
- embedded/common/toolset-forms/js/conditional.js +403 -554
- embedded/common/toolset-forms/js/date.js +60 -108
- embedded/common/toolset-forms/js/file-wp35.js +0 -107
- embedded/common/toolset-forms/js/file.js +68 -0
- embedded/common/toolset-forms/js/jquery.autocomplete.js +507 -0
- embedded/common/toolset-forms/js/main.js +228 -281
- embedded/common/toolset-forms/js/repetitive.js +4 -4
- embedded/common/toolset-forms/js/skype.js +2 -2
- embedded/common/toolset-forms/js/validation.js +5 -62
- embedded/common/toolset-forms/lib/CakePHP-Validation.php +199 -215
- embedded/common/toolset-forms/lib/js/jquery-form-validation/jquery.validate.js +1 -5
- embedded/common/toolset-forms/readme.txt +0 -144
- embedded/common/toolset-forms/templates/metaform-item.php +26 -27
- embedded/common/toolset-forms/templates/metaform.php +6 -6
- embedded/common/toolset-forms/test.php +36 -0
- embedded/common/utility/css/notifications.css +0 -342
- embedded/common/utility/css/select2/select2-overrides.css +0 -26
- embedded/common/utility/css/select2/select2-spinner.gif +0 -0
- embedded/common/utility/css/select2/select2.css +0 -704
- embedded/common/utility/css/select2/select2.png +0 -0
- embedded/common/utility/css/select2/select2x2.png +0 -0
- embedded/common/utility/img/icon-help-message.png +0 -0
- embedded/common/utility/js/jstorage.min.js +0 -16
- embedded/common/utility/js/keyboard.js +0 -961
- embedded/common/utility/js/keyboard.min.js +0 -1
- embedded/common/utility/js/select2.min.js +0 -23
- embedded/common/utility/js/utils.js +0 -968
- embedded/common/utility/utils.php +0 -111
- embedded/common/views/promote.php +93 -0
- embedded/common/views/res/img/views-32.png +0 -0
- embedded/common/visual-editor/editor-addon-generic.class.php +30 -111
- embedded/common/visual-editor/editor-addon.class.php +95 -99
- embedded/common/visual-editor/res/js/icl_editor_addon_plugin.js +27 -180
- embedded/common/visual-editor/res/js/icl_media_manager.js +0 -260
- embedded/common/wplogger.php +6 -6
- embedded/common/wpv-filter-date-embedded.php +1 -1
- embedded/frontend.php +37 -85
- embedded/functions.php +713 -711
- embedded/includes/ajax.php +68 -97
admin.php
CHANGED
@@ -1,1115 +1,998 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* Admin functions
|
5 |
-
*
|
6 |
-
* $HeadURL:
|
7 |
-
* $LastChangedDate:
|
8 |
-
* $LastChangedRevision:
|
9 |
-
* $LastChangedBy:
|
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 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
//
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
'function' => 'wpcf_admin_menu_settings',
|
117 |
-
'submenu' => array(
|
118 |
-
'wpcf-debug-information' => array(
|
119 |
-
'menu_title' => __( 'Debug Information', 'wpcf' ),
|
120 |
-
'function' => 'wpcf_admin_menu_debug_information',
|
121 |
),
|
122 |
),
|
123 |
-
);
|
124 |
-
|
125 |
-
foreach( $subpages as $menu_slug => $menu ) {
|
126 |
-
wpcf_admin_add_submenu_page($menu, $menu_slug);
|
127 |
-
}
|
128 |
-
|
129 |
-
if ( isset( $_GET['page'] ) ) {
|
130 |
-
switch ( $_GET['page'] ) {
|
131 |
-
case 'wpcf-edit':
|
132 |
-
$title = isset( $_GET['group_id'] ) ? __( 'Edit Group', 'wpcf' ) : __( 'Add New Group',
|
133 |
-
'wpcf' );
|
134 |
-
$hook = add_submenu_page( 'wpcf', $title, $title,
|
135 |
-
'manage_options', 'wpcf-edit',
|
136 |
-
'wpcf_admin_menu_edit_fields' );
|
137 |
-
add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_fields_hook' );
|
138 |
-
wpcf_admin_plugin_help( $hook, 'wpcf-edit' );
|
139 |
-
break;
|
140 |
-
|
141 |
-
case 'wpcf-edit-type':
|
142 |
-
$title = isset( $_GET['wpcf-post-type'] ) ? __( 'Edit Custom Post Type',
|
143 |
-
'wpcf' ) : __( 'Add New Custom Post Type',
|
144 |
-
'wpcf' );
|
145 |
-
$hook = add_submenu_page( 'wpcf', $title, $title,
|
146 |
-
'manage_options', 'wpcf-edit-type',
|
147 |
-
'wpcf_admin_menu_edit_type' );
|
148 |
-
add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_type_hook' );
|
149 |
-
wpcf_admin_plugin_help( $hook, 'wpcf-edit-type' );
|
150 |
-
break;
|
151 |
-
|
152 |
-
case 'wpcf-edit-tax':
|
153 |
-
$title = isset( $_GET['wpcf-tax'] ) ? __( 'Edit Taxonomy',
|
154 |
-
'wpcf' ) : __( 'Add New Taxonomy', 'wpcf' );
|
155 |
-
$hook = add_submenu_page( 'wpcf', $title, $title,
|
156 |
-
'manage_options', 'wpcf-edit-tax',
|
157 |
-
'wpcf_admin_menu_edit_tax' );
|
158 |
-
add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_tax_hook' );
|
159 |
-
wpcf_admin_plugin_help( $hook, 'wpcf-edit-tax' );
|
160 |
-
break;
|
161 |
-
case 'wpcf-edit-usermeta':
|
162 |
-
$title = isset( $_GET['group_id'] ) ? __( 'Edit User Fields Group', 'wpcf' ) : __( 'Add New User Fields Group',
|
163 |
-
'wpcf' );
|
164 |
-
$hook = add_submenu_page( 'wpcf', $title, $title,
|
165 |
-
'manage_options', 'wpcf-edit-usermeta',
|
166 |
-
'wpcf_admin_menu_edit_user_fields' );
|
167 |
-
add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_user_fields_hook' );
|
168 |
-
wpcf_admin_plugin_help( $hook, 'wpcf-edit-usermeta' );
|
169 |
-
break;
|
170 |
-
}
|
171 |
-
}
|
172 |
-
|
173 |
-
// Check if migration from other plugin is needed
|
174 |
-
if ( class_exists( 'Acf' ) || defined( 'CPT_VERSION' ) ) {
|
175 |
-
$hook = add_submenu_page( 'wpcf', __( 'Migration', 'wpcf' ),
|
176 |
-
__( 'Migration', 'wpcf' ), 'manage_options', 'wpcf-migration',
|
177 |
-
'wpcf_admin_menu_migration' );
|
178 |
-
add_action( 'load-' . $hook, 'wpcf_admin_menu_migration_hook' );
|
179 |
-
wpcf_admin_plugin_help( $hook, 'wpcf-migration' );
|
180 |
-
}
|
181 |
-
|
182 |
-
do_action( 'wpcf_menu_plus' );
|
183 |
-
|
184 |
-
// remove the repeating Types submenu
|
185 |
-
remove_submenu_page( 'wpcf', 'wpcf' );
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Menu page hook.
|
190 |
-
*/
|
191 |
-
function wpcf_admin_menu_debug_information()
|
192 |
-
{
|
193 |
-
require_once WPCF_EMBEDDED_ABSPATH.'/common/debug/debug-information.php';
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Menu page hook.
|
198 |
-
*/
|
199 |
-
function wpcf_usermeta_summary_hook()
|
200 |
-
{
|
201 |
-
do_action( 'wpcf_admin_page_init' );
|
202 |
-
wpcf_admin_load_collapsible();
|
203 |
-
wpcf_admin_page_add_options('uf', __( 'User Fields', 'wpcf' ));
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Menu page hook.
|
208 |
-
*/
|
209 |
-
function wpcf_admin_menu_summary_hook()
|
210 |
-
{
|
211 |
-
do_action( 'wpcf_admin_page_init' );
|
212 |
-
wpcf_admin_load_collapsible();
|
213 |
-
wpcf_admin_page_add_options('cf', __( 'Custom Fields', 'wpcf' ));
|
214 |
-
}
|
215 |
-
|
216 |
-
/**
|
217 |
-
* Menu page display.
|
218 |
-
*/
|
219 |
-
function wpcf_admin_menu_summary()
|
220 |
-
{
|
221 |
-
wpcf_add_admin_header(
|
222 |
-
__( 'Custom Fields', 'wpcf' ),
|
223 |
-
array('page'=>'wpcf-edit'),
|
224 |
-
__('Add New Group', 'wpcf')
|
225 |
-
);
|
226 |
-
require_once WPCF_INC_ABSPATH . '/fields.php';
|
227 |
-
require_once WPCF_INC_ABSPATH . '/fields-list.php';
|
228 |
-
$to_display = wpcf_admin_fields_get_fields();
|
229 |
-
if ( !empty( $to_display ) ) {
|
230 |
-
add_action( 'wpcf_groups_list_table_after', 'wpcf_admin_promotional_text' );
|
231 |
-
}
|
232 |
-
wpcf_admin_fields_list();
|
233 |
-
wpcf_add_admin_footer();
|
234 |
-
}
|
235 |
-
|
236 |
-
/**
|
237 |
-
* Menu page hook.
|
238 |
-
*/
|
239 |
-
function wpcf_admin_menu_edit_fields_hook()
|
240 |
-
{
|
241 |
-
do_action( 'wpcf_admin_page_init' );
|
242 |
-
|
243 |
-
/*
|
244 |
-
* Enqueue scripts
|
245 |
-
*/
|
246 |
-
// Group filter
|
247 |
-
wp_enqueue_script( 'wpcf-filter-js',
|
248 |
-
WPCF_EMBEDDED_RES_RELPATH
|
249 |
-
. '/js/custom-fields-form-filter.js', array('jquery'), WPCF_VERSION );
|
250 |
-
// Form
|
251 |
-
wp_enqueue_script( 'wpcf-form-validation',
|
252 |
-
WPCF_EMBEDDED_RES_RELPATH . '/js/'
|
253 |
-
. 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
|
254 |
-
WPCF_VERSION );
|
255 |
-
wp_enqueue_script( 'wpcf-form-validation-additional',
|
256 |
-
WPCF_EMBEDDED_RES_RELPATH . '/js/'
|
257 |
-
. 'jquery-form-validation/additional-methods.min.js',
|
258 |
-
array('jquery'), WPCF_VERSION );
|
259 |
-
// Scroll
|
260 |
-
wp_enqueue_script( 'wpcf-scrollbar',
|
261 |
-
WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/scrollbar.js',
|
262 |
-
array('jquery') );
|
263 |
-
wp_enqueue_script( 'wpcf-mousewheel',
|
264 |
-
WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/mousewheel.js',
|
265 |
-
array('wpcf-scrollbar') );
|
266 |
-
// MAIN
|
267 |
-
wp_enqueue_script( 'wpcf-fields-form',
|
268 |
-
WPCF_EMBEDDED_RES_RELPATH
|
269 |
-
. '/js/fields-form.js', array('wpcf-js') );
|
270 |
-
|
271 |
-
/*
|
272 |
-
* Enqueue styles
|
273 |
-
*/
|
274 |
-
wp_enqueue_style( 'wpcf-scroll',
|
275 |
-
WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/css/scroll.css' );
|
276 |
-
|
277 |
-
//Css editor
|
278 |
-
wp_enqueue_script( 'wpcf-form-codemirror' ,
|
279 |
-
WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.js', array('wpcf-js'));
|
280 |
-
wp_enqueue_script( 'wpcf-form-codemirror-css-editor' ,
|
281 |
-
WPCF_RELPATH . '/resources/js/codemirror234/mode/css/css.js', array('wpcf-js'));
|
282 |
-
wp_enqueue_script( 'wpcf-form-codemirror-html-editor' ,
|
283 |
-
WPCF_RELPATH . '/resources/js/codemirror234/mode/xml/xml.js', array('wpcf-js'));
|
284 |
-
wp_enqueue_script( 'wpcf-form-codemirror-html-editor2' ,
|
285 |
-
WPCF_RELPATH . '/resources/js/codemirror234/mode/htmlmixed/htmlmixed.js', array('wpcf-js'));
|
286 |
-
wp_enqueue_script( 'wpcf-form-codemirror-editor-resize' ,
|
287 |
-
WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.resizable.min.js', array('wpcf-js'));
|
288 |
-
|
289 |
-
wp_enqueue_style( 'wpcf-css-editor',
|
290 |
-
WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.css' );
|
291 |
-
wp_enqueue_style( 'wpcf-css-editor-resize',
|
292 |
-
WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.theme.min.css' );
|
293 |
-
wp_enqueue_style( 'wpcf-usermeta',
|
294 |
-
WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css' );
|
295 |
-
|
296 |
-
add_action( 'admin_footer', 'wpcf_admin_fields_form_js_validation' );
|
297 |
-
require_once WPCF_INC_ABSPATH . '/fields.php';
|
298 |
-
require_once WPCF_INC_ABSPATH . '/fields-form.php';
|
299 |
-
$form = wpcf_admin_fields_form();
|
300 |
-
wpcf_form( 'wpcf_form_fields', $form );
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Menu page display.
|
305 |
-
*/
|
306 |
-
function wpcf_admin_menu_edit_fields()
|
307 |
-
{
|
308 |
-
if ( isset( $_GET['group_id'] ) ) {
|
309 |
-
$title = __( 'Edit Group', 'wpcf' );
|
310 |
-
} else {
|
311 |
-
$title = __( 'Add New Group', 'wpcf' );
|
312 |
-
}
|
313 |
-
wpcf_add_admin_header( $title );
|
314 |
-
wpcf_wpml_warning();
|
315 |
-
$form = wpcf_form( 'wpcf_form_fields' );
|
316 |
-
echo '<form method="post" action="" class="wpcf-fields-form wpcf-form-validate">';
|
317 |
-
echo '<div id="poststuff">';
|
318 |
-
echo $form->renderForm();
|
319 |
-
echo '</div>';
|
320 |
-
echo '</form>';
|
321 |
-
wpcf_add_admin_footer();
|
322 |
-
}
|
323 |
-
|
324 |
-
function wpcf_admin_page_add_options( $name, $label)
|
325 |
-
{
|
326 |
-
$option = 'per_page';
|
327 |
-
$args = array(
|
328 |
-
'label' => $label,
|
329 |
-
'default' => 10,
|
330 |
-
'option' => sprintf('wpcf_%s_%s', $name, $option),
|
331 |
-
);
|
332 |
-
add_screen_option( $option, $args );
|
333 |
-
}
|
334 |
-
|
335 |
-
function wpcf_admin_menu_summary_cpt_ctt_hook()
|
336 |
-
{
|
337 |
-
do_action( 'wpcf_admin_page_init' );
|
338 |
-
wp_enqueue_style( 'wpcf-promo-tabs', WPCF_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION );
|
339 |
-
wpcf_admin_load_collapsible();
|
340 |
-
require_once WPCF_INC_ABSPATH . '/custom-types.php';
|
341 |
-
require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
|
342 |
-
require_once WPCF_INC_ABSPATH . '/custom-types-taxonomies-list.php';
|
343 |
-
}
|
344 |
|
345 |
-
/**
|
346 |
-
* Menu page hook.
|
347 |
-
*/
|
348 |
-
function wpcf_admin_menu_summary_cpt_hook()
|
349 |
-
{
|
350 |
-
wpcf_admin_menu_summary_cpt_ctt_hook();
|
351 |
-
wpcf_admin_page_add_options('cpt', __( 'Custom Post Types', 'wpcf' ));
|
352 |
-
}
|
353 |
-
|
354 |
-
/**
|
355 |
-
* Menu page display.
|
356 |
-
*/
|
357 |
-
function wpcf_admin_menu_summary_cpt()
|
358 |
-
{
|
359 |
-
wpcf_add_admin_header(
|
360 |
-
__( 'Custom Post Types', 'wpcf' ),
|
361 |
-
array('page'=>'wpcf-edit-type'),
|
362 |
-
__('Add New Custom Post Type', 'wpcf')
|
363 |
);
|
364 |
-
$to_display_posts = get_option( 'wpcf-custom-types', array() );
|
365 |
-
$to_display_tax = get_option( 'wpcf-custom-taxonomies', array() );
|
366 |
-
if ( !empty( $to_display_posts ) || !empty( $to_display_tax ) ) {
|
367 |
-
add_action( 'wpcf_types_tax_list_table_after', 'wpcf_admin_promotional_text' );
|
368 |
-
}
|
369 |
-
wpcf_admin_custom_post_types_list();
|
370 |
-
wpcf_add_admin_footer();
|
371 |
-
}
|
372 |
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
/**
|
383 |
-
* Menu page display.
|
384 |
-
*/
|
385 |
-
function wpcf_admin_menu_summary_ctt()
|
386 |
-
{
|
387 |
-
wpcf_add_admin_header( __( 'Custom Taxonomies', 'wpcf' ), array('page' => 'wpcf-edit-tax') );
|
388 |
-
wpcf_admin_custom_taxonomies_list();
|
389 |
-
do_action('wpcf_types_tax_list_table_after');
|
390 |
-
wpcf_add_admin_footer();
|
391 |
-
}
|
392 |
-
|
393 |
-
/**
|
394 |
-
* Menu page hook.
|
395 |
-
*/
|
396 |
-
function wpcf_admin_menu_edit_type_hook()
|
397 |
-
{
|
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 |
-
{
|
424 |
-
if ( isset( $_GET['wpcf-post-type'] ) ) {
|
425 |
-
$title = __( 'Edit Custom Post Type', 'wpcf' );
|
426 |
-
/**
|
427 |
-
* add new CPT link
|
428 |
-
*/
|
429 |
-
$title .= sprintf(
|
430 |
-
'<a href="%s" class="add-new-h2">%s</a>',
|
431 |
-
add_query_arg( 'page', 'wpcf-edit-type', admin_url('admin.php')),
|
432 |
-
__('Add New')
|
433 |
);
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
echo '</form>';
|
444 |
-
wpcf_add_admin_footer();
|
445 |
-
}
|
446 |
-
|
447 |
-
/**
|
448 |
-
* Menu page hook.
|
449 |
-
*/
|
450 |
-
function wpcf_admin_menu_edit_tax_hook()
|
451 |
-
{
|
452 |
-
do_action( 'wpcf_admin_page_init' );
|
453 |
-
wp_enqueue_script( 'wpcf-form-validation',
|
454 |
-
WPCF_RES_RELPATH . '/js/'
|
455 |
-
. 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
|
456 |
-
WPCF_VERSION );
|
457 |
-
wp_enqueue_script( 'wpcf-form-validation-additional',
|
458 |
-
WPCF_RES_RELPATH . '/js/'
|
459 |
-
. 'jquery-form-validation/additional-methods.min.js',
|
460 |
-
array('jquery'), WPCF_VERSION );
|
461 |
-
add_action( 'admin_footer', 'wpcf_admin_tax_form_js_validation' );
|
462 |
-
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
|
463 |
-
require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
|
464 |
-
$form = wpcf_admin_custom_taxonomies_form();
|
465 |
-
wpcf_form( 'wpcf_form_tax', $form );
|
466 |
-
}
|
467 |
-
|
468 |
-
/**
|
469 |
-
* Menu page display.
|
470 |
-
*/
|
471 |
-
function wpcf_admin_menu_edit_tax()
|
472 |
-
{
|
473 |
-
if ( isset( $_GET['wpcf-tax'] ) ) {
|
474 |
-
$title = __( 'Edit Taxonomy', 'wpcf' );
|
475 |
-
/**
|
476 |
-
* add new CPT link
|
477 |
-
*/
|
478 |
-
$title .= sprintf(
|
479 |
-
'<a href="%s" class="add-new-h2">%s</a>',
|
480 |
-
add_query_arg( 'page', 'wpcf-edit-tax', admin_url('admin.php')),
|
481 |
-
__('Add New')
|
482 |
-
);
|
483 |
-
} else {
|
484 |
-
$title = __( 'Add New Taxonomy', 'wpcf' );
|
485 |
-
}
|
486 |
-
wpcf_add_admin_header( $title );
|
487 |
-
wpcf_wpml_warning();
|
488 |
-
$form = wpcf_form( 'wpcf_form_tax' );
|
489 |
-
echo '<br /><form method="post" action="" class="wpcf-tax-form '
|
490 |
-
. 'wpcf-form-validate">';
|
491 |
-
echo $form->renderForm();
|
492 |
-
echo '</form>';
|
493 |
-
wpcf_add_admin_footer();
|
494 |
-
}
|
495 |
-
|
496 |
-
/**
|
497 |
-
* Menu page hook.
|
498 |
-
*/
|
499 |
-
function wpcf_admin_menu_import_export_hook()
|
500 |
-
{
|
501 |
-
do_action( 'wpcf_admin_page_init' );
|
502 |
-
require_once WPCF_INC_ABSPATH . '/fields.php';
|
503 |
-
require_once WPCF_INC_ABSPATH . '/import-export.php';
|
504 |
-
if ( extension_loaded( 'simplexml' ) && isset( $_POST['export'] )
|
505 |
-
&& wp_verify_nonce( $_POST['_wpnonce'], 'wpcf_import' ) ) {
|
506 |
-
wpcf_admin_export_data();
|
507 |
-
die();
|
508 |
-
}
|
509 |
-
}
|
510 |
-
|
511 |
-
/**
|
512 |
-
* Menu page display.
|
513 |
-
*/
|
514 |
-
function wpcf_admin_menu_import_export()
|
515 |
-
{
|
516 |
-
wpcf_add_admin_header( __( 'Import/Export', 'wpcf' ) );
|
517 |
-
echo '<br /><form method="post" action="" class="wpcf-import-export-form '
|
518 |
-
. 'wpcf-form-validate" enctype="multipart/form-data">';
|
519 |
-
echo wpcf_form_simple( wpcf_admin_import_export_form() );
|
520 |
-
echo '</form>';
|
521 |
-
wpcf_add_admin_footer();
|
522 |
-
}
|
523 |
-
|
524 |
-
/**
|
525 |
-
* Menu page hook.
|
526 |
-
*/
|
527 |
-
function wpcf_admin_menu_custom_fields_control_hook()
|
528 |
-
{
|
529 |
-
do_action( 'wpcf_admin_page_init' );
|
530 |
-
add_action( 'admin_head', 'wpcf_admin_custom_fields_control_js' );
|
531 |
-
add_thickbox();
|
532 |
-
require_once WPCF_INC_ABSPATH . '/fields.php';
|
533 |
-
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
534 |
-
require_once WPCF_INC_ABSPATH . '/fields-control.php';
|
535 |
-
|
536 |
-
if ( isset( $_REQUEST['_wpnonce'] )
|
537 |
-
&& wp_verify_nonce( $_REQUEST['_wpnonce'],
|
538 |
-
'custom_fields_control_bulk' )
|
539 |
-
&& (isset( $_POST['action'] ) || isset( $_POST['action2'] )) && !empty( $_POST['fields'] ) ) {
|
540 |
-
$action = ( $_POST['action'] == '-1' ) ? sanitize_text_field( $_POST['action2'] ) : sanitize_text_field( $_POST['action'] );
|
541 |
-
wpcf_admin_custom_fields_control_bulk_actions( $action );
|
542 |
-
}
|
543 |
-
|
544 |
-
global $wpcf_control_table;
|
545 |
-
$wpcf_control_table = new WPCF_Custom_Fields_Control_Table( array(
|
546 |
-
'ajax' => true,
|
547 |
-
'singular' => __( 'Custom Field', 'wpcf' ),
|
548 |
-
'plural' => __( 'Custom Fields', 'wpcf' ),
|
549 |
-
) );
|
550 |
-
$wpcf_control_table->prepare_items();
|
551 |
-
}
|
552 |
-
|
553 |
-
/**
|
554 |
-
* Menu page display.
|
555 |
-
*/
|
556 |
-
function wpcf_admin_menu_custom_fields_control()
|
557 |
-
{
|
558 |
-
global $wpcf_control_table;
|
559 |
-
wpcf_add_admin_header( __( 'Custom Fields Control', 'wpcf' ) );
|
560 |
-
echo '<form method="post" action="" id="wpcf-custom-fields-control-form" class="wpcf-custom-fields-control-form '
|
561 |
-
. 'wpcf-form-validate" enctype="multipart/form-data">';
|
562 |
-
echo wpcf_admin_custom_fields_control_form( $wpcf_control_table );
|
563 |
-
wp_nonce_field( 'custom_fields_control_bulk' );
|
564 |
-
echo '</form>';
|
565 |
-
wpcf_add_admin_footer();
|
566 |
-
}
|
567 |
-
|
568 |
-
/**
|
569 |
-
* Menu page hook.
|
570 |
-
*/
|
571 |
-
function wpcf_admin_menu_migration_hook()
|
572 |
-
{
|
573 |
-
do_action( 'wpcf_admin_page_init' );
|
574 |
-
require_once WPCF_INC_ABSPATH . '/fields.php';
|
575 |
-
require_once WPCF_INC_ABSPATH . '/custom-types.php';
|
576 |
-
require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
|
577 |
-
require_once WPCF_INC_ABSPATH . '/migration.php';
|
578 |
-
$form = wpcf_admin_migration_form();
|
579 |
-
wpcf_form( 'wpcf_form_migration', $form );
|
580 |
-
}
|
581 |
-
|
582 |
-
/**
|
583 |
-
* Menu page display.
|
584 |
-
*/
|
585 |
-
function wpcf_admin_menu_migration()
|
586 |
-
{
|
587 |
-
wpcf_add_admin_header( __( 'Migration', 'wpcf' ) );
|
588 |
-
echo '<br /><form method="post" action="" id="wpcf-migration-form" class="wpcf-migration-form '
|
589 |
-
. 'wpcf-form-validate" enctype="multipart/form-data">';
|
590 |
-
$form = wpcf_form( 'wpcf_form_migration' );
|
591 |
-
echo $form->renderForm();
|
592 |
-
echo '</form>';
|
593 |
-
wpcf_add_admin_footer();
|
594 |
-
}
|
595 |
-
|
596 |
-
/**
|
597 |
-
* Menu page hook.
|
598 |
-
*/
|
599 |
-
function wpcf_admin_menu_settings_hook()
|
600 |
-
{
|
601 |
-
do_action( 'wpcf_admin_page_init' );
|
602 |
-
require_once WPCF_INC_ABSPATH . '/settings.php';
|
603 |
-
$form = wpcf_admin_image_settings_form();
|
604 |
-
wpcf_form( 'wpcf_form_image_settings', $form );
|
605 |
-
$form = wpcf_admin_general_settings_form();
|
606 |
-
wpcf_form( 'wpcf_form_general_settings', $form );
|
607 |
-
$form = wpcf_admin_toolset_messages_form();
|
608 |
-
wpcf_form( 'wpcf_form_toolset_messages', $form );
|
609 |
-
}
|
610 |
-
|
611 |
-
/**
|
612 |
-
* Menu page display.
|
613 |
-
*/
|
614 |
-
function wpcf_admin_menu_settings()
|
615 |
-
{
|
616 |
-
$show_toolset_messages = !WPCF_Types_Marketing_Messages::check_register();
|
617 |
-
ob_start();
|
618 |
-
wpcf_add_admin_header( __( 'Settings', 'wpcf' ) );
|
619 |
-
|
620 |
-
?>
|
621 |
-
<p style="font-weight: bold;"><?php
|
622 |
-
_e( 'This screen contains the Types settings for your site.', 'wpcf' );
|
623 |
-
|
624 |
-
?></p>
|
625 |
-
<ul class="horlist">
|
626 |
-
<li><a href="#types-image-settings"><?php _e( 'Image Settings', 'wpcf' ); ?></a></li>
|
627 |
-
<li><a href="#types-general-settings"><?php _e( 'General Setings', 'wpcf' ); ?></a></li>
|
628 |
-
<?php if ( $show_toolset_messages ) { ?><li><a href="#toolset-messages"><?php _e( 'Toolset Messages', 'wpcf' ); ?></a></li><?php } ?>
|
629 |
-
<li><a href="#debug"><?php _e( 'Debug Information', 'wpcf' ); ?></a></li>
|
630 |
-
</ul>
|
631 |
-
<br style='clear:both'/><br /><br />
|
632 |
-
<a id="types-image-settings"></a>
|
633 |
-
<table class="widefat" id="types_image_settings_table">
|
634 |
-
<thead>
|
635 |
-
<tr>
|
636 |
-
<th><?php
|
637 |
-
_e( 'Image 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-image-settings-form" class="wpcf-settings-form '
|
647 |
-
. 'wpcf-form-validate">';
|
648 |
-
$form = wpcf_form( 'wpcf_form_image_settings' );
|
649 |
-
echo $form->renderForm();
|
650 |
-
echo '</form>';
|
651 |
-
|
652 |
-
?>
|
653 |
-
</td>
|
654 |
-
</tr>
|
655 |
-
</tbody>
|
656 |
-
</table>
|
657 |
-
<br /><br />
|
658 |
-
<a id="types-general-settings"></a>
|
659 |
-
<table class="widefat" id="types_general_settings_table">
|
660 |
-
<thead>
|
661 |
-
<tr>
|
662 |
-
<th><?php
|
663 |
-
_e( 'General Settings', 'wpcf' );
|
664 |
-
|
665 |
-
?></th>
|
666 |
-
</tr>
|
667 |
-
</thead>
|
668 |
-
<tbody>
|
669 |
-
<tr>
|
670 |
-
<td>
|
671 |
-
<?php
|
672 |
-
echo '<br /><form method="post" action="" id="wpcf-general-settings-form" class="wpcf-settings-form '
|
673 |
-
. 'wpcf-form-validate">';
|
674 |
-
$form = wpcf_form( 'wpcf_form_general_settings' );
|
675 |
-
echo $form->renderForm();
|
676 |
-
echo '</form>';
|
677 |
-
?>
|
678 |
-
</td>
|
679 |
-
</tr>
|
680 |
-
</tbody>
|
681 |
-
</table>
|
682 |
-
<br /><br />
|
683 |
-
<?php
|
684 |
-
/**
|
685 |
-
* Toolset Messages
|
686 |
-
*/
|
687 |
-
if ( $show_toolset_messages ) {
|
688 |
-
?>
|
689 |
-
<a id="toolset-messages"></a>
|
690 |
-
<table class="widefat" id="toolset_messages">
|
691 |
-
<thead>
|
692 |
-
<tr>
|
693 |
-
<th><?php _e( 'Toolset Messages', 'wpcf' ); ?></th>
|
694 |
-
</tr>
|
695 |
-
</thead>
|
696 |
-
<tbody>
|
697 |
-
<tr>
|
698 |
-
<td>
|
699 |
-
<?php
|
700 |
-
echo '<br /><form method="post" action="" id="wpcf-toolset-messages-form" class="wpcf-settings-form '
|
701 |
-
. 'wpcf-form-validate">';
|
702 |
-
$form = wpcf_form( 'wpcf_form_toolset_messages' );
|
703 |
-
echo $form->renderForm();
|
704 |
-
echo '</form>';
|
705 |
-
?>
|
706 |
-
</td>
|
707 |
-
</tr>
|
708 |
-
</tbody>
|
709 |
-
</table>
|
710 |
-
<br /><br />
|
711 |
-
<?php } ?>
|
712 |
-
<?php
|
713 |
-
/**
|
714 |
-
* Debug Information
|
715 |
-
*/
|
716 |
-
?>
|
717 |
-
<a id="debug"></a>
|
718 |
-
<table class="widefat" id="debug_table">
|
719 |
-
<thead>
|
720 |
-
<tr>
|
721 |
-
<th><?php _e( 'Debug Information', 'wpcf' ); ?></th>
|
722 |
-
</tr>
|
723 |
-
</thead>
|
724 |
-
<tbody>
|
725 |
-
<tr>
|
726 |
-
<td>
|
727 |
-
<?php
|
728 |
-
printf(
|
729 |
-
__( 'For retrieving debug information if asked by a support person, use the <a href="%s">debug information</a> page.', 'wpcf' ),
|
730 |
-
admin_url('admin.php?page=wpcf-debug-information')
|
731 |
-
);
|
732 |
-
?>
|
733 |
-
</td>
|
734 |
-
</tr>
|
735 |
-
</tbody>
|
736 |
-
</table>
|
737 |
-
<?php
|
738 |
-
wpcf_add_admin_footer();
|
739 |
-
|
740 |
-
echo ob_get_clean();
|
741 |
-
}
|
742 |
-
|
743 |
-
/**
|
744 |
-
* Adds typical header on admin pages.
|
745 |
-
*
|
746 |
-
* @param string $title
|
747 |
-
* @param string $icon_id Custom icon
|
748 |
-
* @return string
|
749 |
-
*/
|
750 |
-
function wpcf_add_admin_header($title, $add_new = false, $add_new_title = false)
|
751 |
-
{
|
752 |
-
echo '<div class="wrap">';
|
753 |
-
echo '<h2>', $title;
|
754 |
-
if ( !$add_new_title ) {
|
755 |
-
$add_new_title = __('Add New', 'wpcf');
|
756 |
-
}
|
757 |
-
if ( $add_new ) {
|
758 |
-
printf(
|
759 |
-
' <a href="%s" class="add-new-h2">%s</a>',
|
760 |
-
add_query_arg( $add_new, admin_url('admin.php')),
|
761 |
-
$add_new_title
|
762 |
-
);
|
763 |
-
}
|
764 |
-
echo '</h2>';
|
765 |
-
$current_page = sanitize_text_field( $_GET['page'] );
|
766 |
-
do_action( 'wpcf_admin_header' );
|
767 |
-
do_action( 'wpcf_admin_header_' . $current_page );
|
768 |
-
}
|
769 |
-
|
770 |
-
/**
|
771 |
-
* Adds footer on admin pages.
|
772 |
-
*
|
773 |
-
* <b>Strongly recomended</b> if wpcf_add_admin_header() is called before.
|
774 |
-
* Otherwise invalid HTML formatting will occur.
|
775 |
-
*/
|
776 |
-
function wpcf_add_admin_footer()
|
777 |
-
{
|
778 |
-
$current_page = sanitize_text_field( $_GET['page'] );
|
779 |
-
do_action( 'wpcf_admin_footer_' . $current_page );
|
780 |
-
do_action( 'wpcf_admin_footer' );
|
781 |
-
echo '</div>';
|
782 |
-
}
|
783 |
-
|
784 |
-
/**
|
785 |
-
* Returns HTML formatted 'widefat' table.
|
786 |
-
*
|
787 |
-
* @param type $ID
|
788 |
-
* @param type $header
|
789 |
-
* @param type $rows
|
790 |
-
* @param type $empty_message
|
791 |
-
*/
|
792 |
-
function wpcf_admin_widefat_table( $ID, $header, $rows = array(), $empty_message = 'No results' )
|
793 |
-
{
|
794 |
-
if ( 'No results' == $empty_message ) {
|
795 |
-
$empty_message = __('No results', 'wpcf');
|
796 |
-
}
|
797 |
-
$head = '';
|
798 |
-
$footer = '';
|
799 |
-
foreach ( $header as $key => $value ) {
|
800 |
-
$head .= '<th id="wpcf-table-' . $key . '">' . $value . '</th>' . "\r\n";
|
801 |
-
$footer .= '<th>' . $value . '</th>' . "\r\n";
|
802 |
-
}
|
803 |
-
echo '<table id="' . $ID . '" class="widefat" cellspacing="0">
|
804 |
-
<thead>
|
805 |
-
<tr>
|
806 |
-
' . $head . '
|
807 |
-
</tr>
|
808 |
-
</thead>
|
809 |
-
<tfoot>
|
810 |
-
<tr>
|
811 |
-
' . $footer . '
|
812 |
-
</tr>
|
813 |
-
</tfoot>
|
814 |
-
<tbody>
|
815 |
-
';
|
816 |
-
$row = '';
|
817 |
-
if ( empty( $rows ) ) {
|
818 |
-
echo '<tr><td colspan="' . count( $header ) . '">' . $empty_message
|
819 |
-
. '</td></tr>';
|
820 |
-
} else {
|
821 |
-
$i = 0;
|
822 |
-
foreach ( $rows as $row ) {
|
823 |
-
$classes = array();
|
824 |
-
if ( $i++%2 ) {
|
825 |
-
$classes[] = 'alternate';
|
826 |
-
}
|
827 |
-
if ( isset($row['status']) && 'inactive' == $row['status'] ) {
|
828 |
-
$classes[] = sprintf('status-%s', $row['status']);
|
829 |
-
};
|
830 |
-
printf('<tr class="%s">', implode(' ', $classes ));
|
831 |
-
foreach ( $row as $column_name => $column_value ) {
|
832 |
-
if ( preg_match( '/^(status|raw_name)$/', $column_name )) {
|
833 |
-
continue;
|
834 |
-
}
|
835 |
-
echo '<td class="wpcf-table-column-' . $column_name . '">';
|
836 |
-
echo $column_value;
|
837 |
-
echo '</td>' . "\r\n";
|
838 |
-
}
|
839 |
-
echo '</tr>' . "\r\n";
|
840 |
-
}
|
841 |
-
}
|
842 |
-
echo '
|
843 |
-
</tbody>
|
844 |
-
</table>' . "\r\n";
|
845 |
-
}
|
846 |
-
|
847 |
-
/**
|
848 |
-
* Admin tabs.
|
849 |
-
*
|
850 |
-
* @param type $tabs
|
851 |
-
* @param type $page
|
852 |
-
* @param type $default
|
853 |
-
* @param type $current
|
854 |
-
* @return string
|
855 |
-
*/
|
856 |
-
function wpcf_admin_tabs($tabs, $page, $default = '', $current = '')
|
857 |
-
{
|
858 |
-
if ( empty( $current ) && isset( $_GET['tab'] ) ) {
|
859 |
-
$current = sanitize_text_field( $_GET['tab'] );
|
860 |
-
} else {
|
861 |
-
$current = $default;
|
862 |
-
}
|
863 |
-
$output = '<h2 class="nav-tab-wrapper">';
|
864 |
-
foreach ( $tabs as $tab => $name ) {
|
865 |
-
$class = ( $tab == $current ) ? ' nav-tab-active' : '';
|
866 |
-
$output .= "<a class='nav-tab$class' href='?page=$page&tab=$tab'>$name</a>";
|
867 |
-
}
|
868 |
-
$output .= '</h2>';
|
869 |
-
return $output;
|
870 |
-
}
|
871 |
-
|
872 |
-
/**
|
873 |
-
* Saves open fieldsets.
|
874 |
-
*
|
875 |
-
* @param type $action
|
876 |
-
* @param type $fieldset
|
877 |
-
*/
|
878 |
-
function wpcf_admin_form_fieldset_save_toggle($action, $fieldset)
|
879 |
-
{
|
880 |
-
$data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
|
881 |
-
true );
|
882 |
-
if ( $action == 'open' ) {
|
883 |
-
$data[$fieldset] = 1;
|
884 |
-
} elseif ( $action == 'close' ) {
|
885 |
-
unset( $data[$fieldset] );
|
886 |
-
}
|
887 |
-
update_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle', $data );
|
888 |
-
}
|
889 |
-
|
890 |
-
/**
|
891 |
-
* Check if fieldset is saved as open.
|
892 |
-
*
|
893 |
-
* @param type $fieldset
|
894 |
-
*/
|
895 |
-
function wpcf_admin_form_fieldset_is_collapsed($fieldset)
|
896 |
-
{
|
897 |
-
$data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
|
898 |
-
true );
|
899 |
-
if ( empty( $data ) ) {
|
900 |
-
return true;
|
901 |
-
}
|
902 |
-
return array_key_exists( $fieldset, $data ) ? false : true;
|
903 |
-
}
|
904 |
-
|
905 |
-
/**
|
906 |
-
* Adds help on admin pages.
|
907 |
-
*
|
908 |
-
* @param type $contextual_help
|
909 |
-
* @param type $screen_id
|
910 |
-
* @param type $screen
|
911 |
-
* @return type
|
912 |
-
*/
|
913 |
-
function wpcf_admin_plugin_help($hook, $page)
|
914 |
-
{
|
915 |
-
global $wp_version;
|
916 |
-
$call = false;
|
917 |
-
$contextual_help = '';
|
918 |
-
$page = $page;
|
919 |
-
if ( isset( $page ) && isset( $_GET['page'] ) && $_GET['page'] == $page ) {
|
920 |
-
switch ( $page ) {
|
921 |
-
case 'wpcf-cf':
|
922 |
-
$call = 'custom_fields';
|
923 |
-
break;
|
924 |
-
|
925 |
-
case 'wpcf-cpt':
|
926 |
-
case 'wpcf-ctt':
|
927 |
-
$call = 'custom_types_and_taxonomies';
|
928 |
-
break;
|
929 |
-
|
930 |
-
case 'wpcf-import-export':
|
931 |
-
$call = 'import_export';
|
932 |
-
break;
|
933 |
-
|
934 |
-
case 'wpcf-edit':
|
935 |
-
$call = 'edit_group';
|
936 |
-
break;
|
937 |
-
|
938 |
-
case 'wpcf-edit-type':
|
939 |
-
$call = 'edit_type';
|
940 |
-
break;
|
941 |
-
|
942 |
-
case 'wpcf-edit-tax':
|
943 |
-
$call = 'edit_tax';
|
944 |
-
break;
|
945 |
-
case 'wpcf':
|
946 |
-
$call = 'wpcf';
|
947 |
-
break;
|
948 |
-
}
|
949 |
-
}
|
950 |
-
if ( $call ) {
|
951 |
-
require_once WPCF_ABSPATH . '/help.php';
|
952 |
-
$contextual_help = wpcf_admin_help( $call, $contextual_help );
|
953 |
-
// WP 3.3 changes
|
954 |
-
if ( version_compare( $wp_version, '3.2.1', '>' ) ) {
|
955 |
-
set_current_screen( $hook );
|
956 |
-
$screen = get_current_screen();
|
957 |
-
if ( !is_null( $screen ) ) {
|
958 |
-
$args = array(
|
959 |
-
'title' => __( 'Types', 'wpcf' ),
|
960 |
-
'id' => 'wpcf',
|
961 |
-
'content' => $contextual_help,
|
962 |
-
'callback' => false,
|
963 |
);
|
964 |
-
$screen->add_help_tab( $args );
|
965 |
}
|
966 |
-
} else {
|
967 |
-
add_contextual_help( $hook, $contextual_help );
|
968 |
}
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
/**
|
973 |
-
* Promo texts
|
974 |
-
*
|
975 |
-
* @todo Move!
|
976 |
-
*/
|
977 |
-
function wpcf_admin_promotional_text()
|
978 |
-
{
|
979 |
-
$promo_tabs = get_option( '_wpcf_promo_tabs', false );
|
980 |
-
// random selection every one hour
|
981 |
-
if ( $promo_tabs ) {
|
982 |
-
$time = time();
|
983 |
-
$time_check = intval( $promo_tabs['time'] ) + 60 * 60;
|
984 |
-
if ( $time > $time_check ) {
|
985 |
-
$selected = mt_rand( 0, 3 );
|
986 |
-
$promo_tabs['selected'] = $selected;
|
987 |
-
$promo_tabs['time'] = $time;
|
988 |
-
update_option( '_wpcf_promo_tabs', $promo_tabs );
|
989 |
-
} else {
|
990 |
-
$selected = $promo_tabs['selected'];
|
991 |
}
|
992 |
-
|
993 |
-
$
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
if ( empty( $data['taxonomies'] ) ) {
|
1068 |
-
continue;
|
1069 |
-
}
|
1070 |
-
if ( array_key_exists( $arg, $data['taxonomies'] ) ) {
|
1071 |
-
unset( $custom[$post_type]['taxonomies'][$arg] );
|
1072 |
-
$custom[$post_type][TOOLSET_EDIT_LAST] = time();
|
1073 |
-
}
|
1074 |
-
}
|
1075 |
-
update_option( 'wpcf-custom-types', $custom );
|
1076 |
-
}
|
1077 |
-
break;
|
1078 |
-
|
1079 |
-
default:
|
1080 |
-
break;
|
1081 |
-
}
|
1082 |
}
|
1083 |
|
1084 |
/**
|
1085 |
-
*
|
1086 |
-
*
|
1087 |
-
* @param type $teasers
|
1088 |
*/
|
1089 |
-
function
|
1090 |
{
|
1091 |
-
|
1092 |
-
$file = WPCF_ABSPATH . '/plus/' . $teaser;
|
1093 |
-
if ( file_exists( $file ) ) {
|
1094 |
-
require_once $file;
|
1095 |
-
}
|
1096 |
-
}
|
1097 |
}
|
1098 |
|
1099 |
/**
|
1100 |
-
*
|
1101 |
-
*
|
1102 |
-
* @return
|
1103 |
*/
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1113 |
return $dir;
|
1114 |
}
|
1115 |
|
@@ -1133,37 +1016,6 @@ function wpcf_welcome_panel()
|
|
1133 |
</div>
|
1134 |
<?php
|
1135 |
}
|
1136 |
-
/**
|
1137 |
-
*
|
1138 |
-
*/
|
1139 |
-
|
1140 |
-
function wpcf_admin_enqueue_scripts($hook)
|
1141 |
-
{
|
1142 |
-
wp_register_script(
|
1143 |
-
'marketing-getting-started',
|
1144 |
-
plugin_dir_url( __FILE__ ).'/marketing/getting-started/assets/scripts/getting-started.js',
|
1145 |
-
array('jquery'),
|
1146 |
-
WPCF_VERSION,
|
1147 |
-
true
|
1148 |
-
);
|
1149 |
-
if ( preg_match( '@/marketing/getting-started/[^/]+.php$@', $hook ) ) {
|
1150 |
-
$marketing = new WPCF_Types_Marketing_Messages();
|
1151 |
-
wp_localize_script(
|
1152 |
-
'marketing-getting-started',
|
1153 |
-
'marketing_getting_started',
|
1154 |
-
array( 'id' => $marketing->get_option_name() )
|
1155 |
-
);
|
1156 |
-
wp_enqueue_script('marketing-getting-started');
|
1157 |
-
wp_enqueue_style(
|
1158 |
-
'marketing-getting-started',
|
1159 |
-
plugin_dir_url( __FILE__ ).'/marketing/getting-started/assets/css/getting-started.css',
|
1160 |
-
array(),
|
1161 |
-
WPCF_VERSION,
|
1162 |
-
'all'
|
1163 |
-
);
|
1164 |
-
}
|
1165 |
-
}
|
1166 |
-
|
1167 |
|
1168 |
/**
|
1169 |
* add types configuration to debug
|
@@ -1178,70 +1030,3 @@ function wpcf_get_extra_debug_info($extra_debug)
|
|
1178 |
add_action( 'wpcf_admin_header', 'wpcf_welcome_panel', PHP_INT_SIZE );
|
1179 |
add_filter( 'icl_get_extra_debug_info', 'wpcf_get_extra_debug_info' );
|
1180 |
|
1181 |
-
function wpcf_admin_add_submenu_page($menu, $menu_slug = null, $menu_parent = 'wpcf')
|
1182 |
-
{
|
1183 |
-
if ( !is_admin() ) {
|
1184 |
-
return;
|
1185 |
-
}
|
1186 |
-
$wpcf_capability = apply_filters( 'wpcf_capability', 'manage_options' );
|
1187 |
-
$menu_slug = array_key_exists('menu_slug', $menu)? $menu['menu_slug']:$menu_slug;
|
1188 |
-
/**
|
1189 |
-
* add submenu
|
1190 |
-
*/
|
1191 |
-
$hook = add_submenu_page(
|
1192 |
-
$menu_parent,
|
1193 |
-
isset($menu['page_title'])? $menu['page_title']:$menu['menu_title'],
|
1194 |
-
$menu['menu_title'],
|
1195 |
-
$wpcf_capability,
|
1196 |
-
$menu_slug,
|
1197 |
-
array_key_exists('function', $menu)? $menu['function']:null
|
1198 |
-
);
|
1199 |
-
if ( !empty($menu_slug) ) {
|
1200 |
-
wpcf_admin_plugin_help( $hook, $menu_slug );
|
1201 |
-
}
|
1202 |
-
/**
|
1203 |
-
* add action
|
1204 |
-
*/
|
1205 |
-
if ( !array_key_exists('load_hook', $menu) && array_key_exists('function', $menu) ) {
|
1206 |
-
$menu['load_hook'] = sprintf( '%s_hook', $menu['function'] );
|
1207 |
-
}
|
1208 |
-
if ( !empty($menu['load_hook']) && function_exists( $menu['load_hook'] ) ) {
|
1209 |
-
$action = sprintf(
|
1210 |
-
'load-%s',
|
1211 |
-
array_key_exists('hook', $menu)? $menu['hook']:$hook
|
1212 |
-
);
|
1213 |
-
add_action( $action, $menu['load_hook'] );
|
1214 |
-
}
|
1215 |
-
/**
|
1216 |
-
* add submenu to submenu
|
1217 |
-
*/
|
1218 |
-
if ( array_key_exists('submenu', $menu) ) {
|
1219 |
-
foreach( $menu['submenu'] as $submenu_slug => $submenu ) {
|
1220 |
-
wpcf_admin_add_submenu_page($submenu, $submenu_slug, $hook);
|
1221 |
-
}
|
1222 |
-
}
|
1223 |
-
return $hook;
|
1224 |
-
}
|
1225 |
-
|
1226 |
-
/**
|
1227 |
-
* sort helper for tables
|
1228 |
-
*/
|
1229 |
-
function wpcf_usort_reorder($a,$b)
|
1230 |
-
{
|
1231 |
-
$orderby = (!empty($_REQUEST['orderby'])) ? sanitize_text_field( $_REQUEST['orderby'] ) : 'title'; //If no sort, default to title
|
1232 |
-
$order = (!empty($_REQUEST['order'])) ? sanitize_text_field( $_REQUEST['order'] ) : 'asc'; //If no order, default to asc
|
1233 |
-
if ( ! in_array( $order, array( 'asc', 'desc' ) ) ) {
|
1234 |
-
$order = 'asc';
|
1235 |
-
}
|
1236 |
-
if ('title' == $orderby || !isset($a[$orderby])) {
|
1237 |
-
$orderby = 'slug';
|
1238 |
-
}
|
1239 |
-
$result = strcmp($a[$orderby], $b[$orderby]); //Determine sort order
|
1240 |
-
return ($order==='asc') ? $result : -$result; //Send final sort direction to usort
|
1241 |
-
}
|
1242 |
-
|
1243 |
-
add_filter('set-screen-option', 'wpcf_table_set_option', 10, 3);
|
1244 |
-
function wpcf_table_set_option($status, $option, $value)
|
1245 |
-
{
|
1246 |
-
return $value;
|
1247 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* Admin functions
|
5 |
+
*
|
6 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/admin.php $
|
7 |
+
* $LastChangedDate: 2014-08-12 04:19:36 +0200 (Tue, 12 Aug 2014) $
|
8 |
+
* $LastChangedRevision: 25849 $
|
9 |
+
* $LastChangedBy: bruce $
|
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 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* admin_menu hook.
|
43 |
+
*/
|
44 |
+
function wpcf_admin_menu_hook()
|
45 |
+
{
|
46 |
+
$wpcf_capability = apply_filters( 'wpcf_capability', 'manage_options' );
|
47 |
+
|
48 |
+
add_menu_page(
|
49 |
+
__( 'Types', 'wpcf' ),
|
50 |
+
__( 'Types', 'wpcf' ),
|
51 |
+
$wpcf_capability,
|
52 |
+
'wpcf',
|
53 |
+
'wpcf_admin_menu_summary',
|
54 |
+
'none'
|
55 |
+
);
|
56 |
+
|
57 |
+
$subpages = array(
|
58 |
+
|
59 |
+
// Custom types and tax
|
60 |
+
'wpcf-ctt' => array(
|
61 |
+
'page_title' => __( 'Custom Types and Taxonomies', 'wpcf' ),
|
62 |
+
'menu_title' => __( 'Types & Taxonomies', 'wpcf' ),
|
63 |
+
'function' => 'wpcf_admin_menu_summary_ctt',
|
64 |
+
),
|
65 |
+
|
66 |
+
// Custom fields
|
67 |
+
'wpcf-cf' => array(
|
68 |
+
'page_title' => __( 'Custom Fields', 'wpcf' ),
|
69 |
+
'menu_title' => __( 'Custom Fields', 'wpcf' ),
|
70 |
+
'function' => 'wpcf_admin_menu_summary',
|
71 |
+
),
|
72 |
+
// Custom Fields Control
|
73 |
+
'wpcf-custom-fields-control' => array(
|
74 |
+
'page_title' => __( 'Custom Fields Control', 'wpcf' ),
|
75 |
+
'menu_title' => __( 'Custom Fields Control', 'wpcf' ),
|
76 |
+
'function' => 'wpcf_admin_menu_custom_fields_control',
|
77 |
+
),
|
78 |
+
// User Meta
|
79 |
+
'wpcf-um' => array(
|
80 |
+
'page_title' => __( 'User Fields', 'wpcf' ),
|
81 |
+
'menu_title' => __( 'User Fields', 'wpcf' ),
|
82 |
+
'function' => 'wpcf_usermeta_summary',
|
83 |
+
'load-hook' => 'wpcf_admin_menu_summary_hook',
|
84 |
+
),
|
85 |
+
// User Fields Control
|
86 |
+
'wpcf-user-fields-control' => array(
|
87 |
+
'page_title' => __( 'User Fields Control', 'wpcf' ),
|
88 |
+
'menu_title' => __( 'User Fields Control', 'wpcf' ),
|
89 |
+
'function' => 'wpcf_admin_menu_user_fields_control',
|
90 |
+
),
|
91 |
+
|
92 |
+
// Import/Export
|
93 |
+
'wpcf-import-export' => array(
|
94 |
+
'page_title' => __( 'Import/Export', 'wpcf' ),
|
95 |
+
'menu_title' => __( 'Import/Export', 'wpcf' ),
|
96 |
+
'function' => 'wpcf_admin_menu_import_export',
|
97 |
+
),
|
98 |
+
// Settings
|
99 |
+
'wpcf-custom-settings' => array(
|
100 |
+
'page_title' => __( 'Settings', 'wpcf' ),
|
101 |
+
'menu_title' => __( 'Settings', 'wpcf' ),
|
102 |
+
'function' => 'wpcf_admin_menu_settings',
|
103 |
+
),
|
104 |
+
|
105 |
+
// Introduction
|
106 |
+
'wpcf-help' => array(
|
107 |
+
'page_title' => __( 'Help', 'wpcf' ),
|
108 |
+
'menu_title' => __( 'Help', 'wpcf' ),
|
109 |
+
'function' => 'wpcf_admin_menu_introduction',
|
110 |
+
'submenu' => array(
|
111 |
+
'wpcf-debug-information' => array(
|
112 |
+
'page_title' => __( 'Debug information', 'wpcf' ),
|
113 |
+
'menu_title' => __( 'Debug information', 'wpcf' ),
|
114 |
+
'function' => 'wpcf_admin_menu_debug_information',
|
115 |
+
),
|
|
|
|
|
|
|
|
|
|
|
116 |
),
|
117 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
+
foreach( $subpages as $menu_slug => $data ) {
|
122 |
+
$hook = add_submenu_page(
|
123 |
+
'wpcf',
|
124 |
+
$data['page_title'],
|
125 |
+
$data['menu_title'],
|
126 |
+
$wpcf_capability,
|
127 |
+
$menu_slug,
|
128 |
+
$data['function']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
);
|
130 |
+
if ( array_key_exists('submenu', $data ) ) {
|
131 |
+
foreach( $data['submenu'] as $submenu_slug => $submenu ) {
|
132 |
+
add_submenu_page(
|
133 |
+
$hook,
|
134 |
+
$submenu['page_title'],
|
135 |
+
$submenu['menu_title'],
|
136 |
+
$wpcf_capability,
|
137 |
+
$submenu_slug,
|
138 |
+
$submenu['function']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
);
|
|
|
140 |
}
|
|
|
|
|
141 |
}
|
142 |
+
if ( !array_key_exists('load-hook', $data ) ) {
|
143 |
+
$data['load-hook'] = sprintf( '%s_hook', $data['function'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
}
|
145 |
+
wpcf_admin_plugin_help( $hook, $menu_slug );
|
146 |
+
add_action( 'load-' . $hook, $data['load-hook'] );
|
147 |
+
}
|
148 |
+
|
149 |
+
if ( isset( $_GET['page'] ) ) {
|
150 |
+
switch ( $_GET['page'] ) {
|
151 |
+
case 'wpcf-edit':
|
152 |
+
$title = isset( $_GET['group_id'] ) ? __( 'Edit Group', 'wpcf' ) : __( 'Add New Group',
|
153 |
+
'wpcf' );
|
154 |
+
$hook = add_submenu_page( 'wpcf', $title, $title,
|
155 |
+
'manage_options', 'wpcf-edit',
|
156 |
+
'wpcf_admin_menu_edit_fields' );
|
157 |
+
add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_fields_hook' );
|
158 |
+
wpcf_admin_plugin_help( $hook, 'wpcf-edit' );
|
159 |
+
break;
|
160 |
+
|
161 |
+
case 'wpcf-edit-type':
|
162 |
+
$title = isset( $_GET['wpcf-post-type'] ) ? __( 'Edit Custom Post Type',
|
163 |
+
'wpcf' ) : __( 'Add New Custom Post Type',
|
164 |
+
'wpcf' );
|
165 |
+
$hook = add_submenu_page( 'wpcf', $title, $title,
|
166 |
+
'manage_options', 'wpcf-edit-type',
|
167 |
+
'wpcf_admin_menu_edit_type' );
|
168 |
+
add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_type_hook' );
|
169 |
+
wpcf_admin_plugin_help( $hook, 'wpcf-edit-type' );
|
170 |
+
break;
|
171 |
+
|
172 |
+
case 'wpcf-edit-tax':
|
173 |
+
$title = isset( $_GET['wpcf-tax'] ) ? __( 'Edit Taxonomy',
|
174 |
+
'wpcf' ) : __( 'Add New Taxonomy', 'wpcf' );
|
175 |
+
$hook = add_submenu_page( 'wpcf', $title, $title,
|
176 |
+
'manage_options', 'wpcf-edit-tax',
|
177 |
+
'wpcf_admin_menu_edit_tax' );
|
178 |
+
add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_tax_hook' );
|
179 |
+
wpcf_admin_plugin_help( $hook, 'wpcf-edit-tax' );
|
180 |
+
break;
|
181 |
+
case 'wpcf-edit-usermeta':
|
182 |
+
$title = isset( $_GET['group_id'] ) ? __( 'Edit User Fields Group', 'wpcf' ) : __( 'Add New User Fields Group',
|
183 |
+
'wpcf' );
|
184 |
+
$hook = add_submenu_page( 'wpcf', $title, $title,
|
185 |
+
'manage_options', 'wpcf-edit-usermeta',
|
186 |
+
'wpcf_admin_menu_edit_user_fields' );
|
187 |
+
add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_user_fields_hook' );
|
188 |
+
wpcf_admin_plugin_help( $hook, 'wpcf-edit-usermeta' );
|
189 |
+
break;
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
// Check if migration from other plugin is needed
|
194 |
+
if ( class_exists( 'Acf' ) || defined( 'CPT_VERSION' ) ) {
|
195 |
+
$hook = add_submenu_page( 'wpcf', __( 'Migration', 'wpcf' ),
|
196 |
+
__( 'Migration', 'wpcf' ), 'manage_options', 'wpcf-migration',
|
197 |
+
'wpcf_admin_menu_migration' );
|
198 |
+
add_action( 'load-' . $hook, 'wpcf_admin_menu_migration_hook' );
|
199 |
+
wpcf_admin_plugin_help( $hook, 'wpcf-migration' );
|
200 |
+
}
|
201 |
+
|
202 |
+
do_action( 'wpcf_menu_plus' );
|
203 |
+
|
204 |
+
// remove the repeating Types submenu
|
205 |
+
remove_submenu_page( 'wpcf', 'wpcf' );
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Menu page hook.
|
210 |
+
*/
|
211 |
+
function wpcf_admin_menu_introduction_hook() {
|
212 |
+
do_action( 'wpcf_admin_page_init' );
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Menu page display.
|
217 |
+
*/
|
218 |
+
function wpcf_admin_menu_introduction() {
|
219 |
+
require_once WPCF_INC_ABSPATH . '/introduction.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
}
|
221 |
|
222 |
/**
|
223 |
+
* Menu page hook.
|
|
|
|
|
224 |
*/
|
225 |
+
function wpcf_admin_menu_debug_information()
|
226 |
{
|
227 |
+
require_once WPCF_EMBEDDED_ABSPATH.'/common/debug/debug-information.php';
|
|
|
|
|
|
|
|
|
|
|
228 |
}
|
229 |
|
230 |
/**
|
231 |
+
* Menu page hook.
|
|
|
|
|
232 |
*/
|
233 |
+
function wpcf_admin_menu_summary_hook() {
|
234 |
+
do_action( 'wpcf_admin_page_init' );
|
235 |
+
wpcf_admin_load_collapsible();
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Menu page display.
|
240 |
+
*/
|
241 |
+
function wpcf_admin_menu_summary() {
|
242 |
+
echo wpcf_add_admin_header( __( 'Custom Fields', 'wpcf' ) );
|
243 |
+
require_once WPCF_INC_ABSPATH . '/fields.php';
|
244 |
+
require_once WPCF_INC_ABSPATH . '/fields-list.php';
|
245 |
+
$to_display = wpcf_admin_fields_get_fields();
|
246 |
+
if ( !empty( $to_display ) ) {
|
247 |
+
add_action( 'wpcf_groups_list_table_after',
|
248 |
+
'wpcf_admin_promotional_text' );
|
249 |
+
}
|
250 |
+
wpcf_admin_fields_list();
|
251 |
+
echo wpcf_add_admin_footer();
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Menu page hook.
|
256 |
+
*/
|
257 |
+
function wpcf_admin_menu_edit_fields_hook() {
|
258 |
+
do_action( 'wpcf_admin_page_init' );
|
259 |
+
|
260 |
+
/*
|
261 |
+
* Enqueue scripts
|
262 |
+
*/
|
263 |
+
// Group filter
|
264 |
+
wp_enqueue_script( 'wpcf-filter-js',
|
265 |
+
WPCF_EMBEDDED_RES_RELPATH
|
266 |
+
. '/js/custom-fields-form-filter.js', array('jquery'), WPCF_VERSION );
|
267 |
+
// Form
|
268 |
+
wp_enqueue_script( 'wpcf-form-validation',
|
269 |
+
WPCF_EMBEDDED_RES_RELPATH . '/js/'
|
270 |
+
. 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
|
271 |
+
WPCF_VERSION );
|
272 |
+
wp_enqueue_script( 'wpcf-form-validation-additional',
|
273 |
+
WPCF_EMBEDDED_RES_RELPATH . '/js/'
|
274 |
+
. 'jquery-form-validation/additional-methods.min.js',
|
275 |
+
array('jquery'), WPCF_VERSION );
|
276 |
+
// Scroll
|
277 |
+
wp_enqueue_script( 'wpcf-scrollbar',
|
278 |
+
WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/scrollbar.js',
|
279 |
+
array('jquery') );
|
280 |
+
wp_enqueue_script( 'wpcf-mousewheel',
|
281 |
+
WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/mousewheel.js',
|
282 |
+
array('wpcf-scrollbar') );
|
283 |
+
// MAIN
|
284 |
+
wp_enqueue_script( 'wpcf-fields-form',
|
285 |
+
WPCF_EMBEDDED_RES_RELPATH
|
286 |
+
. '/js/fields-form.js', array('wpcf-js') );
|
287 |
+
|
288 |
+
/*
|
289 |
+
* Enqueue styles
|
290 |
+
*/
|
291 |
+
wp_enqueue_style( 'wpcf-scroll',
|
292 |
+
WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/css/scroll.css' );
|
293 |
+
|
294 |
+
//Css editor
|
295 |
+
wp_enqueue_script( 'wpcf-form-codemirror' ,
|
296 |
+
WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.js', array('wpcf-js'));
|
297 |
+
wp_enqueue_script( 'wpcf-form-codemirror-css-editor' ,
|
298 |
+
WPCF_RELPATH . '/resources/js/codemirror234/mode/css/css.js', array('wpcf-js'));
|
299 |
+
wp_enqueue_script( 'wpcf-form-codemirror-html-editor' ,
|
300 |
+
WPCF_RELPATH . '/resources/js/codemirror234/mode/xml/xml.js', array('wpcf-js'));
|
301 |
+
wp_enqueue_script( 'wpcf-form-codemirror-html-editor2' ,
|
302 |
+
WPCF_RELPATH . '/resources/js/codemirror234/mode/htmlmixed/htmlmixed.js', array('wpcf-js'));
|
303 |
+
wp_enqueue_script( 'wpcf-form-codemirror-editor-resize' ,
|
304 |
+
WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.resizable.min.js', array('wpcf-js'));
|
305 |
+
|
306 |
+
|
307 |
+
|
308 |
+
wp_enqueue_style( 'wpcf-css-editor',
|
309 |
+
WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.css' );
|
310 |
+
wp_enqueue_style( 'wpcf-css-editor-resize',
|
311 |
+
WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.theme.min.css' );
|
312 |
+
wp_enqueue_style( 'wpcf-usermeta',
|
313 |
+
WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css' );
|
314 |
+
|
315 |
+
add_action( 'admin_footer', 'wpcf_admin_fields_form_js_validation' );
|
316 |
+
require_once WPCF_INC_ABSPATH . '/fields.php';
|
317 |
+
require_once WPCF_INC_ABSPATH . '/fields-form.php';
|
318 |
+
$form = wpcf_admin_fields_form();
|
319 |
+
wpcf_form( 'wpcf_form_fields', $form );
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Menu page display.
|
324 |
+
*/
|
325 |
+
function wpcf_admin_menu_edit_fields() {
|
326 |
+
if ( isset( $_GET['group_id'] ) ) {
|
327 |
+
$title = __( 'Edit Group', 'wpcf' );
|
328 |
+
} else {
|
329 |
+
$title = __( 'Add New Group', 'wpcf' );
|
330 |
+
}
|
331 |
+
echo wpcf_add_admin_header( $title );
|
332 |
+
wpcf_wpml_warning();
|
333 |
+
$form = wpcf_form( 'wpcf_form_fields' );
|
334 |
+
|
335 |
+
?>
|
336 |
+
<script type="text/javascript">
|
337 |
+
function wpcf_group_submit() {
|
338 |
+
if (jQuery('#wpcf-group-name').val() == 'Enter group title') {
|
339 |
+
jQuery('#wpcf-group-name').val('');
|
340 |
+
}
|
341 |
+
if (jQuery('#wpcf-group-description').val() == 'Enter a description for this group') {
|
342 |
+
jQuery('#wpcf-group-description').val('');
|
343 |
+
}
|
344 |
+
jQuery('.wpcf-forms-set-legend').each(function(){
|
345 |
+
if (jQuery(this).val() == 'Enter field name') {
|
346 |
+
jQuery(this).val('');
|
347 |
+
}
|
348 |
+
if (jQuery(this).next().val() == 'Enter field slug') {
|
349 |
+
jQuery(this).next().val('');
|
350 |
+
}
|
351 |
+
if (jQuery(this).next().next().val() == 'Describe this field') {
|
352 |
+
jQuery(this).next().next().val('');
|
353 |
+
}
|
354 |
+
});
|
355 |
+
}
|
356 |
+
</script>
|
357 |
+
|
358 |
+
<br /><form method="post" action="" class="wpcf-fields-form wpcf-form-validate" onsubmit="wpcf_group_submit()">
|
359 |
+
<?php echo $form->renderForm(); ?>
|
360 |
+
</form>
|
361 |
+
<?php
|
362 |
+
echo wpcf_add_admin_footer();
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Menu page hook.
|
367 |
+
*/
|
368 |
+
function wpcf_admin_menu_summary_ctt_hook() {
|
369 |
+
do_action( 'wpcf_admin_page_init' );
|
370 |
+
wp_enqueue_style( 'wpcf-promo-tabs', WPCF_RES_RELPATH . '/css/tabs.css',
|
371 |
+
array(), WPCF_VERSION );
|
372 |
+
wpcf_admin_load_collapsible();
|
373 |
+
require_once WPCF_INC_ABSPATH . '/custom-types.php';
|
374 |
+
require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
|
375 |
+
require_once WPCF_INC_ABSPATH . '/custom-types-taxonomies-list.php';
|
376 |
+
}
|
377 |
+
|
378 |
+
/**
|
379 |
+
* Menu page display.
|
380 |
+
*/
|
381 |
+
function wpcf_admin_menu_summary_ctt() {
|
382 |
+
echo wpcf_add_admin_header( __( 'Custom Post Types and Taxonomies', 'wpcf' ) );
|
383 |
+
$to_display_posts = get_option( 'wpcf-custom-types', array() );
|
384 |
+
$to_display_tax = get_option( 'wpcf-custom-taxonomies', array() );
|
385 |
+
if ( !empty( $to_display_posts ) || !empty( $to_display_tax ) ) {
|
386 |
+
add_action( 'wpcf_types_tax_list_table_after',
|
387 |
+
'wpcf_admin_promotional_text' );
|
388 |
+
}
|
389 |
+
wpcf_admin_ctt_list();
|
390 |
+
echo wpcf_add_admin_footer();
|
391 |
+
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Menu page hook.
|
395 |
+
*/
|
396 |
+
function wpcf_admin_menu_edit_type_hook() {
|
397 |
+
do_action( 'wpcf_admin_page_init' );
|
398 |
+
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-types.php';
|
399 |
+
require_once WPCF_INC_ABSPATH . '/custom-types-form.php';
|
400 |
+
require_once WPCF_INC_ABSPATH . '/post-relationship.php';
|
401 |
+
wp_enqueue_script( 'wpcf-custom-types-form',
|
402 |
+
WPCF_RES_RELPATH . '/js/'
|
403 |
+
. 'custom-types-form.js', array('jquery'), WPCF_VERSION );
|
404 |
+
wp_enqueue_script( 'wpcf-form-validation',
|
405 |
+
WPCF_RES_RELPATH . '/js/'
|
406 |
+
. 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
|
407 |
+
WPCF_VERSION );
|
408 |
+
wp_enqueue_script( 'wpcf-form-validation-additional',
|
409 |
+
WPCF_RES_RELPATH . '/js/'
|
410 |
+
. 'jquery-form-validation/additional-methods.min.js',
|
411 |
+
array('jquery'), WPCF_VERSION );
|
412 |
+
add_action( 'admin_footer', 'wpcf_admin_types_form_js_validation' );
|
413 |
+
wpcf_post_relationship_init();
|
414 |
+
$form = wpcf_admin_custom_types_form();
|
415 |
+
wpcf_form( 'wpcf_form_types', $form );
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Menu page display.
|
420 |
+
*/
|
421 |
+
function wpcf_admin_menu_edit_type() {
|
422 |
+
if ( isset( $_GET['wpcf-post-type'] ) ) {
|
423 |
+
$title = __( 'Edit Custom Post Type', 'wpcf' );
|
424 |
+
} else {
|
425 |
+
$title = __( 'Add New Custom Post Type', 'wpcf' );
|
426 |
+
}
|
427 |
+
echo wpcf_add_admin_header( $title );
|
428 |
+
wpcf_wpml_warning();
|
429 |
+
$form = wpcf_form( 'wpcf_form_types' );
|
430 |
+
echo '<br /><form method="post" action="" class="wpcf-types-form '
|
431 |
+
. 'wpcf-form-validate">';
|
432 |
+
echo $form->renderForm();
|
433 |
+
echo '</form>';
|
434 |
+
echo wpcf_add_admin_footer();
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Menu page hook.
|
439 |
+
*/
|
440 |
+
function wpcf_admin_menu_edit_tax_hook() {
|
441 |
+
do_action( 'wpcf_admin_page_init' );
|
442 |
+
wp_enqueue_script( 'wpcf-form-validation',
|
443 |
+
WPCF_RES_RELPATH . '/js/'
|
444 |
+
. 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
|
445 |
+
WPCF_VERSION );
|
446 |
+
wp_enqueue_script( 'wpcf-form-validation-additional',
|
447 |
+
WPCF_RES_RELPATH . '/js/'
|
448 |
+
. 'jquery-form-validation/additional-methods.min.js',
|
449 |
+
array('jquery'), WPCF_VERSION );
|
450 |
+
add_action( 'admin_footer', 'wpcf_admin_tax_form_js_validation' );
|
451 |
+
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
|
452 |
+
require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
|
453 |
+
$form = wpcf_admin_custom_taxonomies_form();
|
454 |
+
wpcf_form( 'wpcf_form_tax', $form );
|
455 |
+
}
|
456 |
+
|
457 |
+
/**
|
458 |
+
* Menu page display.
|
459 |
+
*/
|
460 |
+
function wpcf_admin_menu_edit_tax() {
|
461 |
+
if ( isset( $_GET['wpcf-tax'] ) ) {
|
462 |
+
$title = __( 'Edit Taxonomy', 'wpcf' );
|
463 |
+
} else {
|
464 |
+
$title = __( 'Add New Taxonomy', 'wpcf' );
|
465 |
+
}
|
466 |
+
echo wpcf_add_admin_header( $title );
|
467 |
+
wpcf_wpml_warning();
|
468 |
+
$form = wpcf_form( 'wpcf_form_tax' );
|
469 |
+
echo '<br /><form method="post" action="" class="wpcf-tax-form '
|
470 |
+
. 'wpcf-form-validate">';
|
471 |
+
echo $form->renderForm();
|
472 |
+
echo '</form>';
|
473 |
+
echo wpcf_add_admin_footer();
|
474 |
+
}
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Menu page hook.
|
478 |
+
*/
|
479 |
+
function wpcf_admin_menu_import_export_hook() {
|
480 |
+
do_action( 'wpcf_admin_page_init' );
|
481 |
+
require_once WPCF_INC_ABSPATH . '/fields.php';
|
482 |
+
require_once WPCF_INC_ABSPATH . '/import-export.php';
|
483 |
+
if ( extension_loaded( 'simplexml' ) && isset( $_POST['export'] )
|
484 |
+
&& wp_verify_nonce( $_POST['_wpnonce'], 'wpcf_import' ) ) {
|
485 |
+
wpcf_admin_export_data();
|
486 |
+
die();
|
487 |
+
}
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* Menu page display.
|
492 |
+
*/
|
493 |
+
function wpcf_admin_menu_import_export() {
|
494 |
+
echo wpcf_add_admin_header( __( 'Import/Export', 'wpcf' ) );
|
495 |
+
echo '<br /><form method="post" action="" class="wpcf-import-export-form '
|
496 |
+
. 'wpcf-form-validate" enctype="multipart/form-data">';
|
497 |
+
echo wpcf_form_simple( wpcf_admin_import_export_form() );
|
498 |
+
echo '</form>';
|
499 |
+
echo wpcf_add_admin_footer();
|
500 |
+
}
|
501 |
+
|
502 |
+
/**
|
503 |
+
* Menu page hook.
|
504 |
+
*/
|
505 |
+
function wpcf_admin_menu_custom_fields_control_hook() {
|
506 |
+
do_action( 'wpcf_admin_page_init' );
|
507 |
+
add_action( 'admin_head', 'wpcf_admin_custom_fields_control_js' );
|
508 |
+
add_thickbox();
|
509 |
+
require_once WPCF_INC_ABSPATH . '/fields.php';
|
510 |
+
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
|
511 |
+
require_once WPCF_INC_ABSPATH . '/fields-control.php';
|
512 |
+
|
513 |
+
if ( isset( $_REQUEST['_wpnonce'] )
|
514 |
+
&& wp_verify_nonce( $_REQUEST['_wpnonce'],
|
515 |
+
'custom_fields_control_bulk' )
|
516 |
+
&& (isset( $_POST['action'] ) || isset( $_POST['action2'] )) && !empty( $_POST['fields'] ) ) {
|
517 |
+
$action = $_POST['action'] == '-1' ? $_POST['action2'] : $_POST['action'];
|
518 |
+
wpcf_admin_custom_fields_control_bulk_actions( $action );
|
519 |
+
}
|
520 |
+
|
521 |
+
global $wpcf_control_table;
|
522 |
+
$wpcf_control_table = new WPCF_Custom_Fields_Control_Table( array(
|
523 |
+
'ajax' => true,
|
524 |
+
'singular' => __( 'Custom Field', 'wpcf' ),
|
525 |
+
'plural' => __( 'Custom Fields', 'wpcf' ),
|
526 |
+
) );
|
527 |
+
$wpcf_control_table->prepare_items();
|
528 |
+
}
|
529 |
+
|
530 |
+
/**
|
531 |
+
* Menu page display.
|
532 |
+
*/
|
533 |
+
function wpcf_admin_menu_custom_fields_control() {
|
534 |
+
global $wpcf_control_table;
|
535 |
+
echo wpcf_add_admin_header( __( 'Custom Fields Control', 'wpcf' ) );
|
536 |
+
echo '<form method="post" action="" id="wpcf-custom-fields-control-form" class="wpcf-custom-fields-control-form '
|
537 |
+
. 'wpcf-form-validate" enctype="multipart/form-data">';
|
538 |
+
echo wpcf_admin_custom_fields_control_form( $wpcf_control_table );
|
539 |
+
wp_nonce_field( 'custom_fields_control_bulk' );
|
540 |
+
echo '</form>';
|
541 |
+
echo wpcf_add_admin_footer();
|
542 |
+
}
|
543 |
+
|
544 |
+
/**
|
545 |
+
* Menu page hook.
|
546 |
+
*/
|
547 |
+
function wpcf_admin_menu_migration_hook() {
|
548 |
+
do_action( 'wpcf_admin_page_init' );
|
549 |
+
require_once WPCF_INC_ABSPATH . '/fields.php';
|
550 |
+
require_once WPCF_INC_ABSPATH . '/custom-types.php';
|
551 |
+
require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
|
552 |
+
require_once WPCF_INC_ABSPATH . '/migration.php';
|
553 |
+
$form = wpcf_admin_migration_form();
|
554 |
+
wpcf_form( 'wpcf_form_migration', $form );
|
555 |
+
}
|
556 |
+
|
557 |
+
/**
|
558 |
+
* Menu page display.
|
559 |
+
*/
|
560 |
+
function wpcf_admin_menu_migration() {
|
561 |
+
echo wpcf_add_admin_header( __( 'Migration', 'wpcf' ) );
|
562 |
+
echo '<br /><form method="post" action="" id="wpcf-migration-form" class="wpcf-migration-form '
|
563 |
+
. 'wpcf-form-validate" enctype="multipart/form-data">';
|
564 |
+
$form = wpcf_form( 'wpcf_form_migration' );
|
565 |
+
echo $form->renderForm();
|
566 |
+
echo '</form>';
|
567 |
+
echo wpcf_add_admin_footer();
|
568 |
+
}
|
569 |
+
|
570 |
+
/**
|
571 |
+
* Menu page hook.
|
572 |
+
*/
|
573 |
+
function wpcf_admin_menu_settings_hook() {
|
574 |
+
do_action( 'wpcf_admin_page_init' );
|
575 |
+
require_once WPCF_INC_ABSPATH . '/settings.php';
|
576 |
+
$form = wpcf_admin_image_settings_form();
|
577 |
+
wpcf_form( 'wpcf_form_image_settings', $form );
|
578 |
+
$form = wpcf_admin_general_settings_form();
|
579 |
+
wpcf_form( 'wpcf_form_general_settings', $form );
|
580 |
+
}
|
581 |
+
|
582 |
+
/**
|
583 |
+
* Menu page display.
|
584 |
+
*/
|
585 |
+
function wpcf_admin_menu_settings() {
|
586 |
+
ob_start();
|
587 |
+
echo wpcf_add_admin_header( __( 'Settings', 'wpcf' ) );
|
588 |
+
|
589 |
+
?>
|
590 |
+
<p style="font-weight: bold;"><?php
|
591 |
+
_e( 'This screen contains the Types settings for your site.', 'wpcf' );
|
592 |
+
|
593 |
+
?></p>
|
594 |
+
<ul class="horlist">
|
595 |
+
<li><a href="#types-image-settings"><?php
|
596 |
+
_e( 'Image Settings', 'wpcf' );
|
597 |
+
|
598 |
+
?></a></li>
|
599 |
+
<li><a href="#types-general-settings"><?php
|
600 |
+
_e( 'General Setings', 'wpcf' );
|
601 |
+
|
602 |
+
?></a></li>
|
603 |
+
</ul>
|
604 |
+
<br style='clear:both'/><br /><br />
|
605 |
+
<a id="types-image-settings"></a>
|
606 |
+
<table class="widefat" id="types_image_settings_table">
|
607 |
+
<thead>
|
608 |
+
<tr>
|
609 |
+
<th><?php
|
610 |
+
_e( 'Image Settings', 'wpcf' );
|
611 |
+
|
612 |
+
?></th>
|
613 |
+
</tr>
|
614 |
+
</thead>
|
615 |
+
<tbody>
|
616 |
+
<tr>
|
617 |
+
<td>
|
618 |
+
<?php
|
619 |
+
echo '<br /><form method="post" action="" id="wpcf-image-settings-form" class="wpcf-settings-form '
|
620 |
+
. 'wpcf-form-validate">';
|
621 |
+
$form = wpcf_form( 'wpcf_form_image_settings' );
|
622 |
+
echo $form->renderForm();
|
623 |
+
echo '</form>';
|
624 |
+
|
625 |
+
?>
|
626 |
+
</td>
|
627 |
+
</tr>
|
628 |
+
</tbody>
|
629 |
+
</table>
|
630 |
+
<br /><br />
|
631 |
+
<a id="types-general-settings"></a>
|
632 |
+
<table class="widefat" id="types_general_settings_table">
|
633 |
+
<thead>
|
634 |
+
<tr>
|
635 |
+
<th><?php
|
636 |
+
_e( 'General Settings', 'wpcf' );
|
637 |
+
|
638 |
+
?></th>
|
639 |
+
</tr>
|
640 |
+
</thead>
|
641 |
+
<tbody>
|
642 |
+
<tr>
|
643 |
+
<td>
|
644 |
+
<?php
|
645 |
+
echo '<br /><form method="post" action="" id="wpcf-general-settings-form" class="wpcf-settings-form '
|
646 |
+
. 'wpcf-form-validate">';
|
647 |
+
$form = wpcf_form( 'wpcf_form_general_settings' );
|
648 |
+
echo $form->renderForm();
|
649 |
+
echo '</form>';
|
650 |
+
|
651 |
+
?>
|
652 |
+
</td>
|
653 |
+
</tr>
|
654 |
+
</tbody>
|
655 |
+
</table>
|
656 |
+
<?php
|
657 |
+
echo wpcf_add_admin_footer();
|
658 |
+
|
659 |
+
echo ob_get_clean();
|
660 |
+
}
|
661 |
+
|
662 |
+
/**
|
663 |
+
* Adds typical header on admin pages.
|
664 |
+
*
|
665 |
+
* @param string $title
|
666 |
+
* @param string $icon_id Custom icon
|
667 |
+
* @return string
|
668 |
+
*/
|
669 |
+
function wpcf_add_admin_header( $title, $icon_id = 'icon-wpcf' )
|
670 |
+
{
|
671 |
+
global $wp_version;
|
672 |
+
if ( version_compare( '3.8', $wp_version ) ) {
|
673 |
+
echo PHP_EOL;
|
674 |
+
printf('<div class="wrap"><div id="%s" class="icon32"><br /></div>', $icon_id );
|
675 |
+
}
|
676 |
+
printf('<h2>%s</h2>', $title );
|
677 |
+
do_action( 'wpcf_admin_header' );
|
678 |
+
do_action( 'wpcf_admin_header_' . $_GET['page'] );
|
679 |
+
}
|
680 |
+
|
681 |
+
/**
|
682 |
+
* Adds footer on admin pages.
|
683 |
+
*
|
684 |
+
* <b>Strongly recomended</b> if wpcf_add_admin_header() is called before.
|
685 |
+
* Otherwise invalid HTML formatting will occur.
|
686 |
+
*/
|
687 |
+
function wpcf_add_admin_footer() {
|
688 |
+
do_action( 'wpcf_admin_footer_' . $_GET['page'] );
|
689 |
+
do_action( 'wpcf_admin_footer' );
|
690 |
+
echo "\r\n" . '</div>' . "\r\n";
|
691 |
+
}
|
692 |
+
|
693 |
+
/**
|
694 |
+
* Returns HTML formatted 'widefat' table.
|
695 |
+
*
|
696 |
+
* @param type $ID
|
697 |
+
* @param type $header
|
698 |
+
* @param type $rows
|
699 |
+
* @param type $empty_message
|
700 |
+
*/
|
701 |
+
function wpcf_admin_widefat_table( $ID, $header, $rows = array(),
|
702 |
+
$empty_message = 'No results' ) {
|
703 |
+
$head = '';
|
704 |
+
$footer = '';
|
705 |
+
foreach ( $header as $key => $value ) {
|
706 |
+
$head .= '<th id="wpcf-table-' . $key . '">' . $value . '</th>' . "\r\n";
|
707 |
+
$footer .= '<th>' . $value . '</th>' . "\r\n";
|
708 |
+
}
|
709 |
+
echo '<table id="' . $ID . '" class="widefat" cellspacing="0">
|
710 |
+
<thead>
|
711 |
+
<tr>
|
712 |
+
' . $head . '
|
713 |
+
</tr>
|
714 |
+
</thead>
|
715 |
+
<tfoot>
|
716 |
+
<tr>
|
717 |
+
' . $footer . '
|
718 |
+
</tr>
|
719 |
+
</tfoot>
|
720 |
+
<tbody>
|
721 |
+
';
|
722 |
+
$row = '';
|
723 |
+
if ( empty( $rows ) ) {
|
724 |
+
echo '<tr><td colspan="' . count( $header ) . '">' . $empty_message
|
725 |
+
. '</td></tr>';
|
726 |
+
} else {
|
727 |
+
foreach ( $rows as $row ) {
|
728 |
+
echo '<tr>';
|
729 |
+
foreach ( $row as $column_name => $column_value ) {
|
730 |
+
echo '<td class="wpcf-table-column-' . $column_name . '">';
|
731 |
+
echo $column_value;
|
732 |
+
echo '</td>' . "\r\n";
|
733 |
+
}
|
734 |
+
echo '</tr>' . "\r\n";
|
735 |
+
}
|
736 |
+
}
|
737 |
+
echo '
|
738 |
+
</tbody>
|
739 |
+
</table>' . "\r\n";
|
740 |
+
}
|
741 |
+
|
742 |
+
/**
|
743 |
+
* Admin tabs.
|
744 |
+
*
|
745 |
+
* @param type $tabs
|
746 |
+
* @param type $page
|
747 |
+
* @param type $default
|
748 |
+
* @param type $current
|
749 |
+
* @return string
|
750 |
+
*/
|
751 |
+
function wpcf_admin_tabs( $tabs, $page, $default = '', $current = '' ) {
|
752 |
+
if ( empty( $current ) && isset( $_GET['tab'] ) ) {
|
753 |
+
$current = $_GET['tab'];
|
754 |
+
} else {
|
755 |
+
$current = $default;
|
756 |
+
}
|
757 |
+
$output = '<h2 class="nav-tab-wrapper">';
|
758 |
+
foreach ( $tabs as $tab => $name ) {
|
759 |
+
$class = ( $tab == $current ) ? ' nav-tab-active' : '';
|
760 |
+
$output .= "<a class='nav-tab$class' href='?page=$page&tab=$tab'>$name</a>";
|
761 |
+
}
|
762 |
+
$output .= '</h2>';
|
763 |
+
return $output;
|
764 |
+
}
|
765 |
+
|
766 |
+
/**
|
767 |
+
* Saves open fieldsets.
|
768 |
+
*
|
769 |
+
* @param type $action
|
770 |
+
* @param type $fieldset
|
771 |
+
*/
|
772 |
+
function wpcf_admin_form_fieldset_save_toggle( $action, $fieldset ) {
|
773 |
+
$data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
|
774 |
+
true );
|
775 |
+
if ( $action == 'open' ) {
|
776 |
+
$data[$fieldset] = 1;
|
777 |
+
} else if ( $action == 'close' ) {
|
778 |
+
unset( $data[$fieldset] );
|
779 |
+
}
|
780 |
+
update_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle', $data );
|
781 |
+
}
|
782 |
+
|
783 |
+
/**
|
784 |
+
* Check if fieldset is saved as open.
|
785 |
+
*
|
786 |
+
* @param type $fieldset
|
787 |
+
*/
|
788 |
+
function wpcf_admin_form_fieldset_is_collapsed( $fieldset ) {
|
789 |
+
$data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
|
790 |
+
true );
|
791 |
+
if ( empty( $data ) ) {
|
792 |
+
return true;
|
793 |
+
}
|
794 |
+
return array_key_exists( $fieldset, $data ) ? false : true;
|
795 |
+
}
|
796 |
+
|
797 |
+
/**
|
798 |
+
* Adds help on admin pages.
|
799 |
+
*
|
800 |
+
* @param type $contextual_help
|
801 |
+
* @param type $screen_id
|
802 |
+
* @param type $screen
|
803 |
+
* @return type
|
804 |
+
*/
|
805 |
+
function wpcf_admin_plugin_help( $hook, $page ) {
|
806 |
+
global $wp_version;
|
807 |
+
$call = false;
|
808 |
+
$contextual_help = '';
|
809 |
+
$page = $page;
|
810 |
+
if ( isset( $page ) && isset( $_GET['page'] ) && $_GET['page'] == $page ) {
|
811 |
+
switch ( $page ) {
|
812 |
+
case 'wpcf-cf':
|
813 |
+
$call = 'custom_fields';
|
814 |
+
break;
|
815 |
+
|
816 |
+
case 'wpcf-ctt':
|
817 |
+
$call = 'custom_types_and_taxonomies';
|
818 |
+
break;
|
819 |
+
|
820 |
+
case 'wpcf-import-export':
|
821 |
+
$call = 'import_export';
|
822 |
+
break;
|
823 |
+
|
824 |
+
case 'wpcf-edit':
|
825 |
+
$call = 'edit_group';
|
826 |
+
break;
|
827 |
+
|
828 |
+
case 'wpcf-edit-type':
|
829 |
+
$call = 'edit_type';
|
830 |
+
break;
|
831 |
+
|
832 |
+
case 'wpcf-edit-tax':
|
833 |
+
$call = 'edit_tax';
|
834 |
+
break;
|
835 |
+
case 'wpcf':
|
836 |
+
$call = 'wpcf';
|
837 |
+
break;
|
838 |
+
}
|
839 |
+
}
|
840 |
+
if ( $call ) {
|
841 |
+
require_once WPCF_ABSPATH . '/help.php';
|
842 |
+
$contextual_help = wpcf_admin_help( $call, $contextual_help );
|
843 |
+
// WP 3.3 changes
|
844 |
+
if ( version_compare( $wp_version, '3.2.1', '>' ) ) {
|
845 |
+
set_current_screen( $hook );
|
846 |
+
$screen = get_current_screen();
|
847 |
+
if ( !is_null( $screen ) ) {
|
848 |
+
$args = array(
|
849 |
+
'title' => __( 'Types', 'wpcf' ),
|
850 |
+
'id' => 'wpcf',
|
851 |
+
'content' => $contextual_help,
|
852 |
+
'callback' => false,
|
853 |
+
);
|
854 |
+
$screen->add_help_tab( $args );
|
855 |
+
}
|
856 |
+
} else {
|
857 |
+
add_contextual_help( $hook, $contextual_help );
|
858 |
+
}
|
859 |
+
}
|
860 |
+
}
|
861 |
+
|
862 |
+
/**
|
863 |
+
* Promo texts
|
864 |
+
*
|
865 |
+
* @todo Move!
|
866 |
+
*/
|
867 |
+
function wpcf_admin_promotional_text() {
|
868 |
+
$promo_tabs = get_option( '_wpcf_promo_tabs', false );
|
869 |
+
// random selection every one hour
|
870 |
+
if ( $promo_tabs ) {
|
871 |
+
$time = time();
|
872 |
+
$time_check = intval( $promo_tabs['time'] ) + 60 * 60;
|
873 |
+
if ( $time > $time_check ) {
|
874 |
+
$selected = mt_rand( 0, 3 );
|
875 |
+
$promo_tabs['selected'] = $selected;
|
876 |
+
$promo_tabs['time'] = $time;
|
877 |
+
update_option( '_wpcf_promo_tabs', $promo_tabs );
|
878 |
+
} else {
|
879 |
+
$selected = $promo_tabs['selected'];
|
880 |
+
}
|
881 |
+
} else {
|
882 |
+
$promo_tabs = array();
|
883 |
+
$selected = mt_rand( 0, 3 );
|
884 |
+
$promo_tabs['selected'] = $selected;
|
885 |
+
$promo_tabs['time'] = time();
|
886 |
+
update_option( '_wpcf_promo_tabs', $promo_tabs );
|
887 |
+
}
|
888 |
+
include WPCF_ABSPATH . '/marketing/helpful-links.php';
|
889 |
+
}
|
890 |
+
|
891 |
+
/**
|
892 |
+
* Collapsible scripts.
|
893 |
+
*/
|
894 |
+
function wpcf_admin_load_collapsible() {
|
895 |
+
wp_enqueue_script( 'wpcf-collapsible',
|
896 |
+
WPCF_RES_RELPATH . '/js/collapsible.js', array('jquery'),
|
897 |
+
WPCF_VERSION );
|
898 |
+
wp_enqueue_style( 'wpcf-collapsible',
|
899 |
+
WPCF_RES_RELPATH . '/css/collapsible.css', array(), WPCF_VERSION );
|
900 |
+
$option = get_option( 'wpcf_toggle', array() );
|
901 |
+
if ( !empty( $option ) ) {
|
902 |
+
$setting = 'new Array("' . implode( '", "', array_keys( $option ) ) . '")';
|
903 |
+
wpcf_admin_add_js_settings( 'wpcf_collapsed', $setting );
|
904 |
+
}
|
905 |
+
}
|
906 |
+
|
907 |
+
/**
|
908 |
+
* Toggle button.
|
909 |
+
*
|
910 |
+
* @param type $div_id
|
911 |
+
* @return type
|
912 |
+
*/
|
913 |
+
function wpcf_admin_toggle_button( $div_id ) {
|
914 |
+
return '<a href="'
|
915 |
+
. admin_url( 'admin-ajax.php?action=wpcf_ajax&wpcf_action=toggle&div='
|
916 |
+
. $div_id . '-toggle&_wpnonce='
|
917 |
+
. wp_create_nonce( 'toggle' ) )
|
918 |
+
. '" id="' . $div_id
|
919 |
+
. '" class="wpcf-collapsible-button"></a>';
|
920 |
+
}
|
921 |
+
|
922 |
+
/**
|
923 |
+
* Various delete/deactivate content actions.
|
924 |
+
*
|
925 |
+
* @param type $type
|
926 |
+
* @param type $arg
|
927 |
+
* @param type $action
|
928 |
+
*/
|
929 |
+
function wpcf_admin_deactivate_content( $type, $arg, $action = 'delete' ) {
|
930 |
+
switch ( $type ) {
|
931 |
+
case 'post_type':
|
932 |
+
// Clean tax relations
|
933 |
+
if ( $action == 'delete' ) {
|
934 |
+
$custom = get_option( 'wpcf-custom-taxonomies', array() );
|
935 |
+
foreach ( $custom as $post_type => $data ) {
|
936 |
+
if ( empty( $data['supports'] ) ) {
|
937 |
+
continue;
|
938 |
+
}
|
939 |
+
if ( array_key_exists( $arg, $data['supports'] ) ) {
|
940 |
+
unset( $custom[$post_type]['supports'][$arg] );
|
941 |
+
}
|
942 |
+
}
|
943 |
+
update_option( 'wpcf-custom-taxonomies', $custom );
|
944 |
+
}
|
945 |
+
break;
|
946 |
+
|
947 |
+
case 'taxonomy':
|
948 |
+
// Clean post relations
|
949 |
+
if ( $action == 'delete' ) {
|
950 |
+
$custom = get_option( 'wpcf-custom-types', array() );
|
951 |
+
foreach ( $custom as $post_type => $data ) {
|
952 |
+
if ( empty( $data['taxonomies'] ) ) {
|
953 |
+
continue;
|
954 |
+
}
|
955 |
+
if ( array_key_exists( $arg, $data['taxonomies'] ) ) {
|
956 |
+
unset( $custom[$post_type]['taxonomies'][$arg] );
|
957 |
+
}
|
958 |
+
}
|
959 |
+
update_option( 'wpcf-custom-types', $custom );
|
960 |
+
}
|
961 |
+
break;
|
962 |
+
|
963 |
+
default:
|
964 |
+
break;
|
965 |
+
}
|
966 |
+
}
|
967 |
+
|
968 |
+
/**
|
969 |
+
* Loads teasers.
|
970 |
+
*
|
971 |
+
* @param type $teasers
|
972 |
+
*/
|
973 |
+
function wpcf_admin_load_teasers( $teasers ) {
|
974 |
+
foreach ( $teasers as $teaser ) {
|
975 |
+
$file = WPCF_ABSPATH . '/plus/' . $teaser;
|
976 |
+
if ( file_exists( $file ) ) {
|
977 |
+
require_once $file;
|
978 |
+
}
|
979 |
+
}
|
980 |
+
}
|
981 |
+
|
982 |
+
/**
|
983 |
+
* Get temporary directory
|
984 |
+
*
|
985 |
+
* @return
|
986 |
+
*/
|
987 |
+
|
988 |
+
function wpcf_get_temporary_directory()
|
989 |
+
{
|
990 |
+
$dir = sys_get_temp_dir();
|
991 |
+
if ( !empty( $dir ) && is_dir( $dir ) && is_writable( $dir ) ) {
|
992 |
+
return $dir;
|
993 |
+
}
|
994 |
+
$dir = wp_upload_dir();
|
995 |
+
$dir = $dir['basedir'];
|
996 |
return $dir;
|
997 |
}
|
998 |
|
1016 |
</div>
|
1017 |
<?php
|
1018 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1019 |
|
1020 |
/**
|
1021 |
* add types configuration to debug
|
1030 |
add_action( 'wpcf_admin_header', 'wpcf_welcome_panel', PHP_INT_SIZE );
|
1031 |
add_filter( 'icl_get_extra_debug_info', 'wpcf_get_extra_debug_info' );
|
1032 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/class.wpcf-marketing-messages.php
DELETED
@@ -1,364 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* Types Marketing Class
|
5 |
-
*
|
6 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6.6/classes/class.wpcf-marketing-messages.php $
|
7 |
-
* $LastChangedDate: 2015-04-10 07:43:49 +0000 (Fri, 10 Apr 2015) $
|
8 |
-
* $LastChangedRevision: 1131821 $
|
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 |
-
$this->state = 'disabled';
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
public static function check_register()
|
51 |
-
{
|
52 |
-
if(!function_exists('WP_Installer')){
|
53 |
-
return false;
|
54 |
-
}
|
55 |
-
$repos = array(
|
56 |
-
'toolset'
|
57 |
-
);
|
58 |
-
foreach( $repos as $repository_id ) {
|
59 |
-
$key = WP_Installer()->repository_has_subscription($repository_id);
|
60 |
-
if ( empty($key) ) {
|
61 |
-
continue;
|
62 |
-
}
|
63 |
-
return true;
|
64 |
-
}
|
65 |
-
return false;
|
66 |
-
}
|
67 |
-
|
68 |
-
private function get_data()
|
69 |
-
{
|
70 |
-
/**
|
71 |
-
* check kind
|
72 |
-
*/
|
73 |
-
$kind = $this->get_kind();
|
74 |
-
/**
|
75 |
-
* get default
|
76 |
-
*/
|
77 |
-
if ( empty($kind) ) {
|
78 |
-
$kind = $this->get_default_kind();
|
79 |
-
}
|
80 |
-
/**
|
81 |
-
* check exists?
|
82 |
-
*/
|
83 |
-
if ( empty($kind) || !array_key_exists($kind, $this->adverts ) ) {
|
84 |
-
return;
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* check type
|
89 |
-
*/
|
90 |
-
$type = $this->get_page_type();
|
91 |
-
if ( empty($type) || !array_key_exists($type, $this->adverts[$kind]) ) {
|
92 |
-
return;
|
93 |
-
}
|
94 |
-
if ( !is_array($this->adverts[$kind][$type]) ) {
|
95 |
-
return;
|
96 |
-
}
|
97 |
-
/**
|
98 |
-
* get number
|
99 |
-
*/
|
100 |
-
$number = intval(get_user_option('types-modal'));
|
101 |
-
if ( !isset($this->adverts[$kind][$type][$number]) ) {
|
102 |
-
if ( empty($this->adverts[$kind][$type]) ) {
|
103 |
-
return;
|
104 |
-
}
|
105 |
-
$number = 0;
|
106 |
-
}
|
107 |
-
|
108 |
-
$data = $this->adverts[$kind][$type][$number];
|
109 |
-
$data['number'] = $number;
|
110 |
-
$data['count'] = count($this->adverts[$kind][$type]);
|
111 |
-
return $data;
|
112 |
-
}
|
113 |
-
|
114 |
-
private function replace_placeholders($text)
|
115 |
-
{
|
116 |
-
$type = $this->get_page_type();
|
117 |
-
switch($type) {
|
118 |
-
case 'cpt':
|
119 |
-
if (
|
120 |
-
is_array($_GET)
|
121 |
-
&& array_key_exists('wpcf-post-type', $_GET)
|
122 |
-
) {
|
123 |
-
$types = get_option('wpcf-custom-types', array());
|
124 |
-
$candidate_key = sanitize_text_field( $_GET['wpcf-post-type'] );
|
125 |
-
if ( array_key_exists($candidate_key, $types ) ) {
|
126 |
-
$text = preg_replace( '/PPP/', $types[$candidate_key]['labels']['name'], $text);
|
127 |
-
}
|
128 |
-
}
|
129 |
-
break;
|
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 |
-
$candidate_key = sanitize_text_field( $_GET['wpcf-tax'] );
|
138 |
-
if ( array_key_exists($candidate_key, $taxonomies) ) {
|
139 |
-
$text = preg_replace( '/TTT/', $taxonomies[$candidate_key]['labels']['name'], $text);
|
140 |
-
if ( array_key_exists('supports', $taxonomies[$candidate_key]) ) {
|
141 |
-
$types = get_option('wpcf-custom-types', array());
|
142 |
-
$post_type = array_keys($taxonomies[$candidate_key]['supports']);
|
143 |
-
if ( !empty($post_type) ) {
|
144 |
-
$post_type = $post_type[array_rand($post_type)];
|
145 |
-
$post_type = get_post_type_object($post_type);
|
146 |
-
if ( $post_type ) {
|
147 |
-
$text = preg_replace( '/PPP/', $post_type->labels->name, $text);
|
148 |
-
}
|
149 |
-
}
|
150 |
-
}
|
151 |
-
}
|
152 |
-
}
|
153 |
-
break;
|
154 |
-
}
|
155 |
-
/**
|
156 |
-
* defaults
|
157 |
-
*/
|
158 |
-
$text = preg_replace( '/PPP/', __('Posts'), $text);
|
159 |
-
$text = preg_replace( '/TTT/', __('Tags'), $text);
|
160 |
-
|
161 |
-
return $text;
|
162 |
-
}
|
163 |
-
|
164 |
-
public function register_scripts()
|
165 |
-
{
|
166 |
-
|
167 |
-
$data = $this->get_data();
|
168 |
-
if ( empty($data) ) {
|
169 |
-
return;
|
170 |
-
}
|
171 |
-
/**
|
172 |
-
* common question
|
173 |
-
*/
|
174 |
-
$data['message'] = __('Saving your changes', 'wpcf');
|
175 |
-
$data['spinner'] = apply_filters('wpcf_marketing_message', admin_url('/images/spinner.gif'), $data, 'spinner');
|
176 |
-
$data['question'] = apply_filters('wpcf_marketing_message', __('Did you know?', 'wcpf'), $data, 'question');
|
177 |
-
/**
|
178 |
-
* random image & class
|
179 |
-
*/
|
180 |
-
$image = isset($data['image'])? $data['image']:'views';
|
181 |
-
$src = sprintf(
|
182 |
-
'%s/marketing/assets/images/%s.png',
|
183 |
-
WPCF_RELPATH,
|
184 |
-
$image
|
185 |
-
);
|
186 |
-
$data['image'] = apply_filters('wpcf_marketing_message', $src, $data, 'image');
|
187 |
-
$data['class'] = apply_filters('wpcf_marketing_message', $image, $data, 'class');
|
188 |
-
/**
|
189 |
-
* values depend on type
|
190 |
-
*/
|
191 |
-
foreach ( array('header', 'description') as $key ) {
|
192 |
-
$value = '';
|
193 |
-
if ( isset($data[$key]) && $data[$key] ) {
|
194 |
-
$value = $this->replace_placeholders($data[$key]);
|
195 |
-
}
|
196 |
-
$data[$key] = apply_filters('wpcf_marketing_message', $value, $data, $key );
|
197 |
-
$data['state'] = $this->state;
|
198 |
-
}
|
199 |
-
wp_register_script( 'types-modal', WPCF_EMBEDDED_RES_RELPATH.'/js/modal.js', array('jquery'), WPCF_VERSION, true);
|
200 |
-
wp_localize_script( 'types-modal', 'types_modal', $data);
|
201 |
-
wp_enqueue_script('types-modal');
|
202 |
-
}
|
203 |
-
|
204 |
-
public function update_message($message = false)
|
205 |
-
{
|
206 |
-
if (empty($message)) {
|
207 |
-
return;
|
208 |
-
}
|
209 |
-
echo '<div class="updated"><p>', $message, '</p></div>';
|
210 |
-
}
|
211 |
-
|
212 |
-
public function update_options()
|
213 |
-
{
|
214 |
-
if(!isset($_POST['marketing'])) {
|
215 |
-
return;
|
216 |
-
}
|
217 |
-
if ( !wp_verify_nonce($_POST['marketing'], 'update')) {
|
218 |
-
return;
|
219 |
-
}
|
220 |
-
if (
|
221 |
-
array_key_exists($this->option_name, $_POST)
|
222 |
-
&& array_key_exists($_POST[$this->option_name], $this->options)
|
223 |
-
) {
|
224 |
-
// @todo we need to sanitize $_POST[$this->option_name]: is it a string, an array or what?
|
225 |
-
if ( !add_option($this->option_name, $_POST[$this->option_name], '', 'no') ) {
|
226 |
-
update_option($this->option_name, $_POST[$this->option_name]);
|
227 |
-
}
|
228 |
-
}
|
229 |
-
$this->set_state();
|
230 |
-
}
|
231 |
-
|
232 |
-
public function delete_option_kind()
|
233 |
-
{
|
234 |
-
delete_option($this->option_name);
|
235 |
-
}
|
236 |
-
|
237 |
-
public function get_kind_list()
|
238 |
-
{
|
239 |
-
$type = get_option($this->option_name);
|
240 |
-
$content = '<ul class="marketing-kind-list">';
|
241 |
-
foreach( $this->options as $key => $one ) {
|
242 |
-
$content .= '<li>';
|
243 |
-
$content .= sprintf(
|
244 |
-
'<input type="radio" name="%s" value="%s" id="getting_started_%s" %s/>',
|
245 |
-
$this->get_option_name(),
|
246 |
-
$key,
|
247 |
-
$key,
|
248 |
-
$type == $key? ' checked="checked" ':''
|
249 |
-
);
|
250 |
-
$content .= sprintf(
|
251 |
-
'<label for="getting_started_%s"> <strong>%s</strong>%s%s</label>',
|
252 |
-
$key,
|
253 |
-
$one['title'],
|
254 |
-
array_key_exists('description', $one)? ' | ':'',
|
255 |
-
array_key_exists('description', $one)? $one['description']:''
|
256 |
-
);
|
257 |
-
$content .= '</li>';
|
258 |
-
}
|
259 |
-
$content .= '</ul>';
|
260 |
-
return $content;
|
261 |
-
}
|
262 |
-
|
263 |
-
public function kind_list()
|
264 |
-
{
|
265 |
-
echo $this->get_kind_list();
|
266 |
-
}
|
267 |
-
|
268 |
-
public function show_top($update = true)
|
269 |
-
{
|
270 |
-
$data = $this->get_data();
|
271 |
-
if ( empty($data) ) {
|
272 |
-
return false;
|
273 |
-
}
|
274 |
-
$content = '<div class="icon-toolset-logo icon-toolset">';
|
275 |
-
$content .= sprintf('<p class="wpcf-notif-header">%s</p>', $update? __('Updated!', 'wpcf'):__('Created!', 'wpcf') );
|
276 |
-
if ( 'endabled' == $this->state) {
|
277 |
-
$content .= '<p class="wpcf-notif-description">';
|
278 |
-
if ( isset($data['link']) ) {
|
279 |
-
$content .= sprintf(
|
280 |
-
'<a href="%s">%s</a>',
|
281 |
-
$this->add_ga_campain($data['link'], 'save-updated'),
|
282 |
-
$data['description']
|
283 |
-
);
|
284 |
-
} else {
|
285 |
-
$content .= $data['description'];
|
286 |
-
}
|
287 |
-
$content .= '</p>';
|
288 |
-
}
|
289 |
-
$content .= '</div>';
|
290 |
-
|
291 |
-
$content = $this->replace_placeholders($content);
|
292 |
-
|
293 |
-
/**
|
294 |
-
* after all set up types-modal for next time
|
295 |
-
*/
|
296 |
-
$key = rand( 0, $data['count']-1 );
|
297 |
-
$user_id = get_current_user_id();
|
298 |
-
update_user_option($user_id, 'types-modal', $key);
|
299 |
-
|
300 |
-
return $content;
|
301 |
-
}
|
302 |
-
|
303 |
-
public function get_content()
|
304 |
-
{
|
305 |
-
if ( $url = $this->get_kind_url() ) {
|
306 |
-
include_once dirname(__FILE__).'/class.wpcf-marketing-tutorial.php';
|
307 |
-
$tutorial = new WPCF_Types_Marketing_Tutorial();
|
308 |
-
return $tutorial->get_content('kind');
|
309 |
-
}
|
310 |
-
return;
|
311 |
-
}
|
312 |
-
|
313 |
-
// @todo nonce ?
|
314 |
-
// @todo auth ?
|
315 |
-
public function update_toolset_messages()
|
316 |
-
{
|
317 |
-
$settings = wpcf_get_settings();
|
318 |
-
if (
|
319 |
-
array_key_exists('value', $_POST)
|
320 |
-
&& 'checked' == $_POST['value']
|
321 |
-
) {
|
322 |
-
if ( !add_option($this->option_disable, '1', '', 'no') ) {
|
323 |
-
update_option($this->option_disable, '1');
|
324 |
-
}
|
325 |
-
$settings['toolset_messages'] = true;
|
326 |
-
} else {
|
327 |
-
delete_option($this->option_disable);
|
328 |
-
$settings['toolset_messages'] = false;
|
329 |
-
}
|
330 |
-
update_option('wpcf_settings', $settings);
|
331 |
-
echo '<div class="updated"><p>';
|
332 |
-
_e('Toolset Messages state saved!', 'wpcf');
|
333 |
-
echo '</p></div>';
|
334 |
-
die;
|
335 |
-
}
|
336 |
-
|
337 |
-
public function add_message_after_activate()
|
338 |
-
{
|
339 |
-
if ( !isset($_GET['activate']) ) {
|
340 |
-
return;
|
341 |
-
}
|
342 |
-
if ( is_multisite() ) {
|
343 |
-
return;
|
344 |
-
}
|
345 |
-
if ( 'show' != get_option('types_show_on_activate') ) {
|
346 |
-
return;
|
347 |
-
}
|
348 |
-
wp_enqueue_style('onthego-admin-styles');
|
349 |
-
wp_enqueue_style('wpcf-css-embedded');
|
350 |
-
$data = array(
|
351 |
-
'header' => __('Need help with <em>Types</em>?', 'wpcf'),
|
352 |
-
'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'),
|
353 |
-
'button_primary_url' => add_query_arg( 'page', basename(dirname(dirname(__FILE__))).'/marketing/getting-started/index.php', admin_url('admin.php') ),
|
354 |
-
'button_primary_text' => __('Get Started', 'wpcf'),
|
355 |
-
'button_dismiss_url' => '',
|
356 |
-
'button_dismiss_text' => __('Dismiss', 'wpcf'),
|
357 |
-
);
|
358 |
-
wp_localize_script('marketing-getting-started', 'types_activate', $data);
|
359 |
-
wp_enqueue_script('marketing-getting-started');
|
360 |
-
update_option('types_show_on_activate', 'hide');
|
361 |
-
}
|
362 |
-
|
363 |
-
}
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/class.wpcf-marketing-tutorial.php
DELETED
@@ -1,247 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* Types Tutorial Class
|
5 |
-
*
|
6 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6.6/classes/class.wpcf-marketing-tutorial.php $
|
7 |
-
* $LastChangedDate: 2015-04-10 07:43:49 +0000 (Fri, 10 Apr 2015) $
|
8 |
-
* $LastChangedRevision: 1131821 $
|
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, 'fetch-data');
|
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
DELETED
@@ -1,159 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
* Types Marketing Class
|
5 |
-
*
|
6 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6.6/classes/class.wpcf-marketing.php $
|
7 |
-
* $LastChangedDate: 2015-04-10 07:43:49 +0000 (Fri, 10 Apr 2015) $
|
8 |
-
* $LastChangedRevision: 1131821 $
|
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, $utm_medium = 'getting-started')
|
131 |
-
{
|
132 |
-
$url = add_query_arg(
|
133 |
-
array(
|
134 |
-
'utm_source' => 'typesplugin',
|
135 |
-
'utm_medium' => $utm_medium,
|
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.
|
5 |
-
* $LastChangedDate:
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
require_once(WPCF_EMBEDDED_ABSPATH . '/common/visual-editor/editor-addon.class.php');
|
@@ -52,8 +52,11 @@ function wpcf_embedded_admin_init_hook() {
|
|
52 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/file.php';
|
53 |
// Add types button
|
54 |
add_filter( 'attachment_fields_to_edit', 'wpcf_fields_file_attachment_fields_to_edit_filter', PHP_INT_MAX, 2 );
|
|
|
|
|
55 |
// Filter media TABs
|
56 |
-
add_filter( 'media_upload_tabs',
|
|
|
57 |
}
|
58 |
|
59 |
register_post_type( 'wp-types-group',
|
@@ -154,15 +157,14 @@ function wpcf_admin_fields_postfields_styles(){
|
|
154 |
|
155 |
// $groups = wpcf_admin_fields_get_groups();
|
156 |
$groups = wpcf_admin_post_get_post_groups_fields( wpcf_admin_get_edited_post() );
|
157 |
-
|
158 |
if ( !empty( $groups ) ) {
|
159 |
-
echo '<style type="text/css">';
|
160 |
foreach ( $groups as $group ) {
|
161 |
echo str_replace( "}", "}\n",
|
162 |
wpcf_admin_get_groups_admin_styles_by_group( $group['id'] ) );
|
163 |
}
|
164 |
-
echo '</style>';
|
165 |
}
|
|
|
166 |
}
|
167 |
|
168 |
/**
|
@@ -185,6 +187,42 @@ function wpcf_form( $id, $form = array() ) {
|
|
185 |
return $wpcf_forms[$id];
|
186 |
}
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
/**
|
189 |
* Renders form elements.
|
190 |
*
|
@@ -291,17 +329,16 @@ function wpcf_admin_validation_messages( $method = false, $sprintf = '' ) {
|
|
291 |
'date' => __( 'Please enter a valid date', 'wpcf' ),
|
292 |
'digits' => __( 'Please enter numeric data', 'wpcf' ),
|
293 |
'number' => __( 'Please enter numeric data', 'wpcf' ),
|
294 |
-
'alphanumeric' => __( 'Letters, numbers, spaces or underscores only please',
|
295 |
-
|
296 |
-
'
|
297 |
-
|
298 |
-
'
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
'skype' => __( 'Letters, numbers, dashes, underscores, commas and periods only please.', 'wpcf' ),
|
305 |
);
|
306 |
if ( $method ) {
|
307 |
return isset( $messages[$method] ) ? $messages[$method] : '';
|
@@ -350,20 +387,8 @@ function wpcf_show_admin_messages() {
|
|
350 |
* @param type $class
|
351 |
* @return type
|
352 |
*/
|
353 |
-
function wpcf_admin_message_store( $message, $class = 'updated',
|
354 |
-
{
|
355 |
-
/**
|
356 |
-
* Allow to store or note
|
357 |
-
*
|
358 |
-
* Filter allow to turn off storing messages in Types
|
359 |
-
*
|
360 |
-
* @since 1.6.6
|
361 |
-
*
|
362 |
-
* @param boolean $var default value is true to show messages
|
363 |
-
*/
|
364 |
-
if (!apply_filters('wpcf_admin_message_store', true) ) {
|
365 |
-
return;
|
366 |
-
}
|
367 |
$messages = get_option( 'wpcf-messages', array() );
|
368 |
$messages[get_current_user_id()][md5( $message )] = array(
|
369 |
'message' => $message,
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/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');
|
52 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/file.php';
|
53 |
// Add types button
|
54 |
add_filter( 'attachment_fields_to_edit', 'wpcf_fields_file_attachment_fields_to_edit_filter', PHP_INT_MAX, 2 );
|
55 |
+
// Add JS
|
56 |
+
add_action( 'admin_head', 'wpcf_fields_file_media_admin_head' );
|
57 |
// Filter media TABs
|
58 |
+
add_filter( 'media_upload_tabs',
|
59 |
+
'wpcf_fields_file_media_upload_tabs_filter' );
|
60 |
}
|
61 |
|
62 |
register_post_type( 'wp-types-group',
|
157 |
|
158 |
// $groups = wpcf_admin_fields_get_groups();
|
159 |
$groups = wpcf_admin_post_get_post_groups_fields( wpcf_admin_get_edited_post() );
|
160 |
+
echo '<style type="text/css">';
|
161 |
if ( !empty( $groups ) ) {
|
|
|
162 |
foreach ( $groups as $group ) {
|
163 |
echo str_replace( "}", "}\n",
|
164 |
wpcf_admin_get_groups_admin_styles_by_group( $group['id'] ) );
|
165 |
}
|
|
|
166 |
}
|
167 |
+
echo '</style>';
|
168 |
}
|
169 |
|
170 |
/**
|
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 |
*
|
329 |
'date' => __( 'Please enter a valid date', 'wpcf' ),
|
330 |
'digits' => __( 'Please enter numeric data', 'wpcf' ),
|
331 |
'number' => __( 'Please enter numeric data', 'wpcf' ),
|
332 |
+
'alphanumeric' => __( 'Letters, numbers, spaces or underscores only please',
|
333 |
+
'wpcf' ),
|
334 |
+
'nospecialchars' => __( 'Letters, numbers, spaces, underscores and dashes only please',
|
335 |
+
'wpcf' ),
|
336 |
+
'rewriteslug' => __( 'Letters, numbers, slashes, underscores and dashes only please',
|
337 |
+
'wpcf' ),
|
338 |
+
'negativeTimestamp' => __( 'Please enter a date after 1 January 1970.',
|
339 |
+
'wpcf' ),
|
340 |
+
'maxlength' => sprintf( __( 'Maximum of %s characters exceeded.', 'wpcf' ),
|
341 |
+
strval( $sprintf ) ),
|
|
|
342 |
);
|
343 |
if ( $method ) {
|
344 |
return isset( $messages[$method] ) ? $messages[$method] : '';
|
387 |
* @param type $class
|
388 |
* @return type
|
389 |
*/
|
390 |
+
function wpcf_admin_message_store( $message, $class = 'updated',
|
391 |
+
$keep_id = false ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
$messages = get_option( 'wpcf-messages', array() );
|
393 |
$messages[get_current_user_id()][md5( $message )] = array(
|
394 |
'message' => $message,
|
embedded/bootstrap.php
CHANGED
@@ -7,10 +7,10 @@
|
|
7 |
*
|
8 |
* @since Types 1.2
|
9 |
*
|
10 |
-
* $HeadURL:
|
11 |
-
* $LastChangedDate:
|
12 |
-
* $LastChangedRevision:
|
13 |
-
* $LastChangedBy:
|
14 |
*
|
15 |
*/
|
16 |
|
@@ -42,13 +42,6 @@ if ( !defined( 'TYPES_INIT_PRIORITY' ) ) {
|
|
42 |
* Init
|
43 |
*/
|
44 |
add_action( 'init', 'wpcf_embedded_init', TYPES_INIT_PRIORITY );
|
45 |
-
add_action( 'init', 'wpcf_init_custom_types_taxonomies', TYPES_INIT_PRIORITY );
|
46 |
-
|
47 |
-
/**
|
48 |
-
* register_post_type & register_taxonomy - must be with default pririty to
|
49 |
-
* handle defult taxonomies
|
50 |
-
*/
|
51 |
-
add_action('init', 'wpcf_init_build_in_taxonomies');
|
52 |
|
53 |
/*
|
54 |
*
|
@@ -138,7 +131,7 @@ function wpcf_embedded_init() {
|
|
138 |
// Define necessary constants if plugin is not present
|
139 |
// This ones are skipped if used as embedded code!
|
140 |
if ( !defined( 'WPCF_VERSION' ) ) {
|
141 |
-
define( 'WPCF_VERSION', '1.6.
|
142 |
define( 'WPCF_META_PREFIX', 'wpcf-' );
|
143 |
}
|
144 |
|
@@ -307,20 +300,16 @@ function wpcf_embedded_init() {
|
|
307 |
// 'attachment' = Media
|
308 |
//
|
309 |
$wpcf->excluded_post_types = array(
|
310 |
-
'
|
311 |
-
'cred-form',
|
312 |
-
'mediapage',
|
313 |
-
'nav_menu_item',
|
314 |
-
'revision',
|
315 |
-
'view',
|
316 |
-
'view-template',
|
317 |
-
'wp-types-group',
|
318 |
-
'wp-types-user-group',
|
319 |
);
|
320 |
|
321 |
// Init loader
|
322 |
WPCF_Loader::init();
|
323 |
|
|
|
|
|
|
|
|
|
324 |
/*
|
325 |
* TODO Check why we enabled this
|
326 |
*
|
7 |
*
|
8 |
* @since Types 1.2
|
9 |
*
|
10 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/embedded/bootstrap.php $
|
11 |
+
* $LastChangedDate: 2014-08-28 12:06:20 +0200 (Thu, 28 Aug 2014) $
|
12 |
+
* $LastChangedRevision: 26516 $
|
13 |
+
* $LastChangedBy: bruce $
|
14 |
*
|
15 |
*/
|
16 |
|
42 |
* Init
|
43 |
*/
|
44 |
add_action( 'init', 'wpcf_embedded_init', TYPES_INIT_PRIORITY );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
/*
|
47 |
*
|
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.2' );
|
135 |
define( 'WPCF_META_PREFIX', 'wpcf-' );
|
136 |
}
|
137 |
|
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
|
307 |
WPCF_Loader::init();
|
308 |
|
309 |
+
// Init custom types and taxonomies
|
310 |
+
wpcf_init_custom_types_taxonomies();
|
311 |
+
|
312 |
+
|
313 |
/*
|
314 |
* TODO Check why we enabled this
|
315 |
*
|
embedded/classes/class.wpcf-post-types.php
CHANGED
@@ -3,10 +3,10 @@
|
|
3 |
*
|
4 |
* Post Types Class
|
5 |
*
|
6 |
-
* $HeadURL:
|
7 |
-
* $LastChangedDate:
|
8 |
-
* $LastChangedRevision:
|
9 |
-
* $LastChangedBy:
|
10 |
*
|
11 |
*/
|
12 |
|
@@ -29,237 +29,6 @@ class WPCF_Post_Types
|
|
29 |
var $settings;
|
30 |
var $messages = null;
|
31 |
|
32 |
-
function __construct()
|
33 |
-
{
|
34 |
-
add_action('admin_init', array($this, 'admin_init'));
|
35 |
-
add_action('admin_head-nav-menus.php', array($this, 'add_filters'));
|
36 |
-
add_filter('wp_setup_nav_menu_item', array( $this, 'setup_archive_item'));
|
37 |
-
add_filter('wp_nav_menu_objects', array( $this, 'maybe_make_current'));
|
38 |
-
}
|
39 |
-
/**
|
40 |
-
* Check has some custom fields to display.
|
41 |
-
*
|
42 |
-
* Check custom post type for custom fields to display on custom post edit
|
43 |
-
* screen.
|
44 |
-
*
|
45 |
-
* @since 1.6.6
|
46 |
-
* @access (for functions: only use if private)
|
47 |
-
*
|
48 |
-
* @return bool It has some fields?
|
49 |
-
*/
|
50 |
-
private function check_has_custom_fields($data)
|
51 |
-
{
|
52 |
-
return
|
53 |
-
isset($data['custom_fields'])
|
54 |
-
&& is_array($data['custom_fields'])
|
55 |
-
&& !empty($data['custom_fields']);
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Admin init.
|
60 |
-
*
|
61 |
-
* Admin init function used to add columns..
|
62 |
-
*
|
63 |
-
* @since 1.6.6
|
64 |
-
*/
|
65 |
-
public function admin_init()
|
66 |
-
{
|
67 |
-
$custom_post_types = wpcf_get_active_custom_types();
|
68 |
-
foreach( $custom_post_types as $post_type => $data ) {
|
69 |
-
if ( $this->check_has_custom_fields($data)) {
|
70 |
-
$hook = sprintf('manage_edit-%s_columns', $post_type);
|
71 |
-
add_filter($hook, array($this, 'manage_posts_columns'));
|
72 |
-
$hook = sprintf('manage_%s_posts_custom_column', $post_type);
|
73 |
-
add_action($hook, array($this, 'manage_custom_columns'), 10, 2);
|
74 |
-
}
|
75 |
-
}
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Add custom fields as a columns.
|
80 |
-
*
|
81 |
-
* Add custom fields as a columns on custom post admin list
|
82 |
-
*
|
83 |
-
* @since 1.6.6
|
84 |
-
*
|
85 |
-
* @param array $columns Hashtable of columns;
|
86 |
-
* @return array Hashtable of columns;
|
87 |
-
*/
|
88 |
-
public function manage_posts_columns($columns)
|
89 |
-
{
|
90 |
-
$screen = get_current_screen();
|
91 |
-
if ( !isset( $screen->post_type) ) {
|
92 |
-
return $columns;
|
93 |
-
}
|
94 |
-
$custom_post_types = wpcf_get_active_custom_types();
|
95 |
-
if(
|
96 |
-
!isset($custom_post_types[$screen->post_type])
|
97 |
-
|| !$this->check_has_custom_fields($custom_post_types[$screen->post_type])
|
98 |
-
) {
|
99 |
-
return $columns;
|
100 |
-
}
|
101 |
-
$fields = wpcf_admin_fields_get_fields();
|
102 |
-
ksort($fields);
|
103 |
-
foreach( $fields as $key => $data ) {
|
104 |
-
if ( !isset($data['meta_key']) ) {
|
105 |
-
continue;
|
106 |
-
}
|
107 |
-
if ( in_array($data['meta_key'], $custom_post_types[$screen->post_type]['custom_fields']) ) {
|
108 |
-
$columns[$data['meta_key']] = $data['name'];
|
109 |
-
}
|
110 |
-
}
|
111 |
-
return $columns;
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Show value of custom field.
|
116 |
-
*
|
117 |
-
* Show value of custom field.
|
118 |
-
*
|
119 |
-
* @since 1.6.6
|
120 |
-
*
|
121 |
-
* @param string $column Column name,
|
122 |
-
* @param int $var Current post ID.
|
123 |
-
*/
|
124 |
-
public function manage_custom_columns($column, $post_id)
|
125 |
-
{
|
126 |
-
$value = get_post_meta($post_id, $column, true);
|
127 |
-
if ( empty($value) ) {
|
128 |
-
return;
|
129 |
-
}
|
130 |
-
$field = wpcf_admin_fields_get_field_by_meta_key($column);
|
131 |
-
if ( isset( $field['type'] ) ) {
|
132 |
-
switch( $field['type'] ) {
|
133 |
-
case 'image':
|
134 |
-
$value = sprintf(
|
135 |
-
'<img src="%s" width="120" />',
|
136 |
-
$value
|
137 |
-
);
|
138 |
-
break;
|
139 |
-
case 'skype':
|
140 |
-
$value = isset($value['skypename'])? $value['skypename']:'';
|
141 |
-
break;
|
142 |
-
case 'date':
|
143 |
-
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
|
144 |
-
$value = WPToolset_Field_Date::timetodate($value);
|
145 |
-
break;
|
146 |
-
}
|
147 |
-
}
|
148 |
-
if ( is_string($value ) ) {
|
149 |
-
echo $value;
|
150 |
-
}
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* Assign menu item the appropriate url
|
155 |
-
* @param object $menu_item
|
156 |
-
* @return object $menu_item
|
157 |
-
*/
|
158 |
-
public function setup_archive_item( $menu_item ) {
|
159 |
-
if ( $menu_item->type !== 'post_type_archive' ) {
|
160 |
-
return $menu_item;
|
161 |
-
}
|
162 |
-
$post_type = $menu_item->object;
|
163 |
-
if (post_type_exists( $post_type )) {
|
164 |
-
$data = get_post_type_object( $post_type );
|
165 |
-
$menu_item->type_label = sprintf( __( 'Archive for %s', 'wpcf' ), $data->labels->name);
|
166 |
-
$menu_item->url = get_post_type_archive_link( $post_type );
|
167 |
-
}
|
168 |
-
return $menu_item;
|
169 |
-
}
|
170 |
-
|
171 |
-
public function add_filters()
|
172 |
-
{
|
173 |
-
$custom_post_types = wpcf_get_active_custom_types();
|
174 |
-
if ( empty($custom_post_types) ) {
|
175 |
-
return;
|
176 |
-
}
|
177 |
-
foreach ( $custom_post_types as $slug => $data ) {
|
178 |
-
add_filter( 'nav_menu_items_' . $slug, array( $this, 'add_archive_checkbox' ), null, 3 );
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
public function add_archive_checkbox( $posts, $args, $post_type )
|
183 |
-
{
|
184 |
-
global $_nav_menu_placeholder, $wp_rewrite;
|
185 |
-
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
|
186 |
-
|
187 |
-
array_unshift( $posts, (object) array(
|
188 |
-
'ID' => 0,
|
189 |
-
'object_id' => $_nav_menu_placeholder,
|
190 |
-
'post_title' => $post_type['args']->labels->all_items,
|
191 |
-
'post_type' => 'nav_menu_item',
|
192 |
-
'type' => 'post_type_archive',
|
193 |
-
'object' => $post_type['args']->slug,
|
194 |
-
) );
|
195 |
-
|
196 |
-
return $posts;
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Make post type archive link 'current'
|
201 |
-
* @uses Post_Type_Archive_Links :: get_item_ancestors()
|
202 |
-
* @param array $items
|
203 |
-
* @return array $items
|
204 |
-
*/
|
205 |
-
public function maybe_make_current( $items ) {
|
206 |
-
foreach ( $items as $item ) {
|
207 |
-
if ( 'post_type_archive' !== $item->type ) {
|
208 |
-
continue;
|
209 |
-
}
|
210 |
-
$post_type = $item->object;
|
211 |
-
if (
|
212 |
-
! is_post_type_archive( $post_type )
|
213 |
-
AND ! is_singular( $post_type )
|
214 |
-
)
|
215 |
-
continue;
|
216 |
-
|
217 |
-
// Make item current
|
218 |
-
$item->current = true;
|
219 |
-
$item->classes[] = 'current-menu-item';
|
220 |
-
|
221 |
-
// Loop through ancestors and give them 'parent' or 'ancestor' class
|
222 |
-
$active_anc_item_ids = $this->get_item_ancestors( $item );
|
223 |
-
foreach ( $items as $key => $parent_item ) {
|
224 |
-
$classes = (array) $parent_item->classes;
|
225 |
-
|
226 |
-
// If menu item is the parent
|
227 |
-
if ( $parent_item->db_id == $item->menu_item_parent ) {
|
228 |
-
$classes[] = 'current-menu-parent';
|
229 |
-
$items[ $key ]->current_item_parent = true;
|
230 |
-
}
|
231 |
-
|
232 |
-
// If menu item is an ancestor
|
233 |
-
if ( in_array( intval( $parent_item->db_id ), $active_anc_item_ids ) ) {
|
234 |
-
$classes[] = 'current-menu-ancestor';
|
235 |
-
$items[ $key ]->current_item_ancestor = true;
|
236 |
-
}
|
237 |
-
|
238 |
-
$items[ $key ]->classes = array_unique( $classes );
|
239 |
-
}
|
240 |
-
}
|
241 |
-
|
242 |
-
return $items;
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Get menu item's ancestors
|
247 |
-
* @param object $item
|
248 |
-
* @return array $active_anc_item_ids
|
249 |
-
*/
|
250 |
-
public function get_item_ancestors( $item ) {
|
251 |
-
$anc_id = absint( $item->db_id );
|
252 |
-
|
253 |
-
$active_anc_item_ids = array();
|
254 |
-
while (
|
255 |
-
$anc_id = get_post_meta( $anc_id, '_menu_item_menu_item_parent', true )
|
256 |
-
AND ! in_array( $anc_id, $active_anc_item_ids )
|
257 |
-
)
|
258 |
-
$active_anc_item_ids[] = $anc_id;
|
259 |
-
|
260 |
-
return $active_anc_item_ids;
|
261 |
-
}
|
262 |
-
|
263 |
function set($post_type, $settings = null)
|
264 |
{
|
265 |
$data = get_post_type_object( $post_type );
|
3 |
*
|
4 |
* Post Types Class
|
5 |
*
|
6 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/embedded/classes/class.wpcf-post-types.php $
|
7 |
+
* $LastChangedDate: 2014-05-13 12:49:25 +0200 (Tue, 13 May 2014) $
|
8 |
+
* $LastChangedRevision: 22267 $
|
9 |
+
* $LastChangedBy: marcin $
|
10 |
*
|
11 |
*/
|
12 |
|
29 |
var $settings;
|
30 |
var $messages = null;
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
function set($post_type, $settings = null)
|
33 |
{
|
34 |
$data = get_post_type_object( $post_type );
|
embedded/classes/editor.php
CHANGED
@@ -284,7 +284,8 @@ class WPCF_Editor
|
|
284 |
/*
|
285 |
* Callback
|
286 |
*/
|
287 |
-
$shortcode = call_user_func( $function, $_POST, $this->field,
|
|
|
288 |
} else {
|
289 |
/*
|
290 |
* Generic
|
@@ -304,7 +305,8 @@ class WPCF_Editor
|
|
304 |
*/
|
305 |
$shortcode = preg_replace( '@</?script[^>]*>@im', '', wp_kses_post($shortcode) );
|
306 |
// Add additional parameters if required
|
307 |
-
$shortcode = $this->_add_parameters_to_shortcode( $shortcode,
|
|
|
308 |
// Insert shortcode
|
309 |
echo '<script type="text/javascript">jQuery(function(){tedFrame.close(\''
|
310 |
. $shortcode . '\', \'' . esc_js( $shortcode ) . '\');});</script>';
|
284 |
/*
|
285 |
* Callback
|
286 |
*/
|
287 |
+
$shortcode = call_user_func( $function, $_POST, $this->field,
|
288 |
+
$this->_meta_type );
|
289 |
} else {
|
290 |
/*
|
291 |
* Generic
|
305 |
*/
|
306 |
$shortcode = preg_replace( '@</?script[^>]*>@im', '', wp_kses_post($shortcode) );
|
307 |
// Add additional parameters if required
|
308 |
+
$shortcode = $this->_add_parameters_to_shortcode( $shortcode,
|
309 |
+
$_POST );
|
310 |
// Insert shortcode
|
311 |
echo '<script type="text/javascript">jQuery(function(){tedFrame.close(\''
|
312 |
. $shortcode . '\', \'' . esc_js( $shortcode ) . '\');});</script>';
|
embedded/classes/field.php
CHANGED
@@ -2,37 +2,37 @@
|
|
2 |
/*
|
3 |
* Field class.
|
4 |
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
6 |
-
* $LastChangedDate: 2015-
|
7 |
-
* $LastChangedRevision:
|
8 |
* $LastChangedBy: iworks $
|
9 |
*
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Base class.
|
14 |
-
*
|
15 |
* Fields are our core items and we'll use this class to sort them out a little.
|
16 |
* Very useful, should be used to finish small tasks for field.
|
17 |
-
*
|
18 |
* Example:
|
19 |
-
*
|
20 |
* // Setup field
|
21 |
* global $wpcf;
|
22 |
* $my_field = new WPCF_Field();
|
23 |
* $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
|
24 |
-
*
|
25 |
* // Use it
|
26 |
* $my_field->save();
|
27 |
-
*
|
28 |
* // Generic instance can be found in global $wpcf.
|
29 |
* global $wpcf;
|
30 |
* $wpcf->field->set(...);
|
31 |
-
*
|
32 |
* !! BE CAREFUL !! not to disturb global instance if you suspect processing
|
33 |
* current item is not finished. Core code sometimes use same instance over
|
34 |
* few functions and places.
|
35 |
-
*
|
36 |
* @since Types 1.2
|
37 |
* @package Types
|
38 |
* @subpackage Classes
|
@@ -45,18 +45,18 @@ class WPCF_Field
|
|
45 |
|
46 |
/**
|
47 |
* Field structure
|
48 |
-
*
|
49 |
* This is actually a form array collected from files per specific field:
|
50 |
* /embedded/includes/fields/$field_type.php
|
51 |
* /includes/fields/$field_type.php
|
52 |
-
*
|
53 |
* @var type array
|
54 |
*/
|
55 |
var $cf = array();
|
56 |
|
57 |
/**
|
58 |
* All Types created fields
|
59 |
-
* @var type
|
60 |
*/
|
61 |
var $fields = null;
|
62 |
|
@@ -68,9 +68,9 @@ class WPCF_Field
|
|
68 |
|
69 |
/**
|
70 |
* Field config.
|
71 |
-
*
|
72 |
* Use it to set default configuration.
|
73 |
-
*
|
74 |
* @var type array
|
75 |
*/
|
76 |
var $config = array(
|
@@ -102,8 +102,8 @@ class WPCF_Field
|
|
102 |
|
103 |
/**
|
104 |
* Cache.DEPRECATED
|
105 |
-
*
|
106 |
-
* @var type
|
107 |
*/
|
108 |
var $cache = array();
|
109 |
|
@@ -115,25 +115,25 @@ class WPCF_Field
|
|
115 |
|
116 |
/**
|
117 |
* Context in which class is called
|
118 |
-
* @var type
|
119 |
*/
|
120 |
var $context = 'group';
|
121 |
|
122 |
/**
|
123 |
* Invalid fields
|
124 |
-
*
|
125 |
* @todo Revise
|
126 |
-
* @var type
|
127 |
*/
|
128 |
var $invalid_fields = array();
|
129 |
|
130 |
/**
|
131 |
-
* ID
|
132 |
*/
|
133 |
var $ID = '';
|
134 |
|
135 |
/**
|
136 |
-
* Unique ID
|
137 |
*/
|
138 |
var $unique_id = '';
|
139 |
|
@@ -144,16 +144,16 @@ class WPCF_Field
|
|
144 |
|
145 |
/**
|
146 |
* Set current post and field.
|
147 |
-
*
|
148 |
* @param type $post
|
149 |
-
* @param type $cf
|
150 |
*/
|
151 |
function set( $post, $cf ) {
|
152 |
|
153 |
global $wpcf;
|
154 |
|
155 |
/*
|
156 |
-
*
|
157 |
* Check if $cf is string
|
158 |
*/
|
159 |
if ( is_string( $cf ) ) {
|
@@ -218,8 +218,8 @@ class WPCF_Field
|
|
218 |
|
219 |
/**
|
220 |
* Set needed but not required form elements.
|
221 |
-
*
|
222 |
-
* @param string $cf
|
223 |
*/
|
224 |
function _parse_cf_form_element( $cf ) {
|
225 |
$p = array('#before' => '', '#after' => '', '#description' => '');
|
@@ -233,9 +233,8 @@ class WPCF_Field
|
|
233 |
|
234 |
/**
|
235 |
* Fetch and sort fields.
|
236 |
-
*
|
237 |
-
* @global
|
238 |
-
*
|
239 |
*/
|
240 |
function _get_meta() {
|
241 |
global $wpdb;
|
@@ -302,16 +301,18 @@ class WPCF_Field
|
|
302 |
* Apply filters
|
303 |
*/
|
304 |
$meta = apply_filters( 'wpcf_fields_value_get', $meta, $this );
|
305 |
-
$meta = apply_filters( 'wpcf_fields_slug_' . $this->cf['slug']
|
306 |
-
|
|
|
|
|
307 |
|
308 |
return $meta;
|
309 |
}
|
310 |
|
311 |
/**
|
312 |
* Gets $_POST data.
|
313 |
-
*
|
314 |
-
* @return type
|
315 |
*/
|
316 |
function get_submitted_data() {
|
317 |
$posted = isset( $_POST['wpcf'][$this->cf['slug']] ) ? $_POST['wpcf'][$this->cf['slug']] : null;
|
@@ -321,12 +322,12 @@ class WPCF_Field
|
|
321 |
|
322 |
/**
|
323 |
* Save field.
|
324 |
-
*
|
325 |
* If $value is empty, $_POST will be checked.
|
326 |
* 1.3.2 Reverted saving empty fields
|
327 |
* removed - if ( !empty( $value ) || is_numeric( $value ) ) {
|
328 |
-
*
|
329 |
-
* @param type $value
|
330 |
*/
|
331 |
function save( $value = null )
|
332 |
{
|
@@ -395,16 +396,18 @@ class WPCF_Field
|
|
395 |
|
396 |
/**
|
397 |
* Apply filters to saved value.
|
398 |
-
*
|
399 |
* @param type $value
|
400 |
-
* @return type
|
401 |
*/
|
402 |
-
function _filter_save_value( $value )
|
403 |
-
{
|
404 |
// Apply filters
|
405 |
-
$value = apply_filters( 'wpcf_fields_value_save', $value,
|
406 |
-
|
407 |
-
$value = apply_filters( '
|
|
|
|
|
|
|
408 |
|
409 |
return $value;
|
410 |
}
|
@@ -412,16 +415,18 @@ class WPCF_Field
|
|
412 |
/**
|
413 |
* Use these hooks to add future functionality.
|
414 |
* Do not add any more code to core.
|
415 |
-
*
|
416 |
* @param type $field
|
417 |
* @param type $value
|
418 |
* @param type $meta_id
|
419 |
*/
|
420 |
-
function _action_save( $field, $value, $meta_id, $meta_value_original )
|
421 |
-
|
422 |
-
|
423 |
-
do_action( 'wpcf_fields_slug_' . $field['slug'] . '_save', $value,
|
424 |
-
|
|
|
|
|
425 |
}
|
426 |
|
427 |
/**
|
@@ -443,8 +448,8 @@ class WPCF_Field
|
|
443 |
|
444 |
/**
|
445 |
* Sets field config.
|
446 |
-
*
|
447 |
-
* @return type
|
448 |
*/
|
449 |
function _get_config() {
|
450 |
$this->_include_file_by_field_type($this->cf['type']);
|
@@ -457,7 +462,7 @@ class WPCF_Field
|
|
457 |
|
458 |
/**
|
459 |
* Discouraged usage.
|
460 |
-
*
|
461 |
* @return type
|
462 |
*/
|
463 |
function _deprecated_inherited_allowed() {
|
@@ -472,8 +477,8 @@ class WPCF_Field
|
|
472 |
|
473 |
/**
|
474 |
* Sets field meta box form.
|
475 |
-
*
|
476 |
-
* @return type
|
477 |
*/
|
478 |
function _get_meta_form( $meta_value = null, $meta_id = null, $wrap = true ) {
|
479 |
|
@@ -485,7 +490,7 @@ class WPCF_Field
|
|
485 |
|
486 |
/*
|
487 |
* Set value
|
488 |
-
*
|
489 |
* IMPORTANT
|
490 |
* Here we set values for form elements
|
491 |
*/
|
@@ -507,10 +512,10 @@ class WPCF_Field
|
|
507 |
}
|
508 |
|
509 |
/*
|
510 |
-
*
|
511 |
-
*
|
512 |
-
*
|
513 |
-
*
|
514 |
* Since Types 1.2
|
515 |
* Avoid using parent (inherited) type
|
516 |
* $this->config->inherited_field_type
|
@@ -550,7 +555,7 @@ class WPCF_Field
|
|
550 |
$func = 'wpcf_fields_' . $this->cf['type'] . '_meta_box_form';
|
551 |
if ( is_callable( $func ) ) {
|
552 |
/*
|
553 |
-
*
|
554 |
* From Types 1.2 use complete form setup
|
555 |
*/
|
556 |
$form_meta_box = call_user_func_array( 'wpcf_fields_'
|
@@ -577,7 +582,7 @@ class WPCF_Field
|
|
577 |
foreach ( $form as $element_key => $element ) {
|
578 |
|
579 |
/*
|
580 |
-
*
|
581 |
* Start using __ in keys to skip element
|
582 |
*/
|
583 |
// Skip protected
|
@@ -615,7 +620,8 @@ class WPCF_Field
|
|
615 |
}
|
616 |
|
617 |
// Set form element
|
618 |
-
$form[$element_key] = apply_filters( 'wpcf_post_edit_field',
|
|
|
619 |
}
|
620 |
|
621 |
// Add to editor
|
@@ -697,17 +703,10 @@ class WPCF_Field
|
|
697 |
|
698 |
/**
|
699 |
* Use this function to add final filters to HTML output.
|
700 |
-
*
|
701 |
-
* @param type $output
|
702 |
*/
|
703 |
-
function html( $html, $params )
|
704 |
-
{
|
705 |
-
/**
|
706 |
-
* check input
|
707 |
-
*/
|
708 |
-
if ( is_array($html) || is_object($html) ) {
|
709 |
-
return '';
|
710 |
-
}
|
711 |
/**
|
712 |
*
|
713 |
* Exception when RAW = TRUE.
|
@@ -720,18 +719,20 @@ class WPCF_Field
|
|
720 |
$html = htmlspecialchars( $html );
|
721 |
}
|
722 |
// Process shortcodes too
|
|
|
723 |
$html = do_shortcode( htmlspecialchars_decode( stripslashes( $html ) ) );
|
|
|
724 |
return $html;
|
725 |
}
|
726 |
|
727 |
/**
|
728 |
* Determines if field is created with Types.
|
729 |
-
*
|
730 |
* @param type $field_key
|
731 |
*/
|
732 |
function is_under_control( $field_key ) {
|
733 |
/*
|
734 |
-
*
|
735 |
* We force checking our meta prefix
|
736 |
*/
|
737 |
$key = $this->__get_slug_no_prefix( $field_key );
|
@@ -740,7 +741,7 @@ class WPCF_Field
|
|
740 |
|
741 |
/**
|
742 |
* Return slug.
|
743 |
-
*
|
744 |
* @param type $meta_key
|
745 |
* @return type
|
746 |
*/
|
@@ -751,14 +752,14 @@ class WPCF_Field
|
|
751 |
|
752 |
/**
|
753 |
* Returns altered element form name.
|
754 |
-
*
|
755 |
* Use $prefix to set name like:
|
756 |
* wpcf_post_relationship[214][wpcf-my-checkbox]
|
757 |
-
*
|
758 |
* Or if multi array
|
759 |
* wpcf_post_relationship[214][wpcf-my-date][datepicker]
|
760 |
* wpcf_post_relationship[214][wpcf-my-date][hour]
|
761 |
-
*
|
762 |
* @param type $prefix
|
763 |
* @param type $name
|
764 |
* @return type
|
@@ -775,7 +776,7 @@ class WPCF_Field
|
|
775 |
. $this->post->ID
|
776 |
. '][' . $this->slug . ']';
|
777 |
/*
|
778 |
-
*
|
779 |
* Multi array case
|
780 |
*/
|
781 |
} else {
|
2 |
/*
|
3 |
* Field class.
|
4 |
*
|
5 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/classes/field.php $
|
6 |
+
* $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
|
7 |
+
* $LastChangedRevision: 1180956 $
|
8 |
* $LastChangedBy: iworks $
|
9 |
*
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
* Base class.
|
14 |
+
*
|
15 |
* Fields are our core items and we'll use this class to sort them out a little.
|
16 |
* Very useful, should be used to finish small tasks for field.
|
17 |
+
*
|
18 |
* Example:
|
19 |
+
*
|
20 |
* // Setup field
|
21 |
* global $wpcf;
|
22 |
* $my_field = new WPCF_Field();
|
23 |
* $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
|
24 |
+
*
|
25 |
* // Use it
|
26 |
* $my_field->save();
|
27 |
+
*
|
28 |
* // Generic instance can be found in global $wpcf.
|
29 |
* global $wpcf;
|
30 |
* $wpcf->field->set(...);
|
31 |
+
*
|
32 |
* !! BE CAREFUL !! not to disturb global instance if you suspect processing
|
33 |
* current item is not finished. Core code sometimes use same instance over
|
34 |
* few functions and places.
|
35 |
+
*
|
36 |
* @since Types 1.2
|
37 |
* @package Types
|
38 |
* @subpackage Classes
|
45 |
|
46 |
/**
|
47 |
* Field structure
|
48 |
+
*
|
49 |
* This is actually a form array collected from files per specific field:
|
50 |
* /embedded/includes/fields/$field_type.php
|
51 |
* /includes/fields/$field_type.php
|
52 |
+
*
|
53 |
* @var type array
|
54 |
*/
|
55 |
var $cf = array();
|
56 |
|
57 |
/**
|
58 |
* All Types created fields
|
59 |
+
* @var type
|
60 |
*/
|
61 |
var $fields = null;
|
62 |
|
68 |
|
69 |
/**
|
70 |
* Field config.
|
71 |
+
*
|
72 |
* Use it to set default configuration.
|
73 |
+
*
|
74 |
* @var type array
|
75 |
*/
|
76 |
var $config = array(
|
102 |
|
103 |
/**
|
104 |
* Cache.DEPRECATED
|
105 |
+
*
|
106 |
+
* @var type
|
107 |
*/
|
108 |
var $cache = array();
|
109 |
|
115 |
|
116 |
/**
|
117 |
* Context in which class is called
|
118 |
+
* @var type
|
119 |
*/
|
120 |
var $context = 'group';
|
121 |
|
122 |
/**
|
123 |
* Invalid fields
|
124 |
+
*
|
125 |
* @todo Revise
|
126 |
+
* @var type
|
127 |
*/
|
128 |
var $invalid_fields = array();
|
129 |
|
130 |
/**
|
131 |
+
* ID
|
132 |
*/
|
133 |
var $ID = '';
|
134 |
|
135 |
/**
|
136 |
+
* Unique ID
|
137 |
*/
|
138 |
var $unique_id = '';
|
139 |
|
144 |
|
145 |
/**
|
146 |
* Set current post and field.
|
147 |
+
*
|
148 |
* @param type $post
|
149 |
+
* @param type $cf
|
150 |
*/
|
151 |
function set( $post, $cf ) {
|
152 |
|
153 |
global $wpcf;
|
154 |
|
155 |
/*
|
156 |
+
*
|
157 |
* Check if $cf is string
|
158 |
*/
|
159 |
if ( is_string( $cf ) ) {
|
218 |
|
219 |
/**
|
220 |
* Set needed but not required form elements.
|
221 |
+
*
|
222 |
+
* @param string $cf
|
223 |
*/
|
224 |
function _parse_cf_form_element( $cf ) {
|
225 |
$p = array('#before' => '', '#after' => '', '#description' => '');
|
233 |
|
234 |
/**
|
235 |
* Fetch and sort fields.
|
236 |
+
*
|
237 |
+
* @global type $wpdb
|
|
|
238 |
*/
|
239 |
function _get_meta() {
|
240 |
global $wpdb;
|
301 |
* Apply filters
|
302 |
*/
|
303 |
$meta = apply_filters( 'wpcf_fields_value_get', $meta, $this );
|
304 |
+
$meta = apply_filters( 'wpcf_fields_slug_' . $this->cf['slug']
|
305 |
+
. '_value_get', $meta, $this );
|
306 |
+
$meta = apply_filters( 'wpcf_fields_type_' . $this->cf['type']
|
307 |
+
. '_value_get', $meta, $this );
|
308 |
|
309 |
return $meta;
|
310 |
}
|
311 |
|
312 |
/**
|
313 |
* Gets $_POST data.
|
314 |
+
*
|
315 |
+
* @return type
|
316 |
*/
|
317 |
function get_submitted_data() {
|
318 |
$posted = isset( $_POST['wpcf'][$this->cf['slug']] ) ? $_POST['wpcf'][$this->cf['slug']] : null;
|
322 |
|
323 |
/**
|
324 |
* Save field.
|
325 |
+
*
|
326 |
* If $value is empty, $_POST will be checked.
|
327 |
* 1.3.2 Reverted saving empty fields
|
328 |
* removed - if ( !empty( $value ) || is_numeric( $value ) ) {
|
329 |
+
*
|
330 |
+
* @param type $value
|
331 |
*/
|
332 |
function save( $value = null )
|
333 |
{
|
396 |
|
397 |
/**
|
398 |
* Apply filters to saved value.
|
399 |
+
*
|
400 |
* @param type $value
|
401 |
+
* @return type
|
402 |
*/
|
403 |
+
function _filter_save_value( $value ) {
|
|
|
404 |
// Apply filters
|
405 |
+
$value = apply_filters( 'wpcf_fields_value_save', $value,
|
406 |
+
$this->cf['type'], $this->cf['slug'], $this->cf, $this );
|
407 |
+
$value = apply_filters( 'wpcf_fields_slug_' . $this->cf['slug']
|
408 |
+
. '_value_save', $value, $this->cf, $this );
|
409 |
+
$value = apply_filters( 'wpcf_fields_type_' . $this->cf['type']
|
410 |
+
. '_value_save', $value, $this->cf, $this );
|
411 |
|
412 |
return $value;
|
413 |
}
|
415 |
/**
|
416 |
* Use these hooks to add future functionality.
|
417 |
* Do not add any more code to core.
|
418 |
+
*
|
419 |
* @param type $field
|
420 |
* @param type $value
|
421 |
* @param type $meta_id
|
422 |
*/
|
423 |
+
function _action_save( $field, $value, $meta_id, $meta_value_original ) {
|
424 |
+
do_action( 'wpcf_fields_save', $value, $field, $this, $meta_id,
|
425 |
+
$meta_value_original );
|
426 |
+
do_action( 'wpcf_fields_slug_' . $field['slug'] . '_save', $value,
|
427 |
+
$field, $this, $meta_id, $meta_value_original );
|
428 |
+
do_action( 'wpcf_fields_type_' . $field['type'] . '_save', $value,
|
429 |
+
$field, $this, $meta_id, $meta_value_original );
|
430 |
}
|
431 |
|
432 |
/**
|
448 |
|
449 |
/**
|
450 |
* Sets field config.
|
451 |
+
*
|
452 |
+
* @return type
|
453 |
*/
|
454 |
function _get_config() {
|
455 |
$this->_include_file_by_field_type($this->cf['type']);
|
462 |
|
463 |
/**
|
464 |
* Discouraged usage.
|
465 |
+
*
|
466 |
* @return type
|
467 |
*/
|
468 |
function _deprecated_inherited_allowed() {
|
477 |
|
478 |
/**
|
479 |
* Sets field meta box form.
|
480 |
+
*
|
481 |
+
* @return type
|
482 |
*/
|
483 |
function _get_meta_form( $meta_value = null, $meta_id = null, $wrap = true ) {
|
484 |
|
490 |
|
491 |
/*
|
492 |
* Set value
|
493 |
+
*
|
494 |
* IMPORTANT
|
495 |
* Here we set values for form elements
|
496 |
*/
|
512 |
}
|
513 |
|
514 |
/*
|
515 |
+
*
|
516 |
+
*
|
517 |
+
*
|
518 |
+
*
|
519 |
* Since Types 1.2
|
520 |
* Avoid using parent (inherited) type
|
521 |
* $this->config->inherited_field_type
|
555 |
$func = 'wpcf_fields_' . $this->cf['type'] . '_meta_box_form';
|
556 |
if ( is_callable( $func ) ) {
|
557 |
/*
|
558 |
+
*
|
559 |
* From Types 1.2 use complete form setup
|
560 |
*/
|
561 |
$form_meta_box = call_user_func_array( 'wpcf_fields_'
|
582 |
foreach ( $form as $element_key => $element ) {
|
583 |
|
584 |
/*
|
585 |
+
*
|
586 |
* Start using __ in keys to skip element
|
587 |
*/
|
588 |
// Skip protected
|
620 |
}
|
621 |
|
622 |
// Set form element
|
623 |
+
$form[$element_key] = apply_filters( 'wpcf_post_edit_field',
|
624 |
+
$element, $this->cf, $this->post, $this->context );
|
625 |
}
|
626 |
|
627 |
// Add to editor
|
703 |
|
704 |
/**
|
705 |
* Use this function to add final filters to HTML output.
|
706 |
+
*
|
707 |
+
* @param type $output
|
708 |
*/
|
709 |
+
function html( $html, $params ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
710 |
/**
|
711 |
*
|
712 |
* Exception when RAW = TRUE.
|
719 |
$html = htmlspecialchars( $html );
|
720 |
}
|
721 |
// Process shortcodes too
|
722 |
+
// $shortcode = do_shortcode( $html );
|
723 |
$html = do_shortcode( htmlspecialchars_decode( stripslashes( $html ) ) );
|
724 |
+
|
725 |
return $html;
|
726 |
}
|
727 |
|
728 |
/**
|
729 |
* Determines if field is created with Types.
|
730 |
+
*
|
731 |
* @param type $field_key
|
732 |
*/
|
733 |
function is_under_control( $field_key ) {
|
734 |
/*
|
735 |
+
*
|
736 |
* We force checking our meta prefix
|
737 |
*/
|
738 |
$key = $this->__get_slug_no_prefix( $field_key );
|
741 |
|
742 |
/**
|
743 |
* Return slug.
|
744 |
+
*
|
745 |
* @param type $meta_key
|
746 |
* @return type
|
747 |
*/
|
752 |
|
753 |
/**
|
754 |
* Returns altered element form name.
|
755 |
+
*
|
756 |
* Use $prefix to set name like:
|
757 |
* wpcf_post_relationship[214][wpcf-my-checkbox]
|
758 |
+
*
|
759 |
* Or if multi array
|
760 |
* wpcf_post_relationship[214][wpcf-my-date][datepicker]
|
761 |
* wpcf_post_relationship[214][wpcf-my-date][hour]
|
762 |
+
*
|
763 |
* @param type $prefix
|
764 |
* @param type $name
|
765 |
* @return type
|
776 |
. $this->post->ID
|
777 |
. '][' . $this->slug . ']';
|
778 |
/*
|
779 |
+
*
|
780 |
* Multi array case
|
781 |
*/
|
782 |
} else {
|
embedded/classes/fields.php
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
/**
|
3 |
* Fields class.
|
4 |
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
6 |
-
* $LastChangedDate:
|
7 |
-
* $LastChangedRevision:
|
8 |
* $LastChangedBy: iworks $
|
9 |
*
|
10 |
*/
|
2 |
/**
|
3 |
* Fields class.
|
4 |
*
|
5 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/classes/fields.php $
|
6 |
+
* $LastChangedDate: 2014-05-07 06:56:23 +0000 (Wed, 07 May 2014) $
|
7 |
+
* $LastChangedRevision: 909470 $
|
8 |
* $LastChangedBy: iworks $
|
9 |
*
|
10 |
*/
|
embedded/classes/forms.php
CHANGED
@@ -4,10 +4,10 @@
|
|
4 |
*
|
5 |
* Returns HTML formatted output for elements and handles form submission.
|
6 |
*
|
7 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
8 |
-
* $LastChangedDate:
|
9 |
-
* $LastChangedRevision:
|
10 |
-
* $LastChangedBy:
|
11 |
*
|
12 |
*
|
13 |
* @version 1.0
|
@@ -125,10 +125,8 @@ class Enlimbo_Forms_Wpcf
|
|
125 |
if ( empty( $id ) ) {
|
126 |
$id = $this->_id;
|
127 |
}
|
128 |
-
return (
|
129 |
-
|
130 |
-
&& wp_verify_nonce( $_REQUEST['_wpnonce_wpcf'], $id )
|
131 |
-
);
|
132 |
}
|
133 |
|
134 |
/**
|
@@ -922,15 +920,9 @@ class Enlimbo_Forms_Wpcf
|
|
922 |
array('textfield', 'textarea') ) ? '' : 0;
|
923 |
}
|
924 |
|
925 |
-
if ( !function_exists('getSubmittedDataTrim')) {
|
926 |
-
function getSubmittedDataTrim($a)
|
927 |
-
{
|
928 |
-
return trim($a, ']');
|
929 |
-
}
|
930 |
-
}
|
931 |
-
|
932 |
$parts = explode( '[', $name );
|
933 |
-
$parts = array_map( '
|
|
|
934 |
if ( !isset( $_REQUEST[$parts[0]] ) ) {
|
935 |
return in_array( $element['#type'], array('textfield', 'textarea') ) ? '' : 0;
|
936 |
}
|
4 |
*
|
5 |
* Returns HTML formatted output for elements and handles form submission.
|
6 |
*
|
7 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/classes/forms.php $
|
8 |
+
* $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
|
9 |
+
* $LastChangedRevision: 970205 $
|
10 |
+
* $LastChangedBy: brucepearson $
|
11 |
*
|
12 |
*
|
13 |
* @version 1.0
|
125 |
if ( empty( $id ) ) {
|
126 |
$id = $this->_id;
|
127 |
}
|
128 |
+
return (isset( $_REQUEST['_wpnonce_wpcf'] )
|
129 |
+
&& wp_verify_nonce( $_REQUEST['_wpnonce_wpcf'], $id ));
|
|
|
|
|
130 |
}
|
131 |
|
132 |
/**
|
920 |
array('textfield', 'textarea') ) ? '' : 0;
|
921 |
}
|
922 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
923 |
$parts = explode( '[', $name );
|
924 |
+
$parts = array_map( create_function( '&$a', 'return trim($a, \']\');' ),
|
925 |
+
$parts );
|
926 |
if ( !isset( $_REQUEST[$parts[0]] ) ) {
|
927 |
return in_array( $element['#type'], array('textfield', 'textarea') ) ? '' : 0;
|
928 |
}
|
embedded/classes/loader.php
CHANGED
@@ -3,16 +3,16 @@
|
|
3 |
*
|
4 |
* Loader class
|
5 |
*
|
6 |
-
* $HeadURL:
|
7 |
-
* $LastChangedDate:
|
8 |
-
* $LastChangedRevision:
|
9 |
-
* $LastChangedBy:
|
10 |
*
|
11 |
*/
|
12 |
|
13 |
/**
|
14 |
* Loader Class
|
15 |
-
*
|
16 |
* @since Types 1.2
|
17 |
* @package Types
|
18 |
* @subpackage Classes
|
@@ -25,7 +25,7 @@ class WPCF_Loader
|
|
25 |
|
26 |
/**
|
27 |
* Settings
|
28 |
-
* @var array
|
29 |
*/
|
30 |
private static $__settings = array();
|
31 |
|
@@ -38,14 +38,11 @@ class WPCF_Loader
|
|
38 |
array('WPCF_Loader', 'renderJsSettings'), 5 );
|
39 |
add_filter( 'the_posts', array('WPCF_Loader', 'wpcf_cache_complete_postmeta') );
|
40 |
}
|
41 |
-
|
42 |
/**
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
*
|
47 |
-
*/
|
48 |
-
|
49 |
public static function wpcf_cache_complete_postmeta( $posts ) {
|
50 |
global $wpdb;
|
51 |
if ( !$posts )
|
@@ -57,7 +54,7 @@ class WPCF_Loader
|
|
57 |
$cache_key_looped_post = md5( 'post::_is_cached' . $post->ID );
|
58 |
$cached_object = wp_cache_get( $cache_key_looped_post, $cache_group_ids );
|
59 |
if ( false === $cached_object ) {
|
60 |
-
$post_ids[] =
|
61 |
wp_cache_add( $cache_key_looped_post, $post->ID, $cache_group_ids );
|
62 |
}
|
63 |
}
|
@@ -153,7 +150,7 @@ class WPCF_Loader
|
|
153 |
|
154 |
/**
|
155 |
* Returns HTML formatted output.
|
156 |
-
*
|
157 |
* @param string $view
|
158 |
* @param mixed $data
|
159 |
* @return string
|
@@ -174,7 +171,7 @@ class WPCF_Loader
|
|
174 |
|
175 |
/**
|
176 |
* Returns HTML formatted output.
|
177 |
-
*
|
178 |
* @param string $view
|
179 |
* @param mixed $data
|
180 |
* @return string
|
@@ -190,7 +187,7 @@ class WPCF_Loader
|
|
190 |
|
191 |
/**
|
192 |
* Returns HTML formatted output.
|
193 |
-
*
|
194 |
* @param string $template
|
195 |
* @param mixed $data
|
196 |
* @return string
|
@@ -211,7 +208,7 @@ class WPCF_Loader
|
|
211 |
|
212 |
/**
|
213 |
* Loads model.
|
214 |
-
*
|
215 |
* @param string $template
|
216 |
* @param mixed $data
|
217 |
* @return string
|
@@ -227,7 +224,7 @@ class WPCF_Loader
|
|
227 |
|
228 |
/**
|
229 |
* Loads class.
|
230 |
-
*
|
231 |
* @param string $template
|
232 |
* @param mixed $data
|
233 |
* @return string
|
@@ -243,7 +240,7 @@ class WPCF_Loader
|
|
243 |
|
244 |
/**
|
245 |
* Loads include.
|
246 |
-
*
|
247 |
* @param string $template
|
248 |
* @param mixed $data
|
249 |
* @return string
|
@@ -259,7 +256,7 @@ class WPCF_Loader
|
|
259 |
|
260 |
/**
|
261 |
* Adds JS settings.
|
262 |
-
*
|
263 |
* @staticvar array $settings
|
264 |
* @param type $id
|
265 |
* @param type $setting
|
3 |
*
|
4 |
* Loader class
|
5 |
*
|
6 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/embedded/classes/loader.php $
|
7 |
+
* $LastChangedDate: 2014-06-26 19:13:20 +0200 (Thu, 26 Jun 2014) $
|
8 |
+
* $LastChangedRevision: 24403 $
|
9 |
+
* $LastChangedBy: juan $
|
10 |
*
|
11 |
*/
|
12 |
|
13 |
/**
|
14 |
* Loader Class
|
15 |
+
*
|
16 |
* @since Types 1.2
|
17 |
* @package Types
|
18 |
* @subpackage Classes
|
25 |
|
26 |
/**
|
27 |
* Settings
|
28 |
+
* @var array
|
29 |
*/
|
30 |
private static $__settings = array();
|
31 |
|
38 |
array('WPCF_Loader', 'renderJsSettings'), 5 );
|
39 |
add_filter( 'the_posts', array('WPCF_Loader', 'wpcf_cache_complete_postmeta') );
|
40 |
}
|
41 |
+
|
42 |
/**
|
43 |
+
* Cache the postmeta for posts returned by a WP_Query
|
44 |
+
*/
|
45 |
+
|
|
|
|
|
|
|
46 |
public static function wpcf_cache_complete_postmeta( $posts ) {
|
47 |
global $wpdb;
|
48 |
if ( !$posts )
|
54 |
$cache_key_looped_post = md5( 'post::_is_cached' . $post->ID );
|
55 |
$cached_object = wp_cache_get( $cache_key_looped_post, $cache_group_ids );
|
56 |
if ( false === $cached_object ) {
|
57 |
+
$post_ids[] = $post->ID;
|
58 |
wp_cache_add( $cache_key_looped_post, $post->ID, $cache_group_ids );
|
59 |
}
|
60 |
}
|
150 |
|
151 |
/**
|
152 |
* Returns HTML formatted output.
|
153 |
+
*
|
154 |
* @param string $view
|
155 |
* @param mixed $data
|
156 |
* @return string
|
171 |
|
172 |
/**
|
173 |
* Returns HTML formatted output.
|
174 |
+
*
|
175 |
* @param string $view
|
176 |
* @param mixed $data
|
177 |
* @return string
|
187 |
|
188 |
/**
|
189 |
* Returns HTML formatted output.
|
190 |
+
*
|
191 |
* @param string $template
|
192 |
* @param mixed $data
|
193 |
* @return string
|
208 |
|
209 |
/**
|
210 |
* Loads model.
|
211 |
+
*
|
212 |
* @param string $template
|
213 |
* @param mixed $data
|
214 |
* @return string
|
224 |
|
225 |
/**
|
226 |
* Loads class.
|
227 |
+
*
|
228 |
* @param string $template
|
229 |
* @param mixed $data
|
230 |
* @return string
|
240 |
|
241 |
/**
|
242 |
* Loads include.
|
243 |
+
*
|
244 |
* @param string $template
|
245 |
* @param mixed $data
|
246 |
* @return string
|
256 |
|
257 |
/**
|
258 |
* Adds JS settings.
|
259 |
+
*
|
260 |
* @staticvar array $settings
|
261 |
* @param type $id
|
262 |
* @param type $setting
|
embedded/classes/path.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
/**
|
3 |
* WPCF_Path
|
4 |
*
|
5 |
-
* $HeadURL:
|
6 |
-
* $LastChangedDate:
|
7 |
-
* $LastChangedRevision:
|
8 |
-
* $LastChangedBy:
|
9 |
*
|
10 |
*/
|
11 |
final class WPCF_Path
|
2 |
/**
|
3 |
* WPCF_Path
|
4 |
*
|
5 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/embedded/classes/path.php $
|
6 |
+
* $LastChangedDate: 2014-05-12 16:47:19 +0200 (Mon, 12 May 2014) $
|
7 |
+
* $LastChangedRevision: 22250 $
|
8 |
+
* $LastChangedBy: marcin $
|
9 |
*
|
10 |
*/
|
11 |
final class WPCF_Path
|
embedded/classes/post-types/messages.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
/*
|
3 |
* Messages.
|
4 |
*
|
5 |
-
* $HeadURL:
|
6 |
-
* $LastChangedDate:
|
7 |
-
* $LastChangedRevision:
|
8 |
-
* $LastChangedBy:
|
9 |
*
|
10 |
*/
|
11 |
|
2 |
/*
|
3 |
* Messages.
|
4 |
*
|
5 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/embedded/classes/post-types/messages.php $
|
6 |
+
* $LastChangedDate: 2014-05-13 12:49:25 +0200 (Tue, 13 May 2014) $
|
7 |
+
* $LastChangedRevision: 22267 $
|
8 |
+
* $LastChangedBy: marcin $
|
9 |
*
|
10 |
*/
|
11 |
|
embedded/classes/relationship.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
/*
|
3 |
* Post relationship class.
|
4 |
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
6 |
-
* $LastChangedDate:
|
7 |
-
* $LastChangedRevision:
|
8 |
-
* $LastChangedBy:
|
9 |
*
|
10 |
*/
|
11 |
|
@@ -201,8 +201,8 @@ class WPCF_Relationship
|
|
201 |
/**
|
202 |
* Bulk saving children.
|
203 |
*
|
204 |
-
* @param
|
205 |
-
* @param
|
206 |
*/
|
207 |
function save_children($parent_id, $children)
|
208 |
{
|
@@ -214,13 +214,13 @@ class WPCF_Relationship
|
|
214 |
/**
|
215 |
* Unified save child function.
|
216 |
*
|
217 |
-
* @param
|
218 |
-
* @param
|
219 |
-
* @param array $save_fields
|
220 |
-
* @return bool|WP_Error
|
221 |
*/
|
222 |
function save_child( $parent_id, $child_id, $save_fields = array() )
|
223 |
{
|
|
|
|
|
224 |
$parent = get_post( intval( $parent_id ) );
|
225 |
$child = get_post( intval( $child_id ) );
|
226 |
$post_data = array();
|
@@ -254,7 +254,6 @@ class WPCF_Relationship
|
|
254 |
$post_title = $save_fields['_wp_title'];
|
255 |
}
|
256 |
|
257 |
-
|
258 |
$post_data['post_title'] = $post_title;
|
259 |
$post_data['post_content'] = isset( $save_fields['_wp_body'] ) ? $save_fields['_wp_body'] : $child->post_content;
|
260 |
$post_data['post_type'] = $child->post_type;
|
@@ -276,31 +275,7 @@ class WPCF_Relationship
|
|
276 |
* UPDATE POST
|
277 |
*/
|
278 |
|
279 |
-
$cf = new WPCF_Field;
|
280 |
-
if (
|
281 |
-
isset( $_POST['wpcf_post_relationship'][$parent_id])
|
282 |
-
&& isset( $_POST['wpcf_post_relationship'][$parent_id][$child_id] )
|
283 |
-
) {
|
284 |
-
$_POST['wpcf'] = array();
|
285 |
-
foreach( $_POST['wpcf_post_relationship'][$parent_id][$child_id] as $slug => $value ) {
|
286 |
-
$_POST['wpcf'][$cf->__get_slug_no_prefix( $slug )] = $value;
|
287 |
-
$_POST['wpcf'][$slug] = $value;
|
288 |
-
}
|
289 |
-
}
|
290 |
-
unset($cf);
|
291 |
-
|
292 |
-
/**
|
293 |
-
* avoid filters for children
|
294 |
-
* /
|
295 |
-
global $wp_filter;
|
296 |
-
$save_post = $wp_filter['save_post'];
|
297 |
-
$wp_filter['save_post'] = array();
|
298 |
-
*/
|
299 |
$updated_id = wp_update_post( $post_data );
|
300 |
-
/*
|
301 |
-
$wp_filter['save_post'] = $save_post;
|
302 |
-
*/
|
303 |
-
unset($save_post);
|
304 |
if ( empty( $updated_id ) ) {
|
305 |
return new WP_Error( 'relationship-update-post-failed', 'Updating post failed' );
|
306 |
}
|
@@ -391,47 +366,37 @@ class WPCF_Relationship
|
|
391 |
/**
|
392 |
* Saves new child.
|
393 |
*
|
394 |
-
* @param
|
395 |
-
* @param
|
396 |
-
* @return
|
397 |
*/
|
398 |
function add_new_child($parent_id, $post_type)
|
399 |
{
|
400 |
global $wpdb;
|
|
|
401 |
$parent = get_post( $parent_id );
|
402 |
if ( empty( $parent ) ) {
|
403 |
return new WP_Error( 'wpcf-relationship-no-parent', 'No parent' );
|
404 |
}
|
405 |
$new_post = array(
|
406 |
-
'post_title' =>
|
407 |
'post_type' => $post_type,
|
408 |
'post_status' => 'draft',
|
409 |
);
|
410 |
$id = wp_insert_post( $new_post, true );
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
}
|
417 |
-
/**
|
418 |
-
* Mark that it is new post
|
419 |
-
*/
|
420 |
-
update_post_meta( $id, '_wpcf_relationship_new', 1 );
|
421 |
-
/**
|
422 |
-
* Save relationship
|
423 |
-
*/
|
424 |
-
update_post_meta( $id, '_wpcf_belongs_' . $parent->post_type . '_id', $parent->ID );
|
425 |
-
/**
|
426 |
-
* Fix title
|
427 |
-
*/
|
428 |
-
$wpdb->update(
|
429 |
-
$wpdb->posts,
|
430 |
-
array('post_title' => $post_type . ' ' . $id),
|
431 |
-
array('ID' => $id), array('%s'), array('%d')
|
432 |
-
);
|
433 |
-
do_action( 'wpcf_relationship_add_child', get_post( $id ), $parent );
|
434 |
-
wp_cache_flush();
|
435 |
return $id;
|
436 |
}
|
437 |
|
@@ -528,45 +493,4 @@ class WPCF_Relationship
|
|
528 |
die();
|
529 |
}
|
530 |
|
531 |
-
/**
|
532 |
-
* Meta box form on post edit page.
|
533 |
-
*
|
534 |
-
* @param type $parent Parent post
|
535 |
-
* @param type $post_type Child post type
|
536 |
-
* @return type string HTML formatted list
|
537 |
-
*/
|
538 |
-
function child_list($parent, $post_type)
|
539 |
-
{
|
540 |
-
if ( is_integer( $parent ) ) {
|
541 |
-
$parent = get_post( $parent );
|
542 |
-
}
|
543 |
-
$output = '';
|
544 |
-
require_once dirname( __FILE__ ) . '/relationship/form-child.php';
|
545 |
-
$this->child_form = new WPCF_Relationship_Child_Form(
|
546 |
-
$parent,
|
547 |
-
$post_type,
|
548 |
-
$this->settings( $parent->post_type, $post_type )
|
549 |
-
);
|
550 |
-
foreach($this->child_form->children as $child) {
|
551 |
-
$output .= sprintf(
|
552 |
-
'<li>%s</li>',
|
553 |
-
apply_filters('post_title', $child->post_title)
|
554 |
-
);
|
555 |
-
}
|
556 |
-
if ( $output ) {
|
557 |
-
$output = sprintf(
|
558 |
-
'<ul>%s</ul>',
|
559 |
-
$output
|
560 |
-
);
|
561 |
-
} else {
|
562 |
-
$output = sprintf(
|
563 |
-
'<p class="info">%s</p>',
|
564 |
-
$this->child_form->child_post_type_object->labels->not_found
|
565 |
-
);
|
566 |
-
}
|
567 |
-
|
568 |
-
return $output;
|
569 |
-
}
|
570 |
-
|
571 |
-
|
572 |
}
|
2 |
/*
|
3 |
* Post relationship class.
|
4 |
*
|
5 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/classes/relationship.php $
|
6 |
+
* $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
|
7 |
+
* $LastChangedRevision: 970205 $
|
8 |
+
* $LastChangedBy: brucepearson $
|
9 |
*
|
10 |
*/
|
11 |
|
201 |
/**
|
202 |
* Bulk saving children.
|
203 |
*
|
204 |
+
* @param type $parent_id
|
205 |
+
* @param type $children
|
206 |
*/
|
207 |
function save_children($parent_id, $children)
|
208 |
{
|
214 |
/**
|
215 |
* Unified save child function.
|
216 |
*
|
217 |
+
* @param type $child_id
|
218 |
+
* @param type $parent_id
|
|
|
|
|
219 |
*/
|
220 |
function save_child( $parent_id, $child_id, $save_fields = array() )
|
221 |
{
|
222 |
+
global $wpdb;
|
223 |
+
|
224 |
$parent = get_post( intval( $parent_id ) );
|
225 |
$child = get_post( intval( $child_id ) );
|
226 |
$post_data = array();
|
254 |
$post_title = $save_fields['_wp_title'];
|
255 |
}
|
256 |
|
|
|
257 |
$post_data['post_title'] = $post_title;
|
258 |
$post_data['post_content'] = isset( $save_fields['_wp_body'] ) ? $save_fields['_wp_body'] : $child->post_content;
|
259 |
$post_data['post_type'] = $child->post_type;
|
275 |
* UPDATE POST
|
276 |
*/
|
277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
$updated_id = wp_update_post( $post_data );
|
|
|
|
|
|
|
|
|
279 |
if ( empty( $updated_id ) ) {
|
280 |
return new WP_Error( 'relationship-update-post-failed', 'Updating post failed' );
|
281 |
}
|
366 |
/**
|
367 |
* Saves new child.
|
368 |
*
|
369 |
+
* @param type $parent_id
|
370 |
+
* @param type $post_type
|
371 |
+
* @return type
|
372 |
*/
|
373 |
function add_new_child($parent_id, $post_type)
|
374 |
{
|
375 |
global $wpdb;
|
376 |
+
|
377 |
$parent = get_post( $parent_id );
|
378 |
if ( empty( $parent ) ) {
|
379 |
return new WP_Error( 'wpcf-relationship-no-parent', 'No parent' );
|
380 |
}
|
381 |
$new_post = array(
|
382 |
+
'post_title' => ' ', // WP requires at least title with space
|
383 |
'post_type' => $post_type,
|
384 |
'post_status' => 'draft',
|
385 |
);
|
386 |
$id = wp_insert_post( $new_post, true );
|
387 |
+
if ( !is_wp_error( $id ) ) {
|
388 |
+
// Mark that it is new post
|
389 |
+
update_post_meta( $id, '_wpcf_relationship_new', 1 );
|
390 |
+
// Save relationship
|
391 |
+
update_post_meta( $id,
|
392 |
+
'_wpcf_belongs_' . $parent->post_type . '_id', $parent->ID );
|
393 |
+
// Fix title
|
394 |
+
$wpdb->update( $wpdb->posts,
|
395 |
+
array('post_title' => $post_type . ' ' . $id),
|
396 |
+
array('ID' => $id), array('%s'), array('%d') );
|
397 |
+
do_action( 'wpcf_relationship_add_child', get_post( $id ), $parent );
|
398 |
+
wp_cache_flush();
|
399 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
return $id;
|
401 |
}
|
402 |
|
493 |
die();
|
494 |
}
|
495 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
}
|
embedded/classes/relationship/form-child.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
* Relationship form class.
|
4 |
-
*
|
5 |
* Used to render child forms
|
6 |
*/
|
7 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
8 |
|
9 |
/**
|
10 |
* Relationship form class.
|
11 |
-
*
|
12 |
* Used on post edit page to show children rows
|
13 |
*/
|
14 |
class WPCF_Relationship_Child_Form
|
@@ -16,29 +16,29 @@ class WPCF_Relationship_Child_Form
|
|
16 |
|
17 |
/**
|
18 |
* Current post.
|
19 |
-
*
|
20 |
* @var type object
|
21 |
*/
|
22 |
var $post;
|
23 |
|
24 |
/**
|
25 |
* Field object.
|
26 |
-
*
|
27 |
* @var type array
|
28 |
*/
|
29 |
var $cf = array();
|
30 |
|
31 |
/**
|
32 |
* Saved data.
|
33 |
-
*
|
34 |
* @var type array
|
35 |
*/
|
36 |
var $data = array();
|
37 |
|
38 |
/**
|
39 |
* Child post object.
|
40 |
-
*
|
41 |
-
* @var type
|
42 |
*/
|
43 |
var $child_post_type_object;
|
44 |
var $parent;
|
@@ -52,23 +52,6 @@ class WPCF_Relationship_Child_Form
|
|
52 |
'field');
|
53 |
private $__urlParams = array();
|
54 |
|
55 |
-
/**
|
56 |
-
* post type configuration
|
57 |
-
*/
|
58 |
-
private $child_supports = array(
|
59 |
-
'title' => false,
|
60 |
-
'editor' => false,
|
61 |
-
'comments' => false,
|
62 |
-
'trackbacks' => false,
|
63 |
-
'revisions' => false,
|
64 |
-
'author' => false,
|
65 |
-
'excerpt' => false,
|
66 |
-
'thumbnail' => false,
|
67 |
-
'custom-fields' => false,
|
68 |
-
'page-attributes' => false,
|
69 |
-
'post-formats' => false,
|
70 |
-
);
|
71 |
-
|
72 |
/**
|
73 |
* Construct function.
|
74 |
*/
|
@@ -84,13 +67,8 @@ class WPCF_Relationship_Child_Form
|
|
84 |
}
|
85 |
$this->cf = new WPCF_Field();
|
86 |
$this->cf->context = 'relationship';
|
87 |
-
$this->children = WPCF_Relationship_Model::getChildrenByPostType(
|
88 |
-
|
89 |
-
$this->child_post_type,
|
90 |
-
$this->data,
|
91 |
-
$_GET
|
92 |
-
);
|
93 |
-
|
94 |
// If no children - use dummy post
|
95 |
if ( empty( $this->children ) ) {
|
96 |
$_dummy_post = get_default_post_to_edit( $this->child_post_type,
|
@@ -99,37 +77,15 @@ class WPCF_Relationship_Child_Form
|
|
99 |
$this->_dummy_post = true;
|
100 |
}
|
101 |
$this->child_post_type_object = get_post_type_object( $this->child_post_type );
|
102 |
-
|
103 |
// Collect params from request
|
104 |
foreach ( $this->__params as $__param ) {
|
105 |
if ( isset( $_GET[$__param] ) ) {
|
106 |
$this->__urlParams[$__param] = $_GET[$__param];
|
107 |
}
|
108 |
}
|
109 |
-
/**
|
110 |
-
* build-in types
|
111 |
-
*/
|
112 |
-
if ( in_array($child_post_type, array('page', 'post', 'attachment', 'revision', 'nav_menu_item') ) ) {
|
113 |
-
foreach( array_keys($this->child_supports) as $key ) {
|
114 |
-
$this->child_supports[$key] = post_type_supports($child_post_type, $key);
|
115 |
-
}
|
116 |
-
return;
|
117 |
-
}
|
118 |
-
/**
|
119 |
-
* custom post types
|
120 |
-
*/
|
121 |
-
$post_types = get_option( 'wpcf-custom-types', array() );
|
122 |
-
if (
|
123 |
-
array_key_exists($child_post_type, $post_types )
|
124 |
-
&& array_key_exists('supports', $post_types[$child_post_type] )
|
125 |
-
) {
|
126 |
-
foreach( $post_types[$child_post_type]['supports'] as $key => $value ) {
|
127 |
-
$this->child_supports[$key] = (boolean)$value;
|
128 |
-
}
|
129 |
-
}
|
130 |
-
unset($post_types);
|
131 |
}
|
132 |
-
|
133 |
function getParamsQuery() {
|
134 |
return count( $this->__urlParams ) ? '&' . http_build_query( $this->__urlParams,
|
135 |
'', '&' ) : '';
|
@@ -137,7 +93,7 @@ class WPCF_Relationship_Child_Form
|
|
137 |
|
138 |
/**
|
139 |
* Sets form.
|
140 |
-
*
|
141 |
* @param type $o
|
142 |
*/
|
143 |
function _set( $child ) {
|
@@ -146,11 +102,11 @@ class WPCF_Relationship_Child_Form
|
|
146 |
|
147 |
/**
|
148 |
* Returns HTML formatted form.
|
149 |
-
*
|
150 |
* Renders children per row.
|
151 |
-
*
|
152 |
* @todo move all here
|
153 |
-
*
|
154 |
* @return type string (HTML formatted)
|
155 |
*/
|
156 |
function render() {
|
@@ -200,16 +156,16 @@ class WPCF_Relationship_Child_Form
|
|
200 |
$this->child_post_type, $page, $prev, $next, $per_page,
|
201 |
$total_items );
|
202 |
/*
|
203 |
-
*
|
204 |
-
*
|
205 |
* Add pagination bottom
|
206 |
*/
|
207 |
$options = array(__( 'All', 'wpcf' ) => 'all', 5 => 5, 10 => 10, 15 => 15);
|
208 |
// Add sorting
|
209 |
-
$add_data = isset( $_GET['sort'] ) && isset( $_GET['field'] ) ? '&sort=' .
|
210 |
-
.
|
211 |
if ( isset( $_GET['post_type_sort_parent'] ) ) {
|
212 |
-
$add_data .= '&post_type_sort_parent=' .
|
213 |
}
|
214 |
$this->pagination_bottom = wpcf_form_simple( array(
|
215 |
'pagination' => array(
|
@@ -233,7 +189,7 @@ class WPCF_Relationship_Child_Form
|
|
233 |
|
234 |
/**
|
235 |
* Returns rows.
|
236 |
-
*
|
237 |
* @return type
|
238 |
*/
|
239 |
function rows() {
|
@@ -247,9 +203,9 @@ class WPCF_Relationship_Child_Form
|
|
247 |
|
248 |
/**
|
249 |
* Returns HTML formatted row
|
250 |
-
*
|
251 |
* While generating rows we collect headers too.
|
252 |
-
*
|
253 |
* @return type
|
254 |
*/
|
255 |
function row() {
|
@@ -331,10 +287,10 @@ class WPCF_Relationship_Child_Form
|
|
331 |
}
|
332 |
}
|
333 |
/*
|
334 |
-
*
|
335 |
-
*
|
336 |
-
*
|
337 |
-
*
|
338 |
* DEFAULT SETTINGS
|
339 |
*/
|
340 |
} else {
|
@@ -389,6 +345,7 @@ class WPCF_Relationship_Child_Form
|
|
389 |
}
|
390 |
}
|
391 |
}
|
|
|
392 |
return $row;
|
393 |
}
|
394 |
|
@@ -413,45 +370,29 @@ class WPCF_Relationship_Child_Form
|
|
413 |
|
414 |
/**
|
415 |
* Returns HTML formatted title field.
|
416 |
-
*
|
417 |
* @param type $post
|
418 |
* @return type
|
419 |
*/
|
420 |
-
function title()
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
);
|
434 |
-
}
|
435 |
-
$title .= wpcf_form_simple(
|
436 |
-
array(
|
437 |
-
'field' => array(
|
438 |
-
'#type' => $type,
|
439 |
-
'#id' => 'wpcf_post_relationship_'
|
440 |
-
. $this->child->ID . '_wp_title',
|
441 |
-
'#name' => 'wpcf_post_relationship['
|
442 |
-
. $this->parent->ID . ']['
|
443 |
-
. $this->child->ID . '][_wp_title]',
|
444 |
-
'#value' => trim( $this->child->post_title ),
|
445 |
-
'#inline' => true,
|
446 |
-
),
|
447 |
-
)
|
448 |
);
|
449 |
-
return $title;
|
450 |
}
|
451 |
|
452 |
/**
|
453 |
* Returns HTML formatted body field.
|
454 |
-
*
|
455 |
* @return type
|
456 |
*/
|
457 |
function body() {
|
@@ -470,10 +411,10 @@ class WPCF_Relationship_Child_Form
|
|
470 |
)
|
471 |
);
|
472 |
}
|
473 |
-
|
474 |
/**
|
475 |
* Returns HTML formatted taxonomy form.
|
476 |
-
*
|
477 |
* @param type $taxonomy
|
478 |
* @return type
|
479 |
*/
|
@@ -500,7 +441,7 @@ class WPCF_Relationship_Child_Form
|
|
500 |
);
|
501 |
|
502 |
return empty( $output ) ? sprintf( __( 'No %s', 'wpcf' ),
|
503 |
-
$taxonomy->label ) : $output;
|
504 |
}
|
505 |
|
506 |
$data = array(
|
@@ -530,9 +471,9 @@ class WPCF_Relationship_Child_Form
|
|
530 |
|
531 |
/**
|
532 |
* Returns element form as array.
|
533 |
-
*
|
534 |
* This is done per field.
|
535 |
-
*
|
536 |
* @param type $key Field key as stored
|
537 |
* @return array
|
538 |
*/
|
@@ -559,13 +500,13 @@ class WPCF_Relationship_Child_Form
|
|
559 |
return wptoolset_form_field( 'post', $config, $meta );
|
560 |
}
|
561 |
/*
|
562 |
-
*
|
563 |
* Get meta form for field
|
564 |
*/
|
565 |
$form = $this->cf->_get_meta_form( $this->cf->__meta,
|
566 |
$this->cf->meta_object->meta_id, false );
|
567 |
/*
|
568 |
-
*
|
569 |
* Filter form
|
570 |
*/
|
571 |
$_filtered_form = $this->__filter_meta_form( $form );
|
@@ -576,17 +517,17 @@ class WPCF_Relationship_Child_Form
|
|
576 |
|
577 |
/**
|
578 |
* Filters meta form.
|
579 |
-
*
|
580 |
* IMPORTANT: This is place where look of child form is altered.
|
581 |
* Try not to spread it over other code.
|
582 |
-
*
|
583 |
* @param string $form
|
584 |
* @return string
|
585 |
*/
|
586 |
function __filter_meta_form( $form = array() ) {
|
587 |
foreach ( $form as $k => &$e ) {
|
588 |
/*
|
589 |
-
*
|
590 |
* Filter name
|
591 |
*/
|
592 |
if ( isset( $e['#name'] ) ) {
|
@@ -627,7 +568,7 @@ class WPCF_Relationship_Child_Form
|
|
627 |
|
628 |
/**
|
629 |
* Content for choose parent column.
|
630 |
-
*
|
631 |
* @return boolean
|
632 |
*/
|
633 |
function _parent_form( $post_parent = '' ) {
|
@@ -676,7 +617,7 @@ class WPCF_Relationship_Child_Form
|
|
676 |
|
677 |
/**
|
678 |
* HTML formatted row.
|
679 |
-
*
|
680 |
* @return type
|
681 |
*/
|
682 |
function child_row( $child ) {
|
@@ -692,9 +633,9 @@ class WPCF_Relationship_Child_Form
|
|
692 |
|
693 |
/**
|
694 |
* Header HTML formatted output.
|
695 |
-
*
|
696 |
* Each header <th> is array element. Sortable.
|
697 |
-
*
|
698 |
* @return array 'header_id' => html
|
699 |
*/
|
700 |
function headers() {
|
@@ -702,7 +643,7 @@ class WPCF_Relationship_Child_Form
|
|
702 |
// Sorting
|
703 |
$dir = isset( $_GET['sort'] ) && $_GET['sort'] == 'ASC' ? 'DESC' : 'ASC';
|
704 |
$dir_default = 'ASC';
|
705 |
-
$sort_field = isset( $_GET['field'] ) ?
|
706 |
|
707 |
// Set values
|
708 |
$post = $this->parent;
|
@@ -719,17 +660,13 @@ class WPCF_Relationship_Child_Form
|
|
719 |
}
|
720 |
|
721 |
if ( $header == '_wp_title' ) {
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
. wp_create_nonce( 'pr_sort' ) ) . '">' . __( 'Post Title' ) . '</a>';
|
730 |
-
} else {
|
731 |
-
$headers[$header] = 'ID';
|
732 |
-
}
|
733 |
} else if ( $header == '_wp_body' ) {
|
734 |
$body_dir = $sort_field == '_wp_body' ? $dir : $dir_default;
|
735 |
$headers[$header] = '';
|
@@ -789,4 +726,4 @@ class WPCF_Relationship_Child_Form
|
|
789 |
return $headers;
|
790 |
}
|
791 |
|
792 |
-
}
|
1 |
<?php
|
2 |
/*
|
3 |
* Relationship form class.
|
4 |
+
*
|
5 |
* Used to render child forms
|
6 |
*/
|
7 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
8 |
|
9 |
/**
|
10 |
* Relationship form class.
|
11 |
+
*
|
12 |
* Used on post edit page to show children rows
|
13 |
*/
|
14 |
class WPCF_Relationship_Child_Form
|
16 |
|
17 |
/**
|
18 |
* Current post.
|
19 |
+
*
|
20 |
* @var type object
|
21 |
*/
|
22 |
var $post;
|
23 |
|
24 |
/**
|
25 |
* Field object.
|
26 |
+
*
|
27 |
* @var type array
|
28 |
*/
|
29 |
var $cf = array();
|
30 |
|
31 |
/**
|
32 |
* Saved data.
|
33 |
+
*
|
34 |
* @var type array
|
35 |
*/
|
36 |
var $data = array();
|
37 |
|
38 |
/**
|
39 |
* Child post object.
|
40 |
+
*
|
41 |
+
* @var type
|
42 |
*/
|
43 |
var $child_post_type_object;
|
44 |
var $parent;
|
52 |
'field');
|
53 |
private $__urlParams = array();
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
/**
|
56 |
* Construct function.
|
57 |
*/
|
67 |
}
|
68 |
$this->cf = new WPCF_Field();
|
69 |
$this->cf->context = 'relationship';
|
70 |
+
$this->children = WPCF_Relationship_Model::getChildrenByPostType( $this->parent,
|
71 |
+
$this->child_post_type, $this->data, $_GET );
|
|
|
|
|
|
|
|
|
|
|
72 |
// If no children - use dummy post
|
73 |
if ( empty( $this->children ) ) {
|
74 |
$_dummy_post = get_default_post_to_edit( $this->child_post_type,
|
77 |
$this->_dummy_post = true;
|
78 |
}
|
79 |
$this->child_post_type_object = get_post_type_object( $this->child_post_type );
|
80 |
+
|
81 |
// Collect params from request
|
82 |
foreach ( $this->__params as $__param ) {
|
83 |
if ( isset( $_GET[$__param] ) ) {
|
84 |
$this->__urlParams[$__param] = $_GET[$__param];
|
85 |
}
|
86 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
+
|
89 |
function getParamsQuery() {
|
90 |
return count( $this->__urlParams ) ? '&' . http_build_query( $this->__urlParams,
|
91 |
'', '&' ) : '';
|
93 |
|
94 |
/**
|
95 |
* Sets form.
|
96 |
+
*
|
97 |
* @param type $o
|
98 |
*/
|
99 |
function _set( $child ) {
|
102 |
|
103 |
/**
|
104 |
* Returns HTML formatted form.
|
105 |
+
*
|
106 |
* Renders children per row.
|
107 |
+
*
|
108 |
* @todo move all here
|
109 |
+
*
|
110 |
* @return type string (HTML formatted)
|
111 |
*/
|
112 |
function render() {
|
156 |
$this->child_post_type, $page, $prev, $next, $per_page,
|
157 |
$total_items );
|
158 |
/*
|
159 |
+
*
|
160 |
+
*
|
161 |
* Add pagination bottom
|
162 |
*/
|
163 |
$options = array(__( 'All', 'wpcf' ) => 'all', 5 => 5, 10 => 10, 15 => 15);
|
164 |
// Add sorting
|
165 |
+
$add_data = isset( $_GET['sort'] ) && isset( $_GET['field'] ) ? '&sort=' . strval( $_GET['sort'] ) . '&field='
|
166 |
+
. strval( $_GET['field'] ) : '';
|
167 |
if ( isset( $_GET['post_type_sort_parent'] ) ) {
|
168 |
+
$add_data .= '&post_type_sort_parent=' . $_GET['post_type_sort_parent'];
|
169 |
}
|
170 |
$this->pagination_bottom = wpcf_form_simple( array(
|
171 |
'pagination' => array(
|
189 |
|
190 |
/**
|
191 |
* Returns rows.
|
192 |
+
*
|
193 |
* @return type
|
194 |
*/
|
195 |
function rows() {
|
203 |
|
204 |
/**
|
205 |
* Returns HTML formatted row
|
206 |
+
*
|
207 |
* While generating rows we collect headers too.
|
208 |
+
*
|
209 |
* @return type
|
210 |
*/
|
211 |
function row() {
|
287 |
}
|
288 |
}
|
289 |
/*
|
290 |
+
*
|
291 |
+
*
|
292 |
+
*
|
293 |
+
*
|
294 |
* DEFAULT SETTINGS
|
295 |
*/
|
296 |
} else {
|
345 |
}
|
346 |
}
|
347 |
}
|
348 |
+
|
349 |
return $row;
|
350 |
}
|
351 |
|
370 |
|
371 |
/**
|
372 |
* Returns HTML formatted title field.
|
373 |
+
*
|
374 |
* @param type $post
|
375 |
* @return type
|
376 |
*/
|
377 |
+
function title() {
|
378 |
+
return wpcf_form_simple(
|
379 |
+
array('field' => array(
|
380 |
+
'#type' => 'textfield',
|
381 |
+
'#id' => 'wpcf_post_relationship_'
|
382 |
+
. $this->child->ID . '_wp_title',
|
383 |
+
'#name' => 'wpcf_post_relationship['
|
384 |
+
. $this->parent->ID . ']['
|
385 |
+
. $this->child->ID . '][_wp_title]',
|
386 |
+
'#value' => trim( $this->child->post_title ),
|
387 |
+
'#inline' => true,
|
388 |
+
)
|
389 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
);
|
|
|
391 |
}
|
392 |
|
393 |
/**
|
394 |
* Returns HTML formatted body field.
|
395 |
+
*
|
396 |
* @return type
|
397 |
*/
|
398 |
function body() {
|
411 |
)
|
412 |
);
|
413 |
}
|
414 |
+
|
415 |
/**
|
416 |
* Returns HTML formatted taxonomy form.
|
417 |
+
*
|
418 |
* @param type $taxonomy
|
419 |
* @return type
|
420 |
*/
|
441 |
);
|
442 |
|
443 |
return empty( $output ) ? sprintf( __( 'No %s', 'wpcf' ),
|
444 |
+
$taxonomy->label ) : $output;
|
445 |
}
|
446 |
|
447 |
$data = array(
|
471 |
|
472 |
/**
|
473 |
* Returns element form as array.
|
474 |
+
*
|
475 |
* This is done per field.
|
476 |
+
*
|
477 |
* @param type $key Field key as stored
|
478 |
* @return array
|
479 |
*/
|
500 |
return wptoolset_form_field( 'post', $config, $meta );
|
501 |
}
|
502 |
/*
|
503 |
+
*
|
504 |
* Get meta form for field
|
505 |
*/
|
506 |
$form = $this->cf->_get_meta_form( $this->cf->__meta,
|
507 |
$this->cf->meta_object->meta_id, false );
|
508 |
/*
|
509 |
+
*
|
510 |
* Filter form
|
511 |
*/
|
512 |
$_filtered_form = $this->__filter_meta_form( $form );
|
517 |
|
518 |
/**
|
519 |
* Filters meta form.
|
520 |
+
*
|
521 |
* IMPORTANT: This is place where look of child form is altered.
|
522 |
* Try not to spread it over other code.
|
523 |
+
*
|
524 |
* @param string $form
|
525 |
* @return string
|
526 |
*/
|
527 |
function __filter_meta_form( $form = array() ) {
|
528 |
foreach ( $form as $k => &$e ) {
|
529 |
/*
|
530 |
+
*
|
531 |
* Filter name
|
532 |
*/
|
533 |
if ( isset( $e['#name'] ) ) {
|
568 |
|
569 |
/**
|
570 |
* Content for choose parent column.
|
571 |
+
*
|
572 |
* @return boolean
|
573 |
*/
|
574 |
function _parent_form( $post_parent = '' ) {
|
617 |
|
618 |
/**
|
619 |
* HTML formatted row.
|
620 |
+
*
|
621 |
* @return type
|
622 |
*/
|
623 |
function child_row( $child ) {
|
633 |
|
634 |
/**
|
635 |
* Header HTML formatted output.
|
636 |
+
*
|
637 |
* Each header <th> is array element. Sortable.
|
638 |
+
*
|
639 |
* @return array 'header_id' => html
|
640 |
*/
|
641 |
function headers() {
|
643 |
// Sorting
|
644 |
$dir = isset( $_GET['sort'] ) && $_GET['sort'] == 'ASC' ? 'DESC' : 'ASC';
|
645 |
$dir_default = 'ASC';
|
646 |
+
$sort_field = isset( $_GET['field'] ) ? $_GET['field'] : '';
|
647 |
|
648 |
// Set values
|
649 |
$post = $this->parent;
|
660 |
}
|
661 |
|
662 |
if ( $header == '_wp_title' ) {
|
663 |
+
$title_dir = $sort_field == '_wp_title' ? $dir : 'ASC';
|
664 |
+
$headers[$header] = '';
|
665 |
+
$headers[$header] .= $sort_field == '_wp_title' ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
|
666 |
+
$headers[$header] .= '<a href="' . admin_url( 'admin-ajax.php?action=wpcf_ajax&wpcf_action=pr_sort&field='
|
667 |
+
. '_wp_title&sort=' . $title_dir . '&post_id=' . $post->ID . '&post_type='
|
668 |
+
. $post_type . '&_wpnonce='
|
669 |
+
. wp_create_nonce( 'pr_sort' ) ) . '">' . __( 'Post Title' ) . '</a>';
|
|
|
|
|
|
|
|
|
670 |
} else if ( $header == '_wp_body' ) {
|
671 |
$body_dir = $sort_field == '_wp_body' ? $dir : $dir_default;
|
672 |
$headers[$header] = '';
|
726 |
return $headers;
|
727 |
}
|
728 |
|
729 |
+
}
|
embedded/classes/repeater.php
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
*
|
4 |
-
*
|
5 |
* Repeater fields class.
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
* Repater class
|
10 |
-
*
|
11 |
* Very useful, should be used to finish small tasks for repeater field.
|
12 |
-
*
|
13 |
* Example:
|
14 |
-
*
|
15 |
* // Setup field
|
16 |
* global $wpcf;
|
17 |
* $my_field = new WPCF_Repeater();
|
18 |
* $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
|
19 |
-
*
|
20 |
* // Use it
|
21 |
* $my_field->save();
|
22 |
-
*
|
23 |
* Generic instance can be found in global $wpcf.
|
24 |
* global $wpcf;
|
25 |
* $wpcf->repeater->set(...);
|
26 |
-
*
|
27 |
* @since Types 1.2
|
28 |
* @package Types
|
29 |
* @subpackage Classes
|
@@ -36,30 +36,30 @@ class WPCF_Repeater extends WPCF_Field
|
|
36 |
|
37 |
/**
|
38 |
* Field order
|
39 |
-
*
|
40 |
-
* @var type
|
41 |
*/
|
42 |
var $order;
|
43 |
|
44 |
/**
|
45 |
* Indexing
|
46 |
-
*
|
47 |
* Set counts when processing fields.
|
48 |
-
*
|
49 |
-
* @var type
|
50 |
*/
|
51 |
var $index = 0;
|
52 |
|
53 |
/**
|
54 |
* Field title
|
55 |
-
* @var type
|
56 |
*/
|
57 |
var $title = '';
|
58 |
|
59 |
/**
|
60 |
* Field description.
|
61 |
-
*
|
62 |
-
* @var type
|
63 |
*/
|
64 |
var $description = '';
|
65 |
|
@@ -73,9 +73,9 @@ class WPCF_Repeater extends WPCF_Field
|
|
73 |
|
74 |
/**
|
75 |
* Calls parent set func.
|
76 |
-
*
|
77 |
* @param type $post
|
78 |
-
* @param type $field
|
79 |
*/
|
80 |
function set( $post, $field ) {
|
81 |
parent::set( $post, $field );
|
@@ -84,12 +84,12 @@ class WPCF_Repeater extends WPCF_Field
|
|
84 |
|
85 |
/**
|
86 |
* Save fields
|
87 |
-
*
|
88 |
* If $data empty, $_POST will be checked
|
89 |
-
*
|
90 |
* @global type $wpcf
|
91 |
* @param type $data
|
92 |
-
* @return boolean
|
93 |
*/
|
94 |
function save( $data = null ) {
|
95 |
|
@@ -107,7 +107,7 @@ class WPCF_Repeater extends WPCF_Field
|
|
107 |
|
108 |
// Set data
|
109 |
if ( !empty( $data ) ) {
|
110 |
-
|
111 |
do_action('wpcf_postmeta_before_add_repetitive', $this->post, $this->cf);
|
112 |
|
113 |
// Insert new meta and collect all new mids
|
@@ -116,7 +116,7 @@ class WPCF_Repeater extends WPCF_Field
|
|
116 |
foreach ( $data as $meta_value ) {
|
117 |
|
118 |
/*
|
119 |
-
*
|
120 |
* Deprecated!
|
121 |
*/
|
122 |
if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
|
@@ -142,7 +142,7 @@ class WPCF_Repeater extends WPCF_Field
|
|
142 |
// Call insert post actions on each field
|
143 |
$this->_action_save( $this->cf, $_meta_value, $mid, $meta_value );
|
144 |
}
|
145 |
-
|
146 |
do_action('wpcf_postmeta_after_add_repetitive', $this->post, $this->cf);
|
147 |
|
148 |
// Save order
|
@@ -160,8 +160,8 @@ class WPCF_Repeater extends WPCF_Field
|
|
160 |
|
161 |
/**
|
162 |
* Fetch and sort fields.
|
163 |
-
*
|
164 |
-
* @global
|
165 |
*/
|
166 |
function _get_meta() {
|
167 |
global $wpdb;
|
@@ -169,7 +169,7 @@ class WPCF_Repeater extends WPCF_Field
|
|
169 |
$cache_key = md5( 'repeater::_get_meta' . $this->post->ID . $this->slug );
|
170 |
$cache_group = 'types_cache';
|
171 |
$cached_object = wp_cache_get( $cache_key, $cache_group );
|
172 |
-
|
173 |
if ( $this->use_cache ) {
|
174 |
if ( false != $cached_object && is_array( $cached_object ) ) {
|
175 |
return $cached_object;
|
@@ -181,10 +181,10 @@ class WPCF_Repeater extends WPCF_Field
|
|
181 |
$ordered = array();
|
182 |
$this->order = get_post_meta( $this->post->ID, $this->order_meta_name,
|
183 |
true );
|
184 |
-
|
185 |
$cache_key_field = md5( 'field::_get_meta' . $this->post->ID . $this->slug );
|
186 |
$cached_object_field = wp_cache_get( $cache_key_field, $cache_group );
|
187 |
-
|
188 |
if ( $this->use_cache ) {
|
189 |
if ( false != $cached_object_field && is_array( $cached_object_field ) ) {// WordPress cache
|
190 |
$r = $cached_object_field;
|
@@ -265,8 +265,8 @@ class WPCF_Repeater extends WPCF_Field
|
|
265 |
}
|
266 |
|
267 |
/**
|
268 |
-
* Sets repetitive field form.
|
269 |
-
*
|
270 |
* @todo Make more distinction between $field_form and $form_field
|
271 |
*/
|
272 |
function get_fields_form() {
|
@@ -315,8 +315,8 @@ class WPCF_Repeater extends WPCF_Field
|
|
315 |
|
316 |
// Set style
|
317 |
/*
|
318 |
-
*
|
319 |
-
*
|
320 |
* Hide if field not passed check
|
321 |
* TODO Move this to WPCF_Conditional
|
322 |
*/
|
@@ -328,17 +328,17 @@ class WPCF_Repeater extends WPCF_Field
|
|
328 |
$css_cd = !$show ? 'display:none;' : '';
|
329 |
|
330 |
/**
|
331 |
-
*
|
332 |
-
*
|
333 |
-
*
|
334 |
-
*
|
335 |
* Set title and description
|
336 |
* TODO See if can be improved getting main element
|
337 |
-
*
|
338 |
* Get first element and extract details
|
339 |
* Pass emty string as value to avoid using meta as array
|
340 |
*/
|
341 |
-
//
|
342 |
$_c = array_values( parent::_get_meta_form( '' ) );
|
343 |
array_shift( $_c );
|
344 |
$_main_element = array_shift( $_c );
|
@@ -351,8 +351,8 @@ class WPCF_Repeater extends WPCF_Field
|
|
351 |
}
|
352 |
|
353 |
/*
|
354 |
-
*
|
355 |
-
*
|
356 |
* Start wrapper
|
357 |
*/
|
358 |
$form[$unique_id . '_repetitive_wrapper_open'] = array(
|
@@ -372,12 +372,12 @@ class WPCF_Repeater extends WPCF_Field
|
|
372 |
|
373 |
// Set hidden mark field
|
374 |
/*
|
375 |
-
*
|
376 |
-
*
|
377 |
-
*
|
378 |
* This actually marks field as repetitive
|
379 |
* IMPORTANT!!! IF NOT marked field won't be saved at all!
|
380 |
-
*
|
381 |
* @see wpcf_admin_post_save_post_hook()
|
382 |
*/
|
383 |
$form[$form_id . '_hidden_mark'] = array(
|
@@ -443,9 +443,9 @@ class WPCF_Repeater extends WPCF_Field
|
|
443 |
|
444 |
/**
|
445 |
* Sete repetitive form for single field.
|
446 |
-
*
|
447 |
* @param type $meta
|
448 |
-
* @return string
|
449 |
*/
|
450 |
function get_field_form( $meta_value = null, $meta_id = null ) {
|
451 |
|
@@ -456,8 +456,8 @@ class WPCF_Repeater extends WPCF_Field
|
|
456 |
$key = 'wpcf_field_' . md5( maybe_serialize( $meta_value ) . $meta_id );
|
457 |
}
|
458 |
/*
|
459 |
-
*
|
460 |
-
*
|
461 |
* TODO We prevented array because of some fails we had before.
|
462 |
* Now it should work fine
|
463 |
* Add debug log if meta_value['custom_order'] passed.
|
@@ -480,7 +480,7 @@ class WPCF_Repeater extends WPCF_Field
|
|
480 |
$field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
|
481 |
|
482 |
/*
|
483 |
-
*
|
484 |
* Apply filters to each form element.
|
485 |
* Here we add specific properties
|
486 |
* e.g. Skype alters fields.
|
@@ -489,7 +489,7 @@ class WPCF_Repeater extends WPCF_Field
|
|
489 |
foreach ( $field_form as $k => $field ) {
|
490 |
|
491 |
/*
|
492 |
-
*
|
493 |
* IMPORTANT
|
494 |
* We change name to hold array
|
495 |
*/
|
@@ -579,7 +579,7 @@ class WPCF_Repeater extends WPCF_Field
|
|
579 |
}
|
580 |
|
581 |
/**
|
582 |
-
* Set counting elements.
|
583 |
*/
|
584 |
function _set_form_count() {
|
585 |
if ( $this->index === 0 ) {
|
@@ -592,11 +592,8 @@ class WPCF_Repeater extends WPCF_Field
|
|
592 |
|
593 |
/**
|
594 |
* Deletes meta.
|
595 |
-
*
|
596 |
-
* @
|
597 |
-
*
|
598 |
-
* @param type $meta_key
|
599 |
-
*
|
600 |
*/
|
601 |
function delete( $meta_id ) {
|
602 |
global $wpdb;
|
@@ -616,4 +613,4 @@ class WPCF_Repeater extends WPCF_Field
|
|
616 |
return $r;
|
617 |
}
|
618 |
|
619 |
-
}
|
1 |
<?php
|
2 |
/*
|
3 |
+
*
|
4 |
+
*
|
5 |
* Repeater fields class.
|
6 |
*/
|
7 |
|
8 |
/**
|
9 |
* Repater class
|
10 |
+
*
|
11 |
* Very useful, should be used to finish small tasks for repeater field.
|
12 |
+
*
|
13 |
* Example:
|
14 |
+
*
|
15 |
* // Setup field
|
16 |
* global $wpcf;
|
17 |
* $my_field = new WPCF_Repeater();
|
18 |
* $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
|
19 |
+
*
|
20 |
* // Use it
|
21 |
* $my_field->save();
|
22 |
+
*
|
23 |
* Generic instance can be found in global $wpcf.
|
24 |
* global $wpcf;
|
25 |
* $wpcf->repeater->set(...);
|
26 |
+
*
|
27 |
* @since Types 1.2
|
28 |
* @package Types
|
29 |
* @subpackage Classes
|
36 |
|
37 |
/**
|
38 |
* Field order
|
39 |
+
*
|
40 |
+
* @var type
|
41 |
*/
|
42 |
var $order;
|
43 |
|
44 |
/**
|
45 |
* Indexing
|
46 |
+
*
|
47 |
* Set counts when processing fields.
|
48 |
+
*
|
49 |
+
* @var type
|
50 |
*/
|
51 |
var $index = 0;
|
52 |
|
53 |
/**
|
54 |
* Field title
|
55 |
+
* @var type
|
56 |
*/
|
57 |
var $title = '';
|
58 |
|
59 |
/**
|
60 |
* Field description.
|
61 |
+
*
|
62 |
+
* @var type
|
63 |
*/
|
64 |
var $description = '';
|
65 |
|
73 |
|
74 |
/**
|
75 |
* Calls parent set func.
|
76 |
+
*
|
77 |
* @param type $post
|
78 |
+
* @param type $field
|
79 |
*/
|
80 |
function set( $post, $field ) {
|
81 |
parent::set( $post, $field );
|
84 |
|
85 |
/**
|
86 |
* Save fields
|
87 |
+
*
|
88 |
* If $data empty, $_POST will be checked
|
89 |
+
*
|
90 |
* @global type $wpcf
|
91 |
* @param type $data
|
92 |
+
* @return boolean
|
93 |
*/
|
94 |
function save( $data = null ) {
|
95 |
|
107 |
|
108 |
// Set data
|
109 |
if ( !empty( $data ) ) {
|
110 |
+
|
111 |
do_action('wpcf_postmeta_before_add_repetitive', $this->post, $this->cf);
|
112 |
|
113 |
// Insert new meta and collect all new mids
|
116 |
foreach ( $data as $meta_value ) {
|
117 |
|
118 |
/*
|
119 |
+
*
|
120 |
* Deprecated!
|
121 |
*/
|
122 |
if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
|
142 |
// Call insert post actions on each field
|
143 |
$this->_action_save( $this->cf, $_meta_value, $mid, $meta_value );
|
144 |
}
|
145 |
+
|
146 |
do_action('wpcf_postmeta_after_add_repetitive', $this->post, $this->cf);
|
147 |
|
148 |
// Save order
|
160 |
|
161 |
/**
|
162 |
* Fetch and sort fields.
|
163 |
+
*
|
164 |
+
* @global type $wpdb
|
165 |
*/
|
166 |
function _get_meta() {
|
167 |
global $wpdb;
|
169 |
$cache_key = md5( 'repeater::_get_meta' . $this->post->ID . $this->slug );
|
170 |
$cache_group = 'types_cache';
|
171 |
$cached_object = wp_cache_get( $cache_key, $cache_group );
|
172 |
+
|
173 |
if ( $this->use_cache ) {
|
174 |
if ( false != $cached_object && is_array( $cached_object ) ) {
|
175 |
return $cached_object;
|
181 |
$ordered = array();
|
182 |
$this->order = get_post_meta( $this->post->ID, $this->order_meta_name,
|
183 |
true );
|
184 |
+
|
185 |
$cache_key_field = md5( 'field::_get_meta' . $this->post->ID . $this->slug );
|
186 |
$cached_object_field = wp_cache_get( $cache_key_field, $cache_group );
|
187 |
+
|
188 |
if ( $this->use_cache ) {
|
189 |
if ( false != $cached_object_field && is_array( $cached_object_field ) ) {// WordPress cache
|
190 |
$r = $cached_object_field;
|
265 |
}
|
266 |
|
267 |
/**
|
268 |
+
* Sets repetitive field form.
|
269 |
+
*
|
270 |
* @todo Make more distinction between $field_form and $form_field
|
271 |
*/
|
272 |
function get_fields_form() {
|
315 |
|
316 |
// Set style
|
317 |
/*
|
318 |
+
*
|
319 |
+
*
|
320 |
* Hide if field not passed check
|
321 |
* TODO Move this to WPCF_Conditional
|
322 |
*/
|
328 |
$css_cd = !$show ? 'display:none;' : '';
|
329 |
|
330 |
/**
|
331 |
+
*
|
332 |
+
*
|
333 |
+
*
|
334 |
+
*
|
335 |
* Set title and description
|
336 |
* TODO See if can be improved getting main element
|
337 |
+
*
|
338 |
* Get first element and extract details
|
339 |
* Pass emty string as value to avoid using meta as array
|
340 |
*/
|
341 |
+
//
|
342 |
$_c = array_values( parent::_get_meta_form( '' ) );
|
343 |
array_shift( $_c );
|
344 |
$_main_element = array_shift( $_c );
|
351 |
}
|
352 |
|
353 |
/*
|
354 |
+
*
|
355 |
+
*
|
356 |
* Start wrapper
|
357 |
*/
|
358 |
$form[$unique_id . '_repetitive_wrapper_open'] = array(
|
372 |
|
373 |
// Set hidden mark field
|
374 |
/*
|
375 |
+
*
|
376 |
+
*
|
377 |
+
*
|
378 |
* This actually marks field as repetitive
|
379 |
* IMPORTANT!!! IF NOT marked field won't be saved at all!
|
380 |
+
*
|
381 |
* @see wpcf_admin_post_save_post_hook()
|
382 |
*/
|
383 |
$form[$form_id . '_hidden_mark'] = array(
|
443 |
|
444 |
/**
|
445 |
* Sete repetitive form for single field.
|
446 |
+
*
|
447 |
* @param type $meta
|
448 |
+
* @return string
|
449 |
*/
|
450 |
function get_field_form( $meta_value = null, $meta_id = null ) {
|
451 |
|
456 |
$key = 'wpcf_field_' . md5( maybe_serialize( $meta_value ) . $meta_id );
|
457 |
}
|
458 |
/*
|
459 |
+
*
|
460 |
+
*
|
461 |
* TODO We prevented array because of some fails we had before.
|
462 |
* Now it should work fine
|
463 |
* Add debug log if meta_value['custom_order'] passed.
|
480 |
$field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
|
481 |
|
482 |
/*
|
483 |
+
*
|
484 |
* Apply filters to each form element.
|
485 |
* Here we add specific properties
|
486 |
* e.g. Skype alters fields.
|
489 |
foreach ( $field_form as $k => $field ) {
|
490 |
|
491 |
/*
|
492 |
+
*
|
493 |
* IMPORTANT
|
494 |
* We change name to hold array
|
495 |
*/
|
579 |
}
|
580 |
|
581 |
/**
|
582 |
+
* Set counting elements.
|
583 |
*/
|
584 |
function _set_form_count() {
|
585 |
if ( $this->index === 0 ) {
|
592 |
|
593 |
/**
|
594 |
* Deletes meta.
|
595 |
+
*
|
596 |
+
* @param type $meta_key
|
|
|
|
|
|
|
597 |
*/
|
598 |
function delete( $meta_id ) {
|
599 |
global $wpdb;
|
613 |
return $r;
|
614 |
}
|
615 |
|
616 |
+
}
|
embedded/classes/usermeta_field.php
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
|
|
|
|
3 |
* Usermeta Field class extends Field.
|
4 |
*/
|
5 |
|
@@ -11,16 +13,16 @@ class WPCF_Usermeta_Field extends WPCF_Field
|
|
11 |
|
12 |
/**
|
13 |
* Set current post and field.
|
14 |
-
*
|
15 |
* @param type $post
|
16 |
-
* @param type $cf
|
17 |
*/
|
18 |
function set( $user_id, $cf ) {
|
19 |
|
20 |
global $wpcf;
|
21 |
|
22 |
/*
|
23 |
-
*
|
24 |
* Check if $cf is string
|
25 |
*/
|
26 |
if ( is_string( $cf ) ) {
|
@@ -61,9 +63,9 @@ class WPCF_Usermeta_Field extends WPCF_Field
|
|
61 |
|
62 |
/**
|
63 |
* Save usermeta field.
|
64 |
-
*
|
65 |
-
*
|
66 |
-
* @param type $value
|
67 |
*/
|
68 |
function usermeta_save( $value = null ) {
|
69 |
|
@@ -72,8 +74,8 @@ class WPCF_Usermeta_Field extends WPCF_Field
|
|
72 |
$value = $this->get_submitted_data();
|
73 |
}
|
74 |
/*
|
75 |
-
*
|
76 |
-
*
|
77 |
* Since Types 1.2
|
78 |
* We completely rewrite meta.
|
79 |
* It has no impact on frontend and covers a lot of cases
|
@@ -103,17 +105,17 @@ class WPCF_Usermeta_Field extends WPCF_Field
|
|
103 |
|
104 |
/**
|
105 |
* Fetch and sort fields.
|
106 |
-
*
|
107 |
-
*
|
108 |
-
*
|
109 |
*/
|
110 |
function _get_meta() {
|
111 |
global $wpdb;
|
112 |
|
|
|
113 |
$cache_key = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
|
114 |
$cache_group = 'types_cache';
|
115 |
$cached_object = wp_cache_get( $cache_key, $cache_group );
|
116 |
-
|
117 |
if ( $this->use_cache ) {
|
118 |
if ( false != $cached_object && is_array( $cached_object ) && isset( $cached_object[0] ) ) {// WordPress cache
|
119 |
$r = $cached_object[0];
|
@@ -171,15 +173,17 @@ class WPCF_Usermeta_Field extends WPCF_Field
|
|
171 |
$this->__meta = $meta;
|
172 |
|
173 |
/*
|
174 |
-
*
|
175 |
* Apply filters
|
176 |
* !!! IMPORTANT !!!
|
177 |
* TODO Make this only place where field meta value is filtered
|
178 |
*/
|
179 |
$meta = apply_filters( 'wpcf_fields_value_get', $meta, $this );
|
180 |
-
$meta = apply_filters( 'wpcf_fields_slug_' . $this->cf['slug']
|
181 |
-
|
|
|
|
|
182 |
return $meta;
|
183 |
}
|
184 |
|
185 |
-
}
|
1 |
<?php
|
2 |
/*
|
3 |
+
*
|
4 |
+
*
|
5 |
* Usermeta Field class extends Field.
|
6 |
*/
|
7 |
|
13 |
|
14 |
/**
|
15 |
* Set current post and field.
|
16 |
+
*
|
17 |
* @param type $post
|
18 |
+
* @param type $cf
|
19 |
*/
|
20 |
function set( $user_id, $cf ) {
|
21 |
|
22 |
global $wpcf;
|
23 |
|
24 |
/*
|
25 |
+
*
|
26 |
* Check if $cf is string
|
27 |
*/
|
28 |
if ( is_string( $cf ) ) {
|
63 |
|
64 |
/**
|
65 |
* Save usermeta field.
|
66 |
+
*
|
67 |
+
*
|
68 |
+
* @param type $value
|
69 |
*/
|
70 |
function usermeta_save( $value = null ) {
|
71 |
|
74 |
$value = $this->get_submitted_data();
|
75 |
}
|
76 |
/*
|
77 |
+
*
|
78 |
+
*
|
79 |
* Since Types 1.2
|
80 |
* We completely rewrite meta.
|
81 |
* It has no impact on frontend and covers a lot of cases
|
105 |
|
106 |
/**
|
107 |
* Fetch and sort fields.
|
108 |
+
*
|
109 |
+
*
|
|
|
110 |
*/
|
111 |
function _get_meta() {
|
112 |
global $wpdb;
|
113 |
|
114 |
+
|
115 |
$cache_key = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
|
116 |
$cache_group = 'types_cache';
|
117 |
$cached_object = wp_cache_get( $cache_key, $cache_group );
|
118 |
+
|
119 |
if ( $this->use_cache ) {
|
120 |
if ( false != $cached_object && is_array( $cached_object ) && isset( $cached_object[0] ) ) {// WordPress cache
|
121 |
$r = $cached_object[0];
|
173 |
$this->__meta = $meta;
|
174 |
|
175 |
/*
|
176 |
+
*
|
177 |
* Apply filters
|
178 |
* !!! IMPORTANT !!!
|
179 |
* TODO Make this only place where field meta value is filtered
|
180 |
*/
|
181 |
$meta = apply_filters( 'wpcf_fields_value_get', $meta, $this );
|
182 |
+
$meta = apply_filters( 'wpcf_fields_slug_' . $this->cf['slug']
|
183 |
+
. '_value_get', $meta, $this );
|
184 |
+
$meta = apply_filters( 'wpcf_fields_type_' . $this->cf['type']
|
185 |
+
. '_value_get', $meta, $this );
|
186 |
return $meta;
|
187 |
}
|
188 |
|
189 |
+
}
|
embedded/classes/usermeta_repeater.php
CHANGED
@@ -8,30 +8,30 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
8 |
|
9 |
/**
|
10 |
* Field order
|
11 |
-
*
|
12 |
-
* @var type
|
13 |
*/
|
14 |
var $order;
|
15 |
|
16 |
/**
|
17 |
* Indexing
|
18 |
-
*
|
19 |
* Set counts when processing fields.
|
20 |
-
*
|
21 |
-
* @var type
|
22 |
*/
|
23 |
var $index = 0;
|
24 |
|
25 |
/**
|
26 |
* Field title
|
27 |
-
* @var type
|
28 |
*/
|
29 |
var $title = '';
|
30 |
|
31 |
/**
|
32 |
* Field description.
|
33 |
-
*
|
34 |
-
* @var type
|
35 |
*/
|
36 |
var $description = '';
|
37 |
|
@@ -45,9 +45,9 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
45 |
|
46 |
/**
|
47 |
* Calls parent set func.
|
48 |
-
*
|
49 |
* @param type $post
|
50 |
-
* @param type $field
|
51 |
*/
|
52 |
function set( $user_id, $field ) {
|
53 |
parent::set( $user_id, $field );
|
@@ -56,12 +56,12 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
56 |
|
57 |
/**
|
58 |
* Save fields
|
59 |
-
*
|
60 |
* If $data empty, $_POST will be checked
|
61 |
-
*
|
62 |
* @global type $wpcf
|
63 |
* @param type $data
|
64 |
-
* @return boolean
|
65 |
*/
|
66 |
function save( $data = null ) {
|
67 |
|
@@ -83,7 +83,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
83 |
foreach ( $data as $meta_value ) {
|
84 |
|
85 |
/*
|
86 |
-
*
|
87 |
* Deprecated!
|
88 |
*/
|
89 |
if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
|
@@ -123,8 +123,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
123 |
|
124 |
/**
|
125 |
* Fetch and sort fields.
|
126 |
-
*
|
127 |
-
* @global
|
128 |
*/
|
129 |
function _get_meta() {
|
130 |
global $wpdb;
|
@@ -132,7 +132,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
132 |
$cache_key = md5( 'usermetarepeater::_get_meta' . $this->currentUID . $this->slug );
|
133 |
$cache_group = 'types_cache';
|
134 |
$cached_object = wp_cache_get( $cache_key, $cache_group );
|
135 |
-
|
136 |
if ( $this->use_cache ) {
|
137 |
if ( false != $cached_object && is_array( $cached_object ) ) {
|
138 |
return $cached_object;
|
@@ -146,10 +146,10 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
146 |
$ordered = array();
|
147 |
$this->order = get_user_meta( $this->currentUID, $this->order_meta_name,
|
148 |
true );
|
149 |
-
|
150 |
$cache_key_userfield = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
|
151 |
$cached_object_userfield = wp_cache_get( $cache_key_userfield, $cache_group );
|
152 |
-
|
153 |
if ( $this->use_cache ) {
|
154 |
if ( false != $cached_object_userfield && is_array( $cached_object_userfield ) ) {// WordPress cache
|
155 |
$r = $cached_object_userfield;
|
@@ -221,8 +221,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
221 |
}
|
222 |
|
223 |
/**
|
224 |
-
* Sets repetitive field form.
|
225 |
-
*
|
226 |
* @todo Make more distinction between $field_form and $form_field
|
227 |
*/
|
228 |
function get_fields_form( $is_profile = '' ) {
|
@@ -273,8 +273,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
273 |
|
274 |
// Set style
|
275 |
/*
|
276 |
-
*
|
277 |
-
*
|
278 |
* Hide if field not passed check
|
279 |
* TODO Move this to WPCF_Conditional
|
280 |
*/
|
@@ -286,17 +286,17 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
286 |
$css_cd = !$show ? 'display:none;' : '';
|
287 |
|
288 |
/**
|
289 |
-
*
|
290 |
-
*
|
291 |
-
*
|
292 |
-
*
|
293 |
* Set title and description
|
294 |
* TODO See if can be improved getting main element
|
295 |
-
*
|
296 |
* Get first element and extract details
|
297 |
* Pass emty string as value to avoid using meta as array
|
298 |
*/
|
299 |
-
//
|
300 |
$_c = array_values( parent::_get_meta_form( '' ) );
|
301 |
array_shift( $_c );
|
302 |
$_main_element = array_shift( $_c );
|
@@ -319,8 +319,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
319 |
);
|
320 |
|
321 |
/*
|
322 |
-
*
|
323 |
-
*
|
324 |
* Start wrapper
|
325 |
*/
|
326 |
$form[$unique_id . '_repetitive_wrapper_open'] = array(
|
@@ -334,12 +334,12 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
334 |
|
335 |
// Set hidden mark field
|
336 |
/*
|
337 |
-
*
|
338 |
-
*
|
339 |
-
*
|
340 |
* This actually marks field as repetitive
|
341 |
* IMPORTANT!!! IF NOT marked field won't be saved at all!
|
342 |
-
*
|
343 |
* @see wpcf_admin_post_save_post_hook()
|
344 |
*/
|
345 |
$form[$form_id . '_hidden_mark'] = array(
|
@@ -406,9 +406,9 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
406 |
|
407 |
/**
|
408 |
* Sete repetitive form for single field.
|
409 |
-
*
|
410 |
* @param type $meta
|
411 |
-
* @return string
|
412 |
*/
|
413 |
function get_field_form( $meta_value = null, $meta_id = null ) {
|
414 |
|
@@ -435,7 +435,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
435 |
$field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
|
436 |
|
437 |
/*
|
438 |
-
*
|
439 |
* Apply filters to each form element.
|
440 |
* Here we add specific properties
|
441 |
* e.g. Skype alters fields.
|
@@ -444,7 +444,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
444 |
foreach ( $field_form as $k => $field ) {
|
445 |
|
446 |
/*
|
447 |
-
*
|
448 |
* IMPORTANT
|
449 |
* We change name to hold array
|
450 |
*/
|
@@ -534,7 +534,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
534 |
}
|
535 |
|
536 |
/**
|
537 |
-
* Set counting elements.
|
538 |
*/
|
539 |
function _set_form_count() {
|
540 |
if ( $this->index === 0 ) {
|
@@ -547,11 +547,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
547 |
|
548 |
/**
|
549 |
* Deletes meta.
|
550 |
-
*
|
551 |
-
* @
|
552 |
-
*
|
553 |
-
* @param type $meta_key
|
554 |
-
*
|
555 |
*/
|
556 |
function delete( $meta_id ) {
|
557 |
global $wpdb;
|
@@ -571,4 +568,4 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
|
|
571 |
return $r;
|
572 |
}
|
573 |
|
574 |
-
}
|
8 |
|
9 |
/**
|
10 |
* Field order
|
11 |
+
*
|
12 |
+
* @var type
|
13 |
*/
|
14 |
var $order;
|
15 |
|
16 |
/**
|
17 |
* Indexing
|
18 |
+
*
|
19 |
* Set counts when processing fields.
|
20 |
+
*
|
21 |
+
* @var type
|
22 |
*/
|
23 |
var $index = 0;
|
24 |
|
25 |
/**
|
26 |
* Field title
|
27 |
+
* @var type
|
28 |
*/
|
29 |
var $title = '';
|
30 |
|
31 |
/**
|
32 |
* Field description.
|
33 |
+
*
|
34 |
+
* @var type
|
35 |
*/
|
36 |
var $description = '';
|
37 |
|
45 |
|
46 |
/**
|
47 |
* Calls parent set func.
|
48 |
+
*
|
49 |
* @param type $post
|
50 |
+
* @param type $field
|
51 |
*/
|
52 |
function set( $user_id, $field ) {
|
53 |
parent::set( $user_id, $field );
|
56 |
|
57 |
/**
|
58 |
* Save fields
|
59 |
+
*
|
60 |
* If $data empty, $_POST will be checked
|
61 |
+
*
|
62 |
* @global type $wpcf
|
63 |
* @param type $data
|
64 |
+
* @return boolean
|
65 |
*/
|
66 |
function save( $data = null ) {
|
67 |
|
83 |
foreach ( $data as $meta_value ) {
|
84 |
|
85 |
/*
|
86 |
+
*
|
87 |
* Deprecated!
|
88 |
*/
|
89 |
if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
|
123 |
|
124 |
/**
|
125 |
* Fetch and sort fields.
|
126 |
+
*
|
127 |
+
* @global type $wpdb
|
128 |
*/
|
129 |
function _get_meta() {
|
130 |
global $wpdb;
|
132 |
$cache_key = md5( 'usermetarepeater::_get_meta' . $this->currentUID . $this->slug );
|
133 |
$cache_group = 'types_cache';
|
134 |
$cached_object = wp_cache_get( $cache_key, $cache_group );
|
135 |
+
|
136 |
if ( $this->use_cache ) {
|
137 |
if ( false != $cached_object && is_array( $cached_object ) ) {
|
138 |
return $cached_object;
|
146 |
$ordered = array();
|
147 |
$this->order = get_user_meta( $this->currentUID, $this->order_meta_name,
|
148 |
true );
|
149 |
+
|
150 |
$cache_key_userfield = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
|
151 |
$cached_object_userfield = wp_cache_get( $cache_key_userfield, $cache_group );
|
152 |
+
|
153 |
if ( $this->use_cache ) {
|
154 |
if ( false != $cached_object_userfield && is_array( $cached_object_userfield ) ) {// WordPress cache
|
155 |
$r = $cached_object_userfield;
|
221 |
}
|
222 |
|
223 |
/**
|
224 |
+
* Sets repetitive field form.
|
225 |
+
*
|
226 |
* @todo Make more distinction between $field_form and $form_field
|
227 |
*/
|
228 |
function get_fields_form( $is_profile = '' ) {
|
273 |
|
274 |
// Set style
|
275 |
/*
|
276 |
+
*
|
277 |
+
*
|
278 |
* Hide if field not passed check
|
279 |
* TODO Move this to WPCF_Conditional
|
280 |
*/
|
286 |
$css_cd = !$show ? 'display:none;' : '';
|
287 |
|
288 |
/**
|
289 |
+
*
|
290 |
+
*
|
291 |
+
*
|
292 |
+
*
|
293 |
* Set title and description
|
294 |
* TODO See if can be improved getting main element
|
295 |
+
*
|
296 |
* Get first element and extract details
|
297 |
* Pass emty string as value to avoid using meta as array
|
298 |
*/
|
299 |
+
//
|
300 |
$_c = array_values( parent::_get_meta_form( '' ) );
|
301 |
array_shift( $_c );
|
302 |
$_main_element = array_shift( $_c );
|
319 |
);
|
320 |
|
321 |
/*
|
322 |
+
*
|
323 |
+
*
|
324 |
* Start wrapper
|
325 |
*/
|
326 |
$form[$unique_id . '_repetitive_wrapper_open'] = array(
|
334 |
|
335 |
// Set hidden mark field
|
336 |
/*
|
337 |
+
*
|
338 |
+
*
|
339 |
+
*
|
340 |
* This actually marks field as repetitive
|
341 |
* IMPORTANT!!! IF NOT marked field won't be saved at all!
|
342 |
+
*
|
343 |
* @see wpcf_admin_post_save_post_hook()
|
344 |
*/
|
345 |
$form[$form_id . '_hidden_mark'] = array(
|
406 |
|
407 |
/**
|
408 |
* Sete repetitive form for single field.
|
409 |
+
*
|
410 |
* @param type $meta
|
411 |
+
* @return string
|
412 |
*/
|
413 |
function get_field_form( $meta_value = null, $meta_id = null ) {
|
414 |
|
435 |
$field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
|
436 |
|
437 |
/*
|
438 |
+
*
|
439 |
* Apply filters to each form element.
|
440 |
* Here we add specific properties
|
441 |
* e.g. Skype alters fields.
|
444 |
foreach ( $field_form as $k => $field ) {
|
445 |
|
446 |
/*
|
447 |
+
*
|
448 |
* IMPORTANT
|
449 |
* We change name to hold array
|
450 |
*/
|
534 |
}
|
535 |
|
536 |
/**
|
537 |
+
* Set counting elements.
|
538 |
*/
|
539 |
function _set_form_count() {
|
540 |
if ( $this->index === 0 ) {
|
547 |
|
548 |
/**
|
549 |
* Deletes meta.
|
550 |
+
*
|
551 |
+
* @param type $meta_key
|
|
|
|
|
|
|
552 |
*/
|
553 |
function delete( $meta_id ) {
|
554 |
global $wpdb;
|
568 |
return $r;
|
569 |
}
|
570 |
|
571 |
+
}
|
embedded/classes/validate.php
CHANGED
@@ -388,29 +388,6 @@ class Wpcf_Validate
|
|
388 |
return $form;
|
389 |
}
|
390 |
|
391 |
-
/**
|
392 |
-
* Returns form data.
|
393 |
-
*
|
394 |
-
* @param type $field
|
395 |
-
* @param type $data
|
396 |
-
* @return array
|
397 |
-
*/
|
398 |
-
public static function skype_form( $field, $data = array() )
|
399 |
-
{
|
400 |
-
$form = array();
|
401 |
-
$form['skype-checkbox'] = array(
|
402 |
-
'#type' => 'checkbox',
|
403 |
-
'#title' => 'Skype',
|
404 |
-
'#name' => $field['#name'] . '[active]',
|
405 |
-
'#default_value' => isset( $data['active'] ) ? 1 : 0,
|
406 |
-
'#inline' => true,
|
407 |
-
'#suffix' => '<br />',
|
408 |
-
);
|
409 |
-
$form['skype-checkbox'] = self::setForced( $form['skype-checkbox'], $field, $data );
|
410 |
-
$form['skype-message'] = self::get_custom_message( $field, self::get_message( 'skype' ), $data );
|
411 |
-
return $form;
|
412 |
-
}
|
413 |
-
|
414 |
public static function setForced( $element, $field, $data = array() )
|
415 |
{
|
416 |
$attributes = array();
|
@@ -455,4 +432,4 @@ class Wpcf_Validate
|
|
455 |
return true;
|
456 |
}
|
457 |
|
458 |
-
}
|
388 |
return $form;
|
389 |
}
|
390 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
public static function setForced( $element, $field, $data = array() )
|
392 |
{
|
393 |
$attributes = array();
|
432 |
return true;
|
433 |
}
|
434 |
|
435 |
+
}
|
embedded/classes/validation-cakephp.php
CHANGED
@@ -195,29 +195,6 @@ class Wpcf_Cake_Validation
|
|
195 |
return $return;
|
196 |
}
|
197 |
|
198 |
-
function skype( $check ) {
|
199 |
-
$_this = &Wpcf_Cake_Validation::getInstance();
|
200 |
-
$_this->__reset();
|
201 |
-
$_this->check = $check;
|
202 |
-
|
203 |
-
if ( is_array( $check ) ) {
|
204 |
-
$_this->_extract( $check );
|
205 |
-
}
|
206 |
-
|
207 |
-
if ( empty( $_this->check ) && $_this->check != '0' ) {
|
208 |
-
return false;
|
209 |
-
}
|
210 |
-
$_this->regex = '/^[a-zA-Z0-9\s\-\_]*$/mu';
|
211 |
-
$return = $_this->_check();
|
212 |
-
|
213 |
-
if ( !$return ) {
|
214 |
-
$_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}\s\-\_]+$/mu';
|
215 |
-
$return = $_this->_check();
|
216 |
-
}
|
217 |
-
|
218 |
-
return $return;
|
219 |
-
}
|
220 |
-
|
221 |
/**
|
222 |
* Checks that a string length is within s specified range.
|
223 |
* Spaces are included in the character count.
|
195 |
return $return;
|
196 |
}
|
197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
/**
|
199 |
* Checks that a string length is within s specified range.
|
200 |
* Spaces are included in the character count.
|
embedded/common/changelog.txt
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
-------------------------------------------------------------------------------------------------------------------
|
4 |
-
Common 1.5 (Apr 1, 2015)
|
5 |
-
- Tagged for Types 1.6.6, Views 1.8, CRED 1.3.6 and Layouts 1.1.
|
6 |
-
- Fixed issue when there is more than one CRED form on a page with the same taxonomy.
|
7 |
-
- Fixed a little problem with edit skype button modal window - was too narrow.
|
8 |
-
- Fixed empty title problem for filter "wpt_field_options" on user edit/add screen.
|
9 |
-
https://wp-types.com/forums/topic/populate-select-field-in-wpcf-um-group/
|
10 |
-
- Added filter "toolset_editor_add_form_buttons" to disable Toolset buttons on the post editor.
|
11 |
-
- Added placeholder attributes to fields.
|
12 |
-
- Updated CakePHP validation URL method to allow new TLD's.
|
13 |
-
|
14 |
-
-------------------------------------------------------------------------------------------------------------------
|
15 |
-
Common 1.4 (Feb 2 2015)
|
16 |
-
- Tagged for Views 1.7, Types 1.6.5, CRED 1.3.5 and Layouts 1.0 beta1
|
17 |
-
- Updated Installer to 1.5
|
18 |
-
|
19 |
-
-------------------------------------------------------------------------------------------------------------------
|
20 |
-
Common 1.3.1 (Dec 16 2014)
|
21 |
-
- Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
|
22 |
-
- Fixed issue about Editor addon and ACF compatibility
|
23 |
-
- Fixed issue about branding loader
|
24 |
-
|
25 |
-
-------------------------------------------------------------------------------------------------------------------
|
26 |
-
Common 1.3 (Dec 15 2014)
|
27 |
-
- Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/classes/class-toolset-admin-bar-menu.php
DELETED
@@ -1,687 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! class_exists( 'Toolset_Admin_Bar_Menu' ) ) {
|
4 |
-
|
5 |
-
class Toolset_Admin_Bar_Menu {
|
6 |
-
|
7 |
-
// singleton
|
8 |
-
private static $instance;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Avoid executing more than once the code
|
12 |
-
* @var type bool
|
13 |
-
*/
|
14 |
-
private $done;
|
15 |
-
|
16 |
-
private function __construct() {
|
17 |
-
$this->done = false;
|
18 |
-
|
19 |
-
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 99 );
|
20 |
-
|
21 |
-
if ( is_admin() ) {
|
22 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
23 |
-
} else {
|
24 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
25 |
-
}
|
26 |
-
}
|
27 |
-
|
28 |
-
public static function get_instance() {
|
29 |
-
if ( ! self::$instance ) {
|
30 |
-
self::$instance = new Toolset_Admin_Bar_Menu();
|
31 |
-
}
|
32 |
-
|
33 |
-
return self::$instance;
|
34 |
-
}
|
35 |
-
|
36 |
-
public function enqueue_styles() {
|
37 |
-
|
38 |
-
if( ! is_admin_bar_showing() ) {
|
39 |
-
return;
|
40 |
-
}
|
41 |
-
|
42 |
-
if ( $this->is_layouts_available() ) {
|
43 |
-
|
44 |
-
// Check also @WPDD_Layouts::enqueue_toolset_common_styles()
|
45 |
-
global $wpddlayout;
|
46 |
-
$wpddlayout->enqueue_styles( array( 'toolset-common' ) );
|
47 |
-
|
48 |
-
} else if ( $this->is_views_available() ) {
|
49 |
-
|
50 |
-
wp_enqueue_style( 'onthegosystems-icons', WPV_URL_EMBEDDED . '/common/res/css/toolset-common.css', array(), WPV_VERSION );
|
51 |
-
wp_enqueue_style( 'toolset-common', WPV_URL_EMBEDDED . '/onthego-resources/onthegosystems-icons/css/onthegosystems-icons.css', array( 'onthegosystems-icons' ), WPV_VERSION );
|
52 |
-
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* @see action admin_bar_menu
|
58 |
-
*/
|
59 |
-
public function admin_bar_menu( $wp_admin_bar ) {
|
60 |
-
// Check this haven't called more than once
|
61 |
-
if ( $this->done ) {
|
62 |
-
return;
|
63 |
-
}
|
64 |
-
|
65 |
-
if ( $this->get_default_plugin() && $this->has_capatibilities() && $this->is_assignable() ) {
|
66 |
-
|
67 |
-
//
|
68 |
-
// We create a Toolset menu and a child submenu.
|
69 |
-
// Clicking the parent achieves the same result than clicking the child
|
70 |
-
// Maybe we add extra menu options in the future
|
71 |
-
//
|
72 |
-
// (Icon) Design with Toolset < $href >
|
73 |
-
// |
|
74 |
-
// +- $title < $href >
|
75 |
-
//
|
76 |
-
|
77 |
-
$menu_data = $this->get_menu_data();
|
78 |
-
if ( empty( $menu_data ) ) {
|
79 |
-
// If no menu is available, then don't render menu
|
80 |
-
return;
|
81 |
-
}
|
82 |
-
list( $title, $href ) = $menu_data;
|
83 |
-
|
84 |
-
$args = array(
|
85 |
-
'id' => 'toolset_admin_bar_menu',
|
86 |
-
'title' => __( 'Design with Toolset', 'toolset' ),
|
87 |
-
'href' => $href,
|
88 |
-
'meta' => array( 'class' => 'toolset-edit-link' )
|
89 |
-
);
|
90 |
-
$wp_admin_bar->add_node( $args );
|
91 |
-
|
92 |
-
$args = array(
|
93 |
-
'parent' => 'toolset_admin_bar_menu',
|
94 |
-
'id' => 'toolset_design_this_item',
|
95 |
-
'title' => $title,
|
96 |
-
'href' => $href,
|
97 |
-
);
|
98 |
-
$wp_admin_bar->add_node( $args );
|
99 |
-
|
100 |
-
$this->done = true;
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* User is admin or similar?
|
106 |
-
* @return boolean
|
107 |
-
*/
|
108 |
-
private function has_capatibilities() {
|
109 |
-
$manage_options = current_user_can( 'manage_options' );
|
110 |
-
|
111 |
-
$has_layouts = $this->is_layouts_available();
|
112 |
-
|
113 |
-
$has_views = $this->is_views_available();
|
114 |
-
|
115 |
-
return $manage_options && ( $has_layouts || $has_views );
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Can you assign what you are seeing right now to a Layout, Content Template or WordPress Archive?
|
120 |
-
* @return boolean
|
121 |
-
*/
|
122 |
-
private function is_assignable() {
|
123 |
-
|
124 |
-
$context = $this->get_context();
|
125 |
-
if ( ! $context ) { return false; }
|
126 |
-
list( $type, $class ) = explode( '|', $context );
|
127 |
-
|
128 |
-
if ( is_admin() ) {
|
129 |
-
|
130 |
-
global $post_type;
|
131 |
-
$screen = get_current_screen();
|
132 |
-
if( preg_match( '/^(edit|edit-tags|post)$/', $screen->base ) && empty($screen->action) ) {
|
133 |
-
|
134 |
-
if( 'edit' === $screen->base ) {
|
135 |
-
|
136 |
-
// $post_type | archive
|
137 |
-
|
138 |
-
if ( 'page' === $post_type ) {
|
139 |
-
return false;
|
140 |
-
}
|
141 |
-
|
142 |
-
$post_type_object = get_post_type_object( $screen->post_type );
|
143 |
-
if ( ! ( $post_type_object->publicly_queryable && $post_type_object->has_archive ) ) {
|
144 |
-
return false;
|
145 |
-
}
|
146 |
-
|
147 |
-
} else if( 'edit-tags' === $screen->base ) {
|
148 |
-
|
149 |
-
// $taxonomy | archive
|
150 |
-
|
151 |
-
$taxonomy = get_taxonomy( $screen->taxonomy );
|
152 |
-
if ( !( $taxonomy->public ) ) {
|
153 |
-
return false;
|
154 |
-
}
|
155 |
-
|
156 |
-
} else if( 'post' === $screen->base ) {
|
157 |
-
|
158 |
-
// $post_type | page
|
159 |
-
|
160 |
-
$post_type_object = get_post_type_object( $screen->post_type );
|
161 |
-
if ( ! $post_type_object->publicly_queryable ) {
|
162 |
-
return false;
|
163 |
-
}
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
}
|
168 |
-
|
169 |
-
} else {
|
170 |
-
|
171 |
-
// Backend
|
172 |
-
if( 'page' === $class && '404' === $type ) {
|
173 |
-
|
174 |
-
return $this->is_layouts_available() && ( WPDD_Layouts_Users_Profiles::user_can_create() && WPDD_Layouts_Users_Profiles::user_can_assign() || WPDD_Layouts_Users_Profiles::user_can_edit() );
|
175 |
-
|
176 |
-
} else if ( 'page' === $class ) {
|
177 |
-
|
178 |
-
$post_type_object = get_post_type_object( $type );
|
179 |
-
$is_cpt = $post_type_object != null;
|
180 |
-
if( ! $is_cpt || ! $post_type_object->publicly_queryable ) {
|
181 |
-
return false;
|
182 |
-
}
|
183 |
-
|
184 |
-
} else if ( 'archive' === $class && preg_match( '/^(home-blog|search|author|year|month|day)$/', $type ) ) {
|
185 |
-
// DO NOTHING
|
186 |
-
} else if ( 'archive' === $class && 'page' === $type ) {
|
187 |
-
return false;
|
188 |
-
} else if ( 'archive' === $class ) {
|
189 |
-
|
190 |
-
$taxonomy = get_taxonomy( $type );
|
191 |
-
$is_tax = $taxonomy !== false;
|
192 |
-
if ( $is_tax && ! $taxonomy->public ) {
|
193 |
-
return false;
|
194 |
-
}
|
195 |
-
|
196 |
-
$post_type_object = get_post_type_object( $type );
|
197 |
-
$is_cpt = $post_type_object != null;
|
198 |
-
if( $is_cpt && ( ! $post_type_object->publicly_queryable || ! $post_type_object->has_archive ) ) {
|
199 |
-
return false;
|
200 |
-
}
|
201 |
-
|
202 |
-
}
|
203 |
-
|
204 |
-
}
|
205 |
-
|
206 |
-
return true;
|
207 |
-
}
|
208 |
-
|
209 |
-
private function is_layouts_available() {
|
210 |
-
global $wpddlayout;
|
211 |
-
|
212 |
-
// class WPDDL_Admin_Pages exists only in full version
|
213 |
-
return class_exists( 'WPDDL_Admin_Pages' ) && isset( $wpddlayout ) && is_object( $wpddlayout );
|
214 |
-
}
|
215 |
-
|
216 |
-
private function is_views_available() {
|
217 |
-
global $WP_Views;
|
218 |
-
|
219 |
-
// class WP_Views_plugin exists only in full version
|
220 |
-
return class_exists( 'WP_Views_plugin' ) && isset( $WP_Views ) && is_object( $WP_Views );
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Get the best plugin available
|
225 |
-
* @return string (layouts|views|)
|
226 |
-
*/
|
227 |
-
private function get_default_plugin() {
|
228 |
-
// Layouts always has precedence
|
229 |
-
if ( $this->is_layouts_available() ) {
|
230 |
-
return 'layouts';
|
231 |
-
} else if ( $this->is_views_available() ) {
|
232 |
-
return 'views';
|
233 |
-
} else {
|
234 |
-
// Other toolset plugins may be present
|
235 |
-
return null;
|
236 |
-
}
|
237 |
-
}
|
238 |
-
|
239 |
-
/**
|
240 |
-
* Finds the right action depending on what you're seeing and have done
|
241 |
-
* @returns array ($title, $href) or null (do not show menu)
|
242 |
-
*/
|
243 |
-
private function get_menu_data() {
|
244 |
-
|
245 |
-
$context = $this->get_context();
|
246 |
-
if ( ! $context ) {
|
247 |
-
// No context => No menu
|
248 |
-
return null;
|
249 |
-
}
|
250 |
-
|
251 |
-
// Get type {post types, taxonomies, wordpress archives slugs, 404} and class {page, archive}
|
252 |
-
list( $type, $class ) = explode( '|', $context );
|
253 |
-
|
254 |
-
// We are using the best plugin available by default, unless state otherwise below
|
255 |
-
$plugin_used = $this->get_default_plugin();
|
256 |
-
|
257 |
-
$layout_id = 0;
|
258 |
-
$ct_id = 0;
|
259 |
-
$wpa_id = 0;
|
260 |
-
$post_id = 0;
|
261 |
-
$edit_link = null;
|
262 |
-
|
263 |
-
$is_new = true;
|
264 |
-
// warning! syntax sugar ahead
|
265 |
-
|
266 |
-
// Layouts - Edit Link
|
267 |
-
if ( $is_new && $this->is_layouts_available() && WPDD_Layouts_Users_Profiles::user_can_edit() ) {
|
268 |
-
|
269 |
-
global $wpddlayout;
|
270 |
-
|
271 |
-
if( is_admin() ) {
|
272 |
-
|
273 |
-
// Only individual pages, post type pages, post type archives
|
274 |
-
// and taxonomy archives are editable from backend
|
275 |
-
//
|
276 |
-
|
277 |
-
$screen = get_current_screen();
|
278 |
-
if( preg_match( '/^(edit|edit-tags|post)$/', $screen->base ) ) {
|
279 |
-
// Exists layout? $layout_id?
|
280 |
-
|
281 |
-
if( 'edit' === $screen->base ) {
|
282 |
-
// $post_type | archive
|
283 |
-
|
284 |
-
$post_type_object = get_post_type_object( $screen->post_type );
|
285 |
-
$option_type_name = WPDD_layout_post_loop_cell_manager::OPTION_TYPES_PREFIX . $post_type_object->name;
|
286 |
-
if ( $post_type_object && property_exists( $post_type_object, 'public' ) && $post_type_object->public && $wpddlayout->layout_post_loop_cell_manager->get_option( $option_type_name ) ) {
|
287 |
-
$layout_id = (int) $wpddlayout->layout_post_loop_cell_manager->get_option( $option_type_name );
|
288 |
-
}
|
289 |
-
|
290 |
-
} else if( 'edit-tags' === $screen->base ) {
|
291 |
-
// $taxonomy | archive
|
292 |
-
|
293 |
-
$option_type_name = WPDD_layout_post_loop_cell_manager::OPTION_TAXONOMY_PREFIX . $screen->taxonomy;
|
294 |
-
if ( $wpddlayout->layout_post_loop_cell_manager->get_option( $option_type_name ) ) {
|
295 |
-
$layout_id = (int) $wpddlayout->layout_post_loop_cell_manager->get_option( $option_type_name );
|
296 |
-
}
|
297 |
-
|
298 |
-
} else if( 'post' === $screen->base ) {
|
299 |
-
// $post_type | page
|
300 |
-
|
301 |
-
// Individual
|
302 |
-
$layout_slug = get_post_meta( (int) $_GET['post'], WPDDL_LAYOUTS_META_KEY, true );
|
303 |
-
if( ! empty( $layout_slug ) ) {
|
304 |
-
$layout_id = WPDD_Layouts::get_layout_id_by_slug( $layout_slug );
|
305 |
-
|
306 |
-
}
|
307 |
-
|
308 |
-
// Multiple
|
309 |
-
if( (int) $layout_id == 0 ) {
|
310 |
-
$layout_object = $wpddlayout->post_types_manager->get_layout_to_type_object( $type );
|
311 |
-
$layout_id = $layout_object && property_exists( $layout_object, 'layout_id' ) && $layout_object->layout_id > 0
|
312 |
-
? $layout_object->layout_id
|
313 |
-
: 0;
|
314 |
-
}
|
315 |
-
|
316 |
-
}
|
317 |
-
|
318 |
-
}
|
319 |
-
|
320 |
-
} else if ( (int) $wpddlayout->get_rendered_layout_id() > 0 ) {
|
321 |
-
|
322 |
-
$layout_id = $wpddlayout->get_rendered_layout_id();
|
323 |
-
|
324 |
-
}
|
325 |
-
|
326 |
-
$is_new = $layout_id > 0 ? false : true;
|
327 |
-
$plugin_used = ! $is_new ? 'layouts' : $plugin_used;
|
328 |
-
|
329 |
-
}
|
330 |
-
|
331 |
-
// Views - Edit Link
|
332 |
-
if ( $is_new && $this->is_views_available() ) {
|
333 |
-
|
334 |
-
global $WPV_settings;
|
335 |
-
|
336 |
-
if( is_admin() ) {
|
337 |
-
|
338 |
-
// Same as Layouts
|
339 |
-
$screen = get_current_screen();
|
340 |
-
if( preg_match( '/^(edit|edit-tags|post)$/', $screen->base ) ) {
|
341 |
-
// Exists layout? $layout_id?
|
342 |
-
|
343 |
-
if( 'edit' === $screen->base ) {
|
344 |
-
// $post_type | archive
|
345 |
-
|
346 |
-
if ( isset( $WPV_settings['view_cpt_' . $type] ) && $WPV_settings['views_template_for_' . $type] > 0 ) {
|
347 |
-
$wpa_id = $WPV_settings['view_cpt_' . $type];
|
348 |
-
}
|
349 |
-
|
350 |
-
} else if( 'edit-tags' === $screen->base ) {
|
351 |
-
// $taxonomy | archive
|
352 |
-
|
353 |
-
if ( isset( $WPV_settings['view_taxonomy_loop_' . $type] ) && $WPV_settings['view_taxonomy_loop_' . $type] > 0 ) {
|
354 |
-
$wpa_id = $WPV_settings['view_taxonomy_loop_' . $type];
|
355 |
-
}
|
356 |
-
|
357 |
-
} else if( 'post' === $screen->base ) {
|
358 |
-
// $post_type | page
|
359 |
-
|
360 |
-
// Individual
|
361 |
-
if ( isset( $_GET['post'] ) && (int) $_GET['post'] > 0 ) {
|
362 |
-
$ct_id = (int) get_post_meta( (int) $_GET['post'], '_views_template', true );
|
363 |
-
}
|
364 |
-
|
365 |
-
// Multiple
|
366 |
-
if ( (int) $ct_id == 0
|
367 |
-
&& isset( $WPV_settings['views_template_for_' . $type] )
|
368 |
-
&& $WPV_settings['views_template_for_' . $type] > 0
|
369 |
-
) {
|
370 |
-
$ct_id = $WPV_settings['views_template_for_' . $type];
|
371 |
-
}
|
372 |
-
|
373 |
-
}
|
374 |
-
|
375 |
-
}
|
376 |
-
|
377 |
-
if ( ( int ) $wpa_id > 0 || ( int ) $ct_id > 0 ) {
|
378 |
-
$is_new = false;
|
379 |
-
}
|
380 |
-
|
381 |
-
} else {
|
382 |
-
|
383 |
-
if ( 'archive' === $class && 'page' != $type ) {
|
384 |
-
/* WordPress Archive */
|
385 |
-
|
386 |
-
// WordPress Loop Archives
|
387 |
-
if( preg_match( '/^(home-blog|search|author|year|month|day)$/', $type )
|
388 |
-
&& isset( $WPV_settings['view_'.$type.'-page'] )
|
389 |
-
&& (int) $WPV_settings['view_'.$type.'-page'] > 0
|
390 |
-
) {
|
391 |
-
$wpa_id = (int) $WPV_settings['view_'.$type.'-page'];
|
392 |
-
}
|
393 |
-
|
394 |
-
// Taxonomy Archive
|
395 |
-
if( ! $wpa_id ) {
|
396 |
-
$taxonomy = get_taxonomy( $type );
|
397 |
-
$is_tax = $taxonomy !== false;
|
398 |
-
if( $is_tax
|
399 |
-
&& isset( $WPV_settings['view_taxonomy_loop_' . $type] )
|
400 |
-
&& (int) $WPV_settings['view_taxonomy_loop_' . $type] > 0
|
401 |
-
) {
|
402 |
-
$wpa_id = $WPV_settings['view_taxonomy_loop_' . $type];
|
403 |
-
}
|
404 |
-
}
|
405 |
-
|
406 |
-
// Post Type Archive
|
407 |
-
if( ! $wpa_id ) {
|
408 |
-
$post_type_object = get_post_type_object( $type );
|
409 |
-
$is_cpt = $post_type_object != null;
|
410 |
-
if( $is_cpt && isset( $WPV_settings['view_cpt_' . $type] )
|
411 |
-
&& $WPV_settings['view_cpt_' . $type] > 0
|
412 |
-
) {
|
413 |
-
$wpa_id = $WPV_settings['view_cpt_' . $type];
|
414 |
-
}
|
415 |
-
}
|
416 |
-
|
417 |
-
if ( (int) $wpa_id > 0 ) {
|
418 |
-
$is_new = false;
|
419 |
-
}
|
420 |
-
|
421 |
-
} else if( 'page' === $class && ! is_404() ) {
|
422 |
-
/* Content Template */
|
423 |
-
|
424 |
-
// Individual
|
425 |
-
$ct_id = (int) get_post_meta( get_the_ID(), '_views_template', true );
|
426 |
-
|
427 |
-
// Multiple
|
428 |
-
if( (int) $ct_id == 0 ) {
|
429 |
-
|
430 |
-
if( isset( $WPV_settings['views_template_for_'.$type] ) && $WPV_settings['views_template_for_'.$type] > 0 ) {
|
431 |
-
$ct_id = $WPV_settings['views_template_for_'.$type];
|
432 |
-
}
|
433 |
-
}
|
434 |
-
|
435 |
-
if ( (int) $ct_id > 0 ) {
|
436 |
-
$is_new = false;
|
437 |
-
}
|
438 |
-
|
439 |
-
}
|
440 |
-
|
441 |
-
}
|
442 |
-
|
443 |
-
$plugin_used = ! $is_new ? 'views' : $plugin_used;
|
444 |
-
|
445 |
-
}
|
446 |
-
|
447 |
-
// $plugin_used - Create Link
|
448 |
-
if ( $is_new ) {
|
449 |
-
if( is_admin() ) {
|
450 |
-
|
451 |
-
$screen = get_current_screen();
|
452 |
-
if( $screen->id == 'post' ) {
|
453 |
-
$post_id = (int) $_GET['post'];
|
454 |
-
}
|
455 |
-
|
456 |
-
} else {
|
457 |
-
$post_id = get_the_ID();
|
458 |
-
}
|
459 |
-
}
|
460 |
-
|
461 |
-
$title = $this->get_title ( $plugin_used, $is_new, $type, $class, max( array( $layout_id, $ct_id, $wpa_id, $post_id ) ) );
|
462 |
-
$edit_link = $this->get_edit_link( $plugin_used, $is_new, $type, $class, max( array( $layout_id, $ct_id, $wpa_id, $post_id ) ) );
|
463 |
-
|
464 |
-
if ( $edit_link !== null ) {
|
465 |
-
return array( $title, $edit_link );
|
466 |
-
} else {
|
467 |
-
// No valid data => No menu
|
468 |
-
return null;
|
469 |
-
}
|
470 |
-
}
|
471 |
-
|
472 |
-
/**
|
473 |
-
* Returns an string with the context where the link is going to be display
|
474 |
-
* It is going to be like "post_type|archive" or null if link should not be displayed
|
475 |
-
* @return string {post_type or archive_type or taxonomy or 404}|{page or archive}
|
476 |
-
*/
|
477 |
-
private function get_context() {
|
478 |
-
|
479 |
-
// Rule of thumb: if there is a list of posts, it is an archive
|
480 |
-
|
481 |
-
// null means we will not show the link
|
482 |
-
$context = null;
|
483 |
-
|
484 |
-
if ( is_admin() ) {
|
485 |
-
|
486 |
-
// There are less places inside the admin to define Layouts/Templates
|
487 |
-
|
488 |
-
global $post_type;
|
489 |
-
|
490 |
-
$screen = get_current_screen();
|
491 |
-
|
492 |
-
if ( $screen->base == 'edit' && $post_type !== 'page' ) {
|
493 |
-
// list of posts page => create an archive ( WordPress Archive )
|
494 |
-
return "$post_type|archive";
|
495 |
-
} else if ( $screen->base == 'post' && empty( $screen->action ) ) {
|
496 |
-
// post editor page => create a page ( Content Template )
|
497 |
-
return "$post_type|page";
|
498 |
-
} else if ( $screen->base == 'edit-tags' ) {
|
499 |
-
// taxonomy page => always an archive ( WordPress Archive )
|
500 |
-
return "{$screen->taxonomy}|archive";
|
501 |
-
}
|
502 |
-
|
503 |
-
|
504 |
-
} else {
|
505 |
-
|
506 |
-
global $post;
|
507 |
-
|
508 |
-
if ( is_home() ) {
|
509 |
-
// Blog posts index
|
510 |
-
$context = 'home-blog|archive';
|
511 |
-
} else if ( is_search() ) {
|
512 |
-
$context = 'search|archive';
|
513 |
-
} else if ( is_author() ) {
|
514 |
-
$context = 'author|archive';
|
515 |
-
} else if ( is_year() ) {
|
516 |
-
$context = 'year|archive';
|
517 |
-
} else if ( is_month() ) {
|
518 |
-
$context = 'month|archive';
|
519 |
-
} else if ( is_day() ) {
|
520 |
-
$context = 'day|archive';
|
521 |
-
} else if ( is_category() ) {
|
522 |
-
$context = 'category|archive';
|
523 |
-
} else if ( is_tag() ) {
|
524 |
-
$context = 'post_tag|archive';
|
525 |
-
} else if ( is_tax() ) {
|
526 |
-
$taxonomy = get_taxonomy();
|
527 |
-
$context = $taxonomy->name . '|archive';
|
528 |
-
} else if ( is_post_type_archive() ) {
|
529 |
-
$context = get_post_type() . '|archive';
|
530 |
-
} else if ( is_404() ) {
|
531 |
-
// Special WordPress Error 404 Page
|
532 |
-
$context = '404|page';
|
533 |
-
} else if ( is_object( $post ) && get_class( $post ) === 'WP_Post' ) {
|
534 |
-
$context = get_post_type() . '|page';
|
535 |
-
}
|
536 |
-
|
537 |
-
}
|
538 |
-
|
539 |
-
return $context;
|
540 |
-
}
|
541 |
-
|
542 |
-
/**
|
543 |
-
* Get title for menu subitem
|
544 |
-
* @param string $plugin are we using 'layouts' or 'views'?
|
545 |
-
* @param boolean $is_new are we creating a new object?
|
546 |
-
* @param string $type post_type, taxonomy or wp slug
|
547 |
-
* @param string $class (single) page or archive
|
548 |
-
* @param int $post_id must be layout or template id if !$is_new, else post
|
549 |
-
* @return string title for menu subitem
|
550 |
-
*/
|
551 |
-
private function get_title( $plugin, $is_new, $type, $class, $post_id = null) {
|
552 |
-
|
553 |
-
if ( $is_new ) {
|
554 |
-
/* Create */
|
555 |
-
// "Create a new 'Layout for Restaurant archives'"
|
556 |
-
// "Create a new 'Content Template for Restaurants'"
|
557 |
-
// "Create a new 'WordPress Archive for Restaurant archives'"
|
558 |
-
|
559 |
-
$create_a_new = __( 'Create a new', 'toolset' );
|
560 |
-
$object = $this->get_name_auto( $plugin, $type, $class, $post_id );
|
561 |
-
|
562 |
-
return trim( sprintf( '%s %s', $create_a_new, $object ) );
|
563 |
-
|
564 |
-
} else {
|
565 |
-
/* Edit */
|
566 |
-
// "Edit 'Restaurants' Layout"
|
567 |
-
// "Edit 'Layout for Restaurants' Layout" => "Edit 'Layout for Restaurants'"
|
568 |
-
// "Edit 'Layout for Restaurant archives' Layout" => "Edit 'Layout for Restaurant' archives"
|
569 |
-
|
570 |
-
$edit = __( 'Edit', 'toolset' );
|
571 |
-
|
572 |
-
// Layout or Content Template or WordPress Archive
|
573 |
-
$layouts = __( 'Layout', 'toolset' );
|
574 |
-
$views = 'archive' === $class ? __( 'WordPress Archive', 'toolset' ) : __( 'Content Template', 'toolset' );
|
575 |
-
$artifact = 'layouts' === $plugin ? $layouts : $views;
|
576 |
-
|
577 |
-
// avoid "'Layout for Restaurant archives' Layout"
|
578 |
-
// get "'Layout for Restaurants'" instead
|
579 |
-
$post_title = get_the_title( $post_id );
|
580 |
-
$object = strpos( $post_title, $artifact ) === false ? sprintf( '%s %s', $post_title, $artifact ) : $post_title;
|
581 |
-
|
582 |
-
return trim( sprintf( '%s %s', $edit, $object ) );
|
583 |
-
|
584 |
-
}
|
585 |
-
|
586 |
-
}
|
587 |
-
|
588 |
-
/**
|
589 |
-
* Get a valid and self-defining title for a Layout, Content Template or WordPress Archive
|
590 |
-
* @param string $plugin layouts or views
|
591 |
-
* @param string $type post_type, taxonomy or wp slug
|
592 |
-
* @param string $class page or archive
|
593 |
-
*/
|
594 |
-
public function get_name_auto( $plugin, $type, $class, $post_id = null ) {
|
595 |
-
// Examples:
|
596 |
-
// Layout for Restaurants
|
597 |
-
// Layout for Restaurant archives
|
598 |
-
// Content Template for Restaurants
|
599 |
-
// WordPress Archive for Restaurants
|
600 |
-
|
601 |
-
/* Layout or Content Template or WordPress Archive */
|
602 |
-
$layouts = __( 'Layout', 'toolset' );
|
603 |
-
$views = 'archive' === $class ? __( 'WordPress Archive', 'toolset' ) : __( 'Content Template', 'toolset' );
|
604 |
-
$artifact = 'layouts' === $plugin ? $layouts : $views;
|
605 |
-
|
606 |
-
/* for */
|
607 |
-
$for = __( 'for', 'toolset' );
|
608 |
-
|
609 |
-
/* selection */
|
610 |
-
$selection = '';
|
611 |
-
|
612 |
-
if ( 'page' === $class && '404' === $type && 'layouts' === $plugin ) {
|
613 |
-
$selection = __( 'Error 404 page', 'toolset' );
|
614 |
-
} else if ( 'page' === $type ) {
|
615 |
-
$selection = get_the_title( $post_id );
|
616 |
-
} else if ( 'page' === $class ) {
|
617 |
-
$post_type = get_post_type_object( $type );
|
618 |
-
$selection = ucfirst( $post_type->label );
|
619 |
-
} else if ( 'archive' === $class && preg_match( '/^(home-blog|search|author|year|month|day)$/', $type ) ) {
|
620 |
-
$selection = sprintf( '%s %s', ucfirst( $type ), __( 'archives', 'toolset' ) );
|
621 |
-
} else if ( 'archive' === $class && preg_match( '/^(category|post_tag)$/', $type ) ) {
|
622 |
-
$taxonomy = get_taxonomy( $type );
|
623 |
-
$selection = 'layouts' === $plugin ? sprintf( '%s %s', ucfirst( $taxonomy->labels->singular_name ), __( 'archives', 'toolset' ) ) : ucfirst( $taxonomy->labels->name );
|
624 |
-
} else if ( 'archive' === $class ) {
|
625 |
-
$post_type = get_post_type_object( $type );
|
626 |
-
$is_cpt = $post_type != null;
|
627 |
-
|
628 |
-
$taxonomy = get_taxonomy( $type );
|
629 |
-
$is_tax = $taxonomy !== false;
|
630 |
-
|
631 |
-
if ( $is_cpt ) {
|
632 |
-
$selection = 'layouts' === $plugin ? sprintf( '%s %s', ucfirst( $post_type->labels->singular_name ), __( 'archives', 'toolset' ) ) : ucfirst( $post_type->labels->name );
|
633 |
-
} else if ( $is_tax ) {
|
634 |
-
$selection = 'layouts' === $plugin ? sprintf( '%s %s', ucfirst( $taxonomy->labels->singular_name ), __( 'archives', 'toolset' ) ) : ucfirst( $taxonomy->labels->name );
|
635 |
-
} else {
|
636 |
-
$selection = __( 'Unsupported post type archives', 'toolset' );
|
637 |
-
}
|
638 |
-
|
639 |
-
} else {
|
640 |
-
$selection = __( 'Unsupported page', 'toolset' );
|
641 |
-
}
|
642 |
-
|
643 |
-
return trim( sprintf( '%s %s %s', $artifact, $for, $selection ) );
|
644 |
-
}
|
645 |
-
|
646 |
-
public function get_edit_link( $plugin, $is_new, $type, $class, $post_id = null ) {
|
647 |
-
$edit_link = null;
|
648 |
-
|
649 |
-
if( 'layouts' === $plugin ) {
|
650 |
-
|
651 |
-
if( $is_new && WPDD_Layouts_Users_Profiles::user_can_create() && WPDD_Layouts_Users_Profiles::user_can_assign() ) {
|
652 |
-
$edit_link = wp_nonce_url( admin_url( sprintf( 'admin.php?page=dd_layouts_create_auto&type=%s&class=%s&post=%s', $type, $class, $post_id ) ), 'create_auto' );
|
653 |
-
} else if( $post_id > 0 && WPDD_Layouts_Users_Profiles::user_can_edit() ) {
|
654 |
-
// Layouts editor
|
655 |
-
$edit_link = admin_url( sprintf( 'admin.php?page=dd_layouts_edit&layout_id=%s&action=edit', $post_id ) );
|
656 |
-
}
|
657 |
-
|
658 |
-
} else if ( 'views' === $plugin && '404' != $type /* No support for Error 404 page */ ) {
|
659 |
-
|
660 |
-
if ( $is_new ) {
|
661 |
-
$edit_link = wp_nonce_url( admin_url( sprintf( 'admin.php?page=views_template_auto&type=%s&class=%s&post=%s', $type, $class, $post_id ) ), 'create_auto' );
|
662 |
-
} else if( $post_id > 0 ) {
|
663 |
-
|
664 |
-
if( 'archive' === $class ) {
|
665 |
-
// Views' WordPress Archive editor
|
666 |
-
$edit_link = admin_url( sprintf( 'admin.php?page=view-archives-editor&view_id=%s', $post_id ) );
|
667 |
-
} else if( 'page' === $class ) {
|
668 |
-
// WordPress default editor
|
669 |
-
$edit_link = admin_url( sprintf( 'post.php?action=edit&post=%s', $post_id ) );
|
670 |
-
}
|
671 |
-
|
672 |
-
}
|
673 |
-
}
|
674 |
-
|
675 |
-
return $edit_link;
|
676 |
-
}
|
677 |
-
|
678 |
-
}
|
679 |
-
|
680 |
-
// We have checked if @class Toolset_Admin_Bar_Menu already existed.
|
681 |
-
// After that, we've defined the class. Now, we instantiate it once.
|
682 |
-
// This works lìke a singleton.
|
683 |
-
// But the class itself is also a singleton. Using design patterns
|
684 |
-
// clarifies and prevents against changes in future.
|
685 |
-
global $toolset_admin_bar_menu;
|
686 |
-
$toolset_admin_bar_menu = Toolset_Admin_Bar_Menu::get_instance();
|
687 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/classes/class.toolset.promo.php
DELETED
@@ -1,197 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6.6/embedded/common/classes/class.toolset.promo.php $
|
6 |
-
* $LastChangedDate: 2015-03-25 12:38:40 +0000 (Wed, 25 Mar 2015) $
|
7 |
-
* $LastChangedRevision: 1120400 $
|
8 |
-
* $LastChangedBy: iworks $
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
|
12 |
-
if (!class_exists('Toolset_Promotion')) {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Class to show promotion message.
|
16 |
-
*
|
17 |
-
* @since 1.5
|
18 |
-
* @access public
|
19 |
-
*/
|
20 |
-
class Toolset_Promotion
|
21 |
-
{
|
22 |
-
private $version = '1.0';
|
23 |
-
|
24 |
-
public function __construct()
|
25 |
-
{
|
26 |
-
add_action('admin_init', array($this, 'admin_init'));
|
27 |
-
add_action('admin_footer', array($this, 'admin_footer'));
|
28 |
-
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
|
29 |
-
add_action('plugins_loaded', 'on_the_go_systems_branding_plugins_loaded');
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Register script and styles
|
34 |
-
*
|
35 |
-
* Register script and styles for future usage.
|
36 |
-
*
|
37 |
-
* @since 1.5
|
38 |
-
*
|
39 |
-
*/
|
40 |
-
public function admin_init()
|
41 |
-
{
|
42 |
-
wp_register_script(
|
43 |
-
'toolset-colorbox',
|
44 |
-
plugins_url('/res/js/jquery.colorbox-min.js', dirname(__FILE__)),
|
45 |
-
array('jquery'),
|
46 |
-
'1.4.31'
|
47 |
-
);
|
48 |
-
wp_register_script(
|
49 |
-
__CLASS__,
|
50 |
-
plugins_url('/res/js/toolset-promotion.js', dirname(__FILE__)),
|
51 |
-
array('underscore', 'toolset-colorbox'),
|
52 |
-
$this->version,
|
53 |
-
true
|
54 |
-
);
|
55 |
-
wp_register_style(
|
56 |
-
'toolset-colorbox',
|
57 |
-
plugins_url('/res/css/colorbox.css', dirname(__FILE__)),
|
58 |
-
false,
|
59 |
-
'1.4.31'
|
60 |
-
);
|
61 |
-
wp_register_style(
|
62 |
-
__CLASS__,
|
63 |
-
plugins_url('/res/css/toolset-promotion.css', dirname(__FILE__)),
|
64 |
-
array('toolset-colorbox', 'onthego-admin-styles'),
|
65 |
-
$this->version
|
66 |
-
);
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Enqueue scripts & styles
|
71 |
-
*
|
72 |
-
* After check is a correct place, this function enqueue scripts & styles
|
73 |
-
* for toolset promotion box.
|
74 |
-
*
|
75 |
-
* @since 1.5
|
76 |
-
*
|
77 |
-
*/
|
78 |
-
public function admin_enqueue_scripts()
|
79 |
-
{
|
80 |
-
if (!is_admin() || !function_exists('get_current_screen')) {
|
81 |
-
return;
|
82 |
-
}
|
83 |
-
/**
|
84 |
-
* List of admin page id
|
85 |
-
*
|
86 |
-
* Filter allow to add or change list of admin screen id for checking
|
87 |
-
* where we need enqueue toolset promotion assets.
|
88 |
-
*
|
89 |
-
* @since 1.5
|
90 |
-
*
|
91 |
-
* @param array $screen_ids List of admin page screen ids.
|
92 |
-
*
|
93 |
-
*/
|
94 |
-
$screen_ids = apply_filters('toolset_promotion_screen_ids', array());
|
95 |
-
if (empty($screen_ids)) {
|
96 |
-
return;
|
97 |
-
}
|
98 |
-
$screen = get_current_screen();
|
99 |
-
if (!in_array($screen->id, $screen_ids)) {
|
100 |
-
return;
|
101 |
-
}
|
102 |
-
wp_enqueue_style(__CLASS__);
|
103 |
-
wp_enqueue_script(__CLASS__);
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Print in footer
|
108 |
-
*
|
109 |
-
* Print nessary elemnt in admin footer
|
110 |
-
*
|
111 |
-
* @since 1.5
|
112 |
-
*
|
113 |
-
*/
|
114 |
-
public function admin_footer()
|
115 |
-
{
|
116 |
-
$link_learn = $this->get_affiliate_link_string('http://wp-types.com/');
|
117 |
-
$link_button = $this->get_affiliate_link_string('http://wp-types.com/#buy-toolset');
|
118 |
-
|
119 |
-
ob_start();
|
120 |
-
?>
|
121 |
-
|
122 |
-
<div class="ddl-dialogs-container">
|
123 |
-
<div id="js-buy-toolset-embedded-message-wrap"></div>
|
124 |
-
</div>
|
125 |
-
<script type="text/html" id="js-buy-toolset-embedded-message">
|
126 |
-
<div class="toolset-modal">
|
127 |
-
<h2><?php _e('Want to edit Views, CRED forms and Layouts? Get the full <em>Toolset</em> package!', 'wpcf'); ?></h2>
|
128 |
-
|
129 |
-
<div class="content">
|
130 |
-
<p class="full"><?php _e('The full <em>Toolset</em> package allows you to develop and customize themes without touching PHP. You will be able to:', 'wpcf'); ?></p>
|
131 |
-
|
132 |
-
<div class="icons">
|
133 |
-
<ul>
|
134 |
-
<li class="template"><?php _e('Create templates', 'wpcf'); ?></li>
|
135 |
-
<li class="layout"><?php _e('Design page layouts using drag-and-drop', 'wpcf'); ?></li>
|
136 |
-
<li class="toolset-search"><?php _e('Build parametric searches', 'wpcf'); ?></li>
|
137 |
-
</ul>
|
138 |
-
<ul>
|
139 |
-
<li class="list"><?php _e('Display lists of content', 'wpcf'); ?></li>
|
140 |
-
<li class="form"><?php _e('Create front-end content editing forms', 'wpcf'); ?></li>
|
141 |
-
<li class="more"><?php _e('and more…', 'wpcf'); ?></li>
|
142 |
-
</ul>
|
143 |
-
</div>
|
144 |
-
|
145 |
-
<p class="description"><?php _e('Once you buy the full Toolset, you will be able to edit Views, CRED forms and Layouts in your site, as well as build new ones.', 'wpcf'); ?></p>
|
146 |
-
|
147 |
-
<a href="<?php echo $link_button; ?>"
|
148 |
-
class="button"><?php _e('<em>Toolset</em> Package Options', 'wpcf'); ?></a>
|
149 |
-
<a href="<?php echo $link_learn; ?>"
|
150 |
-
class="learn"><?php _e('Learn more about <em>Toolset</em>', 'wpcf'); ?></a>
|
151 |
-
|
152 |
-
</div>
|
153 |
-
<span class="icon-toolset-logo"></span>
|
154 |
-
<span class="js-close-promotional-message"></span>
|
155 |
-
</div>
|
156 |
-
</script>
|
157 |
-
<?php
|
158 |
-
echo ob_get_clean();
|
159 |
-
}
|
160 |
-
|
161 |
-
private function get_affiliate_link_string($link)
|
162 |
-
{
|
163 |
-
if (function_exists('installer_ep_get_configuration') === false) {
|
164 |
-
return $link;
|
165 |
-
}
|
166 |
-
|
167 |
-
$info = installer_ep_get_configuration(wp_get_theme()->Name);
|
168 |
-
|
169 |
-
if (!isset($info['repositories']) &&
|
170 |
-
!isset($info['repositories']['toolset'])
|
171 |
-
) {
|
172 |
-
return $link;
|
173 |
-
|
174 |
-
} else if (
|
175 |
-
isset($info['repositories']['toolset']['affiliate_id']) &&
|
176 |
-
isset($info['repositories']['toolset']['affiliate_key'])
|
177 |
-
) {
|
178 |
-
$id = $info['repositories']['toolset']['affiliate_id'];
|
179 |
-
$key = $info['repositories']['toolset']['affiliate_key'];
|
180 |
-
|
181 |
-
$hash = explode( '#', $link );
|
182 |
-
if( count($hash) > 1 ){
|
183 |
-
$link = $hash[0];
|
184 |
-
$hash = "#" . $hash[1];
|
185 |
-
} else {
|
186 |
-
$hash = '';
|
187 |
-
}
|
188 |
-
|
189 |
-
return sprintf("%s?aid=%s&affiliate_key=%s%s", $link, $id, $key, $hash);
|
190 |
-
}
|
191 |
-
|
192 |
-
return $link;
|
193 |
-
}
|
194 |
-
|
195 |
-
}
|
196 |
-
|
197 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/classes/forms.php
CHANGED
@@ -2,15 +2,15 @@
|
|
2 |
/**
|
3 |
* Returns HTML formatted output for elements and handles form submission.
|
4 |
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
6 |
-
* $LastChangedDate:
|
7 |
-
* $LastChangedRevision:
|
8 |
* $LastChangedBy: iworks $
|
9 |
*
|
10 |
* @version 1.0
|
11 |
*/
|
12 |
-
if (!class_exists('Enlimbo_Forms_Wpcf')) {
|
13 |
-
|
14 |
class Enlimbo_Forms_Wpcf
|
15 |
{
|
16 |
|
@@ -323,7 +323,7 @@ if (!class_exists('Enlimbo_Forms_Wpcf')) {
|
|
323 |
continue;
|
324 |
}
|
325 |
// Don't set disabled for checkbox
|
326 |
-
if (
|
327 |
continue;
|
328 |
}
|
329 |
// Append class values
|
@@ -368,15 +368,10 @@ if (!class_exists('Enlimbo_Forms_Wpcf')) {
|
|
368 |
if ( isset( $element['#labelclass'] ) ) {
|
369 |
$labelclass = $element['#labelclass'] . ' ';
|
370 |
}
|
371 |
-
$labelstyle = '';
|
372 |
-
if ( isset( $element['#labelstyle'] ) ) {
|
373 |
-
$labelstyle = ' style="' . $element['#labelstyle'] . '" ';
|
374 |
-
}
|
375 |
$element['_render']['label'] = isset($element['#title']) ? '<label class="'
|
376 |
. $labelclass
|
377 |
. $this->css_class . '-label ' . $this->css_class . '-'
|
378 |
-
. $element['#type'] . '-label" for="' . $element['#id'] . '"'
|
379 |
-
$labelstyle . '>'
|
380 |
. stripslashes($element['#title'])
|
381 |
. '</label>' . "\r\n" : '';
|
382 |
$element['_render']['title'] = $this->_setElementTitle($element);
|
@@ -588,7 +583,7 @@ if (!class_exists('Enlimbo_Forms_Wpcf')) {
|
|
588 |
$element['_render']['element'] .= ' onclick="javascript:return false; if(this.checked == 1){this.checked=1; return true;}else{this.checked=0; return false;}"';
|
589 |
}
|
590 |
if (!empty($element['#attributes']['#disabled'])) {
|
591 |
-
$element['_render']['element'] .= ' disabled="disabled"';
|
592 |
}
|
593 |
|
594 |
$element['_render']['element'] .= ' />';
|
@@ -937,10 +932,8 @@ if (!class_exists('Enlimbo_Forms_Wpcf')) {
|
|
937 |
}
|
938 |
|
939 |
$parts = explode('[', $name);
|
940 |
-
|
941 |
-
|
942 |
-
//$parts = array_map(create function('&$a', 'return trim($a, \']\');'), $parts);
|
943 |
-
$parts = array_map("cred_mytrimfunction", $parts);
|
944 |
if (!isset($_REQUEST[$parts[0]])) {
|
945 |
return in_array($element['#type'],
|
946 |
array('textfield', 'textarea')) ? '' : 0;
|
2 |
/**
|
3 |
* Returns HTML formatted output for elements and handles form submission.
|
4 |
*
|
5 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/classes/forms.php $
|
6 |
+
* $LastChangedDate: 2014-05-29 08:44:10 +0000 (Thu, 29 May 2014) $
|
7 |
+
* $LastChangedRevision: 922956 $
|
8 |
* $LastChangedBy: iworks $
|
9 |
*
|
10 |
* @version 1.0
|
11 |
*/
|
12 |
+
if (!class_exists('Enlimbo_Forms_Wpcf')) {
|
13 |
+
|
14 |
class Enlimbo_Forms_Wpcf
|
15 |
{
|
16 |
|
323 |
continue;
|
324 |
}
|
325 |
// Don't set disabled for checkbox
|
326 |
+
if ($attribute == 'disabled' && $element['#type'] == 'checkbox') {
|
327 |
continue;
|
328 |
}
|
329 |
// Append class values
|
368 |
if ( isset( $element['#labelclass'] ) ) {
|
369 |
$labelclass = $element['#labelclass'] . ' ';
|
370 |
}
|
|
|
|
|
|
|
|
|
371 |
$element['_render']['label'] = isset($element['#title']) ? '<label class="'
|
372 |
. $labelclass
|
373 |
. $this->css_class . '-label ' . $this->css_class . '-'
|
374 |
+
. $element['#type'] . '-label" for="' . $element['#id'] . '">'
|
|
|
375 |
. stripslashes($element['#title'])
|
376 |
. '</label>' . "\r\n" : '';
|
377 |
$element['_render']['title'] = $this->_setElementTitle($element);
|
583 |
$element['_render']['element'] .= ' onclick="javascript:return false; if(this.checked == 1){this.checked=1; return true;}else{this.checked=0; return false;}"';
|
584 |
}
|
585 |
if (!empty($element['#attributes']['#disabled'])) {
|
586 |
+
$element['_render']['element'] .= ' disabled="disabled""';
|
587 |
}
|
588 |
|
589 |
$element['_render']['element'] .= ' />';
|
932 |
}
|
933 |
|
934 |
$parts = explode('[', $name);
|
935 |
+
$parts = array_map(create_function('&$a', 'return trim($a, \']\');'),
|
936 |
+
$parts);
|
|
|
|
|
937 |
if (!isset($_REQUEST[$parts[0]])) {
|
938 |
return in_array($element['#type'],
|
939 |
array('textfield', 'textarea')) ? '' : 0;
|
embedded/common/classes/validation-cakephp.php
CHANGED
@@ -29,1111 +29,1098 @@
|
|
29 |
* @since CakePHP v 1.2.0.3830
|
30 |
*/
|
31 |
//class Validation extends Object {
|
32 |
-
if
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
|
|
|
|
|
|
426 |
$cake_date_formats = array(
|
427 |
'F j, Y' => 'Mdy',
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
);
|
433 |
|
434 |
$format = $cake_date_formats[$date_format];
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
*
|
1124 |
-
* @return void
|
1125 |
-
* @access private
|
1126 |
-
*/
|
1127 |
-
function __reset() {
|
1128 |
-
$this->check = null;
|
1129 |
-
$this->regex = null;
|
1130 |
-
$this->country = null;
|
1131 |
-
$this->deep = null;
|
1132 |
-
$this->type = null;
|
1133 |
-
$this->error = array();
|
1134 |
-
$this->errors = array();
|
1135 |
-
}
|
1136 |
-
|
1137 |
-
}
|
1138 |
-
|
1139 |
}
|
29 |
* @since CakePHP v 1.2.0.3830
|
30 |
*/
|
31 |
//class Validation extends Object {
|
32 |
+
if(!class_exists('Wpcf_Cake_Validation')) {
|
33 |
+
class Wpcf_Cake_Validation
|
34 |
+
{
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Set the value of methods $check param.
|
38 |
+
*
|
39 |
+
* @var string
|
40 |
+
* @access public
|
41 |
+
*/
|
42 |
+
var $check = null;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Set to a valid regular expression in the class methods.
|
46 |
+
* Can be set from $regex param also
|
47 |
+
*
|
48 |
+
* @var string
|
49 |
+
* @access public
|
50 |
+
*/
|
51 |
+
var $regex = null;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Some complex patterns needed in multiple places
|
55 |
+
*
|
56 |
+
* @var array
|
57 |
+
* @access private
|
58 |
+
*/
|
59 |
+
var $__pattern = array(
|
60 |
+
'hostname' => '(?:[a-z0-9][-a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)'
|
61 |
+
);
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Some class methods use a country to determine proper validation.
|
65 |
+
* This can be passed to methods in the $country param
|
66 |
+
*
|
67 |
+
* @var string
|
68 |
+
* @access public
|
69 |
+
*/
|
70 |
+
var $country = null;
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Some class methods use a deeper validation when set to true
|
74 |
+
*
|
75 |
+
* @var string
|
76 |
+
* @access public
|
77 |
+
*/
|
78 |
+
var $deep = null;
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Some class methods use the $type param to determine which validation to perfom in the method
|
82 |
+
*
|
83 |
+
* @var string
|
84 |
+
* @access public
|
85 |
+
*/
|
86 |
+
var $type = null;
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Holds an array of errors messages set in this class.
|
90 |
+
* These are used for debugging purposes
|
91 |
+
*
|
92 |
+
* @var array
|
93 |
+
* @access public
|
94 |
+
*/
|
95 |
+
var $errors = array();
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Gets a reference to the Validation object instance
|
99 |
+
*
|
100 |
+
* @return object Validation instance
|
101 |
+
* @access public
|
102 |
+
* @static
|
103 |
+
*/
|
104 |
+
function &getInstance() {
|
105 |
+
static $instance = array();
|
106 |
+
|
107 |
+
if (!$instance) {
|
108 |
+
$instance[0] = new Wpcf_Cake_Validation();
|
109 |
+
}
|
110 |
+
return $instance[0];
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Checks that a string contains something other than whitespace
|
115 |
+
*
|
116 |
+
* Returns true if string contains something other than whitespace
|
117 |
+
*
|
118 |
+
* $check can be passed as an array:
|
119 |
+
* array('check' => 'valueToCheck');
|
120 |
+
*
|
121 |
+
* @param mixed $check Value to check
|
122 |
+
* @return boolean Success
|
123 |
+
* @access public
|
124 |
+
*/
|
125 |
+
function notEmpty($check) {
|
126 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
127 |
+
$_this->__reset();
|
128 |
+
$_this->check = $check;
|
129 |
+
|
130 |
+
if (is_array($check)) {
|
131 |
+
$_this->_extract($check);
|
132 |
+
}
|
133 |
+
|
134 |
+
if (empty($_this->check) && $_this->check != '0') {
|
135 |
+
return false;
|
136 |
+
}
|
137 |
+
$_this->regex = '/[^\s]+/m';
|
138 |
+
return $_this->_check();
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Checks that a string contains only integer or letters
|
143 |
+
*
|
144 |
+
* Returns true if string contains only integer or letters
|
145 |
+
*
|
146 |
+
* $check can be passed as an array:
|
147 |
+
* array('check' => 'valueToCheck');
|
148 |
+
*
|
149 |
+
* @param mixed $check Value to check
|
150 |
+
* @return boolean Success
|
151 |
+
* @access public
|
152 |
+
*/
|
153 |
+
function alphaNumeric($check) {
|
154 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
155 |
+
$_this->__reset();
|
156 |
+
$_this->check = $check;
|
157 |
+
|
158 |
+
if (is_array($check)) {
|
159 |
+
$_this->_extract($check);
|
160 |
+
}
|
161 |
+
|
162 |
+
if (empty($_this->check) && $_this->check != '0') {
|
163 |
+
return false;
|
164 |
+
}
|
165 |
+
$_this->regex = '/^[a-zA-Z0-9]*$/mu';
|
166 |
+
$return = $_this->_check();
|
167 |
+
|
168 |
+
if (!$return) {
|
169 |
+
$_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/mu';
|
170 |
+
$return = $_this->_check();
|
171 |
+
}
|
172 |
+
|
173 |
+
return $_this->_check();
|
174 |
+
}
|
175 |
+
|
176 |
+
function alphaNumericWhitespaces($check) {
|
177 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
178 |
+
$_this->__reset();
|
179 |
+
$_this->check = $check;
|
180 |
+
|
181 |
+
if (is_array($check)) {
|
182 |
+
$_this->_extract($check);
|
183 |
+
}
|
184 |
+
|
185 |
+
if (empty($_this->check) && $_this->check != '0') {
|
186 |
+
return false;
|
187 |
+
}
|
188 |
+
$_this->regex = '/^[a-zA-Z0-9\s\-\_]*$/mu';
|
189 |
+
$return = $_this->_check();
|
190 |
+
|
191 |
+
if (!$return) {
|
192 |
+
$_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}\s\-\_]+$/mu';
|
193 |
+
$return = $_this->_check();
|
194 |
+
}
|
195 |
+
|
196 |
+
return $return;
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Checks that a string length is within s specified range.
|
201 |
+
* Spaces are included in the character count.
|
202 |
+
* Returns true is string matches value min, max, or between min and max,
|
203 |
+
*
|
204 |
+
* @param string $check Value to check for length
|
205 |
+
* @param integer $min Minimum value in range (inclusive)
|
206 |
+
* @param integer $max Maximum value in range (inclusive)
|
207 |
+
* @return boolean Success
|
208 |
+
* @access public
|
209 |
+
*/
|
210 |
+
function between($check, $min, $max) {
|
211 |
+
$length = strlen($check);
|
212 |
+
return ($length >= $min && $length <= $max);
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Returns true if field is left blank -OR- only whitespace characters are present in it's value
|
217 |
+
* Whitespace characters include Space, Tab, Carriage Return, Newline
|
218 |
+
*
|
219 |
+
* $check can be passed as an array:
|
220 |
+
* array('check' => 'valueToCheck');
|
221 |
+
*
|
222 |
+
* @param mixed $check Value to check
|
223 |
+
* @return boolean Success
|
224 |
+
* @access public
|
225 |
+
*/
|
226 |
+
function blank($check) {
|
227 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
228 |
+
$_this->__reset();
|
229 |
+
$_this->check = $check;
|
230 |
+
|
231 |
+
if (is_array($check)) {
|
232 |
+
$_this->_extract($check);
|
233 |
+
}
|
234 |
+
|
235 |
+
$_this->regex = '/[^\\s]/';
|
236 |
+
return!$_this->_check();
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Validation of credit card numbers.
|
241 |
+
* Returns true if $check is in the proper credit card format.
|
242 |
+
*
|
243 |
+
* @param mixed $check credit card number to validate
|
244 |
+
* @param mixed $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit cards
|
245 |
+
* if an array is used only the values of the array are checked.
|
246 |
+
* Example: array('amex', 'bankcard', 'maestro')
|
247 |
+
* @param boolean $deep set to true this will check the Luhn algorithm of the credit card.
|
248 |
+
* @param string $regex A custom regex can also be passed, this will be used instead of the defined regex values
|
249 |
+
* @return boolean Success
|
250 |
+
* @access public
|
251 |
+
* @see Wpcf_Cake_Validation::_luhn()
|
252 |
+
*/
|
253 |
+
function cc($check, $type = 'fast', $deep = false, $regex = null) {
|
254 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
255 |
+
$_this->__reset();
|
256 |
+
$_this->check = $check;
|
257 |
+
$_this->type = $type;
|
258 |
+
$_this->deep = $deep;
|
259 |
+
$_this->regex = $regex;
|
260 |
+
|
261 |
+
if (is_array($check)) {
|
262 |
+
$_this->_extract($check);
|
263 |
+
}
|
264 |
+
$_this->check = str_replace(array('-', ' '), '', $_this->check);
|
265 |
+
|
266 |
+
if (strlen($_this->check) < 13) {
|
267 |
+
return false;
|
268 |
+
}
|
269 |
+
|
270 |
+
if (!is_null($_this->regex)) {
|
271 |
+
if ($_this->_check()) {
|
272 |
+
return $_this->_luhn();
|
273 |
+
}
|
274 |
+
}
|
275 |
+
$cards = array(
|
276 |
+
'all' => array(
|
277 |
+
'amex' => '/^3[4|7]\\d{13}$/',
|
278 |
+
'bankcard' => '/^56(10\\d\\d|022[1-5])\\d{10}$/',
|
279 |
+
'diners' => '/^(?:3(0[0-5]|[68]\\d)\\d{11})|(?:5[1-5]\\d{14})$/',
|
280 |
+
'disc' => '/^(?:6011|650\\d)\\d{12}$/',
|
281 |
+
'electron' => '/^(?:417500|4917\\d{2}|4913\\d{2})\\d{10}$/',
|
282 |
+
'enroute' => '/^2(?:014|149)\\d{11}$/',
|
283 |
+
'jcb' => '/^(3\\d{4}|2100|1800)\\d{11}$/',
|
284 |
+
'maestro' => '/^(?:5020|6\\d{3})\\d{12}$/',
|
285 |
+
'mc' => '/^5[1-5]\\d{14}$/',
|
286 |
+
'solo' => '/^(6334[5-9][0-9]|6767[0-9]{2})\\d{10}(\\d{2,3})?$/',
|
287 |
+
'switch' => '/^(?:49(03(0[2-9]|3[5-9])|11(0[1-2]|7[4-9]|8[1-2])|36[0-9]{2})\\d{10}(\\d{2,3})?)|(?:564182\\d{10}(\\d{2,3})?)|(6(3(33[0-4][0-9])|759[0-9]{2})\\d{10}(\\d{2,3})?)$/',
|
288 |
+
'visa' => '/^4\\d{12}(\\d{3})?$/',
|
289 |
+
'voyager' => '/^8699[0-9]{11}$/'
|
290 |
+
),
|
291 |
+
'fast' => '/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/'
|
292 |
+
);
|
293 |
+
|
294 |
+
if (is_array($_this->type)) {
|
295 |
+
foreach ($_this->type as $value) {
|
296 |
+
$_this->regex = $cards['all'][strtolower($value)];
|
297 |
+
|
298 |
+
if ($_this->_check()) {
|
299 |
+
return $_this->_luhn();
|
300 |
+
}
|
301 |
+
}
|
302 |
+
} elseif ($_this->type == 'all') {
|
303 |
+
foreach ($cards['all'] as $value) {
|
304 |
+
$_this->regex = $value;
|
305 |
+
|
306 |
+
if ($_this->_check()) {
|
307 |
+
return $_this->_luhn();
|
308 |
+
}
|
309 |
+
}
|
310 |
+
} else {
|
311 |
+
$_this->regex = $cards['fast'];
|
312 |
+
|
313 |
+
if ($_this->_check()) {
|
314 |
+
return $_this->_luhn();
|
315 |
+
}
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Used to compare 2 numeric values.
|
321 |
+
*
|
322 |
+
* @param mixed $check1 if string is passed for a string must also be passed for $check2
|
323 |
+
* used as an array it must be passed as array('check1' => value, 'operator' => 'value', 'check2' -> value)
|
324 |
+
* @param string $operator Can be either a word or operand
|
325 |
+
* is greater >, is less <, greater or equal >=
|
326 |
+
* less or equal <=, is less <, equal to ==, not equal !=
|
327 |
+
* @param integer $check2 only needed if $check1 is a string
|
328 |
+
* @return boolean Success
|
329 |
+
* @access public
|
330 |
+
*/
|
331 |
+
function comparison($check1, $operator = null, $check2 = null) {
|
332 |
+
if (is_array($check1)) {
|
333 |
+
extract($check1, EXTR_OVERWRITE);
|
334 |
+
}
|
335 |
+
$operator = str_replace(array(' ', "\t", "\n", "\r", "\0", "\x0B"), '',
|
336 |
+
strtolower($operator));
|
337 |
+
|
338 |
+
switch ($operator) {
|
339 |
+
case 'isgreater':
|
340 |
+
case '>':
|
341 |
+
if ($check1 > $check2) {
|
342 |
+
return true;
|
343 |
+
}
|
344 |
+
break;
|
345 |
+
case 'isless':
|
346 |
+
case '<':
|
347 |
+
if ($check1 < $check2) {
|
348 |
+
return true;
|
349 |
+
}
|
350 |
+
break;
|
351 |
+
case 'greaterorequal':
|
352 |
+
case '>=':
|
353 |
+
if ($check1 >= $check2) {
|
354 |
+
return true;
|
355 |
+
}
|
356 |
+
break;
|
357 |
+
case 'lessorequal':
|
358 |
+
case '<=':
|
359 |
+
if ($check1 <= $check2) {
|
360 |
+
return true;
|
361 |
+
}
|
362 |
+
break;
|
363 |
+
case 'equalto':
|
364 |
+
case '==':
|
365 |
+
if ($check1 == $check2) {
|
366 |
+
return true;
|
367 |
+
}
|
368 |
+
break;
|
369 |
+
case 'notequal':
|
370 |
+
case '!=':
|
371 |
+
if ($check1 != $check2) {
|
372 |
+
return true;
|
373 |
+
}
|
374 |
+
break;
|
375 |
+
default:
|
376 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
377 |
+
$_this->errors[] = __('You must define the $operator parameter for Wpcf_Cake_Validation::comparison()',
|
378 |
+
'wpcf');
|
379 |
+
break;
|
380 |
+
}
|
381 |
+
return false;
|
382 |
+
}
|
383 |
+
|
384 |
+
/**
|
385 |
+
* Used when a custom regular expression is needed.
|
386 |
+
*
|
387 |
+
* @param mixed $check When used as a string, $regex must also be a valid regular expression.
|
388 |
+
* As and array: array('check' => value, 'regex' => 'valid regular expression')
|
389 |
+
* @param string $regex If $check is passed as a string, $regex must also be set to valid regular expression
|
390 |
+
* @return boolean Success
|
391 |
+
* @access public
|
392 |
+
*/
|
393 |
+
function custom($check, $regex = null) {
|
394 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
395 |
+
$_this->__reset();
|
396 |
+
$_this->check = $check;
|
397 |
+
$_this->regex = $regex;
|
398 |
+
if (is_array($check)) {
|
399 |
+
$_this->_extract($check);
|
400 |
+
}
|
401 |
+
if ($_this->regex === null) {
|
402 |
+
$_this->errors[] = __('You must define a regular expression for Wpcf_Cake_Validation::custom()',
|
403 |
+
'wpcf');
|
404 |
+
return false;
|
405 |
+
}
|
406 |
+
return $_this->_check();
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Date validation, determines if the string passed is a valid date.
|
411 |
+
* keys that expect full month, day and year will validate leap years
|
412 |
+
*
|
413 |
+
* @param string $check a valid date string
|
414 |
+
* @param mixed $format Use a string or an array of the keys below. Arrays should be passed as array('dmy', 'mdy', etc)
|
415 |
+
* Keys: dmy 27-12-2006 or 27-12-06 separators can be a space, period, dash, forward slash
|
416 |
+
* mdy 12-27-2006 or 12-27-06 separators can be a space, period, dash, forward slash
|
417 |
+
* ymd 2006-12-27 or 06-12-27 separators can be a space, period, dash, forward slash
|
418 |
+
* dMy 27 December 2006 or 27 Dec 2006
|
419 |
+
* Mdy December 27, 2006 or Dec 27, 2006 comma is optional
|
420 |
+
* My December 2006 or Dec 2006
|
421 |
+
* my 12/2006 separators can be a space, period, dash, forward slash
|
422 |
+
* @param string $regex If a custom regular expression is used this is the only validation that will occur.
|
423 |
+
* @return boolean Success
|
424 |
+
* @access public
|
425 |
+
*/
|
426 |
+
function date($check, $format = 'ymd', $regex = null) {
|
427 |
+
|
428 |
+
$date_format = wpcf_get_date_format();
|
429 |
$cake_date_formats = array(
|
430 |
'F j, Y' => 'Mdy',
|
431 |
+
'Y/m/d' => 'ymd',
|
432 |
+
'm/d/Y' => 'mdy',
|
433 |
+
'd/m/Y' => 'dmy',
|
434 |
+
'd/m/y' => 'dmy',
|
435 |
);
|
436 |
|
437 |
$format = $cake_date_formats[$date_format];
|
438 |
+
|
439 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
440 |
+
$_this->__reset();
|
441 |
+
$_this->check = $check;
|
442 |
+
$_this->regex = $regex;
|
443 |
+
|
444 |
+
if (!is_null($_this->regex)) {
|
445 |
+
return $_this->_check();
|
446 |
+
}
|
447 |
+
|
448 |
+
$regex['dmy'] = '%^(?:(?:31(\\/|-|\\.|\\x20)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(\\/|-|\\.|\\x20)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(\\/|-|\\.|\\x20)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\d|2[0-8])(\\/|-|\\.|\\x20)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$%';
|
449 |
+
$regex['mdy'] = '%^(?:(?:(?:0?[13578]|1[02])(\\/|-|\\.|\\x20)31)\\1|(?:(?:0?[13-9]|1[0-2])(\\/|-|\\.|\\x20)(?:29|30)\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:0?2(\\/|-|\\.|\\x20)29\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\\/|-|\\.|\\x20)(?:0?[1-9]|1\\d|2[0-8])\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$%';
|
450 |
+
$regex['ymd'] = '%^(?:(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.|\\x20)(?:0?2\\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.|\\x20)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]))))$%';
|
451 |
+
$regex['dMy'] = '/^((31(?!\\ (Feb(ruary)?|Apr(il)?|June?|(Sep(?=\\b|t)t?|Nov)(ember)?)))|((30|29)(?!\\ Feb(ruary)?))|(29(?=\\ Feb(ruary)?\\ (((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\\d|2[0-8])\\ (Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)\\ ((1[6-9]|[2-9]\\d)\\d{2})$/';
|
452 |
+
$regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(ember)?)\\ (0?[1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\ ((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/';
|
453 |
+
$regex['My'] = '%^(Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)[ /]((1[6-9]|[2-9]\\d)\\d{2})$%';
|
454 |
+
$regex['my'] = '%^(((0[123456789]|10|11|12)([- /.])(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))))$%';
|
455 |
+
|
456 |
+
$format = (is_array($format)) ? array_values($format) : array($format);
|
457 |
+
foreach ($format as $key) {
|
458 |
+
$_this->regex = $regex[$key];
|
459 |
+
|
460 |
+
if ($_this->_check() === true) {
|
461 |
+
return true;
|
462 |
+
}
|
463 |
+
}
|
464 |
+
return false;
|
465 |
+
}
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Time validation, determines if the string passed is a valid time.
|
469 |
+
* Validates time as 24hr (HH:MM) or am/pm ([H]H:MM[a|p]m)
|
470 |
+
* Does not allow/validate seconds.
|
471 |
+
*
|
472 |
+
* @param string $check a valid time string
|
473 |
+
* @return boolean Success
|
474 |
+
* @access public
|
475 |
+
*/
|
476 |
+
function time($check) {
|
477 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
478 |
+
$_this->__reset();
|
479 |
+
$_this->check = $check;
|
480 |
+
$_this->regex = '%^((0?[1-9]|1[012])(:[0-5]\d){0,2}([AP]M|[ap]m))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$%';
|
481 |
+
return $_this->_check();
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
* Boolean validation, determines if value passed is a boolean integer or true/false.
|
486 |
+
*
|
487 |
+
* @param string $check a valid boolean
|
488 |
+
* @return boolean Success
|
489 |
+
* @access public
|
490 |
+
*/
|
491 |
+
function boolean($check) {
|
492 |
+
$booleanList = array(0, 1, '0', '1', true, false);
|
493 |
+
return in_array($check, $booleanList, true);
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Checks that a value is a valid decimal. If $places is null, the $check is allowed to be a scientific float
|
498 |
+
* If no decimal point is found a false will be returned. Both the sign and exponent are optional.
|
499 |
+
*
|
500 |
+
* @param integer $check The value the test for decimal
|
501 |
+
* @param integer $places if set $check value must have exactly $places after the decimal point
|
502 |
+
* @param string $regex If a custom regular expression is used this is the only validation that will occur.
|
503 |
+
* @return boolean Success
|
504 |
+
* @access public
|
505 |
+
*/
|
506 |
+
function decimal($check, $places = null, $regex = null) {
|
507 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
508 |
+
$_this->__reset();
|
509 |
+
$_this->regex = $regex;
|
510 |
+
$_this->check = $check;
|
511 |
+
|
512 |
+
if (is_null($_this->regex)) {
|
513 |
+
if (is_null($places)) {
|
514 |
+
$_this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?$/';
|
515 |
+
} else {
|
516 |
+
$_this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]{' . $places . '}$/';
|
517 |
+
}
|
518 |
+
}
|
519 |
+
return $_this->_check();
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Validates for an email address.
|
524 |
+
*
|
525 |
+
* @param string $check Value to check
|
526 |
+
* @param boolean $deep Perform a deeper validation (if true), by also checking availability of host
|
527 |
+
* @param string $regex Regex to use (if none it will use built in regex)
|
528 |
+
* @return boolean Success
|
529 |
+
* @access public
|
530 |
+
*/
|
531 |
+
function email($check, $deep = false, $regex = null) {
|
532 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
533 |
+
$_this->__reset();
|
534 |
+
$_this->check = $check;
|
535 |
+
$_this->regex = $regex;
|
536 |
+
$_this->deep = $deep;
|
537 |
+
|
538 |
+
if (is_array($check)) {
|
539 |
+
$_this->_extract($check);
|
540 |
+
}
|
541 |
+
|
542 |
+
if (is_null($_this->regex)) {
|
543 |
+
$_this->regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . $_this->__pattern['hostname'] . '$/i';
|
544 |
+
}
|
545 |
+
$return = $_this->_check();
|
546 |
+
|
547 |
+
if ($_this->deep === false || $_this->deep === null) {
|
548 |
+
return $return;
|
549 |
+
}
|
550 |
+
|
551 |
+
if ($return === true && preg_match('/@(' . $_this->__pattern['hostname'] . ')$/i',
|
552 |
+
$_this->check, $regs)) {
|
553 |
+
if (function_exists('getmxrr') && getmxrr($regs[1], $mxhosts)) {
|
554 |
+
return true;
|
555 |
+
}
|
556 |
+
if (function_exists('checkdnsrr') && checkdnsrr($regs[1], 'MX')) {
|
557 |
+
return true;
|
558 |
+
}
|
559 |
+
return is_array(gethostbynamel($regs[1]));
|
560 |
+
}
|
561 |
+
return false;
|
562 |
+
}
|
563 |
+
|
564 |
+
/**
|
565 |
+
* Check that value is exactly $comparedTo.
|
566 |
+
*
|
567 |
+
* @param mixed $check Value to check
|
568 |
+
* @param mixed $comparedTo Value to compare
|
569 |
+
* @return boolean Success
|
570 |
+
* @access public
|
571 |
+
*/
|
572 |
+
function equalTo($check, $comparedTo) {
|
573 |
+
return ($check === $comparedTo);
|
574 |
+
}
|
575 |
+
|
576 |
+
/**
|
577 |
+
* Check that value has a valid file extension.
|
578 |
+
*
|
579 |
+
* @param mixed $check Value to check
|
580 |
+
* @param array $extensions file extenstions to allow
|
581 |
+
* @return boolean Success
|
582 |
+
* @access public
|
583 |
+
*/
|
584 |
+
function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) {
|
585 |
+
if (is_array($check)) {
|
586 |
+
return Wpcf_Cake_Validation::extension(array_shift($check),
|
587 |
+
$extensions);
|
588 |
+
}
|
589 |
+
$extension = strtolower(array_pop(explode('.', $check)));
|
590 |
+
foreach ($extensions as $value) {
|
591 |
+
if ($extension == strtolower($value)) {
|
592 |
+
return true;
|
593 |
+
}
|
594 |
+
}
|
595 |
+
return false;
|
596 |
+
}
|
597 |
+
|
598 |
+
/**
|
599 |
+
* Validation of an IP address.
|
600 |
+
*
|
601 |
+
* Valid IP version strings for type restriction are:
|
602 |
+
* - both: Check both IPv4 and IPv6, return true if the supplied address matches either version
|
603 |
+
* - IPv4: Version 4 (Eg: 127.0.0.1, 192.168.10.123, 203.211.24.8)
|
604 |
+
* - IPv6: Version 6 (Eg: ::1, 2001:0db8::1428:57ab)
|
605 |
+
*
|
606 |
+
* @param string $check The string to test.
|
607 |
+
* @param string $type The IP Version to test against
|
608 |
+
* @return boolean Success
|
609 |
+
* @access public
|
610 |
+
*/
|
611 |
+
function ip($check, $type = 'both') {
|
612 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
613 |
+
$success = false;
|
614 |
+
$type = strtolower($type);
|
615 |
+
if ($type === 'ipv4' || $type === 'both') {
|
616 |
+
$success |= $_this->_ipv4($check);
|
617 |
+
}
|
618 |
+
if ($type === 'ipv6' || $type === 'both') {
|
619 |
+
$success |= $_this->_ipv6($check);
|
620 |
+
}
|
621 |
+
return $success;
|
622 |
+
}
|
623 |
+
|
624 |
+
/**
|
625 |
+
* Validation of IPv4 addresses.
|
626 |
+
*
|
627 |
+
* @param string $check IP Address to test
|
628 |
+
* @return boolean Success
|
629 |
+
* @access protected
|
630 |
+
*/
|
631 |
+
function _ipv4($check) {
|
632 |
+
if (function_exists('filter_var')) {
|
633 |
+
return filter_var($check, FILTER_VALIDATE_IP,
|
634 |
+
array('flags' => FILTER_FLAG_IPV4)) !== false;
|
635 |
+
}
|
636 |
+
$this->__populateIp();
|
637 |
+
$this->check = $check;
|
638 |
+
$this->regex = '/^' . $this->__pattern['IPv4'] . '$/';
|
639 |
+
return $this->_check();
|
640 |
+
}
|
641 |
+
|
642 |
+
/**
|
643 |
+
* Validation of IPv6 addresses.
|
644 |
+
*
|
645 |
+
* @param string $check IP Address to test
|
646 |
+
* @return boolean Success
|
647 |
+
* @access protected
|
648 |
+
*/
|
649 |
+
function _ipv6($check) {
|
650 |
+
if (function_exists('filter_var')) {
|
651 |
+
return filter_var($check, FILTER_VALIDATE_IP,
|
652 |
+
array('flags' => FILTER_FLAG_IPV6)) !== false;
|
653 |
+
}
|
654 |
+
$this->__populateIp();
|
655 |
+
$this->check = $check;
|
656 |
+
$this->regex = '/^' . $this->__pattern['IPv6'] . '$/';
|
657 |
+
return $this->_check();
|
658 |
+
}
|
659 |
+
|
660 |
+
/**
|
661 |
+
* Checks whether the length of a string is greater or equal to a minimal length.
|
662 |
+
*
|
663 |
+
* @param string $check The string to test
|
664 |
+
* @param integer $min The minimal string length
|
665 |
+
* @return boolean Success
|
666 |
+
* @access public
|
667 |
+
*/
|
668 |
+
function minLength($check, $min) {
|
669 |
+
$length = strlen($check);
|
670 |
+
return ($length >= $min);
|
671 |
+
}
|
672 |
+
|
673 |
+
/**
|
674 |
+
* Checks whether the length of a string is smaller or equal to a maximal length..
|
675 |
+
*
|
676 |
+
* @param string $check The string to test
|
677 |
+
* @param integer $max The maximal string length
|
678 |
+
* @return boolean Success
|
679 |
+
* @access public
|
680 |
+
*/
|
681 |
+
function maxLength($check, $max) {
|
682 |
+
$length = strlen($check);
|
683 |
+
return ($length <= $max);
|
684 |
+
}
|
685 |
+
|
686 |
+
/**
|
687 |
+
* Checks that a value is a monetary amount.
|
688 |
+
*
|
689 |
+
* @param string $check Value to check
|
690 |
+
* @param string $symbolPosition Where symbol is located (left/right)
|
691 |
+
* @return boolean Success
|
692 |
+
* @access public
|
693 |
+
*/
|
694 |
+
function money($check, $symbolPosition = 'left') {
|
695 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
696 |
+
$_this->check = $check;
|
697 |
+
|
698 |
+
if ($symbolPosition == 'right') {
|
699 |
+
$_this->regex = '/^(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?(?<!\x{00a2})\p{Sc}?$/u';
|
700 |
+
} else {
|
701 |
+
$_this->regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u';
|
702 |
+
}
|
703 |
+
return $_this->_check();
|
704 |
+
}
|
705 |
+
|
706 |
+
/**
|
707 |
+
* Validate a multiple select.
|
708 |
+
*
|
709 |
+
* Valid Options
|
710 |
+
*
|
711 |
+
* - in => provide a list of choices that selections must be made from
|
712 |
+
* - max => maximun number of non-zero choices that can be made
|
713 |
+
* - min => minimum number of non-zero choices that can be made
|
714 |
+
*
|
715 |
+
* @param mixed $check Value to check
|
716 |
+
* @param mixed $options Options for the check.
|
717 |
+
* @return boolean Success
|
718 |
+
* @access public
|
719 |
+
*/
|
720 |
+
function multiple($check, $options = array()) {
|
721 |
+
$defaults = array('in' => null, 'max' => null, 'min' => null);
|
722 |
+
$options = array_merge($defaults, $options);
|
723 |
+
$check = array_filter((array) $check);
|
724 |
+
if (empty($check)) {
|
725 |
+
return false;
|
726 |
+
}
|
727 |
+
if ($options['max'] && count($check) > $options['max']) {
|
728 |
+
return false;
|
729 |
+
}
|
730 |
+
if ($options['min'] && count($check) < $options['min']) {
|
731 |
+
return false;
|
732 |
+
}
|
733 |
+
if ($options['in'] && is_array($options['in'])) {
|
734 |
+
foreach ($check as $val) {
|
735 |
+
if (!in_array($val, $options['in'])) {
|
736 |
+
return false;
|
737 |
+
}
|
738 |
+
}
|
739 |
+
}
|
740 |
+
return true;
|
741 |
+
}
|
742 |
+
|
743 |
+
/**
|
744 |
+
* Checks if a value is numeric.
|
745 |
+
*
|
746 |
+
* @param string $check Value to check
|
747 |
+
* @return boolean Succcess
|
748 |
+
* @access public
|
749 |
+
*/
|
750 |
+
function numeric($check) {
|
751 |
+
return is_numeric($check);
|
752 |
+
}
|
753 |
+
|
754 |
+
/**
|
755 |
+
* Check that a value is a valid phone number.
|
756 |
+
*
|
757 |
+
* @param mixed $check Value to check (string or array)
|
758 |
+
* @param string $regex Regular expression to use
|
759 |
+
* @param string $country Country code (defaults to 'all')
|
760 |
+
* @return boolean Success
|
761 |
+
* @access public
|
762 |
+
*/
|
763 |
+
function phone($check, $regex = null, $country = 'all') {
|
764 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
765 |
+
$_this->check = $check;
|
766 |
+
$_this->regex = $regex;
|
767 |
+
$_this->country = $country;
|
768 |
+
if (is_array($check)) {
|
769 |
+
$_this->_extract($check);
|
770 |
+
}
|
771 |
+
|
772 |
+
if (is_null($_this->regex)) {
|
773 |
+
switch ($_this->country) {
|
774 |
+
case 'us':
|
775 |
+
case 'all':
|
776 |
+
case 'can':
|
777 |
+
// includes all NANPA members. see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
|
778 |
+
$_this->regex = '/^(?:\+?1)?[-. ]?\\(?[2-9][0-8][0-9]\\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/';
|
779 |
+
break;
|
780 |
+
}
|
781 |
+
}
|
782 |
+
if (empty($_this->regex)) {
|
783 |
+
return $_this->_pass('phone', $check, $country);
|
784 |
+
}
|
785 |
+
return $_this->_check();
|
786 |
+
}
|
787 |
+
|
788 |
+
/**
|
789 |
+
* Checks that a given value is a valid postal code.
|
790 |
+
*
|
791 |
+
* @param mixed $check Value to check
|
792 |
+
* @param string $regex Regular expression to use
|
793 |
+
* @param string $country Country to use for formatting
|
794 |
+
* @return boolean Success
|
795 |
+
* @access public
|
796 |
+
*/
|
797 |
+
function postal($check, $regex = null, $country = null) {
|
798 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
799 |
+
$_this->check = $check;
|
800 |
+
$_this->regex = $regex;
|
801 |
+
$_this->country = $country;
|
802 |
+
if (is_array($check)) {
|
803 |
+
$_this->_extract($check);
|
804 |
+
}
|
805 |
+
if (empty($country)) {
|
806 |
+
$_this->country = 'us';
|
807 |
+
}
|
808 |
+
|
809 |
+
if (is_null($_this->regex)) {
|
810 |
+
switch ($_this->country) {
|
811 |
+
case 'uk':
|
812 |
+
$_this->regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
|
813 |
+
break;
|
814 |
+
case 'ca':
|
815 |
+
$_this->regex = '/\\A\\b[ABCEGHJKLMNPRSTVXY][0-9][A-Z] ?[0-9][A-Z][0-9]\\b\\z/i';
|
816 |
+
break;
|
817 |
+
case 'it':
|
818 |
+
case 'de':
|
819 |
+
$_this->regex = '/^[0-9]{5}$/i';
|
820 |
+
break;
|
821 |
+
case 'be':
|
822 |
+
$_this->regex = '/^[1-9]{1}[0-9]{3}$/i';
|
823 |
+
break;
|
824 |
+
case 'us':
|
825 |
+
$_this->regex = '/\\A\\b[0-9]{5}(?:-[0-9]{4})?\\b\\z/i';
|
826 |
+
break;
|
827 |
+
}
|
828 |
+
}
|
829 |
+
if (empty($_this->regex)) {
|
830 |
+
return $_this->_pass('postal', $check, $country);
|
831 |
+
}
|
832 |
+
return $_this->_check();
|
833 |
+
}
|
834 |
+
|
835 |
+
/**
|
836 |
+
* Validate that a number is in specified range.
|
837 |
+
* if $lower and $upper are not set, will return true if
|
838 |
+
* $check is a legal finite on this platform
|
839 |
+
*
|
840 |
+
* @param string $check Value to check
|
841 |
+
* @param integer $lower Lower limit
|
842 |
+
* @param integer $upper Upper limit
|
843 |
+
* @return boolean Success
|
844 |
+
* @access public
|
845 |
+
*/
|
846 |
+
function range($check, $lower = null, $upper = null) {
|
847 |
+
if (!is_numeric($check)) {
|
848 |
+
return false;
|
849 |
+
}
|
850 |
+
if (isset($lower) && isset($upper)) {
|
851 |
+
return ($check > $lower && $check < $upper);
|
852 |
+
}
|
853 |
+
return is_finite($check);
|
854 |
+
}
|
855 |
+
|
856 |
+
/**
|
857 |
+
* Checks that a value is a valid Social Security Number.
|
858 |
+
*
|
859 |
+
* @param mixed $check Value to check
|
860 |
+
* @param string $regex Regular expression to use
|
861 |
+
* @param string $country Country
|
862 |
+
* @return boolean Success
|
863 |
+
* @access public
|
864 |
+
*/
|
865 |
+
function ssn($check, $regex = null, $country = null) {
|
866 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
867 |
+
$_this->check = $check;
|
868 |
+
$_this->regex = $regex;
|
869 |
+
$_this->country = $country;
|
870 |
+
if (is_array($check)) {
|
871 |
+
$_this->_extract($check);
|
872 |
+
}
|
873 |
+
|
874 |
+
if (is_null($_this->regex)) {
|
875 |
+
switch ($_this->country) {
|
876 |
+
case 'dk':
|
877 |
+
$_this->regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i';
|
878 |
+
break;
|
879 |
+
case 'nl':
|
880 |
+
$_this->regex = '/\\A\\b[0-9]{9}\\b\\z/i';
|
881 |
+
break;
|
882 |
+
case 'us':
|
883 |
+
$_this->regex = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i';
|
884 |
+
break;
|
885 |
+
}
|
886 |
+
}
|
887 |
+
if (empty($_this->regex)) {
|
888 |
+
return $_this->_pass('ssn', $check, $country);
|
889 |
+
}
|
890 |
+
return $_this->_check();
|
891 |
+
}
|
892 |
+
|
893 |
+
/**
|
894 |
+
* Checks that a value is a valid uuid - http://tools.ietf.org/html/rfc4122
|
895 |
+
*
|
896 |
+
* @param string $check Value to check
|
897 |
+
* @return boolean Success
|
898 |
+
* @access public
|
899 |
+
*/
|
900 |
+
function uuid($check) {
|
901 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
902 |
+
$_this->check = $check;
|
903 |
+
$_this->regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i';
|
904 |
+
return $_this->_check();
|
905 |
+
}
|
906 |
+
|
907 |
+
/**
|
908 |
+
* Checks that a value is a valid URL according to http://www.w3.org/Addressing/URL/url-spec.txt
|
909 |
+
*
|
910 |
+
* The regex checks for the following component parts:
|
911 |
+
*
|
912 |
+
* - a valid, optional, scheme
|
913 |
+
* - a valid ip address OR
|
914 |
+
* a valid domain name as defined by section 2.3.1 of http://www.ietf.org/rfc/rfc1035.txt
|
915 |
+
* with an optional port number
|
916 |
+
* - an optional valid path
|
917 |
+
* - an optional query string (get parameters)
|
918 |
+
* - an optional fragment (anchor tag)
|
919 |
+
*
|
920 |
+
* @param string $check Value to check
|
921 |
+
* @param boolean $strict Require URL to be prefixed by a valid scheme (one of http(s)/ftp(s)/file/news/gopher)
|
922 |
+
* @return boolean Success
|
923 |
+
* @access public
|
924 |
+
*/
|
925 |
+
function url($check, $strict = false) {
|
926 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
927 |
+
$_this->__populateIp();
|
928 |
+
$_this->check = $check;
|
929 |
+
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))';
|
930 |
+
$_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
|
931 |
+
'(?:' . $_this->__pattern['IPv4'] . '|\[' . $_this->__pattern['IPv6'] . '\]|' . $_this->__pattern['hostname'] . ')' .
|
932 |
+
'(?::[1-9][0-9]{0,4})?' .
|
933 |
+
'(?:\/?|\/' . $validChars . '*)?' .
|
934 |
+
'(?:\?' . $validChars . '*)?' .
|
935 |
+
'(?:#' . $validChars . '*)?$/iu';
|
936 |
+
return $_this->_check();
|
937 |
+
}
|
938 |
+
|
939 |
+
/**
|
940 |
+
* Checks if a value is in a given list.
|
941 |
+
*
|
942 |
+
* @param string $check Value to check
|
943 |
+
* @param array $list List to check against
|
944 |
+
* @return boolean Succcess
|
945 |
+
* @access public
|
946 |
+
*/
|
947 |
+
function inList($check, $list) {
|
948 |
+
return in_array($check, $list);
|
949 |
+
}
|
950 |
+
|
951 |
+
/**
|
952 |
+
* Runs an user-defined validation.
|
953 |
+
*
|
954 |
+
* @param mixed $check value that will be validated in user-defined methods.
|
955 |
+
* @param object $object class that holds validation method
|
956 |
+
* @param string $method class method name for validation to run
|
957 |
+
* @param array $args arguments to send to method
|
958 |
+
* @return mixed user-defined class class method returns
|
959 |
+
* @access public
|
960 |
+
*/
|
961 |
+
function userDefined($check, $object, $method, $args = null) {
|
962 |
+
return call_user_func_array(array(&$object, $method),
|
963 |
+
array($check, $args));
|
964 |
+
}
|
965 |
+
|
966 |
+
function noSpecialChars($check) {
|
967 |
+
return preg_match('#[^a-zA-Z0-9\s\_\-]#', $check) ? false : true;
|
968 |
+
}
|
969 |
+
|
970 |
+
function rewriteSlug($check) {
|
971 |
+
return preg_match('#[^a-zA-Z0-9\s\_\-\%]#', $check) ? false : true;
|
972 |
+
}
|
973 |
+
|
974 |
+
/**
|
975 |
+
* Attempts to pass unhandled Validation locales to a class starting with $classPrefix
|
976 |
+
* and ending with Validation. For example $classPrefix = 'nl', the class would be
|
977 |
+
* `NlValidation`.
|
978 |
+
*
|
979 |
+
* @param string $method The method to call on the other class.
|
980 |
+
* @param mixed $check The value to check or an array of parameters for the method to be called.
|
981 |
+
* @param string $classPrefix The prefix for the class to do the validation.
|
982 |
+
* @return mixed Return of Passed method, false on failure
|
983 |
+
* @access protected
|
984 |
+
* */
|
985 |
+
function _pass($method, $check, $classPrefix) {
|
986 |
+
$className = ucwords($classPrefix) . 'Validation';
|
987 |
+
if (!class_exists($className)) {
|
988 |
+
trigger_error(sprintf(__('Could not find %s class, unable to complete validation.',
|
989 |
+
true), $className), E_USER_WARNING);
|
990 |
+
return false;
|
991 |
+
}
|
992 |
+
if (!is_callable(array($className, $method))) {
|
993 |
+
trigger_error(sprintf(__('Method %s does not exist on %s unable to complete validation.',
|
994 |
+
true), $method, $className), E_USER_WARNING);
|
995 |
+
return false;
|
996 |
+
}
|
997 |
+
$check = (array) $check;
|
998 |
+
return call_user_func_array(array($className, $method), $check);
|
999 |
+
}
|
1000 |
+
|
1001 |
+
/**
|
1002 |
+
* Runs a regular expression match.
|
1003 |
+
*
|
1004 |
+
* @return boolean Success of match
|
1005 |
+
* @access protected
|
1006 |
+
*/
|
1007 |
+
function _check() {
|
1008 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
1009 |
+
if (preg_match($_this->regex, $_this->check)) {
|
1010 |
+
$_this->error[] = false;
|
1011 |
+
return true;
|
1012 |
+
} else {
|
1013 |
+
$_this->error[] = true;
|
1014 |
+
return false;
|
1015 |
+
}
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
/**
|
1019 |
+
* Get the values to use when value sent to validation method is
|
1020 |
+
* an array.
|
1021 |
+
*
|
1022 |
+
* @param array $params Parameters sent to validation method
|
1023 |
+
* @return void
|
1024 |
+
* @access protected
|
1025 |
+
*/
|
1026 |
+
function _extract($params) {
|
1027 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
1028 |
+
extract($params, EXTR_OVERWRITE);
|
1029 |
+
|
1030 |
+
if (isset($check)) {
|
1031 |
+
$_this->check = $check;
|
1032 |
+
}
|
1033 |
+
if (isset($regex)) {
|
1034 |
+
$_this->regex = $regex;
|
1035 |
+
}
|
1036 |
+
if (isset($country)) {
|
1037 |
+
$_this->country = strtolower($country);
|
1038 |
+
}
|
1039 |
+
if (isset($deep)) {
|
1040 |
+
$_this->deep = $deep;
|
1041 |
+
}
|
1042 |
+
if (isset($type)) {
|
1043 |
+
$_this->type = $type;
|
1044 |
+
}
|
1045 |
+
}
|
1046 |
+
|
1047 |
+
/**
|
1048 |
+
* Luhn algorithm
|
1049 |
+
*
|
1050 |
+
* @see http://en.wikipedia.org/wiki/Luhn_algorithm
|
1051 |
+
* @return boolean Success
|
1052 |
+
* @access protected
|
1053 |
+
*/
|
1054 |
+
function _luhn() {
|
1055 |
+
$_this = & Wpcf_Cake_Validation::getInstance();
|
1056 |
+
if ($_this->deep !== true) {
|
1057 |
+
return true;
|
1058 |
+
}
|
1059 |
+
if ($_this->check == 0) {
|
1060 |
+
return false;
|
1061 |
+
}
|
1062 |
+
$sum = 0;
|
1063 |
+
$length = strlen($_this->check);
|
1064 |
+
|
1065 |
+
for ($position = 1 - ($length % 2); $position < $length; $position += 2) {
|
1066 |
+
$sum += $_this->check[$position];
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
for ($position = ($length % 2); $position < $length; $position += 2) {
|
1070 |
+
$number = $_this->check[$position] * 2;
|
1071 |
+
$sum += ($number < 10) ? $number : $number - 9;
|
1072 |
+
}
|
1073 |
+
|
1074 |
+
return ($sum % 10 == 0);
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
/*
|
1078 |
+
* Lazily popualate the IP address patterns used for validations
|
1079 |
+
*
|
1080 |
+
* @return void
|
1081 |
+
* @access private
|
1082 |
+
*/
|
1083 |
+
|
1084 |
+
function __populateIp() {
|
1085 |
+
if (!isset($this->__pattern['IPv6'])) {
|
1086 |
+
$pattern = '((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}';
|
1087 |
+
$pattern .= '(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})';
|
1088 |
+
$pattern .= '|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})';
|
1089 |
+
$pattern .= '(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)';
|
1090 |
+
$pattern .= '{4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2}))';
|
1091 |
+
$pattern .= '{3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}';
|
1092 |
+
$pattern .= '((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|';
|
1093 |
+
$pattern .= '((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}';
|
1094 |
+
$pattern .= '((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2}))';
|
1095 |
+
$pattern .= '{3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4})';
|
1096 |
+
$pattern .= '{0,4}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)';
|
1097 |
+
$pattern .= '|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]';
|
1098 |
+
$pattern .= '\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4})';
|
1099 |
+
$pattern .= '{1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?';
|
1100 |
+
|
1101 |
+
$this->__pattern['IPv6'] = $pattern;
|
1102 |
+
}
|
1103 |
+
if (!isset($this->__pattern['IPv4'])) {
|
1104 |
+
$pattern = '(?:(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])';
|
1105 |
+
$this->__pattern['IPv4'] = $pattern;
|
1106 |
+
}
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
/**
|
1110 |
+
* Reset internal variables for another validation run.
|
1111 |
+
*
|
1112 |
+
* @return void
|
1113 |
+
* @access private
|
1114 |
+
*/
|
1115 |
+
function __reset() {
|
1116 |
+
$this->check = null;
|
1117 |
+
$this->regex = null;
|
1118 |
+
$this->country = null;
|
1119 |
+
$this->deep = null;
|
1120 |
+
$this->type = null;
|
1121 |
+
$this->error = array();
|
1122 |
+
$this->errors = array();
|
1123 |
+
}
|
1124 |
+
|
1125 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1126 |
}
|
embedded/common/debug/debug-information.php
CHANGED
@@ -3,10 +3,10 @@
|
|
3 |
/**
|
4 |
* produce debug information
|
5 |
*
|
6 |
-
* $HeadURL:
|
7 |
-
* $LastChangedDate: 2014-
|
8 |
-
* $LastChangedRevision:
|
9 |
-
* $LastChangedBy:
|
10 |
*
|
11 |
*/
|
12 |
|
3 |
/**
|
4 |
* produce debug information
|
5 |
*
|
6 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/debug/debug-information.php $
|
7 |
+
* $LastChangedDate: 2014-08-13 03:38:06 +0200 (Wed, 13 Aug 2014) $
|
8 |
+
* $LastChangedRevision: 25892 $
|
9 |
+
* $LastChangedBy: bruce $
|
10 |
*
|
11 |
*/
|
12 |
|
embedded/common/debug/functions_debug_information.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
/**
|
3 |
* produce debug information
|
4 |
*
|
5 |
-
* $HeadURL:
|
6 |
-
* $LastChangedDate:
|
7 |
-
* $LastChangedRevision:
|
8 |
-
* $LastChangedBy:
|
9 |
*
|
10 |
*/
|
11 |
|
@@ -23,7 +23,7 @@ class ICL_Debug_Information
|
|
23 |
if (empty($info)) {
|
24 |
$info = array('core', 'plugins', 'theme', 'extra-debug');
|
25 |
}
|
26 |
-
|
27 |
$output = array();
|
28 |
foreach ($info as $type) {
|
29 |
switch ($type) {
|
@@ -42,17 +42,12 @@ class ICL_Debug_Information
|
|
42 |
}
|
43 |
}
|
44 |
return $output;
|
45 |
-
|
46 |
-
|
47 |
-
/**
|
48 |
-
*
|
49 |
-
* @global object $wpdb
|
50 |
-
*
|
51 |
-
*/
|
52 |
function get_core_info() {
|
53 |
-
|
54 |
global $wpdb;
|
55 |
-
|
56 |
$core = array(
|
57 |
'Wordpress' => array(
|
58 |
'Multisite' => is_multisite() ? 'Yes' : 'No',
|
@@ -82,12 +77,12 @@ class ICL_Debug_Information
|
|
82 |
}
|
83 |
|
84 |
function get_plugins_info() {
|
85 |
-
|
86 |
if ( ! function_exists( 'get_plugins' ) ) {
|
87 |
$admin_includes_path = str_replace( site_url('/', 'admin'), ABSPATH, admin_url('includes/', 'admin') );
|
88 |
require_once $admin_includes_path . 'plugin.php';
|
89 |
}
|
90 |
-
|
91 |
$plugins = get_plugins();
|
92 |
$active_plugins = get_option('active_plugins');
|
93 |
$active_plugins_info = array();
|
@@ -97,7 +92,7 @@ class ICL_Debug_Information
|
|
97 |
$active_plugins_info[$plugin] = $plugins[$plugin];
|
98 |
}
|
99 |
}
|
100 |
-
|
101 |
$mu_plugins = get_mu_plugins();
|
102 |
|
103 |
$dropins = get_dropins();
|
@@ -107,12 +102,12 @@ class ICL_Debug_Information
|
|
107 |
'mu_plugins' => $mu_plugins,
|
108 |
'dropins' => $dropins,
|
109 |
);
|
110 |
-
|
111 |
return $output;
|
112 |
}
|
113 |
-
|
114 |
function get_theme_info() {
|
115 |
-
|
116 |
if ( get_bloginfo( 'version' ) < '3.4' ) {
|
117 |
$current_theme = get_theme_data( get_stylesheet_directory() . '/style.css' );
|
118 |
$theme = $current_theme;
|
@@ -132,33 +127,28 @@ class ICL_Debug_Information
|
|
132 |
'DomainPath' => $current_theme->DomainPath,
|
133 |
);
|
134 |
}
|
135 |
-
|
136 |
return $theme;
|
137 |
}
|
138 |
|
139 |
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
$json_options += JSON_UNESCAPED_UNICODE;
|
160 |
-
}
|
161 |
-
return json_encode($data, $json_options);
|
162 |
-
}
|
163 |
-
|
164 |
}
|
2 |
/**
|
3 |
* produce debug information
|
4 |
*
|
5 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/debug/functions_debug_information.php $
|
6 |
+
* $LastChangedDate: 2014-08-12 17:40:07 +0200 (Tue, 12 Aug 2014) $
|
7 |
+
* $LastChangedRevision: 25886 $
|
8 |
+
* $LastChangedBy: marcin $
|
9 |
*
|
10 |
*/
|
11 |
|
23 |
if (empty($info)) {
|
24 |
$info = array('core', 'plugins', 'theme', 'extra-debug');
|
25 |
}
|
26 |
+
|
27 |
$output = array();
|
28 |
foreach ($info as $type) {
|
29 |
switch ($type) {
|
42 |
}
|
43 |
}
|
44 |
return $output;
|
45 |
+
}
|
46 |
+
|
|
|
|
|
|
|
|
|
|
|
47 |
function get_core_info() {
|
48 |
+
|
49 |
global $wpdb;
|
50 |
+
|
51 |
$core = array(
|
52 |
'Wordpress' => array(
|
53 |
'Multisite' => is_multisite() ? 'Yes' : 'No',
|
77 |
}
|
78 |
|
79 |
function get_plugins_info() {
|
80 |
+
|
81 |
if ( ! function_exists( 'get_plugins' ) ) {
|
82 |
$admin_includes_path = str_replace( site_url('/', 'admin'), ABSPATH, admin_url('includes/', 'admin') );
|
83 |
require_once $admin_includes_path . 'plugin.php';
|
84 |
}
|
85 |
+
|
86 |
$plugins = get_plugins();
|
87 |
$active_plugins = get_option('active_plugins');
|
88 |
$active_plugins_info = array();
|
92 |
$active_plugins_info[$plugin] = $plugins[$plugin];
|
93 |
}
|
94 |
}
|
95 |
+
|
96 |
$mu_plugins = get_mu_plugins();
|
97 |
|
98 |
$dropins = get_dropins();
|
102 |
'mu_plugins' => $mu_plugins,
|
103 |
'dropins' => $dropins,
|
104 |
);
|
105 |
+
|
106 |
return $output;
|
107 |
}
|
108 |
+
|
109 |
function get_theme_info() {
|
110 |
+
|
111 |
if ( get_bloginfo( 'version' ) < '3.4' ) {
|
112 |
$current_theme = get_theme_data( get_stylesheet_directory() . '/style.css' );
|
113 |
$theme = $current_theme;
|
127 |
'DomainPath' => $current_theme->DomainPath,
|
128 |
);
|
129 |
}
|
130 |
+
|
131 |
return $theme;
|
132 |
}
|
133 |
|
134 |
|
135 |
+
function do_json_encode($data) {
|
136 |
+
$json_options = 0;
|
137 |
+
if (defined('JSON_HEX_TAG')) {
|
138 |
+
$json_options += JSON_HEX_TAG;
|
139 |
+
}
|
140 |
+
if (defined('JSON_HEX_APOS')) {
|
141 |
+
$json_options += JSON_HEX_APOS;
|
142 |
+
}
|
143 |
+
if (defined('JSON_HEX_QUOT')) {
|
144 |
+
$json_options += JSON_HEX_QUOT;
|
145 |
+
}
|
146 |
+
if (defined('JSON_HEX_AMP')) {
|
147 |
+
$json_options += JSON_HEX_AMP;
|
148 |
+
}
|
149 |
+
if (defined('JSON_UNESCAPED_UNICODE')) {
|
150 |
+
$json_options += JSON_UNESCAPED_UNICODE;
|
151 |
+
}
|
152 |
+
return json_encode($data, $json_options);
|
153 |
+
}
|
|
|
|
|
|
|
|
|
|
|
154 |
}
|
embedded/common/expression-parser/js/parser.js
CHANGED
@@ -1602,14 +1602,14 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
1602 |
if (varTmp != "RAND")
|
1603 |
{
|
1604 |
if (arrArgs.length < 1)
|
1605 |
-
throw varTmp + " requires
|
1606 |
else if (arrArgs.length > 1)
|
1607 |
throw varTmp + " requires only one argument!";
|
1608 |
}
|
1609 |
else
|
1610 |
{
|
1611 |
if (arrArgs.length < 1)
|
1612 |
-
throw varTmp + " requires
|
1613 |
else if (arrArgs.length > 2)
|
1614 |
throw varTmp + " requires at most two arguments!";
|
1615 |
}
|
@@ -1687,7 +1687,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
1687 |
break;
|
1688 |
case "STR" :
|
1689 |
if (arrArgs.length < 1)
|
1690 |
-
throw varTmp + " requires
|
1691 |
else if (arrArgs.length > 2)
|
1692 |
throw varTmp + " requires at most two arguments!";
|
1693 |
varTerm = arrArgs[arrArgs.length-1];
|
@@ -1729,7 +1729,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
1729 |
if (arrArgs.length > 1)
|
1730 |
throw varTmp + " requires only one argument!";
|
1731 |
else if (arrArgs.length < 1)
|
1732 |
-
throw varTmp + " requires
|
1733 |
varTerm = arrArgs[0];
|
1734 |
if (varTerm.isVariable)
|
1735 |
{
|
@@ -1758,7 +1758,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
1758 |
break;
|
1759 |
case "REGEX" :
|
1760 |
if (arrArgs.length < 1)
|
1761 |
-
throw varTmp + " requires
|
1762 |
else if (arrArgs.length > 2)
|
1763 |
throw varTmp + " requires at most two arguments!";
|
1764 |
|
@@ -1798,7 +1798,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
1798 |
case "NUM" :
|
1799 |
|
1800 |
if (arrArgs.length < 1)
|
1801 |
-
throw varTmp + " requires
|
1802 |
else if (arrArgs.length > 1)
|
1803 |
throw varTmp + " requires only one argument!";
|
1804 |
|
@@ -1841,7 +1841,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
1841 |
break;
|
1842 |
case "LEN" :
|
1843 |
if (arrArgs.length < 1)
|
1844 |
-
throw varTmp + " requires
|
1845 |
else if (arrArgs.length > 1)
|
1846 |
throw varTmp + " requires only one argument!";
|
1847 |
|
@@ -1864,7 +1864,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
1864 |
break;
|
1865 |
case "USER" :
|
1866 |
if (arrArgs.length < 1)
|
1867 |
-
throw varTmp + " requires
|
1868 |
else if (arrArgs.length > 1)
|
1869 |
throw varTmp + " requires only one argument!";
|
1870 |
|
@@ -1887,7 +1887,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
1887 |
break;
|
1888 |
case "COOKIE" :
|
1889 |
if (arrArgs.length < 1)
|
1890 |
-
throw varTmp + " requires
|
1891 |
else if (arrArgs.length > 1)
|
1892 |
throw varTmp + " requires only one argument!";
|
1893 |
|
@@ -1912,7 +1912,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
1912 |
case "CONTAINS" :
|
1913 |
// console.log( 'testing functions ', varTmp, arrArgs );
|
1914 |
if (arrArgs.length < 2)
|
1915 |
-
throw varTmp + " requires
|
1916 |
else if (arrArgs.length > 2)
|
1917 |
throw varTmp + " requires only two arguments!";
|
1918 |
|
@@ -1955,7 +1955,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
1955 |
break;
|
1956 |
case "DATE" :
|
1957 |
if (arrArgs.length < 2)
|
1958 |
-
throw varTmp + " requires
|
1959 |
else if (arrArgs.length > 2)
|
1960 |
throw varTmp + " requires only two arguments!";
|
1961 |
|
@@ -2030,7 +2030,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
2030 |
case "LEFT" :
|
2031 |
case "RIGHT" :
|
2032 |
if (arrArgs.length < 2)
|
2033 |
-
throw varTmp + " requires
|
2034 |
else if (arrArgs.length > 2)
|
2035 |
throw varTmp + " requires only two arguments!";
|
2036 |
|
@@ -2073,7 +2073,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
2073 |
case "IIF" :
|
2074 |
|
2075 |
if (arrArgs.length < 3)
|
2076 |
-
throw varTmp + " requires
|
2077 |
else if (arrArgs.length > 3)
|
2078 |
throw varTmp + " requires only three arguments!";
|
2079 |
|
@@ -2134,7 +2134,7 @@ window.ToolsetParser=window.ToolsetParser ||
|
|
2134 |
case "MAX" :
|
2135 |
case "MIN" :
|
2136 |
if (arrArgs.length < 1)
|
2137 |
-
throw varTmp + " requires
|
2138 |
|
2139 |
var _arr=[];
|
2140 |
intCntr = arrArgs.length;
|
1602 |
if (varTmp != "RAND")
|
1603 |
{
|
1604 |
if (arrArgs.length < 1)
|
1605 |
+
throw varTmp + " requires atleast one argument!";
|
1606 |
else if (arrArgs.length > 1)
|
1607 |
throw varTmp + " requires only one argument!";
|
1608 |
}
|
1609 |
else
|
1610 |
{
|
1611 |
if (arrArgs.length < 1)
|
1612 |
+
throw varTmp + " requires atleast one argument!";
|
1613 |
else if (arrArgs.length > 2)
|
1614 |
throw varTmp + " requires at most two arguments!";
|
1615 |
}
|
1687 |
break;
|
1688 |
case "STR" :
|
1689 |
if (arrArgs.length < 1)
|
1690 |
+
throw varTmp + " requires atleast one argument!";
|
1691 |
else if (arrArgs.length > 2)
|
1692 |
throw varTmp + " requires at most two arguments!";
|
1693 |
varTerm = arrArgs[arrArgs.length-1];
|
1729 |
if (arrArgs.length > 1)
|
1730 |
throw varTmp + " requires only one argument!";
|
1731 |
else if (arrArgs.length < 1)
|
1732 |
+
throw varTmp + " requires atleast one argument!";
|
1733 |
varTerm = arrArgs[0];
|
1734 |
if (varTerm.isVariable)
|
1735 |
{
|
1758 |
break;
|
1759 |
case "REGEX" :
|
1760 |
if (arrArgs.length < 1)
|
1761 |
+
throw varTmp + " requires atleast one argument!";
|
1762 |
else if (arrArgs.length > 2)
|
1763 |
throw varTmp + " requires at most two arguments!";
|
1764 |
|
1798 |
case "NUM" :
|
1799 |
|
1800 |
if (arrArgs.length < 1)
|
1801 |
+
throw varTmp + " requires atleast one argument!";
|
1802 |
else if (arrArgs.length > 1)
|
1803 |
throw varTmp + " requires only one argument!";
|
1804 |
|
1841 |
break;
|
1842 |
case "LEN" :
|
1843 |
if (arrArgs.length < 1)
|
1844 |
+
throw varTmp + " requires atleast one argument!";
|
1845 |
else if (arrArgs.length > 1)
|
1846 |
throw varTmp + " requires only one argument!";
|
1847 |
|
1864 |
break;
|
1865 |
case "USER" :
|
1866 |
if (arrArgs.length < 1)
|
1867 |
+
throw varTmp + " requires atleast one argument!";
|
1868 |
else if (arrArgs.length > 1)
|
1869 |
throw varTmp + " requires only one argument!";
|
1870 |
|
1887 |
break;
|
1888 |
case "COOKIE" :
|
1889 |
if (arrArgs.length < 1)
|
1890 |
+
throw varTmp + " requires atleast one argument!";
|
1891 |
else if (arrArgs.length > 1)
|
1892 |
throw varTmp + " requires only one argument!";
|
1893 |
|
1912 |
case "CONTAINS" :
|
1913 |
// console.log( 'testing functions ', varTmp, arrArgs );
|
1914 |
if (arrArgs.length < 2)
|
1915 |
+
throw varTmp + " requires atleast two arguments!";
|
1916 |
else if (arrArgs.length > 2)
|
1917 |
throw varTmp + " requires only two arguments!";
|
1918 |
|
1955 |
break;
|
1956 |
case "DATE" :
|
1957 |
if (arrArgs.length < 2)
|
1958 |
+
throw varTmp + " requires atleast two arguments!";
|
1959 |
else if (arrArgs.length > 2)
|
1960 |
throw varTmp + " requires only two arguments!";
|
1961 |
|
2030 |
case "LEFT" :
|
2031 |
case "RIGHT" :
|
2032 |
if (arrArgs.length < 2)
|
2033 |
+
throw varTmp + " requires atleast two arguments!";
|
2034 |
else if (arrArgs.length > 2)
|
2035 |
throw varTmp + " requires only two arguments!";
|
2036 |
|
2073 |
case "IIF" :
|
2074 |
|
2075 |
if (arrArgs.length < 3)
|
2076 |
+
throw varTmp + " requires atleast three arguments!";
|
2077 |
else if (arrArgs.length > 3)
|
2078 |
throw varTmp + " requires only three arguments!";
|
2079 |
|
2134 |
case "MAX" :
|
2135 |
case "MIN" :
|
2136 |
if (arrArgs.length < 1)
|
2137 |
+
throw varTmp + " requires atleast one operand!";
|
2138 |
|
2139 |
var _arr=[];
|
2140 |
intCntr = arrArgs.length;
|
embedded/common/expression-parser/parser.php
CHANGED
@@ -1639,14 +1639,14 @@ class Toolset_Parser
|
|
1639 |
if ($varTmp != "RAND")
|
1640 |
{
|
1641 |
if (count($arrArgs) < 1)
|
1642 |
-
throw new Exception($varTmp . " requires
|
1643 |
else if (count($arrArgs) > 1)
|
1644 |
throw new Exception($varTmp . " requires only one argument!");
|
1645 |
}
|
1646 |
else
|
1647 |
{
|
1648 |
if (count($arrArgs) < 1)
|
1649 |
-
throw new Exception($varTmp . " requires
|
1650 |
else if (count($arrArgs) > 2)
|
1651 |
throw new Exception($varTmp . " requires at most two arguments!");
|
1652 |
}
|
@@ -1717,7 +1717,7 @@ class Toolset_Parser
|
|
1717 |
break;
|
1718 |
case "STR" :
|
1719 |
if (count($arrArgs) < 1)
|
1720 |
-
throw new Exception($varTmp . " requires
|
1721 |
else if (count($arrArgs) > 2)
|
1722 |
throw new Exception($varTmp . " requires at most two arguments!");
|
1723 |
$varTerm = $arrArgs[count($arrArgs)-1];
|
@@ -1756,7 +1756,7 @@ class Toolset_Parser
|
|
1756 |
if (count($arrArgs) > 1)
|
1757 |
throw new Exception($varTmp . " requires only one argument!");
|
1758 |
else if (count($arrArgs) < 1)
|
1759 |
-
throw new Exception($varTmp . " requires
|
1760 |
$varTerm = $arrArgs[0];
|
1761 |
if ($varTerm->isVariable)
|
1762 |
{
|
@@ -1791,7 +1791,7 @@ class Toolset_Parser
|
|
1791 |
break;
|
1792 |
case "REGEX" :
|
1793 |
if (count($arrArgs) < 1)
|
1794 |
-
throw new Exception($varTmp . " requires
|
1795 |
else if (count($arrArgs) > 2)
|
1796 |
throw new Exception($varTmp . " requires at most two arguments!");
|
1797 |
|
@@ -1828,7 +1828,7 @@ class Toolset_Parser
|
|
1828 |
case "UCASE" :
|
1829 |
case "NUM" :
|
1830 |
if (count($arrArgs) < 1)
|
1831 |
-
throw new Exception($varTmp . " requires
|
1832 |
else if (count($arrArgs) > 1)
|
1833 |
throw new Exception($varTmp . " requires only one argument!");
|
1834 |
|
@@ -1870,7 +1870,7 @@ class Toolset_Parser
|
|
1870 |
break;
|
1871 |
case "LEN" :
|
1872 |
if (count($arrArgs) < 1)
|
1873 |
-
throw new Exception($varTmp . " requires
|
1874 |
else if (count($arrArgs) > 1)
|
1875 |
throw new Exception($varTmp . " requires only one argument!");
|
1876 |
|
@@ -1895,7 +1895,7 @@ class Toolset_Parser
|
|
1895 |
break;
|
1896 |
case "USER" :
|
1897 |
if (count($arrArgs) < 1)
|
1898 |
-
throw new Exception($varTmp . " requires
|
1899 |
else if (count($arrArgs) > 1)
|
1900 |
throw new Exception($varTmp . " requires only one argument!");
|
1901 |
|
@@ -1917,7 +1917,7 @@ class Toolset_Parser
|
|
1917 |
break;
|
1918 |
case "COOKIE" :
|
1919 |
if (count($arrArgs) < 1)
|
1920 |
-
throw new Exception($varTmp . " requires
|
1921 |
else if (count($arrArgs) > 1)
|
1922 |
throw new Exception($varTmp . " requires only one argument!");
|
1923 |
|
@@ -1939,7 +1939,7 @@ class Toolset_Parser
|
|
1939 |
break;
|
1940 |
case "CONTAINS" :
|
1941 |
if (count($arrArgs) < 2)
|
1942 |
-
throw new Exception($varTmp . " requires
|
1943 |
else if (count($arrArgs) > 2)
|
1944 |
throw new Exception($varTmp . " requires only two arguments!");
|
1945 |
|
@@ -1970,7 +1970,7 @@ class Toolset_Parser
|
|
1970 |
break;
|
1971 |
case "DATE" :
|
1972 |
if (count($arrArgs) < 2)
|
1973 |
-
throw new Exception($varTmp . " requires
|
1974 |
else if (count($arrArgs) > 2)
|
1975 |
throw new Exception($varTmp . " requires only two arguments!");
|
1976 |
|
@@ -2010,7 +2010,7 @@ class Toolset_Parser
|
|
2010 |
case "empty" :
|
2011 |
case "EMPTY" :
|
2012 |
if (count($arrArgs) < 1)
|
2013 |
-
throw new Exception($varTmp . " requires
|
2014 |
else if (count($arrArgs) > 1)
|
2015 |
throw new Exception($varTmp . " requires only one arguments!");
|
2016 |
|
@@ -2041,7 +2041,7 @@ class Toolset_Parser
|
|
2041 |
case "LEFT" :
|
2042 |
case "RIGHT" :
|
2043 |
if (count($arrArgs) < 2)
|
2044 |
-
throw new Exception($varTmp . " requires
|
2045 |
else if (count($arrArgs) > 2)
|
2046 |
throw new Exception($varTmp . " requires only two arguments!");
|
2047 |
|
@@ -2082,7 +2082,7 @@ class Toolset_Parser
|
|
2082 |
case "MID" :
|
2083 |
case "IIF" :
|
2084 |
if (count($arrArgs) < 3)
|
2085 |
-
throw new Exception($varTmp . " requires
|
2086 |
else if (count($arrArgs) > 3)
|
2087 |
throw new Exception($varTmp . " requires only three arguments!");
|
2088 |
|
@@ -2132,7 +2132,7 @@ class Toolset_Parser
|
|
2132 |
case "MAX" :
|
2133 |
case "MIN" :
|
2134 |
if (count($arrArgs) < 1)
|
2135 |
-
throw new Exception($varTmp . " requires
|
2136 |
|
2137 |
$_arr=array();
|
2138 |
$intCntr = count($arrArgs);
|
1639 |
if ($varTmp != "RAND")
|
1640 |
{
|
1641 |
if (count($arrArgs) < 1)
|
1642 |
+
throw new Exception($varTmp . " requires atleast one argument!");
|
1643 |
else if (count($arrArgs) > 1)
|
1644 |
throw new Exception($varTmp . " requires only one argument!");
|
1645 |
}
|
1646 |
else
|
1647 |
{
|
1648 |
if (count($arrArgs) < 1)
|
1649 |
+
throw new Exception($varTmp . " requires atleast one argument!");
|
1650 |
else if (count($arrArgs) > 2)
|
1651 |
throw new Exception($varTmp . " requires at most two arguments!");
|
1652 |
}
|
1717 |
break;
|
1718 |
case "STR" :
|
1719 |
if (count($arrArgs) < 1)
|
1720 |
+
throw new Exception($varTmp . " requires atleast one argument!");
|
1721 |
else if (count($arrArgs) > 2)
|
1722 |
throw new Exception($varTmp . " requires at most two arguments!");
|
1723 |
$varTerm = $arrArgs[count($arrArgs)-1];
|
1756 |
if (count($arrArgs) > 1)
|
1757 |
throw new Exception($varTmp . " requires only one argument!");
|
1758 |
else if (count($arrArgs) < 1)
|
1759 |
+
throw new Exception($varTmp . " requires atleast one argument!");
|
1760 |
$varTerm = $arrArgs[0];
|
1761 |
if ($varTerm->isVariable)
|
1762 |
{
|
1791 |
break;
|
1792 |
case "REGEX" :
|
1793 |
if (count($arrArgs) < 1)
|
1794 |
+
throw new Exception($varTmp . " requires atleast one argument!");
|
1795 |
else if (count($arrArgs) > 2)
|
1796 |
throw new Exception($varTmp . " requires at most two arguments!");
|
1797 |
|
1828 |
case "UCASE" :
|
1829 |
case "NUM" :
|
1830 |
if (count($arrArgs) < 1)
|
1831 |
+
throw new Exception($varTmp . " requires atleast one argument!");
|
1832 |
else if (count($arrArgs) > 1)
|
1833 |
throw new Exception($varTmp . " requires only one argument!");
|
1834 |
|
1870 |
break;
|
1871 |
case "LEN" :
|
1872 |
if (count($arrArgs) < 1)
|
1873 |
+
throw new Exception($varTmp . " requires atleast one argument!");
|
1874 |
else if (count($arrArgs) > 1)
|
1875 |
throw new Exception($varTmp . " requires only one argument!");
|
1876 |
|
1895 |
break;
|
1896 |
case "USER" :
|
1897 |
if (count($arrArgs) < 1)
|
1898 |
+
throw new Exception($varTmp . " requires atleast one argument!");
|
1899 |
else if (count($arrArgs) > 1)
|
1900 |
throw new Exception($varTmp . " requires only one argument!");
|
1901 |
|
1917 |
break;
|
1918 |
case "COOKIE" :
|
1919 |
if (count($arrArgs) < 1)
|
1920 |
+
throw new Exception($varTmp . " requires atleast one argument!");
|
1921 |
else if (count($arrArgs) > 1)
|
1922 |
throw new Exception($varTmp . " requires only one argument!");
|
1923 |
|
1939 |
break;
|
1940 |
case "CONTAINS" :
|
1941 |
if (count($arrArgs) < 2)
|
1942 |
+
throw new Exception($varTmp . " requires atleast two arguments!");
|
1943 |
else if (count($arrArgs) > 2)
|
1944 |
throw new Exception($varTmp . " requires only two arguments!");
|
1945 |
|
1970 |
break;
|
1971 |
case "DATE" :
|
1972 |
if (count($arrArgs) < 2)
|
1973 |
+
throw new Exception($varTmp . " requires atleast two arguments!");
|
1974 |
else if (count($arrArgs) > 2)
|
1975 |
throw new Exception($varTmp . " requires only two arguments!");
|
1976 |
|
2010 |
case "empty" :
|
2011 |
case "EMPTY" :
|
2012 |
if (count($arrArgs) < 1)
|
2013 |
+
throw new Exception($varTmp . " requires atleast one argument!");
|
2014 |
else if (count($arrArgs) > 1)
|
2015 |
throw new Exception($varTmp . " requires only one arguments!");
|
2016 |
|
2041 |
case "LEFT" :
|
2042 |
case "RIGHT" :
|
2043 |
if (count($arrArgs) < 2)
|
2044 |
+
throw new Exception($varTmp . " requires atleast two arguments!");
|
2045 |
else if (count($arrArgs) > 2)
|
2046 |
throw new Exception($varTmp . " requires only two arguments!");
|
2047 |
|
2082 |
case "MID" :
|
2083 |
case "IIF" :
|
2084 |
if (count($arrArgs) < 3)
|
2085 |
+
throw new Exception($varTmp . " requires atleast three arguments!");
|
2086 |
else if (count($arrArgs) > 3)
|
2087 |
throw new Exception($varTmp . " requires only three arguments!");
|
2088 |
|
2132 |
case "MAX" :
|
2133 |
case "MIN" :
|
2134 |
if (count($arrArgs) < 1)
|
2135 |
+
throw new Exception($varTmp . " requires atleast one operand!");
|
2136 |
|
2137 |
$_arr=array();
|
2138 |
$intCntr = count($arrArgs);
|
embedded/common/functions.php
CHANGED
@@ -4,15 +4,6 @@
|
|
4 |
*/
|
5 |
define( 'ICL_COMMON_FUNCTIONS', true );
|
6 |
|
7 |
-
// for retro compatibility with WP < 3.5
|
8 |
-
if( !function_exists('wp_normalize_path') ){
|
9 |
-
function wp_normalize_path( $path ) {
|
10 |
-
$path = str_replace( '\\', '/', $path );
|
11 |
-
$path = preg_replace( '|/+|','/', $path );
|
12 |
-
return $path;
|
13 |
-
}
|
14 |
-
}
|
15 |
-
|
16 |
/**
|
17 |
* Calculates relative path for given file.
|
18 |
*
|
@@ -20,28 +11,24 @@ if( !function_exists('wp_normalize_path') ){
|
|
20 |
* @return string Relative path
|
21 |
*/
|
22 |
function icl_get_file_relpath( $file ) {
|
23 |
-
|
24 |
-
$
|
25 |
-
|
26 |
-
$
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
$
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
// build url
|
43 |
-
$relpath = $base_root . '/' . $path;
|
44 |
-
|
45 |
return $relpath;
|
46 |
}
|
47 |
|
@@ -149,8 +136,6 @@ function wpv_condition( $atts, $post_to_check = null ) {
|
|
149 |
|
150 |
add_filter( 'wpv-extra-condition-filters', 'wpv_add_time_functions' );
|
151 |
$evaluate = apply_filters( 'wpv-extra-condition-filters', $evaluate );
|
152 |
-
|
153 |
-
$logging_string .= "; After extra conditions: " . $evaluate;
|
154 |
|
155 |
// evaluate empty() statements for variables
|
156 |
if ( $has_post ) {
|
@@ -167,8 +152,8 @@ function wpv_condition( $atts, $post_to_check = null ) {
|
|
167 |
|| ( is_array( $match_var ) && empty( $match_var ) ) ) {
|
168 |
$is_empty = '1=1';
|
169 |
}
|
|
|
170 |
$evaluate = str_replace( $matches[0][$i], $is_empty, $evaluate );
|
171 |
-
$logging_string .= "; After empty: " . $evaluate;
|
172 |
}
|
173 |
}
|
174 |
}
|
@@ -187,9 +172,10 @@ function wpv_condition( $atts, $post_to_check = null ) {
|
|
187 |
if ( strpos( $string, '$' ) === 0 ) {
|
188 |
$variable_name = substr( $string, 1 ); // omit dollar sign
|
189 |
if ( isset( $atts[$variable_name] ) ) {
|
190 |
-
$string = get_post_meta( $post->ID, $atts[$variable_name],
|
191 |
-
|
192 |
-
$
|
|
|
193 |
}
|
194 |
}
|
195 |
}
|
@@ -247,10 +233,11 @@ function wpv_condition( $atts, $post_to_check = null ) {
|
|
247 |
$evaluate = str_replace( $matches[0][$i], '1=0', $evaluate );
|
248 |
}
|
249 |
} else {
|
250 |
-
$evaluate = str_replace( $matches[1][$i], $first_string,
|
251 |
-
|
|
|
|
|
252 |
}
|
253 |
-
$logging_string .= "; After variables II: " . $evaluate;
|
254 |
}
|
255 |
}
|
256 |
|
@@ -261,10 +248,10 @@ function wpv_condition( $atts, $post_to_check = null ) {
|
|
261 |
for ( $i = 0; $i < $strings_count; $i++ ) {
|
262 |
$string = $matches[1][$i];
|
263 |
// remove single quotes from string literals to get value only
|
264 |
-
$string = (strpos( $string, '\'' ) === 0) ? substr( $string, 1,
|
|
|
265 |
if ( is_numeric( $string ) ) {
|
266 |
$evaluate = str_replace( $matches[1][$i], $string, $evaluate );
|
267 |
-
$logging_string .= "; After variables III: " . $evaluate;
|
268 |
}
|
269 |
}
|
270 |
}
|
@@ -292,7 +279,6 @@ function wpv_condition( $atts, $post_to_check = null ) {
|
|
292 |
$meta = "0";
|
293 |
}
|
294 |
$evaluate = str_replace( '$' . $match, $meta, $evaluate );
|
295 |
-
$logging_string .= "; After variables IV: " . $evaluate;
|
296 |
}
|
297 |
}
|
298 |
}
|
@@ -488,7 +474,7 @@ class WPV_wpcf_switch_post_from_attr_id
|
|
488 |
$this->found = true;
|
489 |
|
490 |
// save original post
|
491 |
-
$this->post =
|
492 |
if ( $authordata ) {
|
493 |
$this->authordata = clone $authordata;
|
494 |
} else {
|
@@ -510,7 +496,7 @@ class WPV_wpcf_switch_post_from_attr_id
|
|
510 |
global $post, $authordata, $id;
|
511 |
|
512 |
// restore the global post values.
|
513 |
-
$post =
|
514 |
if ( $this->authordata ) {
|
515 |
$authordata = clone $this->authordata;
|
516 |
} else {
|
@@ -616,3 +602,70 @@ function wpv_dismiss_message_ajax() {
|
|
616 |
die( 'ajax' );
|
617 |
}
|
618 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
*/
|
5 |
define( 'ICL_COMMON_FUNCTIONS', true );
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
/**
|
8 |
* Calculates relative path for given file.
|
9 |
*
|
11 |
* @return string Relative path
|
12 |
*/
|
13 |
function icl_get_file_relpath( $file ) {
|
14 |
+
$is_https = isset( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) == 'on';
|
15 |
+
$http_protocol = $is_https ? 'https' : 'http';
|
16 |
+
$base_root = $http_protocol . '://' . $_SERVER['HTTP_HOST'];
|
17 |
+
$base_url = $base_root;
|
18 |
+
$dir = rtrim( dirname( $file ), '\/' );
|
19 |
+
if ( $dir ) {
|
20 |
+
$base_path = $dir;
|
21 |
+
$base_url .= $base_path;
|
22 |
+
$base_path .= '/';
|
23 |
+
} else {
|
24 |
+
$base_path = '/';
|
25 |
+
}
|
26 |
+
$relpath = $base_root
|
27 |
+
. str_replace(
|
28 |
+
str_replace( '\\', '/',
|
29 |
+
realpath( $_SERVER['DOCUMENT_ROOT'] ) )
|
30 |
+
, '', str_replace( '\\', '/', dirname( $file ) )
|
31 |
+
);
|
|
|
|
|
|
|
|
|
32 |
return $relpath;
|
33 |
}
|
34 |
|
136 |
|
137 |
add_filter( 'wpv-extra-condition-filters', 'wpv_add_time_functions' );
|
138 |
$evaluate = apply_filters( 'wpv-extra-condition-filters', $evaluate );
|
|
|
|
|
139 |
|
140 |
// evaluate empty() statements for variables
|
141 |
if ( $has_post ) {
|
152 |
|| ( is_array( $match_var ) && empty( $match_var ) ) ) {
|
153 |
$is_empty = '1=1';
|
154 |
}
|
155 |
+
|
156 |
$evaluate = str_replace( $matches[0][$i], $is_empty, $evaluate );
|
|
|
157 |
}
|
158 |
}
|
159 |
}
|
172 |
if ( strpos( $string, '$' ) === 0 ) {
|
173 |
$variable_name = substr( $string, 1 ); // omit dollar sign
|
174 |
if ( isset( $atts[$variable_name] ) ) {
|
175 |
+
$string = get_post_meta( $post->ID, $atts[$variable_name],
|
176 |
+
true );
|
177 |
+
$evaluate = str_replace( $matches[1][$i],
|
178 |
+
"'" . $string . "'", $evaluate );
|
179 |
}
|
180 |
}
|
181 |
}
|
233 |
$evaluate = str_replace( $matches[0][$i], '1=0', $evaluate );
|
234 |
}
|
235 |
} else {
|
236 |
+
$evaluate = str_replace( $matches[1][$i], $first_string,
|
237 |
+
$evaluate );
|
238 |
+
$evaluate = str_replace( $matches[5][$i], $second_string,
|
239 |
+
$evaluate );
|
240 |
}
|
|
|
241 |
}
|
242 |
}
|
243 |
|
248 |
for ( $i = 0; $i < $strings_count; $i++ ) {
|
249 |
$string = $matches[1][$i];
|
250 |
// remove single quotes from string literals to get value only
|
251 |
+
$string = (strpos( $string, '\'' ) === 0) ? substr( $string, 1,
|
252 |
+
strlen( $string ) - 2 ) : $string;
|
253 |
if ( is_numeric( $string ) ) {
|
254 |
$evaluate = str_replace( $matches[1][$i], $string, $evaluate );
|
|
|
255 |
}
|
256 |
}
|
257 |
}
|
279 |
$meta = "0";
|
280 |
}
|
281 |
$evaluate = str_replace( '$' . $match, $meta, $evaluate );
|
|
|
282 |
}
|
283 |
}
|
284 |
}
|
474 |
$this->found = true;
|
475 |
|
476 |
// save original post
|
477 |
+
$this->post = isset( $post ) ? clone $post : null;
|
478 |
if ( $authordata ) {
|
479 |
$this->authordata = clone $authordata;
|
480 |
} else {
|
496 |
global $post, $authordata, $id;
|
497 |
|
498 |
// restore the global post values.
|
499 |
+
$post = isset( $this->post ) ? clone $this->post : null;
|
500 |
if ( $this->authordata ) {
|
501 |
$authordata = clone $this->authordata;
|
502 |
} else {
|
602 |
die( 'ajax' );
|
603 |
}
|
604 |
|
605 |
+
// disable the admin messages for now. They are causing problems.
|
606 |
+
//add_action('admin_head', 'wpv_show_admin_messages');
|
607 |
+
|
608 |
+
/**
|
609 |
+
* Shows stored admin messages.
|
610 |
+
*/
|
611 |
+
function wpv_show_admin_messages() {
|
612 |
+
$messages = get_option( 'wpv-messages', array() );
|
613 |
+
$dismissed_messages = get_option( 'wpv-dismissed-messages', array() );
|
614 |
+
foreach ( $messages as $message_id => $message ) {
|
615 |
+
if ( array_key_exists( $message_id, $dismissed_messages ) ) {
|
616 |
+
unset( $messages[$message_id] );
|
617 |
+
continue;
|
618 |
+
}
|
619 |
+
// update the nonce
|
620 |
+
$text = $message['message'];
|
621 |
+
$nonce = preg_match_all( "/_wpnonce=[^']+/", $text, $matches );
|
622 |
+
|
623 |
+
if ( $nonce ) {
|
624 |
+
$text = str_replace( $matches[0][0],
|
625 |
+
'_wpnonce=' . wp_create_nonce( 'dismiss_message' ), $text );
|
626 |
+
}
|
627 |
+
|
628 |
+
wpv_admin_message( $message_id, $text, $message['class'] );
|
629 |
+
if ( $show_once ) {
|
630 |
+
unset( $messages[$message_id] );
|
631 |
+
}
|
632 |
+
}
|
633 |
+
update_option( 'wpv-messages', $messages );
|
634 |
+
}
|
635 |
+
|
636 |
+
/**
|
637 |
+
* Stores admin messages.
|
638 |
+
*
|
639 |
+
* @param type $message_id
|
640 |
+
* @param type $message
|
641 |
+
* @param type $show_once
|
642 |
+
* @param type $class
|
643 |
+
*/
|
644 |
+
function wpv_admin_message_store( $message_id, $message, $show_once = true,
|
645 |
+
$class = 'updated' ) {
|
646 |
+
$messages = get_option( 'wpv-messages', array() );
|
647 |
+
$messages[strval( $message_id )] = array(
|
648 |
+
'message' => strval( $message ),
|
649 |
+
'class' => strval( $class ),
|
650 |
+
'show_once' => $show_once,
|
651 |
+
);
|
652 |
+
update_option( 'wpv-messages', $messages );
|
653 |
+
}
|
654 |
+
|
655 |
+
/**
|
656 |
+
* Shows admin message.
|
657 |
+
*
|
658 |
+
* @param type $message_id
|
659 |
+
* @param type $message
|
660 |
+
* @param type $class
|
661 |
+
*/
|
662 |
+
function wpv_admin_message( $message_id, $message, $class = 'updated' ) {
|
663 |
+
if ( apply_filters( 'wpv-show-message', true, $message_id ) ) {
|
664 |
+
add_action( 'admin_notices',
|
665 |
+
create_function( '$a=1, $message_id=\'' . strval( $message_id )
|
666 |
+
. '\', $class=\'' . strval( $class )
|
667 |
+
. '\', $message=\''
|
668 |
+
. htmlentities( strval( $message ), ENT_QUOTES ) . '\'',
|
669 |
+
'$screen = get_current_screen(); if (!$screen->is_network) echo "<div class=\"message $class\" id=\"wpv-message-$message_id\"><p>" . html_entity_decode($message, ENT_QUOTES) . "</p></div>";' ) );
|
670 |
+
}
|
671 |
+
}
|
embedded/common/res/css/colorbox.css
DELETED
@@ -1,88 +0,0 @@
|
|
1 |
-
/* -------- */
|
2 |
-
/* Colorbox */
|
3 |
-
/* -------- */
|
4 |
-
|
5 |
-
/* This file contains styles for default Colorbox elements only */
|
6 |
-
/* TODO: This file can be removed, we can load it from common */
|
7 |
-
|
8 |
-
body.disable-scrollbar {
|
9 |
-
overflow: hidden;
|
10 |
-
}
|
11 |
-
|
12 |
-
#colorbox,
|
13 |
-
#cboxOverlay,
|
14 |
-
#cboxWrapper {
|
15 |
-
position:absolute;
|
16 |
-
top:0;
|
17 |
-
left:0;
|
18 |
-
z-index:10000;
|
19 |
-
/* overflow:hidden;*/
|
20 |
-
}
|
21 |
-
|
22 |
-
#cboxOverlay {
|
23 |
-
position:fixed;
|
24 |
-
width:100%;
|
25 |
-
max-width: 100%;
|
26 |
-
height:100%;
|
27 |
-
background: #000;
|
28 |
-
}
|
29 |
-
#cboxMiddleLeft,
|
30 |
-
#cboxBottomLeft {
|
31 |
-
clear:left;
|
32 |
-
}
|
33 |
-
#cboxContent {
|
34 |
-
position:relative;
|
35 |
-
}
|
36 |
-
#cboxLoadedContent {
|
37 |
-
overflow:visible!important;
|
38 |
-
-webkit-overflow-scrolling: touch;
|
39 |
-
}
|
40 |
-
#cboxTitle {
|
41 |
-
margin:0;
|
42 |
-
}
|
43 |
-
#cboxLoadingOverlay,
|
44 |
-
#cboxLoadingGraphic {
|
45 |
-
position:absolute;
|
46 |
-
top:0;
|
47 |
-
left:0;
|
48 |
-
width:100%;
|
49 |
-
height:100%;
|
50 |
-
}
|
51 |
-
#cboxPrevious,
|
52 |
-
#cboxNext,
|
53 |
-
#cboxClose,
|
54 |
-
#cboxSlideshow {
|
55 |
-
cursor:pointer;
|
56 |
-
}
|
57 |
-
.cboxPhoto {
|
58 |
-
display:block;
|
59 |
-
float:left;
|
60 |
-
margin:auto;
|
61 |
-
max-width:none;
|
62 |
-
border:0;
|
63 |
-
-ms-interpolation-mode:bicubic;
|
64 |
-
}
|
65 |
-
.cboxIframe {
|
66 |
-
display:block;
|
67 |
-
width:100%;
|
68 |
-
height:100%;
|
69 |
-
border:0;
|
70 |
-
}
|
71 |
-
#colorbox,
|
72 |
-
#cboxContent,
|
73 |
-
#cboxLoadedContent {
|
74 |
-
-webkit-box-sizing:content-box;
|
75 |
-
-moz-box-sizing:content-box;
|
76 |
-
box-sizing:content-box;
|
77 |
-
}
|
78 |
-
|
79 |
-
.cboxIE #cboxTopLeft,
|
80 |
-
.cboxIE #cboxTopCenter,
|
81 |
-
.cboxIE #cboxTopRight,
|
82 |
-
.cboxIE #cboxBottomLeft,
|
83 |
-
.cboxIE #cboxBottomCenter,
|
84 |
-
.cboxIE #cboxBottomRight,
|
85 |
-
.cboxIE #cboxMiddleLeft,
|
86 |
-
.cboxIE #cboxMiddleRight {
|
87 |
-
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
|
88 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/res/css/toolset-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,
|
@@ -59,15 +59,4 @@ Toolset Primary Button Style - use with .button.button-primary-toolset classname
|
|
59 |
/* ----------------------------------------------------------------------------
|
60 |
Generic CSS to be applied anywhere
|
61 |
---------------------------------------------------------------------------- */
|
62 |
-
.padding-top-30{padding-top:30px;}
|
63 |
-
|
64 |
-
/* ----------------------------------------------------------------------------
|
65 |
-
Design with Toolset icon
|
66 |
-
---------------------------------------------------------------------------- */
|
67 |
-
#wpadminbar ul#wp-admin-bar-root-default> li.toolset-edit-link> a{position:relative;}
|
68 |
-
#wpadminbar ul#wp-admin-bar-root-default> li.toolset-edit-link> a:before{
|
69 |
-
font-family: "onthegosystems-icons"!important;
|
70 |
-
content: "\f11a";
|
71 |
-
top:2px;
|
72 |
-
}
|
73 |
-
|
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 |
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,
|
59 |
/* ----------------------------------------------------------------------------
|
60 |
Generic CSS to be applied anywhere
|
61 |
---------------------------------------------------------------------------- */
|
62 |
+
.padding-top-30{padding-top:30px;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/res/css/toolset-promotion.css
DELETED
@@ -1,164 +0,0 @@
|
|
1 |
-
|
2 |
-
.toolset-modal
|
3 |
-
{
|
4 |
-
font-family: "Open Sans";
|
5 |
-
font-size: 15px;
|
6 |
-
width: 550px;
|
7 |
-
background-color: #fff;
|
8 |
-
padding: 45px 0 20px 0;
|
9 |
-
position: relative;
|
10 |
-
|
11 |
-
-webkit-box-shadow: 5px 5px 15px 0px rgba(50, 50, 50, 0.38);
|
12 |
-
-moz-box-shadow: 5px 5px 15px 0px rgba(50, 50, 50, 0.38);
|
13 |
-
box-shadow: 5px 5px 15px 0px rgba(50, 50, 50, 0.38);
|
14 |
-
|
15 |
-
}
|
16 |
-
|
17 |
-
.toolset-modal h2
|
18 |
-
{
|
19 |
-
color: #fff;
|
20 |
-
position: relative;
|
21 |
-
background-color: #333;
|
22 |
-
padding: 10px 30px;
|
23 |
-
font-size: 24px;
|
24 |
-
line-height: 30px;
|
25 |
-
font-weight: 300;
|
26 |
-
margin: 0;
|
27 |
-
}
|
28 |
-
|
29 |
-
.toolset-modal .icon-toolset-logo
|
30 |
-
{
|
31 |
-
color: #f05a28;
|
32 |
-
position: absolute;
|
33 |
-
top: 6px;
|
34 |
-
left: 23px;
|
35 |
-
font-size: 53px;
|
36 |
-
background: transparent url(../images/toolset.promotion/toolset.png) no-repeat 7px 3px;
|
37 |
-
width: 55px;
|
38 |
-
height: 55px;
|
39 |
-
}
|
40 |
-
|
41 |
-
.toolset-modal .icon-toolset-logo:before
|
42 |
-
{
|
43 |
-
content: none;
|
44 |
-
display: none;
|
45 |
-
}
|
46 |
-
|
47 |
-
.toolset-modal ul:before
|
48 |
-
{
|
49 |
-
content: "";
|
50 |
-
display: table;
|
51 |
-
}
|
52 |
-
|
53 |
-
.toolset-modal .content
|
54 |
-
{
|
55 |
-
padding: 0 28px;
|
56 |
-
}
|
57 |
-
|
58 |
-
.toolset-modal ul
|
59 |
-
{
|
60 |
-
display: table-row;
|
61 |
-
}
|
62 |
-
|
63 |
-
.toolset-modal li:first-child
|
64 |
-
{
|
65 |
-
min-width: 75px;
|
66 |
-
}
|
67 |
-
|
68 |
-
.toolset-modal li:last-child
|
69 |
-
{
|
70 |
-
padding-right: 0;
|
71 |
-
min-width: 115px;
|
72 |
-
}
|
73 |
-
|
74 |
-
.toolset-modal li
|
75 |
-
,.js-close-promotional-message
|
76 |
-
{
|
77 |
-
background: transparent url(../images/toolset.promotion/icons.png) no-repeat;
|
78 |
-
}
|
79 |
-
|
80 |
-
.toolset-modal li
|
81 |
-
{
|
82 |
-
display: table-cell;
|
83 |
-
font-size: 13px;
|
84 |
-
font-weight: 700;
|
85 |
-
height: 46px;
|
86 |
-
padding: 0 20px 0 38px;
|
87 |
-
}
|
88 |
-
|
89 |
-
|
90 |
-
.toolset-modal li.layout{background-position: 0 -65px}
|
91 |
-
.toolset-modal li.toolset-search{background-position: 0 -130px}
|
92 |
-
.toolset-modal li.list {background-position: 0 -195px}
|
93 |
-
.toolset-modal li.form {background-position: 0 -260px}
|
94 |
-
.toolset-modal li.more {background-position: 0 -325px}
|
95 |
-
|
96 |
-
.toolset-modal .full img
|
97 |
-
{
|
98 |
-
padding-bottom: 19px;
|
99 |
-
}
|
100 |
-
|
101 |
-
.toolset-modal .full
|
102 |
-
{
|
103 |
-
background: transparent url(../images/toolset.promotion/full.jpg) no-repeat;
|
104 |
-
padding-left: 298px;
|
105 |
-
min-height: 160px;
|
106 |
-
font-size: 15px;
|
107 |
-
margin: 10px 0 0 0;
|
108 |
-
}
|
109 |
-
|
110 |
-
.toolset-modal .icons
|
111 |
-
{
|
112 |
-
border: 1px solid #777;
|
113 |
-
border-width: 1px 0;
|
114 |
-
padding-top: 10px;
|
115 |
-
}
|
116 |
-
|
117 |
-
.toolset-modal .description
|
118 |
-
{
|
119 |
-
font-size: 13px;
|
120 |
-
color: #4d4d4d;
|
121 |
-
margin: 10px 0 20px 0;
|
122 |
-
}
|
123 |
-
|
124 |
-
.toolset-modal em
|
125 |
-
{
|
126 |
-
font-weight: 600;
|
127 |
-
}
|
128 |
-
|
129 |
-
.toolset-modal .button
|
130 |
-
{
|
131 |
-
padding: 10px 15px;
|
132 |
-
background-color: #f05a28;
|
133 |
-
color: #fff;
|
134 |
-
text-decoration: none;
|
135 |
-
margin-top: -10px;
|
136 |
-
height: auto;
|
137 |
-
font-size: 18px;
|
138 |
-
line-height: 1em;
|
139 |
-
}
|
140 |
-
|
141 |
-
.toolset-modal .learn
|
142 |
-
{
|
143 |
-
font-size: 15px;
|
144 |
-
color: #f05a28;
|
145 |
-
display: inline-block;
|
146 |
-
margin-left: 20px;
|
147 |
-
}
|
148 |
-
|
149 |
-
.ddl-dialogs-container
|
150 |
-
{
|
151 |
-
display: none;
|
152 |
-
}
|
153 |
-
|
154 |
-
.js-close-promotional-message
|
155 |
-
{
|
156 |
-
background-position: 0 -480px;
|
157 |
-
cursor: pointer;
|
158 |
-
display: block;
|
159 |
-
height: 20px;
|
160 |
-
position: absolute;
|
161 |
-
right: -10px;
|
162 |
-
top: -10px;
|
163 |
-
width: 20px;
|
164 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/res/images/toolset.promotion/full.jpg
DELETED
Binary file
|
embedded/common/res/images/toolset.promotion/icons.png
DELETED
Binary file
|
embedded/common/res/images/toolset.promotion/toolset.png
DELETED
Binary file
|
embedded/common/res/js/jquery.colorbox-min.js
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
/*!
|
2 |
-
Colorbox v1.4.31 - 2013-09-25
|
3 |
-
jQuery lightbox and modal window plugin
|
4 |
-
(c) 2013 Jack Moore - http://www.jacklmoore.com/colorbox
|
5 |
-
license: http://www.opensource.org/licenses/mit-license.php
|
6 |
-
*/
|
7 |
-
(function(e,t,i){function o(i,o,n){var r=t.createElement(i);return o&&(r.id=Z+o),n&&(r.style.cssText=n),e(r)}function n(){return i.innerHeight?i.innerHeight:e(i).height()}function r(e){var t=k.length,i=(z+e)%t;return 0>i?t+i:i}function h(e,t){return Math.round((/%/.test(e)?("x"===t?E.width():n())/100:1)*parseInt(e,10))}function s(e,t){return e.photo||e.photoRegex.test(t)}function l(e,t){return e.retinaUrl&&i.devicePixelRatio>1?t.replace(e.photoRegex,e.retinaSuffix):t}function a(e){"contains"in g[0]&&!g[0].contains(e.target)&&(e.stopPropagation(),g.focus())}function d(){var t,i=e.data(N,Y);null==i?(B=e.extend({},X),console&&console.log&&console.log("Error: cboxElement missing settings object")):B=e.extend({},i);for(t in B)e.isFunction(B[t])&&"on"!==t.slice(0,2)&&(B[t]=B[t].call(N));B.rel=B.rel||N.rel||e(N).data("rel")||"nofollow",B.href=B.href||e(N).attr("href"),B.title=B.title||N.title,"string"==typeof B.href&&(B.href=e.trim(B.href))}function c(i,o){e(t).trigger(i),st.trigger(i),e.isFunction(o)&&o.call(N)}function u(i){q||(N=i,d(),k=e(N),z=0,"nofollow"!==B.rel&&(k=e("."+et).filter(function(){var t,i=e.data(this,Y);return i&&(t=e(this).data("rel")||i.rel||this.rel),t===B.rel}),z=k.index(N),-1===z&&(k=k.add(N),z=k.length-1)),w.css({opacity:parseFloat(B.opacity),cursor:B.overlayClose?"pointer":"auto",visibility:"visible"}).show(),J&&g.add(w).removeClass(J),B.className&&g.add(w).addClass(B.className),J=B.className,B.closeButton?K.html(B.close).appendTo(y):K.appendTo("<div/>"),U||(U=$=!0,g.css({visibility:"hidden",display:"block"}),H=o(lt,"LoadedContent","width:0; height:0; overflow:hidden"),y.css({width:"",height:""}).append(H),O=x.height()+C.height()+y.outerHeight(!0)-y.height(),_=b.width()+T.width()+y.outerWidth(!0)-y.width(),D=H.outerHeight(!0),A=H.outerWidth(!0),B.w=h(B.initialWidth,"x"),B.h=h(B.initialHeight,"y"),H.css({width:"",height:B.h}),Q.position(),c(tt,B.onOpen),P.add(L).hide(),g.focus(),B.trapFocus&&t.addEventListener&&(t.addEventListener("focus",a,!0),st.one(rt,function(){t.removeEventListener("focus",a,!0)})),B.returnFocus&&st.one(rt,function(){e(N).focus()})),m())}function f(){!g&&t.body&&(V=!1,E=e(i),g=o(lt).attr({id:Y,"class":e.support.opacity===!1?Z+"IE":"",role:"dialog",tabindex:"-1"}).hide(),w=o(lt,"Overlay").hide(),F=e([o(lt,"LoadingOverlay")[0],o(lt,"LoadingGraphic")[0]]),v=o(lt,"Wrapper"),y=o(lt,"Content").append(L=o(lt,"Title"),S=o(lt,"Current"),I=e('<button type="button"/>').attr({id:Z+"Previous"}),R=e('<button type="button"/>').attr({id:Z+"Next"}),M=o("button","Slideshow"),F),K=e('<button type="button"/>').attr({id:Z+"Close"}),v.append(o(lt).append(o(lt,"TopLeft"),x=o(lt,"TopCenter"),o(lt,"TopRight")),o(lt,!1,"clear:left").append(b=o(lt,"MiddleLeft"),y,T=o(lt,"MiddleRight")),o(lt,!1,"clear:left").append(o(lt,"BottomLeft"),C=o(lt,"BottomCenter"),o(lt,"BottomRight"))).find("div div").css({"float":"left"}),W=o(lt,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),P=R.add(I).add(S).add(M),e(t.body).append(w,g.append(v,W)))}function p(){function i(e){e.which>1||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey||(e.preventDefault(),u(this))}return g?(V||(V=!0,R.click(function(){Q.next()}),I.click(function(){Q.prev()}),K.click(function(){Q.close()}),w.click(function(){B.overlayClose&&Q.close()}),e(t).bind("keydown."+Z,function(e){var t=e.keyCode;U&&B.escKey&&27===t&&(e.preventDefault(),Q.close()),U&&B.arrowKey&&k[1]&&!e.altKey&&(37===t?(e.preventDefault(),I.click()):39===t&&(e.preventDefault(),R.click()))}),e.isFunction(e.fn.on)?e(t).on("click."+Z,"."+et,i):e("."+et).live("click."+Z,i)),!0):!1}function m(){var n,r,a,u=Q.prep,f=++at;$=!0,j=!1,N=k[z],d(),c(ht),c(it,B.onLoad),B.h=B.height?h(B.height,"y")-D-O:B.innerHeight&&h(B.innerHeight,"y"),B.w=B.width?h(B.width,"x")-A-_:B.innerWidth&&h(B.innerWidth,"x"),B.mw=B.w,B.mh=B.h,B.maxWidth&&(B.mw=h(B.maxWidth,"x")-A-_,B.mw=B.w&&B.w<B.mw?B.w:B.mw),B.maxHeight&&(B.mh=h(B.maxHeight,"y")-D-O,B.mh=B.h&&B.h<B.mh?B.h:B.mh),n=B.href,G=setTimeout(function(){F.show()},100),B.inline?(a=o(lt).hide().insertBefore(e(n)[0]),st.one(ht,function(){a.replaceWith(H.children())}),u(e(n))):B.iframe?u(" "):B.html?u(B.html):s(B,n)?(n=l(B,n),j=t.createElement("img"),e(j).addClass(Z+"Photo").bind("error",function(){B.title=!1,u(o(lt,"Error").html(B.imgError))}).one("load",function(){var t;f===at&&(e.each(["alt","longdesc","aria-describedby"],function(t,i){var o=e(N).attr(i)||e(N).attr("data-"+i);o&&j.setAttribute(i,o)}),B.retinaImage&&i.devicePixelRatio>1&&(j.height=j.height/i.devicePixelRatio,j.width=j.width/i.devicePixelRatio),B.scalePhotos&&(r=function(){j.height-=j.height*t,j.width-=j.width*t},B.mw&&j.width>B.mw&&(t=(j.width-B.mw)/j.width,r()),B.mh&&j.height>B.mh&&(t=(j.height-B.mh)/j.height,r())),B.h&&(j.style.marginTop=Math.max(B.mh-j.height,0)/2+"px"),k[1]&&(B.loop||k[z+1])&&(j.style.cursor="pointer",j.onclick=function(){Q.next()}),j.style.width=j.width+"px",j.style.height=j.height+"px",setTimeout(function(){u(j)},1))}),setTimeout(function(){j.src=n},1)):n&&W.load(n,B.data,function(t,i){f===at&&u("error"===i?o(lt,"Error").html(B.xhrError):e(this).contents())})}var w,g,v,y,x,b,T,C,k,E,H,W,F,L,S,M,R,I,K,P,B,O,_,D,A,N,z,j,U,$,q,G,Q,J,V,X={html:!1,photo:!1,iframe:!1,inline:!1,transition:"elastic",speed:300,fadeOut:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,className:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:void 0,closeButton:!0,fastIframe:!0,open:!1,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",photoRegex:/\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i,retinaImage:!1,retinaUrl:!1,retinaSuffix:"@2x.$1",current:"image {current} of {total}",previous:"previous",next:"next",close:"close",xhrError:"This content failed to load.",imgError:"This image failed to load.",returnFocus:!0,trapFocus:!0,onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1},Y="colorbox",Z="cbox",et=Z+"Element",tt=Z+"_open",it=Z+"_load",ot=Z+"_complete",nt=Z+"_cleanup",rt=Z+"_closed",ht=Z+"_purge",st=e("<a/>"),lt="div",at=0,dt={},ct=function(){function e(){clearTimeout(h)}function t(){(B.loop||k[z+1])&&(e(),h=setTimeout(Q.next,B.slideshowSpeed))}function i(){M.html(B.slideshowStop).unbind(l).one(l,o),st.bind(ot,t).bind(it,e),g.removeClass(s+"off").addClass(s+"on")}function o(){e(),st.unbind(ot,t).unbind(it,e),M.html(B.slideshowStart).unbind(l).one(l,function(){Q.next(),i()}),g.removeClass(s+"on").addClass(s+"off")}function n(){r=!1,M.hide(),e(),st.unbind(ot,t).unbind(it,e),g.removeClass(s+"off "+s+"on")}var r,h,s=Z+"Slideshow_",l="click."+Z;return function(){r?B.slideshow||(st.unbind(nt,n),n()):B.slideshow&&k[1]&&(r=!0,st.one(nt,n),B.slideshowAuto?i():o(),M.show())}}();e.colorbox||(e(f),Q=e.fn[Y]=e[Y]=function(t,i){var o=this;if(t=t||{},f(),p()){if(e.isFunction(o))o=e("<a/>"),t.open=!0;else if(!o[0])return o;i&&(t.onComplete=i),o.each(function(){e.data(this,Y,e.extend({},e.data(this,Y)||X,t))}).addClass(et),(e.isFunction(t.open)&&t.open.call(o)||t.open)&&u(o[0])}return o},Q.position=function(t,i){function o(){x[0].style.width=C[0].style.width=y[0].style.width=parseInt(g[0].style.width,10)-_+"px",y[0].style.height=b[0].style.height=T[0].style.height=parseInt(g[0].style.height,10)-O+"px"}var r,s,l,a=0,d=0,c=g.offset();if(E.unbind("resize."+Z),g.css({top:-9e4,left:-9e4}),s=E.scrollTop(),l=E.scrollLeft(),B.fixed?(c.top-=s,c.left-=l,g.css({position:"fixed"})):(a=s,d=l,g.css({position:"absolute"})),d+=B.right!==!1?Math.max(E.width()-B.w-A-_-h(B.right,"x"),0):B.left!==!1?h(B.left,"x"):Math.round(Math.max(E.width()-B.w-A-_,0)/2),a+=B.bottom!==!1?Math.max(n()-B.h-D-O-h(B.bottom,"y"),0):B.top!==!1?h(B.top,"y"):Math.round(Math.max(n()-B.h-D-O,0)/2),g.css({top:c.top,left:c.left,visibility:"visible"}),v[0].style.width=v[0].style.height="9999px",r={width:B.w+A+_,height:B.h+D+O,top:a,left:d},t){var u=0;e.each(r,function(e){return r[e]!==dt[e]?(u=t,void 0):void 0}),t=u}dt=r,t||g.css(r),g.dequeue().animate(r,{duration:t||0,complete:function(){o(),$=!1,v[0].style.width=B.w+A+_+"px",v[0].style.height=B.h+D+O+"px",B.reposition&&setTimeout(function(){E.bind("resize."+Z,Q.position)},1),i&&i()},step:o})},Q.resize=function(e){var t;U&&(e=e||{},e.width&&(B.w=h(e.width,"x")-A-_),e.innerWidth&&(B.w=h(e.innerWidth,"x")),H.css({width:B.w}),e.height&&(B.h=h(e.height,"y")-D-O),e.innerHeight&&(B.h=h(e.innerHeight,"y")),e.innerHeight||e.height||(t=H.scrollTop(),H.css({height:"auto"}),B.h=H.height()),H.css({height:B.h}),t&&H.scrollTop(t),Q.position("none"===B.transition?0:B.speed))},Q.prep=function(i){function n(){return B.w=B.w||H.width(),B.w=B.mw&&B.mw<B.w?B.mw:B.w,B.w}function h(){return B.h=B.h||H.height(),B.h=B.mh&&B.mh<B.h?B.mh:B.h,B.h}if(U){var a,d="none"===B.transition?0:B.speed;H.empty().remove(),H=o(lt,"LoadedContent").append(i),H.hide().appendTo(W.show()).css({width:n(),overflow:B.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(y),W.hide(),e(j).css({"float":"none"}),a=function(){function i(){e.support.opacity===!1&&g[0].style.removeAttribute("filter")}var n,h,a=k.length,u="frameBorder",f="allowTransparency";U&&(h=function(){clearTimeout(G),F.hide(),c(ot,B.onComplete)},L.html(B.title).add(H).show(),a>1?("string"==typeof B.current&&S.html(B.current.replace("{current}",z+1).replace("{total}",a)).show(),R[B.loop||a-1>z?"show":"hide"]().html(B.next),I[B.loop||z?"show":"hide"]().html(B.previous),ct(),B.preloading&&e.each([r(-1),r(1)],function(){var i,o,n=k[this],r=e.data(n,Y);r&&r.href?(i=r.href,e.isFunction(i)&&(i=i.call(n))):i=e(n).attr("href"),i&&s(r,i)&&(i=l(r,i),o=t.createElement("img"),o.src=i)})):P.hide(),B.iframe?(n=o("iframe")[0],u in n&&(n[u]=0),f in n&&(n[f]="true"),B.scrolling||(n.scrolling="no"),e(n).attr({src:B.href,name:(new Date).getTime(),"class":Z+"Iframe",allowFullScreen:!0,webkitAllowFullScreen:!0,mozallowfullscreen:!0}).one("load",h).appendTo(H),st.one(ht,function(){n.src="//about:blank"}),B.fastIframe&&e(n).trigger("load")):h(),"fade"===B.transition?g.fadeTo(d,1,i):i())},"fade"===B.transition?g.fadeTo(d,0,function(){Q.position(0,a)}):Q.position(d,a)}},Q.next=function(){!$&&k[1]&&(B.loop||k[z+1])&&(z=r(1),u(k[z]))},Q.prev=function(){!$&&k[1]&&(B.loop||z)&&(z=r(-1),u(k[z]))},Q.close=function(){U&&!q&&(q=!0,U=!1,c(nt,B.onCleanup),E.unbind("."+Z),w.fadeTo(B.fadeOut||0,0),g.stop().fadeTo(B.fadeOut||0,0,function(){g.add(w).css({opacity:1,cursor:"auto"}).hide(),c(ht),H.empty().remove(),setTimeout(function(){q=!1,c(rt,B.onClosed)},1)}))},Q.remove=function(){g&&(g.stop(),e.colorbox.close(),g.stop().remove(),w.remove(),q=!1,g=null,e("."+et).removeData(Y).removeClass(et),e(t).unbind("click."+Z))},Q.element=function(){return e(N)},Q.settings=X)})(jQuery,document,window);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/res/js/toolset-promotion.js
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
var Toolset_Promotion = Toolset_Promotion || {};
|
2 |
-
|
3 |
-
Toolset_Promotion = function($){
|
4 |
-
var self = this;
|
5 |
-
|
6 |
-
self.init = function(){
|
7 |
-
self.toolset_open_promotional_message();
|
8 |
-
};
|
9 |
-
|
10 |
-
self.toolset_open_promotional_message = function(){
|
11 |
-
var $el = $('.js-open-promotional-message')
|
12 |
-
, template = $('#js-buy-toolset-embedded-message').html()
|
13 |
-
, $container = $('#js-buy-toolset-embedded-message-wrap');
|
14 |
-
|
15 |
-
$container.html( _.template( template ) );
|
16 |
-
|
17 |
-
$(document).on('click', $el.selector, function(event){
|
18 |
-
event.preventDefault();
|
19 |
-
$.colorbox({
|
20 |
-
href: $container.selector,
|
21 |
-
inline: true,
|
22 |
-
open: true,
|
23 |
-
closeButton: false,
|
24 |
-
fixed: true,
|
25 |
-
top: false,
|
26 |
-
width:'554px',
|
27 |
-
onComplete: function() {
|
28 |
-
|
29 |
-
},
|
30 |
-
onCleanup: function() {
|
31 |
-
|
32 |
-
},
|
33 |
-
opacity: .2
|
34 |
-
});
|
35 |
-
})
|
36 |
-
$('.js-close-promotional-message').on('click', function(){
|
37 |
-
$.colorbox.close();
|
38 |
-
});
|
39 |
-
};
|
40 |
-
|
41 |
-
self.init();
|
42 |
-
|
43 |
-
};
|
44 |
-
|
45 |
-
;(function($){
|
46 |
-
var toolset_promotion_message = new Toolset_Promotion($);
|
47 |
-
}(jQuery));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/toolset-forms/api.php
CHANGED
@@ -1,14 +1,5 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
/**
|
4 |
-
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.6.6/embedded/common/toolset-forms/api.php $
|
6 |
-
* $LastChangedDate: 2015-03-16 12:03:31 +0000 (Mon, 16 Mar 2015) $
|
7 |
-
* $LastChangedRevision: 1113864 $
|
8 |
-
* $LastChangedBy: iworks $
|
9 |
-
*
|
10 |
-
*/
|
11 |
-
|
12 |
function wptoolset_form( $form_id, $config = array() ){
|
13 |
global $wptoolset_forms;
|
14 |
$html = $wptoolset_forms->form( $form_id, $config );
|
@@ -17,7 +8,7 @@ function wptoolset_form( $form_id, $config = array() ){
|
|
17 |
|
18 |
function wptoolset_form_field( $form_id, $config, $value = array() ){
|
19 |
global $wptoolset_forms;
|
20 |
-
$html = $wptoolset_forms->field( $form_id, $config, $value );
|
21 |
return apply_filters( 'wptoolset_fieldform', $html, $config, $form_id );
|
22 |
}
|
23 |
|
@@ -65,33 +56,4 @@ function wptoolset_strtotime( $date, $format = null ){
|
|
65 |
function wptoolset_timetodate( $timestamp, $format = null ){
|
66 |
global $wptoolset_forms;
|
67 |
return $wptoolset_forms->timetodate( $timestamp, $format );
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* wptoolset_esc_like
|
72 |
-
*
|
73 |
-
* In WordPress 4.0, like_escape() was deprecated, due to incorrect
|
74 |
-
* documentation and improper sanitization leading to a history of misuse
|
75 |
-
* To maintain compatibility with versions of WP before 4.0, we duplicate the
|
76 |
-
* logic of the replacement, wpdb::esc_like()
|
77 |
-
*
|
78 |
-
* @see wpdb::esc_like() for more details on proper use.
|
79 |
-
*
|
80 |
-
* @global object $wpdb
|
81 |
-
*
|
82 |
-
* @param string $text The raw text to be escaped.
|
83 |
-
* @return string Text in the form of a LIKE phrase. Not SQL safe. Run through
|
84 |
-
* wpdb::prepare() before use.
|
85 |
-
*/
|
86 |
-
function wptoolset_esc_like( $like )
|
87 |
-
{
|
88 |
-
global $wpdb;
|
89 |
-
if ( method_exists( $wpdb, 'esc_like' ) ) {
|
90 |
-
return $wpdb->esc_like( $like );
|
91 |
-
}
|
92 |
-
if ( version_compare( get_bloginfo('version'), '4' ) < 0 ) {
|
93 |
-
return like_escape( $like );
|
94 |
-
}
|
95 |
-
return addcslashes( $like, '_%\\' );
|
96 |
-
}
|
97 |
-
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
function wptoolset_form( $form_id, $config = array() ){
|
4 |
global $wptoolset_forms;
|
5 |
$html = $wptoolset_forms->form( $form_id, $config );
|
8 |
|
9 |
function wptoolset_form_field( $form_id, $config, $value = array() ){
|
10 |
global $wptoolset_forms;
|
11 |
+
$html = $wptoolset_forms->field( $form_id, $config, $value );
|
12 |
return apply_filters( 'wptoolset_fieldform', $html, $config, $form_id );
|
13 |
}
|
14 |
|
56 |
function wptoolset_timetodate( $timestamp, $format = null ){
|
57 |
global $wptoolset_forms;
|
58 |
return $wptoolset_forms->timetodate( $timestamp, $format );
|
59 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/toolset-forms/bootstrap.php
CHANGED
@@ -2,301 +2,199 @@
|
|
2 |
|
3 |
/**
|
4 |
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
6 |
-
* $LastChangedDate:
|
7 |
-
* $LastChangedRevision:
|
8 |
-
* $LastChangedBy:
|
9 |
*
|
10 |
*/
|
|
|
11 |
require_once 'api.php';
|
12 |
|
13 |
-
define('WPTOOLSET_FORMS_VERSION', '0.1.1');
|
14 |
-
define('WPTOOLSET_FORMS_ABSPATH', dirname(__FILE__));
|
15 |
|
16 |
/**
|
17 |
* check we are as a embedded?
|
18 |
*/
|
19 |
-
if (defined('WPCF_RUNNING_EMBEDDED') && WPCF_RUNNING_EMBEDDED) {
|
20 |
-
define('WPTOOLSET_FORMS_RELPATH', wpcf_get_file_url(__FILE__, false));
|
21 |
}
|
22 |
/**
|
23 |
* setup WPTOOLSET_FORMS_RELPATH for plugin
|
24 |
*/
|
25 |
-
if (!defined('WPTOOLSET_FORMS_RELPATH')) {
|
26 |
-
define('WPTOOLSET_FORMS_RELPATH', plugins_url('', __FILE__));
|
27 |
}
|
28 |
-
if (!defined('WPTOOLSET_COMMON_PATH')) {
|
29 |
-
define('WPTOOLSET_COMMON_PATH', plugin_dir_path(__FILE__));
|
30 |
}
|
31 |
|
32 |
-
class WPToolset_Forms_Bootstrap
|
|
|
33 |
|
34 |
private $__forms;
|
35 |
|
36 |
-
public final function __construct()
|
|
|
37 |
// Custom conditinal AJAX check
|
38 |
-
add_action('wp_ajax_wptoolset_custom_conditional',
|
|
|
39 |
|
40 |
// Date conditinal AJAX check
|
41 |
-
add_action('wp_ajax_wptoolset_conditional',
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
54 |
/**
|
55 |
* common class for calendar
|
56 |
*/
|
57 |
-
require_once WPTOOLSET_FORMS_ABSPATH
|
58 |
new WPToolset_Field_Date_Scripts();
|
59 |
-
|
60 |
-
add_action('pre_get_posts', array($this, 'pre_get_posts'));
|
61 |
}
|
62 |
|
63 |
// returns HTML
|
64 |
-
public function field($form_id, $config, $value)
|
65 |
-
|
66 |
-
|
|
|
67 |
}
|
68 |
|
69 |
// returns HTML
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
public function form($form_id, $config = array())
|
76 |
-
|
|
|
77 |
return $this->__forms[$form_id];
|
78 |
}
|
79 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.form_factory.php';
|
80 |
-
return $this->__forms[$form_id] = new FormFactory($form_id, $config);
|
81 |
}
|
82 |
|
83 |
-
public function validate_field($form_id, $config, $value)
|
84 |
-
|
|
|
85 |
return true;
|
86 |
}
|
87 |
-
$form = $this->form($form_id, array());
|
88 |
-
return $form->validateField($config, $value);
|
89 |
}
|
90 |
|
91 |
-
public function ajaxCustomConditional()
|
|
|
92 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
|
93 |
WPToolset_Forms_Conditional::ajaxCustomConditional();
|
94 |
}
|
95 |
|
96 |
-
public function checkConditional($config)
|
97 |
-
|
|
|
98 |
return true;
|
99 |
}
|
100 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
|
101 |
-
return WPToolset_Forms_Conditional::evaluate($config['conditional']);
|
102 |
}
|
103 |
|
104 |
-
public function addConditional($form_id, $config)
|
105 |
-
|
|
|
106 |
}
|
107 |
|
108 |
-
public function ajaxConditional()
|
|
|
109 |
$data = $_POST['conditions'];
|
110 |
$data['values'] = $_POST['values'];
|
111 |
-
echo $this->checkConditional(array('conditional' => $data));
|
112 |
-
die();
|
113 |
-
}
|
114 |
-
|
115 |
-
public function wpt_localize_extended_date() {
|
116 |
-
if (!isset($_POST['date'])) {
|
117 |
-
die();
|
118 |
-
}
|
119 |
-
$date = $_POST['date'];
|
120 |
-
$date_format = '';
|
121 |
-
if (isset($_POST['date-format'])) {
|
122 |
-
$date_format = $_POST['date-format'];
|
123 |
-
}
|
124 |
-
if ($date_format == '') {
|
125 |
-
$date_format = get_option('date_format');
|
126 |
-
}
|
127 |
-
$date = adodb_mktime(0, 0, 0, substr($date, 2, 2), substr($date, 0, 2), substr($date, 4, 4));
|
128 |
-
$date_format = str_replace('\\\\', '\\', $date_format);
|
129 |
-
echo json_encode(array('display' => adodb_date($date_format, $date), 'timestamp' => $date));
|
130 |
-
die();
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* wpt_suggest_taxonomy_term
|
135 |
-
*
|
136 |
-
* Renders the suggestions when adding new flat taxonomy terms on a CRED form
|
137 |
-
*
|
138 |
-
* Needs a non-empty q attribute and can take an optional non-empty taxonomy attribute on the $_REQUEST
|
139 |
-
*
|
140 |
-
* @since 1.5.0
|
141 |
-
*/
|
142 |
-
public function wpt_suggest_taxonomy_term() {
|
143 |
-
if (
|
144 |
-
!isset($_REQUEST['q']) || $_REQUEST['q'] == ''
|
145 |
-
) {
|
146 |
-
die();
|
147 |
-
}
|
148 |
-
global $wpdb;
|
149 |
-
$values_to_prepare = array();
|
150 |
-
if (function_exists("wpv_esc_like")) {
|
151 |
-
$term_name = '%' . wpv_esc_like($_REQUEST['q']) . '%';
|
152 |
-
} else {
|
153 |
-
if (function_exists("cred_wrap_esc_like")) {
|
154 |
-
$term_name = '%' . cred_wrap_esc_like($_REQUEST['q']) . '%';
|
155 |
-
}
|
156 |
-
}
|
157 |
-
$values_to_prepare[] = $term_name;
|
158 |
-
|
159 |
-
$tax_join = "";
|
160 |
-
$tax_where = "";
|
161 |
-
if (
|
162 |
-
isset($_REQUEST['taxonomy']) && $_REQUEST['taxonomy'] != ''
|
163 |
-
) {
|
164 |
-
$tax_join = " JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id ";
|
165 |
-
$tax_where = " AND tt.taxonomy = %s ";
|
166 |
-
$values_to_prepare[] = $_REQUEST['taxonomy'];
|
167 |
-
}
|
168 |
-
//
|
169 |
-
$results = $wpdb->get_results(
|
170 |
-
$wpdb->prepare(
|
171 |
-
"SELECT name FROM {$wpdb->terms} t {$tax_join}
|
172 |
-
WHERE t.name LIKE %s
|
173 |
-
{$tax_where}
|
174 |
-
ORDER BY name DESC
|
175 |
-
LIMIT 5", $values_to_prepare
|
176 |
-
)
|
177 |
-
);
|
178 |
-
foreach ($results as $row) {
|
179 |
-
echo $row->name . "\n";
|
180 |
-
}
|
181 |
-
|
182 |
die();
|
183 |
}
|
184 |
-
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.types.php';
|
187 |
-
return WPToolset_Types::filterField($field, $post_id, $_post_wpcf);
|
188 |
}
|
189 |
|
190 |
-
public function addFieldFilters($type)
|
191 |
-
|
192 |
-
|
193 |
-
call_user_func(array($class, '
|
|
|
194 |
}
|
195 |
}
|
196 |
|
197 |
-
public function getConditionalData($form_id)
|
198 |
-
|
|
|
199 |
}
|
200 |
|
201 |
-
public function strtotime($date, $format = null)
|
|
|
202 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
|
203 |
-
return WPToolset_Field_Date::strtotime($date, $format);
|
204 |
}
|
205 |
|
206 |
-
public function timetodate($timestamp, $format = null)
|
|
|
207 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
|
208 |
-
return WPToolset_Field_Date::timetodate($timestamp, $format);
|
209 |
}
|
210 |
|
211 |
-
public function sanitize_file_name($filename)
|
|
|
212 |
/**
|
213 |
* replace german special characters
|
214 |
*/
|
215 |
-
$de_from
|
216 |
-
$de_to
|
217 |
$filename = str_replace($de_from, $de_to, $filename);
|
218 |
/**
|
219 |
* replace polish special characters
|
220 |
*/
|
221 |
-
$pl_from
|
222 |
-
$pl_to
|
223 |
$filename = str_replace($pl_from, $pl_to, $filename);
|
224 |
/**
|
225 |
* remove special characters
|
226 |
*/
|
227 |
-
$filename = preg_replace('/[^A-Za-z0-9\._
|
228 |
-
$filename = preg_replace('
|
|
|
229 |
return $filename;
|
230 |
}
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
/**
|
237 |
-
* add custom post type to query when they use category or tags taxonomy.
|
238 |
-
*/
|
239 |
-
public function pre_get_posts($query) {
|
240 |
-
if (is_admin()) {
|
241 |
-
return;
|
242 |
-
}
|
243 |
-
/**
|
244 |
-
* do that only for main query
|
245 |
-
*/
|
246 |
-
if (!$query->is_main_query()) {
|
247 |
-
return;
|
248 |
-
}
|
249 |
-
$types_cpt = get_option('wpcf-custom-types');
|
250 |
-
if (!is_array($types_cpt) || empty($types_cpt)) {
|
251 |
-
return;
|
252 |
-
}
|
253 |
-
$cpt_to_add = array();
|
254 |
-
/**
|
255 |
-
* check category
|
256 |
-
*/
|
257 |
-
if (is_category()) {
|
258 |
-
foreach ($types_cpt as $cpt_slug => $cpt) {
|
259 |
-
if (array_key_exists('taxonomies', $cpt) && is_array($cpt['taxonomies'])) {
|
260 |
-
foreach ($cpt['taxonomies'] as $tax_slug => $value) {
|
261 |
-
if ('category' == $tax_slug && $value) {
|
262 |
-
$cpt_to_add[] = $cpt_slug;
|
263 |
-
}
|
264 |
-
}
|
265 |
-
}
|
266 |
-
}
|
267 |
-
}
|
268 |
-
/**
|
269 |
-
* check tags
|
270 |
-
*/
|
271 |
-
if (is_tag()) {
|
272 |
-
foreach ($types_cpt as $cpt_slug => $cpt) {
|
273 |
-
if (array_key_exists('taxonomies', $cpt) && is_array($cpt['taxonomies'])) {
|
274 |
-
foreach ($cpt['taxonomies'] as $tax_slug => $value) {
|
275 |
-
if ('post_tag' == $tax_slug && $value) {
|
276 |
-
$cpt_to_add[] = $cpt_slug;
|
277 |
-
}
|
278 |
-
}
|
279 |
-
}
|
280 |
-
}
|
281 |
-
}
|
282 |
-
/**
|
283 |
-
* change query if some CPT use this
|
284 |
-
*/
|
285 |
-
if (!empty($cpt_to_add)) {
|
286 |
-
/**
|
287 |
-
* remeber if is empty, then is post
|
288 |
-
*/
|
289 |
-
$current_types = $query->get('post_type');
|
290 |
-
if (empty($current_types)) {
|
291 |
-
$cpt_to_add[] = 'post';
|
292 |
-
} else {
|
293 |
-
$cpt_to_add = array_merge($current_types, $cpt_to_add);
|
294 |
-
}
|
295 |
-
$query->set('post_type', $cpt_to_add);
|
296 |
-
}
|
297 |
-
return;
|
298 |
-
}
|
299 |
-
|
300 |
}
|
301 |
|
302 |
$GLOBALS['wptoolset_forms'] = new WPToolset_Forms_Bootstrap();
|
2 |
|
3 |
/**
|
4 |
*
|
5 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/bootstrap.php $
|
6 |
+
* $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
|
7 |
+
* $LastChangedRevision: 970205 $
|
8 |
+
* $LastChangedBy: brucepearson $
|
9 |
*
|
10 |
*/
|
11 |
+
|
12 |
require_once 'api.php';
|
13 |
|
14 |
+
define( 'WPTOOLSET_FORMS_VERSION', '0.1.1' );
|
15 |
+
define( 'WPTOOLSET_FORMS_ABSPATH', dirname( __FILE__ ) );
|
16 |
|
17 |
/**
|
18 |
* check we are as a embedded?
|
19 |
*/
|
20 |
+
if ( defined('WPCF_RUNNING_EMBEDDED' ) && WPCF_RUNNING_EMBEDDED ) {
|
21 |
+
define( 'WPTOOLSET_FORMS_RELPATH', wpcf_get_file_url( __FILE__, false ) );
|
22 |
}
|
23 |
/**
|
24 |
* setup WPTOOLSET_FORMS_RELPATH for plugin
|
25 |
*/
|
26 |
+
if ( !defined( 'WPTOOLSET_FORMS_RELPATH' ) ) {
|
27 |
+
define( 'WPTOOLSET_FORMS_RELPATH', plugins_url( '', __FILE__ ) );
|
28 |
}
|
29 |
+
if ( !defined( 'WPTOOLSET_COMMON_PATH' ) ) {
|
30 |
+
define( 'WPTOOLSET_COMMON_PATH', plugin_dir_path( __FILE__ ) );
|
31 |
}
|
32 |
|
33 |
+
class WPToolset_Forms_Bootstrap
|
34 |
+
{
|
35 |
|
36 |
private $__forms;
|
37 |
|
38 |
+
public final function __construct()
|
39 |
+
{
|
40 |
// Custom conditinal AJAX check
|
41 |
+
add_action( 'wp_ajax_wptoolset_custom_conditional',
|
42 |
+
array($this, 'ajaxCustomConditional') );
|
43 |
|
44 |
// Date conditinal AJAX check
|
45 |
+
add_action( 'wp_ajax_wptoolset_conditional',
|
46 |
+
array($this, 'ajaxConditional') );
|
47 |
+
|
48 |
+
// Date extended localization AJAX callback
|
49 |
+
add_action( 'wp_ajax_wpt_localize_extended_date', array( $this, 'wpt_localize_extended_date' ) );
|
50 |
+
add_action( 'wp_ajax_nopriv_wpt_localize_extended_date', array( $this, 'wpt_localize_extended_date' ) );
|
51 |
+
|
52 |
+
// File media popup
|
53 |
+
if ( (isset( $_GET['context'] ) && $_GET['context'] == 'wpt-fields-media-insert') || (isset( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'],
|
54 |
+
'context=wpt-fields-media-insert' ) !== false)
|
55 |
+
) {
|
56 |
+
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.file.php';
|
57 |
+
add_action( 'init', array('WPToolset_Field_File', 'mediaPopup') );
|
58 |
+
}
|
59 |
+
add_filter('sanitize_file_name', array( $this, 'sanitize_file_name' ) );
|
60 |
+
|
61 |
+
add_filter( 'wptoolset_filter_wptoolset_repdrag_image', array( $this, 'set_default_repdrag_image' ), 10, 1 );
|
62 |
/**
|
63 |
* common class for calendar
|
64 |
*/
|
65 |
+
require_once WPTOOLSET_FORMS_ABSPATH.'/classes/class.date.scripts.php';
|
66 |
new WPToolset_Field_Date_Scripts();
|
|
|
|
|
67 |
}
|
68 |
|
69 |
// returns HTML
|
70 |
+
public function field($form_id, $config, $value)
|
71 |
+
{
|
72 |
+
$form = $this->form( $form_id, array() );
|
73 |
+
return $form->metaform( $config, $config['name'], $value );
|
74 |
}
|
75 |
|
76 |
// returns HTML
|
77 |
+
// public function fieldEdit($form_id, $config) {
|
78 |
+
// $form = $this->form( $form_id, array() );
|
79 |
+
// return $form->editform( $config );
|
80 |
+
// }
|
81 |
+
|
82 |
+
public function form( $form_id, $config = array() )
|
83 |
+
{
|
84 |
+
if ( isset( $this->__forms[$form_id] ) ) {
|
85 |
return $this->__forms[$form_id];
|
86 |
}
|
87 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.form_factory.php';
|
88 |
+
return $this->__forms[$form_id] = new FormFactory( $form_id, $config );
|
89 |
}
|
90 |
|
91 |
+
public function validate_field($form_id, $config, $value)
|
92 |
+
{
|
93 |
+
if ( empty( $config['validation'] ) ) {
|
94 |
return true;
|
95 |
}
|
96 |
+
$form = $this->form( $form_id, array() );
|
97 |
+
return $form->validateField( $config, $value );
|
98 |
}
|
99 |
|
100 |
+
public function ajaxCustomConditional()
|
101 |
+
{
|
102 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
|
103 |
WPToolset_Forms_Conditional::ajaxCustomConditional();
|
104 |
}
|
105 |
|
106 |
+
public function checkConditional($config)
|
107 |
+
{
|
108 |
+
if ( empty( $config['conditional'] ) ) {
|
109 |
return true;
|
110 |
}
|
111 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
|
112 |
+
return WPToolset_Forms_Conditional::evaluate( $config['conditional'] );
|
113 |
}
|
114 |
|
115 |
+
public function addConditional($form_id, $config)
|
116 |
+
{
|
117 |
+
$this->form( $form_id )->addConditional( $config );
|
118 |
}
|
119 |
|
120 |
+
public function ajaxConditional()
|
121 |
+
{
|
122 |
$data = $_POST['conditions'];
|
123 |
$data['values'] = $_POST['values'];
|
124 |
+
echo $this->checkConditional( array('conditional' => $data) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
die();
|
126 |
}
|
127 |
+
|
128 |
+
public function wpt_localize_extended_date()
|
129 |
+
{
|
130 |
+
$date_format = $_POST['date-format'];
|
131 |
+
if ($date_format == '') {
|
132 |
+
$date_format = get_option('date_format');
|
133 |
+
}
|
134 |
+
$date = $_POST['date'];
|
135 |
+
$date = adodb_mktime(0, 0, 0, substr($date, 2, 2), substr($date, 0, 2), substr($date, 4, 4));
|
136 |
+
$date_format = str_replace('\\\\', '\\', $date_format);
|
137 |
+
echo json_encode(array('display' => adodb_date($date_format, $date),'timestamp' => $date));
|
138 |
+
die();
|
139 |
+
}
|
140 |
+
|
141 |
+
public function filterTypesField($field, $post_id = null, $_post_wpcf = array())
|
142 |
+
{
|
143 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.types.php';
|
144 |
+
return WPToolset_Types::filterField( $field, $post_id, $_post_wpcf);
|
145 |
}
|
146 |
|
147 |
+
public function addFieldFilters($type)
|
148 |
+
{
|
149 |
+
if ( $class = $this->form( 'generic' )->loadFieldClass( $type ) ) {
|
150 |
+
call_user_func( array($class, 'addFilters') );
|
151 |
+
call_user_func( array($class, 'addActions') );
|
152 |
}
|
153 |
}
|
154 |
|
155 |
+
public function getConditionalData($form_id)
|
156 |
+
{
|
157 |
+
return $this->form( $form_id )->getConditionalClass()->getData();
|
158 |
}
|
159 |
|
160 |
+
public function strtotime($date, $format = null)
|
161 |
+
{
|
162 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
|
163 |
+
return WPToolset_Field_Date::strtotime( $date, $format );
|
164 |
}
|
165 |
|
166 |
+
public function timetodate($timestamp, $format = null)
|
167 |
+
{
|
168 |
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
|
169 |
+
return WPToolset_Field_Date::timetodate( $timestamp, $format );
|
170 |
}
|
171 |
|
172 |
+
public function sanitize_file_name( $filename )
|
173 |
+
{
|
174 |
/**
|
175 |
* replace german special characters
|
176 |
*/
|
177 |
+
$de_from = array('ä','ö','ü','ß','Ä','Ö','Ü');
|
178 |
+
$de_to = array('ae','oe','ue','ss','Ae','Oe','Ue');
|
179 |
$filename = str_replace($de_from, $de_to, $filename);
|
180 |
/**
|
181 |
* replace polish special characters
|
182 |
*/
|
183 |
+
$pl_from = array( 'ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż', 'Ą', 'Ć', 'Ę', 'Ł', 'Ń', 'Ó', 'Ś', 'Ź', 'Ż' );
|
184 |
+
$pl_to = array( 'a', 'c', 'e', 'l', 'n', 'o', 's', 'z', 'z', 'A', 'C', 'E', 'L', 'N', 'O', 'S', 'Z', 'Z' );
|
185 |
$filename = str_replace($pl_from, $pl_to, $filename);
|
186 |
/**
|
187 |
* remove special characters
|
188 |
*/
|
189 |
+
$filename = preg_replace( '/[^A-Za-z0-9\._]/', '-', $filename);
|
190 |
+
$filename = preg_replace( '/[_ ]+/', '-', $filename);
|
191 |
+
$filename = preg_replace( '/%20/', '-', $filename);
|
192 |
return $filename;
|
193 |
}
|
194 |
+
|
195 |
+
public function set_default_repdrag_image( $image ) {
|
196 |
+
return WPTOOLSET_FORMS_RELPATH . '/images/move.png';
|
197 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
}
|
199 |
|
200 |
$GLOBALS['wptoolset_forms'] = new WPToolset_Forms_Bootstrap();
|
embedded/common/toolset-forms/classes/class.audio.php
CHANGED
@@ -6,10 +6,10 @@ require_once 'class.file.php';
|
|
6 |
*
|
7 |
* @author Srdjan
|
8 |
*
|
9 |
-
* $HeadURL:
|
10 |
-
* $LastChangedDate: 2014-
|
11 |
-
* $LastChangedRevision:
|
12 |
-
* $LastChangedBy:
|
13 |
*
|
14 |
*/
|
15 |
class WPToolset_Field_Audio extends WPToolset_Field_File
|
6 |
*
|
7 |
* @author Srdjan
|
8 |
*
|
9 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.audio.php $
|
10 |
+
* $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
|
11 |
+
* $LastChangedRevision: 26350 $
|
12 |
+
* $LastChangedBy: francesco $
|
13 |
*
|
14 |
*/
|
15 |
class WPToolset_Field_Audio extends WPToolset_Field_File
|
embedded/common/toolset-forms/classes/class.checkbox.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
5 |
-
* $LastChangedDate:
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.field_factory.php';
|
@@ -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,17 +34,11 @@ 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 |
-
&& ( 'y' === $value || $value === $data['default_value'])
|
44 |
-
) {
|
45 |
$checked = true;
|
46 |
}
|
47 |
-
|
48 |
// Comment out broken code. This tries to set the previous state after validation fails
|
49 |
//if (!$checked&&$this->getValue()==1) {
|
50 |
// $checked=true;
|
@@ -58,7 +52,6 @@ class WPToolset_Field_Checkbox extends FieldFactory
|
|
58 |
'#value' => $value,
|
59 |
'#default_value' => array_key_exists( 'default_value', $data )? $data['default_value']:null,
|
60 |
'#name' => $this->getName(),
|
61 |
-
'#description' => $this->getDescription(),
|
62 |
'#title' => $this->getTitle(),
|
63 |
'#validate' => $this->getValidationData(),
|
64 |
'#after' => '<input type="hidden" name="_wptoolset_checkbox[' . $this->getId() . ']" value="1" />',
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.checkbox.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 'class.field_factory.php';
|
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 |
+
if ( array_key_exists('default_value', $data) && $value == $data['default_value'] ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
$checked = true;
|
40 |
}
|
41 |
+
|
42 |
// Comment out broken code. This tries to set the previous state after validation fails
|
43 |
//if (!$checked&&$this->getValue()==1) {
|
44 |
// $checked=true;
|
52 |
'#value' => $value,
|
53 |
'#default_value' => array_key_exists( 'default_value', $data )? $data['default_value']:null,
|
54 |
'#name' => $this->getName(),
|
|
|
55 |
'#title' => $this->getTitle(),
|
56 |
'#validate' => $this->getValidationData(),
|
57 |
'#after' => '<input type="hidden" name="_wptoolset_checkbox[' . $this->getId() . ']" value="1" />',
|
embedded/common/toolset-forms/classes/class.checkboxes.php
CHANGED
@@ -4,10 +4,10 @@
|
|
4 |
*
|
5 |
* @author Srdjan
|
6 |
*
|
7 |
-
* $HeadURL:
|
8 |
-
* $LastChangedDate:
|
9 |
-
* $LastChangedRevision:
|
10 |
-
* $LastChangedBy:
|
11 |
*
|
12 |
*/
|
13 |
|
@@ -20,19 +20,18 @@ class WPToolset_Field_Checkboxes extends FieldFactory
|
|
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'])) {
|
28 |
foreach ( $data['options'] as $option_key => $option ) {
|
29 |
-
|
30 |
$checked = isset( $option['checked'] ) ? $option['checked'] : !empty( $value[$option_key] );
|
31 |
-
|
32 |
if (isset($post) && 'auto-draft' == $post->post_status && array_key_exists( 'checked', $option ) && $option['checked']) {
|
33 |
$checked = true;
|
34 |
}
|
35 |
-
|
36 |
// Comment out broken code. This tries to set the previous state after validation fails
|
37 |
//$_values=$this->getValue();
|
38 |
//if (!$checked&&isset($value)&&!empty($value)&&is_array($value)&&in_array($option['value'],$value)) {
|
@@ -47,31 +46,14 @@ class WPToolset_Field_Checkboxes extends FieldFactory
|
|
47 |
'#name' => $option['name']."[]",
|
48 |
//'#inline' => true,
|
49 |
);
|
50 |
-
|
51 |
if ( isset( $option['data-value'] ) ) {
|
52 |
//Fixing https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188528502/comments
|
53 |
$_options[$option_key]['#attributes'] = array('data-value' => $option['data-value']);
|
54 |
}
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
'wpt-form-item',
|
59 |
-
'wpt-form-item-checkbox',
|
60 |
-
'checkbox-'.sanitize_title($option['title'])
|
61 |
-
);
|
62 |
-
/**
|
63 |
-
* filter: cred_checkboxes_class
|
64 |
-
* @param array $clases current array of classes
|
65 |
-
* @parem array $option current option
|
66 |
-
* @param string field type
|
67 |
-
*
|
68 |
-
* @return array
|
69 |
-
*/
|
70 |
-
$clases = apply_filters( 'cred_item_li_class', $clases, $option, 'checkboxes' );
|
71 |
-
$_options[$option_key]['#before'] = sprintf(
|
72 |
-
'<li class="%s">',
|
73 |
-
implode(' ', $clases)
|
74 |
-
);
|
75 |
$_options[$option_key]['#after'] = '</li>';
|
76 |
$_options[$option_key]['#pattern'] = '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
|
77 |
}
|
@@ -80,7 +62,6 @@ class WPToolset_Field_Checkboxes extends FieldFactory
|
|
80 |
$metaform = array(
|
81 |
'#type' => 'checkboxes',
|
82 |
'#options' => $_options,
|
83 |
-
'#description' => $this->getDescription(),
|
84 |
);
|
85 |
if ( is_admin() ) {
|
86 |
$metaform['#title'] = $this->getTitle();
|
4 |
*
|
5 |
* @author Srdjan
|
6 |
*
|
7 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.checkboxes.php $
|
8 |
+
* $LastChangedDate: 2014-08-27 04:51:19 +0200 (Wed, 27 Aug 2014) $
|
9 |
+
* $LastChangedRevision: 26470 $
|
10 |
+
* $LastChangedBy: bruce $
|
11 |
*
|
12 |
*/
|
13 |
|
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'])) {
|
27 |
foreach ( $data['options'] as $option_key => $option ) {
|
28 |
+
|
29 |
$checked = isset( $option['checked'] ) ? $option['checked'] : !empty( $value[$option_key] );
|
30 |
+
|
31 |
if (isset($post) && 'auto-draft' == $post->post_status && array_key_exists( 'checked', $option ) && $option['checked']) {
|
32 |
$checked = true;
|
33 |
}
|
34 |
+
|
35 |
// Comment out broken code. This tries to set the previous state after validation fails
|
36 |
//$_values=$this->getValue();
|
37 |
//if (!$checked&&isset($value)&&!empty($value)&&is_array($value)&&in_array($option['value'],$value)) {
|
46 |
'#name' => $option['name']."[]",
|
47 |
//'#inline' => true,
|
48 |
);
|
49 |
+
|
50 |
if ( isset( $option['data-value'] ) ) {
|
51 |
//Fixing https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188528502/comments
|
52 |
$_options[$option_key]['#attributes'] = array('data-value' => $option['data-value']);
|
53 |
}
|
54 |
+
|
55 |
+
if ( !is_admin() ) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
|
56 |
+
$_options[$option_key]['#before'] = '<li class="wpt-form-item wpt-form-item-checkbox">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
$_options[$option_key]['#after'] = '</li>';
|
58 |
$_options[$option_key]['#pattern'] = '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
|
59 |
}
|
62 |
$metaform = array(
|
63 |
'#type' => 'checkboxes',
|
64 |
'#options' => $_options,
|
|
|
65 |
);
|
66 |
if ( is_admin() ) {
|
67 |
$metaform['#title'] = $this->getTitle();
|
embedded/common/toolset-forms/classes/class.colorpicker.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
-
* $HeadURL:
|
5 |
-
* $LastChangedDate:
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.field_factory.php';
|
@@ -18,7 +18,8 @@ class WPToolset_Field_Colorpicker extends FieldFactory
|
|
18 |
{
|
19 |
public function init()
|
20 |
{
|
21 |
-
|
|
|
22 |
wp_enqueue_style( 'wp-color-picker' );
|
23 |
wp_enqueue_script(
|
24 |
'iris',
|
@@ -37,63 +38,44 @@ class WPToolset_Field_Colorpicker extends FieldFactory
|
|
37 |
$colorpicker_l10n = array(
|
38 |
'clear' => __( 'Clear' ),
|
39 |
'defaultString' => __( 'Default', 'wpv-views' ),
|
40 |
-
'pick' => __( 'Select', 'wpv-views' )
|
41 |
);
|
42 |
wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n );
|
43 |
}
|
44 |
-
|
45 |
'wptoolset-field-colorpicker',
|
46 |
WPTOOLSET_FORMS_RELPATH . '/js/colorpicker.js',
|
47 |
array('iris'),
|
48 |
WPTOOLSET_FORMS_VERSION,
|
49 |
true
|
50 |
);
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
static public function registerScripts()
|
56 |
{
|
|
|
57 |
}
|
58 |
|
59 |
public function enqueueScripts()
|
60 |
{
|
61 |
-
|
62 |
-
}
|
63 |
-
|
64 |
-
public function addTypeValidation($validation) {
|
65 |
-
$validation['hexadecimal'] = array(
|
66 |
-
'args' => array(
|
67 |
-
'hexadecimal'
|
68 |
-
),
|
69 |
-
'message' => __( 'You can add valid hexadecimal.', 'wpv-views' ),
|
70 |
-
);
|
71 |
-
return $validation;
|
72 |
}
|
73 |
|
74 |
public function metaform()
|
75 |
{
|
76 |
-
$
|
77 |
-
$
|
78 |
-
$this->setValidationData($validation);
|
79 |
-
|
80 |
-
$attributes = $this->getAttr();
|
81 |
-
if ( isset($attributes['class'] ) ) {
|
82 |
-
$attributes['class'] .= ' ';
|
83 |
-
} else {
|
84 |
-
$attributes['class'] = '';
|
85 |
-
}
|
86 |
-
$attributes['class'] = 'js-wpt-colorpicker';
|
87 |
-
|
88 |
$form = array();
|
89 |
$form['name'] = array(
|
90 |
'#type' => 'textfield',
|
91 |
'#title' => $this->getTitle(),
|
92 |
-
|
93 |
'#value' => $this->getValue(),
|
94 |
'#name' => $this->getName(),
|
95 |
-
'#attributes' => $
|
96 |
-
'#validate' => $
|
97 |
'#after' => '',
|
98 |
'#repetitive' => $this->isRepetitive(),
|
99 |
);
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.colorpicker.php $
|
5 |
+
* $LastChangedDate: 2014-07-12 10:38:18 +0200 (Sat, 12 Jul 2014) $
|
6 |
+
* $LastChangedRevision: 24908 $
|
7 |
+
* $LastChangedBy: gen $
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.field_factory.php';
|
18 |
{
|
19 |
public function init()
|
20 |
{
|
21 |
+
|
22 |
+
if ( !is_admin() ) {
|
23 |
wp_enqueue_style( 'wp-color-picker' );
|
24 |
wp_enqueue_script(
|
25 |
'iris',
|
38 |
$colorpicker_l10n = array(
|
39 |
'clear' => __( 'Clear' ),
|
40 |
'defaultString' => __( 'Default', 'wpv-views' ),
|
41 |
+
'pick' => __( 'Select Color', 'wpv-views' )
|
42 |
);
|
43 |
wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n );
|
44 |
}
|
45 |
+
wp_register_script(
|
46 |
'wptoolset-field-colorpicker',
|
47 |
WPTOOLSET_FORMS_RELPATH . '/js/colorpicker.js',
|
48 |
array('iris'),
|
49 |
WPTOOLSET_FORMS_VERSION,
|
50 |
true
|
51 |
);
|
52 |
+
wp_enqueue_script( 'wptoolset-field-colorpicker' );
|
53 |
+
|
54 |
+
}
|
55 |
|
56 |
static public function registerScripts()
|
57 |
{
|
58 |
+
|
59 |
}
|
60 |
|
61 |
public function enqueueScripts()
|
62 |
{
|
63 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
|
66 |
public function metaform()
|
67 |
{
|
68 |
+
$classes = array();
|
69 |
+
$classes[] = 'js-wpt-colorpicker';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
$form = array();
|
71 |
$form['name'] = array(
|
72 |
'#type' => 'textfield',
|
73 |
'#title' => $this->getTitle(),
|
74 |
+
'#description' => $this->getDescription(),
|
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 |
);
|
embedded/common/toolset-forms/classes/class.conditional.php
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/*
|
4 |
* - Checks conditionals when form is displayed and values changed
|
5 |
* - Checks simple conditionals using JS
|
@@ -41,11 +40,11 @@
|
|
41 |
* 'custom' => '($wpcf-text = show) OR ($wpcf-date > '21-01-2014')'
|
42 |
* );
|
43 |
*/
|
44 |
-
if (!defined('ICL_COMMON_FUNCTIONS')) {
|
45 |
-
|
46 |
}
|
47 |
if (!function_exists('wpv_filter_parse_date')) {
|
48 |
-
|
49 |
}
|
50 |
|
51 |
require_once WPTOOLSET_COMMON_PATH . '/expression-parser/parser.php';
|
@@ -58,7 +57,9 @@ require_once WPTOOLSET_COMMON_PATH . '/expression-parser/parser.php';
|
|
58 |
*
|
59 |
* @author Srdjan
|
60 |
*/
|
61 |
-
|
|
|
|
|
62 |
|
63 |
private $__formID;
|
64 |
protected $_collected = array(), $_triggers = array(), $_fields = array(), $_custom_triggers = array(), $_custom_fields = array();
|
@@ -68,26 +69,30 @@ class WPToolset_Forms_Conditional {
|
|
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',
|
75 |
-
|
|
|
|
|
76 |
$js_data = array(
|
77 |
-
|
78 |
);
|
79 |
-
wp_localize_script('wptoolset-form-conditional', 'wptConditional', $js_data);
|
80 |
|
81 |
-
|
82 |
-
|
|
|
|
|
83 |
$js_data = array(
|
84 |
-
|
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,8 +102,8 @@ class WPToolset_Forms_Conditional {
|
|
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,44 +113,38 @@ class WPToolset_Forms_Conditional {
|
|
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 |
-
|
117 |
-
|
118 |
-
|
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)
|
132 |
-
if (isset($config)
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
149 |
}
|
150 |
}
|
151 |
}
|
@@ -156,21 +155,21 @@ class WPToolset_Forms_Conditional {
|
|
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,50 +180,51 @@ class WPToolset_Forms_Conditional {
|
|
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
|
195 |
}
|
196 |
|
197 |
$passedOne = false;
|
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',
|
205 |
-
|
206 |
-
$value =
|
|
|
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,81 +271,88 @@ class WPToolset_Forms_Conditional {
|
|
271 |
* @param type $evaluate
|
272 |
* @return boolean
|
273 |
*/
|
274 |
-
public static function evaluateCustom($evaluate, $values) {
|
275 |
-
|
276 |
-
//
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
}
|
284 |
-
|
285 |
-
$fields = self::extractFields($evaluate);
|
286 |
-
$evaluate = self::_update_values_in_expression($evaluate, $fields, $values);
|
287 |
-
|
288 |
-
$check = false;
|
289 |
try {
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
}
|
298 |
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
|
303 |
-
private static function _update_values_in_expression($evaluate, $fields, $values) {
|
304 |
|
305 |
-
|
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 |
-
|
310 |
-
usort($keys, 'WPToolset_Forms_Conditional::sortByLength');
|
311 |
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
if (is_numeric($value)) {
|
318 |
-
$value = '\'' . $value . '\'';
|
319 |
-
}
|
320 |
|
321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
// workaround for datepicker data to cover all cases
|
323 |
-
if
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
337 |
}
|
338 |
}
|
339 |
|
340 |
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
|
347 |
-
|
348 |
-
|
349 |
|
350 |
/**
|
351 |
* Extracts fields from custom conditional statement.
|
@@ -353,62 +360,62 @@ class WPToolset_Forms_Conditional {
|
|
353 |
* @param type $evaluate
|
354 |
* @return type
|
355 |
*/
|
356 |
-
public static function extractFields($evaluate) {
|
357 |
-
|
358 |
-
//
|
359 |
-
|
360 |
-
|
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]/',
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
$
|
|
|
|
|
374 |
}
|
375 |
}
|
376 |
// if new version $(field-value) use this regex
|
377 |
-
|
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 |
-
|
|
|
398 |
$occurrences = preg_match_all('/(\\w+)\(([^\)]*)\)/', $evaluate, $matches);
|
399 |
|
400 |
-
if
|
|
|
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
|
407 |
-
|
|
|
408 |
}
|
409 |
|
410 |
-
if
|
411 |
-
$evaluate = str_replace($matches[0][$i], $result, $evaluate);
|
412 |
}
|
413 |
}
|
414 |
}
|
@@ -421,25 +428,26 @@ class WPToolset_Forms_Conditional {
|
|
421 |
*/
|
422 |
public static function ajaxCustomConditional() {
|
423 |
$res = array('passed' => array(), 'failed' => array());
|
424 |
-
|
425 |
-
foreach ($conditional
|
426 |
-
|
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',
|
|
|
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,9 +456,11 @@ class WPToolset_Forms_Conditional {
|
|
448 |
*
|
449 |
* @param type $config
|
450 |
*/
|
451 |
-
public function actionFieldClass($config) {
|
452 |
if (
|
453 |
-
|
|
|
|
|
454 |
) {
|
455 |
echo ' wpt-hidden js-wpt-remove-on-submit js-wpt-validation-ignore';
|
456 |
}
|
@@ -461,7 +471,7 @@ class WPToolset_Forms_Conditional {
|
|
461 |
*
|
462 |
* @return type
|
463 |
*/
|
464 |
-
public function getData()
|
465 |
$this->_parseData();
|
466 |
return array(
|
467 |
'triggers' => $this->_triggers,
|
@@ -473,36 +483,35 @@ class WPToolset_Forms_Conditional {
|
|
473 |
|
474 |
}
|
475 |
|
476 |
-
if (!class_exists('WPV_Handle_Users_Functions')) {
|
477 |
|
478 |
-
|
|
|
|
|
|
|
479 |
|
480 |
private static $field;
|
481 |
|
482 |
-
public static function get_user_field($field)
|
483 |
-
|
484 |
-
|
485 |
|
486 |
self::$field = str_replace("'", '', $field);
|
487 |
|
488 |
-
$ret = self::get_info();
|
489 |
|
490 |
-
if
|
491 |
-
return "'" . $ret . "'";
|
492 |
|
493 |
return false;
|
494 |
}
|
495 |
|
496 |
-
private static function get_info()
|
497 |
{
|
498 |
-
if (!is_user_logged_in()) {
|
499 |
-
return false;
|
500 |
-
}
|
501 |
global $current_user;
|
502 |
|
503 |
get_currentuserinfo();
|
504 |
|
505 |
-
switch
|
|
|
506 |
case 'role':
|
507 |
return isset($current_user->roles[0]) ? $current_user->roles[0] : 'Subscriber';
|
508 |
break;
|
@@ -522,7 +531,5 @@ if (!class_exists('WPV_Handle_Users_Functions')) {
|
|
522 |
|
523 |
return false;
|
524 |
}
|
525 |
-
|
526 |
}
|
527 |
-
|
528 |
}
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
* - Checks conditionals when form is displayed and values changed
|
4 |
* - Checks simple conditionals using JS
|
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 |
*
|
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 |
*
|
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(__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 |
*
|
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 |
* 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 |
*/
|
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 |
* @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 false;
|
194 |
}
|
195 |
|
196 |
$passedOne = false;
|
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 |
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 |
+
$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 |
* @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 |
*/
|
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 |
*
|
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 |
*
|
472 |
* @return type
|
473 |
*/
|
474 |
+
public function getData(){
|
475 |
$this->_parseData();
|
476 |
return array(
|
477 |
'triggers' => $this->_triggers,
|
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 |
|
532 |
return false;
|
533 |
}
|
|
|
534 |
}
|
|
|
535 |
}
|
embedded/common/toolset-forms/classes/class.credaudio.php
CHANGED
@@ -7,10 +7,10 @@ require_once 'class.audio.php';
|
|
7 |
*
|
8 |
* @author Srdjan
|
9 |
*
|
10 |
-
* $HeadURL:
|
11 |
-
* $LastChangedDate: 2014-
|
12 |
-
* $LastChangedRevision:
|
13 |
-
* $LastChangedBy:
|
14 |
*
|
15 |
*/
|
16 |
class WPToolset_Field_Credaudio extends WPToolset_Field_Credfile
|
7 |
*
|
8 |
* @author Srdjan
|
9 |
*
|
10 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.credaudio.php $
|
11 |
+
* $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
|
12 |
+
* $LastChangedRevision: 26350 $
|
13 |
+
* $LastChangedBy: francesco $
|
14 |
*
|
15 |
*/
|
16 |
class WPToolset_Field_Credaudio extends WPToolset_Field_Credfile
|
embedded/common/toolset-forms/classes/class.credfile.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
-
* $HeadURL:
|
5 |
-
* $LastChangedDate: 2014-
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.textfield.php';
|
@@ -111,7 +111,7 @@ class WPToolset_Field_Credfile extends WPToolset_Field_Textfield
|
|
111 |
);
|
112 |
$form[] = array(
|
113 |
'#type' => 'markup',
|
114 |
-
'#markup' => '<input type="button"' . $delete_input_showhide . ' data-action="delete" class="js-wpt-credfile-delete wpt-credfile-delete' . $button_extra_classnames . '" value="' . esc_attr( __( '
|
115 |
);
|
116 |
$form[] = array(
|
117 |
'#type' => 'hidden',
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.credfile.php $
|
5 |
+
* $LastChangedDate: 2014-08-08 23:11:46 +0200 (Fri, 08 Aug 2014) $
|
6 |
+
* $LastChangedRevision: 25806 $
|
7 |
+
* $LastChangedBy: francesco $
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.textfield.php';
|
111 |
);
|
112 |
$form[] = array(
|
113 |
'#type' => 'markup',
|
114 |
+
'#markup' => '<input type="button"' . $delete_input_showhide . ' data-action="delete" class="js-wpt-credfile-delete wpt-credfile-delete' . $button_extra_classnames . '" value="' . esc_attr( __( 'Delete', 'wpv-views' ) ) . '" />',
|
115 |
);
|
116 |
$form[] = array(
|
117 |
'#type' => 'hidden',
|
embedded/common/toolset-forms/classes/class.credimage.php
CHANGED
@@ -7,10 +7,10 @@ require_once 'class.image.php';
|
|
7 |
*
|
8 |
* @author Srdjan
|
9 |
*
|
10 |
-
* $HeadURL:
|
11 |
-
* $LastChangedDate: 2014-
|
12 |
-
* $LastChangedRevision:
|
13 |
-
* $LastChangedBy:
|
14 |
*
|
15 |
*/
|
16 |
class WPToolset_Field_Credimage extends WPToolset_Field_Credfile
|
7 |
*
|
8 |
* @author Srdjan
|
9 |
*
|
10 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.credimage.php $
|
11 |
+
* $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
|
12 |
+
* $LastChangedRevision: 26350 $
|
13 |
+
* $LastChangedBy: francesco $
|
14 |
*
|
15 |
*/
|
16 |
class WPToolset_Field_Credimage extends WPToolset_Field_Credfile
|
embedded/common/toolset-forms/classes/class.credvideo.php
CHANGED
@@ -7,10 +7,10 @@ require_once 'class.video.php';
|
|
7 |
*
|
8 |
* @author Srdjan
|
9 |
*
|
10 |
-
* $HeadURL:
|
11 |
-
* $LastChangedDate: 2014-
|
12 |
-
* $LastChangedRevision:
|
13 |
-
* $LastChangedBy:
|
14 |
*
|
15 |
*/
|
16 |
class WPToolset_Field_Credvideo extends WPToolset_Field_Credfile
|
7 |
*
|
8 |
* @author Srdjan
|
9 |
*
|
10 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.credvideo.php $
|
11 |
+
* $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
|
12 |
+
* $LastChangedRevision: 26350 $
|
13 |
+
* $LastChangedBy: francesco $
|
14 |
*
|
15 |
*/
|
16 |
class WPToolset_Field_Credvideo extends WPToolset_Field_Credfile
|
embedded/common/toolset-forms/classes/class.date.php
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
require_once 'class.field_factory.php';
|
4 |
if (!function_exists('adodb_mktime')) {
|
5 |
-
|
6 |
}
|
7 |
|
8 |
/**
|
@@ -12,13 +11,13 @@ if (!function_exists('adodb_mktime')) {
|
|
12 |
*/
|
13 |
class WPToolset_Field_Date extends FieldFactory
|
14 |
{
|
|
|
15 |
// 15/10/1582 00:00 - 31/12/3000 23:59
|
16 |
protected static $_mintimestamp = -12219292800, $_maxtimestamp = 32535215940;
|
17 |
|
18 |
public function init()
|
19 |
{
|
20 |
-
|
21 |
-
}
|
22 |
|
23 |
public static function registerScripts()
|
24 |
{
|
@@ -28,19 +27,25 @@ class WPToolset_Field_Date extends FieldFactory
|
|
28 |
{
|
29 |
}
|
30 |
|
31 |
-
public static function addFilters()
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
}
|
36 |
// Filter validation
|
37 |
-
add_filter('wptoolset_validation_value_date',
|
38 |
-
|
39 |
-
add_filter(
|
|
|
|
|
|
|
40 |
// Filter conditional
|
41 |
-
add_filter('wptoolset_conditional_args_php',
|
42 |
-
|
43 |
-
add_filter(
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
|
46 |
public function enqueueScripts()
|
@@ -51,195 +56,178 @@ class WPToolset_Field_Date extends FieldFactory
|
|
51 |
{
|
52 |
}
|
53 |
|
54 |
-
public function metaform()
|
55 |
-
{
|
56 |
$time_value = $this->getValue();
|
57 |
$datepicker = $hour = $minute = null;
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
$data = $this->getData();
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
$def_class = 'js-wpt-date';
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
$form = array();
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
if (isset($data['attribute']) && isset($data['attribute']['placeholder'])) {
|
134 |
-
$attr_visible['placeholder'] = $data['attribute']['placeholder'];
|
135 |
-
}
|
136 |
-
|
137 |
-
$form[] = array(
|
138 |
'#type' => 'textfield',
|
139 |
'#title' => $title,
|
140 |
-
|
141 |
'#attributes' => $attr_visible,
|
142 |
-
'#name' =>
|
143 |
'#value' => $datepicker,
|
144 |
-
'#inline' => true,
|
145 |
);
|
146 |
-
|
147 |
'#type' => 'hidden',
|
148 |
'#title' => $title,
|
149 |
'#attributes' => $attr_hidden,
|
150 |
'#name' => $this->getName() . '[datepicker]',
|
151 |
'#value' => $timestamp,
|
152 |
-
|
153 |
'#repetitive' => $this->isRepetitive(),
|
154 |
);
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
if (!empty($data['add_time'])) {
|
171 |
// Shared attributes
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
175 |
}
|
176 |
-
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
// Hour
|
181 |
$hours = 24;
|
182 |
$options = array();
|
183 |
-
for ($index = 0; $index < $hours; $index++) {
|
184 |
$prefix = $index < 10 ? '0' : '';
|
185 |
$options[$index] = array(
|
186 |
-
'#title' => $prefix . strval($index),
|
187 |
'#value' => $index,
|
188 |
);
|
189 |
}
|
190 |
$hour_element = array(
|
191 |
'#type' => 'select',
|
192 |
-
'#
|
193 |
'#options' => $options,
|
194 |
'#default_value' => $hour,
|
195 |
'#name' => $this->getName() . '[hour]',
|
196 |
'#inline' => true,
|
197 |
-
'#attributes' => array('title' => esc_attr(__('Select', 'wpv-views'))." Date"),
|
198 |
);
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
$form[] = $hour_element;
|
203 |
// Minutes
|
204 |
$minutes = 60;
|
205 |
$options = array();
|
206 |
-
for ($index = 0; $index < $minutes; $index++) {
|
207 |
$prefix = $index < 10 ? '0' : '';
|
208 |
$options[$index] = array(
|
209 |
-
'#title' => $prefix . strval($index),
|
210 |
'#value' => $index,
|
211 |
);
|
212 |
}
|
213 |
-
|
214 |
'#type' => 'select',
|
215 |
-
'#
|
216 |
'#options' => $options,
|
217 |
'#default_value' => $minute,
|
218 |
'#name' => $this->getName() . '[minute]',
|
219 |
'#inline' => true,
|
220 |
-
'#attributes' => array('title' => esc_attr(__('Select minute', 'wpv-views'))),
|
221 |
);
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
$form[] = $minute_element;
|
226 |
}
|
227 |
|
228 |
-
$form[] = array(
|
229 |
-
'#type' => 'markup',
|
230 |
-
'#inline' => true,
|
231 |
-
'#markup' => sprintf(
|
232 |
-
'<input type="button" class="button button-secondary js-wpt-date-clear wpt-date-clear" value="%s" %s/>',
|
233 |
-
esc_attr(__('Clear', 'wpv-views'))." Date",
|
234 |
-
/**
|
235 |
-
* show button if array is empty or timestamp in array is
|
236 |
-
* empty
|
237 |
-
*/
|
238 |
-
empty($time_value) ||
|
239 |
-
(isset($time_value['timestamp']) &&
|
240 |
-
empty($time_value['timestamp']))? 'style="display:none" ':''
|
241 |
-
),
|
242 |
-
);
|
243 |
return $form;
|
244 |
}
|
245 |
|
@@ -248,154 +236,141 @@ class WPToolset_Field_Date extends FieldFactory
|
|
248 |
return WPToolset_Field_Date_Scripts::getDateFormat();
|
249 |
}
|
250 |
|
251 |
-
protected function _dateToStrftime($format)
|
252 |
-
|
253 |
-
$format = str_replace('
|
254 |
-
$format = str_replace('
|
255 |
-
$format = str_replace('
|
256 |
-
$format = str_replace('
|
257 |
-
$format = str_replace('
|
258 |
-
$format = str_replace('w', '%w', $format);
|
259 |
|
260 |
-
$format = str_replace('W', '%W', $format);
|
261 |
|
262 |
-
$format = str_replace('F', '%B', $format);
|
263 |
-
$format = str_replace('m', '%m', $format);
|
264 |
-
$format = str_replace('M', '%b', $format);
|
265 |
-
$format = str_replace('n', '%m', $format);
|
266 |
|
267 |
-
$format = str_replace('o', '%g', $format);
|
268 |
-
$format = str_replace('Y', '%Y', $format);
|
269 |
-
$format = str_replace('y', '%y', $format);
|
270 |
|
271 |
return $format;
|
272 |
}
|
273 |
|
274 |
-
public static function filterValidationValue($value)
|
275 |
-
|
276 |
-
/**
|
277 |
-
* validate fimestamp range is possible
|
278 |
-
*/
|
279 |
-
if (isset($value['timestamp'])) {
|
280 |
-
return $value['timestamp'];
|
281 |
-
}
|
282 |
-
if (isset($value['datepicker'])) {
|
283 |
return $value['datepicker'];
|
284 |
}
|
285 |
return $value;
|
286 |
}
|
287 |
|
288 |
-
public static function filterValidationRuleJs($rule)
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
}
|
295 |
}
|
296 |
|
297 |
-
public static function filterValidationArgsPhp($args, $rule)
|
298 |
-
|
299 |
-
if ($rule == 'date') {
|
300 |
return array('$value', self::getDateFormat());
|
301 |
}
|
302 |
return $args;
|
303 |
}
|
304 |
|
305 |
-
public static function filterConditionalArgsJs($args, $type)
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
$arg = self::strtotime($arg);
|
312 |
}
|
313 |
}
|
314 |
}
|
315 |
return $args;
|
316 |
}
|
317 |
|
318 |
-
public static function filterConditionalArgsPhp($args, $type)
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
$arg = self::filterConditionalValuePhp($arg, $type);
|
323 |
}
|
324 |
}
|
325 |
return $args;
|
326 |
}
|
327 |
|
328 |
-
public static function filterConditionalValuePhp($value, $type)
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
$value = self::strtotime($value);
|
334 |
}
|
335 |
// Use timestamp with PHP
|
336 |
// Convert back/forward to have rounded timestamp (no H and i)
|
337 |
-
|
338 |
//$value = self::strtotime( self::timetodate( $value ) );
|
339 |
}
|
340 |
return $value;
|
341 |
}
|
342 |
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
public static function strtotime($value, $format = null)
|
351 |
{
|
352 |
-
if (is_null($format)) {
|
353 |
$format = self::getDateFormat();
|
354 |
}
|
355 |
/**
|
356 |
* add exception to handle short year
|
357 |
*/
|
358 |
-
if ('d/m/y' == $format) {
|
359 |
-
preg_match_all('/(\d{2})/', $value, $value);
|
360 |
-
$value[0][2] += $value[0][2] < 70
|
361 |
-
$value = implode('-', $value[0]);
|
362 |
}
|
363 |
-
if (strpos($format, 'd/m/Y') !== false) {
|
364 |
// strtotime requires a dash or dot separator to determine dd/mm/yyyy format
|
365 |
-
preg_match('/\d{2}\/\d{2}\/\d{4}/', $value, $matches);
|
366 |
-
if (!empty($matches)) {
|
367 |
-
foreach ($matches as $match) {
|
368 |
-
$value = str_replace(
|
|
|
369 |
}
|
370 |
}
|
371 |
}
|
372 |
try {
|
373 |
-
$date = new DateTime($value);
|
374 |
-
} catch (Exception $e) {
|
375 |
return false;
|
376 |
}
|
377 |
-
$timestamp = $date->format("U");
|
378 |
-
return self::_isTimestampInRange($timestamp) ? $timestamp : false;
|
379 |
}
|
380 |
|
381 |
-
|
382 |
-
public static function timetodate($timestamp, $format = null)
|
383 |
{
|
384 |
-
return WPToolset_Field_Date_Scripts::timetodate($timestamp, $format);
|
385 |
}
|
386 |
|
387 |
-
protected static function _isTimestampInRange($timestamp)
|
388 |
{
|
389 |
return WPToolset_Field_Date_Scripts::_isTimestampInRange($timestamp);
|
390 |
}
|
391 |
|
392 |
/**
|
393 |
* DEPRECATED
|
394 |
-
|
395 |
-
|
396 |
*/
|
397 |
-
public static function timeIsValid($time)
|
398 |
-
{
|
399 |
/*
|
400 |
* http://php.net/manual/en/function.strtotime.php
|
401 |
* The valid range of a timestamp is typically
|
@@ -409,24 +384,23 @@ class WPToolset_Field_Date extends FieldFactory
|
|
409 |
* This means that e.g. dates prior to Jan 1, 1970 will not
|
410 |
* work on Windows, some Linux distributions,
|
411 |
* and a few other operating systems.
|
412 |
-
* PHP 5.1.0 and newer versions overcome this limitation though.
|
413 |
*/
|
414 |
// MIN 'Jan 1, 1970' - 0 | Fri, 13 Dec 1901 20:45:54 UTC
|
415 |
$_min_time = self::timeNegativeSupported() ? -2147483646 : 0;
|
416 |
// MAX 'Tue, 19 Jan 2038 03:14:07 UTC' - 2147483647
|
417 |
$_max_time = 2147483647;
|
418 |
|
419 |
-
return is_numeric($time) && $_min_time <= intval($time) && intval($time) <= $_max_time;
|
420 |
}
|
421 |
|
422 |
/**
|
423 |
* DEPRECATED
|
424 |
-
|
425 |
-
|
426 |
*/
|
427 |
-
public static function timeNegativeSupported()
|
428 |
-
|
429 |
-
return strtotime('Fri, 13 Dec 1950 20:45:54 UTC') === -601010046;
|
430 |
}
|
431 |
|
432 |
}
|
1 |
<?php
|
|
|
2 |
require_once 'class.field_factory.php';
|
3 |
if (!function_exists('adodb_mktime')) {
|
4 |
+
require_once WPTOOLSET_FORMS_ABSPATH . '/lib/adodb-time.inc.php';
|
5 |
}
|
6 |
|
7 |
/**
|
11 |
*/
|
12 |
class WPToolset_Field_Date extends FieldFactory
|
13 |
{
|
14 |
+
|
15 |
// 15/10/1582 00:00 - 31/12/3000 23:59
|
16 |
protected static $_mintimestamp = -12219292800, $_maxtimestamp = 32535215940;
|
17 |
|
18 |
public function init()
|
19 |
{
|
20 |
+
}
|
|
|
21 |
|
22 |
public static function registerScripts()
|
23 |
{
|
27 |
{
|
28 |
}
|
29 |
|
30 |
+
public static function addFilters(){
|
31 |
+
if ( has_filter( 'wptoolset_validation_value_date',
|
32 |
+
array('WPToolset_Field_Date', 'filterValidationValue') ) )
|
33 |
+
return;
|
|
|
34 |
// Filter validation
|
35 |
+
add_filter( 'wptoolset_validation_value_date',
|
36 |
+
array('WPToolset_Field_Date', 'filterValidationValue') );
|
37 |
+
add_filter( 'wptoolset_validation_rule_js',
|
38 |
+
array('WPToolset_Field_Date', 'filterValidationRuleJs') );
|
39 |
+
add_filter( 'wptoolset_validation_args_php',
|
40 |
+
array('WPToolset_Field_Date', 'filterValidationArgsPhp'), 10, 2 );
|
41 |
// Filter conditional
|
42 |
+
add_filter( 'wptoolset_conditional_args_php',
|
43 |
+
array('WPToolset_Field_Date', 'filterConditionalArgsPhp'), 10, 2 );
|
44 |
+
add_filter( 'wptoolset_conditional_value_php',
|
45 |
+
array('WPToolset_Field_Date', 'filterConditionalValuePhp'), 10,
|
46 |
+
2 );
|
47 |
+
add_filter( 'wptoolset_conditional_args_js',
|
48 |
+
array('WPToolset_Field_Date', 'filterConditionalArgsJs'), 10, 2 );
|
49 |
}
|
50 |
|
51 |
public function enqueueScripts()
|
56 |
{
|
57 |
}
|
58 |
|
59 |
+
public function metaform() {
|
|
|
60 |
$time_value = $this->getValue();
|
61 |
$datepicker = $hour = $minute = null;
|
62 |
+
$timestamp = false;
|
63 |
+
$readonly = false;
|
64 |
+
if ( is_admin() ) {
|
65 |
+
// In this case, getValue returns the timestamp stored as postmeta value on the database
|
66 |
+
// So we compose $timestamp, $datepicker, $hour and $minute based on that value
|
67 |
+
if ( !empty( $time_value ) && $time_value != '0' ) {
|
68 |
+
if ( !is_numeric( $time_value ) ) {
|
69 |
+
$timestamp = self::strtotime( $time_value );
|
70 |
+
} else {
|
71 |
+
$timestamp = $time_value;
|
72 |
+
}
|
73 |
+
if ( $timestamp !== false && self::_isTimestampInRange( $timestamp ) ) {
|
74 |
+
$datepicker = self::timetodate( $timestamp );
|
75 |
+
$hour = self::timetodate( $timestamp, 'H' );
|
76 |
+
$minute = self::timetodate( $timestamp, 'i' );
|
77 |
+
}
|
78 |
+
}
|
79 |
+
} else {
|
80 |
+
// We are on a CRED form, on frontend, so getVAlue returns nothing or a string or an array of the kind array( 'datepicker' =>, 'hour' =>, 'minute' => )
|
81 |
+
// Note that even if the array is passed, 'hour' and 'minute' will only be passed if there are any
|
82 |
+
if ( !empty( $time_value ) ) {
|
83 |
+
if ( is_array( $time_value ) ) {
|
84 |
+
if ( isset ( $time_value['timestamp'] ) && is_numeric( $time_value['timestamp'] ) && self::_isTimestampInRange( $time_value['timestamp'] ) ) {
|
85 |
+
$timestamp = $time_value['timestamp'];
|
86 |
+
$datepicker = self::timetodate( $timestamp );
|
87 |
+
} else if ( isset( $time_value['datepicker'] ) && $time_value['datepicker'] !== false && is_numeric( $time_value['datepicker'] ) && self::_isTimestampInRange( $time_value['datepicker'] ) ) {
|
88 |
+
$timestamp = $time_value['datepicker'];
|
89 |
+
$datepicker = self::timetodate( $timestamp );
|
90 |
+
}
|
91 |
+
if ( isset( $time_value['hour'] ) && is_numeric( $time_value['hour'] ) ) {
|
92 |
+
$hour = $time_value['hour'];
|
93 |
+
}
|
94 |
+
if ( isset( $time_value['minute'] ) && is_numeric( $time_value['minute'] ) ) {
|
95 |
+
$minute = $time_value['minute'];
|
96 |
+
}
|
97 |
+
} else {
|
98 |
+
if ( is_numeric( $time_value ) && self::_isTimestampInRange( $time_value ) ) {
|
99 |
+
$timestamp = $time_value;
|
100 |
+
$datepicker = self::timetodate( $timestamp );
|
101 |
+
} else {
|
102 |
+
$timestamp = self::strtotime( $time_value );
|
103 |
+
$datepicker = $time_value;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
$data = $this->getData();
|
109 |
+
if ( !$timestamp ) {
|
110 |
+
// If there is no timestamp, we need to make it an empty string
|
111 |
+
// A false value would render the hidden field with a value of 1
|
112 |
+
$timestamp = '';
|
113 |
+
$datepicker = null;
|
114 |
+
}
|
115 |
+
|
|
|
116 |
$def_class = 'js-wpt-date';
|
117 |
+
|
118 |
+
$def_class_aux = 'js-wpt-date-auxiliar';
|
119 |
+
|
120 |
+
if ( isset( $data['attribute'] ) && isset( $data['attribute']['readonly'] ) && $data['attribute']['readonly'] == 'readonly' ) {
|
121 |
+
$def_class .= ' js-wpv-date-readonly';
|
122 |
+
$def_class_aux .= ' js-wpt-date-readonly';
|
123 |
+
$readonly = true;
|
124 |
+
}
|
125 |
+
|
126 |
$form = array();
|
127 |
+
|
128 |
+
$validate = $this->getValidationData();
|
129 |
+
$title = $this->getTitle();
|
130 |
+
|
131 |
+
if ( isset( $validate['required'] ) && !empty( $title ) ) {
|
132 |
+
// Asterisk
|
133 |
+
$title .= '*';
|
134 |
+
}
|
135 |
+
|
136 |
+
$attr_visible = array('class' => $def_class, 'style' => 'display:inline;width:150px;position:relative;z-index:20;', 'readonly' => 'readonly');
|
137 |
+
$attr_hidden = array('class' => $def_class_aux, 'data-ts' => $timestamp, 'data-wpt-type' => 'date' );
|
138 |
+
|
139 |
+
if ( isset( $data['attribute'] ) && isset( $data['attribute']['placeholder'] ) ) {
|
140 |
+
$attr_visible['placeholder'] = $data['attribute']['placeholder'];
|
141 |
+
}
|
142 |
+
|
143 |
+
$form[] = array(
|
|
|
|
|
|
|
|
|
|
|
144 |
'#type' => 'textfield',
|
145 |
'#title' => $title,
|
146 |
+
'#description' => $this->getDescription(),
|
147 |
'#attributes' => $attr_visible,
|
148 |
+
'#name' => '',
|
149 |
'#value' => $datepicker,
|
|
|
150 |
);
|
151 |
+
$form[] = array(
|
152 |
'#type' => 'hidden',
|
153 |
'#title' => $title,
|
154 |
'#attributes' => $attr_hidden,
|
155 |
'#name' => $this->getName() . '[datepicker]',
|
156 |
'#value' => $timestamp,
|
157 |
+
'#validate' => $validate,
|
158 |
'#repetitive' => $this->isRepetitive(),
|
159 |
);
|
160 |
+
|
161 |
+
/*
|
162 |
+
// This was the old implementaton
|
163 |
+
// We have implemented the above one because we need a hidden field to hold the timestamp
|
164 |
+
// And the visible text input field to display the date string to the user
|
165 |
+
$form[] = array(
|
166 |
+
'#type' => 'textfield',
|
167 |
+
'#title' => $this->getTitle(),
|
168 |
+
'#attributes' => array('class' => $def_class, 'style' => 'width:150px;'),
|
169 |
+
'#name' => $this->getName() . '[datepicker]',
|
170 |
+
'#value' => $timestamp,
|
171 |
+
'#validate' => $this->getValidationData(),
|
172 |
+
'#repetitive' => $this->isRepetitive(),
|
173 |
+
);
|
174 |
+
*/
|
175 |
+
if ( !empty( $data['add_time'] ) ) {
|
176 |
// Shared attributes
|
177 |
+
$attributes_hour_minute = array();
|
178 |
+
if ( $readonly ) {
|
179 |
+
$attributes_hour_minute['disabled'] = 'disabled' ;
|
180 |
+
}
|
181 |
+
if ( array_key_exists( 'use_bootstrap', $this->_data ) && $this->_data['use_bootstrap'] ) {
|
182 |
+
$attributes_hour_minute['style'] = 'display:inline;width:auto;' ;
|
183 |
}
|
184 |
+
|
185 |
+
// Hour
|
|
|
|
|
|
|
186 |
$hours = 24;
|
187 |
$options = array();
|
188 |
+
for ( $index = 0; $index < $hours; $index++ ) {
|
189 |
$prefix = $index < 10 ? '0' : '';
|
190 |
$options[$index] = array(
|
191 |
+
'#title' => $prefix . strval( $index ),
|
192 |
'#value' => $index,
|
193 |
);
|
194 |
}
|
195 |
$hour_element = array(
|
196 |
'#type' => 'select',
|
197 |
+
'#title' => __( 'Hour', 'wpv-views' ),
|
198 |
'#options' => $options,
|
199 |
'#default_value' => $hour,
|
200 |
'#name' => $this->getName() . '[hour]',
|
201 |
'#inline' => true,
|
|
|
202 |
);
|
203 |
+
if ( !empty( $attributes_hour_minute ) ) {
|
204 |
+
$hour_element['#attributes'] = $attributes_hour_minute;
|
205 |
+
}
|
206 |
$form[] = $hour_element;
|
207 |
// Minutes
|
208 |
$minutes = 60;
|
209 |
$options = array();
|
210 |
+
for ( $index = 0; $index < $minutes; $index++ ) {
|
211 |
$prefix = $index < 10 ? '0' : '';
|
212 |
$options[$index] = array(
|
213 |
+
'#title' => $prefix . strval( $index ),
|
214 |
'#value' => $index,
|
215 |
);
|
216 |
}
|
217 |
+
$minute_element = array(
|
218 |
'#type' => 'select',
|
219 |
+
'#title' => __( 'Minute', 'wpv-views' ),
|
220 |
'#options' => $options,
|
221 |
'#default_value' => $minute,
|
222 |
'#name' => $this->getName() . '[minute]',
|
223 |
'#inline' => true,
|
|
|
224 |
);
|
225 |
+
if ( !empty( $attributes_hour_minute ) ) {
|
226 |
+
$minute_element['#attributes'] = $attributes_hour_minute;
|
227 |
+
}
|
228 |
$form[] = $minute_element;
|
229 |
}
|
230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
return $form;
|
232 |
}
|
233 |
|
236 |
return WPToolset_Field_Date_Scripts::getDateFormat();
|
237 |
}
|
238 |
|
239 |
+
protected function _dateToStrftime( $format ) {
|
240 |
+
$format = str_replace( 'd', '%d', $format );
|
241 |
+
$format = str_replace( 'D', '%a', $format );
|
242 |
+
$format = str_replace( 'j', '%e', $format );
|
243 |
+
$format = str_replace( 'l', '%A', $format );
|
244 |
+
$format = str_replace( 'N', '%u', $format );
|
245 |
+
$format = str_replace( 'w', '%w', $format );
|
|
|
246 |
|
247 |
+
$format = str_replace( 'W', '%W', $format );
|
248 |
|
249 |
+
$format = str_replace( 'F', '%B', $format );
|
250 |
+
$format = str_replace( 'm', '%m', $format );
|
251 |
+
$format = str_replace( 'M', '%b', $format );
|
252 |
+
$format = str_replace( 'n', '%m', $format );
|
253 |
|
254 |
+
$format = str_replace( 'o', '%g', $format );
|
255 |
+
$format = str_replace( 'Y', '%Y', $format );
|
256 |
+
$format = str_replace( 'y', '%y', $format );
|
257 |
|
258 |
return $format;
|
259 |
}
|
260 |
|
261 |
+
public static function filterValidationValue( $value ) {
|
262 |
+
if ( isset( $value['datepicker'] ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
return $value['datepicker'];
|
264 |
}
|
265 |
return $value;
|
266 |
}
|
267 |
|
268 |
+
public static function filterValidationRuleJs( $rule ) {
|
269 |
+
if ( $rule == 'date' ) {
|
270 |
+
return 'dateADODB_STAMP';
|
271 |
+
} else {
|
272 |
+
return $rule;
|
273 |
+
}
|
|
|
274 |
}
|
275 |
|
276 |
+
public static function filterValidationArgsPhp( $args, $rule ) {
|
277 |
+
if ( $rule == 'date' ) {
|
|
|
278 |
return array('$value', self::getDateFormat());
|
279 |
}
|
280 |
return $args;
|
281 |
}
|
282 |
|
283 |
+
public static function filterConditionalArgsJs( $args, $type ) {
|
284 |
+
if ( $type == 'date' ) {
|
285 |
+
foreach ( $args as &$arg ) {
|
286 |
+
if ( !is_numeric( $arg ) ) {
|
287 |
+
// Well it should be a numeric timestamp indeed
|
288 |
+
$arg = self::strtotime( $arg );
|
|
|
289 |
}
|
290 |
}
|
291 |
}
|
292 |
return $args;
|
293 |
}
|
294 |
|
295 |
+
public static function filterConditionalArgsPhp( $args, $type ) {
|
296 |
+
if ( $type == 'date' ) {
|
297 |
+
foreach ( $args as &$arg ) {
|
298 |
+
$arg = self::filterConditionalValuePhp( $arg, $type );
|
|
|
299 |
}
|
300 |
}
|
301 |
return $args;
|
302 |
}
|
303 |
|
304 |
+
public static function filterConditionalValuePhp( $value, $type ) {
|
305 |
+
if ( $type == 'date' ) {
|
306 |
+
if ( !is_numeric( $value ) ) {
|
307 |
+
// Well it should be a numeric timestamp indeed
|
308 |
+
$value = self::strtotime( $value );
|
|
|
309 |
}
|
310 |
// Use timestamp with PHP
|
311 |
// Convert back/forward to have rounded timestamp (no H and i)
|
312 |
+
// TODO review this because we should not play with timestamps generated on adodb_xxx functions
|
313 |
//$value = self::strtotime( self::timetodate( $value ) );
|
314 |
}
|
315 |
return $value;
|
316 |
}
|
317 |
|
318 |
+
// We need to keep this for backwards compatibility
|
319 |
+
// Note that this function will only convert dates coming on a string:
|
320 |
+
// - in english
|
321 |
+
// - inside the valid PHP date range
|
322 |
+
// We are only using this when the value being checked is not a timestamp
|
323 |
+
// And we have tried to avoid that situation from happening
|
324 |
+
// But for old implementation, this happens for date conditions on conditional fields
|
325 |
+
public static function strtotime( $value, $format = null )
|
326 |
{
|
327 |
+
if ( is_null( $format ) ) {
|
328 |
$format = self::getDateFormat();
|
329 |
}
|
330 |
/**
|
331 |
* add exception to handle short year
|
332 |
*/
|
333 |
+
if ( 'd/m/y' == $format ) {
|
334 |
+
preg_match_all( '/(\d{2})/', $value, $value );
|
335 |
+
$value[0][2] += $value[0][2] < 70? 2000:1900;
|
336 |
+
$value = implode('-', $value[0] );
|
337 |
}
|
338 |
+
if ( strpos($format, 'd/m/Y') !== false ) {
|
339 |
// strtotime requires a dash or dot separator to determine dd/mm/yyyy format
|
340 |
+
preg_match( '/\d{2}\/\d{2}\/\d{4}/', $value, $matches );
|
341 |
+
if ( !empty( $matches ) ) {
|
342 |
+
foreach ( $matches as $match ) {
|
343 |
+
$value = str_replace( $match,
|
344 |
+
str_replace( '/', '-', $match ), $value );
|
345 |
}
|
346 |
}
|
347 |
}
|
348 |
try {
|
349 |
+
$date = new DateTime( $value );
|
350 |
+
} catch ( Exception $e ) {
|
351 |
return false;
|
352 |
}
|
353 |
+
$timestamp = $date->format( "U" );
|
354 |
+
return self::_isTimestampInRange( $timestamp ) ? $timestamp : false;
|
355 |
}
|
356 |
|
357 |
+
// TODO review this because we should not play with timestamps generated on adodb_xxx functions
|
358 |
+
public static function timetodate( $timestamp, $format = null )
|
359 |
{
|
360 |
+
return WPToolset_Field_Date_Scripts::timetodate( $timestamp, $format );
|
361 |
}
|
362 |
|
363 |
+
protected static function _isTimestampInRange( $timestamp )
|
364 |
{
|
365 |
return WPToolset_Field_Date_Scripts::_isTimestampInRange($timestamp);
|
366 |
}
|
367 |
|
368 |
/**
|
369 |
* DEPRECATED
|
370 |
+
*
|
371 |
+
* This is not used anymore
|
372 |
*/
|
373 |
+
public static function timeIsValid( $time ) {
|
|
|
374 |
/*
|
375 |
* http://php.net/manual/en/function.strtotime.php
|
376 |
* The valid range of a timestamp is typically
|
384 |
* This means that e.g. dates prior to Jan 1, 1970 will not
|
385 |
* work on Windows, some Linux distributions,
|
386 |
* and a few other operating systems.
|
387 |
+
* PHP 5.1.0 and newer versions overcome this limitation though.
|
388 |
*/
|
389 |
// MIN 'Jan 1, 1970' - 0 | Fri, 13 Dec 1901 20:45:54 UTC
|
390 |
$_min_time = self::timeNegativeSupported() ? -2147483646 : 0;
|
391 |
// MAX 'Tue, 19 Jan 2038 03:14:07 UTC' - 2147483647
|
392 |
$_max_time = 2147483647;
|
393 |
|
394 |
+
return is_numeric( $time ) && $_min_time <= intval( $time ) && intval( $time ) <= $_max_time;
|
395 |
}
|
396 |
|
397 |
/**
|
398 |
* DEPRECATED
|
399 |
+
*
|
400 |
+
* This is not used anymore
|
401 |
*/
|
402 |
+
public static function timeNegativeSupported() {
|
403 |
+
return strtotime( 'Fri, 13 Dec 1950 20:45:54 UTC' ) === -601010046;
|
|
|
404 |
}
|
405 |
|
406 |
}
|
embedded/common/toolset-forms/classes/class.date.scripts.php
CHANGED
@@ -37,24 +37,13 @@ class WPToolset_Field_Date_Scripts
|
|
37 |
//for edit pages including profile pages
|
38 |
($pagenow == 'profile.php' || $pagenow == 'post-new.php' || $pagenow == 'user-edit.php' || $pagenow == 'user-new.php' || $pagenow == 'post.php' || $pagenow == 'admin-ajax.php') && is_admin() ) ){
|
39 |
add_action( 'admin_enqueue_scripts', array( $this,'date_enqueue_scripts' ) );
|
40 |
-
|
41 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'date_enqueue_scripts' ) );
|
42 |
-
}
|
43 |
}
|
44 |
$this->localization_slug = false;
|
45 |
}
|
46 |
|
47 |
public function date_enqueue_scripts()
|
48 |
{
|
49 |
-
/**
|
50 |
-
* prevent load scripts on custom field group edit screen
|
51 |
-
*/
|
52 |
-
if ( is_admin() ) {
|
53 |
-
$screen = get_current_screen();
|
54 |
-
if ( 'types_page_wpcf-edit' == $screen->id ) {
|
55 |
-
return;
|
56 |
-
}
|
57 |
-
}
|
58 |
/**
|
59 |
* styles
|
60 |
*/
|
@@ -130,8 +119,8 @@ class WPToolset_Field_Date_Scripts
|
|
130 |
'yearMin' => intval( self::timetodate( self::$_mintimestamp, 'Y' ) ) + 1,
|
131 |
'yearMax' => self::timetodate( self::$_maxtimestamp, 'Y' ),
|
132 |
'ajaxurl' => admin_url('admin-ajax.php', null),
|
133 |
-
'readonly' => esc_js( __( 'This is a
|
134 |
-
|
135 |
);
|
136 |
wp_localize_script( 'wptoolset-field-date', 'wptDateData', $js_data );
|
137 |
if ( $this->localization_slug && !wp_script_is( 'jquery-ui-datepicker-local-' . $this->localization_slug ) ) {
|
37 |
//for edit pages including profile pages
|
38 |
($pagenow == 'profile.php' || $pagenow == 'post-new.php' || $pagenow == 'user-edit.php' || $pagenow == 'user-new.php' || $pagenow == 'post.php' || $pagenow == 'admin-ajax.php') && is_admin() ) ){
|
39 |
add_action( 'admin_enqueue_scripts', array( $this,'date_enqueue_scripts' ) );
|
40 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'date_enqueue_scripts' ) );
|
|
|
|
|
41 |
}
|
42 |
$this->localization_slug = false;
|
43 |
}
|
44 |
|
45 |
public function date_enqueue_scripts()
|
46 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
/**
|
48 |
* styles
|
49 |
*/
|
119 |
'yearMin' => intval( self::timetodate( self::$_mintimestamp, 'Y' ) ) + 1,
|
120 |
'yearMax' => self::timetodate( self::$_maxtimestamp, 'Y' ),
|
121 |
'ajaxurl' => admin_url('admin-ajax.php', null),
|
122 |
+
'readonly' => esc_js( __( 'This is a readonly date input', 'wpv-views' ) ),
|
123 |
+
'readonly_image' => $calendar_image_readonly
|
124 |
);
|
125 |
wp_localize_script( 'wptoolset-field-date', 'wptDateData', $js_data );
|
126 |
if ( $this->localization_slug && !wp_script_is( 'jquery-ui-datepicker-local-' . $this->localization_slug ) ) {
|
embedded/common/toolset-forms/classes/class.eforms.php
CHANGED
@@ -1,20 +1,19 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/* Copyright 2011 enlimbo lancers (email : lancers@enlimbo.net)
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
*/
|
19 |
|
20 |
/**
|
@@ -28,20 +27,22 @@
|
|
28 |
* @link http://enlimbo.net/forms
|
29 |
* @author srdjan <srdjan@enlimbo.net>
|
30 |
*
|
31 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
32 |
-
* $LastChangedDate:
|
33 |
-
* $LastChangedRevision:
|
34 |
-
* $LastChangedBy:
|
35 |
*
|
36 |
*/
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
43 |
*/
|
44 |
-
class Enlimbo_Forms
|
|
|
45 |
|
46 |
/**
|
47 |
* @var string
|
@@ -78,7 +79,8 @@ class Enlimbo_Forms {
|
|
78 |
*/
|
79 |
public $form_settings = array();
|
80 |
|
81 |
-
public function __construct($id)
|
|
|
82 |
/**
|
83 |
* default settings
|
84 |
*/
|
@@ -87,22 +89,21 @@ class Enlimbo_Forms {
|
|
87 |
'use_bootstrap' => false,
|
88 |
);
|
89 |
$this->_id = $id;
|
90 |
-
if (!is_admin()
|
91 |
-
|
92 |
-
$
|
93 |
-
|
94 |
-
if (isset($form_settings->form)) {
|
95 |
$this->form_settings = $form_settings->form;
|
96 |
}
|
97 |
unset($form_settings);
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
}
|
107 |
|
108 |
/**
|
@@ -113,7 +114,8 @@ class Enlimbo_Forms {
|
|
113 |
* @param array $element
|
114 |
* @return HTML formatted output
|
115 |
*/
|
116 |
-
public function autoHandle($id, $form)
|
|
|
117 |
// Auto-add nonce field
|
118 |
$form['nonce'] = array(
|
119 |
'#type' => 'hidden',
|
@@ -165,11 +167,13 @@ class Enlimbo_Forms {
|
|
165 |
* @param type $id
|
166 |
* @return type
|
167 |
*/
|
168 |
-
public function isSubmitted($id = '')
|
|
|
169 |
if (empty($id)) {
|
170 |
$id = $this->_id;
|
171 |
}
|
172 |
-
return (isset($_REQUEST['_nonce'])
|
|
|
173 |
}
|
174 |
|
175 |
/**
|
@@ -187,18 +191,23 @@ class Enlimbo_Forms {
|
|
187 |
*
|
188 |
* @param type $elements
|
189 |
*/
|
190 |
-
public function validate(&$elements)
|
|
|
191 |
foreach ($elements as $key => &$element) {
|
192 |
-
if (!isset($element['#type'])
|
|
|
193 |
continue;
|
194 |
}
|
195 |
if ($element['#type'] != 'fieldset') {
|
196 |
-
if (isset($element['#name'])
|
|
|
197 |
if ($this->isSubmitted()) {
|
198 |
// Set submitted data
|
199 |
-
if (!in_array($element['#type'], array('checkboxes'))
|
|
|
200 |
$element['#value'] = $this->getSubmittedData($element);
|
201 |
-
} else if (!empty($element['#options'])
|
|
|
202 |
foreach ($element['#options'] as $option_key => $option) {
|
203 |
$option['#type'] = 'checkbox';
|
204 |
$element['#options'][$option_key]['#value'] = $this->getSubmittedData($option);
|
@@ -210,7 +219,8 @@ class Enlimbo_Forms {
|
|
210 |
if (isset($element['#validate'])) {
|
211 |
$this->validateElement($element);
|
212 |
}
|
213 |
-
} else if (isset($element['#type'])
|
|
|
214 |
$this->validate($element);
|
215 |
} else if (is_array($element)) {
|
216 |
$this->validate($element);
|
@@ -223,13 +233,15 @@ class Enlimbo_Forms {
|
|
223 |
*
|
224 |
* @param type $element
|
225 |
*/
|
226 |
-
public function validateElement(&$element)
|
227 |
-
|
228 |
-
|
|
|
229 |
$value = $element['#default_value'];
|
230 |
}
|
231 |
-
$element = apply_filters('wptoolset_form_' . $this->_id . '_validate_field',
|
232 |
-
|
|
|
233 |
$this->_errors = true;
|
234 |
$_errors = $element['error']->get_error_data();
|
235 |
$element['#error'] = $_errors[0];
|
@@ -241,14 +253,16 @@ class Enlimbo_Forms {
|
|
241 |
*
|
242 |
* @return type
|
243 |
*/
|
244 |
-
public function isError()
|
|
|
245 |
return $this->_errors;
|
246 |
}
|
247 |
|
248 |
/**
|
249 |
* Sets errors to true.
|
250 |
*/
|
251 |
-
public function triggerError()
|
|
|
252 |
$this->_errors = true;
|
253 |
}
|
254 |
|
@@ -257,7 +271,8 @@ class Enlimbo_Forms {
|
|
257 |
*
|
258 |
* @return type
|
259 |
*/
|
260 |
-
public function renderForm()
|
|
|
261 |
// loop over elements and render them
|
262 |
return $this->renderElements($this->_elements);
|
263 |
}
|
@@ -282,10 +297,12 @@ class Enlimbo_Forms {
|
|
282 |
* @param string $type
|
283 |
* @return boolean
|
284 |
*/
|
285 |
-
private function _isValidType($type)
|
286 |
-
|
287 |
-
|
288 |
-
|
|
|
|
|
289 |
}
|
290 |
|
291 |
/**
|
@@ -294,31 +311,31 @@ class Enlimbo_Forms {
|
|
294 |
* @param type $elements
|
295 |
* @return type
|
296 |
*/
|
297 |
-
public function renderElements($elements)
|
|
|
298 |
$output = '';
|
299 |
-
if (!isset($elements))
|
300 |
-
|
301 |
-
foreach ($elements as $key => $element) {
|
302 |
if (!isset($element['#type']) || !$this->_isValidType($element['#type'])) {
|
303 |
continue;
|
304 |
}
|
305 |
if ($element['#type'] != 'fieldset') {
|
306 |
-
|
307 |
/**
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
if (!is_admin()) {
|
312 |
-
if ($element['#type']
|
313 |
if (isset($element['#error'])) {
|
314 |
-
if (isset($element['#options'])
|
315 |
-
$element['#options'][0]['#error']
|
316 |
}
|
317 |
}
|
318 |
}
|
319 |
//##################################################################################################
|
320 |
-
|
321 |
-
$output .= $this->renderElement($element);
|
322 |
} else if (isset($element['#type']) && $element['#type'] == 'fieldset') {
|
323 |
$buffer = $this->renderElements($element);
|
324 |
$output .= $this->fieldset($element, 'wrap', $buffer);
|
@@ -337,9 +354,10 @@ class Enlimbo_Forms {
|
|
337 |
* @param array $element
|
338 |
* @return HTML formatted output
|
339 |
*/
|
340 |
-
public function renderElement($element)
|
|
|
341 |
$method = $element['#type'];
|
342 |
-
if (!isset($element['#name']) && !in_array($element['#type'], array('markup', 'checkboxes'))) {
|
343 |
if (!isset($element['#attributes']['name'])) {
|
344 |
return '#name or #attributes[\'name\'] required!';
|
345 |
} else {
|
@@ -348,52 +366,46 @@ class Enlimbo_Forms {
|
|
348 |
}
|
349 |
if (is_callable(array($this, $method))) {
|
350 |
$custom_field_title = '';
|
351 |
-
if (isset($element['#title']) && !empty($element['#title']))
|
352 |
-
|
353 |
}
|
354 |
|
355 |
-
if (empty($custom_field_title) && isset($element['#name']) && !empty($element['#name']))
|
356 |
-
|
357 |
}
|
358 |
if (!isset($element['#id'])) {
|
359 |
if (isset($element['#attributes']['id'])) {
|
360 |
$element['#id'] = $element['#attributes']['id'];
|
361 |
} else {
|
362 |
-
$_id = isset($this->_id) ? $this->_id . '-' : '';
|
363 |
$element['#id'] = "{$_id}{$element['#type']}-"
|
364 |
. $this->_count($element['#type']) . '-' . time();
|
365 |
}
|
366 |
}
|
367 |
-
|
368 |
if (isset($this->_errors[$element['#id']])) {
|
369 |
$element['#error'] = $this->_errors[$element['#id']];
|
370 |
}
|
371 |
// Add JS validation
|
372 |
-
if (!empty($element['#validate'])) {
|
373 |
-
if (isset($element['#validate']['required']
|
|
|
374 |
// Asterisk
|
375 |
$element['#title'] .= '*';
|
376 |
}
|
377 |
-
$element['#attributes']['data-wpt-validate'] =
|
378 |
-
|
|
|
379 |
}
|
380 |
-
if ($element['#type'] == 'radios' && !empty($element['#options'])) {
|
381 |
-
foreach ($element['#options'] as &$option) {
|
382 |
-
if (!empty($option['#validate'])) {
|
383 |
-
$option['#attributes']['data-wpt-validate'] =
|
384 |
-
|
|
|
385 |
}
|
386 |
}
|
387 |
}
|
388 |
-
/**
|
389 |
-
* WPML - lock CF is has option "copy from original".
|
390 |
-
*/
|
391 |
-
if (is_admin() && function_exists('wpcf_wpml_field_is_copied') && wpcf_wpml_field_is_copied($element)) {
|
392 |
-
$element['#title'] .= sprintf(
|
393 |
-
'<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')
|
394 |
-
);
|
395 |
-
$element['#attributes']['readonly'] = true;
|
396 |
-
}
|
397 |
return $this->{$method}($element);
|
398 |
}
|
399 |
}
|
@@ -404,57 +416,56 @@ class Enlimbo_Forms {
|
|
404 |
* @param array $element
|
405 |
* @return string
|
406 |
*/
|
407 |
-
private function _setElementAttributes($element)
|
|
|
408 |
$attributes = '';
|
409 |
|
410 |
$classes = array();
|
411 |
$classes[] = $this->css_class . '-' . $element['#type'];
|
412 |
$classes[] = 'form-' . $element['#type'];
|
413 |
|
414 |
-
if ($this->form_settings['use_bootstrap']) {
|
415 |
-
switch
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
}
|
426 |
-
} else {
|
427 |
-
if ('hidden' != $element['#type']) {
|
428 |
-
$classes[] = $element['#type'];
|
429 |
-
}
|
430 |
-
}
|
431 |
-
|
432 |
-
if (isset($element['#attributes']) && !empty($element['#attributes'])
|
433 |
-
) {
|
434 |
-
if (isset($element['#attributes']['class'])) {
|
435 |
-
$element['#attributes']['class'] .= ' ' . implode(' ', $classes);
|
436 |
-
} else {
|
437 |
-
$element['#attributes']['class'] = implode(' ', $classes);
|
438 |
}
|
439 |
} else {
|
440 |
-
$element['#
|
441 |
-
'class' => implode(' ', $classes)
|
442 |
-
);
|
443 |
}
|
444 |
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
|
459 |
return $attributes;
|
460 |
}
|
@@ -464,7 +475,8 @@ class Enlimbo_Forms {
|
|
464 |
*
|
465 |
* @param array $element
|
466 |
*/
|
467 |
-
private function _setRender($element)
|
|
|
468 |
if (!isset($element['#id'])) {
|
469 |
if (isset($element['#attributes']['id'])) {
|
470 |
$element['#id'] = $element['#attributes']['id'];
|
@@ -485,24 +497,27 @@ class Enlimbo_Forms {
|
|
485 |
* label
|
486 |
*/
|
487 |
$element['_render']['label'] = '';
|
488 |
-
if (isset($element['#title'])) {
|
489 |
$classes = array();
|
490 |
$classes[] = sprintf('%s-label', $this->css_class);
|
491 |
$classes[] = sprintf('%s-%s-label', $this->css_class, $element['#type']);
|
492 |
-
if ($this->form_settings['use_bootstrap']) {
|
493 |
-
switch
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
}
|
499 |
}
|
500 |
$element['_render']['label'] .= sprintf(
|
501 |
-
|
|
|
|
|
502 |
);
|
503 |
$element['_render']['label'] .= stripslashes($element['#title']);
|
504 |
$element['_render']['label'] .= '</label>';
|
505 |
}
|
|
|
506 |
return $element;
|
507 |
}
|
508 |
|
@@ -515,7 +530,8 @@ class Enlimbo_Forms {
|
|
515 |
* Accepts: <prefix><suffix><label><title><desription><error>
|
516 |
* @param array $element
|
517 |
*/
|
518 |
-
private function _pattern($pattern, $element)
|
|
|
519 |
$pattern = strtolower($pattern);
|
520 |
foreach ($element['_render'] as $key => $value) {
|
521 |
$pattern = str_replace('<' . strtolower($key) . '>', $value, $pattern);
|
@@ -530,24 +546,28 @@ class Enlimbo_Forms {
|
|
530 |
* @param string $output
|
531 |
* @return string
|
532 |
*/
|
533 |
-
private function _wrapElement($element, $output)
|
|
|
534 |
if (!empty($element['#inline'])) {
|
535 |
return $output;
|
536 |
}
|
537 |
$classes = array();
|
538 |
$classes[] = 'form-item';
|
539 |
$classes[] = 'form-item-' . $element['#type'];
|
540 |
-
$classes[] =
|
541 |
-
$classes[] =
|
542 |
-
if ($this->form_settings['use_bootstrap']) {
|
543 |
$classes[] = 'form-group';
|
544 |
}
|
545 |
-
if (preg_match('/_hidden$/', $element['#id']) && !is_admin()) {
|
546 |
$classes[] = 'wpt-form-hide-container';
|
547 |
}
|
548 |
-
if (is_admin()) {
|
549 |
return sprintf(
|
550 |
-
|
|
|
|
|
|
|
551 |
);
|
552 |
}
|
553 |
return $output;
|
@@ -559,7 +579,8 @@ class Enlimbo_Forms {
|
|
559 |
* @param string $element
|
560 |
* @return string
|
561 |
*/
|
562 |
-
private function _setElementTitle($element)
|
|
|
563 |
$output = '';
|
564 |
if (isset($element['#title'])) {
|
565 |
$output .= '<div class="title '
|
@@ -578,9 +599,9 @@ class Enlimbo_Forms {
|
|
578 |
* @param array $element
|
579 |
* @return string
|
580 |
*/
|
581 |
-
private function _setElementDescription($element)
|
582 |
-
|
583 |
-
|
584 |
$element['#description'] = stripslashes($element['#description']);
|
585 |
$output = "\r\n"
|
586 |
. '<div class="description '
|
@@ -599,7 +620,8 @@ class Enlimbo_Forms {
|
|
599 |
* @param array $element
|
600 |
* @return string
|
601 |
*/
|
602 |
-
public function renderError($element)
|
|
|
603 |
if (!isset($element['#error'])) {
|
604 |
return '';
|
605 |
}
|
@@ -624,7 +646,8 @@ class Enlimbo_Forms {
|
|
624 |
* @param string $wrap_content HTML formatted output of child elements
|
625 |
* @return string
|
626 |
*/
|
627 |
-
public function fieldset($element, $action = 'open', $wrap_content = '')
|
|
|
628 |
$collapsible_open = '<div class="fieldset-wrapper">';
|
629 |
$collapsible_close = '</div>';
|
630 |
$legend_class = '';
|
@@ -634,13 +657,15 @@ class Enlimbo_Forms {
|
|
634 |
if (!isset($element['_attributes_string'])) {
|
635 |
$element['_attributes_string'] = $this->_setElementAttributes($element);
|
636 |
}
|
637 |
-
if ((isset($element['#collapsible']) && $element['#collapsible'])
|
|
|
638 |
$collapsible_open = '<div class="collapsible fieldset-wrapper">';
|
639 |
$collapsible_close = '</div>';
|
640 |
$legend_class = ' class="legend-expanded"';
|
641 |
}
|
642 |
if (isset($element['#collapsed']) && $element['#collapsed']) {
|
643 |
-
$collapsible_open = str_replace('class="', 'class="collapsed ',
|
|
|
644 |
$legend_class = ' class="legend-collapsed"';
|
645 |
}
|
646 |
$output = '';
|
@@ -694,18 +719,19 @@ class Enlimbo_Forms {
|
|
694 |
* @param array $element
|
695 |
* @return string
|
696 |
*/
|
697 |
-
public function checkbox($element)
|
|
|
698 |
$element['#type'] = 'checkbox';
|
699 |
$element = $this->_setRender($element);
|
700 |
$element['_render']['element'] = '<input type="checkbox"';
|
701 |
-
foreach
|
702 |
-
$element['_render']['element'] .= sprintf(' %s="%s"', $key, $element['#'
|
703 |
}
|
704 |
/**
|
705 |
* type and data_id
|
706 |
*/
|
707 |
-
$element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
|
708 |
-
$element['_render']['element'] .= $this->_getDataWptId($element);
|
709 |
|
710 |
$element['_render']['element'] .= ' value="';
|
711 |
/**
|
@@ -713,17 +739,19 @@ class Enlimbo_Forms {
|
|
713 |
* but if is defined default value, use default
|
714 |
*/
|
715 |
$value = 1;
|
716 |
-
if (array_key_exists('#default_value', $element)) {
|
717 |
$value = $element['#default_value'];
|
718 |
}
|
719 |
-
$element['_render']['element'] .= ( empty($element['#value']) && !preg_match('/^0$/', $element['#value']) )
|
720 |
$element['_render']['element'] .= '"' . $element['_attributes_string'];
|
721 |
if (
|
722 |
-
|
723 |
!$this->isSubmitted() && (
|
724 |
-
|
|
|
725 |
)
|
726 |
-
|
|
|
727 |
) {
|
728 |
$element['_render']['element'] .= ' checked="checked"';
|
729 |
}
|
@@ -732,7 +760,7 @@ class Enlimbo_Forms {
|
|
732 |
}
|
733 |
$element['_render']['element'] .= ' />';
|
734 |
|
735 |
-
$pattern = $this->_getStatndardPatern($element, '<BEFORE><PREFIX><ELEMENT> <LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>');
|
736 |
$output = $this->_pattern($pattern, $element);
|
737 |
$output = $this->_wrapElement($element, $output);
|
738 |
return $output . "\r\n";
|
@@ -747,7 +775,8 @@ class Enlimbo_Forms {
|
|
747 |
* @param array $element
|
748 |
* @return string
|
749 |
*/
|
750 |
-
public function checkboxes($element)
|
|
|
751 |
$element['#type'] = 'checkboxes';
|
752 |
$element = $this->_setRender($element);
|
753 |
$clone = $element;
|
@@ -759,7 +788,7 @@ class Enlimbo_Forms {
|
|
759 |
}
|
760 |
$element['_render']['element'] .= $this->checkbox($value);
|
761 |
}
|
762 |
-
$pattern = $this->_getStatndardPatern($element, '<BEFORE><PREFIX><TITLE><DESCRIPTION><ELEMENT><SUFFIX><AFTER>');
|
763 |
$output = $this->_pattern($pattern, $element);
|
764 |
$output = $this->_wrapElement($element, $output);
|
765 |
return $output;
|
@@ -771,7 +800,8 @@ class Enlimbo_Forms {
|
|
771 |
* @param array $element
|
772 |
* @return string
|
773 |
*/
|
774 |
-
public function radio($element)
|
|
|
775 |
$element['#type'] = 'radio';
|
776 |
$element = $this->_setRender($element);
|
777 |
$element['_render']['element'] = '<input type="radio" id="'
|
@@ -780,21 +810,22 @@ class Enlimbo_Forms {
|
|
780 |
$element['_render']['element'] .= isset($element['#value']) ? htmlspecialchars($element['#value']) : $this->_count['radio'];
|
781 |
$element['_render']['element'] .= '"';
|
782 |
$element['_render']['element'] .= $element['_attributes_string'];
|
783 |
-
$element['_render']['element'] .= ( isset($element['#value'])
|
|
|
784 |
if (isset($element['#disable']) && $element['#disable']) {
|
785 |
$element['_render']['element'] .= ' disabled="disabled"';
|
786 |
}
|
787 |
-
if (array_key_exists('#types-value', $element)) {
|
788 |
-
$element['_render']['element'] .= sprintf(' data-types-value="%s"', $element['#types-value']);
|
789 |
}
|
790 |
/**
|
791 |
* type and data_id
|
792 |
*/
|
793 |
-
$element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
|
794 |
-
$element['_render']['element'] .= $this->_getDataWptId($element);
|
795 |
|
796 |
$element['_render']['element'] .= ' />';
|
797 |
-
|
798 |
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><PREFIX><ELEMENT> <LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
|
799 |
$output = $this->_pattern($pattern, $element);
|
800 |
$output = $this->_wrapElement($element, $output);
|
@@ -810,7 +841,8 @@ class Enlimbo_Forms {
|
|
810 |
* @param array $element
|
811 |
* @return string
|
812 |
*/
|
813 |
-
public function radios($element)
|
|
|
814 |
if (!isset($element['#name']) || empty($element['#name'])) {
|
815 |
return FALSE;
|
816 |
}
|
@@ -834,7 +866,7 @@ class Enlimbo_Forms {
|
|
834 |
} else {
|
835 |
$pattern = '<BEFORE><PREFIX><DESCRIPTION><ELEMENT><SUFFIX><AFTER>';
|
836 |
}
|
837 |
-
|
838 |
$pattern = $this->_getStatndardPatern($element, $pattern);
|
839 |
$output = $this->_pattern($pattern, $element);
|
840 |
$output = $this->_wrapElement($element, $output);
|
@@ -847,23 +879,24 @@ class Enlimbo_Forms {
|
|
847 |
* @param array $element
|
848 |
* @return string
|
849 |
*/
|
850 |
-
public function select($element)
|
|
|
851 |
$element = $this->_setRender($element);
|
852 |
|
853 |
$element['_render']['element'] = '';
|
854 |
$element['_render']['element'] .= '<select id="' . $element['#id'] . '" ';
|
855 |
$element['_render']['element'] .= $element['_attributes_string'];
|
856 |
-
$element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
|
857 |
/**
|
858 |
* multiple
|
859 |
*/
|
860 |
-
if (array_key_exists('#multiple', $element) && $element['#multiple']) {
|
861 |
$element['_render']['element'] .= ' multiple="multiple"';
|
862 |
$element['_render']['element'] .= ' name="' . $element['#name'] . '[]"';
|
863 |
} else {
|
864 |
$element['_render']['element'] .= ' name="' . $element['#name'] . '"';
|
865 |
}
|
866 |
-
$element['_render']['element'] .=
|
867 |
$count = 1;
|
868 |
foreach ($element['#options'] as $id => $value) {
|
869 |
if (!is_array($value)) {
|
@@ -876,22 +909,22 @@ class Enlimbo_Forms {
|
|
876 |
}
|
877 |
$element['_render']['element'] .= '<option value="' . htmlspecialchars($value['#value']) . '"';
|
878 |
$element['_render']['element'] .= $this->_setElementAttributes($value);
|
879 |
-
if (array_key_exists('#types-value', $value)) {
|
880 |
-
$element['_render']['element'] .= sprintf(' data-types-value="%s"', $value['#types-value']);
|
881 |
}
|
882 |
/**
|
883 |
* type and data_id
|
884 |
*/
|
885 |
$element['_render']['element'] .= ' data-wpt-type="option"';
|
886 |
-
$element['_render']['element'] .= $this->_getDataWptId($element);
|
887 |
/**
|
888 |
* selected
|
889 |
*/
|
890 |
-
if (array_key_exists('#multiple', $element) && $element['#multiple']) {
|
891 |
-
if (is_array($element['#default_value']) && in_array($value['#value'], $element['#default_value'])) {
|
892 |
$element['_render']['element'] .= ' selected="selected"';
|
893 |
}
|
894 |
-
} elseif ($element['#default_value'] == $value['#value']) {
|
895 |
$element['_render']['element'] .= ' selected="selected"';
|
896 |
}
|
897 |
$element['_render']['element'] .= '>';
|
@@ -901,7 +934,7 @@ class Enlimbo_Forms {
|
|
901 |
$element['_render']['element'] .= '</select>';
|
902 |
$element['_render']['element'] .= PHP_EOL;
|
903 |
|
904 |
-
$pattern = $this->_getStatndardPatern($element);
|
905 |
$output = $this->_pattern($pattern, $element);
|
906 |
$output = $this->_wrapElement($element, $output);
|
907 |
|
@@ -914,15 +947,16 @@ class Enlimbo_Forms {
|
|
914 |
* @param array $element
|
915 |
* @return string
|
916 |
*/
|
917 |
-
public function textfield($element)
|
|
|
918 |
$element['#type'] = 'textfield';
|
919 |
$element = $this->_setRender($element);
|
920 |
|
921 |
$element['_render']['element'] = '<input type="text"';
|
922 |
//$element['_render']['element'] .= sprintf( ' data-wpt-type="%s" ', __FUNCTION__ );
|
923 |
-
$element['_render']['element'] .= sprintf(' id="%s"', $element['#id']);
|
924 |
-
$element['_render']['element'] .= sprintf(' name="%s"', $element['#name']);
|
925 |
-
$element['_render']['element'] .= sprintf(' value="%s"', isset($element['#value']) ? esc_attr($element['#value']) : '' );
|
926 |
$element['_render']['element'] .= $element['_attributes_string'];
|
927 |
if (isset($element['#disable']) && $element['#disable']) {
|
928 |
$element['_render']['element'] .= ' disabled="disabled"';
|
@@ -930,11 +964,11 @@ class Enlimbo_Forms {
|
|
930 |
/**
|
931 |
* type and data_id
|
932 |
*/
|
933 |
-
$element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
|
934 |
-
$element['_render']['element'] .= $this->_getDataWptId($element);
|
935 |
|
936 |
$element['_render']['element'] .= ' />';
|
937 |
-
$pattern = $this->_getStatndardPatern($element);
|
938 |
$output = $this->_pattern($pattern, $element);
|
939 |
$output = $this->_wrapElement($element, $output);
|
940 |
return $output . "\r\n";
|
@@ -946,7 +980,8 @@ class Enlimbo_Forms {
|
|
946 |
* @param array $element
|
947 |
* @return string
|
948 |
*/
|
949 |
-
public function password($element)
|
|
|
950 |
$element['#type'] = 'password';
|
951 |
$element = $this->_setRender($element);
|
952 |
$element['_render']['element'] = '<input type="password" id="'
|
@@ -959,8 +994,8 @@ class Enlimbo_Forms {
|
|
959 |
/**
|
960 |
* type and data_id
|
961 |
*/
|
962 |
-
$element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
|
963 |
-
$element['_render']['element'] .= $this->_getDataWptId($element);
|
964 |
|
965 |
$element['_render']['element'] .= ' />';
|
966 |
$pattern = $this->_getStatndardPatern($element);
|
@@ -975,7 +1010,8 @@ class Enlimbo_Forms {
|
|
975 |
* @param array $element
|
976 |
* @return string
|
977 |
*/
|
978 |
-
public function textarea($element)
|
|
|
979 |
$element['#type'] = 'textarea';
|
980 |
if (!isset($element['#attributes']['rows'])) {
|
981 |
$element['#attributes']['rows'] = 5;
|
@@ -990,14 +1026,14 @@ class Enlimbo_Forms {
|
|
990 |
/**
|
991 |
* type and data_id
|
992 |
*/
|
993 |
-
$element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
|
994 |
-
$element['_render']['element'] .= $this->_getDataWptId($element);
|
995 |
|
996 |
$element['_render']['element'] .= '>';
|
997 |
|
998 |
$element['_render']['element'] .= isset($element['#value']) ? esc_attr($element['#value']) : '';
|
999 |
$element['_render']['element'] .= '</textarea>' . "\r\n";
|
1000 |
-
$pattern = $this->_getStatndardPatern($element);
|
1001 |
$output = $this->_pattern($pattern, $element);
|
1002 |
$output = $this->_wrapElement($element, $output);
|
1003 |
return $output . "\r\n";
|
@@ -1009,7 +1045,8 @@ class Enlimbo_Forms {
|
|
1009 |
* @param array $element
|
1010 |
* @return string
|
1011 |
*/
|
1012 |
-
public function file($element)
|
|
|
1013 |
$element['#type'] = 'file';
|
1014 |
$element = $this->_setRender($element);
|
1015 |
$element['_render']['element'] = '<input type="file" id="'
|
@@ -1021,11 +1058,11 @@ class Enlimbo_Forms {
|
|
1021 |
/**
|
1022 |
* type and data_id
|
1023 |
*/
|
1024 |
-
$element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
|
1025 |
-
$element['_render']['element'] .= $this->_getDataWptId($element);
|
1026 |
|
1027 |
$element['_render']['element'] .= ' />';
|
1028 |
-
$pattern = $this->_getStatndardPatern($element);
|
1029 |
$output = $this->_pattern($pattern, $element);
|
1030 |
$output = $this->_wrapElement($element, $output);
|
1031 |
return $output;
|
@@ -1037,7 +1074,8 @@ class Enlimbo_Forms {
|
|
1037 |
* @param array $element
|
1038 |
* @return string
|
1039 |
*/
|
1040 |
-
public function markup($element)
|
|
|
1041 |
return $element['#markup'];
|
1042 |
}
|
1043 |
|
@@ -1047,13 +1085,14 @@ class Enlimbo_Forms {
|
|
1047 |
* @param array $element
|
1048 |
* @return string
|
1049 |
*/
|
1050 |
-
public function hidden($element)
|
|
|
1051 |
$element['#type'] = 'hidden';
|
1052 |
$element = $this->_setRender($element);
|
1053 |
$output = '<input type="hidden" id="' . $element['#id'] . '" name="'
|
1054 |
. $element['#name'] . '" value="';
|
1055 |
$output .= isset($element['#value']) ? $element['#value'] : 1;
|
1056 |
-
$output .= '"' . $element['_attributes_string'] . $this->_getDataWptId($element) . ' />';
|
1057 |
return $output;
|
1058 |
}
|
1059 |
|
@@ -1063,7 +1102,8 @@ class Enlimbo_Forms {
|
|
1063 |
* @param array $element
|
1064 |
* @return string
|
1065 |
*/
|
1066 |
-
public function reset($element)
|
|
|
1067 |
return $this->submit($element, 'reset', 'Reset');
|
1068 |
}
|
1069 |
|
@@ -1073,7 +1113,8 @@ class Enlimbo_Forms {
|
|
1073 |
* @param array $element
|
1074 |
* @return string
|
1075 |
*/
|
1076 |
-
public function button($element)
|
|
|
1077 |
return $this->submit($element, 'button', 'Button');
|
1078 |
}
|
1079 |
|
@@ -1087,7 +1128,8 @@ class Enlimbo_Forms {
|
|
1087 |
* @param string $title
|
1088 |
* @return string
|
1089 |
*/
|
1090 |
-
public function submit($element, $type = 'submit', $title = 'Submit')
|
|
|
1091 |
$element['#type'] = $type;
|
1092 |
$element = $this->_setRender($element);
|
1093 |
$element['_render']['element'] = '<input type="' . $type . '" id="'
|
@@ -1095,7 +1137,7 @@ class Enlimbo_Forms {
|
|
1095 |
$element['_render']['element'] .= isset($element['#value']) ? $element['#value'] : $title;
|
1096 |
$element['_render']['element'] .= '"' . $element['_attributes_string']
|
1097 |
. ' />';
|
1098 |
-
$pattern = $this->_getStatndardPatern($element, '<BEFORE><PREFIX><ELEMENT><SUFFIX><AFTER>');
|
1099 |
$output = $this->_pattern($pattern, $element);
|
1100 |
return $output;
|
1101 |
}
|
@@ -1106,20 +1148,20 @@ class Enlimbo_Forms {
|
|
1106 |
* @param type $element
|
1107 |
* @return type mixed
|
1108 |
*/
|
1109 |
-
public function getSubmittedData($element)
|
|
|
1110 |
$name = $element['#name'];
|
1111 |
if (strpos($name, '[') === false) {
|
1112 |
if ($element['#type'] == 'file') {
|
1113 |
return $_FILES[$name]['tmp_name'];
|
1114 |
}
|
1115 |
-
return isset($_REQUEST[$name]) ? $_REQUEST[$name] : in_array($element['#type'],
|
|
|
1116 |
}
|
1117 |
|
1118 |
$parts = explode('[', $name);
|
1119 |
-
|
1120 |
-
|
1121 |
-
//$parts = array_map(create function('&$a', 'return trim($a, \']\');'), $parts);
|
1122 |
-
$parts = array_map("cred_mytrimfunction", $parts);
|
1123 |
if (!isset($_REQUEST[$parts[0]])) {
|
1124 |
return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
|
1125 |
}
|
@@ -1128,12 +1170,14 @@ class Enlimbo_Forms {
|
|
1128 |
$key = $parts[$index];
|
1129 |
// We're at the end but no data retrieved
|
1130 |
if (!isset($parts[$index + 1])) {
|
1131 |
-
return in_array($element['#type'],
|
|
|
1132 |
}
|
1133 |
$key_next = $parts[$index + 1];
|
1134 |
if ($index > 0) {
|
1135 |
if (!isset($search[$key])) {
|
1136 |
-
return in_array($element['#type'],
|
|
|
1137 |
} else {
|
1138 |
$search = $search[$key];
|
1139 |
}
|
@@ -1147,23 +1191,25 @@ class Enlimbo_Forms {
|
|
1147 |
return 0;
|
1148 |
}
|
1149 |
|
1150 |
-
private function _getDataWptId($element)
|
|
|
1151 |
$html = '';
|
1152 |
-
if (array_key_exists('#id', $element)) {
|
1153 |
-
if (is_admin()) {
|
1154 |
-
$html .= sprintf(' data-wpt-id="%s"', preg_replace('/\[/', '-', preg_replace('/\]/', '', $element['#name'])));
|
1155 |
} else {
|
1156 |
-
$html .= sprintf(' data-wpt-id="%s_%s"', $this->_id, $element['#id']);
|
1157 |
}
|
1158 |
-
if (array_key_exists('#name', $element) && $element['#name']) {
|
1159 |
-
if (!is_admin() && $this->_isRepetitive($element)) {
|
1160 |
-
$html .= sprintf(' data-wpt-name="%s"', preg_replace('/\[.+$/', '', $element['#name']));
|
1161 |
} else {
|
1162 |
-
if (preg_match('/^wpcf_post_relationship\[\d+\]\[\d+\]\[[^\]]+\]/', $element['#name'])) {
|
1163 |
$html .= sprintf(
|
1164 |
-
|
|
|
1165 |
} else {
|
1166 |
-
$html .= sprintf(' data-wpt-name="%s"', $element['#name']);
|
1167 |
}
|
1168 |
}
|
1169 |
}
|
@@ -1171,60 +1217,63 @@ class Enlimbo_Forms {
|
|
1171 |
return $html;
|
1172 |
}
|
1173 |
|
1174 |
-
private function _getStatndardPatern($element, $default = false)
|
1175 |
-
|
|
|
1176 |
return $element['#pattern'];
|
1177 |
}
|
1178 |
-
if ($default) {
|
1179 |
return $default;
|
1180 |
}
|
1181 |
-
if (is_admin()) {
|
1182 |
return '<BEFORE><LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
|
1183 |
}
|
1184 |
return '<BEFORE><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
|
1185 |
}
|
1186 |
|
1187 |
-
private function _isRepetitive($element)
|
1188 |
-
|
|
|
1189 |
return false;
|
1190 |
}
|
1191 |
-
return array_key_exists('#repetitive', $element) && $element['#repetitive'];
|
1192 |
-
}
|
1193 |
-
|
1194 |
-
static function json_encode($array) {
|
1195 |
-
// php > 5.3 do not escape utf-8 characters using native constant argument
|
1196 |
-
if (defined('JSON_UNESCAPED_UNICODE')) {
|
1197 |
-
return json_encode($array, JSON_UNESCAPED_UNICODE);
|
1198 |
-
}
|
1199 |
-
// fallback for php < 5.3 to support unicode characters in json string
|
1200 |
-
else {
|
1201 |
-
if (function_exists('mb_decode_numericentity')) {
|
1202 |
-
return self::json_encode_unescaped_unicode($array);
|
1203 |
-
} else {
|
1204 |
-
return json_encode($array);
|
1205 |
-
}
|
1206 |
-
}
|
1207 |
-
}
|
1208 |
-
|
1209 |
-
/**
|
1210 |
-
* @param $arr
|
1211 |
-
* @return string
|
1212 |
-
* courtesy from: http://www.php.net/manual/ru/function.json-encode.php#105789
|
1213 |
-
*/
|
1214 |
-
public static function json_encode_unescaped_unicode($arr) {
|
1215 |
-
|
1216 |
-
array_walk_recursive($arr, array(__CLASS__, 'json_unescaped_unicode_walk_callback'));
|
1217 |
-
|
1218 |
-
return mb_decode_numericentity(json_encode($arr), array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
|
1219 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1220 |
|
1221 |
/*
|
1222 |
* Helper function to json_encode with UTF-8 support for php < 5.3
|
1223 |
*/
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
$item = mb_encode_numericentity($item, array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
|
1228 |
-
}
|
1229 |
-
|
1230 |
}
|
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 |
* @link http://enlimbo.net/forms
|
28 |
* @author srdjan <srdjan@enlimbo.net>
|
29 |
*
|
30 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.eforms.php $
|
31 |
+
* $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
|
32 |
+
* $LastChangedRevision: 970205 $
|
33 |
+
* $LastChangedBy: brucepearson $
|
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 |
*/
|
80 |
public $form_settings = array();
|
81 |
|
82 |
+
public function __construct( $id )
|
83 |
+
{
|
84 |
/**
|
85 |
* default settings
|
86 |
*/
|
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 |
* @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 |
* @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 |
*
|
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 |
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 |
*
|
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 |
*
|
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 |
*
|
272 |
* @return type
|
273 |
*/
|
274 |
+
public function renderForm()
|
275 |
+
{
|
276 |
// loop over elements and render them
|
277 |
return $this->renderElements($this->_elements);
|
278 |
}
|
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 |
* @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 |
* @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 |
}
|
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'] .= '*';
|
395 |
}
|
396 |
+
$element['#attributes']['data-wpt-validate'] = esc_js( 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_js( 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 |
return $this->{$method}($element);
|
410 |
}
|
411 |
}
|
416 |
* @param array $element
|
417 |
* @return string
|
418 |
*/
|
419 |
+
private function _setElementAttributes($element)
|
420 |
+
{
|
421 |
$attributes = '';
|
422 |
|
423 |
$classes = array();
|
424 |
$classes[] = $this->css_class . '-' . $element['#type'];
|
425 |
$classes[] = 'form-' . $element['#type'];
|
426 |
|
427 |
+
if ( $this->form_settings['use_bootstrap'] ) {
|
428 |
+
switch( $element['#type'] ) {
|
429 |
+
case 'hidden':
|
430 |
+
case 'button':
|
431 |
+
case 'submit':
|
432 |
+
case 'radio':
|
433 |
+
case 'checkbox':
|
434 |
+
case 'file':
|
435 |
+
break;
|
436 |
+
default:
|
437 |
+
$classes[] = 'form-control';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
}
|
439 |
} else {
|
440 |
+
$classes[] = $element['#type'];
|
|
|
|
|
441 |
}
|
442 |
|
443 |
+
if ( isset( $element['#attributes'] )
|
444 |
+
&& !empty( $element['#attributes'] )
|
445 |
+
) {
|
446 |
+
if ( isset( $element['#attributes']['class'] ) ) {
|
447 |
+
$element['#attributes']['class'] .= ' ' . implode( ' ', $classes );
|
448 |
+
} else {
|
449 |
+
$element['#attributes']['class'] = implode( ' ', $classes );
|
450 |
+
}
|
451 |
+
} else {
|
452 |
+
$element['#attributes'] = array(
|
453 |
+
'class' => implode( ' ', $classes )
|
454 |
+
);
|
455 |
+
}
|
456 |
+
|
457 |
+
foreach ($element['#attributes'] as $attribute => $value) {
|
458 |
+
// Prevent undesired elements
|
459 |
+
if (in_array($attribute, array('id', 'name'))) {
|
460 |
+
continue;
|
461 |
+
}
|
462 |
+
// Don't set disabled for checkbox
|
463 |
+
if ($attribute == 'disabled' && $element['#type'] == 'checkbox') {
|
464 |
+
continue;
|
465 |
+
}
|
466 |
+
// Set return string
|
467 |
+
$attributes .= ' ' . $attribute . '="' . $value . '"';
|
468 |
+
}
|
469 |
|
470 |
return $attributes;
|
471 |
}
|
475 |
*
|
476 |
* @param array $element
|
477 |
*/
|
478 |
+
private function _setRender($element)
|
479 |
+
{
|
480 |
if (!isset($element['#id'])) {
|
481 |
if (isset($element['#attributes']['id'])) {
|
482 |
$element['#id'] = $element['#attributes']['id'];
|
497 |
* label
|
498 |
*/
|
499 |
$element['_render']['label'] = '';
|
500 |
+
if ( isset($element['#title']) ) {
|
501 |
$classes = array();
|
502 |
$classes[] = sprintf('%s-label', $this->css_class);
|
503 |
$classes[] = sprintf('%s-%s-label', $this->css_class, $element['#type']);
|
504 |
+
if ( $this->form_settings['use_bootstrap']) {
|
505 |
+
switch( $element['#type'] ) {
|
506 |
+
case 'checkbox':
|
507 |
+
case 'radio':
|
508 |
+
$classes[] = 'control-label';
|
509 |
+
break;
|
510 |
}
|
511 |
}
|
512 |
$element['_render']['label'] .= sprintf(
|
513 |
+
'<label class="%s" for="%s">',
|
514 |
+
implode(' ', $classes),
|
515 |
+
$element['#id']
|
516 |
);
|
517 |
$element['_render']['label'] .= stripslashes($element['#title']);
|
518 |
$element['_render']['label'] .= '</label>';
|
519 |
}
|
520 |
+
|
521 |
return $element;
|
522 |
}
|
523 |
|
530 |
* Accepts: <prefix><suffix><label><title><desription><error>
|
531 |
* @param array $element
|
532 |
*/
|
533 |
+
private function _pattern($pattern, $element)
|
534 |
+
{
|
535 |
$pattern = strtolower($pattern);
|
536 |
foreach ($element['_render'] as $key => $value) {
|
537 |
$pattern = str_replace('<' . strtolower($key) . '>', $value, $pattern);
|
546 |
* @param string $output
|
547 |
* @return string
|
548 |
*/
|
549 |
+
private function _wrapElement($element, $output)
|
550 |
+
{
|
551 |
if (!empty($element['#inline'])) {
|
552 |
return $output;
|
553 |
}
|
554 |
$classes = array();
|
555 |
$classes[] = 'form-item';
|
556 |
$classes[] = 'form-item-' . $element['#type'];
|
557 |
+
$classes[] = $this->css_class . '-item';
|
558 |
+
$classes[] = $this->css_class . '-item-' . $element['#type'];
|
559 |
+
if ( $this->form_settings['use_bootstrap'] ) {
|
560 |
$classes[] = 'form-group';
|
561 |
}
|
562 |
+
if ( preg_match( '/_hidden$/', $element['#id'] ) && !is_admin() ) {
|
563 |
$classes[] = 'wpt-form-hide-container';
|
564 |
}
|
565 |
+
if ( is_admin() ) {
|
566 |
return sprintf(
|
567 |
+
'<div id="%s-wrapper" class="%s">%s</div>',
|
568 |
+
$element['#id'],
|
569 |
+
implode( ' ', $classes ),
|
570 |
+
$output
|
571 |
);
|
572 |
}
|
573 |
return $output;
|
579 |
* @param string $element
|
580 |
* @return string
|
581 |
*/
|
582 |
+
private function _setElementTitle($element)
|
583 |
+
{
|
584 |
$output = '';
|
585 |
if (isset($element['#title'])) {
|
586 |
$output .= '<div class="title '
|
599 |
* @param array $element
|
600 |
* @return string
|
601 |
*/
|
602 |
+
private function _setElementDescription($element)
|
603 |
+
{
|
604 |
+
if ( empty( $element['#description'] ) ) return '';
|
605 |
$element['#description'] = stripslashes($element['#description']);
|
606 |
$output = "\r\n"
|
607 |
. '<div class="description '
|
620 |
* @param array $element
|
621 |
* @return string
|
622 |
*/
|
623 |
+
public function renderError($element)
|
624 |
+
{
|
625 |
if (!isset($element['#error'])) {
|
626 |
return '';
|
627 |
}
|
646 |
* @param string $wrap_content HTML formatted output of child elements
|
647 |
* @return string
|
648 |
*/
|
649 |
+
public function fieldset($element, $action = 'open', $wrap_content = '')
|
650 |
+
{
|
651 |
$collapsible_open = '<div class="fieldset-wrapper">';
|
652 |
$collapsible_close = '</div>';
|
653 |
$legend_class = '';
|
657 |
if (!isset($element['_attributes_string'])) {
|
658 |
$element['_attributes_string'] = $this->_setElementAttributes($element);
|
659 |
}
|
660 |
+
if ((isset($element['#collapsible']) && $element['#collapsible'])
|
661 |
+
|| (isset($element['#collapsed']) && $element['#collapsed'])) {
|
662 |
$collapsible_open = '<div class="collapsible fieldset-wrapper">';
|
663 |
$collapsible_close = '</div>';
|
664 |
$legend_class = ' class="legend-expanded"';
|
665 |
}
|
666 |
if (isset($element['#collapsed']) && $element['#collapsed']) {
|
667 |
+
$collapsible_open = str_replace('class="', 'class="collapsed ',
|
668 |
+
$collapsible_open);
|
669 |
$legend_class = ' class="legend-collapsed"';
|
670 |
}
|
671 |
$output = '';
|
719 |
* @param array $element
|
720 |
* @return string
|
721 |
*/
|
722 |
+
public function checkbox($element)
|
723 |
+
{
|
724 |
$element['#type'] = 'checkbox';
|
725 |
$element = $this->_setRender($element);
|
726 |
$element['_render']['element'] = '<input type="checkbox"';
|
727 |
+
foreach( array( 'id', 'name' ) as $key ) {
|
728 |
+
$element['_render']['element'] .= sprintf( ' %s="%s"', $key, $element['#'.$key] );
|
729 |
}
|
730 |
/**
|
731 |
* type and data_id
|
732 |
*/
|
733 |
+
$element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
|
734 |
+
$element['_render']['element'] .= $this->_getDataWptId( $element );
|
735 |
|
736 |
$element['_render']['element'] .= ' value="';
|
737 |
/**
|
739 |
* but if is defined default value, use default
|
740 |
*/
|
741 |
$value = 1;
|
742 |
+
if ( array_key_exists( '#default_value', $element ) ) {
|
743 |
$value = $element['#default_value'];
|
744 |
}
|
745 |
+
$element['_render']['element'] .= ( empty($element['#value']) && !preg_match( '/^0$/', $element['#value']) )? $value:esc_attr($element['#value']);
|
746 |
$element['_render']['element'] .= '"' . $element['_attributes_string'];
|
747 |
if (
|
748 |
+
(
|
749 |
!$this->isSubmitted() && (
|
750 |
+
( !empty($element['#default_value']) && $element['#default_value'] == $element['#value'] )
|
751 |
+
|| ( isset($element['#checked']) && $element['#checked'] )
|
752 |
)
|
753 |
+
)
|
754 |
+
|| ($this->isSubmitted() && !empty($element['#value']))
|
755 |
) {
|
756 |
$element['_render']['element'] .= ' checked="checked"';
|
757 |
}
|
760 |
}
|
761 |
$element['_render']['element'] .= ' />';
|
762 |
|
763 |
+
$pattern = $this->_getStatndardPatern( $element, '<BEFORE><PREFIX><ELEMENT> <LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>');
|
764 |
$output = $this->_pattern($pattern, $element);
|
765 |
$output = $this->_wrapElement($element, $output);
|
766 |
return $output . "\r\n";
|
775 |
* @param array $element
|
776 |
* @return string
|
777 |
*/
|
778 |
+
public function checkboxes($element)
|
779 |
+
{
|
780 |
$element['#type'] = 'checkboxes';
|
781 |
$element = $this->_setRender($element);
|
782 |
$clone = $element;
|
788 |
}
|
789 |
$element['_render']['element'] .= $this->checkbox($value);
|
790 |
}
|
791 |
+
$pattern = $this->_getStatndardPatern( $element, '<BEFORE><PREFIX><TITLE><DESCRIPTION><ELEMENT><SUFFIX><AFTER>' );
|
792 |
$output = $this->_pattern($pattern, $element);
|
793 |
$output = $this->_wrapElement($element, $output);
|
794 |
return $output;
|
800 |
* @param array $element
|
801 |
* @return string
|
802 |
*/
|
803 |
+
public function radio($element)
|
804 |
+
{
|
805 |
$element['#type'] = 'radio';
|
806 |
$element = $this->_setRender($element);
|
807 |
$element['_render']['element'] = '<input type="radio" id="'
|
810 |
$element['_render']['element'] .= isset($element['#value']) ? htmlspecialchars($element['#value']) : $this->_count['radio'];
|
811 |
$element['_render']['element'] .= '"';
|
812 |
$element['_render']['element'] .= $element['_attributes_string'];
|
813 |
+
$element['_render']['element'] .= ( isset($element['#value'])
|
814 |
+
&& $element['#value'] === $element['#default_value']) ? ' checked="checked"' : '';
|
815 |
if (isset($element['#disable']) && $element['#disable']) {
|
816 |
$element['_render']['element'] .= ' disabled="disabled"';
|
817 |
}
|
818 |
+
if ( array_key_exists( '#types-value', $element ) ) {
|
819 |
+
$element['_render']['element'] .= sprintf( ' data-types-value="%s"', $element['#types-value'] );
|
820 |
}
|
821 |
/**
|
822 |
* type and data_id
|
823 |
*/
|
824 |
+
$element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
|
825 |
+
$element['_render']['element'] .= $this->_getDataWptId( $element );
|
826 |
|
827 |
$element['_render']['element'] .= ' />';
|
828 |
+
|
829 |
$pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><PREFIX><ELEMENT> <LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
|
830 |
$output = $this->_pattern($pattern, $element);
|
831 |
$output = $this->_wrapElement($element, $output);
|
841 |
* @param array $element
|
842 |
* @return string
|
843 |
*/
|
844 |
+
public function radios($element)
|
845 |
+
{
|
846 |
if (!isset($element['#name']) || empty($element['#name'])) {
|
847 |
return FALSE;
|
848 |
}
|
866 |
} else {
|
867 |
$pattern = '<BEFORE><PREFIX><DESCRIPTION><ELEMENT><SUFFIX><AFTER>';
|
868 |
}
|
869 |
+
|
870 |
$pattern = $this->_getStatndardPatern($element, $pattern);
|
871 |
$output = $this->_pattern($pattern, $element);
|
872 |
$output = $this->_wrapElement($element, $output);
|
879 |
* @param array $element
|
880 |
* @return string
|
881 |
*/
|
882 |
+
public function select($element)
|
883 |
+
{
|
884 |
$element = $this->_setRender($element);
|
885 |
|
886 |
$element['_render']['element'] = '';
|
887 |
$element['_render']['element'] .= '<select id="' . $element['#id'] . '" ';
|
888 |
$element['_render']['element'] .= $element['_attributes_string'];
|
889 |
+
$element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
|
890 |
/**
|
891 |
* multiple
|
892 |
*/
|
893 |
+
if ( array_key_exists( '#multiple', $element ) && $element['#multiple'] ) {
|
894 |
$element['_render']['element'] .= ' multiple="multiple"';
|
895 |
$element['_render']['element'] .= ' name="' . $element['#name'] . '[]"';
|
896 |
} else {
|
897 |
$element['_render']['element'] .= ' name="' . $element['#name'] . '"';
|
898 |
}
|
899 |
+
$element['_render']['element'] .= ">\r\n";
|
900 |
$count = 1;
|
901 |
foreach ($element['#options'] as $id => $value) {
|
902 |
if (!is_array($value)) {
|
909 |
}
|
910 |
$element['_render']['element'] .= '<option value="' . htmlspecialchars($value['#value']) . '"';
|
911 |
$element['_render']['element'] .= $this->_setElementAttributes($value);
|
912 |
+
if ( array_key_exists( '#types-value', $value ) ) {
|
913 |
+
$element['_render']['element'] .= sprintf( ' data-types-value="%s"', $value['#types-value'] );
|
914 |
}
|
915 |
/**
|
916 |
* type and data_id
|
917 |
*/
|
918 |
$element['_render']['element'] .= ' data-wpt-type="option"';
|
919 |
+
$element['_render']['element'] .= $this->_getDataWptId( $element );
|
920 |
/**
|
921 |
* selected
|
922 |
*/
|
923 |
+
if ( array_key_exists( '#multiple', $element ) && $element['#multiple'] ) {
|
924 |
+
if ( is_array( $element['#default_value'] ) && in_array( $value['#value'], $element['#default_value'] ) ) {
|
925 |
$element['_render']['element'] .= ' selected="selected"';
|
926 |
}
|
927 |
+
} elseif ( $element['#default_value'] == $value['#value']) {
|
928 |
$element['_render']['element'] .= ' selected="selected"';
|
929 |
}
|
930 |
$element['_render']['element'] .= '>';
|
934 |
$element['_render']['element'] .= '</select>';
|
935 |
$element['_render']['element'] .= PHP_EOL;
|
936 |
|
937 |
+
$pattern = $this->_getStatndardPatern( $element );
|
938 |
$output = $this->_pattern($pattern, $element);
|
939 |
$output = $this->_wrapElement($element, $output);
|
940 |
|
947 |
* @param array $element
|
948 |
* @return string
|
949 |
*/
|
950 |
+
public function textfield($element)
|
951 |
+
{
|
952 |
$element['#type'] = 'textfield';
|
953 |
$element = $this->_setRender($element);
|
954 |
|
955 |
$element['_render']['element'] = '<input type="text"';
|
956 |
//$element['_render']['element'] .= sprintf( ' data-wpt-type="%s" ', __FUNCTION__ );
|
957 |
+
$element['_render']['element'] .= sprintf( ' id="%s"', $element['#id']);
|
958 |
+
$element['_render']['element'] .= sprintf( ' name="%s"', $element['#name']);
|
959 |
+
$element['_render']['element'] .= sprintf( ' value="%s"', isset($element['#value']) ? esc_attr($element['#value']) : '' );
|
960 |
$element['_render']['element'] .= $element['_attributes_string'];
|
961 |
if (isset($element['#disable']) && $element['#disable']) {
|
962 |
$element['_render']['element'] .= ' disabled="disabled"';
|
964 |
/**
|
965 |
* type and data_id
|
966 |
*/
|
967 |
+
$element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
|
968 |
+
$element['_render']['element'] .= $this->_getDataWptId( $element );
|
969 |
|
970 |
$element['_render']['element'] .= ' />';
|
971 |
+
$pattern = $this->_getStatndardPatern( $element );
|
972 |
$output = $this->_pattern($pattern, $element);
|
973 |
$output = $this->_wrapElement($element, $output);
|
974 |
return $output . "\r\n";
|
980 |
* @param array $element
|
981 |
* @return string
|
982 |
*/
|
983 |
+
public function password($element)
|
984 |
+
{
|
985 |
$element['#type'] = 'password';
|
986 |
$element = $this->_setRender($element);
|
987 |
$element['_render']['element'] = '<input type="password" id="'
|
994 |
/**
|
995 |
* type and data_id
|
996 |
*/
|
997 |
+
$element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
|
998 |
+
$element['_render']['element'] .= $this->_getDataWptId( $element );
|
999 |
|
1000 |
$element['_render']['element'] .= ' />';
|
1001 |
$pattern = $this->_getStatndardPatern($element);
|
1010 |
* @param array $element
|
1011 |
* @return string
|
1012 |
*/
|
1013 |
+
public function textarea($element)
|
1014 |
+
{
|
1015 |
$element['#type'] = 'textarea';
|
1016 |
if (!isset($element['#attributes']['rows'])) {
|
1017 |
$element['#attributes']['rows'] = 5;
|
1026 |
/**
|
1027 |
* type and data_id
|
1028 |
*/
|
1029 |
+
$element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
|
1030 |
+
$element['_render']['element'] .= $this->_getDataWptId( $element );
|
1031 |
|
1032 |
$element['_render']['element'] .= '>';
|
1033 |
|
1034 |
$element['_render']['element'] .= isset($element['#value']) ? esc_attr($element['#value']) : '';
|
1035 |
$element['_render']['element'] .= '</textarea>' . "\r\n";
|
1036 |
+
$pattern = $this->_getStatndardPatern( $element );
|
1037 |
$output = $this->_pattern($pattern, $element);
|
1038 |
$output = $this->_wrapElement($element, $output);
|
1039 |
return $output . "\r\n";
|
1045 |
* @param array $element
|
1046 |
* @return string
|
1047 |
*/
|
1048 |
+
public function file($element)
|
1049 |
+
{
|
1050 |
$element['#type'] = 'file';
|
1051 |
$element = $this->_setRender($element);
|
1052 |
$element['_render']['element'] = '<input type="file" id="'
|
1058 |
/**
|
1059 |
* type and data_id
|
1060 |
*/
|
1061 |
+
$element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
|
1062 |
+
$element['_render']['element'] .= $this->_getDataWptId( $element );
|
1063 |
|
1064 |
$element['_render']['element'] .= ' />';
|
1065 |
+
$pattern = $this->_getStatndardPatern( $element );
|
1066 |
$output = $this->_pattern($pattern, $element);
|
1067 |
$output = $this->_wrapElement($element, $output);
|
1068 |
return $output;
|
1074 |
* @param array $element
|
1075 |
* @return string
|
1076 |
*/
|
1077 |
+
public function markup($element)
|
1078 |
+
{
|
1079 |
return $element['#markup'];
|
1080 |
}
|
1081 |
|
1085 |
* @param array $element
|
1086 |
* @return string
|
1087 |
*/
|
1088 |
+
public function hidden($element)
|
1089 |
+
{
|
1090 |
$element['#type'] = 'hidden';
|
1091 |
$element = $this->_setRender($element);
|
1092 |
$output = '<input type="hidden" id="' . $element['#id'] . '" name="'
|
1093 |
. $element['#name'] . '" value="';
|
1094 |
$output .= isset($element['#value']) ? $element['#value'] : 1;
|
1095 |
+
$output .= '"' . $element['_attributes_string'] . $this->_getDataWptId( $element ) . ' />';
|
1096 |
return $output;
|
1097 |
}
|
1098 |
|
1102 |
* @param array $element
|
1103 |
* @return string
|
1104 |
*/
|
1105 |
+
public function reset($element)
|
1106 |
+
{
|
1107 |
return $this->submit($element, 'reset', 'Reset');
|
1108 |
}
|
1109 |
|
1113 |
* @param array $element
|
1114 |
* @return string
|
1115 |
*/
|
1116 |
+
public function button($element)
|
1117 |
+
{
|
1118 |
return $this->submit($element, 'button', 'Button');
|
1119 |
}
|
1120 |
|
1128 |
* @param string $title
|
1129 |
* @return string
|
1130 |
*/
|
1131 |
+
public function submit($element, $type = 'submit', $title = 'Submit')
|
1132 |
+
{
|
1133 |
$element['#type'] = $type;
|
1134 |
$element = $this->_setRender($element);
|
1135 |
$element['_render']['element'] = '<input type="' . $type . '" id="'
|
1137 |
$element['_render']['element'] .= isset($element['#value']) ? $element['#value'] : $title;
|
1138 |
$element['_render']['element'] .= '"' . $element['_attributes_string']
|
1139 |
. ' />';
|
1140 |
+
$pattern = $this->_getStatndardPatern( $element, '<BEFORE><PREFIX><ELEMENT><SUFFIX><AFTER>' );
|
1141 |
$output = $this->_pattern($pattern, $element);
|
1142 |
return $output;
|
1143 |
}
|
1148 |
* @param type $element
|
1149 |
* @return type mixed
|
1150 |
*/
|
1151 |
+
public function getSubmittedData($element)
|
1152 |
+
{
|
1153 |
$name = $element['#name'];
|
1154 |
if (strpos($name, '[') === false) {
|
1155 |
if ($element['#type'] == 'file') {
|
1156 |
return $_FILES[$name]['tmp_name'];
|
1157 |
}
|
1158 |
+
return isset($_REQUEST[$name]) ? $_REQUEST[$name] : in_array($element['#type'],
|
1159 |
+
array('textfield', 'textarea')) ? '' : 0;
|
1160 |
}
|
1161 |
|
1162 |
$parts = explode('[', $name);
|
1163 |
+
$parts = array_map(create_function('&$a', 'return trim($a, \']\');'),
|
1164 |
+
$parts);
|
|
|
|
|
1165 |
if (!isset($_REQUEST[$parts[0]])) {
|
1166 |
return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
|
1167 |
}
|
1170 |
$key = $parts[$index];
|
1171 |
// We're at the end but no data retrieved
|
1172 |
if (!isset($parts[$index + 1])) {
|
1173 |
+
return in_array($element['#type'],
|
1174 |
+
array('textfield', 'textarea')) ? '' : 0;
|
1175 |
}
|
1176 |
$key_next = $parts[$index + 1];
|
1177 |
if ($index > 0) {
|
1178 |
if (!isset($search[$key])) {
|
1179 |
+
return in_array($element['#type'],
|
1180 |
+
array('textfield', 'textarea')) ? '' : 0;
|
1181 |
} else {
|
1182 |
$search = $search[$key];
|
1183 |
}
|
1191 |
return 0;
|
1192 |
}
|
1193 |
|
1194 |
+
private function _getDataWptId($element)
|
1195 |
+
{
|
1196 |
$html = '';
|
1197 |
+
if ( array_key_exists( '#id', $element ) ) {
|
1198 |
+
if ( is_admin() ) {
|
1199 |
+
$html .= sprintf( ' data-wpt-id="%s"', preg_replace( '/\[/', '-', preg_replace( '/\]/', '', $element['#name'] ) ) );
|
1200 |
} else {
|
1201 |
+
$html .= sprintf( ' data-wpt-id="%s_%s"', $this->_id, $element['#id'] );
|
1202 |
}
|
1203 |
+
if ( array_key_exists( '#name', $element ) && $element['#name'] ) {
|
1204 |
+
if ( !is_admin() && $this->_isRepetitive($element)) {
|
1205 |
+
$html .= sprintf( ' data-wpt-name="%s"', preg_replace( '/\[.+$/', '', $element['#name'] ) );
|
1206 |
} else {
|
1207 |
+
if ( preg_match( '/^wpcf_post_relationship\[\d+\]\[\d+\]\[[^\]]+\]/', $element['#name'] ) ) {
|
1208 |
$html .= sprintf(
|
1209 |
+
' data-wpt-name="%s"',
|
1210 |
+
preg_replace( '/^wpcf_post_relationship\[\d+\]\[(\d+)\]\[wpcf-([^\]]+)\]/', "wpcf[$2-$1]", $element['#name'] ) );
|
1211 |
} else {
|
1212 |
+
$html .= sprintf( ' data-wpt-name="%s"', $element['#name'] );
|
1213 |
}
|
1214 |
}
|
1215 |
}
|
1217 |
return $html;
|
1218 |
}
|
1219 |
|
1220 |
+
private function _getStatndardPatern($element, $default = false )
|
1221 |
+
{
|
1222 |
+
if ( isset($element['#pattern'] ) ) {
|
1223 |
return $element['#pattern'];
|
1224 |
}
|
1225 |
+
if ( $default ) {
|
1226 |
return $default;
|
1227 |
}
|
1228 |
+
if ( is_admin() ) {
|
1229 |
return '<BEFORE><LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
|
1230 |
}
|
1231 |
return '<BEFORE><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
|
1232 |
}
|
1233 |
|
1234 |
+
private function _isRepetitive($element)
|
1235 |
+
{
|
1236 |
+
if ( !is_array($element) ) {
|
1237 |
return false;
|
1238 |
}
|
1239 |
+
return array_key_exists( '#repetitive', $element ) && $element['#repetitive'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1240 |
}
|
1241 |
+
|
1242 |
+
static function json_encode( $array )
|
1243 |
+
{
|
1244 |
+
// php > 5.3 do not escape utf-8 characters using native constant argument
|
1245 |
+
if( defined('JSON_UNESCAPED_UNICODE') )
|
1246 |
+
{
|
1247 |
+
return json_encode($array, JSON_UNESCAPED_UNICODE );
|
1248 |
+
}
|
1249 |
+
// fallback for php < 5.3 to support unicode characters in json string
|
1250 |
+
else
|
1251 |
+
{
|
1252 |
+
if (function_exists('mb_decode_numericentity')) {
|
1253 |
+
return self::json_encode_unescaped_unicode( $array );
|
1254 |
+
} else {
|
1255 |
+
return json_encode( $array );
|
1256 |
+
}
|
1257 |
+
}
|
1258 |
+
}
|
1259 |
+
|
1260 |
+
/**
|
1261 |
+
* @param $arr
|
1262 |
+
* @return string
|
1263 |
+
* courtesy from: http://www.php.net/manual/ru/function.json-encode.php#105789
|
1264 |
+
*/
|
1265 |
+
public static function json_encode_unescaped_unicode($arr)
|
1266 |
+
{
|
1267 |
+
|
1268 |
+
array_walk_recursive($arr, array(__CLASS__, 'json_unescaped_unicode_walk_callback' ));
|
1269 |
+
|
1270 |
+
return mb_decode_numericentity(json_encode($arr), array (0x80, 0xffff, 0, 0xffff), 'UTF-8');
|
1271 |
+
}
|
1272 |
|
1273 |
/*
|
1274 |
* Helper function to json_encode with UTF-8 support for php < 5.3
|
1275 |
*/
|
1276 |
+
public static function json_unescaped_unicode_walk_callback (&$item, $key){
|
1277 |
+
if (is_string($item)) $item = mb_encode_numericentity($item, array (0x80, 0xffff, 0, 0xffff), 'UTF-8');
|
1278 |
+
}
|
|
|
|
|
|
|
1279 |
}
|
embedded/common/toolset-forms/classes/class.field_factory.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
|
3 |
/**
|
4 |
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
6 |
-
* $LastChangedDate:
|
7 |
-
* $LastChangedRevision:
|
8 |
-
* $LastChangedBy:
|
9 |
*
|
10 |
*/
|
11 |
|
@@ -28,17 +28,6 @@ abstract class FieldFactory extends FieldAbstract
|
|
28 |
{
|
29 |
$cred_cred_settings = get_option( 'cred_cred_settings' );
|
30 |
$this->_use_bootstrap = is_array($cred_cred_settings) && array_key_exists( 'use_bootstrap', $cred_cred_settings ) && $cred_cred_settings['use_bootstrap'];
|
31 |
-
$this->set_placeholder_as_attribute();
|
32 |
-
}
|
33 |
-
|
34 |
-
public function set_placeholder_as_attribute()
|
35 |
-
{
|
36 |
-
if ( !isset($this->_data['attribute']) ) {
|
37 |
-
$this->_data['attribute'] = array();
|
38 |
-
}
|
39 |
-
if ( isset($this->_data['placeholder']) && !empty($this->_data['placeholder'])) {
|
40 |
-
$this->_data['attribute']['placeholder'] = htmlentities(stripcslashes($this->_data['placeholder']));
|
41 |
-
}
|
42 |
}
|
43 |
|
44 |
public function set_metaform($metaform)
|
@@ -83,21 +72,11 @@ abstract class FieldFactory extends FieldAbstract
|
|
83 |
|
84 |
public function getValue()
|
85 |
{
|
86 |
-
|
87 |
-
$value = $this->_value;
|
88 |
-
$value = apply_filters( 'wpcf_fields_value_get', $value, $post );
|
89 |
-
if ( array_key_exists('slug', $this->_data ) ) {
|
90 |
-
$value = apply_filters( 'wpcf_fields_slug_' . $this->_data['slug'] . '_value_get', $value, $post );
|
91 |
-
}
|
92 |
-
$value = apply_filters( 'wpcf_fields_type_' . $this->_data['type'] . '_value_get', $value, $post );
|
93 |
-
return $value;
|
94 |
}
|
95 |
|
96 |
-
public function getTitle(
|
97 |
{
|
98 |
-
if ( $_title && empty($this->_data['title']) && isset($this->_data['_title']) ) {
|
99 |
-
return $this->_data['_title'];
|
100 |
-
}
|
101 |
return $this->_data['title'];
|
102 |
}
|
103 |
|
@@ -143,14 +122,6 @@ abstract class FieldFactory extends FieldAbstract
|
|
143 |
return array();
|
144 |
}
|
145 |
|
146 |
-
public function getWPMLAction()
|
147 |
-
{
|
148 |
-
if ( array_key_exists( 'wpml_action', $this->_data ) ) {
|
149 |
-
return $this->_data['wpml_action'];
|
150 |
-
}
|
151 |
-
return 0;
|
152 |
-
}
|
153 |
-
|
154 |
public static function registerScripts() {}
|
155 |
public static function registerStyles() {}
|
156 |
public static function addFilters() {}
|
2 |
|
3 |
/**
|
4 |
*
|
5 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.field_factory.php $
|
6 |
+
* $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
|
7 |
+
* $LastChangedRevision: 970205 $
|
8 |
+
* $LastChangedBy: brucepearson $
|
9 |
*
|
10 |
*/
|
11 |
|
28 |
{
|
29 |
$cred_cred_settings = get_option( 'cred_cred_settings' );
|
30 |
$this->_use_bootstrap = is_array($cred_cred_settings) && array_key_exists( 'use_bootstrap', $cred_cred_settings ) && $cred_cred_settings['use_bootstrap'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
public function set_metaform($metaform)
|
72 |
|
73 |
public function getValue()
|
74 |
{
|
75 |
+
return $this->_value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
78 |
+
public function getTitle()
|
79 |
{
|
|
|
|
|
|
|
80 |
return $this->_data['title'];
|
81 |
}
|
82 |
|
122 |
return array();
|
123 |
}
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
public static function registerScripts() {}
|
126 |
public static function registerStyles() {}
|
127 |
public static function addFilters() {}
|
embedded/common/toolset-forms/classes/class.fieldconfig.php
CHANGED
@@ -1,15 +1,13 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
6 |
-
* $LastChangedDate: 2015-
|
7 |
-
* $LastChangedRevision:
|
8 |
* $LastChangedBy: iworks $
|
9 |
*
|
10 |
*/
|
11 |
if (!class_exists("FieldConfig")) {
|
12 |
-
|
13 |
/**
|
14 |
* Description of FieldConfig
|
15 |
*
|
@@ -30,10 +28,10 @@ if (!class_exists("FieldConfig")) {
|
|
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,41 +45,32 @@ if (!class_exists("FieldConfig")) {
|
|
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
|
|
|
60 |
switch ($type) {
|
61 |
case 'date':
|
62 |
$this->add_time = false;
|
63 |
-
|
64 |
-
|
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 |
-
|
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':
|
@@ -89,35 +78,33 @@ if (!class_exists("FieldConfig")) {
|
|
89 |
break;
|
90 |
|
91 |
case 'checkbox':
|
92 |
-
$this->default_value = isset($field_arr['data']['checked'])
|
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
|
104 |
$arr = array();
|
105 |
switch ($type) {
|
106 |
case 'checkbox':
|
107 |
-
$arr
|
108 |
break;
|
109 |
case 'checkboxes':
|
110 |
-
foreach ($attrs['actual_titles'] as $refvalue
|
111 |
$value = $attrs['actual_values'][$refvalue];
|
112 |
-
$arr[$refvalue] = array('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
|
121 |
$arr[$refvalue] = array(
|
122 |
'value' => $refvalue,
|
123 |
'title' => $title,
|
@@ -126,7 +113,7 @@ if (!class_exists("FieldConfig")) {
|
|
126 |
}
|
127 |
break;
|
128 |
case 'radios':
|
129 |
-
foreach ($attrs['actual_titles'] as $refvalue
|
130 |
$arr[$refvalue] = array(
|
131 |
'value' => $refvalue,
|
132 |
'title' => $title,
|
@@ -135,10 +122,10 @@ if (!class_exists("FieldConfig")) {
|
|
135 |
'types-value' => $attrs['actual_values'][$refvalue],
|
136 |
);
|
137 |
}
|
138 |
-
|
139 |
default:
|
140 |
return;
|
141 |
-
|
142 |
}
|
143 |
$this->options = $arr;
|
144 |
}
|
@@ -153,13 +140,13 @@ if (!class_exists("FieldConfig")) {
|
|
153 |
'default_value' => $this->getDefaultValue(),
|
154 |
'description' => $this->getDescription(),
|
155 |
'repetitive' => $this->isRepetitive(),
|
156 |
-
/*
|
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,7 +175,8 @@ if (!class_exists("FieldConfig")) {
|
|
188 |
return $this->title;
|
189 |
}
|
190 |
|
191 |
-
public function getDisplay()
|
|
|
192 |
return $this->display;
|
193 |
}
|
194 |
|
@@ -244,11 +232,10 @@ if (!class_exists("FieldConfig")) {
|
|
244 |
$this->id = $id;
|
245 |
}
|
246 |
|
247 |
-
public function setDisplay($display)
|
|
|
248 |
$this->display = $display;
|
249 |
}
|
250 |
-
|
251 |
}
|
252 |
-
|
253 |
}
|
254 |
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.fieldconfig.php $
|
5 |
+
* $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
|
6 |
+
* $LastChangedRevision: 1180956 $
|
7 |
* $LastChangedBy: iworks $
|
8 |
*
|
9 |
*/
|
10 |
if (!class_exists("FieldConfig")) {
|
|
|
11 |
/**
|
12 |
* Description of FieldConfig
|
13 |
*
|
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 |
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 |
+
$this->default_value = isset( $field_arr['attr']['actual_value'][0] )? $field_arr['attr']['actual_value'][0] : null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
break;
|
75 |
|
76 |
case 'radios':
|
78 |
break;
|
79 |
|
80 |
case 'checkbox':
|
81 |
+
$this->default_value = isset($field_arr['data']['checked'])?$field_arr['data']['checked']:0;
|
|
|
|
|
82 |
break;
|
83 |
+
|
84 |
default:
|
85 |
$this->default_value = "";
|
86 |
break;
|
87 |
}
|
88 |
}
|
89 |
|
90 |
+
public function setOptions($name,$type,$values,$attrs) {
|
91 |
$arr = array();
|
92 |
switch ($type) {
|
93 |
case 'checkbox':
|
94 |
+
$arr=$attrs;
|
95 |
break;
|
96 |
case 'checkboxes':
|
97 |
+
foreach ($attrs['actual_titles'] as $refvalue=>$title) {
|
98 |
$value = $attrs['actual_values'][$refvalue];
|
99 |
+
$arr[$refvalue] = array('value'=>$refvalue,'title'=>$title,'name'=>$name,'data-value'=>$value);
|
100 |
+
if ( in_array($refvalue, $attrs['default']) ) {
|
101 |
$arr[$refvalue]['checked'] = true;
|
102 |
}
|
103 |
}
|
104 |
break;
|
105 |
case 'select':
|
106 |
$values = $attrs['options'];
|
107 |
+
foreach ($values as $refvalue=>$title) {
|
108 |
$arr[$refvalue] = array(
|
109 |
'value' => $refvalue,
|
110 |
'title' => $title,
|
113 |
}
|
114 |
break;
|
115 |
case 'radios':
|
116 |
+
foreach ($attrs['actual_titles'] as $refvalue=>$title) {
|
117 |
$arr[$refvalue] = array(
|
118 |
'value' => $refvalue,
|
119 |
'title' => $title,
|
122 |
'types-value' => $attrs['actual_values'][$refvalue],
|
123 |
);
|
124 |
}
|
125 |
+
break;
|
126 |
default:
|
127 |
return;
|
128 |
+
break;
|
129 |
}
|
130 |
$this->options = $arr;
|
131 |
}
|
140 |
'default_value' => $this->getDefaultValue(),
|
141 |
'description' => $this->getDescription(),
|
142 |
'repetitive' => $this->isRepetitive(),
|
143 |
+
/*'name' => $base_name."[".$this->getType()."]",*/
|
144 |
'name' => $this->getName(),
|
145 |
'value' => $this->getValue(),
|
146 |
'add_time' => $this->getAddTime(),
|
147 |
'validation' => array(),
|
148 |
'display' => $this->getDisplay(),
|
149 |
+
'attribute' => $this->getAttr()
|
150 |
);
|
151 |
return $this->config;
|
152 |
}
|
175 |
return $this->title;
|
176 |
}
|
177 |
|
178 |
+
public function getDisplay()
|
179 |
+
{
|
180 |
return $this->display;
|
181 |
}
|
182 |
|
232 |
$this->id = $id;
|
233 |
}
|
234 |
|
235 |
+
public function setDisplay($display)
|
236 |
+
{
|
237 |
$this->display = $display;
|
238 |
}
|
|
|
239 |
}
|
|
|
240 |
}
|
241 |
|
embedded/common/toolset-forms/classes/class.file.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
-
* $HeadURL:
|
5 |
-
* $LastChangedDate:
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.textfield.php';
|
@@ -20,57 +20,40 @@ class WPToolset_Field_File extends WPToolset_Field_Textfield
|
|
20 |
protected $_validation = array('required');
|
21 |
//protected $_defaults = array('filename' => '', 'button_style' => 'btn2');
|
22 |
|
23 |
-
public function init()
|
24 |
-
{
|
25 |
WPToolset_Field_File::file_enqueue_scripts();
|
26 |
-
$this->set_placeholder_as_attribute();
|
27 |
}
|
28 |
|
29 |
-
public static function file_enqueue_scripts()
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
array('jquery', 'jquery-masonry'),
|
35 |
-
WPTOOLSET_FORMS_VERSION,
|
36 |
-
true
|
37 |
-
);
|
38 |
-
|
39 |
if ( !wp_script_is( 'wptoolset-field-file', 'enqueued' ) ) {
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
47 |
|
48 |
-
public function enqueueStyles()
|
49 |
-
|
50 |
}
|
51 |
|
52 |
-
|
53 |
-
*
|
54 |
-
* @global object $wpdb
|
55 |
-
*
|
56 |
-
*/
|
57 |
-
public function metaform()
|
58 |
-
{
|
59 |
$value = $this->getValue();
|
60 |
-
|
61 |
-
|
62 |
$form = array();
|
63 |
$preview = '';
|
64 |
-
|
65 |
// Get attachment by guid
|
66 |
if ( !empty( $value ) ) {
|
67 |
global $wpdb;
|
68 |
-
$attachment_id = $wpdb->get_var(
|
69 |
-
$wpdb->prepare(
|
70 |
-
"SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s",
|
71 |
-
$value
|
72 |
-
)
|
73 |
-
);
|
74 |
}
|
75 |
|
76 |
// Set preview
|
@@ -89,20 +72,20 @@ class WPToolset_Field_File extends WPToolset_Field_Textfield
|
|
89 |
}
|
90 |
|
91 |
// Set button
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
$button = sprintf(
|
107 |
'<a href="#" class="js-wpt-file-upload button button-secondary" data-wpt-type="%s">%s</a>',
|
108 |
$type,
|
@@ -114,12 +97,11 @@ class WPToolset_Field_File extends WPToolset_Field_Textfield
|
|
114 |
'#type' => 'textfield',
|
115 |
'#name' => $this->getName(),
|
116 |
'#title' => $this->getTitle(),
|
117 |
-
|
118 |
'#value' => $value,
|
119 |
'#suffix' => ' ' . $button,
|
120 |
'#validate' => $this->getValidationData(),
|
121 |
'#repetitive' => $this->isRepetitive(),
|
122 |
-
'#attributes' => $this->getAttr(),
|
123 |
);
|
124 |
|
125 |
$form[] = array(
|
@@ -129,4 +111,80 @@ class WPToolset_Field_File extends WPToolset_Field_Textfield
|
|
129 |
|
130 |
return $form;
|
131 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.file.php $
|
5 |
+
* $LastChangedDate: 2014-08-08 16:42:50 +0200 (Fri, 08 Aug 2014) $
|
6 |
+
* $LastChangedRevision: 25798 $
|
7 |
+
* $LastChangedBy: juan $
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.textfield.php';
|
20 |
protected $_validation = array('required');
|
21 |
//protected $_defaults = array('filename' => '', 'button_style' => 'btn2');
|
22 |
|
23 |
+
public function init() {
|
|
|
24 |
WPToolset_Field_File::file_enqueue_scripts();
|
|
|
25 |
}
|
26 |
|
27 |
+
public static function file_enqueue_scripts() {
|
28 |
+
wp_register_script( 'wptoolset-field-file',
|
29 |
+
WPTOOLSET_FORMS_RELPATH . '/js/file.js', array('jquery'),
|
30 |
+
WPTOOLSET_FORMS_VERSION, true );
|
31 |
+
|
|
|
|
|
|
|
|
|
|
|
32 |
if ( !wp_script_is( 'wptoolset-field-file', 'enqueued' ) ) {
|
33 |
+
wp_enqueue_script( 'wptoolset-field-file' );
|
34 |
+
add_thickbox();
|
35 |
+
global $post;
|
36 |
+
$for_post = (!empty( $post->ID ) ? 'post_id=' . $post->ID . '&' : '');
|
37 |
+
$js_data = array('title' => esc_js( __( 'Select file', 'wpv-views' ) ), 'for_post' => $for_post, 'adminurl' => admin_url());
|
38 |
+
wp_localize_script( 'wptoolset-field-file', 'wptFileData', $js_data );
|
39 |
+
}
|
40 |
+
}
|
41 |
|
42 |
+
public function enqueueStyles() {
|
43 |
+
|
44 |
}
|
45 |
|
46 |
+
public function metaform() {
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
$value = $this->getValue();
|
48 |
+
$type = $this->getType();
|
49 |
+
$translated_type = '';
|
50 |
$form = array();
|
51 |
$preview = '';
|
52 |
+
|
53 |
// Get attachment by guid
|
54 |
if ( !empty( $value ) ) {
|
55 |
global $wpdb;
|
56 |
+
$attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s", $value ) );
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
|
59 |
// Set preview
|
72 |
}
|
73 |
|
74 |
// Set button
|
75 |
+
switch( $type ) {
|
76 |
+
case 'audio':
|
77 |
+
$translated_type = __( 'audio', 'wpv-views' );
|
78 |
+
break;
|
79 |
+
case 'image':
|
80 |
+
$translated_type = __( 'image', 'wpv-views' );
|
81 |
+
break;
|
82 |
+
case 'video':
|
83 |
+
$translated_type = __( 'video', 'wpv-views' );
|
84 |
+
break;
|
85 |
+
default:
|
86 |
+
$translated_type = __( 'file', 'wpv-views' );
|
87 |
+
break;
|
88 |
+
}
|
89 |
$button = sprintf(
|
90 |
'<a href="#" class="js-wpt-file-upload button button-secondary" data-wpt-type="%s">%s</a>',
|
91 |
$type,
|
97 |
'#type' => 'textfield',
|
98 |
'#name' => $this->getName(),
|
99 |
'#title' => $this->getTitle(),
|
100 |
+
'#description' => $this->getDescription(),
|
101 |
'#value' => $value,
|
102 |
'#suffix' => ' ' . $button,
|
103 |
'#validate' => $this->getValidationData(),
|
104 |
'#repetitive' => $this->isRepetitive(),
|
|
|
105 |
);
|
106 |
|
107 |
$form[] = array(
|
111 |
|
112 |
return $form;
|
113 |
}
|
114 |
+
|
115 |
+
public static function mediaPopup() {
|
116 |
+
WPToolset_Field_File::file_enqueue_scripts();
|
117 |
+
// Add types button
|
118 |
+
add_filter( 'attachment_fields_to_edit',
|
119 |
+
array('WPToolset_Field_File', 'attachmentFieldsToEditFilter'),
|
120 |
+
9999, 2 );
|
121 |
+
// Filter media TABs
|
122 |
+
add_filter( 'media_upload_tabs',
|
123 |
+
array('WPToolset_Field_File', 'mediaUploadTabsFilter') );
|
124 |
+
// Add head data
|
125 |
+
add_filter( 'admin_head',
|
126 |
+
array('WPToolset_Field_File', 'mediaPopupHead') );
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Adds column to media item table.
|
131 |
+
*
|
132 |
+
* @param type $form_fields
|
133 |
+
* @param type $post
|
134 |
+
* @return type
|
135 |
+
*/
|
136 |
+
public static function attachmentFieldsToEditFilter( $form_fields, $post ) {
|
137 |
+
// Reset form
|
138 |
+
$form_fields = array();
|
139 |
+
$type = (strpos( $post->post_mime_type, 'image/' ) !== false) ? 'image' : 'file';
|
140 |
+
$url = wp_get_attachment_url( $post->ID );
|
141 |
+
$form_fields['wpt_fields_file'] = array(
|
142 |
+
'label' => __( 'Toolset' ),
|
143 |
+
'input' => 'html',
|
144 |
+
'html' => '<a href="#" title="' . $url
|
145 |
+
. '" class="js-wpt-file-insert-button'
|
146 |
+
. ' button-primary" onclick="wptFile.mediaInsertTrigger(\''
|
147 |
+
. $url . '\', \'' . $type . '\')">'
|
148 |
+
. __( 'Use as field value', 'wpv-views' ) . '</a><br /><br />',
|
149 |
+
);
|
150 |
+
return $form_fields;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Filters media TABs.
|
155 |
+
*
|
156 |
+
* @param type $tabs
|
157 |
+
* @return type
|
158 |
+
*/
|
159 |
+
public static function mediaUploadTabsFilter( $tabs ) {
|
160 |
+
unset( $tabs['type_url'] );
|
161 |
+
return $tabs;
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Media popup head.
|
166 |
+
*/
|
167 |
+
public static function mediaPopupHead() {
|
168 |
+
?>
|
169 |
+
<script type="text/javascript">
|
170 |
+
<?php
|
171 |
+
if ( isset( $_GET['wpt']['type'] ) && in_array( $_GET['wpt']['type'],
|
172 |
+
array('audio', 'video') ) ):
|
173 |
+
|
174 |
+
?>
|
175 |
+
jQuery(document).ready(function($) {
|
176 |
+
$('#media-upload-header').after('<div class="message updated"><p><?php
|
177 |
+
printf( esc_js( __( 'Please note that not all video and audio formats are supported by the WordPress media player. Before you upload media files, have a look at %ssupported media formats%s.', 'wpv-views' ) ),
|
178 |
+
'<a href="http://wp-types.com/documentation/user-guides/adding-audio-video-and-other-embedded-content-to-your-site/?utm_source=typesplugin&utm_campaign=types&utm_medium=types-field-media-popup&utm_term=supported media formats" target="_blank">',
|
179 |
+
'</a>' );
|
180 |
+
|
181 |
+
?></p></div>');
|
182 |
+
});
|
183 |
+
<?php endif; ?>
|
184 |
+
</script>
|
185 |
+
<style type="text/css">
|
186 |
+
tr.submit, .ml-submit, #save, #media-items .A1B1 p:last-child { display: none; }
|
187 |
+
</style>
|
188 |
+
<?php
|
189 |
+
}
|
190 |
}
|
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.
|
14 |
-
* $LastChangedDate: 2015-
|
15 |
-
* $LastChangedRevision:
|
16 |
* $LastChangedBy: iworks $
|
17 |
*
|
18 |
*
|
@@ -37,12 +37,8 @@ class FormFactory extends FormAbstract
|
|
37 |
|
38 |
wp_register_script( 'wptoolset-forms',
|
39 |
WPTOOLSET_FORMS_RELPATH . '/js/main.js',
|
40 |
-
array('jquery', 'underscore'
|
41 |
wp_enqueue_script( 'wptoolset-forms' );
|
42 |
-
$wptoolset_forms_localization = array(
|
43 |
-
'ajaxurl' => admin_url( 'admin-ajax.php', null )
|
44 |
-
);
|
45 |
-
wp_localize_script( 'wptoolset-forms', 'wptoolset_forms_local', $wptoolset_forms_localization );
|
46 |
|
47 |
if ( is_admin() ) {
|
48 |
wp_register_style( 'wptoolset-forms-admin',
|
@@ -56,22 +52,10 @@ class FormFactory extends FormAbstract
|
|
56 |
$cred_cred_settings = get_option( 'cred_cred_settings' );
|
57 |
/**
|
58 |
* load or not cred.css
|
59 |
-
* and check use bootstrap
|
60 |
*/
|
61 |
$load_cred_css = true;
|
62 |
-
if ( is_array($cred_cred_settings) ) {
|
63 |
-
|
64 |
-
array_key_exists('dont_load_cred_css', $cred_cred_settings )
|
65 |
-
&& $cred_cred_settings['dont_load_cred_css']
|
66 |
-
) {
|
67 |
-
$load_cred_css = false;
|
68 |
-
}
|
69 |
-
if (
|
70 |
-
array_key_exists( 'use_bootstrap', $cred_cred_settings )
|
71 |
-
&& $cred_cred_settings['use_bootstrap']
|
72 |
-
) {
|
73 |
-
$this->_use_bootstrap = true;
|
74 |
-
}
|
75 |
}
|
76 |
/**
|
77 |
* register
|
@@ -85,6 +69,10 @@ class FormFactory extends FormAbstract
|
|
85 |
);
|
86 |
wp_enqueue_style( 'wptoolset-forms-cred' );
|
87 |
}
|
|
|
|
|
|
|
|
|
88 |
}
|
89 |
}
|
90 |
|
@@ -182,28 +170,16 @@ class FormFactory extends FormAbstract
|
|
182 |
*/
|
183 |
$config['use_bootstrap'] = $this->theForm->form_settings['use_bootstrap'];
|
184 |
$config['has_media_button'] = $this->theForm->form_settings['has_media_button'];
|
185 |
-
/**
|
186 |
-
* WMPL configuration
|
187 |
-
*/
|
188 |
-
$config['wpml_action'] = $this->get_wpml_action($config['id']);
|
189 |
-
|
190 |
$htmlArray = array();
|
191 |
$_gnf = $global_name_field;
|
192 |
$_cfg = $config;
|
193 |
if ( empty( $value ) ) $value = array(null);
|
194 |
elseif ( !is_array( $value ) ) $value = array($value);
|
195 |
$count = 0;
|
196 |
-
|
197 |
-
//Fix if i get skype i receive skype i have 2 elements array in $value !!
|
198 |
-
if ($config['type']=='skype') {
|
199 |
-
if (isset($value['style'])) unset($value['style']);
|
200 |
-
if (isset($value['button_style'])) unset($value['button_style']);
|
201 |
-
}
|
202 |
-
|
203 |
-
foreach ( $value as $val ) {
|
204 |
if ( !empty( $config['repetitive'] ) ) {
|
205 |
$_gnf = $_cfg['name'] = "{$global_name_field}[{$count}]";
|
206 |
-
}
|
207 |
//CHECKGEN
|
208 |
if ( isset($_cfg['validation']) &&
|
209 |
is_array($_cfg['validation']) &&
|
@@ -211,7 +187,7 @@ class FormFactory extends FormAbstract
|
|
211 |
!is_admin() && $_SERVER['REQUEST_METHOD'] == 'POST' &&
|
212 |
isset( $_GET['_tt'] ) &&
|
213 |
!isset( $_GET['_success'] ) &&
|
214 |
-
!isset( $_GET['_success_message'] ) )
|
215 |
{
|
216 |
$_cfg['validate'] = 1;
|
217 |
}
|
@@ -235,24 +211,10 @@ class FormFactory extends FormAbstract
|
|
235 |
}
|
236 |
$this->form[$global_name_field] = $form;
|
237 |
$this->field_count++;
|
238 |
-
$htmlArray[] = $this->theForm->renderElements( $form );
|
239 |
if ( empty( $config['repetitive'] ) ) break;
|
240 |
$count++;
|
241 |
-
} else
|
242 |
-
if ( current_user_can('manage_options') ) {
|
243 |
-
$htmlArray[] = sprintf(
|
244 |
-
'<div id="message" class="error"><p>%s</p><p>%s</p></div>',
|
245 |
-
//https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196628627/comments#310360880
|
246 |
-
//changed render to rendering
|
247 |
-
sprintf(
|
248 |
-
__('There is a problem rendering field <strong>%s (%s)</strong>.', 'wpv-views'),
|
249 |
-
$_cfg['title'],
|
250 |
-
$_cfg['type']
|
251 |
-
),
|
252 |
-
$field->get_error_message()
|
253 |
-
);
|
254 |
-
}
|
255 |
-
}
|
256 |
}
|
257 |
if ( !empty( $htmlArray ) && isset($config['repetitive']) && $config['repetitive'] ) {
|
258 |
$_gnf = $_cfg['name'] = "{$global_name_field}[%%{$count}%%]";
|
@@ -262,7 +224,6 @@ class FormFactory extends FormAbstract
|
|
262 |
$this->_repetitive()->add( $config, $tpl );
|
263 |
}
|
264 |
}
|
265 |
-
|
266 |
return !empty( $htmlArray ) ? $this->_tpl( $config, $htmlArray ) : '';
|
267 |
}
|
268 |
|
@@ -391,7 +352,7 @@ class FormFactory extends FormAbstract
|
|
391 |
{
|
392 |
$mess = $field->getTitle().' Field is required';
|
393 |
return new WP_Error( 'wptoolset_forms', $mess,
|
394 |
-
array($field->getTitle().' Field is required') )
|
395 |
}
|
396 |
}
|
397 |
}
|
@@ -419,15 +380,6 @@ class FormFactory extends FormAbstract
|
|
419 |
public function loadFieldClass( $type ) {
|
420 |
$type = strtolower( $type );
|
421 |
$class = $this->getClassFromType( $type );
|
422 |
-
|
423 |
-
/**
|
424 |
-
* try to load custom class
|
425 |
-
*/
|
426 |
-
$loader = $class.'_loader';
|
427 |
-
if ( function_exists($loader) ) {
|
428 |
-
$loader();
|
429 |
-
}
|
430 |
-
|
431 |
if ( !class_exists( $class ) ) {
|
432 |
$file = WPTOOLSET_FORMS_ABSPATH . "/classes/class.{$type}.php";
|
433 |
if ( file_exists( $file ) ) {
|
@@ -446,16 +398,4 @@ class FormFactory extends FormAbstract
|
|
446 |
return class_exists( $class ) ? $class : false;
|
447 |
}
|
448 |
|
449 |
-
private function get_wpml_action($id)
|
450 |
-
{
|
451 |
-
global $iclTranslationManagement;
|
452 |
-
if (
|
453 |
-
is_object($iclTranslationManagement)
|
454 |
-
&& 'TranslationManagement' == get_class($iclTranslationManagement)
|
455 |
-
&& isset($iclTranslationManagement->settings['custom_fields_translation'][$id])
|
456 |
-
) {
|
457 |
-
return $iclTranslationManagement->settings['custom_fields_translation'][$id];
|
458 |
-
}
|
459 |
-
return 0;
|
460 |
-
}
|
461 |
}
|
10 |
* Creation Form Class
|
11 |
* @author onTheGo System
|
12 |
*
|
13 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.form_factory.php $
|
14 |
+
* $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
|
15 |
+
* $LastChangedRevision: 1180956 $
|
16 |
* $LastChangedBy: iworks $
|
17 |
*
|
18 |
*
|
37 |
|
38 |
wp_register_script( 'wptoolset-forms',
|
39 |
WPTOOLSET_FORMS_RELPATH . '/js/main.js',
|
40 |
+
array('jquery', 'underscore'), WPTOOLSET_FORMS_VERSION, false );
|
41 |
wp_enqueue_script( 'wptoolset-forms' );
|
|
|
|
|
|
|
|
|
42 |
|
43 |
if ( is_admin() ) {
|
44 |
wp_register_style( 'wptoolset-forms-admin',
|
52 |
$cred_cred_settings = get_option( 'cred_cred_settings' );
|
53 |
/**
|
54 |
* load or not cred.css
|
|
|
55 |
*/
|
56 |
$load_cred_css = true;
|
57 |
+
if ( is_array($cred_cred_settings) && array_key_exists('dont_load_cred_css', $cred_cred_settings ) && $cred_cred_settings['dont_load_cred_css'] ) {
|
58 |
+
$load_cred_css = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
/**
|
61 |
* register
|
69 |
);
|
70 |
wp_enqueue_style( 'wptoolset-forms-cred' );
|
71 |
}
|
72 |
+
|
73 |
+
if ( array_key_exists( 'use_bootstrap', $cred_cred_settings ) && $cred_cred_settings['use_bootstrap'] ) {
|
74 |
+
$this->_use_bootstrap = true;
|
75 |
+
}
|
76 |
}
|
77 |
}
|
78 |
|
170 |
*/
|
171 |
$config['use_bootstrap'] = $this->theForm->form_settings['use_bootstrap'];
|
172 |
$config['has_media_button'] = $this->theForm->form_settings['has_media_button'];
|
|
|
|
|
|
|
|
|
|
|
173 |
$htmlArray = array();
|
174 |
$_gnf = $global_name_field;
|
175 |
$_cfg = $config;
|
176 |
if ( empty( $value ) ) $value = array(null);
|
177 |
elseif ( !is_array( $value ) ) $value = array($value);
|
178 |
$count = 0;
|
179 |
+
foreach ( $value as $val ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
if ( !empty( $config['repetitive'] ) ) {
|
181 |
$_gnf = $_cfg['name'] = "{$global_name_field}[{$count}]";
|
182 |
+
}
|
183 |
//CHECKGEN
|
184 |
if ( isset($_cfg['validation']) &&
|
185 |
is_array($_cfg['validation']) &&
|
187 |
!is_admin() && $_SERVER['REQUEST_METHOD'] == 'POST' &&
|
188 |
isset( $_GET['_tt'] ) &&
|
189 |
!isset( $_GET['_success'] ) &&
|
190 |
+
!isset( $_GET['_success_message'] ) )
|
191 |
{
|
192 |
$_cfg['validate'] = 1;
|
193 |
}
|
211 |
}
|
212 |
$this->form[$global_name_field] = $form;
|
213 |
$this->field_count++;
|
214 |
+
$htmlArray[] = $this->theForm->renderElements( $form );
|
215 |
if ( empty( $config['repetitive'] ) ) break;
|
216 |
$count++;
|
217 |
+
} else echo "error";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
}
|
219 |
if ( !empty( $htmlArray ) && isset($config['repetitive']) && $config['repetitive'] ) {
|
220 |
$_gnf = $_cfg['name'] = "{$global_name_field}[%%{$count}%%]";
|
224 |
$this->_repetitive()->add( $config, $tpl );
|
225 |
}
|
226 |
}
|
|
|
227 |
return !empty( $htmlArray ) ? $this->_tpl( $config, $htmlArray ) : '';
|
228 |
}
|
229 |
|
352 |
{
|
353 |
$mess = $field->getTitle().' Field is required';
|
354 |
return new WP_Error( 'wptoolset_forms', $mess,
|
355 |
+
array($field->getTitle().' Field is required') );;
|
356 |
}
|
357 |
}
|
358 |
}
|
380 |
public function loadFieldClass( $type ) {
|
381 |
$type = strtolower( $type );
|
382 |
$class = $this->getClassFromType( $type );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
if ( !class_exists( $class ) ) {
|
384 |
$file = WPTOOLSET_FORMS_ABSPATH . "/classes/class.{$type}.php";
|
385 |
if ( file_exists( $file ) ) {
|
398 |
return class_exists( $class ) ? $class : false;
|
399 |
}
|
400 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
}
|
embedded/common/toolset-forms/classes/class.image.php
CHANGED
@@ -6,10 +6,10 @@ require_once 'class.file.php';
|
|
6 |
*
|
7 |
* @author Srdjan
|
8 |
*
|
9 |
-
* $HeadURL:
|
10 |
-
* $LastChangedDate: 2014-
|
11 |
-
* $LastChangedRevision:
|
12 |
-
* $LastChangedBy:
|
13 |
*
|
14 |
*/
|
15 |
class WPToolset_Field_Image extends WPToolset_Field_File
|
@@ -19,28 +19,17 @@ class WPToolset_Field_Image extends WPToolset_Field_File
|
|
19 |
$validation = $this->getValidationData();
|
20 |
$validation = self::addTypeValidation($validation);
|
21 |
$this->setValidationData($validation);
|
22 |
-
return parent::metaform();
|
23 |
}
|
24 |
|
25 |
-
public static function addTypeValidation($validation)
|
26 |
-
{
|
27 |
-
$valid_extensions = array(
|
28 |
-
'bmp',
|
29 |
-
'gif',
|
30 |
-
'jpeg',
|
31 |
-
'jpg',
|
32 |
-
'png',
|
33 |
-
'svg',
|
34 |
-
'webp',
|
35 |
-
);
|
36 |
-
$valid_extensions = apply_filters( 'toolset_valid_image_extentions', $valid_extensions);
|
37 |
$validation['extension'] = array(
|
38 |
'args' => array(
|
39 |
'extension',
|
40 |
-
|
41 |
),
|
42 |
'message' => __( 'You can add only images.', 'wpv-views' ),
|
43 |
);
|
44 |
return $validation;
|
45 |
-
}
|
46 |
}
|
6 |
*
|
7 |
* @author Srdjan
|
8 |
*
|
9 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.image.php $
|
10 |
+
* $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
|
11 |
+
* $LastChangedRevision: 26350 $
|
12 |
+
* $LastChangedBy: francesco $
|
13 |
*
|
14 |
*/
|
15 |
class WPToolset_Field_Image extends WPToolset_Field_File
|
19 |
$validation = $this->getValidationData();
|
20 |
$validation = self::addTypeValidation($validation);
|
21 |
$this->setValidationData($validation);
|
22 |
+
return parent::metaform();
|
23 |
}
|
24 |
|
25 |
+
public static function addTypeValidation($validation) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
$validation['extension'] = array(
|
27 |
'args' => array(
|
28 |
'extension',
|
29 |
+
'jpg|jpeg|gif|png|bmp|webp',
|
30 |
),
|
31 |
'message' => __( 'You can add only images.', 'wpv-views' ),
|
32 |
);
|
33 |
return $validation;
|
34 |
+
}
|
35 |
}
|
embedded/common/toolset-forms/classes/class.integer.php
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once 'class.textfield.php';
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Description of class
|
6 |
-
*
|
7 |
-
* @author Srdjan
|
8 |
-
*/
|
9 |
-
class WPToolset_Field_Integer extends WPToolset_Field_Textfield
|
10 |
-
{
|
11 |
-
|
12 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/toolset-forms/classes/class.radios.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
-
* $HeadURL:
|
5 |
-
* $LastChangedDate:
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.field_factory.php';
|
@@ -30,28 +30,11 @@ class WPToolset_Field_Radios extends FieldFactory
|
|
30 |
'#title' => $option['title'],
|
31 |
'#validate' => $this->getValidationData()
|
32 |
);
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
);
|
39 |
-
/**
|
40 |
-
* filter: cred_checkboxes_class
|
41 |
-
* @param array $clases current array of classes
|
42 |
-
* @parem array $option current option
|
43 |
-
* @param string field type
|
44 |
-
*
|
45 |
-
* @return array
|
46 |
-
*/
|
47 |
-
$clases = apply_filters( 'cred_item_li_class', $clases, $option, 'radio' );
|
48 |
-
$one_option_data['#before'] = sprintf(
|
49 |
-
'<li class="%s">',
|
50 |
-
implode(' ', $clases)
|
51 |
-
);
|
52 |
-
$one_option_data['#after'] = '</li>';
|
53 |
-
$one_option_data['#pattern'] = '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
|
54 |
-
}
|
55 |
/**
|
56 |
* add default value if needed
|
57 |
* issue: frontend, multiforms CRED
|
@@ -64,15 +47,7 @@ class WPToolset_Field_Radios extends FieldFactory
|
|
64 |
*/
|
65 |
$options[] = $one_option_data;
|
66 |
}
|
67 |
-
|
68 |
-
* for user fields we reset title and description to avoid double
|
69 |
-
* display
|
70 |
-
*/
|
71 |
-
$title = $this->getTitle();
|
72 |
-
if ( empty($title) ) {
|
73 |
-
$title = $this->getTitle(true);
|
74 |
-
}
|
75 |
-
$options = apply_filters( 'wpt_field_options', $options, $title, 'select' );
|
76 |
/**
|
77 |
* default_value
|
78 |
*/
|
@@ -92,12 +67,12 @@ class WPToolset_Field_Radios extends FieldFactory
|
|
92 |
'#repetitive' => $this->isRepetitive(),
|
93 |
'#validate' => $this->getValidationData(),
|
94 |
);
|
95 |
-
|
96 |
if ( !is_admin() ) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
|
97 |
$form_attr['#before'] = '<ul class="wpt-form-set wpt-form-set-radios wpt-form-set-radios-' . $name . '">';
|
98 |
$form_attr['#after'] = '</ul>';
|
99 |
}
|
100 |
-
|
101 |
$form[] = $form_attr;
|
102 |
|
103 |
return $form;
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.radios.php $
|
5 |
+
* $LastChangedDate: 2014-08-14 09:35:38 +0200 (Thu, 14 Aug 2014) $
|
6 |
+
* $LastChangedRevision: 25961 $
|
7 |
+
* $LastChangedBy: francesco $
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.field_factory.php';
|
30 |
'#title' => $option['title'],
|
31 |
'#validate' => $this->getValidationData()
|
32 |
);
|
33 |
+
if ( !is_admin() ) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
|
34 |
+
$one_option_data['#before'] = '<li class="wpt-form-item wpt-form-item-radio">';
|
35 |
+
$one_option_data['#after'] = '</li>';
|
36 |
+
$one_option_data['#pattern'] = '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
|
37 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
/**
|
39 |
* add default value if needed
|
40 |
* issue: frontend, multiforms CRED
|
47 |
*/
|
48 |
$options[] = $one_option_data;
|
49 |
}
|
50 |
+
$options = apply_filters( 'wpt_field_options', $options, $this->getTitle(), 'select' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
/**
|
52 |
* default_value
|
53 |
*/
|
67 |
'#repetitive' => $this->isRepetitive(),
|
68 |
'#validate' => $this->getValidationData(),
|
69 |
);
|
70 |
+
|
71 |
if ( !is_admin() ) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
|
72 |
$form_attr['#before'] = '<ul class="wpt-form-set wpt-form-set-radios wpt-form-set-radios-' . $name . '">';
|
73 |
$form_attr['#after'] = '</ul>';
|
74 |
}
|
75 |
+
|
76 |
$form[] = $form_attr;
|
77 |
|
78 |
return $form;
|
embedded/common/toolset-forms/classes/class.recaptcha.php
CHANGED
@@ -40,21 +40,20 @@ class WPToolset_Field_Recaptcha extends WPToolset_Field_Textfield
|
|
40 |
public function metaform() {
|
41 |
$form = array();
|
42 |
|
43 |
-
|
44 |
if ($this->pubkey || !is_admin()) {
|
45 |
try {
|
46 |
-
$capture = recaptcha_get_html($this->pubkey
|
47 |
} catch(Exception $e ) {
|
48 |
-
//https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188424989/comments
|
49 |
if ( current_user_can( 'manage_options' ) ) {
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
}
|
54 |
-
//###########################################################################################
|
55 |
}
|
56 |
}
|
57 |
|
|
|
58 |
$form[] = array(
|
59 |
'#type' => 'textfield',
|
60 |
'#title' => '',
|
40 |
public function metaform() {
|
41 |
$form = array();
|
42 |
|
43 |
+
$capture = '';
|
44 |
if ($this->pubkey || !is_admin()) {
|
45 |
try {
|
46 |
+
$capture = recaptcha_get_html($this->pubkey);
|
47 |
} catch(Exception $e ) {
|
|
|
48 |
if ( current_user_can( 'manage_options' ) ) {
|
49 |
+
echo '<div class="message error">';
|
50 |
+
echo 'Caught exception: ', $e->getMessage(), "\n";
|
51 |
+
echo '</div>';
|
52 |
}
|
|
|
53 |
}
|
54 |
}
|
55 |
|
56 |
+
|
57 |
$form[] = array(
|
58 |
'#type' => 'textfield',
|
59 |
'#title' => '',
|
embedded/common/toolset-forms/classes/class.repetitive.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
/*
|
3 |
* Repetitive controller
|
4 |
*
|
5 |
-
* $HeadURL:
|
6 |
-
* $LastChangedDate: 2014-
|
7 |
-
* $LastChangedRevision:
|
8 |
-
* $LastChangedBy:
|
9 |
*
|
10 |
* If field is repetitive
|
11 |
* - queues repetitive CSS and JS
|
2 |
/*
|
3 |
* Repetitive controller
|
4 |
*
|
5 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.repetitive.php $
|
6 |
+
* $LastChangedDate: 2014-07-03 09:27:50 +0200 (Thu, 03 Jul 2014) $
|
7 |
+
* $LastChangedRevision: 24580 $
|
8 |
+
* $LastChangedBy: juan $
|
9 |
*
|
10 |
* If field is repetitive
|
11 |
* - queues repetitive CSS and JS
|
embedded/common/toolset-forms/classes/class.select.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
-
* $HeadURL:
|
5 |
-
* $LastChangedDate:
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.field_factory.php';
|
@@ -28,7 +28,7 @@ class WPToolset_Field_Select extends FieldFactory
|
|
28 |
foreach ( $data['options'] as $option ) {
|
29 |
$one_option_data = array(
|
30 |
'#value' => $option['value'],
|
31 |
-
'#title' =>
|
32 |
);
|
33 |
/**
|
34 |
* add default value if needed
|
@@ -43,32 +43,13 @@ class WPToolset_Field_Select extends FieldFactory
|
|
43 |
$options[] = $one_option_data;
|
44 |
}
|
45 |
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* for user fields we reset title and description to avoid double
|
49 |
-
* display
|
50 |
-
*/
|
51 |
-
$title = $this->getTitle();
|
52 |
-
if ( empty($title) ) {
|
53 |
-
$title = $this->getTitle(true);
|
54 |
-
}
|
55 |
-
$options = apply_filters( 'wpt_field_options', $options, $title, 'select' );
|
56 |
/**
|
57 |
* default_value
|
58 |
*/
|
59 |
if ( !empty( $value ) || $value == '0' ) {
|
60 |
$data['default_value'] = $value;
|
61 |
}
|
62 |
-
|
63 |
-
$is_multiselect = array_key_exists('multiple', $attributes) && 'multiple' == $attributes['multiple'];
|
64 |
-
$default_value = isset( $data['default_value'] ) ? $data['default_value'] : null;
|
65 |
-
//Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/189219391/comments
|
66 |
-
if ($is_multiselect) {
|
67 |
-
$default_value = new RecursiveIteratorIterator(new RecursiveArrayIterator($default_value));
|
68 |
-
$default_value = iterator_to_array($default_value,false);
|
69 |
-
}
|
70 |
-
//##############################################################################################
|
71 |
-
|
72 |
/**
|
73 |
* metaform
|
74 |
*/
|
@@ -78,8 +59,8 @@ class WPToolset_Field_Select extends FieldFactory
|
|
78 |
'#description' => $this->getDescription(),
|
79 |
'#name' => $this->getName(),
|
80 |
'#options' => $options,
|
81 |
-
'#default_value' => $default_value,
|
82 |
-
'#multiple' => $
|
83 |
'#validate' => $this->getValidationData(),
|
84 |
'#class' => 'form-inline',
|
85 |
'#repetitive' => $this->isRepetitive(),
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.select.php $
|
5 |
+
* $LastChangedDate: 2014-07-29 16:50:22 +0200 (Tue, 29 Jul 2014) $
|
6 |
+
* $LastChangedRevision: 25428 $
|
7 |
+
* $LastChangedBy: marcin $
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.field_factory.php';
|
28 |
foreach ( $data['options'] as $option ) {
|
29 |
$one_option_data = array(
|
30 |
'#value' => $option['value'],
|
31 |
+
'#title' => $option['title'],
|
32 |
);
|
33 |
/**
|
34 |
* add default value if needed
|
43 |
$options[] = $one_option_data;
|
44 |
}
|
45 |
}
|
46 |
+
$options = apply_filters( 'wpt_field_options', $options, $this->getTitle(), 'select' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
/**
|
48 |
* default_value
|
49 |
*/
|
50 |
if ( !empty( $value ) || $value == '0' ) {
|
51 |
$data['default_value'] = $value;
|
52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
/**
|
54 |
* metaform
|
55 |
*/
|
59 |
'#description' => $this->getDescription(),
|
60 |
'#name' => $this->getName(),
|
61 |
'#options' => $options,
|
62 |
+
'#default_value' => isset( $data['default_value'] ) ? $data['default_value'] : null,
|
63 |
+
'#multiple' => array_key_exists('multiple', $attributes) && 'multiple' == $attributes['multiple'],
|
64 |
'#validate' => $this->getValidationData(),
|
65 |
'#class' => 'form-inline',
|
66 |
'#repetitive' => $this->isRepetitive(),
|
embedded/common/toolset-forms/classes/class.skype.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
-
* $HeadURL:
|
5 |
-
* $LastChangedDate:
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.textfield.php';
|
@@ -14,38 +14,29 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
|
|
14 |
|
15 |
protected $_defaults = array('skypename' => '', 'button_style' => 'btn2');
|
16 |
|
17 |
-
public function init()
|
18 |
-
|
19 |
-
|
20 |
add_action( 'wp_footer', array($this, 'editButtonTemplate') );
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
array('jquery'),
|
26 |
-
WPTOOLSET_FORMS_VERSION,
|
27 |
-
true
|
28 |
-
);
|
29 |
wp_enqueue_script( 'wptoolset-field-skype' );
|
30 |
add_thickbox();
|
31 |
$translation = array('title' => esc_js( __( 'Edit Skype button', 'wpv-views' ) ) );
|
32 |
-
wp_localize_script( 'wptoolset-field-skype', 'wptSkypeData',
|
33 |
-
|
|
|
34 |
}
|
35 |
|
36 |
public function enqueueStyles() {
|
37 |
-
|
38 |
}
|
39 |
|
40 |
public function metaform() {
|
41 |
$value = wp_parse_args( $this->getValue(), $this->_defaults );
|
42 |
-
$
|
43 |
-
if ( isset($attributes['class'] ) ) {
|
44 |
-
$attributes['class'] .= ' ';
|
45 |
-
} else {
|
46 |
-
$attributes['class'] = '';
|
47 |
-
}
|
48 |
-
$attributes['class'] = 'js-wpt-skypename js-wpt-cond-trigger';// What is this js-wpt-cond-trigger classname for?
|
49 |
$form = array();
|
50 |
$form[] = array(
|
51 |
'#type' => 'textfield',
|
@@ -55,7 +46,7 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
|
|
55 |
'#attributes' => array(),
|
56 |
'#value' => $value['skypename'],
|
57 |
'#validate' => $this->getValidationData(),
|
58 |
-
'#attributes' => $
|
59 |
'#repetitive' => $this->isRepetitive(),
|
60 |
);
|
61 |
$form['style'] = array(
|
@@ -72,7 +63,7 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
|
|
72 |
$button_element = array(
|
73 |
'#name' => '',
|
74 |
'#type' => 'button',
|
75 |
-
'#value' => esc_attr( __( 'Edit', 'wpv-views' ) )
|
76 |
'#attributes' => array('class' => 'js-wpt-skype-edit-button button button-small button-secondary'),
|
77 |
);
|
78 |
/*
|
@@ -111,7 +102,7 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
|
|
111 |
}
|
112 |
|
113 |
public function editform( $config = null ) {
|
114 |
-
|
115 |
}
|
116 |
|
117 |
public function mediaEditor(){
|
@@ -120,11 +111,11 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
|
|
120 |
|
121 |
/**
|
122 |
* Returns HTML formatted skype button.
|
123 |
-
*
|
124 |
* @param type $skypename
|
125 |
* @param type $template
|
126 |
* @param type $class
|
127 |
-
* @return type
|
128 |
*/
|
129 |
function getButton( $skypename, $template = '', $class = false ) {
|
130 |
|
@@ -188,10 +179,10 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
|
|
188 |
|
189 |
/**
|
190 |
* Returns HTML formatted skype button image.
|
191 |
-
*
|
192 |
* @param type $skypename
|
193 |
* @param type $template
|
194 |
-
* @return type
|
195 |
*/
|
196 |
public function getButtonImage( $skypename = '', $template = '', $class = '' ) {
|
197 |
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.skype.php $
|
5 |
+
* $LastChangedDate: 2014-08-05 18:18:16 +0200 (Tue, 05 Aug 2014) $
|
6 |
+
* $LastChangedRevision: 25657 $
|
7 |
+
* $LastChangedBy: juan $
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.textfield.php';
|
14 |
|
15 |
protected $_defaults = array('skypename' => '', 'button_style' => 'btn2');
|
16 |
|
17 |
+
public function init(){
|
18 |
+
|
19 |
+
add_action( 'admin_footer', array($this, 'editButtonTemplate') );
|
20 |
add_action( 'wp_footer', array($this, 'editButtonTemplate') );
|
21 |
+
|
22 |
+
wp_register_script( 'wptoolset-field-skype',
|
23 |
+
WPTOOLSET_FORMS_RELPATH . '/js/skype.js', array('jquery'),
|
24 |
+
WPTOOLSET_FORMS_VERSION, true );
|
|
|
|
|
|
|
|
|
25 |
wp_enqueue_script( 'wptoolset-field-skype' );
|
26 |
add_thickbox();
|
27 |
$translation = array('title' => esc_js( __( 'Edit Skype button', 'wpv-views' ) ) );
|
28 |
+
wp_localize_script( 'wptoolset-field-skype', 'wptSkypeData',
|
29 |
+
$translation );
|
30 |
+
|
31 |
}
|
32 |
|
33 |
public function enqueueStyles() {
|
34 |
+
|
35 |
}
|
36 |
|
37 |
public function metaform() {
|
38 |
$value = wp_parse_args( $this->getValue(), $this->_defaults );
|
39 |
+
$def_class='js-wpt-skypename js-wpt-cond-trigger';// What is this js-wpt-cond-trigger classname for?
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
$form = array();
|
41 |
$form[] = array(
|
42 |
'#type' => 'textfield',
|
46 |
'#attributes' => array(),
|
47 |
'#value' => $value['skypename'],
|
48 |
'#validate' => $this->getValidationData(),
|
49 |
+
'#attributes' => array('class' => $def_class), // Mark to be checked as conditional
|
50 |
'#repetitive' => $this->isRepetitive(),
|
51 |
);
|
52 |
$form['style'] = array(
|
63 |
$button_element = array(
|
64 |
'#name' => '',
|
65 |
'#type' => 'button',
|
66 |
+
'#value' => esc_attr( __( 'Edit Skype button', 'wpv-views' ) ),
|
67 |
'#attributes' => array('class' => 'js-wpt-skype-edit-button button button-small button-secondary'),
|
68 |
);
|
69 |
/*
|
102 |
}
|
103 |
|
104 |
public function editform( $config = null ) {
|
105 |
+
|
106 |
}
|
107 |
|
108 |
public function mediaEditor(){
|
111 |
|
112 |
/**
|
113 |
* Returns HTML formatted skype button.
|
114 |
+
*
|
115 |
* @param type $skypename
|
116 |
* @param type $template
|
117 |
* @param type $class
|
118 |
+
* @return type
|
119 |
*/
|
120 |
function getButton( $skypename, $template = '', $class = false ) {
|
121 |
|
179 |
|
180 |
/**
|
181 |
* Returns HTML formatted skype button image.
|
182 |
+
*
|
183 |
* @param type $skypename
|
184 |
* @param type $template
|
185 |
+
* @return type
|
186 |
*/
|
187 |
public function getButtonImage( $skypename = '', $template = '', $class = '' ) {
|
188 |
|
embedded/common/toolset-forms/classes/class.submit.php
CHANGED
@@ -1,41 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
'#
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
);
|
31 |
-
if (array_key_exists( 'class', $attributes )) {
|
32 |
-
$metaform[0]['#attributes']['class'] = $attributes['class'];
|
33 |
-
}
|
34 |
-
if ( array_key_exists( 'use_bootstrap', $this->_data ) && $this->_data['use_bootstrap'] ) {
|
35 |
-
$metaform[0]['#attributes']['class'] .= ' btn btn-primary';
|
36 |
-
}
|
37 |
-
$this->set_metaform($metaform);
|
38 |
-
return $metaform;
|
39 |
-
}
|
40 |
-
|
41 |
-
}
|
1 |
+
<?php
|
2 |
+
require_once 'class.textfield.php';
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Description of class
|
6 |
+
*
|
7 |
+
* @author Franko
|
8 |
+
*/
|
9 |
+
class WPToolset_Field_Submit extends WPToolset_Field_Textfield
|
10 |
+
{
|
11 |
+
|
12 |
+
public function metaform() {
|
13 |
+
$metaform = array();
|
14 |
+
$metaform[] = array(
|
15 |
+
'#type' => 'submit',
|
16 |
+
'#title' => $this->getTitle(),
|
17 |
+
'#description' => $this->getDescription(),
|
18 |
+
'#name' => $this->getName(),
|
19 |
+
'#value' => $this->getValue(),
|
20 |
+
'#validate' => $this->getValidationData()
|
21 |
+
);
|
22 |
+
if ( array_key_exists( 'use_bootstrap', $this->_data ) && $this->_data['use_bootstrap'] ) {
|
23 |
+
$metaform[0]['#attributes']['class'] = 'btn btn-primary';
|
24 |
+
}
|
25 |
+
$this->set_metaform($metaform);
|
26 |
+
return $metaform;
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/toolset-forms/classes/class.taxonomy.php
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
|
3 |
/**
|
4 |
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
6 |
-
* $LastChangedDate: 2015-
|
7 |
-
* $LastChangedRevision:
|
8 |
* $LastChangedBy: iworks $
|
9 |
*
|
10 |
*/
|
@@ -26,15 +26,40 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield
|
|
26 |
$this->objValues[$term->slug] = $term;
|
27 |
$i++;
|
28 |
}
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
add_action( 'wp_footer', array($this, 'javascript_autocompleter') );
|
31 |
}
|
32 |
|
33 |
public function javascript_autocompleter() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
echo '<script type="text/javascript">
|
35 |
jQuery(document).ready(function() {
|
36 |
initTaxonomies("'. $this->values .'", "'.$this->getName().'", "'.WPTOOLSET_FORMS_RELPATH.'", "'.$this->_nameField.'");
|
37 |
});
|
|
|
|
|
38 |
</script>';
|
39 |
}
|
40 |
|
@@ -79,7 +104,7 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield
|
|
79 |
'#title' => '',
|
80 |
'#description' => '',
|
81 |
'#name' => "new_tax_button_".$taxonomy,
|
82 |
-
'#value' =>
|
83 |
'#attributes' => array(
|
84 |
'class' => $use_bootstrap ? 'btn btn-default wpt-taxonomy-add-new js-wpt-taxonomy-add-new' : 'wpt-taxonomy-add-new js-wpt-taxonomy-add-new',
|
85 |
'data-taxonomy' => $taxonomy,
|
@@ -107,12 +132,12 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield
|
|
107 |
'#title' => '',
|
108 |
'#description' => '',
|
109 |
'#name' => "sh_".$taxonomy,
|
110 |
-
'#value' =>
|
111 |
'#attributes' => array(
|
112 |
'class' => $use_bootstrap ? 'btn btn-default popular wpt-taxonomy-popular-show-hide js-wpt-taxonomy-popular-show-hide' : 'popular wpt-taxonomy-popular-show-hide js-wpt-taxonomy-popular-show-hide',
|
113 |
'data-taxonomy' => $this->getName(),
|
114 |
-
'data-show-popular-text' =>
|
115 |
-
'data-hide-popular-text' =>
|
116 |
'data-after-selector' => 'js-show-popular-after',
|
117 |
'style' => $show ? '' : 'display:none;'
|
118 |
),
|
@@ -197,18 +222,15 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield
|
|
197 |
);
|
198 |
}
|
199 |
|
|
|
200 |
foreach($terms as $term) {
|
201 |
-
$style = '';
|
202 |
if ( $add_sizes ) {
|
203 |
-
$font_size = ( ( $term->count - $min ) * 10 ) / ( $max - $min ) +
|
204 |
-
$style = sprintf( ' style="font-size
|
205 |
}
|
206 |
-
$
|
207 |
-
$clases[] = 'tax-'.$term->slug;
|
208 |
-
$clases[] = 'taxonomy-'.$this->getName().'-'.$term->term_id;
|
209 |
$content .= sprintf(
|
210 |
-
'<a href="#" class="
|
211 |
-
implode(' ', $clases ),
|
212 |
$term->slug,
|
213 |
$term->name,
|
214 |
$this->getName(),
|
2 |
|
3 |
/**
|
4 |
*
|
5 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.taxonomy.php $
|
6 |
+
* $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
|
7 |
+
* $LastChangedRevision: 1180956 $
|
8 |
* $LastChangedBy: iworks $
|
9 |
*
|
10 |
*/
|
26 |
$this->objValues[$term->slug] = $term;
|
27 |
$i++;
|
28 |
}
|
29 |
+
|
30 |
+
wp_register_script( 'wptoolset-jquery-autocompleter',
|
31 |
+
WPTOOLSET_FORMS_RELPATH . '/js/jquery.autocomplete.js',
|
32 |
+
array('jquery'), WPTOOLSET_FORMS_VERSION, true );
|
33 |
+
|
34 |
+
wp_register_style('wptoolset-autocompleter', WPTOOLSET_FORMS_RELPATH.'/css/autocompleter.css');
|
35 |
+
wp_enqueue_script('wptoolset-jquery-autocompleter');
|
36 |
add_action( 'wp_footer', array($this, 'javascript_autocompleter') );
|
37 |
}
|
38 |
|
39 |
public function javascript_autocompleter() {
|
40 |
+
$autosubmit = 'function onSelectItem(row)
|
41 |
+
{
|
42 |
+
jQuery("input#'.$this->getName().'").focus();
|
43 |
+
}';
|
44 |
+
$extra = '
|
45 |
+
function formatItem(row) {
|
46 |
+
return row[0];
|
47 |
+
}
|
48 |
+
function formatItem2(row) {
|
49 |
+
if(row.length == 3){
|
50 |
+
var attr = "attr=\"" + row[2] + "\"";
|
51 |
+
} else {
|
52 |
+
attr = "";
|
53 |
+
}
|
54 |
+
return "<span "+attr+">" + row[1] + " matches</span>" + row[0];
|
55 |
+
}';
|
56 |
+
$results = 1;
|
57 |
echo '<script type="text/javascript">
|
58 |
jQuery(document).ready(function() {
|
59 |
initTaxonomies("'. $this->values .'", "'.$this->getName().'", "'.WPTOOLSET_FORMS_RELPATH.'", "'.$this->_nameField.'");
|
60 |
});
|
61 |
+
'.$autosubmit.'
|
62 |
+
'.$extra.'
|
63 |
</script>';
|
64 |
}
|
65 |
|
104 |
'#title' => '',
|
105 |
'#description' => '',
|
106 |
'#name' => "new_tax_button_".$taxonomy,
|
107 |
+
'#value' => esc_attr( $attributes['add_text'] ),
|
108 |
'#attributes' => array(
|
109 |
'class' => $use_bootstrap ? 'btn btn-default wpt-taxonomy-add-new js-wpt-taxonomy-add-new' : 'wpt-taxonomy-add-new js-wpt-taxonomy-add-new',
|
110 |
'data-taxonomy' => $taxonomy,
|
132 |
'#title' => '',
|
133 |
'#description' => '',
|
134 |
'#name' => "sh_".$taxonomy,
|
135 |
+
'#value' => esc_attr( $attributes['show_popular_text'] ),
|
136 |
'#attributes' => array(
|
137 |
'class' => $use_bootstrap ? 'btn btn-default popular wpt-taxonomy-popular-show-hide js-wpt-taxonomy-popular-show-hide' : 'popular wpt-taxonomy-popular-show-hide js-wpt-taxonomy-popular-show-hide',
|
138 |
'data-taxonomy' => $this->getName(),
|
139 |
+
'data-show-popular-text' => esc_attr( $attributes['show_popular_text'] ),
|
140 |
+
'data-hide-popular-text' => esc_attr( $attributes['hide_popular_text'] ),
|
141 |
'data-after-selector' => 'js-show-popular-after',
|
142 |
'style' => $show ? '' : 'display:none;'
|
143 |
),
|
222 |
);
|
223 |
}
|
224 |
|
225 |
+
$style = '';
|
226 |
foreach($terms as $term) {
|
|
|
227 |
if ( $add_sizes ) {
|
228 |
+
$font_size = ( ( $term->count - $min ) * 10 ) / ( $max - $min ) + 5;
|
229 |
+
$style = sprintf( ' style="font-size:1.%dem;"', $font_size );
|
230 |
}
|
231 |
+
_pre($term);
|
|
|
|
|
232 |
$content .= sprintf(
|
233 |
+
'<a href="#" class="wpt-taxonomy-popular-add js-wpt-taxonomy-popular-add" data-slug="%s" data-name="%s" data-taxonomy="%s"%s>%s</a> ',
|
|
|
234 |
$term->slug,
|
235 |
$term->name,
|
236 |
$this->getName(),
|
embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php
CHANGED
@@ -1,24 +1,25 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
6 |
-
* $LastChangedDate: 2015-
|
7 |
-
* $LastChangedRevision:
|
8 |
* $LastChangedBy: iworks $
|
9 |
*
|
10 |
*/
|
11 |
-
include_once 'class.textfield.php';
|
12 |
|
13 |
-
class
|
14 |
|
|
|
|
|
15 |
protected $child;
|
16 |
protected $names;
|
17 |
protected $values = array();
|
18 |
protected $valuesId = array();
|
19 |
protected $objValues;
|
20 |
|
21 |
-
public function init()
|
|
|
22 |
global $post;
|
23 |
|
24 |
$this->objValues = array();
|
@@ -30,43 +31,44 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
|
|
30 |
$this->objValues[$term->slug] = $term;
|
31 |
}
|
32 |
}
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
$childs = array();
|
39 |
-
$names = array();
|
40 |
foreach ($all as $term) {
|
41 |
-
$names[$term['term_id']]
|
42 |
if (!isset($childs[$term['parent']]) || !is_array($childs[$term['parent']]))
|
43 |
-
$childs[$term['parent']]
|
44 |
-
$childs[$term['parent']][]
|
45 |
}
|
46 |
|
47 |
// ksort($childs);
|
48 |
-
|
49 |
$this->childs = $childs;
|
50 |
$this->names = $names;
|
51 |
}
|
52 |
|
53 |
-
public function enqueueScripts()
|
54 |
-
|
55 |
}
|
56 |
|
57 |
-
public function enqueueStyles()
|
58 |
-
|
59 |
}
|
60 |
|
61 |
-
public function metaform()
|
62 |
-
|
|
|
63 |
$attributes = $this->getAttr();
|
64 |
-
|
65 |
$res = '';
|
66 |
$metaform = array();
|
67 |
$build_what = '';
|
68 |
-
|
69 |
-
if (array_key_exists('display', $this->_data) && 'select' == $this->_data['display']) {
|
70 |
$metaform = $this->buildSelect();
|
71 |
$build_what = 'select';
|
72 |
} else {
|
@@ -74,14 +76,15 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
|
|
74 |
$this->set_metaform($res);
|
75 |
$build_what = 'checkboxes';
|
76 |
}
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
85 |
/**
|
86 |
* "Add new" button
|
87 |
*/
|
@@ -89,47 +92,48 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
|
|
89 |
'#type' => 'button',
|
90 |
'#title' => '',
|
91 |
'#description' => '',
|
92 |
-
'#name' => "btn_"
|
93 |
-
'#value' =>
|
94 |
'#attributes' => array(
|
95 |
'style' => 'display:none;',
|
96 |
'data-taxonomy' => $taxname,
|
97 |
'data-build_what' => $build_what,
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
'class' => $use_bootstrap ? 'btn btn-default wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide' : 'wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide',
|
102 |
),
|
|
|
103 |
'#validate' => $this->getValidationData(),
|
104 |
);
|
105 |
|
106 |
// Input for new taxonomy
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
$metaform[] = array(
|
118 |
'#type' => 'textfield',
|
119 |
'#title' => '',
|
120 |
'#description' => '',
|
121 |
-
'#name' => "new_tax_text_"
|
122 |
'#value' => '',
|
123 |
'#attributes' => array(
|
124 |
'data-taxonomy' => $taxname,
|
125 |
-
|
126 |
-
|
127 |
),
|
128 |
'#validate' => $this->getValidationData(),
|
129 |
'#before' => $container,
|
|
|
130 |
);
|
131 |
-
|
132 |
-
|
133 |
* The select for parent
|
134 |
*/
|
135 |
$metaform[] = array(
|
@@ -141,12 +145,13 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
|
|
141 |
)),
|
142 |
'#default_value' => 0,
|
143 |
'#description' => '',
|
144 |
-
'#name' => "new_tax_select_"
|
145 |
'#attributes' => array(
|
146 |
'data-parent-text' => $attributes['parent_text'],
|
147 |
'data-taxonomy' => $taxname,
|
148 |
-
'class' => 'js-taxonomy-parent
|
149 |
),
|
|
|
150 |
'#validate' => $this->getValidationData(),
|
151 |
);
|
152 |
|
@@ -157,44 +162,49 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
|
|
157 |
'#type' => 'button',
|
158 |
'#title' => '',
|
159 |
'#description' => '',
|
160 |
-
'#name' => "new_tax_button_"
|
161 |
-
'#value' =>
|
162 |
'#attributes' => array(
|
163 |
'data-taxonomy' => $taxname,
|
164 |
'data-build_what' => $build_what,
|
165 |
-
|
166 |
),
|
167 |
-
'#validate' => $this->getValidationData(),
|
168 |
-
'#after' => '</div>',
|
169 |
-
);
|
170 |
|
|
|
|
|
|
|
|
|
171 |
return $metaform;
|
|
|
172 |
}
|
173 |
|
174 |
-
private function buildTerms($obj_terms)
|
175 |
-
|
|
|
176 |
foreach ($obj_terms as $term) {
|
177 |
-
$tax_terms[]
|
178 |
-
'name'
|
179 |
-
'count'
|
180 |
-
'parent'
|
181 |
-
'term_taxonomy_id'
|
182 |
-
'term_id'
|
183 |
);
|
184 |
}
|
185 |
return $tax_terms;
|
186 |
}
|
187 |
|
188 |
-
private function buildSelect()
|
|
|
189 |
$attributes = $this->getAttr();
|
190 |
-
|
191 |
$multiple = !isset($attributes['single_select']) || !$attributes['single_select'];
|
192 |
-
|
193 |
$curr_options = $this->getOptions();
|
194 |
$values = $this->valuesId;
|
195 |
$options = array();
|
196 |
-
if
|
197 |
-
|
|
|
198 |
$option = array(
|
199 |
'#value' => $name,
|
200 |
'#title' => $data['value'],
|
@@ -212,7 +222,7 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
|
|
212 |
* default_value
|
213 |
*/
|
214 |
$default_value = null;
|
215 |
-
if (count($this->valuesId)) {
|
216 |
$default_value = $this->valuesId[0];
|
217 |
}
|
218 |
/**
|
@@ -225,16 +235,16 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
|
|
225 |
'#description' => $this->getDescription(),
|
226 |
'#name' => $this->getName() . '[]',
|
227 |
'#options' => $options,
|
228 |
-
'#default_value' => isset($data['default_value']) && !empty($data['default_value']) ? $data['default_value'] : $default_value,
|
229 |
'#validate' => $this->getValidationData(),
|
230 |
'#class' => 'form-inline',
|
231 |
'#repetitive' => $this->isRepetitive(),
|
232 |
);
|
233 |
-
|
234 |
if ($multiple) {
|
235 |
$select['#attributes'] = array('multiple' => 'multiple');
|
236 |
}
|
237 |
-
|
238 |
if (count($options) == 0) {
|
239 |
if (isset($select['#attributes'])) {
|
240 |
$select['#attributes']['style'] = 'display:none';
|
@@ -247,17 +257,18 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
|
|
247 |
return $form;
|
248 |
}
|
249 |
|
250 |
-
private function getOptions($index = 0, $level = 0, $parent = -1)
|
251 |
-
|
|
|
252 |
return;
|
253 |
}
|
254 |
$options = array();
|
255 |
|
256 |
-
foreach
|
257 |
-
$options[$one] = array('value' => sprintf('%s%s', str_repeat(' ', 2
|
258 |
-
|
259 |
-
if (isset($this->childs[$one]) && count($this->childs[$one])) {
|
260 |
-
foreach
|
261 |
$options[$id] = $data;
|
262 |
}
|
263 |
}
|
@@ -265,78 +276,65 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
|
|
265 |
return $options;
|
266 |
}
|
267 |
|
268 |
-
private function buildCheckboxes($index, &$childs, &$names, &$metaform, $level = 0, $parent = -1)
|
|
|
269 |
if (isset($childs[$index])) {
|
270 |
-
$level_count = count($childs[$index]);
|
271 |
-
foreach ($childs[$index] as $tkey => $tid) {
|
272 |
$name = $names[$tid];
|
273 |
/**
|
274 |
* check for "checked"
|
275 |
*/
|
276 |
$default_value = false;
|
277 |
-
if (isset($this->valuesId) && is_array($this->valuesId) && !empty($this->valuesId)) {
|
278 |
-
$default_value = in_array($tid, $this->valuesId);
|
279 |
-
} else if (is_array($this->getValue())) {
|
280 |
-
$default_value = in_array($tid, $this->getValue());
|
281 |
}
|
282 |
-
$clases = array();
|
283 |
-
$clases[] = 'tax-' . sanitize_title($names[$tid]);
|
284 |
-
$clases[] = 'tax-' . $this->_data['name'] . '-' . $tid;
|
285 |
-
/**
|
286 |
-
* filter: cred_checkboxes_class
|
287 |
-
* @param array $clases current array of classes
|
288 |
-
* @parem array $option current option
|
289 |
-
* @param string field type
|
290 |
-
*
|
291 |
-
* @return array
|
292 |
-
*/
|
293 |
-
$clases = apply_filters('cred_item_li_class', $clases, array('id' => $tid, 'name' => $name), 'taxonomyhierarchical');
|
294 |
-
|
295 |
$item = array(
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
if ($tkey == 0) {
|
313 |
if ($level > 0) {
|
314 |
-
$item['#before'] = '<li
|
315 |
-
} else
|
316 |
-
$item['#before'] = '<ul class="wpt-form-set wpt-form-set-checkboxes wpt-form-set-checkboxes-' . $this->getName() . '" data-level="0">'
|
317 |
}
|
318 |
}
|
319 |
-
if ($tkey == ( $level_count - 1 )) {
|
320 |
$item['#after'] = '</li>';
|
321 |
}
|
322 |
-
|
323 |
$metaform[] = $item;
|
324 |
|
325 |
-
if (isset($childs[$tid])) {
|
326 |
-
$metaform = $this->buildCheckboxes($tid, $childs, $names, $metaform, $level + 1, $tid);
|
327 |
}
|
|
|
328 |
}
|
329 |
}
|
330 |
-
|
331 |
if (count($metaform)) {
|
332 |
if ($level == 0) {
|
333 |
$metaform[count($metaform) - 1]['#after'] .= '</ul>';
|
334 |
-
} else
|
335 |
$metaform[count($metaform) - 1]['#after'] .= '</ul></li>';
|
336 |
}
|
337 |
}
|
338 |
-
|
339 |
return $metaform;
|
340 |
}
|
341 |
-
|
342 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php $
|
5 |
+
* $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
|
6 |
+
* $LastChangedRevision: 1180956 $
|
7 |
* $LastChangedBy: iworks $
|
8 |
*
|
9 |
*/
|
|
|
10 |
|
11 |
+
include_once 'class.textfield.php';
|
12 |
|
13 |
+
class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
|
14 |
+
{
|
15 |
protected $child;
|
16 |
protected $names;
|
17 |
protected $values = array();
|
18 |
protected $valuesId = array();
|
19 |
protected $objValues;
|
20 |
|
21 |
+
public function init()
|
22 |
+
{
|
23 |
global $post;
|
24 |
|
25 |
$this->objValues = array();
|
31 |
$this->objValues[$term->slug] = $term;
|
32 |
}
|
33 |
}
|
34 |
+
|
35 |
+
$all = $this->buildTerms(get_terms($this->getName(),array('hide_empty'=>0,'fields'=>'all')));
|
36 |
|
37 |
+
|
38 |
+
|
39 |
+
$childs=array();
|
40 |
+
$names=array();
|
|
|
|
|
41 |
foreach ($all as $term) {
|
42 |
+
$names[$term['term_id']]=$term['name'];
|
43 |
if (!isset($childs[$term['parent']]) || !is_array($childs[$term['parent']]))
|
44 |
+
$childs[$term['parent']]=array();
|
45 |
+
$childs[$term['parent']][]=$term['term_id'];
|
46 |
}
|
47 |
|
48 |
// ksort($childs);
|
49 |
+
|
50 |
$this->childs = $childs;
|
51 |
$this->names = $names;
|
52 |
}
|
53 |
|
54 |
+
public function enqueueScripts()
|
55 |
+
{
|
56 |
}
|
57 |
|
58 |
+
public function enqueueStyles()
|
59 |
+
{
|
60 |
}
|
61 |
|
62 |
+
public function metaform()
|
63 |
+
{
|
64 |
+
$use_bootstrap = array_key_exists( 'use_bootstrap', $this->_data ) && $this->_data['use_bootstrap'];
|
65 |
$attributes = $this->getAttr();
|
66 |
+
$taxname = $this->getName();
|
67 |
$res = '';
|
68 |
$metaform = array();
|
69 |
$build_what = '';
|
70 |
+
|
71 |
+
if ( array_key_exists( 'display', $this->_data ) && 'select' == $this->_data['display'] ) {
|
72 |
$metaform = $this->buildSelect();
|
73 |
$build_what = 'select';
|
74 |
} else {
|
76 |
$this->set_metaform($res);
|
77 |
$build_what = 'checkboxes';
|
78 |
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* TODO
|
82 |
+
*
|
83 |
+
* Use this to get the taxonomy labels for the "Add new" event
|
84 |
+
*
|
85 |
+
* $taxobject = get_taxonomy( $taxname );
|
86 |
+
*/
|
87 |
+
|
88 |
/**
|
89 |
* "Add new" button
|
90 |
*/
|
92 |
'#type' => 'button',
|
93 |
'#title' => '',
|
94 |
'#description' => '',
|
95 |
+
'#name' => "btn_".$taxname,
|
96 |
+
'#value' => esc_attr( $attributes['add_new_text'] ),
|
97 |
'#attributes' => array(
|
98 |
'style' => 'display:none;',
|
99 |
'data-taxonomy' => $taxname,
|
100 |
'data-build_what' => $build_what,
|
101 |
+
'data-after-selector' => 'js-wpt-hierarchical-taxonomy-add-new-' . $taxname,
|
102 |
+
'data-close' => esc_attr( __( 'Cancel', 'wpv-views' ) ),// TODO adjust the button value depending on open/close action
|
103 |
+
'class' => $use_bootstrap? 'btn btn-default wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide' : 'wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide',
|
|
|
104 |
),
|
105 |
+
|
106 |
'#validate' => $this->getValidationData(),
|
107 |
);
|
108 |
|
109 |
// Input for new taxonomy
|
110 |
+
|
111 |
+
if ( $use_bootstrap ) {
|
112 |
+
$container = '<div style="display:none" class="form-group wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new-' . $taxname . '" data-taxonomy="' . $taxname . '">';
|
113 |
+
} else {
|
114 |
+
$container = '<div style="display:none" class="wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new-' . $taxname . '" data-taxonomy="' . $taxname . '">';
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* The textfield input
|
119 |
+
*/
|
120 |
$metaform[] = array(
|
121 |
'#type' => 'textfield',
|
122 |
'#title' => '',
|
123 |
'#description' => '',
|
124 |
+
'#name' => "new_tax_text_".$taxname,
|
125 |
'#value' => '',
|
126 |
'#attributes' => array(
|
127 |
'data-taxonomy' => $taxname,
|
128 |
+
'data-taxtype' => 'hierarchical',
|
129 |
+
'class' => $use_bootstrap ? 'inline wpt-new-taxonomy-title js-wpt-new-taxonomy-title' : 'wpt-new-taxonomy-title js-wpt-new-taxonomy-title',
|
130 |
),
|
131 |
'#validate' => $this->getValidationData(),
|
132 |
'#before' => $container,
|
133 |
+
|
134 |
);
|
135 |
+
|
136 |
+
/**
|
137 |
* The select for parent
|
138 |
*/
|
139 |
$metaform[] = array(
|
145 |
)),
|
146 |
'#default_value' => 0,
|
147 |
'#description' => '',
|
148 |
+
'#name' => "new_tax_select_".$taxname,
|
149 |
'#attributes' => array(
|
150 |
'data-parent-text' => $attributes['parent_text'],
|
151 |
'data-taxonomy' => $taxname,
|
152 |
+
'class' => 'js-taxonomy-parent'
|
153 |
),
|
154 |
+
|
155 |
'#validate' => $this->getValidationData(),
|
156 |
);
|
157 |
|
162 |
'#type' => 'button',
|
163 |
'#title' => '',
|
164 |
'#description' => '',
|
165 |
+
'#name' => "new_tax_button_".$taxname,
|
166 |
+
'#value' => esc_attr( $attributes['add_text'] ),
|
167 |
'#attributes' => array(
|
168 |
'data-taxonomy' => $taxname,
|
169 |
'data-build_what' => $build_what,
|
170 |
+
'class' => $use_bootstrap ? 'btn btn-default wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new' : 'wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new',
|
171 |
),
|
|
|
|
|
|
|
172 |
|
173 |
+
'#validate' => $this->getValidationData(),
|
174 |
+
'#after' => '</div>',
|
175 |
+
);
|
176 |
+
|
177 |
return $metaform;
|
178 |
+
|
179 |
}
|
180 |
|
181 |
+
private function buildTerms($obj_terms)
|
182 |
+
{
|
183 |
+
$tax_terms=array();
|
184 |
foreach ($obj_terms as $term) {
|
185 |
+
$tax_terms[]=array(
|
186 |
+
'name'=>$term->name,
|
187 |
+
'count'=>$term->count,
|
188 |
+
'parent'=>$term->parent,
|
189 |
+
'term_taxonomy_id'=>$term->term_taxonomy_id,
|
190 |
+
'term_id'=>$term->term_id
|
191 |
);
|
192 |
}
|
193 |
return $tax_terms;
|
194 |
}
|
195 |
|
196 |
+
private function buildSelect()
|
197 |
+
{
|
198 |
$attributes = $this->getAttr();
|
199 |
+
|
200 |
$multiple = !isset($attributes['single_select']) || !$attributes['single_select'];
|
201 |
+
|
202 |
$curr_options = $this->getOptions();
|
203 |
$values = $this->valuesId;
|
204 |
$options = array();
|
205 |
+
if( $curr_options )
|
206 |
+
{
|
207 |
+
foreach ($curr_options as $name=>$data) {
|
208 |
$option = array(
|
209 |
'#value' => $name,
|
210 |
'#title' => $data['value'],
|
222 |
* default_value
|
223 |
*/
|
224 |
$default_value = null;
|
225 |
+
if ( count( $this->valuesId) ) {
|
226 |
$default_value = $this->valuesId[0];
|
227 |
}
|
228 |
/**
|
235 |
'#description' => $this->getDescription(),
|
236 |
'#name' => $this->getName() . '[]',
|
237 |
'#options' => $options,
|
238 |
+
'#default_value' => isset( $data['default_value'] ) && !empty( $data['default_value'] ) ? $data['default_value'] : $default_value,
|
239 |
'#validate' => $this->getValidationData(),
|
240 |
'#class' => 'form-inline',
|
241 |
'#repetitive' => $this->isRepetitive(),
|
242 |
);
|
243 |
+
|
244 |
if ($multiple) {
|
245 |
$select['#attributes'] = array('multiple' => 'multiple');
|
246 |
}
|
247 |
+
|
248 |
if (count($options) == 0) {
|
249 |
if (isset($select['#attributes'])) {
|
250 |
$select['#attributes']['style'] = 'display:none';
|
257 |
return $form;
|
258 |
}
|
259 |
|
260 |
+
private function getOptions($index = 0, $level = 0, $parent = -1)
|
261 |
+
{
|
262 |
+
if ( !isset($this->childs[$index]) || empty( $this->childs[$index] ) ) {
|
263 |
return;
|
264 |
}
|
265 |
$options = array();
|
266 |
|
267 |
+
foreach( $this->childs[$index] as $one ) {
|
268 |
+
$options[$one] = array('value' => sprintf('%s%s', str_repeat(' ', 2*$level ), $this->names[$one]),
|
269 |
+
'parent' => $parent);
|
270 |
+
if ( isset($this->childs[$one]) && count($this->childs[$one])) {
|
271 |
+
foreach( $this->getOptions( $one, $level + 1, $one ) as $id => $data ) {
|
272 |
$options[$id] = $data;
|
273 |
}
|
274 |
}
|
276 |
return $options;
|
277 |
}
|
278 |
|
279 |
+
private function buildCheckboxes( $index, &$childs, &$names, &$metaform, $level = 0, $parent = -1 )
|
280 |
+
{
|
281 |
if (isset($childs[$index])) {
|
282 |
+
$level_count = count( $childs[$index] );
|
283 |
+
foreach ( $childs[$index] as $tkey => $tid ) {
|
284 |
$name = $names[$tid];
|
285 |
/**
|
286 |
* check for "checked"
|
287 |
*/
|
288 |
$default_value = false;
|
289 |
+
if ( isset( $this->valuesId ) && is_array( $this->valuesId ) && !empty($this->valuesId)) {
|
290 |
+
$default_value = in_array( $tid, $this->valuesId );
|
291 |
+
} else if ( is_array( $this->getValue() ) ) {
|
292 |
+
$default_value = in_array( $tid, $this->getValue() );
|
293 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
$item = array(
|
295 |
+
'#type' => 'checkbox',
|
296 |
+
'#title' => $names[$tid],
|
297 |
+
'#description' => '',
|
298 |
+
'#name' => $this->getName()."[]",
|
299 |
+
'#value' => $tid,
|
300 |
+
'#default_value' => $default_value,
|
301 |
+
'#validate' => $this->getValidationData(),
|
302 |
+
'#before' => '<li>',
|
303 |
+
'#after' => '</li>',
|
304 |
+
'#attributes' => array(
|
305 |
+
'data-parent' => $parent
|
306 |
+
),
|
307 |
+
'#pattern' => '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>'
|
308 |
+
);
|
309 |
+
|
310 |
+
if ( $tkey == 0 ) {
|
|
|
311 |
if ($level > 0) {
|
312 |
+
$item['#before'] = '<li><ul class="wpt-form-set-children wpt-form-set-children-level-' . $level . '" data-level="' . $level . '"><li>';
|
313 |
+
} else {
|
314 |
+
$item['#before'] = '<ul class="wpt-form-set wpt-form-set-checkboxes wpt-form-set-checkboxes-' . $this->getName() . '" data-level="0"><li>';
|
315 |
}
|
316 |
}
|
317 |
+
if ( $tkey == ( $level_count - 1 ) ) {
|
318 |
$item['#after'] = '</li>';
|
319 |
}
|
320 |
+
|
321 |
$metaform[] = $item;
|
322 |
|
323 |
+
if ( isset( $childs[$tid] ) ) {
|
324 |
+
$metaform = $this->buildCheckboxes( $tid, $childs, $names, $metaform, $level + 1, $tid );
|
325 |
}
|
326 |
+
|
327 |
}
|
328 |
}
|
329 |
+
|
330 |
if (count($metaform)) {
|
331 |
if ($level == 0) {
|
332 |
$metaform[count($metaform) - 1]['#after'] .= '</ul>';
|
333 |
+
} else {
|
334 |
$metaform[count($metaform) - 1]['#after'] .= '</ul></li>';
|
335 |
}
|
336 |
}
|
337 |
+
|
338 |
return $metaform;
|
339 |
}
|
|
|
340 |
}
|
embedded/common/toolset-forms/classes/class.textarea.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
-
* $HeadURL:
|
5 |
-
* $LastChangedDate: 2014-
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.field_factory.php';
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.textarea.php $
|
5 |
+
* $LastChangedDate: 2014-07-10 10:46:40 +0200 (Thu, 10 Jul 2014) $
|
6 |
+
* $LastChangedRevision: 24820 $
|
7 |
+
* $LastChangedBy: francesco $
|
8 |
*
|
9 |
*/
|
10 |
require_once 'class.field_factory.php';
|
embedded/common/toolset-forms/classes/class.textfield.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
-
* $HeadURL:
|
5 |
-
* $LastChangedDate:
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
require_once "class.field_factory.php";
|
@@ -22,6 +22,8 @@ class WPToolset_Field_Textfield extends FieldFactory
|
|
22 |
{
|
23 |
public function metaform()
|
24 |
{
|
|
|
|
|
25 |
$metaform = array();
|
26 |
$metaform[] = array(
|
27 |
'#type' => 'textfield',
|
@@ -31,8 +33,7 @@ class WPToolset_Field_Textfield extends FieldFactory
|
|
31 |
'#value' => $this->getValue(),
|
32 |
'#validate' => $this->getValidationData(),
|
33 |
'#repetitive' => $this->isRepetitive(),
|
34 |
-
'#attributes' => $
|
35 |
-
'wpml_action' => $this->getWPMLAction(),
|
36 |
);
|
37 |
return $metaform;
|
38 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.textfield.php $
|
5 |
+
* $LastChangedDate: 2014-07-09 10:26:51 +0200 (Wed, 09 Jul 2014) $
|
6 |
+
* $LastChangedRevision: 24777 $
|
7 |
+
* $LastChangedBy: juan $
|
8 |
*
|
9 |
*/
|
10 |
require_once "class.field_factory.php";
|
22 |
{
|
23 |
public function metaform()
|
24 |
{
|
25 |
+
$attributes = $this->getAttr();
|
26 |
+
|
27 |
$metaform = array();
|
28 |
$metaform[] = array(
|
29 |
'#type' => 'textfield',
|
33 |
'#value' => $this->getValue(),
|
34 |
'#validate' => $this->getValidationData(),
|
35 |
'#repetitive' => $this->isRepetitive(),
|
36 |
+
'#attributes' => $attributes,
|
|
|
37 |
);
|
38 |
return $metaform;
|
39 |
}
|
embedded/common/toolset-forms/classes/class.types.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
/**
|
3 |
* Types fields specific
|
4 |
*
|
5 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
6 |
-
* $LastChangedDate:
|
7 |
-
* $LastChangedRevision:
|
8 |
-
* $LastChangedBy:
|
9 |
*
|
10 |
*/
|
11 |
|
@@ -68,7 +68,6 @@ class WPToolset_Types
|
|
68 |
*
|
69 |
* Main settings that are returned.
|
70 |
*/
|
71 |
-
|
72 |
$_field = array(
|
73 |
'id' => $prefix . $field['id'] . $suffix, // Used as main ID (raw date wpt-id), used to connect conditional relations
|
74 |
'meta_key' => $prefix . $field['id'], // Used by Types (meta key of field saved to DB)
|
@@ -83,7 +82,6 @@ class WPToolset_Types
|
|
83 |
'repetitive' => self::isRepetitive( $field ), // Is repetitive?
|
84 |
'validation' => self::filterValidation( $field ), // Validation settings
|
85 |
'conditional' => self::filterConditional( $field, $post_id, $_post_wpcf ), // Conditional settings
|
86 |
-
'placeholder' => isset($field['data']) && isset($field['data']['placeholder'])? $field['data']['placeholder']:null, // HTML5 placeholder
|
87 |
);
|
88 |
|
89 |
/* Specific field settings
|
@@ -142,7 +140,6 @@ class WPToolset_Types
|
|
142 |
if ( $field['type'] == 'radio' ) {
|
143 |
$_field['type'] = 'radios';
|
144 |
}
|
145 |
-
|
146 |
return $cache[$cache_key] = $_field;
|
147 |
}
|
148 |
|
@@ -197,7 +194,7 @@ class WPToolset_Types
|
|
197 |
$validation[$rule] = array(
|
198 |
'args' => isset( $settings['args'] ) ? array_unshift( $value,
|
199 |
$settings['args'] ) : array($value, true),
|
200 |
-
'message' => self::translate('field ' . $id . ' validation message ' . $rule,
|
201 |
);
|
202 |
}
|
203 |
}
|
@@ -317,7 +314,7 @@ class WPToolset_Types
|
|
317 |
|
318 |
// Get [values]
|
319 |
$cond_values = self::getConditionalValues($post_id, $field['meta_type']);
|
320 |
-
|
321 |
if ( function_exists('wpcf_fields_get_field_by_slug') ){
|
322 |
// Update the conditional values according to what's being saved.
|
323 |
foreach ( $_post_wpcf as $field_slug => $field_value ) {
|
@@ -326,10 +323,11 @@ class WPToolset_Types
|
|
326 |
if ( empty( $field ) ) {
|
327 |
continue;
|
328 |
}
|
329 |
-
|
330 |
-
$field_value = apply_filters( 'wpcf_fields_type_' . $field['type']
|
331 |
-
|
332 |
-
|
|
|
333 |
}
|
334 |
}
|
335 |
|
@@ -384,7 +382,7 @@ class WPToolset_Types
|
|
384 |
unset( $cond_values, $c_values, $c_field );
|
385 |
return $cache[$cache_key] = $cond;
|
386 |
}
|
387 |
-
|
388 |
public static function getConditionalValues($post_id, $meta_type = 'postmeta') {
|
389 |
$cond_values = array();
|
390 |
if ( !empty( $post_id ) ) {
|
@@ -398,10 +396,10 @@ class WPToolset_Types
|
|
398 |
$v = self::getStringFromArray($v);
|
399 |
}
|
400 |
}
|
401 |
-
|
402 |
return $cond_values;
|
403 |
}
|
404 |
-
|
405 |
public static function getCustomConditional($custom, $suffix = '', $cond_values = array()) {
|
406 |
$c_fields = WPToolset_Forms_Conditional::extractFields( $custom );
|
407 |
$c_values = array();
|
@@ -441,7 +439,7 @@ class WPToolset_Types
|
|
441 |
'custom' => $custom,
|
442 |
'values' => $c_values,
|
443 |
);
|
444 |
-
|
445 |
return $cond;
|
446 |
}
|
447 |
|
2 |
/**
|
3 |
* Types fields specific
|
4 |
*
|
5 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.types.php $
|
6 |
+
* $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
|
7 |
+
* $LastChangedRevision: 970205 $
|
8 |
+
* $LastChangedBy: brucepearson $
|
9 |
*
|
10 |
*/
|
11 |
|
68 |
*
|
69 |
* Main settings that are returned.
|
70 |
*/
|
|
|
71 |
$_field = array(
|
72 |
'id' => $prefix . $field['id'] . $suffix, // Used as main ID (raw date wpt-id), used to connect conditional relations
|
73 |
'meta_key' => $prefix . $field['id'], // Used by Types (meta key of field saved to DB)
|
82 |
'repetitive' => self::isRepetitive( $field ), // Is repetitive?
|
83 |
'validation' => self::filterValidation( $field ), // Validation settings
|
84 |
'conditional' => self::filterConditional( $field, $post_id, $_post_wpcf ), // Conditional settings
|
|
|
85 |
);
|
86 |
|
87 |
/* Specific field settings
|
140 |
if ( $field['type'] == 'radio' ) {
|
141 |
$_field['type'] = 'radios';
|
142 |
}
|
|
|
143 |
return $cache[$cache_key] = $_field;
|
144 |
}
|
145 |
|
194 |
$validation[$rule] = array(
|
195 |
'args' => isset( $settings['args'] ) ? array_unshift( $value,
|
196 |
$settings['args'] ) : array($value, true),
|
197 |
+
'message' => self::translate('field ' . $id . ' validation message ' . $rule, $settings['message'])
|
198 |
);
|
199 |
}
|
200 |
}
|
314 |
|
315 |
// Get [values]
|
316 |
$cond_values = self::getConditionalValues($post_id, $field['meta_type']);
|
317 |
+
|
318 |
if ( function_exists('wpcf_fields_get_field_by_slug') ){
|
319 |
// Update the conditional values according to what's being saved.
|
320 |
foreach ( $_post_wpcf as $field_slug => $field_value ) {
|
323 |
if ( empty( $field ) ) {
|
324 |
continue;
|
325 |
}
|
326 |
+
|
327 |
+
$field_value = apply_filters( 'wpcf_fields_type_' . $field['type']
|
328 |
+
. '_value_save', $field_value, $field, null );
|
329 |
+
|
330 |
+
$cond_values[$field['meta_key']] = $field_value;
|
331 |
}
|
332 |
}
|
333 |
|
382 |
unset( $cond_values, $c_values, $c_field );
|
383 |
return $cache[$cache_key] = $cond;
|
384 |
}
|
385 |
+
|
386 |
public static function getConditionalValues($post_id, $meta_type = 'postmeta') {
|
387 |
$cond_values = array();
|
388 |
if ( !empty( $post_id ) ) {
|
396 |
$v = self::getStringFromArray($v);
|
397 |
}
|
398 |
}
|
399 |
+
|
400 |
return $cond_values;
|
401 |
}
|
402 |
+
|
403 |
public static function getCustomConditional($custom, $suffix = '', $cond_values = array()) {
|
404 |
$c_fields = WPToolset_Forms_Conditional::extractFields( $custom );
|
405 |
$c_values = array();
|
439 |
'custom' => $custom,
|
440 |
'values' => $c_values,
|
441 |
);
|
442 |
+
|
443 |
return $cond;
|
444 |
}
|
445 |
|
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,26 +126,26 @@ 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
|
133 |
* @throws Exception
|
134 |
*/
|
135 |
-
public function validateField( $field ) {
|
136 |
-
$value = apply_filters( 'wptoolset_validation_value_' . $field->getType(),
|
|
|
137 |
$rules = $this->_parseRules( $field->getValidationData(), $value );
|
138 |
// If not required but empty - skip
|
139 |
if ( !isset( $rules['required'] )
|
140 |
&& ( is_null( $value ) || $value === false || $value === '' ) ) {
|
141 |
return true;
|
142 |
}
|
143 |
-
|
144 |
try {
|
145 |
-
$errors = array();
|
146 |
foreach ( $rules as $rule => $args ) {
|
147 |
if ( !$this->validate( $rule, $args['args'] ) ) {
|
148 |
-
$errors[] = $field->getTitle() . ' ' . $args['message'];
|
149 |
}
|
150 |
}
|
151 |
if ( !empty( $errors ) ) {
|
@@ -157,7 +157,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 +178,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
|
@@ -188,11 +188,6 @@ class WPToolset_Forms_Validation
|
|
188 |
public function validate( $rule, $args ) {
|
189 |
$validator = $this->_cake();
|
190 |
$rule = $this->_map_rule_js_to_php( $rule );
|
191 |
-
|
192 |
-
if ( 'skype' == $rule ) {
|
193 |
-
return $validator->custom($args[0]['skypename'], '/^([a-zA-Z0-9\,\.\-\_]+)$/');
|
194 |
-
}
|
195 |
-
|
196 |
if ( is_callable( array($validator, $rule) ) ) {
|
197 |
return call_user_func_array( array($validator, $rule), $args );
|
198 |
}
|
@@ -201,7 +196,7 @@ class WPToolset_Forms_Validation
|
|
201 |
|
202 |
/**
|
203 |
* Loads CakePHP Validation class.
|
204 |
-
*
|
205 |
* @return type
|
206 |
*/
|
207 |
protected function _cake() {
|
@@ -214,7 +209,7 @@ class WPToolset_Forms_Validation
|
|
214 |
|
215 |
/**
|
216 |
* Maps rules between JS and PHP.
|
217 |
-
*
|
218 |
* @param type $rule
|
219 |
* @return type
|
220 |
*/
|
@@ -226,9 +221,10 @@ class WPToolset_Forms_Validation
|
|
226 |
* Renders JSON data.
|
227 |
*/
|
228 |
public function renderJsonData() {
|
229 |
-
|
|
|
230 |
}
|
231 |
-
|
232 |
public function actionFieldClass( $config ) {
|
233 |
if ( !empty( $config['validation'] ) ) {
|
234 |
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
|
133 |
* @throws Exception
|
134 |
*/
|
135 |
+
public function validateField( $field ) {
|
136 |
+
$value = apply_filters( 'wptoolset_validation_value_' . $field->getType(),
|
137 |
+
$field->getValue() );
|
138 |
$rules = $this->_parseRules( $field->getValidationData(), $value );
|
139 |
// If not required but empty - skip
|
140 |
if ( !isset( $rules['required'] )
|
141 |
&& ( is_null( $value ) || $value === false || $value === '' ) ) {
|
142 |
return true;
|
143 |
}
|
|
|
144 |
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 |
}
|
158 |
return true;
|
159 |
}
|
160 |
+
|
161 |
protected function _parseRules( $rules, $value ) {
|
162 |
$_rules = array();
|
163 |
foreach ( $rules as $rule => $args ) {
|
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
|
188 |
public function validate( $rule, $args ) {
|
189 |
$validator = $this->_cake();
|
190 |
$rule = $this->_map_rule_js_to_php( $rule );
|
|
|
|
|
|
|
|
|
|
|
191 |
if ( is_callable( array($validator, $rule) ) ) {
|
192 |
return call_user_func_array( array($validator, $rule), $args );
|
193 |
}
|
196 |
|
197 |
/**
|
198 |
* Loads CakePHP Validation class.
|
199 |
+
*
|
200 |
* @return type
|
201 |
*/
|
202 |
protected function _cake() {
|
209 |
|
210 |
/**
|
211 |
* Maps rules between JS and PHP.
|
212 |
+
*
|
213 |
* @param type $rule
|
214 |
* @return type
|
215 |
*/
|
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) {
|
embedded/common/toolset-forms/classes/class.video.php
CHANGED
@@ -6,10 +6,10 @@ require_once 'class.file.php';
|
|
6 |
*
|
7 |
* @author Srdjan
|
8 |
*
|
9 |
-
* $HeadURL:
|
10 |
-
* $LastChangedDate: 2014-
|
11 |
-
* $LastChangedRevision:
|
12 |
-
* $LastChangedBy:
|
13 |
*
|
14 |
*/
|
15 |
class WPToolset_Field_Video extends WPToolset_Field_File
|
@@ -23,51 +23,15 @@ class WPToolset_Field_Video extends WPToolset_Field_File
|
|
23 |
$this->setValidationData($validation);
|
24 |
return parent::metaform();
|
25 |
}
|
26 |
-
|
27 |
-
public static function addTypeValidation($validation)
|
28 |
-
{
|
29 |
-
$valid_extensions = array(
|
30 |
-
'3gp',
|
31 |
-
'aaf',
|
32 |
-
'asf',
|
33 |
-
'avchd',
|
34 |
-
'avi',
|
35 |
-
'cam',
|
36 |
-
'dat',
|
37 |
-
'dsh',
|
38 |
-
'fla',
|
39 |
-
'flr',
|
40 |
-
'flv',
|
41 |
-
'm1v',
|
42 |
-
'm2v',
|
43 |
-
'm4v',
|
44 |
-
'mng',
|
45 |
-
'mp4',
|
46 |
-
'mxf',
|
47 |
-
'nsv',
|
48 |
-
'ogg',
|
49 |
-
'rm',
|
50 |
-
'roq',
|
51 |
-
'smi',
|
52 |
-
'sol',
|
53 |
-
'svi',
|
54 |
-
'swf',
|
55 |
-
'wmv',
|
56 |
-
'wrap',
|
57 |
-
'mkv',
|
58 |
-
'mov',
|
59 |
-
'mpe',
|
60 |
-
'mpeg',
|
61 |
-
'mpg',
|
62 |
-
);
|
63 |
-
$valid_extensions = apply_filters( 'toolset_valid_video_extentions', $valid_extensions);
|
64 |
$validation['extension'] = array(
|
65 |
'args' => array(
|
66 |
'extension',
|
67 |
-
|
68 |
),
|
69 |
'message' => __( 'You can add only video.', 'wpv-views' ),
|
70 |
);
|
71 |
return $validation;
|
72 |
-
}
|
73 |
}
|
6 |
*
|
7 |
* @author Srdjan
|
8 |
*
|
9 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.video.php $
|
10 |
+
* $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
|
11 |
+
* $LastChangedRevision: 26350 $
|
12 |
+
* $LastChangedBy: francesco $
|
13 |
*
|
14 |
*/
|
15 |
class WPToolset_Field_Video extends WPToolset_Field_File
|
23 |
$this->setValidationData($validation);
|
24 |
return parent::metaform();
|
25 |
}
|
26 |
+
|
27 |
+
public static function addTypeValidation($validation) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
$validation['extension'] = array(
|
29 |
'args' => array(
|
30 |
'extension',
|
31 |
+
'3gp|aaf|asf|avchd|avi|cam|dat|dsh|fla|flr|flv|m1v|m2v|m4v|mng|mp4|mxf|nsv|ogg|rm|roq|smi|sol|svi|swf|wmv|wrap|mkv|mov|mpe|mpeg|mpg',
|
32 |
),
|
33 |
'message' => __( 'You can add only video.', 'wpv-views' ),
|
34 |
);
|
35 |
return $validation;
|
36 |
+
}
|
37 |
}
|
embedded/common/toolset-forms/classes/class.wysiwyg.php
CHANGED
@@ -6,19 +6,19 @@ require_once 'class.textarea.php';
|
|
6 |
*
|
7 |
* @author Srdjan
|
8 |
*
|
9 |
-
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.
|
10 |
-
* $LastChangedDate:
|
11 |
-
* $LastChangedRevision:
|
12 |
* $LastChangedBy: iworks $
|
13 |
*
|
14 |
*/
|
15 |
class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea
|
16 |
-
{
|
17 |
protected $_settings = array('min_wp_version' => '3.3');
|
18 |
|
19 |
public function metaform()
|
20 |
{
|
21 |
-
|
22 |
$attributes = $this->getAttr();
|
23 |
$form = array();
|
24 |
$markup = '';
|
@@ -26,7 +26,7 @@ class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea
|
|
26 |
$markup .= '<div class="form-item form-item-markup">';
|
27 |
$markup .= sprintf( '<label class="wpt-form-label wpt-form-textfield-label">%s</label>', $this->getTitle() );
|
28 |
}
|
29 |
-
$markup .=
|
30 |
$markup .= $this->_editor($attributes);
|
31 |
if ( is_admin() ) {
|
32 |
$markup .= '</div>';
|
@@ -41,14 +41,15 @@ class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea
|
|
41 |
protected function _editor(&$attributes)
|
42 |
{
|
43 |
|
|
|
44 |
if (isset($attributes['readonly'])&&$attributes['readonly']=='readonly') {
|
45 |
add_filter( 'tiny_mce_before_init', array(&$this, 'tiny_mce_before_init_callback'));
|
46 |
}
|
47 |
|
48 |
-
|
49 |
//This will fix a lot of issues as WordPress will not be echoing content to the browser before header() is called
|
50 |
//This fix is important so we will not be necessarily adding ob_start() here in this todo:
|
51 |
-
//https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/185336518/comments#282283111
|
52 |
//Using ob_start in that code will have some side effects of some styles from other plugins not being properly loaded.
|
53 |
|
54 |
global $wp_styles;
|
@@ -73,8 +74,7 @@ class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea
|
|
73 |
}
|
74 |
|
75 |
/*RICCARDO: removed anonymous function for retrocompatibility */
|
76 |
-
public function tiny_mce_before_init_callback($args)
|
77 |
-
{
|
78 |
// do you existing check for published here
|
79 |
if ( 1 == 1 )
|
80 |
$args['readonly'] = 1;
|
6 |
*
|
7 |
* @author Srdjan
|
8 |
*
|
9 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.wysiwyg.php $
|
10 |
+
* $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
|
11 |
+
* $LastChangedRevision: 1180956 $
|
12 |
* $LastChangedBy: iworks $
|
13 |
*
|
14 |
*/
|
15 |
class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea
|
16 |
+
{
|
17 |
protected $_settings = array('min_wp_version' => '3.3');
|
18 |
|
19 |
public function metaform()
|
20 |
{
|
21 |
+
|
22 |
$attributes = $this->getAttr();
|
23 |
$form = array();
|
24 |
$markup = '';
|
26 |
$markup .= '<div class="form-item form-item-markup">';
|
27 |
$markup .= sprintf( '<label class="wpt-form-label wpt-form-textfield-label">%s</label>', $this->getTitle() );
|
28 |
}
|
29 |
+
$markup .= $this->getDescription();
|
30 |
$markup .= $this->_editor($attributes);
|
31 |
if ( is_admin() ) {
|
32 |
$markup .= '</div>';
|
41 |
protected function _editor(&$attributes)
|
42 |
{
|
43 |
|
44 |
+
|
45 |
if (isset($attributes['readonly'])&&$attributes['readonly']=='readonly') {
|
46 |
add_filter( 'tiny_mce_before_init', array(&$this, 'tiny_mce_before_init_callback'));
|
47 |
}
|
48 |
|
49 |
+
//EMERSON: Rewritten to set do_concat to TRUE so WordPress won't echo styles directly to the browser
|
50 |
//This will fix a lot of issues as WordPress will not be echoing content to the browser before header() is called
|
51 |
//This fix is important so we will not be necessarily adding ob_start() here in this todo:
|
52 |
+
//https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/185336518/comments#282283111
|
53 |
//Using ob_start in that code will have some side effects of some styles from other plugins not being properly loaded.
|
54 |
|
55 |
global $wp_styles;
|
74 |
}
|
75 |
|
76 |
/*RICCARDO: removed anonymous function for retrocompatibility */
|
77 |
+
public function tiny_mce_before_init_callback( $args ) {
|
|
|
78 |
// do you existing check for published here
|
79 |
if ( 1 == 1 )
|
80 |
$args['readonly'] = 1;
|
embedded/common/toolset-forms/css/wpt-jquery-ui/datepicker.css
CHANGED
@@ -133,7 +133,7 @@
|
|
133 |
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
|
134 |
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
|
135 |
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
|
136 |
-
.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0;
|
137 |
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
|
138 |
.ui-datepicker select.ui-datepicker-month,
|
139 |
.ui-datepicker select.ui-datepicker-year { width: 49%;}
|
133 |
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
|
134 |
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
|
135 |
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
|
136 |
+
.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
|
137 |
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
|
138 |
.ui-datepicker select.ui-datepicker-month,
|
139 |
.ui-datepicker select.ui-datepicker-year { width: 49%;}
|
embedded/common/toolset-forms/css/wpt-toolset-frontend.css
CHANGED
@@ -100,17 +100,6 @@ ul.wpt-form-set, ul.wpt-form-set-children {
|
|
100 |
margin: 10px 0;
|
101 |
display: block;
|
102 |
}
|
103 |
-
|
104 |
-
.wpt-form-success {
|
105 |
-
color:#eee;
|
106 |
-
background-color: #666600;
|
107 |
-
border: 1px solid #aaaa00;
|
108 |
-
padding: 5px 10px;
|
109 |
-
width: auto;
|
110 |
-
margin: 10px 0;
|
111 |
-
display: block;
|
112 |
-
}
|
113 |
-
|
114 |
input.wpt-form-error {
|
115 |
background-color: #F8F8F8;
|
116 |
border-color: red !important;
|
@@ -193,7 +182,7 @@ img.ui-datepicker-trigger, img.ui-datepicker-readonly
|
|
193 |
,.wpt-credfile-undo {
|
194 |
margin: 0 5px 0 0;
|
195 |
}
|
196 |
-
.wpt-repdelete
|
197 |
margin: 0 0 0 5px;
|
198 |
}
|
199 |
.wpt-repadd {
|
@@ -296,17 +285,34 @@ img.wpt-credfile-preview-upload {
|
|
296 |
}
|
297 |
|
298 |
/* Autocomplete */
|
299 |
-
.
|
300 |
-
position: absolute;
|
301 |
-
display: none;
|
302 |
-
min-width: 100px;
|
303 |
-
outline: solid #ccc 1px;
|
304 |
padding: 0px;
|
|
|
305 |
background-color: Window;
|
306 |
overflow: hidden;
|
307 |
}
|
308 |
|
309 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
margin: 0px;
|
311 |
padding: 2px 5px;
|
312 |
cursor: pointer;
|
@@ -317,7 +323,13 @@ img.wpt-credfile-preview-upload {
|
|
317 |
overflow: hidden;
|
318 |
}
|
319 |
|
320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
background-color: Highlight;
|
322 |
color: HighlightText;
|
323 |
}
|
100 |
margin: 10px 0;
|
101 |
display: block;
|
102 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
input.wpt-form-error {
|
104 |
background-color: #F8F8F8;
|
105 |
border-color: red !important;
|
182 |
,.wpt-credfile-undo {
|
183 |
margin: 0 5px 0 0;
|
184 |
}
|
185 |
+
.wpt-repdelete {
|
186 |
margin: 0 0 0 5px;
|
187 |
}
|
188 |
.wpt-repadd {
|
285 |
}
|
286 |
|
287 |
/* Autocomplete */
|
288 |
+
.ac_results {
|
|
|
|
|
|
|
|
|
289 |
padding: 0px;
|
290 |
+
border: 1px solid WindowFrame;
|
291 |
background-color: Window;
|
292 |
overflow: hidden;
|
293 |
}
|
294 |
|
295 |
+
.ac_results ul {
|
296 |
+
width: 100%;
|
297 |
+
list-style-position: outside;
|
298 |
+
list-style: none;
|
299 |
+
padding: 0;
|
300 |
+
margin: 0;
|
301 |
+
}
|
302 |
+
|
303 |
+
.ac_results iframe {
|
304 |
+
display:none;/*sorry for IE5*/
|
305 |
+
display/**/:block;/*sorry for IE5*/
|
306 |
+
position:absolute;
|
307 |
+
top:0;
|
308 |
+
left:0;
|
309 |
+
z-index:-1;
|
310 |
+
filter:mask();
|
311 |
+
width:3000px;
|
312 |
+
height:3000px;
|
313 |
+
}
|
314 |
+
|
315 |
+
.ac_results li {
|
316 |
margin: 0px;
|
317 |
padding: 2px 5px;
|
318 |
cursor: pointer;
|
323 |
overflow: hidden;
|
324 |
}
|
325 |
|
326 |
+
/* changes for matches */
|
327 |
+
.ac_results li span{
|
328 |
+
float: right;
|
329 |
+
padding-right: 10px;
|
330 |
+
}
|
331 |
+
|
332 |
+
.ac_over {
|
333 |
background-color: Highlight;
|
334 |
color: HighlightText;
|
335 |
}
|
embedded/common/toolset-forms/external/autocompleter.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/external/autocompleter.php $
|
5 |
+
* $LastChangedDate: 2014-05-29 08:44:10 +0000 (Thu, 29 May 2014) $
|
6 |
+
* $LastChangedRevision: 922956 $
|
7 |
+
* $LastChangedBy: iworks $
|
8 |
+
*
|
9 |
+
*/
|
10 |
+
|
11 |
+
$path = dirname(__FILE__);
|
12 |
+
$file = '/wp-config.php';
|
13 |
+
while ( !is_file( $path.$file) ) {
|
14 |
+
$path = dirname($path);
|
15 |
+
}
|
16 |
+
require_once $path.$file;
|
17 |
+
function autocompleter()
|
18 |
+
{
|
19 |
+
$results = 1;
|
20 |
+
$wpdb =& $GLOBALS['wpdb'];
|
21 |
+
$search = @$wpdb->escape($_GET['q']);
|
22 |
+
if(strlen($search)){
|
23 |
+
switch($results){
|
24 |
+
case 1: //Tags and categories
|
25 |
+
$words = $wpdb->get_results("SELECT concat( name, '|', sum( count ) ) name, sum( count ) cnt FROM ".$wpdb->prefix."terms t, ".$wpdb->prefix."term_taxonomy tt WHERE t.term_id = tt.term_id AND name LIKE '$search%' GROUP BY t.term_id ORDER BY cnt DESC");
|
26 |
+
break;
|
27 |
+
case 2: //Only tags
|
28 |
+
$words = $wpdb->get_results("SELECT concat( name, '|', sum( count ) ) name, sum( count ) cnt FROM ".$wpdb->prefix."terms t, ".$wpdb->prefix."term_taxonomy tt WHERE t.term_id = tt.term_id AND tt.taxonomy='post_tag' AND name LIKE '$search%' GROUP BY t.term_id ORDER BY cnt DESC");
|
29 |
+
break;
|
30 |
+
case 3: //Only categories
|
31 |
+
$words = $wpdb->get_results("SELECT concat( name, '|', sum( count ) ) name, sum( count ) cnt FROM ".$wpdb->prefix."terms t, ".$wpdb->prefix."term_taxonomy tt WHERE t.term_id = tt.term_id AND tt.taxonomy='category' AND name LIKE '$search%' GROUP BY t.term_id ORDER BY cnt DESC");
|
32 |
+
break;
|
33 |
+
case 4: //Posts and pages titles
|
34 |
+
$words = $wpdb->get_results("SELECT concat( post_title, '|', 1 ) name, 1 cnt, ID FROM ".$wpdb->prefix."posts t WHERE post_status='publish' and (post_type='post' OR post_type='page') and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
|
35 |
+
break;
|
36 |
+
case 5: //Posts titles
|
37 |
+
$words = $wpdb->get_results("SELECT concat( post_title, '|', 1 ) name, 1 cnt, ID FROM ".$wpdb->prefix."posts t WHERE post_status='publish' and (post_type='post') and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
|
38 |
+
break;
|
39 |
+
case 6: //Pages titles
|
40 |
+
$words = $wpdb->get_results("SELECT concat( post_title, '|', 1 ) name, 1 cnt, ID FROM ".$wpdb->prefix."posts t WHERE post_status='publish' and (post_type='page') and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
|
41 |
+
break;
|
42 |
+
}
|
43 |
+
foreach ($words as $word){
|
44 |
+
if($results > 3)
|
45 |
+
echo $word->name."|".get_permalink($word->ID)."\n";
|
46 |
+
else
|
47 |
+
echo $word->name."\n";
|
48 |
+
}
|
49 |
+
}
|
50 |
+
}
|
51 |
+
if($_GET['q']){
|
52 |
+
autocompleter();
|
53 |
+
}
|
embedded/common/toolset-forms/js/colorpicker.js
CHANGED
@@ -5,7 +5,6 @@ var wptColorpicker = (function($) {
|
|
5 |
if ( 'function' == typeof ( $(event.target).data('_bindChange') ) ) {
|
6 |
$(event.target).data('_bindChange')();
|
7 |
}
|
8 |
-
|
9 |
}
|
10 |
});
|
11 |
$(document).click(function (e) {
|
5 |
if ( 'function' == typeof ( $(event.target).data('_bindChange') ) ) {
|
6 |
$(event.target).data('_bindChange')();
|
7 |
}
|
|
|
8 |
}
|
9 |
});
|
10 |
$(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:
|
5 |
-
* $LastChangedDate:
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
var wptCondTriggers = {}
|
11 |
-
,
|
12 |
-
,
|
13 |
-
,
|
14 |
-
,
|
15 |
|
16 |
-
var wptCond = (function
|
17 |
|
18 |
function init()
|
19 |
{
|
20 |
-
_.each(wptCondTriggers, function
|
21 |
-
_.each(triggers, function
|
22 |
var $trigger = _getTrigger(trigger, formID);
|
23 |
-
_bindChange(formID, $trigger, function
|
24 |
_check(formID, fields);
|
25 |
});
|
26 |
_check(formID, fields); // Check conditional on init
|
27 |
});
|
28 |
});
|
29 |
-
_.each(wptCondCustomTriggers, function
|
30 |
-
_.each(triggers, function
|
31 |
var $trigger = _getTrigger(trigger, formID);
|
32 |
-
_bindChange(formID, $trigger, function
|
33 |
_custom(formID, fields);
|
34 |
});
|
35 |
_custom(formID, fields); // Check conditional on init
|
@@ -37,242 +37,228 @@ var wptCond = (function ($) {
|
|
37 |
});
|
38 |
// Fire validation after init conditional
|
39 |
wptCallbacks.validationInit.fire();
|
40 |
-
|
41 |
-
|
42 |
-
//_init_custom();
|
43 |
}
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
$.fn.condSlideFadeDown = function
|
48 |
easing = easing || 'linear';
|
49 |
-
return this.each(function () {
|
50 |
-
$(this).
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
if ($.isFunction(callback)) {
|
56 |
-
callback.call(this);
|
57 |
-
}
|
58 |
-
});
|
59 |
-
});
|
60 |
};
|
61 |
-
|
62 |
-
$.fn.condSlideFadeUp = function
|
63 |
easing = easing || 'linear';
|
64 |
-
return this.each(function () {
|
65 |
-
$(this).
|
66 |
-
|
67 |
-
|
68 |
-
|
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="'
|
80 |
/**
|
81 |
* wp-admin
|
82 |
*/
|
83 |
-
if ($('body').hasClass('wp-admin')) {
|
84 |
-
trigger = trigger.replace(/wpcf\-/, 'wpcf[') + ']';
|
85 |
-
$trigger = $('[data-wpt-name="'
|
86 |
|
87 |
}
|
88 |
/**
|
89 |
* handle skype field
|
90 |
*/
|
91 |
-
if ($trigger.length < 1) {
|
92 |
-
$trigger = $('[data-wpt-name="'
|
93 |
}
|
94 |
/**
|
95 |
* handle date field
|
96 |
*/
|
97 |
-
if ($trigger.length < 1) {
|
98 |
-
$trigger = $('[data-wpt-name="'
|
99 |
}
|
100 |
-
|
101 |
* handle checkboxes and multiselect
|
102 |
*/
|
103 |
-
if ($trigger.length < 1) {
|
104 |
-
$trigger = $('[data-wpt-name="'
|
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 |
-
|
135 |
-
switch
|
136 |
case 'radio':
|
137 |
case 'radios':
|
138 |
radio = $('[name="' + $trigger.attr('name') + '"]:checked', formID);
|
139 |
-
|
140 |
-
|
141 |
-
if ('undefined' == typeof
|
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 |
-
|
152 |
-
|
153 |
-
|
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 |
-
|
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'))
|
182 |
-
} else if ($trigger_checked.length > 1) {
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
}
|
188 |
//#########################################################################################
|
189 |
break;
|
190 |
case 'file':
|
191 |
-
|
192 |
-
|
193 |
-
|
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 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
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 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
}
|
272 |
/**
|
273 |
* debug
|
274 |
*/
|
275 |
-
if (wptCondDebug) {
|
276 |
console.log('$obj', $obj);
|
277 |
}
|
278 |
}
|
@@ -288,7 +274,7 @@ var wptCond = (function ($) {
|
|
288 |
/**
|
289 |
* debug
|
290 |
*/
|
291 |
-
if (wptCondDebug) {
|
292 |
console.log('affected', affected);
|
293 |
console.log('$el', $el);
|
294 |
}
|
@@ -301,24 +287,24 @@ var wptCond = (function ($) {
|
|
301 |
var c = wptCondFields[formID][field];
|
302 |
var passedOne = false, passedAll = true, passed = false;
|
303 |
var $trigger;
|
304 |
-
_.each(c.conditions, function
|
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 |
-
|
317 |
-
|
318 |
-
|
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,92 +312,92 @@ var wptCond = (function ($) {
|
|
326 |
/**
|
327 |
* handle types
|
328 |
*/
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
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 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
if (!passed_single) {
|
416 |
passedAll = false;
|
417 |
} else {
|
@@ -428,14 +414,14 @@ var wptCond = (function ($) {
|
|
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 |
-
|
439 |
//if ( $trigger.length && next && $trigger.hasClass('js-wpt-date' ) ) {
|
440 |
// setTimeout(function() {
|
441 |
// _checkOneField( formID, field, false );
|
@@ -445,10 +431,10 @@ var wptCond = (function ($) {
|
|
445 |
|
446 |
function _check(formID, fields)
|
447 |
{
|
448 |
-
if (wptCondDebug) {
|
449 |
console.info('_check');
|
450 |
}
|
451 |
-
_.each(fields, function
|
452 |
_checkOneField(formID, field, true);
|
453 |
});
|
454 |
wptCallbacks.conditionalCheck.fire(formID);
|
@@ -466,340 +452,207 @@ var wptCond = (function ($) {
|
|
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
|
475 |
case 'checkbox':
|
476 |
$trigger.on('click', func);
|
477 |
break;
|
478 |
case 'radio':
|
479 |
case 'radios':
|
480 |
-
|
481 |
-
* when selecting again, do not forget about formID
|
482 |
-
*/
|
483 |
-
$('[name="' + $trigger.attr('name') + '"]', formID).on('click', func);
|
484 |
break;
|
485 |
case 'select':
|
486 |
$trigger.on('change', func);
|
487 |
break;
|
488 |
-
|
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 |
-
|
500 |
}
|
501 |
}
|
502 |
|
503 |
function _custom(formID, fields)
|
504 |
{
|
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 |
-
|
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 (false) {
|
529 |
-
if ($trigger.is('select') && !$trigger.attr('multiple')) {
|
530 |
-
$("#" + $trigger.attr('id') + " > option").each(function () {
|
531 |
-
//console.log(value + " " + this.text + ' ' + this.value + ' ' + $(this).data('typesValue'));
|
532 |
-
if ($(this).data('typesValue') && $(this).data('typesValue') == value || this.text==value || value==this.value)
|
533 |
-
value = this.text;
|
534 |
-
});
|
535 |
-
}
|
536 |
-
}
|
537 |
-
//#####################################################################################
|
538 |
-
|
539 |
-
if (typeof value != 'undefined') {
|
540 |
|
541 |
-
|
542 |
-
|
543 |
-
|
|
|
|
|
544 |
|
545 |
-
|
546 |
-
// then convert value to ARRAY(...)
|
547 |
|
|
|
548 |
|
549 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
550 |
|
551 |
-
|
552 |
-
|
553 |
-
if (wptCondDebug) {
|
554 |
-
console.log();
|
555 |
-
}
|
556 |
-
|
557 |
-
if (value instanceof Array) {
|
558 |
-
for (var i = 0; i < value.length; i++) {
|
559 |
-
var val = value[i];
|
560 |
-
if (val === '' || isNaN(val)) {
|
561 |
-
val = '\'' + val + '\'';
|
562 |
-
}
|
563 |
-
|
564 |
-
if (val_array == '') {
|
565 |
-
val_array = val;
|
566 |
-
} else {
|
567 |
-
val_array += ',' + val;
|
568 |
-
}
|
569 |
-
}
|
570 |
-
} else {
|
571 |
-
if (isNaN(value)) {
|
572 |
-
value = '\'' + value + '\'';
|
573 |
-
}
|
574 |
-
val_array = value;
|
575 |
-
}
|
576 |
-
|
577 |
-
value = 'ARRAY(' + val_array + ')';
|
578 |
-
|
579 |
-
}
|
580 |
-
else
|
581 |
{
|
582 |
-
if (value === '' || isNaN(value)) {
|
583 |
-
value = '\'' + value + '\'';
|
584 |
-
}
|
585 |
-
}
|
586 |
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
}
|
614 |
-
|
615 |
-
//https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196173370/comments#309696464
|
616 |
-
//Added a new check using text element on select
|
617 |
-
// Get the values and update the expression.
|
618 |
-
_.each(c.triggers, function (t) {
|
619 |
-
var $trigger = _getTrigger(t, formID),
|
620 |
-
value = _getTriggerValue($trigger, formID),
|
621 |
-
is_array = $trigger.length > 1 ? true : false;
|
622 |
-
if (wptCondDebug) {
|
623 |
-
console.log("The value is ", value, " for element: ", t, $trigger);
|
624 |
-
}
|
625 |
-
|
626 |
-
//Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193595717/comments
|
627 |
-
//group issue on select
|
628 |
-
if ($trigger.is('select') && !$trigger.attr('multiple')) {
|
629 |
-
$("#" + $trigger.attr('id') + " > option").each(function () {
|
630 |
-
//console.log(value + " " + this.text + ' ' + this.value + ' ' + $(this).data('typesValue'));
|
631 |
-
if ($(this).data('typesValue') && $(this).data('typesValue') == value || this.text==value || value==this.value)
|
632 |
-
value = this.text;
|
633 |
-
});
|
634 |
-
}
|
635 |
-
//#####################################################################################
|
636 |
-
|
637 |
-
if (typeof value != 'undefined') {
|
638 |
-
|
639 |
-
// make it a string by wrapping in quotes if
|
640 |
-
// 1. the value is an empty string
|
641 |
-
// 2. or it's not a number
|
642 |
-
|
643 |
-
// if the trigger is an array, eg checkboxes
|
644 |
-
// then convert value to ARRAY(...)
|
645 |
-
|
646 |
-
|
647 |
-
if (is_array === true) {
|
648 |
-
|
649 |
-
var val_array = '';
|
650 |
-
|
651 |
-
if (wptCondDebug) {
|
652 |
-
console.log();
|
653 |
-
}
|
654 |
-
|
655 |
-
if (value instanceof Array) {
|
656 |
-
for (var i = 0; i < value.length; i++) {
|
657 |
-
var val = value[i];
|
658 |
-
if (val === '' || isNaN(val)) {
|
659 |
-
val = '\'' + val + '\'';
|
660 |
-
}
|
661 |
-
|
662 |
-
if (val_array == '') {
|
663 |
-
val_array = val;
|
664 |
-
} else {
|
665 |
-
val_array += ',' + val;
|
666 |
-
}
|
667 |
-
}
|
668 |
-
} else {
|
669 |
-
if (isNaN(value)) {
|
670 |
-
value = '\'' + value + '\'';
|
671 |
-
}
|
672 |
-
val_array = value;
|
673 |
-
}
|
674 |
-
|
675 |
-
value = 'ARRAY(' + val_array + ')';
|
676 |
-
|
677 |
-
}
|
678 |
-
else
|
679 |
-
{
|
680 |
-
if (value === '' || isNaN(value)) {
|
681 |
-
value = '\'' + value + '\'';
|
682 |
-
}
|
683 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
684 |
|
685 |
-
|
686 |
-
var replace = new RegExp('\\$\\(' + t + '\\)', 'g');
|
687 |
|
688 |
-
|
689 |
|
690 |
-
|
691 |
-
var replace_old = new RegExp('\\$' + t, 'g');
|
692 |
|
693 |
-
|
694 |
|
695 |
-
|
696 |
|
697 |
});
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
|
|
|
|
|
|
|
|
710 |
});
|
711 |
-
|
712 |
}
|
713 |
|
714 |
function _showHide(show, $el)
|
715 |
{
|
716 |
-
|
717 |
-
|
718 |
-
//TODO: check this cause side effect
|
719 |
-
/*if (jQuery('.wpt-form-error').length) {
|
720 |
-
jQuery('.wpt-form-error').hide();
|
721 |
-
}*/
|
722 |
-
|
723 |
-
if (wptCondDebug) {
|
724 |
console.info('_showHide');
|
725 |
console.log(show, $el);
|
726 |
}
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
default:
|
792 |
-
$el.hide();
|
793 |
-
break;
|
794 |
-
}
|
795 |
-
$($el).find('input, textarea, button, select').attr('disabled','disabled');
|
796 |
-
}
|
797 |
}
|
798 |
|
799 |
function ajaxCheck(formID, field, conditions)
|
800 |
{
|
801 |
var values = {};
|
802 |
-
_.each(conditions.conditions, function
|
803 |
var $trigger = _getTrigger(c.id, formID);
|
804 |
values[c.id] = _getTriggerValue($trigger);
|
805 |
});
|
@@ -808,67 +661,63 @@ var wptCond = (function ($) {
|
|
808 |
'conditions': conditions,
|
809 |
'values': values
|
810 |
};
|
811 |
-
$.post(wptConditional.ajaxurl, data, function
|
812 |
_showHide(passed, _getAffected(field, formID));
|
813 |
wptCallbacks.conditionalCheck.fire(formID);
|
814 |
-
}).fail(function
|
815 |
//alert(data);
|
816 |
});
|
817 |
}
|
818 |
|
819 |
function addConditionals(data)
|
820 |
{
|
821 |
-
_.each(data, function
|
822 |
if (typeof c.triggers != 'undefined'
|
823 |
&& typeof wptCondTriggers[formID] != 'undefined') {
|
824 |
-
_.each(c.triggers, function
|
825 |
wptCondTriggers[formID][trigger] = fields;
|
826 |
var $trigger = _getTrigger(trigger, formID);
|
827 |
-
_bindChange(formID, $trigger, function
|
828 |
_check(formID, fields);
|
829 |
});
|
830 |
});
|
831 |
}
|
832 |
if (typeof c.fields != 'undefined'
|
833 |
&& typeof wptCondFields[formID] != 'undefined') {
|
834 |
-
_.each(c.fields, function
|
835 |
wptCondFields[formID][field] = conditionals;
|
836 |
});
|
837 |
}
|
838 |
if (typeof c.custom_triggers != 'undefined'
|
839 |
&& typeof wptCondCustomTriggers[formID] != 'undefined') {
|
840 |
-
_.each(c.custom_triggers, function
|
841 |
wptCondCustomTriggers[formID][trigger] = fields;
|
842 |
var $trigger = _getTrigger(trigger, formID);
|
843 |
-
_bindChange(formID, $trigger, function
|
844 |
_custom(formID, fields);
|
845 |
});
|
846 |
});
|
847 |
}
|
848 |
if (typeof c.custom_fields != 'undefined'
|
849 |
&& typeof wptCondCustomFields[formID] != 'undefined') {
|
850 |
-
_.each(c.custom_fields, function
|
851 |
wptCondCustomFields[formID][field] = conditionals;
|
852 |
});
|
853 |
}
|
854 |
});
|
855 |
}
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
}
|
869 |
-
}
|
870 |
-
})
|
871 |
-
}
|
872 |
|
873 |
return {
|
874 |
init: init,
|
1 |
/**
|
2 |
* @see WPToolset_Forms_Conditional (classes/conditional.php)
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/js/conditional.js $
|
5 |
+
* $LastChangedDate: 2014-08-27 17:35:29 +0200 (Wed, 27 Aug 2014) $
|
6 |
+
* $LastChangedRevision: 26501 $
|
7 |
+
* $LastChangedBy: riccardo $ 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 |
+
_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 |
break;
|
136 |
+
case 'select':
|
137 |
+
option = $('[name="' + $trigger.attr('name') + '"] option:selected', formID);
|
138 |
+
// If no option was selected, the value should be empty
|
139 |
+
val = '';
|
140 |
+
if ( wptCondDebug ) {
|
141 |
+
console.log( 'option', option );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
+
if ( option.length == 1 ) {
|
144 |
+
if ( 'undefined' == typeof( option.data('types-value' ) ) ) {
|
145 |
+
val = option.val();
|
146 |
+
} else {
|
147 |
+
val = option.data('types-value');
|
148 |
+
}
|
149 |
+
} else if ( option.length > 1 ) {
|
150 |
+
val = [];
|
151 |
+
option.each(function() {
|
152 |
+
if ( 'undefined' == typeof( $(this).data('types-value' ) ) ) {
|
153 |
+
val.push($(this).val());
|
154 |
+
} else {
|
155 |
+
val.push($(this).data('types-value'));
|
156 |
+
}
|
157 |
+
});
|
158 |
+
}
|
159 |
break;
|
160 |
case 'checkbox':
|
161 |
var $trigger_checked = $trigger.filter(':checked');
|
162 |
+
// If no checkbox was checked, the value should be empty
|
163 |
val = '';
|
164 |
//added data-value checking in order to fix
|
165 |
//https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188528502/comments
|
166 |
+
if ( $trigger_checked.length == 1 ) {
|
167 |
+
val = ($trigger_checked.attr('data-value'))?$trigger_checked.attr('data-value'):$trigger_checked.val();
|
168 |
+
} else if ( $trigger_checked.length > 1 ) {
|
169 |
+
val = [];
|
170 |
+
$trigger_checked.each(function() {
|
171 |
+
val.push(($(this).attr('data-value'))?$(this).attr('data-value'):$(this).val());
|
172 |
+
});
|
173 |
}
|
174 |
//#########################################################################################
|
175 |
break;
|
176 |
case 'file':
|
177 |
+
var $trigger_checked = $trigger.filter(':not([disabled])');
|
178 |
+
val = $trigger_checked.val();
|
179 |
+
break;
|
180 |
default:
|
181 |
val = $trigger.val();
|
182 |
}
|
183 |
+
if ( wptCondDebug ) {
|
184 |
+
console.log( 'val', val );
|
185 |
}
|
186 |
return val;
|
187 |
}
|
188 |
|
189 |
function _getAffected(affected, formID)
|
190 |
{
|
191 |
+
if ( wptCondDebug ) {
|
192 |
console.info('_getAffected');
|
193 |
}
|
194 |
var $el = $('[data-wpt-id="' + affected + '"]', formID);
|
195 |
+
if ( $('body').hasClass('wp-admin') ) {
|
196 |
$el = $el.closest('.wpt-field');
|
197 |
if ($el.length < 1) {
|
198 |
$el = $('#' + affected, formID).closest('.form-item');
|
199 |
}
|
200 |
} else {
|
201 |
+
if ( $el.length < 1 ) {
|
202 |
+
/**
|
203 |
+
* get pure field name, without form prefix
|
204 |
+
*/
|
205 |
+
re = new RegExp(formID+'_');
|
206 |
+
name = '#'+affected;
|
207 |
+
name = name.replace( re, '' );
|
208 |
+
/**
|
209 |
+
* try get element
|
210 |
+
*/
|
211 |
+
$obj = $('[data-wpt-id="' + affected + '_file"]', formID);
|
212 |
+
/**
|
213 |
+
* handle by wpt field name
|
214 |
+
*/
|
215 |
+
if ( $obj.length < 1 ) {
|
216 |
+
$obj = $('[data-wpt-name="'+ name + '"]', formID);
|
217 |
+
}
|
218 |
+
/**
|
219 |
+
* handle date field
|
220 |
+
*/
|
221 |
+
if ( $obj.length < 1 ) {
|
222 |
+
$obj = $('[data-wpt-name="'+ name + '[datepicker]"]', formID);
|
223 |
+
}
|
224 |
+
/**
|
225 |
+
* handle skype field
|
226 |
+
*/
|
227 |
+
if ( $obj.length < 1 ) {
|
228 |
+
$obj = $('[data-wpt-name="'+ name + '[skypename]"]', formID);
|
229 |
+
}
|
230 |
+
/**
|
231 |
+
* handle checkboxes field
|
232 |
+
*/
|
233 |
+
if ( $obj.length < 1 ) {
|
234 |
+
$obj = $('[data-wpt-name="'+ name + '[]"]', formID);
|
235 |
+
}
|
236 |
+
/**
|
237 |
+
* catch by id
|
238 |
+
*/
|
239 |
+
if ($obj.length < 1) {
|
240 |
+
$obj = $('#' + affected, formID);
|
241 |
+
}
|
242 |
+
|
243 |
+
} else {
|
244 |
+
$obj = $el;
|
245 |
+
}
|
246 |
/**
|
247 |
* finally catch parent: we should have catched the $obj
|
248 |
*/
|
249 |
if ($obj.length > 0) {
|
250 |
$el = $obj.closest('.js-wpt-conditional-field');
|
251 |
+
if ( $el.length < 1 ) {
|
252 |
+
$el = $obj.closest('.cred-field');// This for backwards compatibility
|
253 |
+
if ( $el.length < 1 ) {
|
254 |
+
$el = $obj.closest('.js-wpt-field-items');
|
255 |
+
}
|
256 |
+
}
|
257 |
}
|
258 |
/**
|
259 |
* debug
|
260 |
*/
|
261 |
+
if ( wptCondDebug ) {
|
262 |
console.log('$obj', $obj);
|
263 |
}
|
264 |
}
|
274 |
/**
|
275 |
* debug
|
276 |
*/
|
277 |
+
if ( wptCondDebug ) {
|
278 |
console.log('affected', affected);
|
279 |
console.log('$el', $el);
|
280 |
}
|
287 |
var c = wptCondFields[formID][field];
|
288 |
var passedOne = false, passedAll = true, passed = false;
|
289 |
var $trigger;
|
290 |
+
_.each(c.conditions, function(data) {
|
291 |
if (__ignore) {
|
292 |
return;
|
293 |
}
|
294 |
$trigger = _getTrigger(data.id, formID);
|
295 |
var val = _getTriggerValue($trigger, formID);
|
296 |
+
if ( wptCondDebug ) {
|
297 |
+
console.log( 'formID', formID );
|
298 |
+
console.log( '$trigger', $trigger );
|
299 |
console.log('val', 1, val);
|
300 |
}
|
301 |
|
302 |
+
var field_type = $trigger.data('wpt-type');
|
303 |
+
if ( data.type == 'date' ) {
|
304 |
+
field_type = 'date';
|
305 |
+
}
|
306 |
val = apply_filters('conditional_value_' + field_type, val, $trigger);
|
307 |
+
if ( wptCondDebug ) {
|
308 |
console.log('val', 2, val);
|
309 |
}
|
310 |
do_action('conditional_check_' + data.type, formID, c, field);
|
312 |
/**
|
313 |
* handle types
|
314 |
*/
|
315 |
+
// Not needed anymore
|
316 |
+
// NEVER Date.parse timestamps coming from adodb_xxx functions
|
317 |
+
/*
|
318 |
+
switch(data.type) {
|
319 |
+
case 'date'://alert(_val);alert(val);
|
320 |
+
if ( _val ) {//alert('this is _val ' + _val);
|
321 |
+
// _val = Date.parse(_val);//alert('this is _val after parse ' + _val);
|
322 |
+
}//alert('val is ' + val);
|
323 |
+
//val = Date.parse(val);//alert('parsed val is ' + val);
|
324 |
+
break;
|
325 |
+
}
|
326 |
+
*/
|
327 |
+
if ('__ignore' == val ) {
|
328 |
__ignore = true;
|
329 |
return;
|
330 |
}
|
331 |
/**
|
332 |
* debug
|
333 |
*/
|
334 |
+
if ( wptCondDebug ) {
|
335 |
console.log('val', 3, val);
|
336 |
console.log('_val', _val);
|
337 |
}
|
338 |
/**
|
339 |
* for __ignore_negative set some dummy operator
|
340 |
*/
|
341 |
+
if ( 0 && '__ignore_negative' == val ) {
|
342 |
operator = '__ignore';
|
343 |
}
|
344 |
+
|
345 |
+
if ( $.isArray( val ) ) {
|
346 |
+
// If the selected value is an array, we just can check == and != operators, which means in_array and not_in_array
|
347 |
+
// We return false in any other scenario
|
348 |
+
switch (operator) {
|
349 |
+
case '===':
|
350 |
+
case '==':
|
351 |
+
case '=':
|
352 |
+
passed_single = jQuery.inArray( _val, val ) !== -1;
|
353 |
+
break;
|
354 |
+
case '!==':
|
355 |
+
case '!=':
|
356 |
+
case '<>':
|
357 |
+
passed_single = jQuery.inArray( _val, val ) == -1;
|
358 |
+
break;
|
359 |
+
default:
|
360 |
+
passed_single = false;
|
361 |
+
break;
|
362 |
+
}
|
363 |
+
} else {
|
364 |
+
// Note: we can use parseInt here although we are dealing with extended timestamps coming from adodb_xxx functions
|
365 |
+
// Because javascript parseInt can deal with integers up to ±1e+21
|
366 |
+
switch (operator) {
|
367 |
+
case '===':
|
368 |
+
case '==':
|
369 |
+
case '=':
|
370 |
+
if ( $.isArray( val ) ) {
|
371 |
+
|
372 |
+
} else {
|
373 |
+
passed_single = val == _val;
|
374 |
+
}
|
375 |
+
break;
|
376 |
+
case '!==':
|
377 |
+
case '!=':
|
378 |
+
case '<>':
|
379 |
+
passed_single = val != _val;
|
380 |
+
break;
|
381 |
+
case '>':
|
382 |
+
passed_single = parseInt(val) > parseInt(_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 'between':
|
394 |
+
passed_single = parseInt(val) > parseInt(_val) && parseInt(val) < parseInt(data.args[1]);
|
395 |
+
break;
|
396 |
+
default:
|
397 |
+
passed_single = false;
|
398 |
+
break;
|
399 |
+
}
|
400 |
+
}
|
401 |
if (!passed_single) {
|
402 |
passedAll = false;
|
403 |
} else {
|
414 |
/**
|
415 |
* debug
|
416 |
*/
|
417 |
+
if ( wptCondDebug ) {
|
418 |
console.log('passedAll', passedAll, 'passedOne', passedOne, 'passed', passed, '__ignore', __ignore);
|
419 |
console.log('field', field);
|
420 |
}
|
421 |
if (!__ignore) {
|
422 |
_showHide(passed, _getAffected(field, formID));
|
423 |
}
|
424 |
+
// No need to set a timeout anymore
|
425 |
//if ( $trigger.length && next && $trigger.hasClass('js-wpt-date' ) ) {
|
426 |
// setTimeout(function() {
|
427 |
// _checkOneField( formID, field, false );
|
431 |
|
432 |
function _check(formID, fields)
|
433 |
{
|
434 |
+
if ( wptCondDebug ) {
|
435 |
console.info('_check');
|
436 |
}
|
437 |
+
_.each(fields, function(field) {
|
438 |
_checkOneField(formID, field, true);
|
439 |
});
|
440 |
wptCallbacks.conditionalCheck.fire(formID);
|
452 |
/**
|
453 |
* debug
|
454 |
*/
|
455 |
+
if ( wptCondDebug ) {
|
456 |
console.info('_bindChange');
|
457 |
console.log('$trigger', $trigger);
|
458 |
console.log('wpt-type', $trigger.data('wpt-type'));
|
459 |
}
|
460 |
+
switch( $trigger.data('wpt-type') ) {
|
461 |
case 'checkbox':
|
462 |
$trigger.on('click', func);
|
463 |
break;
|
464 |
case 'radio':
|
465 |
case 'radios':
|
466 |
+
$('[name="' + $trigger.attr('name') + '"]').on('click', func);
|
|
|
|
|
|
|
467 |
break;
|
468 |
case 'select':
|
469 |
$trigger.on('change', func);
|
470 |
break;
|
471 |
+
case 'date':
|
|
|
|
|
|
|
472 |
$trigger.on('change', func);
|
473 |
break;
|
474 |
+
case 'file':
|
475 |
+
$trigger.on('change', func);
|
476 |
+
break;
|
477 |
default:
|
478 |
+
if ( $trigger.hasClass('js-wpt-colorpicker') ) {
|
479 |
$trigger.data('_bindChange', func)
|
480 |
}
|
481 |
$($trigger).on('blur', func);
|
482 |
+
break;
|
483 |
}
|
484 |
}
|
485 |
|
486 |
function _custom(formID, fields)
|
487 |
{
|
488 |
+
_.each(fields, function(field) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
489 |
var c = wptCondCustomFields[formID][field];
|
490 |
+
var expression = c.custom;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
|
492 |
+
// Get the values and update the expression.
|
493 |
+
_.each(c.triggers, function(t) {
|
494 |
+
var $trigger = _getTrigger(t),
|
495 |
+
value = _getTriggerValue($trigger),
|
496 |
+
is_array = $trigger.length > 1 ? true : false;
|
497 |
|
498 |
+
console.log(":::: AND THE VALUE??????", value, " for t: ", t, $trigger );
|
|
|
499 |
|
500 |
+
if (typeof value != 'undefined') {
|
501 |
|
502 |
+
// make it a string by wrapping in quotes if
|
503 |
+
// 1. the value is an empty string
|
504 |
+
// 2. or it's not a number
|
505 |
+
|
506 |
+
// if the trigger is an array, eg checkboxes
|
507 |
+
// then convert value to ARRAY(...)
|
508 |
+
|
509 |
|
510 |
+
if( is_array === true )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
511 |
{
|
|
|
|
|
|
|
|
|
512 |
|
513 |
+
var val_array = '';
|
514 |
+
|
515 |
+
console.log();
|
516 |
+
|
517 |
+
if (value instanceof Array) {
|
518 |
+
for(var i = 0; i < value.length; i++) {
|
519 |
+
var val = value[i];
|
520 |
+
if (val === '' || isNaN(val)) {
|
521 |
+
val = '\'' + val + '\'';
|
522 |
+
}
|
523 |
+
|
524 |
+
if (val_array == '') {
|
525 |
+
val_array = val;
|
526 |
+
} else {
|
527 |
+
val_array += ',' + val;
|
528 |
+
}
|
529 |
+
}
|
530 |
+
} else {
|
531 |
+
if (isNaN(value)) {
|
532 |
+
value = '\'' + value + '\'';
|
533 |
+
}
|
534 |
+
val_array = value;
|
535 |
+
}
|
536 |
+
|
537 |
+
value = 'ARRAY(' + val_array + ')';
|
538 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
}
|
540 |
+
else
|
541 |
+
{
|
542 |
+
if (value === '' || isNaN(value)) {
|
543 |
+
value = '\'' + value + '\'';
|
544 |
+
}
|
545 |
+
}
|
546 |
|
547 |
+
// First replace the $(field_name) format
|
548 |
+
var replace = new RegExp( '\\$\\(' + t + '\\)', 'g' );
|
549 |
|
550 |
+
expression = expression.replace( replace, value );
|
551 |
|
552 |
+
// next replace the $field_name format
|
553 |
+
var replace_old = new RegExp( '\\$' + t, 'g' );
|
554 |
|
555 |
+
expression = expression.replace( replace_old, value );
|
556 |
|
557 |
+
}
|
558 |
|
559 |
});
|
560 |
+
|
561 |
+
var result = false;
|
562 |
+
|
563 |
+
try {
|
564 |
+
var parser = new ToolsetParser.Expression(expression);
|
565 |
+
parser.parse();
|
566 |
+
result = parser.eval();
|
567 |
+
}
|
568 |
+
catch(e) {
|
569 |
+
console.info( "Error in Tokenizer", e, expression, " there may be an error in your expression syntax" );
|
570 |
+
}
|
571 |
+
|
572 |
+
|
573 |
+
|
574 |
+
_showHide(result, _getAffected(field, formID));
|
575 |
+
|
576 |
});
|
577 |
+
wptCallbacks.conditionalCheck.fire(formID);
|
578 |
}
|
579 |
|
580 |
function _showHide(show, $el)
|
581 |
{
|
582 |
+
if ( wptCondDebug ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
583 |
console.info('_showHide');
|
584 |
console.log(show, $el);
|
585 |
}
|
586 |
+
|
587 |
+
var effectmode = '',
|
588 |
+
dur = 'slow',
|
589 |
+
delay = 50;
|
590 |
+
|
591 |
+
if ( $el.attr( 'data-effectmode' ) ) {
|
592 |
+
effectmode = $el.data( 'effectmode' );
|
593 |
+
} else {
|
594 |
+
effectmode = 'slide';
|
595 |
+
}
|
596 |
+
|
597 |
+
if ( show ) {
|
598 |
+
$el.addClass( 'wpt-conditional-visible' ).removeClass( 'wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore' );
|
599 |
+
switch( effectmode ) {
|
600 |
+
case 'fade-slide':
|
601 |
+
setTimeout( function() {
|
602 |
+
$el.stop( true ).condSlideFadeDown( dur, 'linear' );
|
603 |
+
}, delay );
|
604 |
+
break;
|
605 |
+
case 'slide':
|
606 |
+
setTimeout( function() {
|
607 |
+
$el.stop( true ).slideDown( dur, 'linear', function() {
|
608 |
+
$el.css('height', 'auto');
|
609 |
+
});
|
610 |
+
}, delay );
|
611 |
+
break;
|
612 |
+
case 'fade':
|
613 |
+
setTimeout( function() {
|
614 |
+
$el.stop( true ).fadeIn( dur );
|
615 |
+
}, delay );
|
616 |
+
break;
|
617 |
+
case 'none':
|
618 |
+
break;
|
619 |
+
default:
|
620 |
+
$el.show();
|
621 |
+
break;
|
622 |
+
}
|
623 |
+
} else {
|
624 |
+
$el.addClass( 'wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore' ).removeClass( 'wpt-conditional-visible' );
|
625 |
+
switch( effectmode ) {
|
626 |
+
case 'fade-slide':
|
627 |
+
setTimeout( function() {
|
628 |
+
$el.stop( true ).condSlideFadeUp( dur, 'linear' );
|
629 |
+
}, delay );
|
630 |
+
break;
|
631 |
+
case 'slide':
|
632 |
+
setTimeout( function() {
|
633 |
+
$el.stop( true ).slideUp( dur, 'linear', function() {
|
634 |
+
$el.css('height', 'auto');
|
635 |
+
});
|
636 |
+
}, delay );
|
637 |
+
break;
|
638 |
+
case 'fade':
|
639 |
+
setTimeout( function() {
|
640 |
+
$el.stop( true ).fadeOut( dur );
|
641 |
+
}, delay );
|
642 |
+
break;
|
643 |
+
case 'none':
|
644 |
+
break;
|
645 |
+
default:
|
646 |
+
$el.hide();
|
647 |
+
break;
|
648 |
+
}
|
649 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
650 |
}
|
651 |
|
652 |
function ajaxCheck(formID, field, conditions)
|
653 |
{
|
654 |
var values = {};
|
655 |
+
_.each(conditions.conditions, function(c) {
|
656 |
var $trigger = _getTrigger(c.id, formID);
|
657 |
values[c.id] = _getTriggerValue($trigger);
|
658 |
});
|
661 |
'conditions': conditions,
|
662 |
'values': values
|
663 |
};
|
664 |
+
$.post(wptConditional.ajaxurl, data, function(passed) {
|
665 |
_showHide(passed, _getAffected(field, formID));
|
666 |
wptCallbacks.conditionalCheck.fire(formID);
|
667 |
+
}).fail(function(data) {
|
668 |
//alert(data);
|
669 |
});
|
670 |
}
|
671 |
|
672 |
function addConditionals(data)
|
673 |
{
|
674 |
+
_.each(data, function(c, formID) {
|
675 |
if (typeof c.triggers != 'undefined'
|
676 |
&& typeof wptCondTriggers[formID] != 'undefined') {
|
677 |
+
_.each(c.triggers, function(fields, trigger) {
|
678 |
wptCondTriggers[formID][trigger] = fields;
|
679 |
var $trigger = _getTrigger(trigger, formID);
|
680 |
+
_bindChange(formID, $trigger, function() {
|
681 |
_check(formID, fields);
|
682 |
});
|
683 |
});
|
684 |
}
|
685 |
if (typeof c.fields != 'undefined'
|
686 |
&& typeof wptCondFields[formID] != 'undefined') {
|
687 |
+
_.each(c.fields, function(conditionals, field) {
|
688 |
wptCondFields[formID][field] = conditionals;
|
689 |
});
|
690 |
}
|
691 |
if (typeof c.custom_triggers != 'undefined'
|
692 |
&& typeof wptCondCustomTriggers[formID] != 'undefined') {
|
693 |
+
_.each(c.custom_triggers, function(fields, trigger) {
|
694 |
wptCondCustomTriggers[formID][trigger] = fields;
|
695 |
var $trigger = _getTrigger(trigger, formID);
|
696 |
+
_bindChange(formID, $trigger, function() {
|
697 |
_custom(formID, fields);
|
698 |
});
|
699 |
});
|
700 |
}
|
701 |
if (typeof c.custom_fields != 'undefined'
|
702 |
&& typeof wptCondCustomFields[formID] != 'undefined') {
|
703 |
+
_.each(c.custom_fields, function(conditionals, field) {
|
704 |
wptCondCustomFields[formID][field] = conditionals;
|
705 |
});
|
706 |
}
|
707 |
});
|
708 |
}
|
709 |
+
|
710 |
+
function _init_custom() {
|
711 |
+
$('.js-wpt-field-items').each( function () {
|
712 |
+
var init_custom = $(this).data('initial-conditional');
|
713 |
+
if (init_custom) {
|
714 |
+
var field = $(this).closest('.cred-field');
|
715 |
+
if (field.length) {
|
716 |
+
_showHide(false, field);
|
717 |
+
}
|
718 |
+
}
|
719 |
+
})
|
720 |
+
}
|
|
|
|
|
|
|
|
|
721 |
|
722 |
return {
|
723 |
init: init,
|
embedded/common/toolset-forms/js/date.js
CHANGED
@@ -1,115 +1,68 @@
|
|
1 |
-
|
|
|
2 |
var _tempConditions, _tempField;
|
3 |
function init(parent) {
|
4 |
if ($.isFunction($.fn.datepicker)) {
|
5 |
-
$('input.js-wpt-date', $(parent)).each(function
|
6 |
if (!$(this).is(':disabled') && !$(this).hasClass('hasDatepicker')) {
|
7 |
a = wptDate.add($(this));
|
8 |
//a.next().after('<span style="margin-left:10px"><i>' + wptDateData.dateFormatNote + '</i></span>').data( 'dateFormatNote', true );
|
9 |
}
|
10 |
});
|
11 |
}
|
12 |
-
|
13 |
-
$(document).on('click', '.js-wpt-date-clear', function () {
|
14 |
-
var thiz = $(this), thiz_close, el, el_aux, el_select;
|
15 |
-
if (thiz.closest('.js-wpt-field-item').length > 0) {
|
16 |
-
thiz_close = thiz.closest('.js-wpt-field-item');
|
17 |
-
el_aux = thiz_close.find('.js-wpt-date-auxiliar');
|
18 |
-
el = thiz_close.find('.js-wpt-date');
|
19 |
-
el_select = thiz_close.find('select');
|
20 |
-
} else if (thiz.closest('.wpt-repctl').length > 0) {
|
21 |
-
thiz_close = thiz.closest('.wpt-repctl');
|
22 |
-
el_aux = thiz_close.find('.js-wpt-date-auxiliar');
|
23 |
-
el = thiz_close.find('.js-wpt-date');
|
24 |
-
el_select = thiz_close.find('select');
|
25 |
-
} else if (thiz.closest('.js-wpt-field-items').length > 0) {
|
26 |
-
thiz_close = thiz.closest('.js-wpt-field-items');
|
27 |
-
el_aux = thiz_close.find('.js-wpt-date-auxiliar');
|
28 |
-
el = thiz_close.find('.js-wpt-date');
|
29 |
-
el_select = thiz_close.find('select');
|
30 |
-
} else {
|
31 |
-
// This should be an empty object, but as we use the variable later we need to set it
|
32 |
-
el_aux = thiz.closest('.js-wpt-field-items');
|
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 |
|
45 |
function add(el)
|
46 |
{
|
47 |
// Before anything, return if this is readonly
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
onSelect: function
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
//el.trigger('wptDateSelect');
|
97 |
-
},
|
98 |
-
showOn: "both",
|
99 |
-
buttonImage: wptDateData.buttonImage,
|
100 |
-
buttonImageOnly: true,
|
101 |
-
buttonText: wptDateData.buttonText,
|
102 |
-
dateFormat: 'ddmmyy',
|
103 |
-
//dateFormat: wptDateData.dateFormat,
|
104 |
-
//altFormat: wptDateData.dateFormat,
|
105 |
-
changeMonth: true,
|
106 |
-
changeYear: true,
|
107 |
-
yearRange: wptDateData.yearMin + ':' + wptDateData.yearMax,
|
108 |
-
beforeShow: function(input) {
|
109 |
-
$(input).css({
|
110 |
-
zIndex: 159999 // media library has z-index 160000
|
111 |
-
})
|
112 |
-
}
|
113 |
});
|
114 |
}
|
115 |
|
@@ -123,10 +76,10 @@ var wptDate = (function ($) {
|
|
123 |
wptCond.ajaxCheck(formID, _tempField, _tempConditions);
|
124 |
}
|
125 |
function ignoreConditional(val) {
|
126 |
-
if ('' == val) {
|
127 |
return '__ignore_negative';
|
128 |
}
|
129 |
-
|
130 |
//return Date.parse(val);
|
131 |
}
|
132 |
function bindConditionalChange($trigger, func, formID) {
|
@@ -135,9 +88,8 @@ var wptDate = (function ($) {
|
|
135 |
//$trigger.on('keyup', lazy);
|
136 |
return false;
|
137 |
}
|
138 |
-
function triggerAjax(func)
|
139 |
-
if ($(this).val().length >= wptDateData.dateFormatPhp.length)
|
140 |
-
func();
|
141 |
}
|
142 |
return {
|
143 |
init: init,
|
@@ -150,23 +102,23 @@ var wptDate = (function ($) {
|
|
150 |
};
|
151 |
})(jQuery);
|
152 |
|
153 |
-
jQuery(document).ready(function
|
154 |
wptDate.init('body');
|
155 |
//fixing unknown Srdjan error
|
156 |
jQuery('.ui-datepicker-inline').hide();
|
157 |
});
|
158 |
|
159 |
-
if ('undefined' != typeof
|
160 |
-
wptCallbacks.reset.add(function
|
161 |
wptDate.init(parent);
|
162 |
});
|
163 |
wptCallbacks.addRepetitive.add(wptDate.init);
|
164 |
}
|
165 |
|
166 |
//add_action('conditional_check_date', wptDate.ajaxConditional, 10, 3);
|
167 |
-
if ('function' == typeof
|
168 |
add_filter('conditional_value_date', wptDate.ignoreConditional, 10, 1);
|
169 |
}
|
170 |
-
if ('function' == typeof
|
171 |
add_action('conditional_trigger_bind_date', wptDate.bindConditionalChange, 10, 3);
|
172 |
}
|
1 |
+
|
2 |
+
var wptDate = (function($) {
|
3 |
var _tempConditions, _tempField;
|
4 |
function init(parent) {
|
5 |
if ($.isFunction($.fn.datepicker)) {
|
6 |
+
$('input.js-wpt-date', $(parent)).each(function(index) {
|
7 |
if (!$(this).is(':disabled') && !$(this).hasClass('hasDatepicker')) {
|
8 |
a = wptDate.add($(this));
|
9 |
//a.next().after('<span style="margin-left:10px"><i>' + wptDateData.dateFormatNote + '</i></span>').data( 'dateFormatNote', true );
|
10 |
}
|
11 |
});
|
12 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
}
|
14 |
|
15 |
function add(el)
|
16 |
{
|
17 |
// Before anything, return if this is readonly
|
18 |
+
if ( el.hasClass('js-wpv-date-readonly') ) {
|
19 |
+
if ( !el.hasClass('js-wpv-date-readonly-added') ) {
|
20 |
+
el.addClass('js-wpv-date-readonly-added').after('<img src="' + wptDateData.readonly_image + '" alt="' + wptDateData.readonly + '" title="' + wptDateData.readonly + '" class="ui-datepicker-readonly" />');
|
21 |
+
}
|
22 |
+
return;
|
23 |
+
}
|
24 |
+
// First, a hacky hack: make the id of each el unique, because the way they are produced on repetitive date fields does not ensure it
|
25 |
+
var rand_number = 1 + Math.floor(Math.random() * 150),
|
26 |
+
old_id = el.attr('id');
|
27 |
+
el.attr('id', old_id + '-' + rand_number);
|
28 |
+
// Walk along, nothing to see here...
|
29 |
+
return el.datepicker({
|
30 |
+
onSelect: function( dateText, inst ) {
|
31 |
+
// The el_aux element depends on the scenario: backend or frontend
|
32 |
+
var el_aux;
|
33 |
+
el.val('');
|
34 |
+
if ( el.closest('.js-wpt-field-item').length > 0 ) {
|
35 |
+
el_aux = el.closest('.js-wpt-field-item').find('.js-wpt-date-auxiliar');
|
36 |
+
} else if ( el.closest('.wpt-repctl').length > 0 ) {
|
37 |
+
el_aux = el.closest('.wpt-repctl').find('.js-wpt-date-auxiliar');
|
38 |
+
} else if ( el.closest('.js-wpt-field-items').length > 0 ) {
|
39 |
+
el_aux = el.closest('.js-wpt-field-items').find('.js-wpt-date-auxiliar');
|
40 |
+
} else {
|
41 |
+
// This should be an empty object, but as we use the variable later we need to set it
|
42 |
+
el_aux = el.closest('.js-wpt-field-items');
|
43 |
+
}
|
44 |
+
var data = 'date=' + dateText;
|
45 |
+
data += '&date-format=' + wptDateData.dateFormatPhp;
|
46 |
+
data += '&action=wpt_localize_extended_date';
|
47 |
+
$.post( wptDateData.ajaxurl, data, function( response ) {
|
48 |
+
response = $.parseJSON( response );
|
49 |
+
if ( el_aux.length > 0 ) {
|
50 |
+
el_aux.val( response['timestamp'] ).trigger('wptDateSelect');
|
51 |
+
}
|
52 |
+
el.val( response['display'] );
|
53 |
+
});
|
54 |
+
//el.trigger('wptDateSelect');
|
55 |
+
},
|
56 |
+
showOn: "both",
|
57 |
+
buttonImage: wptDateData.buttonImage,
|
58 |
+
buttonImageOnly: true,
|
59 |
+
buttonText: wptDateData.buttonText,
|
60 |
+
dateFormat: 'ddmmyy',
|
61 |
+
//dateFormat: wptDateData.dateFormat,
|
62 |
+
//altFormat: wptDateData.dateFormat,
|
63 |
+
changeMonth: true,
|
64 |
+
changeYear: true,
|
65 |
+
yearRange: wptDateData.yearMin+':'+wptDateData.yearMax
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
});
|
67 |
}
|
68 |
|
76 |
wptCond.ajaxCheck(formID, _tempField, _tempConditions);
|
77 |
}
|
78 |
function ignoreConditional(val) {
|
79 |
+
if ( '' == val ) {
|
80 |
return '__ignore_negative';
|
81 |
}
|
82 |
+
return val;
|
83 |
//return Date.parse(val);
|
84 |
}
|
85 |
function bindConditionalChange($trigger, func, formID) {
|
88 |
//$trigger.on('keyup', lazy);
|
89 |
return false;
|
90 |
}
|
91 |
+
function triggerAjax(func){
|
92 |
+
if ($(this).val().length >= wptDateData.dateFormatPhp.length) func();
|
|
|
93 |
}
|
94 |
return {
|
95 |
init: init,
|
102 |
};
|
103 |
})(jQuery);
|
104 |
|
105 |
+
jQuery(document).ready(function() {
|
106 |
wptDate.init('body');
|
107 |
//fixing unknown Srdjan error
|
108 |
jQuery('.ui-datepicker-inline').hide();
|
109 |
});
|
110 |
|
111 |
+
if ( 'undefined' != typeof(wptCallbacks) ) {
|
112 |
+
wptCallbacks.reset.add(function(parent) {
|
113 |
wptDate.init(parent);
|
114 |
});
|
115 |
wptCallbacks.addRepetitive.add(wptDate.init);
|
116 |
}
|
117 |
|
118 |
//add_action('conditional_check_date', wptDate.ajaxConditional, 10, 3);
|
119 |
+
if ( 'function' == typeof(add_filter) ) {
|
120 |
add_filter('conditional_value_date', wptDate.ignoreConditional, 10, 1);
|
121 |
}
|
122 |
+
if ( 'function' == typeof(add_action) ) {
|
123 |
add_action('conditional_trigger_bind_date', wptDate.bindConditionalChange, 10, 3);
|
124 |
}
|
embedded/common/toolset-forms/js/file-wp35.js
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
*
|
3 |
-
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/1.5.1/toolset-forms/js/file-wp35.js $
|
4 |
-
* $LastChangedDate: 2015-05-04 08:57:42 +0200 (Mon, 04 May 2015) $
|
5 |
-
* $LastChangedRevision: 33205 $
|
6 |
-
* $LastChangedBy: marcin $
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
var wptFile = (function($, w) {
|
10 |
-
var frame = [];
|
11 |
-
var $item, $parent, $preview;
|
12 |
-
|
13 |
-
function init() {
|
14 |
-
// Fetch available headers and apply jQuery.masonry
|
15 |
-
// once the images have loaded.
|
16 |
-
var $headers = $('.available-headers');
|
17 |
-
|
18 |
-
$headers.imagesLoaded( function() {
|
19 |
-
$headers.masonry({
|
20 |
-
itemSelector: '.default-header',
|
21 |
-
isRTL: !! ( 'undefined' != typeof isRtl && isRtl )
|
22 |
-
});
|
23 |
-
});
|
24 |
-
/*
|
25 |
-
$('.js-wpt-field').on('click', 'a.js-wpt-file-upload', function() {
|
26 |
-
if ( $(this).data('attched-thickbox') ) {
|
27 |
-
return;
|
28 |
-
}
|
29 |
-
return wptFile.open(this, true);
|
30 |
-
});
|
31 |
-
*/
|
32 |
-
// Build the choose from library frame.
|
33 |
-
$('.js-wpt-field').on('click', 'a.js-wpt-file-upload', function( event ) {
|
34 |
-
wptFile.bindOpen($(this), event);
|
35 |
-
});
|
36 |
-
}
|
37 |
-
|
38 |
-
function bindOpen($el, event)
|
39 |
-
{
|
40 |
-
var $type = $el.data('wpt-type');
|
41 |
-
var $id = $el.parent().attr('id');
|
42 |
-
|
43 |
-
if ( event ) {
|
44 |
-
event.preventDefault();
|
45 |
-
}
|
46 |
-
|
47 |
-
// If the media frame already exists, reopen it.
|
48 |
-
if ( frame[$id] ) {
|
49 |
-
frame[$id].open();
|
50 |
-
return;
|
51 |
-
}
|
52 |
-
|
53 |
-
// Create the media frame.
|
54 |
-
frame[$id] = wp.media.frames.customHeader = wp.media({
|
55 |
-
// Set the title of the modal.
|
56 |
-
title: $el.html(),
|
57 |
-
|
58 |
-
// Tell the modal to show only images.
|
59 |
-
library: {
|
60 |
-
type: 'file' == $type? null:$type
|
61 |
-
},
|
62 |
-
|
63 |
-
// Customize the submit button.
|
64 |
-
button: {
|
65 |
-
// Set the text of the button.
|
66 |
-
text: $el.data('update'),
|
67 |
-
// Tell the button not to close the modal, since we're
|
68 |
-
// going to refresh the page when the image is selected.
|
69 |
-
close: false
|
70 |
-
}
|
71 |
-
});
|
72 |
-
|
73 |
-
// When an image is selected, run a callback.
|
74 |
-
frame[$id].on( 'select', function() {
|
75 |
-
// Grab the selected attachment.
|
76 |
-
var attachment = frame[$id].state().get('selection').first();
|
77 |
-
var $parent = $el.parent();
|
78 |
-
switch( $type ) {
|
79 |
-
case 'image':
|
80 |
-
$('.textfield', $parent).val(attachment.attributes.sizes.full.url);
|
81 |
-
if ( 0 == $('.wpt-file-preview img', $parent.parent()).length) {
|
82 |
-
$('.wpt-file-preview', $parent.parent()).append('<img src="">');
|
83 |
-
}
|
84 |
-
if ( 'undefined' != typeof attachment.attributes.sizes.thumbnail ) {
|
85 |
-
$('.wpt-file-preview img', $parent.parent()).attr('src', attachment.attributes.sizes.thumbnail.url);
|
86 |
-
} else {
|
87 |
-
$('.wpt-file-preview img', $parent.parent()).attr('src', attachment.attributes.sizes.full.url);
|
88 |
-
}
|
89 |
-
break;
|
90 |
-
default:
|
91 |
-
$('.textfield', $parent).val(attachment.attributes.url);
|
92 |
-
break;
|
93 |
-
}
|
94 |
-
frame[$id].close();
|
95 |
-
});
|
96 |
-
|
97 |
-
frame[$id].open();
|
98 |
-
}
|
99 |
-
|
100 |
-
return {
|
101 |
-
init: init,
|
102 |
-
bindOpen: bindOpen,
|
103 |
-
};
|
104 |
-
})(jQuery);
|
105 |
-
|
106 |
-
jQuery(document).ready(wptFile.init);
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/toolset-forms/js/file.js
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
*
|
3 |
+
* $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/js/file.js $
|
4 |
+
* $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
|
5 |
+
* $LastChangedRevision: 970205 $
|
6 |
+
* $LastChangedBy: brucepearson $
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
var wptFile = (function($, w) {
|
10 |
+
var $item, $parent, $preview;
|
11 |
+
function init() {
|
12 |
+
$('.js-wpt-field').on('click', 'a.js-wpt-file-upload', function() {
|
13 |
+
if ( $(this).data('attched-thickbox') ) {
|
14 |
+
return;
|
15 |
+
}
|
16 |
+
return wptFile.open(this, true);
|
17 |
+
});
|
18 |
+
}
|
19 |
+
function initRow(row) {
|
20 |
+
$('.js-wpt-field', row).on('click', 'a.js-wpt-file-upload', function() {
|
21 |
+
$(this).data('attched-thickbox', true );
|
22 |
+
return wptFile.open(this, true);
|
23 |
+
});
|
24 |
+
}
|
25 |
+
function mediaInsert(url, type) {
|
26 |
+
$(':input', $item).first().val(url);
|
27 |
+
if (type == 'image') {
|
28 |
+
$preview.html('<img src="' + url + '" />');
|
29 |
+
} else {
|
30 |
+
$preview.html('');
|
31 |
+
}
|
32 |
+
tb_remove();
|
33 |
+
}
|
34 |
+
function mediaInsertTrigger(guid, type) {
|
35 |
+
window.parent.wptFile.mediaInsert(guid, type);
|
36 |
+
window.parent.jQuery('#TB_closeWindowButton').trigger('click');
|
37 |
+
}
|
38 |
+
function open(el)
|
39 |
+
{
|
40 |
+
height = $('body').height()-20;
|
41 |
+
if ( 800 < height ) {
|
42 |
+
height = 800;
|
43 |
+
}
|
44 |
+
width = $('body').width()-20;
|
45 |
+
if ( 670 < width ) {
|
46 |
+
width = 670;
|
47 |
+
}
|
48 |
+
$item = $(el).parents('.js-wpt-field-item');
|
49 |
+
$parent = $item.parents('.js-wpt-field');
|
50 |
+
$preview = $('.js-wpt-file-preview', $item);
|
51 |
+
type = 'file';
|
52 |
+
if ( $(el).data('wpt-type') ) {
|
53 |
+
type = $(el).data('wpt-type');
|
54 |
+
}
|
55 |
+
tb_show(wptFileData.title, wptFileData.adminurl + 'media-upload.php?' + wptFileData.for_post + 'type='+type+'&context=wpt-fields-media-insert&wpt[id]=' + $parent.data('wpt-id') + '&wpt[type]=' + $parent.data('wpt-type') + '&TB_iframe=true&width='+width+'&height='+height);
|
56 |
+
return false;
|
57 |
+
}
|
58 |
+
return {
|
59 |
+
init: init,
|
60 |
+
initRow: initRow,
|
61 |
+
open: open,
|
62 |
+
mediaInsert: mediaInsert,
|
63 |
+
mediaInsertTrigger: mediaInsertTrigger
|
64 |
+
};
|
65 |
+
})(jQuery);
|
66 |
+
|
67 |
+
jQuery(document).ready(wptFile.init);
|
68 |
+
|
embedded/common/toolset-forms/js/jquery.autocomplete.js
ADDED
@@ -0,0 +1,507 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
original jQuery plugin by http://www.pengoworks.com/workshop/jquery/autocomplete.htm
|
3 |
+
just replaced $ with jQuery in order to be complaint with other JavaScript libraries.
|
4 |
+
*/
|
5 |
+
|
6 |
+
jQuery.autocomplete = function(input, options) {
|
7 |
+
// Create a link to self
|
8 |
+
var me = this;
|
9 |
+
|
10 |
+
// Create jQuery object for input element
|
11 |
+
var $input = jQuery(input).attr("autocomplete", "off");
|
12 |
+
|
13 |
+
// Apply inputClass if necessary
|
14 |
+
if (options.inputClass) $input.addClass(options.inputClass);
|
15 |
+
|
16 |
+
// Create results
|
17 |
+
var results = document.createElement("div");
|
18 |
+
// Create jQuery object for results
|
19 |
+
var $results = jQuery(results);
|
20 |
+
$results.hide().addClass(options.resultsClass).css("position", "absolute");
|
21 |
+
if( options.width > 0 ) $results.css("width", options.width);
|
22 |
+
|
23 |
+
// Add to body element
|
24 |
+
jQuery("body").append(results);
|
25 |
+
|
26 |
+
input.autocompleter = me;
|
27 |
+
|
28 |
+
var timeout = null;
|
29 |
+
var prev = "";
|
30 |
+
var active = -1;
|
31 |
+
var cache = {};
|
32 |
+
var keyb = false;
|
33 |
+
var hasFocus = false;
|
34 |
+
var lastKeyPressCode = null;
|
35 |
+
|
36 |
+
// flush cache
|
37 |
+
function flushCache(){
|
38 |
+
cache = {};
|
39 |
+
cache.data = {};
|
40 |
+
cache.length = 0;
|
41 |
+
};
|
42 |
+
|
43 |
+
// flush cache
|
44 |
+
flushCache();
|
45 |
+
|
46 |
+
// if there is a data array supplied
|
47 |
+
if( options.data != null ){
|
48 |
+
var sFirstChar = "", stMatchSets = {}, row = [];
|
49 |
+
|
50 |
+
// no url was specified, we need to adjust the cache length to make sure it fits the local data store
|
51 |
+
if( typeof options.url != "string" ) options.cacheLength = 1;
|
52 |
+
|
53 |
+
// loop through the array and create a lookup structure
|
54 |
+
for( var i=0; i < options.data.length; i++ ){
|
55 |
+
// if row is a string, make an array otherwise just reference the array
|
56 |
+
row = ((typeof options.data[i] == "string") ? [options.data[i]] : options.data[i]);
|
57 |
+
|
58 |
+
// if the length is zero, don't add to list
|
59 |
+
if( row[0].length > 0 ){
|
60 |
+
// get the first character
|
61 |
+
sFirstChar = row[0].substring(0, 1).toLowerCase();
|
62 |
+
// if no lookup array for this character exists, look it up now
|
63 |
+
if( !stMatchSets[sFirstChar] ) stMatchSets[sFirstChar] = [];
|
64 |
+
// if the match is a string
|
65 |
+
stMatchSets[sFirstChar].push(row);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
// add the data items to the cache
|
70 |
+
for( var k in stMatchSets ){
|
71 |
+
// increase the cache size
|
72 |
+
options.cacheLength++;
|
73 |
+
// add to the cache
|
74 |
+
addToCache(k, stMatchSets[k]);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
$input
|
79 |
+
.keydown(function(e) {
|
80 |
+
// track last key pressed
|
81 |
+
lastKeyPressCode = e.keyCode;
|
82 |
+
switch(e.keyCode) {
|
83 |
+
case 38: // up
|
84 |
+
e.preventDefault();
|
85 |
+
moveSelect(-1);
|
86 |
+
break;
|
87 |
+
case 40: // down
|
88 |
+
e.preventDefault();
|
89 |
+
moveSelect(1);
|
90 |
+
break;
|
91 |
+
case 9: // tab
|
92 |
+
case 13: // return
|
93 |
+
if( selectCurrent() ){
|
94 |
+
// make sure to blur off the current field
|
95 |
+
$input.get(0).blur();
|
96 |
+
e.preventDefault();
|
97 |
+
}
|
98 |
+
break;
|
99 |
+
default:
|
100 |
+
active = -1;
|
101 |
+
if (timeout) clearTimeout(timeout);
|
102 |
+
timeout = setTimeout(function(){onChange();}, options.delay);
|
103 |
+
break;
|
104 |
+
}
|
105 |
+
})
|
106 |
+
.focus(function(){
|
107 |
+
// track whether the field has focus, we shouldn't process any results if the field no longer has focus
|
108 |
+
hasFocus = true;
|
109 |
+
})
|
110 |
+
.blur(function() {
|
111 |
+
// track whether the field has focus
|
112 |
+
hasFocus = false;
|
113 |
+
hideResults();
|
114 |
+
});
|
115 |
+
|
116 |
+
hideResultsNow();
|
117 |
+
|
118 |
+
function onChange() {
|
119 |
+
// ignore if the following keys are pressed: [del] [shift] [capslock]
|
120 |
+
if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ) return $results.hide();
|
121 |
+
var v = $input.val();
|
122 |
+
if (v == prev) return;
|
123 |
+
prev = v;
|
124 |
+
if (v.length >= options.minChars) {
|
125 |
+
$input.addClass(options.loadingClass);
|
126 |
+
requestData(v);
|
127 |
+
} else {
|
128 |
+
$input.removeClass(options.loadingClass);
|
129 |
+
$results.hide();
|
130 |
+
}
|
131 |
+
};
|
132 |
+
|
133 |
+
function moveSelect(step) {
|
134 |
+
|
135 |
+
var lis = jQuery("li", results);
|
136 |
+
if (!lis) return;
|
137 |
+
|
138 |
+
active += step;
|
139 |
+
|
140 |
+
if (active < 0) {
|
141 |
+
active = 0;
|
142 |
+
} else if (active >= lis.size()) {
|
143 |
+
active = lis.size() - 1;
|
144 |
+
}
|
145 |
+
|
146 |
+
lis.removeClass("ac_over");
|
147 |
+
|
148 |
+
jQuery(lis[active]).addClass("ac_over");
|
149 |
+
|
150 |
+
// Weird behaviour in IE
|
151 |
+
// if (lis[active] && lis[active].scrollIntoView) {
|
152 |
+
// lis[active].scrollIntoView(false);
|
153 |
+
// }
|
154 |
+
|
155 |
+
};
|
156 |
+
|
157 |
+
function selectCurrent() {
|
158 |
+
var li = jQuery("li.ac_over", results)[0];
|
159 |
+
if (!li) {
|
160 |
+
var $li = jQuery("li", results);
|
161 |
+
if (options.selectOnly) {
|
162 |
+
if ($li.length == 1) li = $li[0];
|
163 |
+
} else if (options.selectFirst) {
|
164 |
+
li = $li[0];
|
165 |
+
}
|
166 |
+
}
|
167 |
+
if (li) {
|
168 |
+
selectItem(li);
|
169 |
+
return true;
|
170 |
+
} else {
|
171 |
+
return false;
|
172 |
+
}
|
173 |
+
};
|
174 |
+
|
175 |
+
function selectItem(li) {
|
176 |
+
if (!li) {
|
177 |
+
li = document.createElement("li");
|
178 |
+
li.extra = [];
|
179 |
+
li.selectValue = "";
|
180 |
+
}
|
181 |
+
var v = jQuery.trim(li.selectValue ? li.selectValue : li.innerHTML);
|
182 |
+
input.lastSelected = v;
|
183 |
+
prev = v;
|
184 |
+
$results.html("");
|
185 |
+
$input.val(v);
|
186 |
+
hideResultsNow();
|
187 |
+
if (options.onItemSelect) setTimeout(function() { options.onItemSelect(li) }, 1);
|
188 |
+
};
|
189 |
+
|
190 |
+
// selects a portion of the input string
|
191 |
+
function createSelection(start, end){
|
192 |
+
// get a reference to the input element
|
193 |
+
var field = $input.get(0);
|
194 |
+
if( field.createTextRange ){
|
195 |
+
var selRange = field.createTextRange();
|
196 |
+
selRange.collapse(true);
|
197 |
+
selRange.moveStart("character", start);
|
198 |
+
selRange.moveEnd("character", end);
|
199 |
+
selRange.select();
|
200 |
+
} else if( field.setSelectionRange ){
|
201 |
+
field.setSelectionRange(start, end);
|
202 |
+
} else {
|
203 |
+
if( field.selectionStart ){
|
204 |
+
field.selectionStart = start;
|
205 |
+
field.selectionEnd = end;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
field.focus();
|
209 |
+
};
|
210 |
+
|
211 |
+
// fills in the input box w/the first match (assumed to be the best match)
|
212 |
+
function autoFill(sValue){
|
213 |
+
// if the last user key pressed was backspace, don't autofill
|
214 |
+
if( lastKeyPressCode != 8 ){
|
215 |
+
// fill in the value (keep the case the user has typed)
|
216 |
+
$input.val($input.val() + sValue.substring(prev.length));
|
217 |
+
// select the portion of the value not typed by the user (so the next character will erase)
|
218 |
+
createSelection(prev.length, sValue.length);
|
219 |
+
}
|
220 |
+
};
|
221 |
+
|
222 |
+
function showResults() {
|
223 |
+
// get the position of the input field right now (in case the DOM is shifted)
|
224 |
+
var pos = findPos(input);
|
225 |
+
// either use the specified width, or autocalculate based on form element
|
226 |
+
var iWidth = (options.width > 0) ? options.width : $input.width();
|
227 |
+
// reposition
|
228 |
+
$results.css({
|
229 |
+
width: parseInt(iWidth) + "px",
|
230 |
+
top: (pos.y + input.offsetHeight + 28) + "px",
|
231 |
+
left: pos.x + "px"
|
232 |
+
}).show();
|
233 |
+
};
|
234 |
+
|
235 |
+
function hideResults() {
|
236 |
+
if (timeout) clearTimeout(timeout);
|
237 |
+
timeout = setTimeout(hideResultsNow, 200);
|
238 |
+
};
|
239 |
+
|
240 |
+
function hideResultsNow() {
|
241 |
+
if (timeout) clearTimeout(timeout);
|
242 |
+
$input.removeClass(options.loadingClass);
|
243 |
+
if ($results.is(":visible")) {
|
244 |
+
$results.hide();
|
245 |
+
}
|
246 |
+
if (options.mustMatch) {
|
247 |
+
var v = $input.val();
|
248 |
+
if (v != input.lastSelected) {
|
249 |
+
selectItem(null);
|
250 |
+
}
|
251 |
+
}
|
252 |
+
};
|
253 |
+
|
254 |
+
function receiveData(q, data) {
|
255 |
+
if (data) {
|
256 |
+
$input.removeClass(options.loadingClass);
|
257 |
+
results.innerHTML = "";
|
258 |
+
|
259 |
+
// if the field no longer has focus or if there are no matches, do not display the drop down
|
260 |
+
if( !hasFocus || data.length == 0 ) return hideResultsNow();
|
261 |
+
|
262 |
+
if (jQuery.browser.msie) {
|
263 |
+
// we put a styled iframe behind the calendar so HTML SELECT elements don't show through
|
264 |
+
$results.append(document.createElement('iframe'));
|
265 |
+
}
|
266 |
+
results.appendChild(dataToDom(data));
|
267 |
+
// autofill in the complete box w/the first match as long as the user hasn't entered in more data
|
268 |
+
if( options.autoFill && ($input.val().toLowerCase() == q.toLowerCase()) ) autoFill(data[0][0]);
|
269 |
+
showResults();
|
270 |
+
} else {
|
271 |
+
hideResultsNow();
|
272 |
+
}
|
273 |
+
};
|
274 |
+
|
275 |
+
function parseData(data) {
|
276 |
+
if (!data) return null;
|
277 |
+
var parsed = [];
|
278 |
+
var rows = data.split(options.lineSeparator);
|
279 |
+
for (var i=0; i < rows.length; i++) {
|
280 |
+
var row = jQuery.trim(rows[i]);
|
281 |
+
if (row) {
|
282 |
+
parsed[parsed.length] = row.split(options.cellSeparator);
|
283 |
+
}
|
284 |
+
}
|
285 |
+
return parsed;
|
286 |
+
};
|
287 |
+
|
288 |
+
function dataToDom(data) {
|
289 |
+
var ul = document.createElement("ul");
|
290 |
+
var num = data.length;
|
291 |
+
|
292 |
+
// limited results to a max number
|
293 |
+
if( (options.maxItemsToShow > 0) && (options.maxItemsToShow < num) ) num = options.maxItemsToShow;
|
294 |
+
|
295 |
+
for (var i=0; i < num; i++) {
|
296 |
+
var row = data[i];
|
297 |
+
if (!row) continue;
|
298 |
+
var li = document.createElement("li");
|
299 |
+
if (options.formatItem) {
|
300 |
+
li.innerHTML = options.formatItem(row, i, num);
|
301 |
+
li.selectValue = row[0];
|
302 |
+
} else {
|
303 |
+
li.innerHTML = row[0];
|
304 |
+
li.selectValue = row[0];
|
305 |
+
}
|
306 |
+
var extra = null;
|
307 |
+
if (row.length > 1) {
|
308 |
+
extra = [];
|
309 |
+
for (var j=1; j < row.length; j++) {
|
310 |
+
extra[extra.length] = row[j];
|
311 |
+
}
|
312 |
+
}
|
313 |
+
li.extra = extra;
|
314 |
+
ul.appendChild(li);
|
315 |
+
jQuery(li).hover(
|
316 |
+
function() { jQuery("li", ul).removeClass("ac_over"); jQuery(this).addClass("ac_over"); active = jQuery("li", ul).indexOf(jQuery(this).get(0)); },
|
317 |
+
function() { jQuery(this).removeClass("ac_over"); }
|
318 |
+
).click(function(e) { e.preventDefault(); e.stopPropagation(); selectItem(this) });
|
319 |
+
}
|
320 |
+
return ul;
|
321 |
+
};
|
322 |
+
|
323 |
+
function requestData(q) {
|
324 |
+
if (!options.matchCase) q = q.toLowerCase();
|
325 |
+
var data = options.cacheLength ? loadFromCache(q) : null;
|
326 |
+
// recieve the cached data
|
327 |
+
if (data) {
|
328 |
+
receiveData(q, data);
|
329 |
+
// if an AJAX url has been supplied, try loading the data now
|
330 |
+
} else if( (typeof options.url == "string") && (options.url.length > 0) ){
|
331 |
+
jQuery.get(makeUrl(q), function(data) {
|
332 |
+
data = parseData(data);
|
333 |
+
addToCache(q, data);
|
334 |
+
receiveData(q, data);
|
335 |
+
});
|
336 |
+
// if there's been no data found, remove the loading class
|
337 |
+
} else {
|
338 |
+
$input.removeClass(options.loadingClass);
|
339 |
+
}
|
340 |
+
};
|
341 |
+
|
342 |
+
function makeUrl(q) {
|
343 |
+
var url = options.url + "?q=" + encodeURI(q);
|
344 |
+
for (var i in options.extraParams) {
|
345 |
+
url += "&" + i + "=" + encodeURI(options.extraParams[i]);
|
346 |
+
}
|
347 |
+
return url;
|
348 |
+
};
|
349 |
+
|
350 |
+
function loadFromCache(q) {
|
351 |
+
if (!q) return null;
|
352 |
+
if (cache.data[q]) return cache.data[q];
|
353 |
+
if (options.matchSubset) {
|
354 |
+
for (var i = q.length - 1; i >= options.minChars; i--) {
|
355 |
+
var qs = q.substr(0, i);
|
356 |
+
var c = cache.data[qs];
|
357 |
+
if (c) {
|
358 |
+
var csub = [];
|
359 |
+
for (var j = 0; j < c.length; j++) {
|
360 |
+
var x = c[j];
|
361 |
+
var x0 = x[0];
|
362 |
+
if (matchSubset(x0, q)) {
|
363 |
+
csub[csub.length] = x;
|
364 |
+
}
|
365 |
+
}
|
366 |
+
return csub;
|
367 |
+
}
|
368 |
+
}
|
369 |
+
}
|
370 |
+
return null;
|
371 |
+
};
|
372 |
+
|
373 |
+
function matchSubset(s, sub) {
|
374 |
+
if (!options.matchCase) s = s.toLowerCase();
|
375 |
+
var i = s.indexOf(sub);
|
376 |
+
if (i == -1) return false;
|
377 |
+
return i == 0 || options.matchContains;
|
378 |
+
};
|
379 |
+
|
380 |
+
this.flushCache = function() {
|
381 |
+
flushCache();
|
382 |
+
};
|
383 |
+
|
384 |
+
this.setExtraParams = function(p) {
|
385 |
+
options.extraParams = p;
|
386 |
+
};
|
387 |
+
|
388 |
+
this.findValue = function(){
|
389 |
+
var q = $input.val();
|
390 |
+
|
391 |
+
if (!options.matchCase) q = q.toLowerCase();
|
392 |
+
var data = options.cacheLength ? loadFromCache(q) : null;
|
393 |
+
if (data) {
|
394 |
+
findValueCallback(q, data);
|
395 |
+
} else if( (typeof options.url == "string") && (options.url.length > 0) ){
|
396 |
+
jQuery.get(makeUrl(q), function(data) {
|
397 |
+
data = parseData(data)
|
398 |
+
addToCache(q, data);
|
399 |
+
findValueCallback(q, data);
|
400 |
+
});
|
401 |
+
} else {
|
402 |
+
// no matches
|
403 |
+
findValueCallback(q, null);
|
404 |
+
}
|
405 |
+
}
|
406 |
+
|
407 |
+
function findValueCallback(q, data){
|
408 |
+
if (data) $input.removeClass(options.loadingClass);
|
409 |
+
|
410 |
+
var num = (data) ? data.length : 0;
|
411 |
+
var li = null;
|
412 |
+
|
413 |
+
for (var i=0; i < num; i++) {
|
414 |
+
var row = data[i];
|
415 |
+
|
416 |
+
if( row[0].toLowerCase() == q.toLowerCase() ){
|
417 |
+
li = document.createElement("li");
|
418 |
+
if (options.formatItem) {
|
419 |
+
li.innerHTML = options.formatItem(row, i, num);
|
420 |
+
li.selectValue = row[0];
|
421 |
+
} else {
|
422 |
+
li.innerHTML = row[0];
|
423 |
+
li.selectValue = row[0];
|
424 |
+
}
|
425 |
+
var extra = null;
|
426 |
+
if( row.length > 1 ){
|
427 |
+
extra = [];
|
428 |
+
for (var j=1; j < row.length; j++) {
|
429 |
+
extra[extra.length] = row[j];
|
430 |
+
}
|
431 |
+
}
|
432 |
+
li.extra = extra;
|
433 |
+
}
|
434 |
+
}
|
435 |
+
|
436 |
+
if( options.onFindValue ) setTimeout(function() { options.onFindValue(li) }, 1);
|
437 |
+
}
|
438 |
+
|
439 |
+
function addToCache(q, data) {
|
440 |
+
if (!data || !q || !options.cacheLength) return;
|
441 |
+
if (!cache.length || cache.length > options.cacheLength) {
|
442 |
+
flushCache();
|
443 |
+
cache.length++;
|
444 |
+
} else if (!cache[q]) {
|
445 |
+
cache.length++;
|
446 |
+
}
|
447 |
+
cache.data[q] = data;
|
448 |
+
};
|
449 |
+
|
450 |
+
function findPos(obj) {
|
451 |
+
var curleft = obj.offsetLeft || 0;
|
452 |
+
var curtop = obj.offsetTop || 0;
|
453 |
+
while (obj = obj.offsetParent) {
|
454 |
+
curleft += obj.offsetLeft
|
455 |
+
curtop += obj.offsetTop
|
456 |
+
}
|
457 |
+
return {x:curleft,y:curtop};
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
jQuery.fn.autocomplete = function(url, options, data) {
|
462 |
+
// Make sure options exists
|
463 |
+
options = options || {};
|
464 |
+
// Set url as option
|
465 |
+
options.url = url;
|
466 |
+
// set some bulk local data
|
467 |
+
options.data = ((typeof data == "object") && (data.constructor == Array)) ? data : null;
|
468 |
+
|
469 |
+
// Set default values for required options
|
470 |
+
options.inputClass = options.inputClass || "ac_input";
|
471 |
+
options.resultsClass = options.resultsClass || "ac_results";
|
472 |
+
options.lineSeparator = options.lineSeparator || "\n";
|
473 |
+
options.cellSeparator = options.cellSeparator || "|";
|
474 |
+
options.minChars = options.minChars || 1;
|
475 |
+
options.delay = options.delay || 400;
|
476 |
+
options.matchCase = options.matchCase || 0;
|
477 |
+
options.matchSubset = options.matchSubset || 1;
|
478 |
+
options.matchContains = options.matchContains || 0;
|
479 |
+
options.cacheLength = options.cacheLength || 1;
|
480 |
+
options.mustMatch = options.mustMatch || 0;
|
481 |
+
options.extraParams = options.extraParams || {};
|
482 |
+
options.loadingClass = options.loadingClass || "ac_loading";
|
483 |
+
options.selectFirst = options.selectFirst || false;
|
484 |
+
options.selectOnly = options.selectOnly || false;
|
485 |
+
options.maxItemsToShow = options.maxItemsToShow || -1;
|
486 |
+
options.autoFill = options.autoFill || false;
|
487 |
+
options.width = parseInt(options.width, 10) || 0;
|
488 |
+
|
489 |
+
this.each(function() {
|
490 |
+
var input = this;
|
491 |
+
new jQuery.autocomplete(input, options);
|
492 |
+
});
|
493 |
+
|
494 |
+
// Don't break the chain
|
495 |
+
return this;
|
496 |
+
}
|
497 |
+
|
498 |
+
jQuery.fn.autocompleteArray = function(data, options) {
|
499 |
+
return this.autocomplete(null, options, data);
|
500 |
+
}
|
501 |
+
|
502 |
+
jQuery.fn.indexOf = function(e){
|
503 |
+
for( var i=0; i<this.length; i++ ){
|
504 |
+
if( this[i] == e ) return i;
|
505 |
+
}
|
506 |
+
return -1;
|
507 |
+
};
|
embedded/common/toolset-forms/js/main.js
CHANGED
@@ -8,9 +8,9 @@ wptCallbacks.removeRepetitive = jQuery.Callbacks('unique');
|
|
8 |
wptCallbacks.conditionalCheck = jQuery.Callbacks('unique');
|
9 |
wptCallbacks.reset = jQuery.Callbacks('unique');
|
10 |
|
11 |
-
jQuery(document).ready(function
|
12 |
if (typeof wptValidation !== 'undefined') {
|
13 |
-
wptCallbacks.validationInit.add(function
|
14 |
wptValidation.init();
|
15 |
});
|
16 |
}
|
@@ -19,15 +19,6 @@ jQuery(document).ready(function () {
|
|
19 |
} else {
|
20 |
wptCallbacks.validationInit.fire();
|
21 |
}
|
22 |
-
/**
|
23 |
-
* check taxonmies on submitted forms
|
24 |
-
*/
|
25 |
-
jQuery('.cred-taxonomy', jQuery('form.is_submitted')).each(function () {
|
26 |
-
parent = jQuery(this);
|
27 |
-
setTimeout(function () {
|
28 |
-
jQuery('input.wpt-taxonomy-add-new', parent).click();
|
29 |
-
}, 50);
|
30 |
-
});
|
31 |
});
|
32 |
|
33 |
|
@@ -44,8 +35,8 @@ function apply_filters(name, val) {
|
|
44 |
if (typeof wptFilters[name] === 'undefined')
|
45 |
return val;
|
46 |
var args = _.rest(_.toArray(arguments));
|
47 |
-
_.each(wptFilters[name], function
|
48 |
-
_.each(funcs, function
|
49 |
var _args = args.slice(0, $callback[1]);
|
50 |
args[0] = $callback[0].apply(null, _args);
|
51 |
});
|
@@ -59,8 +50,8 @@ function do_action(name) {
|
|
59 |
if (typeof wptFilters[name] === 'undefined')
|
60 |
return false;
|
61 |
var args = _.rest(_.toArray(arguments));
|
62 |
-
_.each(wptFilters[name], function
|
63 |
-
_.each(funcs, function
|
64 |
var _args = args.slice(0, $callback[1]);
|
65 |
$callback[0].apply(null, _args);
|
66 |
});
|
@@ -71,130 +62,128 @@ function do_action(name) {
|
|
71 |
/**
|
72 |
* flat taxonomies functions
|
73 |
*/
|
74 |
-
function showHideMostPopularButton(taxonomy
|
75 |
{
|
76 |
-
var $button = jQuery('[name="sh_' + taxonomy + '"]', form);
|
77 |
-
var $taxonomy_box = jQuery('.shmpt-' + taxonomy, form);
|
78 |
-
var $tag_list = $taxonomy_box.find('.js-wpt-taxonomy-popular-add');
|
79 |
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
82 |
|
83 |
-
if
|
84 |
{
|
85 |
$button.show();
|
86 |
return true;
|
87 |
-
}
|
88 |
$button.hide();
|
89 |
return false;
|
90 |
}
|
91 |
}
|
92 |
-
|
93 |
-
jQuery(document).on('click', '.js-wpt-taxonomy-popular-show-hide', function
|
94 |
-
|
95 |
});
|
96 |
|
97 |
function showHideMostPopularTaxonomy(el)
|
98 |
{
|
99 |
var taxonomy = jQuery(el).data('taxonomy');
|
100 |
-
|
101 |
-
jQuery('.shmpt-' + taxonomy, form).toggle();
|
102 |
var curr = jQuery(el).val();
|
103 |
-
if (curr
|
104 |
-
jQuery(el).val(jQuery(el).data('hide-popular-text')
|
105 |
} else {
|
106 |
-
jQuery(el).val(jQuery(el).data('show-popular-text')
|
107 |
}
|
108 |
}
|
109 |
|
110 |
-
jQuery(document).on('click', '.js-wpt-taxonomy-popular-add', function
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
});
|
118 |
|
119 |
function addTaxonomy(slug, taxonomy, el)
|
120 |
{
|
121 |
var form = jQuery(el).closest('form');
|
122 |
-
var curr = jQuery('input[name=tmp_'
|
123 |
-
if (''
|
124 |
-
jQuery('input[name=tmp_'
|
125 |
setTaxonomy(taxonomy, el);
|
126 |
} else {
|
127 |
-
if (curr.indexOf(slug)
|
128 |
-
jQuery('input[name=tmp_'
|
129 |
setTaxonomy(taxonomy, el);
|
130 |
}
|
131 |
}
|
132 |
-
jQuery('input[name=tmp_'
|
|
|
|
|
133 |
}
|
134 |
|
135 |
-
jQuery(document).on('click', '.js-wpt-taxonomy-add-new', function
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
});
|
140 |
|
141 |
-
jQuery(document).on('keypress', '.js-wpt-new-taxonomy-title', function
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
});
|
154 |
|
155 |
function setTaxonomy(taxonomy, el)
|
156 |
{
|
157 |
var form = jQuery(el).closest('form');
|
158 |
-
var tmp_tax = jQuery('input[name=tmp_'
|
159 |
-
if (tmp_tax.trim()
|
160 |
-
|
161 |
-
var tax = jQuery('input[name=' + taxonomy + ']', form).val();
|
162 |
var arr = tax.split(',');
|
163 |
-
if (jQuery.inArray(tmp_tax, arr)
|
164 |
-
|
165 |
-
|
166 |
-
jQuery('input[name='
|
167 |
-
jQuery('input[name=tmp_' + taxonomy + ']', form).val('');
|
168 |
updateTaxonomies(taxonomy, form);
|
169 |
}
|
170 |
|
171 |
function updateTaxonomies(taxonomy, form)
|
172 |
{
|
173 |
-
var taxonomies = jQuery('input[name='
|
174 |
-
jQuery('div.tagchecklist-'
|
175 |
-
if (!taxonomies
|
176 |
-
return;
|
177 |
var toshow = taxonomies.split(',');
|
178 |
var str = '';
|
179 |
-
for (var i
|
180 |
var sh = toshow[i].trim();
|
181 |
-
str += '<span><a href="#" class=\'ntdelbutton\' data-wpcf-i=\''
|
182 |
}
|
183 |
-
jQuery('div.tagchecklist-'
|
184 |
-
jQuery('div.tagchecklist-'
|
185 |
-
jQuery('input[name='
|
186 |
del = jQuery(this).data('wpcf-i');
|
187 |
var values = '';
|
188 |
-
for
|
189 |
-
if (del == i) {
|
190 |
continue;
|
191 |
}
|
192 |
-
if (values) {
|
193 |
values += ',';
|
194 |
}
|
195 |
values += toshow[i];
|
196 |
}
|
197 |
-
jQuery('input[name='
|
198 |
updateTaxonomies(taxonomy, form);
|
199 |
|
200 |
return false;
|
@@ -204,272 +193,250 @@ function updateTaxonomies(taxonomy, form)
|
|
204 |
|
205 |
function initTaxonomies(values, taxonomy, url, fieldId)
|
206 |
{
|
207 |
-
form = jQuery('#'
|
208 |
-
jQuery('div.tagchecklist-'
|
209 |
-
|
210 |
-
jQuery('input[name=' + taxonomy + ']').val(values);
|
211 |
updateTaxonomies(taxonomy, form);
|
212 |
-
jQuery('input[name=tmp_'
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
222 |
}
|
223 |
|
224 |
toolsetForms.CRED_taxonomy = function () {
|
225 |
-
|
226 |
var self = this;
|
227 |
-
|
228 |
self.init = function () {
|
229 |
self._new_taxonomy = new Array();
|
230 |
jQuery(document).ready(self._document_ready);
|
231 |
}
|
232 |
-
|
233 |
self._document_ready = function () {
|
234 |
self._initialize_taxonomy_buttons();
|
235 |
self._initialize_hierachical();
|
236 |
}
|
237 |
-
|
238 |
self._initialize_hierachical = function () {
|
239 |
self._fill_parent_drop_down()
|
240 |
}
|
241 |
-
|
242 |
self._fill_parent_drop_down = function () {
|
243 |
-
jQuery('select.js-taxonomy-parent').each(function () {
|
244 |
var select = jQuery(this);
|
245 |
-
|
246 |
// remove all the options
|
247 |
-
jQuery(this).find('option').each(function () {
|
248 |
if (jQuery(this).val() != '-1') {
|
249 |
jQuery(this).remove();
|
250 |
}
|
251 |
})
|
252 |
|
253 |
var taxonomy = jQuery(this).data('taxonomy');
|
254 |
-
|
255 |
// Copy all the checkbox values if it's checkbox mode
|
256 |
-
jQuery('input[name="' + taxonomy + '\[\]"]').each(function () {
|
257 |
var id = jQuery(this).attr('id');
|
258 |
var label = jQuery(this).next('label');
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
select.append('<option value="' + jQuery(this).val() + '">' + prefix + label.text() + '</option>');
|
265 |
})
|
266 |
-
|
267 |
// Copy all the select option values if it's select mode
|
268 |
-
jQuery('select[name="' + taxonomy + '\[\]"]').find('option').each(function () {
|
269 |
var id = jQuery(this).val();
|
270 |
var text = jQuery(this).text();
|
271 |
select.append('<option value="' + id + '">' + text + '</option>');
|
272 |
})
|
273 |
-
|
274 |
-
|
275 |
});
|
276 |
-
|
277 |
}
|
278 |
-
|
279 |
self._initialize_taxonomy_buttons = function () {
|
280 |
// replace the taxonomy button placeholders with the actual buttons.
|
281 |
jQuery('.js-taxonomy-button-placeholder').each(function () {
|
282 |
-
var placeholder = jQuery(this)
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
var taxonomy = jQuery(this).data('taxonomy');
|
287 |
-
var form = jQuery(this).closest('form');
|
288 |
-
var buttons = jQuery('[name="sh_' + taxonomy + '"],[name="btn_' + taxonomy + '"]', form);
|
289 |
-
var selectors = [];
|
290 |
|
291 |
if (buttons.length) {
|
292 |
-
|
293 |
buttons.each(function () {
|
294 |
-
var button = jQuery(this
|
295 |
-
|
296 |
-
//https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/195150507/comments
|
297 |
-
if (label)
|
298 |
-
button.val(label);
|
299 |
-
//##########################################################################################
|
300 |
|
|
|
301 |
placeholder.replaceWith(button);
|
302 |
|
303 |
if (button.hasClass('js-wpt-taxonomy-popular-show-hide')) {
|
304 |
-
if
|
305 |
button.show();
|
306 |
}
|
307 |
} else {
|
308 |
button.show();
|
309 |
}
|
310 |
-
|
311 |
-
// move anything else that should be moved with the button
|
312 |
//Responsible of the issue https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188673095/comments
|
313 |
//changed selector
|
314 |
//var selector = button.data('after-selector');
|
315 |
-
selectors.push(button.data('after-selector'))
|
316 |
if (typeof selector !== 'undefined' && selector.length) {
|
317 |
var position = button;
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
}
|
323 |
})
|
324 |
}
|
325 |
});
|
326 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
} else {
|
332 |
-
jQuery(this).val(jQuery(this).data('close')).addClass('btn-cancel');
|
333 |
-
}
|
334 |
-
var thiz = jQuery(this), taxonomy = thiz.data('taxonomy');
|
335 |
-
self.add_new_show_hide(taxonomy, this);
|
336 |
-
});
|
337 |
|
338 |
-
|
339 |
-
|
340 |
-
jQuery('.js-wpt-hierarchical-taxonomy-add-new-' + taxonomy, form).toggle();
|
341 |
-
self.hide_parent_button_if_no_terms(taxonomy, button);
|
342 |
-
}
|
343 |
|
344 |
-
jQuery(document).on('click', '.js-wpt-hierarchical-taxonomy-add-new', function () {
|
345 |
-
var thiz = jQuery(this),
|
346 |
-
taxonomy = thiz.data('taxonomy');
|
347 |
-
self.add_taxonomy(taxonomy, this);
|
348 |
-
});
|
349 |
-
/*
|
350 |
-
jQuery(document).on('keypress', '.js-wpt-new-taxonomy-title', function(e) {
|
351 |
-
if( 13 === e.keyCode ) {
|
352 |
-
e.preventDefault();
|
353 |
-
var thiz = jQuery(this),
|
354 |
-
taxonomy = thiz.data( 'taxonomy' );
|
355 |
-
self.add_taxonomy( taxonomy, this );
|
356 |
-
}
|
357 |
-
});
|
358 |
-
*/
|
359 |
-
|
360 |
-
self.terms_exist = function (taxonomy, button)
|
361 |
-
{
|
362 |
-
var form = jQuery(button).closest('form');
|
363 |
-
var build_what = jQuery(button).data('build_what'), parent = jQuery('[name="new_tax_select_' + taxonomy + '"]', form).val();
|
364 |
-
if (build_what === 'checkboxes') {
|
365 |
-
var first_checkbox = jQuery('input[name="' + taxonomy + '\[\]"][data-parent="' + parent + '"]:first', form);
|
366 |
return first_checkbox.length > 0;
|
367 |
-
}
|
368 |
-
|
|
|
|
|
|
|
369 |
return first_option.length > 0;
|
370 |
}
|
371 |
|
372 |
return false;
|
373 |
};
|
374 |
|
375 |
-
self.
|
376 |
-
self.hide_parent_button_if_no_terms = function (taxonomy, button)
|
377 |
{
|
378 |
-
|
379 |
-
|
380 |
-
if ('undefined' == typeof self._add_new_flag[form_id]) {
|
381 |
-
self._add_new_flag[form_id] = '';
|
382 |
}
|
383 |
-
|
384 |
-
|
385 |
-
jQuery('[name="new_tax_select_' + taxonomy + '"]'
|
386 |
-
} else {
|
387 |
-
jQuery('[name="new_tax_select_' + taxonomy + '"]', form).show();
|
388 |
}
|
389 |
};
|
390 |
|
391 |
-
self.add_taxonomy = function (taxonomy, button)
|
392 |
-
{
|
393 |
-
var form = jQuery(button).closest('form');
|
394 |
-
var new_taxonomy = jQuery('[name="new_tax_text_' + taxonomy + '"]', form).val();
|
395 |
-
var build_what = jQuery(button).data('build_what');
|
396 |
-
new_taxonomy = new_taxonomy.trim();
|
397 |
|
|
|
|
|
|
|
|
|
398 |
if (new_taxonomy == '') {
|
399 |
return;
|
400 |
}
|
401 |
|
402 |
// make sure we don't already have a taxonomy with the same name.
|
403 |
var exists = false;
|
404 |
-
jQuery('input[name="' + taxonomy + '\[\]"]').each(function () {
|
405 |
var id = jQuery(this).attr('id');
|
406 |
-
var label = jQuery('label[for="' + id + '"]'
|
407 |
-
|
408 |
if (new_taxonomy == label.text()) {
|
409 |
exists = true
|
410 |
self._flash_it(label);
|
411 |
}
|
412 |
});
|
413 |
|
414 |
-
jQuery('select[name="' + taxonomy + '\[\]"]'
|
415 |
if (new_taxonomy == jQuery(this).text()) {
|
416 |
exists = true;
|
417 |
self._flash_it(jQuery(this));
|
418 |
}
|
419 |
});
|
420 |
-
|
421 |
if (exists) {
|
422 |
-
jQuery('[name="new_tax_text_' + taxonomy + '"]'
|
423 |
return;
|
424 |
}
|
425 |
|
426 |
-
var parent = jQuery('[name="new_tax_select_' + taxonomy + '"]'
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
if (build_what === 'checkboxes') {
|
433 |
-
//Fix add new leaf
|
434 |
-
//https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188589136/comments
|
435 |
-
jQuery('div[data-item_name="taxonomyhierarchical-' + taxonomy + '"] li input[type=checkbox]', form).each(function () {
|
436 |
-
if (this.value == parent || this.value == new_taxonomy) {
|
437 |
-
div_fields_wrap = jQuery(this).parent();
|
438 |
-
}
|
439 |
-
});
|
440 |
-
//#########################################################################################
|
441 |
|
|
|
442 |
var new_checkbox = '<li><input data-parent="' + parent + '" class="wpt-form-checkbox form-checkbox checkbox" type="checkbox" name="' + taxonomy + '[]" checked="checked" value="' + new_taxonomy + '"></input><label>' + new_taxonomy + '</label></li>';
|
443 |
-
|
444 |
-
var first_checkbox = jQuery('input[name="' + taxonomy + '\[\]"][data-parent="' + parent + '"]:first'
|
445 |
if (first_checkbox.length == 0) {
|
446 |
// there are no existing brothers
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
new_checkbox = '<ul class="wpt-form-set-children" data-level="' + level + '">' + new_checkbox + '</ul>';
|
452 |
-
|
453 |
//add_before = false;
|
454 |
//add_position = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]').closest('li');
|
455 |
-
|
456 |
} else {
|
457 |
// there are brothers
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
}
|
462 |
-
jQuery('[name="new_tax_select_' + taxonomy + '"]'
|
463 |
-
} else if
|
464 |
// Select control
|
465 |
-
|
466 |
jQuery('select[name="' + taxonomy + '\[\]"]').show();
|
467 |
-
|
468 |
var indent = '';
|
469 |
-
var first_option = jQuery('select[name="' + taxonomy + '\[\]"]').find('option[data-parent="' + parent + '"]:first'
|
470 |
if (first_option.length == 0) {
|
471 |
// there a no children of this parent
|
472 |
-
first_option = jQuery('select[name="' + taxonomy + '\[\]"]').find('option[value="' + parent + '"]:first'
|
473 |
add_before = false;
|
474 |
var label = first_option.text();
|
475 |
for (var i = 0; i < label.length; i++) {
|
@@ -481,7 +448,8 @@ toolsetForms.CRED_taxonomy = function () {
|
|
481 |
}
|
482 |
indent += '\xA0';
|
483 |
indent += '\xA0';
|
484 |
-
add_position = jQuery('select[name="' + taxonomy + '\[\]"]'
|
|
|
485 |
} else {
|
486 |
add_position = first_option;
|
487 |
var label = first_option.text();
|
@@ -493,7 +461,7 @@ toolsetForms.CRED_taxonomy = function () {
|
|
493 |
}
|
494 |
}
|
495 |
}
|
496 |
-
|
497 |
if (add_position) {
|
498 |
var new_option = '<option value="' + new_taxonomy + '" selected>' + indent + new_taxonomy + '</option>';
|
499 |
if (add_before) {
|
@@ -502,68 +470,47 @@ toolsetForms.CRED_taxonomy = function () {
|
|
502 |
jQuery(new_option).appendTo(add_position);
|
503 |
}
|
504 |
}
|
505 |
-
jQuery('[name="new_tax_select_' + taxonomy + '"]'
|
506 |
}
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
|
|
|
|
|
|
512 |
self._fill_parent_drop_down();
|
513 |
-
|
|
|
514 |
}
|
515 |
-
|
516 |
-
self._update_hierachy = function (taxonomy, new_taxonomy
|
517 |
-
var new_taxonomy_input = jQuery('input[name="' + taxonomy + '_hierarchy"]'
|
518 |
if (!new_taxonomy_input.length) {
|
519 |
// add a hidden field for the hierarchy
|
520 |
-
jQuery('<input name="' + taxonomy + '_hierarchy" style="display:none" type="hidden">').insertAfter(jQuery('[name="new_tax_text_' + taxonomy + '"]'
|
521 |
-
new_taxonomy_input = jQuery('input[name="' + taxonomy + '_hierarchy"]'
|
522 |
}
|
523 |
-
|
524 |
-
var parent = jQuery('[name="new_tax_select_' + taxonomy + '"]'
|
525 |
self._new_taxonomy.push(parent + ',' + new_taxonomy);
|
526 |
-
|
527 |
var value = '';
|
528 |
for (var i = 0; i < self._new_taxonomy.length; i++) {
|
529 |
value += '{' + self._new_taxonomy[i] + '}';
|
530 |
}
|
531 |
new_taxonomy_input.val(value);
|
532 |
-
|
533 |
}
|
534 |
-
|
535 |
self._flash_it = function (element) {
|
536 |
element.fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300);
|
537 |
}
|
538 |
-
|
539 |
self.init();
|
540 |
-
|
541 |
}
|
542 |
|
543 |
toolsetForms.cred_tax = new toolsetForms.CRED_taxonomy();
|
544 |
|
545 |
-
//Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188725294/comments
|
546 |
-
//removed return key press
|
547 |
-
jQuery(function () {
|
548 |
-
var keyStop = {
|
549 |
-
8: ":not(input:text, textarea, input:file, input:password)", // stop backspace = back
|
550 |
-
13: "input:text, input:password", // stop enter = submit
|
551 |
-
|
552 |
-
end: null
|
553 |
-
};
|
554 |
-
jQuery(document).bind("keydown", function (event) {
|
555 |
-
var thiz_selector = keyStop[event.which],
|
556 |
-
thiz_target = jQuery(event.target);
|
557 |
-
|
558 |
-
if (
|
559 |
-
thiz_target.closest( "form.cred-form" ).length
|
560 |
-
&& thiz_selector !== undefined
|
561 |
-
&& thiz_target.is(thiz_selector)
|
562 |
-
) {
|
563 |
-
event.preventDefault(); //stop event
|
564 |
-
}
|
565 |
-
|
566 |
-
return true;
|
567 |
-
});
|
568 |
-
});
|
569 |
-
|
8 |
wptCallbacks.conditionalCheck = jQuery.Callbacks('unique');
|
9 |
wptCallbacks.reset = jQuery.Callbacks('unique');
|
10 |
|
11 |
+
jQuery(document).ready(function() {
|
12 |
if (typeof wptValidation !== 'undefined') {
|
13 |
+
wptCallbacks.validationInit.add(function() {
|
14 |
wptValidation.init();
|
15 |
});
|
16 |
}
|
19 |
} else {
|
20 |
wptCallbacks.validationInit.fire();
|
21 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
});
|
23 |
|
24 |
|
35 |
if (typeof wptFilters[name] === 'undefined')
|
36 |
return val;
|
37 |
var args = _.rest(_.toArray(arguments));
|
38 |
+
_.each(wptFilters[name], function(funcs, priority) {
|
39 |
+
_.each(funcs, function($callback) {
|
40 |
var _args = args.slice(0, $callback[1]);
|
41 |
args[0] = $callback[0].apply(null, _args);
|
42 |
});
|
50 |
if (typeof wptFilters[name] === 'undefined')
|
51 |
return false;
|
52 |
var args = _.rest(_.toArray(arguments));
|
53 |
+
_.each(wptFilters[name], function(funcs, priority) {
|
54 |
+
_.each(funcs, function($callback) {
|
55 |
var _args = args.slice(0, $callback[1]);
|
56 |
$callback[0].apply(null, _args);
|
57 |
});
|
62 |
/**
|
63 |
* flat taxonomies functions
|
64 |
*/
|
65 |
+
function showHideMostPopularButton(taxonomy)
|
66 |
{
|
|
|
|
|
|
|
67 |
|
68 |
+
var $button = jQuery('[name="sh_' + taxonomy + '"]')
|
69 |
+
, $taxonomy_box = jQuery('.shmpt-' + taxonomy)
|
70 |
+
, $tag_list = $taxonomy_box.find('.js-wpt-taxonomy-popular-add');
|
71 |
+
|
72 |
+
if( !$button.hasClass('js-wpt-taxonomy-popular-show-hide') ) return true;
|
73 |
|
74 |
+
if( $tag_list.length > 0 )
|
75 |
{
|
76 |
$button.show();
|
77 |
return true;
|
78 |
+
}else{
|
79 |
$button.hide();
|
80 |
return false;
|
81 |
}
|
82 |
}
|
83 |
+
|
84 |
+
jQuery(document).on('click', '.js-wpt-taxonomy-popular-show-hide', function() {
|
85 |
+
showHideMostPopularTaxonomy(this);
|
86 |
});
|
87 |
|
88 |
function showHideMostPopularTaxonomy(el)
|
89 |
{
|
90 |
var taxonomy = jQuery(el).data('taxonomy');
|
91 |
+
jQuery('.shmpt-'+taxonomy, jQuery(el).closest('form')).toggle();
|
|
|
92 |
var curr = jQuery(el).val();
|
93 |
+
if (curr==jQuery(el).data('show-popular-text')) {
|
94 |
+
jQuery(el).val(jQuery(el).data('hide-popular-text'));
|
95 |
} else {
|
96 |
+
jQuery(el).val(jQuery(el).data('show-popular-text'));
|
97 |
}
|
98 |
}
|
99 |
|
100 |
+
jQuery(document).on('click', '.js-wpt-taxonomy-popular-add', function() {
|
101 |
+
var thiz = jQuery(this),
|
102 |
+
taxonomy = thiz.data( 'taxonomy' );
|
103 |
+
slug = thiz.data( 'slug' );
|
104 |
+
_name = thiz.data( 'name' );
|
105 |
+
addTaxonomy(_name, taxonomy, this);
|
106 |
+
return false;
|
107 |
});
|
108 |
|
109 |
function addTaxonomy(slug, taxonomy, el)
|
110 |
{
|
111 |
var form = jQuery(el).closest('form');
|
112 |
+
var curr = jQuery('input[name=tmp_'+taxonomy+']', form).val().trim();
|
113 |
+
if (''==curr) {
|
114 |
+
jQuery('input[name=tmp_'+taxonomy+']', form).val(slug);
|
115 |
setTaxonomy(taxonomy, el);
|
116 |
} else {
|
117 |
+
if (curr.indexOf( slug )==-1) {
|
118 |
+
jQuery('input[name=tmp_'+taxonomy+']', form).val(curr+','+slug);
|
119 |
setTaxonomy(taxonomy, el);
|
120 |
}
|
121 |
}
|
122 |
+
jQuery('input[name=tmp_'+taxonomy+']', form).val('');
|
123 |
+
|
124 |
+
|
125 |
}
|
126 |
|
127 |
+
jQuery(document).on('click', '.js-wpt-taxonomy-add-new', function() {
|
128 |
+
var thiz = jQuery(this),
|
129 |
+
taxonomy = thiz.data( 'taxonomy' );
|
130 |
+
setTaxonomy(taxonomy, this);
|
131 |
});
|
132 |
|
133 |
+
jQuery(document).on('keypress', '.js-wpt-new-taxonomy-title', function(e) {
|
134 |
+
if( 13 === e.keyCode ) {
|
135 |
+
e.preventDefault();
|
136 |
+
var thiz = jQuery(this),
|
137 |
+
taxonomy = thiz.data( 'taxonomy' ),
|
138 |
+
taxtype = thiz.data( 'taxtype' );
|
139 |
+
if ( taxtype == 'hierarchical' ) {
|
140 |
+
toolsetForms.cred_tax.add_taxonomy( taxonomy, this );
|
141 |
+
} else {
|
142 |
+
setTaxonomy(taxonomy, this);
|
143 |
+
}
|
144 |
+
}
|
145 |
+
});
|
146 |
|
147 |
function setTaxonomy(taxonomy, el)
|
148 |
{
|
149 |
var form = jQuery(el).closest('form');
|
150 |
+
var tmp_tax = jQuery('input[name=tmp_'+taxonomy+']', form).val();
|
151 |
+
if (tmp_tax.trim()=='') return;
|
152 |
+
var tax = jQuery('input[name='+taxonomy+']', form).val();
|
|
|
153 |
var arr = tax.split(',');
|
154 |
+
if (jQuery.inArray(tmp_tax, arr)!==-1) return;
|
155 |
+
var toadd = (tax=='') ? tmp_tax : tax+','+tmp_tax;
|
156 |
+
jQuery('input[name='+taxonomy+']', form).val(toadd);
|
157 |
+
jQuery('input[name=tmp_'+taxonomy+']', form).val('');
|
|
|
158 |
updateTaxonomies(taxonomy, form);
|
159 |
}
|
160 |
|
161 |
function updateTaxonomies(taxonomy, form)
|
162 |
{
|
163 |
+
var taxonomies = jQuery('input[name='+taxonomy+']', form).val();
|
164 |
+
jQuery('div.tagchecklist-'+taxonomy, form).html('');
|
165 |
+
if (!taxonomies||(taxonomies&&taxonomies.trim()=='')) return;
|
|
|
166 |
var toshow = taxonomies.split(',');
|
167 |
var str = '';
|
168 |
+
for (var i=0;i<toshow.length;i++) {
|
169 |
var sh = toshow[i].trim();
|
170 |
+
str += '<span><a href="#" class=\'ntdelbutton\' data-wpcf-i=\''+i+'\' id=\'post_tag-check-num-'+i+'\'>X</a> '+sh+'</span>';
|
171 |
}
|
172 |
+
jQuery('div.tagchecklist-'+taxonomy, form).html(str);
|
173 |
+
jQuery('div.tagchecklist-'+taxonomy+' a', form).bind('click', function() {
|
174 |
+
jQuery('input[name='+taxonomy+']', form).val('');
|
175 |
del = jQuery(this).data('wpcf-i');
|
176 |
var values = '';
|
177 |
+
for(i=0;i<toshow.length;i++ ) {
|
178 |
+
if ( del == i ) {
|
179 |
continue;
|
180 |
}
|
181 |
+
if ( values ) {
|
182 |
values += ',';
|
183 |
}
|
184 |
values += toshow[i];
|
185 |
}
|
186 |
+
jQuery('input[name='+taxonomy+']', form).val(values) ;
|
187 |
updateTaxonomies(taxonomy, form);
|
188 |
|
189 |
return false;
|
193 |
|
194 |
function initTaxonomies(values, taxonomy, url, fieldId)
|
195 |
{
|
196 |
+
form = jQuery('#'+fieldId.replace(/_field_\d+$/, '' ) ).closest('form');
|
197 |
+
jQuery('div.tagchecklist-'+taxonomy).html(values);
|
198 |
+
jQuery('input[name='+taxonomy+']').val(values);
|
|
|
199 |
updateTaxonomies(taxonomy, form);
|
200 |
+
jQuery('input[name=tmp_'+taxonomy+']').autocomplete (
|
201 |
+
url+'/external/autocompleter.php',
|
202 |
+
{
|
203 |
+
delay:10,
|
204 |
+
minChars:2,
|
205 |
+
matchSubset:1,
|
206 |
+
matchContains:1,
|
207 |
+
cacheLength:10,
|
208 |
+
formatItem:formatItem,
|
209 |
+
onItemSelect:onSelectItem,
|
210 |
+
autoFill:true
|
211 |
+
}
|
212 |
+
);
|
213 |
}
|
214 |
|
215 |
toolsetForms.CRED_taxonomy = function () {
|
216 |
+
|
217 |
var self = this;
|
218 |
+
|
219 |
self.init = function () {
|
220 |
self._new_taxonomy = new Array();
|
221 |
jQuery(document).ready(self._document_ready);
|
222 |
}
|
223 |
+
|
224 |
self._document_ready = function () {
|
225 |
self._initialize_taxonomy_buttons();
|
226 |
self._initialize_hierachical();
|
227 |
}
|
228 |
+
|
229 |
self._initialize_hierachical = function () {
|
230 |
self._fill_parent_drop_down()
|
231 |
}
|
232 |
+
|
233 |
self._fill_parent_drop_down = function () {
|
234 |
+
jQuery('select.js-taxonomy-parent').each ( function () {
|
235 |
var select = jQuery(this);
|
236 |
+
|
237 |
// remove all the options
|
238 |
+
jQuery(this).find('option').each (function () {
|
239 |
if (jQuery(this).val() != '-1') {
|
240 |
jQuery(this).remove();
|
241 |
}
|
242 |
})
|
243 |
|
244 |
var taxonomy = jQuery(this).data('taxonomy');
|
245 |
+
|
246 |
// Copy all the checkbox values if it's checkbox mode
|
247 |
+
jQuery('input[name="' + taxonomy + '\[\]"]').each (function () {
|
248 |
var id = jQuery(this).attr('id');
|
249 |
var label = jQuery(this).next('label');
|
250 |
+
var level = jQuery(this).closest('ul').data('level');
|
251 |
+
var prefix = '';
|
252 |
+
if ( level ) {
|
253 |
+
prefix = "\xA0\xA0" + Array(level).join("\xA0\xA0");
|
254 |
+
}
|
255 |
select.append('<option value="' + jQuery(this).val() + '">' + prefix + label.text() + '</option>');
|
256 |
})
|
257 |
+
|
258 |
// Copy all the select option values if it's select mode
|
259 |
+
jQuery('select[name="' + taxonomy + '\[\]"]').find('option').each (function () {
|
260 |
var id = jQuery(this).val();
|
261 |
var text = jQuery(this).text();
|
262 |
select.append('<option value="' + id + '">' + text + '</option>');
|
263 |
})
|
264 |
+
|
265 |
+
|
266 |
});
|
267 |
+
|
268 |
}
|
269 |
+
|
270 |
self._initialize_taxonomy_buttons = function () {
|
271 |
// replace the taxonomy button placeholders with the actual buttons.
|
272 |
jQuery('.js-taxonomy-button-placeholder').each(function () {
|
273 |
+
var placeholder = jQuery(this),
|
274 |
+
taxonomy = jQuery(this).data('taxonomy'),
|
275 |
+
buttons = jQuery('[name="sh_' + taxonomy + '"],[name="btn_' + taxonomy + '"]'),
|
276 |
+
selectors = [];
|
|
|
|
|
|
|
|
|
277 |
|
278 |
if (buttons.length) {
|
279 |
+
|
280 |
buttons.each(function () {
|
281 |
+
var button = jQuery(this);
|
|
|
|
|
|
|
|
|
|
|
282 |
|
283 |
+
button.detach();
|
284 |
placeholder.replaceWith(button);
|
285 |
|
286 |
if (button.hasClass('js-wpt-taxonomy-popular-show-hide')) {
|
287 |
+
if( showHideMostPopularButton(taxonomy) ) {
|
288 |
button.show();
|
289 |
}
|
290 |
} else {
|
291 |
button.show();
|
292 |
}
|
293 |
+
|
294 |
+
// move anything else that should be moved with the button
|
295 |
//Responsible of the issue https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188673095/comments
|
296 |
//changed selector
|
297 |
//var selector = button.data('after-selector');
|
298 |
+
selectors.push( button.data('after-selector') )
|
299 |
if (typeof selector !== 'undefined' && selector.length) {
|
300 |
var position = button;
|
301 |
+
jQuery('.' + selectors[0]).detach();
|
302 |
+
jQuery('.' + selectors[0]).insertAfter(button);
|
303 |
+
position = jQuery('.' + selectors[0]);
|
304 |
+
selectors.pop();
|
305 |
}
|
306 |
})
|
307 |
}
|
308 |
});
|
309 |
+
}
|
310 |
+
|
311 |
+
jQuery(document).on('click', '.js-wpt-hierarchical-taxonomy-add-new-show-hide', function() {
|
312 |
+
var thiz = jQuery(this),
|
313 |
+
taxonomy = thiz.data( 'taxonomy' );
|
314 |
+
self.add_new_show_hide( taxonomy, this );
|
315 |
+
});
|
316 |
+
|
317 |
+
self.add_new_show_hide = function ( taxonomy, button ) {
|
318 |
+
jQuery('.js-wpt-hierarchical-taxonomy-add-new-' + taxonomy).toggle();
|
319 |
+
self.hide_parent_button_if_no_terms( taxonomy, button );
|
320 |
+
}
|
321 |
+
|
322 |
+
jQuery(document).on('click', '.js-wpt-hierarchical-taxonomy-add-new', function() {
|
323 |
+
var thiz = jQuery(this),
|
324 |
+
taxonomy = thiz.data( 'taxonomy' );
|
325 |
+
|
326 |
+
self.add_taxonomy( taxonomy, this );
|
327 |
+
});
|
328 |
+
/*
|
329 |
+
jQuery(document).on('keypress', '.js-wpt-new-taxonomy-title', function(e) {
|
330 |
+
if( 13 === e.keyCode ) {
|
331 |
+
e.preventDefault();
|
332 |
+
var thiz = jQuery(this),
|
333 |
+
taxonomy = thiz.data( 'taxonomy' );
|
334 |
+
self.add_taxonomy( taxonomy, this );
|
335 |
+
}
|
336 |
+
});
|
337 |
+
*/
|
338 |
|
339 |
+
self.terms_exist = function( taxonomy, button )
|
340 |
+
{
|
341 |
+
var build_what = jQuery(button).data('build_what'), parent = jQuery('[name="new_tax_select_' + taxonomy + '"]').val();
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
|
343 |
+
if ( build_what === 'checkboxes' ){
|
344 |
+
var first_checkbox = jQuery('input[name="' + taxonomy + '\[\]"][data-parent="' + parent + '"]:first');
|
|
|
|
|
|
|
345 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
return first_checkbox.length > 0;
|
347 |
+
}
|
348 |
+
else
|
349 |
+
{
|
350 |
+
var first_option = jQuery('select[name="' + taxonomy + '\[\]"]').find('option[data-parent="' + parent + '"]:first');
|
351 |
+
|
352 |
return first_option.length > 0;
|
353 |
}
|
354 |
|
355 |
return false;
|
356 |
};
|
357 |
|
358 |
+
self.hide_parent_button_if_no_terms = function( taxonomy, button )
|
|
|
359 |
{
|
360 |
+
if( self.terms_exist(taxonomy, button) === false ){
|
361 |
+
jQuery('[name="new_tax_select_' + taxonomy + '"]').hide();
|
|
|
|
|
362 |
}
|
363 |
+
else
|
364 |
+
{
|
365 |
+
jQuery('[name="new_tax_select_' + taxonomy + '"]').show();
|
|
|
|
|
366 |
}
|
367 |
};
|
368 |
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
|
370 |
+
self.add_taxonomy = function ( taxonomy, button ) {
|
371 |
+
var new_taxonomy = jQuery('[name="new_tax_text_' + taxonomy + '"]').val()
|
372 |
+
, build_what = jQuery(button).data('build_what');
|
373 |
+
new_taxonomy = new_taxonomy.trim()
|
374 |
if (new_taxonomy == '') {
|
375 |
return;
|
376 |
}
|
377 |
|
378 |
// make sure we don't already have a taxonomy with the same name.
|
379 |
var exists = false;
|
380 |
+
jQuery('input[name="' + taxonomy + '\[\]"]').each (function () {
|
381 |
var id = jQuery(this).attr('id');
|
382 |
+
var label = jQuery('label[for="' + id + '"]');
|
383 |
+
|
384 |
if (new_taxonomy == label.text()) {
|
385 |
exists = true
|
386 |
self._flash_it(label);
|
387 |
}
|
388 |
});
|
389 |
|
390 |
+
jQuery('select[name="' + taxonomy + '\[\]"]').find('option').each (function () {
|
391 |
if (new_taxonomy == jQuery(this).text()) {
|
392 |
exists = true;
|
393 |
self._flash_it(jQuery(this));
|
394 |
}
|
395 |
});
|
396 |
+
|
397 |
if (exists) {
|
398 |
+
jQuery('[name="new_tax_text_' + taxonomy + '"]').val('');
|
399 |
return;
|
400 |
}
|
401 |
|
402 |
+
var parent = jQuery('[name="new_tax_select_' + taxonomy + '"]').val(),
|
403 |
+
add_position = null,
|
404 |
+
add_before = true,
|
405 |
+
div_fields_wrap = jQuery('div[data-item_name="taxonomyhierarchical-'+taxonomy+'"]'),
|
406 |
+
level = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
|
408 |
+
if ( build_what === 'checkboxes' ){
|
409 |
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>';
|
410 |
+
// find the first checkbox sharing parent
|
411 |
+
var first_checkbox = jQuery('input[name="' + taxonomy + '\[\]"][data-parent="' + parent + '"]:first');
|
412 |
if (first_checkbox.length == 0) {
|
413 |
// there are no existing brothers
|
414 |
+
// so we need to compose the ul wrapper and append to the parent li
|
415 |
+
//add_position = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]').closest('li');
|
416 |
+
level = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]').closest('ul').data( 'level' );
|
417 |
+
level++;
|
418 |
new_checkbox = '<ul class="wpt-form-set-children" data-level="' + level + '">' + new_checkbox + '</ul>';
|
419 |
+
//first_checkbox = ;
|
420 |
//add_before = false;
|
421 |
//add_position = jQuery('input[name="' + taxonomy + '\[\]"][value="' + parent + '"]').closest('li');
|
422 |
+
jQuery(new_checkbox).appendTo( div_fields_wrap );
|
423 |
} else {
|
424 |
// there are brothers
|
425 |
+
// so we need to insert before all of them
|
426 |
+
add_position = first_checkbox.closest('li');
|
427 |
+
jQuery(new_checkbox).insertBefore(add_position);
|
428 |
}
|
429 |
+
jQuery('[name="new_tax_select_' + taxonomy + '"]').show();
|
430 |
+
} else if( build_what === 'select' ) {
|
431 |
// Select control
|
432 |
+
|
433 |
jQuery('select[name="' + taxonomy + '\[\]"]').show();
|
434 |
+
|
435 |
var indent = '';
|
436 |
+
var first_option = jQuery('select[name="' + taxonomy + '\[\]"]').find('option[data-parent="' + parent + '"]:first');
|
437 |
if (first_option.length == 0) {
|
438 |
// there a no children of this parent
|
439 |
+
first_option = jQuery('select[name="' + taxonomy + '\[\]"]').find('option[value="' + parent + '"]:first');
|
440 |
add_before = false;
|
441 |
var label = first_option.text();
|
442 |
for (var i = 0; i < label.length; i++) {
|
448 |
}
|
449 |
indent += '\xA0';
|
450 |
indent += '\xA0';
|
451 |
+
add_position = jQuery('select[name="' + taxonomy + '\[\]"]');
|
452 |
+
|
453 |
} else {
|
454 |
add_position = first_option;
|
455 |
var label = first_option.text();
|
461 |
}
|
462 |
}
|
463 |
}
|
464 |
+
|
465 |
if (add_position) {
|
466 |
var new_option = '<option value="' + new_taxonomy + '" selected>' + indent + new_taxonomy + '</option>';
|
467 |
if (add_before) {
|
470 |
jQuery(new_option).appendTo(add_position);
|
471 |
}
|
472 |
}
|
473 |
+
jQuery('[name="new_tax_select_' + taxonomy + '"]').show()
|
474 |
}
|
475 |
+
|
476 |
+
|
477 |
+
|
478 |
+
|
479 |
+
self._update_hierachy(taxonomy, new_taxonomy);
|
480 |
+
|
481 |
+
jQuery('[name="new_tax_text_' + taxonomy + '"]').val('');
|
482 |
+
|
483 |
self._fill_parent_drop_down();
|
484 |
+
|
485 |
+
|
486 |
}
|
487 |
+
|
488 |
+
self._update_hierachy = function (taxonomy, new_taxonomy) {
|
489 |
+
var new_taxonomy_input = jQuery('input[name="' + taxonomy + '_hierarchy"]');
|
490 |
if (!new_taxonomy_input.length) {
|
491 |
// add a hidden field for the hierarchy
|
492 |
+
jQuery('<input name="' + taxonomy + '_hierarchy" style="display:none" type="hidden">').insertAfter(jQuery('[name="new_tax_text_' + taxonomy + '"]'));
|
493 |
+
new_taxonomy_input = jQuery('input[name="' + taxonomy + '_hierarchy"]');
|
494 |
}
|
495 |
+
|
496 |
+
var parent = jQuery('[name="new_tax_select_' + taxonomy + '"]').val();
|
497 |
self._new_taxonomy.push(parent + ',' + new_taxonomy);
|
498 |
+
|
499 |
var value = '';
|
500 |
for (var i = 0; i < self._new_taxonomy.length; i++) {
|
501 |
value += '{' + self._new_taxonomy[i] + '}';
|
502 |
}
|
503 |
new_taxonomy_input.val(value);
|
504 |
+
|
505 |
}
|
506 |
+
|
507 |
self._flash_it = function (element) {
|
508 |
element.fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300);
|
509 |
}
|
510 |
+
|
511 |
self.init();
|
512 |
+
|
513 |
}
|
514 |
|
515 |
toolsetForms.cred_tax = new toolsetForms.CRED_taxonomy();
|
516 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/toolset-forms/js/repetitive.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
/*
|
2 |
* Repetitive JS.
|
3 |
*
|
4 |
-
* $HeadURL:
|
5 |
-
* $LastChangedDate: 2014-
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
var wptRep = (function($) {
|
1 |
/*
|
2 |
* Repetitive JS.
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/js/repetitive.js $
|
5 |
+
* $LastChangedDate: 2014-08-06 16:48:27 +0200 (Wed, 06 Aug 2014) $
|
6 |
+
* $LastChangedRevision: 25705 $
|
7 |
+
* $LastChangedBy: juan $
|
8 |
*
|
9 |
*/
|
10 |
var wptRep = (function($) {
|
embedded/common/toolset-forms/js/skype.js
CHANGED
@@ -11,7 +11,7 @@ var wptSkype = (function($) {
|
|
11 |
$('.js-wpt-skypename-popup', $popup).val($skypename.val());
|
12 |
$('[name="wpt-skypestyle-popup"][value="' + $style.val() + '"]', $popup)
|
13 |
.attr('checked', true);
|
14 |
-
tb_show(wptSkypeData.title, "#TB_inline?inlineId=tpl-wpt-skype-edit-button
|
15 |
});
|
16 |
$('#wpt-skype-edit-button-popup').on('click', '.js-wpt-close-thickbox', function() {
|
17 |
$skypename.val($('.js-wpt-skypename-popup', $popup).val());
|
@@ -26,4 +26,4 @@ var wptSkype = (function($) {
|
|
26 |
};
|
27 |
})(jQuery);
|
28 |
|
29 |
-
jQuery(document).ready(wptSkype.init);
|
11 |
$('.js-wpt-skypename-popup', $popup).val($skypename.val());
|
12 |
$('[name="wpt-skypestyle-popup"][value="' + $style.val() + '"]', $popup)
|
13 |
.attr('checked', true);
|
14 |
+
tb_show(wptSkypeData.title, "#TB_inline?inlineId=tpl-wpt-skype-edit-button", "");
|
15 |
});
|
16 |
$('#wpt-skype-edit-button-popup').on('click', '.js-wpt-close-thickbox', function() {
|
17 |
$skypename.val($('.js-wpt-skypename-popup', $popup).val());
|
26 |
};
|
27 |
})(jQuery);
|
28 |
|
29 |
+
jQuery(document).ready(wptSkype.init);
|
embedded/common/toolset-forms/js/validation.js
CHANGED
@@ -7,10 +7,10 @@
|
|
7 |
*
|
8 |
* @see class WPToolset_Validation
|
9 |
*
|
10 |
-
* $HeadURL:
|
11 |
-
* $LastChangedDate:
|
12 |
-
* $LastChangedRevision:
|
13 |
-
* $LastChangedBy:
|
14 |
*
|
15 |
*/
|
16 |
//var wptValidationData = {};
|
@@ -25,63 +25,6 @@ var wptValidation = (function($) {
|
|
25 |
param = typeof param === "string" ? param.replace(/,/g, "|") : param;
|
26 |
return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
|
27 |
});
|
28 |
-
|
29 |
-
/**
|
30 |
-
* add hexadecimal to validator method
|
31 |
-
*/
|
32 |
-
$.validator.addMethod("hexadecimal", function(value, element, param) {
|
33 |
-
return value=="" || /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(value);
|
34 |
-
});
|
35 |
-
|
36 |
-
/**
|
37 |
-
* add skype to validator method
|
38 |
-
*/
|
39 |
-
$.validator.addMethod("skype", function(value, element, param) {
|
40 |
-
return value=="" || /^([a-z0-9\.\_\,\-\#]+)$/i.test(value);
|
41 |
-
});
|
42 |
-
|
43 |
-
/**
|
44 |
-
* add extension to validator method require
|
45 |
-
*/
|
46 |
-
$.validator.addMethod("required", function(value, element, param) {
|
47 |
-
// check if dependency is met
|
48 |
-
if ( !this.depend(param, element) )
|
49 |
-
return "dependency-mismatch";
|
50 |
-
|
51 |
-
switch( element.nodeName.toLowerCase() ) {
|
52 |
-
case 'select':
|
53 |
-
var val = $(element).val();
|
54 |
-
//Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/189231348/comments
|
55 |
-
// we have data-types-value that in select contains the exactly value
|
56 |
-
$(element).find('option').each(function(index, option){
|
57 |
-
if ($(option).val()==value) {
|
58 |
-
//if $(option).data('typesValue') is undefined i am in backend side
|
59 |
-
val = ($(option).data('typesValue')!=undefined)?$(option).data('typesValue'):val;
|
60 |
-
return;
|
61 |
-
}
|
62 |
-
});
|
63 |
-
//#########################################################################
|
64 |
-
return val && $.trim(val).length > 0;
|
65 |
-
case 'input':
|
66 |
-
// if (jQuery(element).hasClass("hasDatepicker")) {
|
67 |
-
// element = jQuery(element).siblings( 'input[type="hidden"]' );
|
68 |
-
// value = element.val();
|
69 |
-
// element = element[0];
|
70 |
-
// console.log(value+" -> "+this.getLength(value, element));
|
71 |
-
// return this.getLength(value, element) > 0;
|
72 |
-
// }
|
73 |
-
|
74 |
-
if (jQuery(element).hasClass("hasDatepicker")) {
|
75 |
-
return false;
|
76 |
-
}
|
77 |
-
|
78 |
-
if ( this.checkable(element) )
|
79 |
-
return this.getLength(value, element) > 0;
|
80 |
-
default:
|
81 |
-
return $.trim(value).length > 0;
|
82 |
-
}
|
83 |
-
});
|
84 |
-
|
85 |
/**
|
86 |
* Add validation method for datepicker adodb_xxx format for date fields
|
87 |
*/
|
@@ -171,7 +114,7 @@ var wptValidation = (function($) {
|
|
171 |
var _rule = {messages: {}};
|
172 |
_rule[rule] = value.args;
|
173 |
if (value.message !== 'undefined') {
|
174 |
-
_rule.messages[rule] = value.message;
|
175 |
}
|
176 |
element.rules('add', _rule);
|
177 |
element.addClass('js-wpt-validate');
|
7 |
*
|
8 |
* @see class WPToolset_Validation
|
9 |
*
|
10 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/js/validation.js $
|
11 |
+
* $LastChangedDate: 2014-08-26 14:34:10 +0200 (Tue, 26 Aug 2014) $
|
12 |
+
* $LastChangedRevision: 26451 $
|
13 |
+
* $LastChangedBy: francesco $
|
14 |
*
|
15 |
*/
|
16 |
//var wptValidationData = {};
|
25 |
param = typeof param === "string" ? param.replace(/,/g, "|") : param;
|
26 |
return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
|
27 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
/**
|
29 |
* Add validation method for datepicker adodb_xxx format for date fields
|
30 |
*/
|
114 |
var _rule = {messages: {}};
|
115 |
_rule[rule] = value.args;
|
116 |
if (value.message !== 'undefined') {
|
117 |
+
_rule.messages[rule] = value.message;
|
118 |
}
|
119 |
element.rules('add', _rule);
|
120 |
element.addClass('js-wpt-validate');
|
embedded/common/toolset-forms/lib/CakePHP-Validation.php
CHANGED
@@ -29,7 +29,8 @@
|
|
29 |
* @since CakePHP v 1.2.0.3830
|
30 |
*/
|
31 |
//class Validation extends Object {
|
32 |
-
class WPToolset_Cake_Validation
|
|
|
33 |
|
34 |
/**
|
35 |
* Set the value of methods $check param.
|
@@ -55,7 +56,7 @@ class WPToolset_Cake_Validation {
|
|
55 |
* @access private
|
56 |
*/
|
57 |
var $__pattern = array(
|
58 |
-
'hostname' => '(?:[
|
59 |
);
|
60 |
|
61 |
/**
|
@@ -102,7 +103,7 @@ class WPToolset_Cake_Validation {
|
|
102 |
function &getInstance() {
|
103 |
static $instance = array();
|
104 |
|
105 |
-
if (!$instance) {
|
106 |
$instance[0] = new WPToolset_Cake_Validation();
|
107 |
}
|
108 |
return $instance[0];
|
@@ -120,33 +121,22 @@ class WPToolset_Cake_Validation {
|
|
120 |
* @return boolean Success
|
121 |
* @access public
|
122 |
*/
|
123 |
-
function notEmpty($check) {
|
124 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
125 |
$_this->__reset();
|
126 |
$_this->check = $check;
|
127 |
|
128 |
-
if (is_array($check)) {
|
129 |
-
$_this->_extract($check);
|
130 |
}
|
131 |
|
132 |
-
if (empty($_this->check) && $_this->check != '0') {
|
133 |
return false;
|
134 |
}
|
135 |
$_this->regex = '/[^\s]+/m';
|
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 |
*
|
@@ -159,22 +149,22 @@ class WPToolset_Cake_Validation {
|
|
159 |
* @return boolean Success
|
160 |
* @access public
|
161 |
*/
|
162 |
-
function alphaNumeric($check) {
|
163 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
164 |
$_this->__reset();
|
165 |
$_this->check = $check;
|
166 |
|
167 |
-
if (is_array($check)) {
|
168 |
-
$_this->_extract($check);
|
169 |
}
|
170 |
|
171 |
-
if (empty($_this->check) && $_this->check != '0') {
|
172 |
return false;
|
173 |
}
|
174 |
$_this->regex = '/^[a-zA-Z0-9]*$/mu';
|
175 |
$return = $_this->_check();
|
176 |
|
177 |
-
if (!$return) {
|
178 |
$_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/mu';
|
179 |
$return = $_this->_check();
|
180 |
}
|
@@ -182,22 +172,22 @@ class WPToolset_Cake_Validation {
|
|
182 |
return $_this->_check();
|
183 |
}
|
184 |
|
185 |
-
function alphaNumericWhitespaces($check) {
|
186 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
187 |
$_this->__reset();
|
188 |
$_this->check = $check;
|
189 |
|
190 |
-
if (is_array($check)) {
|
191 |
-
$_this->_extract($check);
|
192 |
}
|
193 |
|
194 |
-
if (empty($_this->check) && $_this->check != '0') {
|
195 |
return false;
|
196 |
}
|
197 |
$_this->regex = '/^[a-zA-Z0-9\s\-\_]*$/mu';
|
198 |
$return = $_this->_check();
|
199 |
|
200 |
-
if (!$return) {
|
201 |
$_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}\s\-\_]+$/mu';
|
202 |
$return = $_this->_check();
|
203 |
}
|
@@ -216,8 +206,8 @@ class WPToolset_Cake_Validation {
|
|
216 |
* @return boolean Success
|
217 |
* @access public
|
218 |
*/
|
219 |
-
function between($check, $min, $max) {
|
220 |
-
$length = strlen($check);
|
221 |
return ($length >= $min && $length <= $max);
|
222 |
}
|
223 |
|
@@ -232,13 +222,13 @@ class WPToolset_Cake_Validation {
|
|
232 |
* @return boolean Success
|
233 |
* @access public
|
234 |
*/
|
235 |
-
function blank($check) {
|
236 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
237 |
$_this->__reset();
|
238 |
$_this->check = $check;
|
239 |
|
240 |
-
if (is_array($check)) {
|
241 |
-
$_this->_extract($check);
|
242 |
}
|
243 |
|
244 |
$_this->regex = '/[^\\s]/';
|
@@ -259,7 +249,7 @@ class WPToolset_Cake_Validation {
|
|
259 |
* @access public
|
260 |
* @see WPToolset_Cake_Validation::_luhn()
|
261 |
*/
|
262 |
-
function cc($check, $type = 'fast', $deep = false, $regex = null) {
|
263 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
264 |
$_this->__reset();
|
265 |
$_this->check = $check;
|
@@ -267,17 +257,17 @@ class WPToolset_Cake_Validation {
|
|
267 |
$_this->deep = $deep;
|
268 |
$_this->regex = $regex;
|
269 |
|
270 |
-
if (is_array($check)) {
|
271 |
-
$_this->_extract($check);
|
272 |
}
|
273 |
-
$_this->check = str_replace(array('-', ' '), '', $_this->check);
|
274 |
|
275 |
-
if (strlen($_this->check) < 13) {
|
276 |
return false;
|
277 |
}
|
278 |
|
279 |
-
if (!is_null($_this->regex)) {
|
280 |
-
if ($_this->_check()) {
|
281 |
return $_this->_luhn();
|
282 |
}
|
283 |
}
|
@@ -300,26 +290,26 @@ class WPToolset_Cake_Validation {
|
|
300 |
'fast' => '/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/'
|
301 |
);
|
302 |
|
303 |
-
if (is_array($_this->type)) {
|
304 |
-
foreach ($_this->type as $value) {
|
305 |
-
$_this->regex = $cards['all'][strtolower($value)];
|
306 |
|
307 |
-
if ($_this->_check()) {
|
308 |
return $_this->_luhn();
|
309 |
}
|
310 |
}
|
311 |
-
} elseif ($_this->type == 'all') {
|
312 |
-
foreach ($cards['all'] as $value) {
|
313 |
$_this->regex = $value;
|
314 |
|
315 |
-
if ($_this->_check()) {
|
316 |
return $_this->_luhn();
|
317 |
}
|
318 |
}
|
319 |
} else {
|
320 |
$_this->regex = $cards['fast'];
|
321 |
|
322 |
-
if ($_this->_check()) {
|
323 |
return $_this->_luhn();
|
324 |
}
|
325 |
}
|
@@ -337,52 +327,54 @@ class WPToolset_Cake_Validation {
|
|
337 |
* @return boolean Success
|
338 |
* @access public
|
339 |
*/
|
340 |
-
function comparison($check1, $operator = null, $check2 = null) {
|
341 |
-
if (is_array($check1)) {
|
342 |
-
extract($check1, EXTR_OVERWRITE);
|
343 |
}
|
344 |
-
$operator = str_replace(array(' ', "\t", "\n", "\r", "\0", "\x0B"), '',
|
|
|
345 |
|
346 |
-
switch ($operator) {
|
347 |
case 'isgreater':
|
348 |
case '>':
|
349 |
-
if ($check1 > $check2) {
|
350 |
return true;
|
351 |
}
|
352 |
break;
|
353 |
case 'isless':
|
354 |
case '<':
|
355 |
-
if ($check1 < $check2) {
|
356 |
return true;
|
357 |
}
|
358 |
break;
|
359 |
case 'greaterorequal':
|
360 |
case '>=':
|
361 |
-
if ($check1 >= $check2) {
|
362 |
return true;
|
363 |
}
|
364 |
break;
|
365 |
case 'lessorequal':
|
366 |
case '<=':
|
367 |
-
if ($check1 <= $check2) {
|
368 |
return true;
|
369 |
}
|
370 |
break;
|
371 |
case 'equalto':
|
372 |
case '==':
|
373 |
-
if ($check1 == $check2) {
|
374 |
return true;
|
375 |
}
|
376 |
break;
|
377 |
case 'notequal':
|
378 |
case '!=':
|
379 |
-
if ($check1 != $check2) {
|
380 |
return true;
|
381 |
}
|
382 |
break;
|
383 |
default:
|
384 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
385 |
-
$_this->errors[] = __('You must define the $operator parameter for WPToolset_Cake_Validation::comparison()',
|
|
|
386 |
break;
|
387 |
}
|
388 |
return false;
|
@@ -397,16 +389,17 @@ class WPToolset_Cake_Validation {
|
|
397 |
* @return boolean Success
|
398 |
* @access public
|
399 |
*/
|
400 |
-
function custom($check, $regex = null) {
|
401 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
402 |
$_this->__reset();
|
403 |
$_this->check = $check;
|
404 |
$_this->regex = $regex;
|
405 |
-
if (is_array($check)) {
|
406 |
-
$_this->_extract($check);
|
407 |
}
|
408 |
-
if ($_this->regex === null) {
|
409 |
-
$_this->errors[] = __('You must define a regular expression for WPToolset_Cake_Validation::custom()',
|
|
|
410 |
return false;
|
411 |
}
|
412 |
return $_this->_check();
|
@@ -429,13 +422,13 @@ class WPToolset_Cake_Validation {
|
|
429 |
* @return boolean Success
|
430 |
* @access public
|
431 |
*/
|
432 |
-
function date($check, $format = 'ymd', $regex = null) {
|
433 |
-
|
434 |
-
if (is_numeric($check)) {
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
$valid = wptoolset_strtotime($check);
|
439 |
return $valid !== false;
|
440 |
|
441 |
$cake_date_formats = array('F j, Y' => 'Mdy',
|
@@ -450,7 +443,7 @@ class WPToolset_Cake_Validation {
|
|
450 |
$_this->check = $check;
|
451 |
$_this->regex = $regex;
|
452 |
|
453 |
-
if (!is_null($_this->regex)) {
|
454 |
return $_this->_check();
|
455 |
}
|
456 |
|
@@ -462,11 +455,11 @@ class WPToolset_Cake_Validation {
|
|
462 |
$regex['My'] = '%^(Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)[ /]((1[6-9]|[2-9]\\d)\\d{2})$%';
|
463 |
$regex['my'] = '%^(((0[123456789]|10|11|12)([- /.])(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))))$%';
|
464 |
|
465 |
-
$format = (is_array($format)) ? array_values($format) : array($format);
|
466 |
-
foreach ($format as $key) {
|
467 |
$_this->regex = $regex[$key];
|
468 |
|
469 |
-
if ($_this->_check() === true) {
|
470 |
return true;
|
471 |
}
|
472 |
}
|
@@ -482,7 +475,7 @@ class WPToolset_Cake_Validation {
|
|
482 |
* @return boolean Success
|
483 |
* @access public
|
484 |
*/
|
485 |
-
function time($check) {
|
486 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
487 |
$_this->__reset();
|
488 |
$_this->check = $check;
|
@@ -497,9 +490,9 @@ class WPToolset_Cake_Validation {
|
|
497 |
* @return boolean Success
|
498 |
* @access public
|
499 |
*/
|
500 |
-
function boolean($check) {
|
501 |
$booleanList = array(0, 1, '0', '1', true, false);
|
502 |
-
return in_array($check, $booleanList, true);
|
503 |
}
|
504 |
|
505 |
/**
|
@@ -512,14 +505,14 @@ class WPToolset_Cake_Validation {
|
|
512 |
* @return boolean Success
|
513 |
* @access public
|
514 |
*/
|
515 |
-
function decimal($check, $places = null, $regex = null) {
|
516 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
517 |
$_this->__reset();
|
518 |
$_this->regex = $regex;
|
519 |
$_this->check = $check;
|
520 |
|
521 |
-
if (is_null($_this->regex)) {
|
522 |
-
if (is_null($places)) {
|
523 |
$_this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?$/';
|
524 |
} else {
|
525 |
$_this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]{' . $places . '}$/';
|
@@ -537,34 +530,35 @@ class WPToolset_Cake_Validation {
|
|
537 |
* @return boolean Success
|
538 |
* @access public
|
539 |
*/
|
540 |
-
function email($check, $deep = false, $regex = null) {
|
541 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
542 |
$_this->__reset();
|
543 |
$_this->check = $check;
|
544 |
$_this->regex = $regex;
|
545 |
$_this->deep = $deep;
|
546 |
|
547 |
-
if (is_array($check)) {
|
548 |
-
$_this->_extract($check);
|
549 |
}
|
550 |
|
551 |
-
if (is_null($_this->regex)) {
|
552 |
$_this->regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . $_this->__pattern['hostname'] . '$/i';
|
553 |
}
|
554 |
$return = $_this->_check();
|
555 |
|
556 |
-
if ($_this->deep === false || $_this->deep === null) {
|
557 |
return $return;
|
558 |
}
|
559 |
|
560 |
-
if ($return === true && preg_match('/@(' . $_this->__pattern['hostname'] . ')$/i',
|
561 |
-
|
|
|
562 |
return true;
|
563 |
}
|
564 |
-
if (function_exists('checkdnsrr') && checkdnsrr($regs[1], 'MX')) {
|
565 |
return true;
|
566 |
}
|
567 |
-
return is_array(gethostbynamel($regs[1]));
|
568 |
}
|
569 |
return false;
|
570 |
}
|
@@ -577,7 +571,7 @@ class WPToolset_Cake_Validation {
|
|
577 |
* @return boolean Success
|
578 |
* @access public
|
579 |
*/
|
580 |
-
function equalTo($check, $comparedTo) {
|
581 |
return ($check === $comparedTo);
|
582 |
}
|
583 |
|
@@ -589,21 +583,14 @@ class WPToolset_Cake_Validation {
|
|
589 |
* @return boolean Success
|
590 |
* @access public
|
591 |
*/
|
592 |
-
function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) {
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
if (!is_array($extensions)) {
|
601 |
-
$extensions = explode('|', $extensions);
|
602 |
-
}
|
603 |
-
$check = strtolower($check);
|
604 |
-
$extension = pathinfo($check, PATHINFO_EXTENSION);
|
605 |
-
foreach ($extensions as $value) {
|
606 |
-
if ($extension == strtolower($value)) {
|
607 |
return true;
|
608 |
}
|
609 |
}
|
@@ -623,15 +610,15 @@ class WPToolset_Cake_Validation {
|
|
623 |
* @return boolean Success
|
624 |
* @access public
|
625 |
*/
|
626 |
-
function ip($check, $type = 'both') {
|
627 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
628 |
$success = false;
|
629 |
-
$type = strtolower($type);
|
630 |
-
if ($type === 'ipv4' || $type === 'both') {
|
631 |
-
$success |= $_this->_ipv4($check);
|
632 |
}
|
633 |
-
if ($type === 'ipv6' || $type === 'both') {
|
634 |
-
$success |= $_this->_ipv6($check);
|
635 |
}
|
636 |
return $success;
|
637 |
}
|
@@ -643,9 +630,10 @@ class WPToolset_Cake_Validation {
|
|
643 |
* @return boolean Success
|
644 |
* @access protected
|
645 |
*/
|
646 |
-
function _ipv4($check) {
|
647 |
-
if (function_exists('filter_var')) {
|
648 |
-
return filter_var($check, FILTER_VALIDATE_IP,
|
|
|
649 |
}
|
650 |
$this->__populateIp();
|
651 |
$this->check = $check;
|
@@ -660,9 +648,10 @@ class WPToolset_Cake_Validation {
|
|
660 |
* @return boolean Success
|
661 |
* @access protected
|
662 |
*/
|
663 |
-
function _ipv6($check) {
|
664 |
-
if (function_exists('filter_var')) {
|
665 |
-
return filter_var($check, FILTER_VALIDATE_IP,
|
|
|
666 |
}
|
667 |
$this->__populateIp();
|
668 |
$this->check = $check;
|
@@ -678,8 +667,8 @@ class WPToolset_Cake_Validation {
|
|
678 |
* @return boolean Success
|
679 |
* @access public
|
680 |
*/
|
681 |
-
function minLength($check, $min) {
|
682 |
-
$length = strlen($check);
|
683 |
return ($length >= $min);
|
684 |
}
|
685 |
|
@@ -691,8 +680,8 @@ class WPToolset_Cake_Validation {
|
|
691 |
* @return boolean Success
|
692 |
* @access public
|
693 |
*/
|
694 |
-
function maxLength($check, $max) {
|
695 |
-
$length = strlen($check);
|
696 |
return ($length <= $max);
|
697 |
}
|
698 |
|
@@ -704,11 +693,11 @@ class WPToolset_Cake_Validation {
|
|
704 |
* @return boolean Success
|
705 |
* @access public
|
706 |
*/
|
707 |
-
function money($check, $symbolPosition = 'left') {
|
708 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
709 |
$_this->check = $check;
|
710 |
|
711 |
-
if ($symbolPosition == 'right') {
|
712 |
$_this->regex = '/^(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?(?<!\x{00a2})\p{Sc}?$/u';
|
713 |
} else {
|
714 |
$_this->regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u';
|
@@ -730,22 +719,22 @@ class WPToolset_Cake_Validation {
|
|
730 |
* @return boolean Success
|
731 |
* @access public
|
732 |
*/
|
733 |
-
function multiple($check, $options = array()) {
|
734 |
$defaults = array('in' => null, 'max' => null, 'min' => null);
|
735 |
-
$options = array_merge($defaults, $options);
|
736 |
-
$check = array_filter((array) $check);
|
737 |
-
if (empty($check)) {
|
738 |
return false;
|
739 |
}
|
740 |
-
if ($options['max'] && count($check) > $options['max']) {
|
741 |
return false;
|
742 |
}
|
743 |
-
if ($options['min'] && count($check) < $options['min']) {
|
744 |
return false;
|
745 |
}
|
746 |
-
if ($options['in'] && is_array($options['in'])) {
|
747 |
-
foreach ($check as $val) {
|
748 |
-
if (!in_array($val, $options['in'])) {
|
749 |
return false;
|
750 |
}
|
751 |
}
|
@@ -760,19 +749,8 @@ class WPToolset_Cake_Validation {
|
|
760 |
* @return boolean Succcess
|
761 |
* @access public
|
762 |
*/
|
763 |
-
function numeric($check) {
|
764 |
-
return is_numeric($check);
|
765 |
-
}
|
766 |
-
|
767 |
-
/**
|
768 |
-
* Checks if a value is integer.
|
769 |
-
*
|
770 |
-
* @param string $check Value to check
|
771 |
-
* @return boolean Succcess
|
772 |
-
* @access public
|
773 |
-
*/
|
774 |
-
function integer($check) {
|
775 |
-
return is_int(intval($check));
|
776 |
}
|
777 |
|
778 |
/**
|
@@ -784,17 +762,17 @@ class WPToolset_Cake_Validation {
|
|
784 |
* @return boolean Success
|
785 |
* @access public
|
786 |
*/
|
787 |
-
function phone($check, $regex = null, $country = 'all') {
|
788 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
789 |
$_this->check = $check;
|
790 |
$_this->regex = $regex;
|
791 |
$_this->country = $country;
|
792 |
-
if (is_array($check)) {
|
793 |
-
$_this->_extract($check);
|
794 |
}
|
795 |
|
796 |
-
if (is_null($_this->regex)) {
|
797 |
-
switch ($_this->country) {
|
798 |
case 'us':
|
799 |
case 'all':
|
800 |
case 'can':
|
@@ -803,8 +781,8 @@ class WPToolset_Cake_Validation {
|
|
803 |
break;
|
804 |
}
|
805 |
}
|
806 |
-
if (empty($_this->regex)) {
|
807 |
-
return $_this->_pass('phone', $check, $country);
|
808 |
}
|
809 |
return $_this->_check();
|
810 |
}
|
@@ -818,20 +796,20 @@ class WPToolset_Cake_Validation {
|
|
818 |
* @return boolean Success
|
819 |
* @access public
|
820 |
*/
|
821 |
-
function postal($check, $regex = null, $country = null) {
|
822 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
823 |
$_this->check = $check;
|
824 |
$_this->regex = $regex;
|
825 |
$_this->country = $country;
|
826 |
-
if (is_array($check)) {
|
827 |
-
$_this->_extract($check);
|
828 |
}
|
829 |
-
if (empty($country)) {
|
830 |
$_this->country = 'us';
|
831 |
}
|
832 |
|
833 |
-
if (is_null($_this->regex)) {
|
834 |
-
switch ($_this->country) {
|
835 |
case 'uk':
|
836 |
$_this->regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
|
837 |
break;
|
@@ -850,8 +828,8 @@ class WPToolset_Cake_Validation {
|
|
850 |
break;
|
851 |
}
|
852 |
}
|
853 |
-
if (empty($_this->regex)) {
|
854 |
-
return $_this->_pass('postal', $check, $country);
|
855 |
}
|
856 |
return $_this->_check();
|
857 |
}
|
@@ -867,14 +845,14 @@ class WPToolset_Cake_Validation {
|
|
867 |
* @return boolean Success
|
868 |
* @access public
|
869 |
*/
|
870 |
-
function range($check, $lower = null, $upper = null) {
|
871 |
-
if (!is_numeric($check)) {
|
872 |
return false;
|
873 |
}
|
874 |
-
if (isset($lower) && isset($upper)) {
|
875 |
return ($check > $lower && $check < $upper);
|
876 |
}
|
877 |
-
return is_finite($check);
|
878 |
}
|
879 |
|
880 |
/**
|
@@ -886,17 +864,17 @@ class WPToolset_Cake_Validation {
|
|
886 |
* @return boolean Success
|
887 |
* @access public
|
888 |
*/
|
889 |
-
function ssn($check, $regex = null, $country = null) {
|
890 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
891 |
$_this->check = $check;
|
892 |
$_this->regex = $regex;
|
893 |
$_this->country = $country;
|
894 |
-
if (is_array($check)) {
|
895 |
-
$_this->_extract($check);
|
896 |
}
|
897 |
|
898 |
-
if (is_null($_this->regex)) {
|
899 |
-
switch ($_this->country) {
|
900 |
case 'dk':
|
901 |
$_this->regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i';
|
902 |
break;
|
@@ -908,8 +886,8 @@ class WPToolset_Cake_Validation {
|
|
908 |
break;
|
909 |
}
|
910 |
}
|
911 |
-
if (empty($_this->regex)) {
|
912 |
-
return $_this->_pass('ssn', $check, $country);
|
913 |
}
|
914 |
return $_this->_check();
|
915 |
}
|
@@ -921,7 +899,7 @@ class WPToolset_Cake_Validation {
|
|
921 |
* @return boolean Success
|
922 |
* @access public
|
923 |
*/
|
924 |
-
function uuid($check) {
|
925 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
926 |
$_this->check = $check;
|
927 |
$_this->regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i';
|
@@ -946,16 +924,17 @@ class WPToolset_Cake_Validation {
|
|
946 |
* @return boolean Success
|
947 |
* @access public
|
948 |
*/
|
949 |
-
function url($check, $strict = false) {
|
950 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
951 |
$_this->__populateIp();
|
952 |
$_this->check = $check;
|
953 |
-
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-
|
954 |
-
$_this->regex = '/^(?:(?:https?|ftps?|
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
|
|
959 |
return $_this->_check();
|
960 |
}
|
961 |
|
@@ -967,8 +946,8 @@ class WPToolset_Cake_Validation {
|
|
967 |
* @return boolean Succcess
|
968 |
* @access public
|
969 |
*/
|
970 |
-
function inList($check, $list) {
|
971 |
-
return in_array($check, $list);
|
972 |
}
|
973 |
|
974 |
/**
|
@@ -981,16 +960,17 @@ class WPToolset_Cake_Validation {
|
|
981 |
* @return mixed user-defined class class method returns
|
982 |
* @access public
|
983 |
*/
|
984 |
-
function userDefined($check, $object, $method, $args = null) {
|
985 |
-
return call_user_func_array(array(&$object, $method),
|
|
|
986 |
}
|
987 |
|
988 |
-
function noSpecialChars($check) {
|
989 |
-
return preg_match('#[^a-zA-Z0-9\s\_\-]#', $check) ? false : true;
|
990 |
}
|
991 |
|
992 |
-
function rewriteSlug($check) {
|
993 |
-
return preg_match('#[^a-zA-Z0-9\s\_\-\%]#', $check) ? false : true;
|
994 |
}
|
995 |
|
996 |
/**
|
@@ -1004,18 +984,21 @@ class WPToolset_Cake_Validation {
|
|
1004 |
* @return mixed Return of Passed method, false on failure
|
1005 |
* @access protected
|
1006 |
* */
|
1007 |
-
function _pass($method, $check, $classPrefix) {
|
1008 |
-
$className = ucwords($classPrefix) . 'Validation';
|
1009 |
-
if (!class_exists($className)) {
|
1010 |
-
trigger_error(sprintf(__('Could not find %s class, unable to complete validation.',
|
|
|
1011 |
return false;
|
1012 |
}
|
1013 |
-
if (!is_callable(array($className, $method))) {
|
1014 |
-
trigger_error(sprintf(__('Method %s does not exist on %s unable to complete validation.',
|
|
|
|
|
1015 |
return false;
|
1016 |
}
|
1017 |
$check = (array) $check;
|
1018 |
-
return call_user_func_array(array($className, $method), $check);
|
1019 |
}
|
1020 |
|
1021 |
/**
|
@@ -1026,7 +1009,7 @@ class WPToolset_Cake_Validation {
|
|
1026 |
*/
|
1027 |
function _check() {
|
1028 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
1029 |
-
if (preg_match($_this->regex, $_this->check)) {
|
1030 |
$_this->error[] = false;
|
1031 |
return true;
|
1032 |
} else {
|
@@ -1043,23 +1026,23 @@ class WPToolset_Cake_Validation {
|
|
1043 |
* @return void
|
1044 |
* @access protected
|
1045 |
*/
|
1046 |
-
function _extract($params) {
|
1047 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
1048 |
-
extract($params, EXTR_OVERWRITE);
|
1049 |
|
1050 |
-
if (isset($check)) {
|
1051 |
$_this->check = $check;
|
1052 |
}
|
1053 |
-
if (isset($regex)) {
|
1054 |
$_this->regex = $regex;
|
1055 |
}
|
1056 |
-
if (isset($country)) {
|
1057 |
-
$_this->country = strtolower($country);
|
1058 |
}
|
1059 |
-
if (isset($deep)) {
|
1060 |
$_this->deep = $deep;
|
1061 |
}
|
1062 |
-
if (isset($type)) {
|
1063 |
$_this->type = $type;
|
1064 |
}
|
1065 |
}
|
@@ -1073,20 +1056,20 @@ class WPToolset_Cake_Validation {
|
|
1073 |
*/
|
1074 |
function _luhn() {
|
1075 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
1076 |
-
if ($_this->deep !== true) {
|
1077 |
return true;
|
1078 |
}
|
1079 |
-
if ($_this->check == 0) {
|
1080 |
return false;
|
1081 |
}
|
1082 |
$sum = 0;
|
1083 |
-
$length = strlen($_this->check);
|
1084 |
|
1085 |
-
for ($position = 1 - ($length % 2); $position < $length; $position += 2) {
|
1086 |
$sum += $_this->check[$position];
|
1087 |
}
|
1088 |
|
1089 |
-
for ($position = ($length % 2); $position < $length; $position += 2) {
|
1090 |
$number = $_this->check[$position] * 2;
|
1091 |
$sum += ($number < 10) ? $number : $number - 9;
|
1092 |
}
|
@@ -1102,7 +1085,7 @@ class WPToolset_Cake_Validation {
|
|
1102 |
*/
|
1103 |
|
1104 |
function __populateIp() {
|
1105 |
-
if (!isset($this->__pattern['IPv6'])) {
|
1106 |
$pattern = '((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}';
|
1107 |
$pattern .= '(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})';
|
1108 |
$pattern .= '|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})';
|
@@ -1120,7 +1103,7 @@ class WPToolset_Cake_Validation {
|
|
1120 |
|
1121 |
$this->__pattern['IPv6'] = $pattern;
|
1122 |
}
|
1123 |
-
if (!isset($this->__pattern['IPv4'])) {
|
1124 |
$pattern = '(?:(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])';
|
1125 |
$this->__pattern['IPv4'] = $pattern;
|
1126 |
}
|
@@ -1141,9 +1124,10 @@ class WPToolset_Cake_Validation {
|
|
1141 |
$this->error = array();
|
1142 |
$this->errors = array();
|
1143 |
}
|
1144 |
-
|
1145 |
-
public static function required($value)
|
1146 |
-
|
|
|
1147 |
}
|
1148 |
|
1149 |
}
|
29 |
* @since CakePHP v 1.2.0.3830
|
30 |
*/
|
31 |
//class Validation extends Object {
|
32 |
+
class WPToolset_Cake_Validation
|
33 |
+
{
|
34 |
|
35 |
/**
|
36 |
* Set the value of methods $check param.
|
56 |
* @access private
|
57 |
*/
|
58 |
var $__pattern = array(
|
59 |
+
'hostname' => '(?:[a-z0-9][-a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)'
|
60 |
);
|
61 |
|
62 |
/**
|
103 |
function &getInstance() {
|
104 |
static $instance = array();
|
105 |
|
106 |
+
if ( !$instance ) {
|
107 |
$instance[0] = new WPToolset_Cake_Validation();
|
108 |
}
|
109 |
return $instance[0];
|
121 |
* @return boolean Success
|
122 |
* @access public
|
123 |
*/
|
124 |
+
function notEmpty( $check ) {
|
125 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
126 |
$_this->__reset();
|
127 |
$_this->check = $check;
|
128 |
|
129 |
+
if ( is_array( $check ) ) {
|
130 |
+
$_this->_extract( $check );
|
131 |
}
|
132 |
|
133 |
+
if ( empty( $_this->check ) && $_this->check != '0' ) {
|
134 |
return false;
|
135 |
}
|
136 |
$_this->regex = '/[^\s]+/m';
|
137 |
return $_this->_check();
|
138 |
}
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
/**
|
141 |
* Checks that a string contains only integer or letters
|
142 |
*
|
149 |
* @return boolean Success
|
150 |
* @access public
|
151 |
*/
|
152 |
+
function alphaNumeric( $check ) {
|
153 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
154 |
$_this->__reset();
|
155 |
$_this->check = $check;
|
156 |
|
157 |
+
if ( is_array( $check ) ) {
|
158 |
+
$_this->_extract( $check );
|
159 |
}
|
160 |
|
161 |
+
if ( empty( $_this->check ) && $_this->check != '0' ) {
|
162 |
return false;
|
163 |
}
|
164 |
$_this->regex = '/^[a-zA-Z0-9]*$/mu';
|
165 |
$return = $_this->_check();
|
166 |
|
167 |
+
if ( !$return ) {
|
168 |
$_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/mu';
|
169 |
$return = $_this->_check();
|
170 |
}
|
172 |
return $_this->_check();
|
173 |
}
|
174 |
|
175 |
+
function alphaNumericWhitespaces( $check ) {
|
176 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
177 |
$_this->__reset();
|
178 |
$_this->check = $check;
|
179 |
|
180 |
+
if ( is_array( $check ) ) {
|
181 |
+
$_this->_extract( $check );
|
182 |
}
|
183 |
|
184 |
+
if ( empty( $_this->check ) && $_this->check != '0' ) {
|
185 |
return false;
|
186 |
}
|
187 |
$_this->regex = '/^[a-zA-Z0-9\s\-\_]*$/mu';
|
188 |
$return = $_this->_check();
|
189 |
|
190 |
+
if ( !$return ) {
|
191 |
$_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}\s\-\_]+$/mu';
|
192 |
$return = $_this->_check();
|
193 |
}
|
206 |
* @return boolean Success
|
207 |
* @access public
|
208 |
*/
|
209 |
+
function between( $check, $min, $max ) {
|
210 |
+
$length = strlen( $check );
|
211 |
return ($length >= $min && $length <= $max);
|
212 |
}
|
213 |
|
222 |
* @return boolean Success
|
223 |
* @access public
|
224 |
*/
|
225 |
+
function blank( $check ) {
|
226 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
227 |
$_this->__reset();
|
228 |
$_this->check = $check;
|
229 |
|
230 |
+
if ( is_array( $check ) ) {
|
231 |
+
$_this->_extract( $check );
|
232 |
}
|
233 |
|
234 |
$_this->regex = '/[^\\s]/';
|
249 |
* @access public
|
250 |
* @see WPToolset_Cake_Validation::_luhn()
|
251 |
*/
|
252 |
+
function cc( $check, $type = 'fast', $deep = false, $regex = null ) {
|
253 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
254 |
$_this->__reset();
|
255 |
$_this->check = $check;
|
257 |
$_this->deep = $deep;
|
258 |
$_this->regex = $regex;
|
259 |
|
260 |
+
if ( is_array( $check ) ) {
|
261 |
+
$_this->_extract( $check );
|
262 |
}
|
263 |
+
$_this->check = str_replace( array('-', ' '), '', $_this->check );
|
264 |
|
265 |
+
if ( strlen( $_this->check ) < 13 ) {
|
266 |
return false;
|
267 |
}
|
268 |
|
269 |
+
if ( !is_null( $_this->regex ) ) {
|
270 |
+
if ( $_this->_check() ) {
|
271 |
return $_this->_luhn();
|
272 |
}
|
273 |
}
|
290 |
'fast' => '/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/'
|
291 |
);
|
292 |
|
293 |
+
if ( is_array( $_this->type ) ) {
|
294 |
+
foreach ( $_this->type as $value ) {
|
295 |
+
$_this->regex = $cards['all'][strtolower( $value )];
|
296 |
|
297 |
+
if ( $_this->_check() ) {
|
298 |
return $_this->_luhn();
|
299 |
}
|
300 |
}
|
301 |
+
} elseif ( $_this->type == 'all' ) {
|
302 |
+
foreach ( $cards['all'] as $value ) {
|
303 |
$_this->regex = $value;
|
304 |
|
305 |
+
if ( $_this->_check() ) {
|
306 |
return $_this->_luhn();
|
307 |
}
|
308 |
}
|
309 |
} else {
|
310 |
$_this->regex = $cards['fast'];
|
311 |
|
312 |
+
if ( $_this->_check() ) {
|
313 |
return $_this->_luhn();
|
314 |
}
|
315 |
}
|
327 |
* @return boolean Success
|
328 |
* @access public
|
329 |
*/
|
330 |
+
function comparison( $check1, $operator = null, $check2 = null ) {
|
331 |
+
if ( is_array( $check1 ) ) {
|
332 |
+
extract( $check1, EXTR_OVERWRITE );
|
333 |
}
|
334 |
+
$operator = str_replace( array(' ', "\t", "\n", "\r", "\0", "\x0B"), '',
|
335 |
+
strtolower( $operator ) );
|
336 |
|
337 |
+
switch ( $operator ) {
|
338 |
case 'isgreater':
|
339 |
case '>':
|
340 |
+
if ( $check1 > $check2 ) {
|
341 |
return true;
|
342 |
}
|
343 |
break;
|
344 |
case 'isless':
|
345 |
case '<':
|
346 |
+
if ( $check1 < $check2 ) {
|
347 |
return true;
|
348 |
}
|
349 |
break;
|
350 |
case 'greaterorequal':
|
351 |
case '>=':
|
352 |
+
if ( $check1 >= $check2 ) {
|
353 |
return true;
|
354 |
}
|
355 |
break;
|
356 |
case 'lessorequal':
|
357 |
case '<=':
|
358 |
+
if ( $check1 <= $check2 ) {
|
359 |
return true;
|
360 |
}
|
361 |
break;
|
362 |
case 'equalto':
|
363 |
case '==':
|
364 |
+
if ( $check1 == $check2 ) {
|
365 |
return true;
|
366 |
}
|
367 |
break;
|
368 |
case 'notequal':
|
369 |
case '!=':
|
370 |
+
if ( $check1 != $check2 ) {
|
371 |
return true;
|
372 |
}
|
373 |
break;
|
374 |
default:
|
375 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
376 |
+
$_this->errors[] = __( 'You must define the $operator parameter for WPToolset_Cake_Validation::comparison()',
|
377 |
+
'wpcf' );
|
378 |
break;
|
379 |
}
|
380 |
return false;
|
389 |
* @return boolean Success
|
390 |
* @access public
|
391 |
*/
|
392 |
+
function custom( $check, $regex = null ) {
|
393 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
394 |
$_this->__reset();
|
395 |
$_this->check = $check;
|
396 |
$_this->regex = $regex;
|
397 |
+
if ( is_array( $check ) ) {
|
398 |
+
$_this->_extract( $check );
|
399 |
}
|
400 |
+
if ( $_this->regex === null ) {
|
401 |
+
$_this->errors[] = __( 'You must define a regular expression for WPToolset_Cake_Validation::custom()',
|
402 |
+
'wpcf' );
|
403 |
return false;
|
404 |
}
|
405 |
return $_this->_check();
|
422 |
* @return boolean Success
|
423 |
* @access public
|
424 |
*/
|
425 |
+
function date( $check, $format = 'ymd', $regex = null ) {
|
426 |
+
|
427 |
+
if ( is_numeric( $check ) ) {
|
428 |
+
return WPToolset_Field_Date_Scripts::_isTimestampInRange($check);
|
429 |
+
}
|
430 |
+
// TODO Change to use date strtotime
|
431 |
+
$valid = wptoolset_strtotime( $check );
|
432 |
return $valid !== false;
|
433 |
|
434 |
$cake_date_formats = array('F j, Y' => 'Mdy',
|
443 |
$_this->check = $check;
|
444 |
$_this->regex = $regex;
|
445 |
|
446 |
+
if ( !is_null( $_this->regex ) ) {
|
447 |
return $_this->_check();
|
448 |
}
|
449 |
|
455 |
$regex['My'] = '%^(Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)[ /]((1[6-9]|[2-9]\\d)\\d{2})$%';
|
456 |
$regex['my'] = '%^(((0[123456789]|10|11|12)([- /.])(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))))$%';
|
457 |
|
458 |
+
$format = (is_array( $format )) ? array_values( $format ) : array($format);
|
459 |
+
foreach ( $format as $key ) {
|
460 |
$_this->regex = $regex[$key];
|
461 |
|
462 |
+
if ( $_this->_check() === true ) {
|
463 |
return true;
|
464 |
}
|
465 |
}
|
475 |
* @return boolean Success
|
476 |
* @access public
|
477 |
*/
|
478 |
+
function time( $check ) {
|
479 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
480 |
$_this->__reset();
|
481 |
$_this->check = $check;
|
490 |
* @return boolean Success
|
491 |
* @access public
|
492 |
*/
|
493 |
+
function boolean( $check ) {
|
494 |
$booleanList = array(0, 1, '0', '1', true, false);
|
495 |
+
return in_array( $check, $booleanList, true );
|
496 |
}
|
497 |
|
498 |
/**
|
505 |
* @return boolean Success
|
506 |
* @access public
|
507 |
*/
|
508 |
+
function decimal( $check, $places = null, $regex = null ) {
|
509 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
510 |
$_this->__reset();
|
511 |
$_this->regex = $regex;
|
512 |
$_this->check = $check;
|
513 |
|
514 |
+
if ( is_null( $_this->regex ) ) {
|
515 |
+
if ( is_null( $places ) ) {
|
516 |
$_this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?$/';
|
517 |
} else {
|
518 |
$_this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]{' . $places . '}$/';
|
530 |
* @return boolean Success
|
531 |
* @access public
|
532 |
*/
|
533 |
+
function email( $check, $deep = false, $regex = null ) {
|
534 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
535 |
$_this->__reset();
|
536 |
$_this->check = $check;
|
537 |
$_this->regex = $regex;
|
538 |
$_this->deep = $deep;
|
539 |
|
540 |
+
if ( is_array( $check ) ) {
|
541 |
+
$_this->_extract( $check );
|
542 |
}
|
543 |
|
544 |
+
if ( is_null( $_this->regex ) ) {
|
545 |
$_this->regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . $_this->__pattern['hostname'] . '$/i';
|
546 |
}
|
547 |
$return = $_this->_check();
|
548 |
|
549 |
+
if ( $_this->deep === false || $_this->deep === null ) {
|
550 |
return $return;
|
551 |
}
|
552 |
|
553 |
+
if ( $return === true && preg_match( '/@(' . $_this->__pattern['hostname'] . ')$/i',
|
554 |
+
$_this->check, $regs ) ) {
|
555 |
+
if ( function_exists( 'getmxrr' ) && getmxrr( $regs[1], $mxhosts ) ) {
|
556 |
return true;
|
557 |
}
|
558 |
+
if ( function_exists( 'checkdnsrr' ) && checkdnsrr( $regs[1], 'MX' ) ) {
|
559 |
return true;
|
560 |
}
|
561 |
+
return is_array( gethostbynamel( $regs[1] ) );
|
562 |
}
|
563 |
return false;
|
564 |
}
|
571 |
* @return boolean Success
|
572 |
* @access public
|
573 |
*/
|
574 |
+
function equalTo( $check, $comparedTo ) {
|
575 |
return ($check === $comparedTo);
|
576 |
}
|
577 |
|
583 |
* @return boolean Success
|
584 |
* @access public
|
585 |
*/
|
586 |
+
function extension( $check, $extensions = array('gif', 'jpeg', 'png', 'jpg') ) {
|
587 |
+
if ( is_array( $check ) ) {
|
588 |
+
return WPToolset_Cake_Validation::extension( array_shift( $check ),
|
589 |
+
$extensions );
|
590 |
+
}
|
591 |
+
$extension = strtolower( array_pop( explode( '.', $check ) ) );
|
592 |
+
foreach ( $extensions as $value ) {
|
593 |
+
if ( $extension == strtolower( $value ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
594 |
return true;
|
595 |
}
|
596 |
}
|
610 |
* @return boolean Success
|
611 |
* @access public
|
612 |
*/
|
613 |
+
function ip( $check, $type = 'both' ) {
|
614 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
615 |
$success = false;
|
616 |
+
$type = strtolower( $type );
|
617 |
+
if ( $type === 'ipv4' || $type === 'both' ) {
|
618 |
+
$success |= $_this->_ipv4( $check );
|
619 |
}
|
620 |
+
if ( $type === 'ipv6' || $type === 'both' ) {
|
621 |
+
$success |= $_this->_ipv6( $check );
|
622 |
}
|
623 |
return $success;
|
624 |
}
|
630 |
* @return boolean Success
|
631 |
* @access protected
|
632 |
*/
|
633 |
+
function _ipv4( $check ) {
|
634 |
+
if ( function_exists( 'filter_var' ) ) {
|
635 |
+
return filter_var( $check, FILTER_VALIDATE_IP,
|
636 |
+
array('flags' => FILTER_FLAG_IPV4) ) !== false;
|
637 |
}
|
638 |
$this->__populateIp();
|
639 |
$this->check = $check;
|
648 |
* @return boolean Success
|
649 |
* @access protected
|
650 |
*/
|
651 |
+
function _ipv6( $check ) {
|
652 |
+
if ( function_exists( 'filter_var' ) ) {
|
653 |
+
return filter_var( $check, FILTER_VALIDATE_IP,
|
654 |
+
array('flags' => FILTER_FLAG_IPV6) ) !== false;
|
655 |
}
|
656 |
$this->__populateIp();
|
657 |
$this->check = $check;
|
667 |
* @return boolean Success
|
668 |
* @access public
|
669 |
*/
|
670 |
+
function minLength( $check, $min ) {
|
671 |
+
$length = strlen( $check );
|
672 |
return ($length >= $min);
|
673 |
}
|
674 |
|
680 |
* @return boolean Success
|
681 |
* @access public
|
682 |
*/
|
683 |
+
function maxLength( $check, $max ) {
|
684 |
+
$length = strlen( $check );
|
685 |
return ($length <= $max);
|
686 |
}
|
687 |
|
693 |
* @return boolean Success
|
694 |
* @access public
|
695 |
*/
|
696 |
+
function money( $check, $symbolPosition = 'left' ) {
|
697 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
698 |
$_this->check = $check;
|
699 |
|
700 |
+
if ( $symbolPosition == 'right' ) {
|
701 |
$_this->regex = '/^(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?(?<!\x{00a2})\p{Sc}?$/u';
|
702 |
} else {
|
703 |
$_this->regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u';
|
719 |
* @return boolean Success
|
720 |
* @access public
|
721 |
*/
|
722 |
+
function multiple( $check, $options = array() ) {
|
723 |
$defaults = array('in' => null, 'max' => null, 'min' => null);
|
724 |
+
$options = array_merge( $defaults, $options );
|
725 |
+
$check = array_filter( (array) $check );
|
726 |
+
if ( empty( $check ) ) {
|
727 |
return false;
|
728 |
}
|
729 |
+
if ( $options['max'] && count( $check ) > $options['max'] ) {
|
730 |
return false;
|
731 |
}
|
732 |
+
if ( $options['min'] && count( $check ) < $options['min'] ) {
|
733 |
return false;
|
734 |
}
|
735 |
+
if ( $options['in'] && is_array( $options['in'] ) ) {
|
736 |
+
foreach ( $check as $val ) {
|
737 |
+
if ( !in_array( $val, $options['in'] ) ) {
|
738 |
return false;
|
739 |
}
|
740 |
}
|
749 |
* @return boolean Succcess
|
750 |
* @access public
|
751 |
*/
|
752 |
+
function numeric( $check ) {
|
753 |
+
return is_numeric( $check );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
754 |
}
|
755 |
|
756 |
/**
|
762 |
* @return boolean Success
|
763 |
* @access public
|
764 |
*/
|
765 |
+
function phone( $check, $regex = null, $country = 'all' ) {
|
766 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
767 |
$_this->check = $check;
|
768 |
$_this->regex = $regex;
|
769 |
$_this->country = $country;
|
770 |
+
if ( is_array( $check ) ) {
|
771 |
+
$_this->_extract( $check );
|
772 |
}
|
773 |
|
774 |
+
if ( is_null( $_this->regex ) ) {
|
775 |
+
switch ( $_this->country ) {
|
776 |
case 'us':
|
777 |
case 'all':
|
778 |
case 'can':
|
781 |
break;
|
782 |
}
|
783 |
}
|
784 |
+
if ( empty( $_this->regex ) ) {
|
785 |
+
return $_this->_pass( 'phone', $check, $country );
|
786 |
}
|
787 |
return $_this->_check();
|
788 |
}
|
796 |
* @return boolean Success
|
797 |
* @access public
|
798 |
*/
|
799 |
+
function postal( $check, $regex = null, $country = null ) {
|
800 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
801 |
$_this->check = $check;
|
802 |
$_this->regex = $regex;
|
803 |
$_this->country = $country;
|
804 |
+
if ( is_array( $check ) ) {
|
805 |
+
$_this->_extract( $check );
|
806 |
}
|
807 |
+
if ( empty( $country ) ) {
|
808 |
$_this->country = 'us';
|
809 |
}
|
810 |
|
811 |
+
if ( is_null( $_this->regex ) ) {
|
812 |
+
switch ( $_this->country ) {
|
813 |
case 'uk':
|
814 |
$_this->regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
|
815 |
break;
|
828 |
break;
|
829 |
}
|
830 |
}
|
831 |
+
if ( empty( $_this->regex ) ) {
|
832 |
+
return $_this->_pass( 'postal', $check, $country );
|
833 |
}
|
834 |
return $_this->_check();
|
835 |
}
|
845 |
* @return boolean Success
|
846 |
* @access public
|
847 |
*/
|
848 |
+
function range( $check, $lower = null, $upper = null ) {
|
849 |
+
if ( !is_numeric( $check ) ) {
|
850 |
return false;
|
851 |
}
|
852 |
+
if ( isset( $lower ) && isset( $upper ) ) {
|
853 |
return ($check > $lower && $check < $upper);
|
854 |
}
|
855 |
+
return is_finite( $check );
|
856 |
}
|
857 |
|
858 |
/**
|
864 |
* @return boolean Success
|
865 |
* @access public
|
866 |
*/
|
867 |
+
function ssn( $check, $regex = null, $country = null ) {
|
868 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
869 |
$_this->check = $check;
|
870 |
$_this->regex = $regex;
|
871 |
$_this->country = $country;
|
872 |
+
if ( is_array( $check ) ) {
|
873 |
+
$_this->_extract( $check );
|
874 |
}
|
875 |
|
876 |
+
if ( is_null( $_this->regex ) ) {
|
877 |
+
switch ( $_this->country ) {
|
878 |
case 'dk':
|
879 |
$_this->regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i';
|
880 |
break;
|
886 |
break;
|
887 |
}
|
888 |
}
|
889 |
+
if ( empty( $_this->regex ) ) {
|
890 |
+
return $_this->_pass( 'ssn', $check, $country );
|
891 |
}
|
892 |
return $_this->_check();
|
893 |
}
|
899 |
* @return boolean Success
|
900 |
* @access public
|
901 |
*/
|
902 |
+
function uuid( $check ) {
|
903 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
904 |
$_this->check = $check;
|
905 |
$_this->regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i';
|
924 |
* @return boolean Success
|
925 |
* @access public
|
926 |
*/
|
927 |
+
function url( $check, $strict = false ) {
|
928 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
929 |
$_this->__populateIp();
|
930 |
$_this->check = $check;
|
931 |
+
$validChars = '([' . preg_quote( '!"$&\'()*+,-.@_:;=~[]' ) . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))';
|
932 |
+
$_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty( $strict ) ? '' : '?') .
|
933 |
+
'(?:' . $_this->__pattern['IPv4'] . '|\[' . $_this->__pattern['IPv6'] . '\]|' . $_this->__pattern['hostname'] . ')' .
|
934 |
+
'(?::[1-9][0-9]{0,4})?' .
|
935 |
+
'(?:\/?|\/' . $validChars . '*)?' .
|
936 |
+
'(?:\?' . $validChars . '*)?' .
|
937 |
+
'(?:#' . $validChars . '*)?$/iu';
|
938 |
return $_this->_check();
|
939 |
}
|
940 |
|
946 |
* @return boolean Succcess
|
947 |
* @access public
|
948 |
*/
|
949 |
+
function inList( $check, $list ) {
|
950 |
+
return in_array( $check, $list );
|
951 |
}
|
952 |
|
953 |
/**
|
960 |
* @return mixed user-defined class class method returns
|
961 |
* @access public
|
962 |
*/
|
963 |
+
function userDefined( $check, $object, $method, $args = null ) {
|
964 |
+
return call_user_func_array( array(&$object, $method),
|
965 |
+
array($check, $args) );
|
966 |
}
|
967 |
|
968 |
+
function noSpecialChars( $check ) {
|
969 |
+
return preg_match( '#[^a-zA-Z0-9\s\_\-]#', $check ) ? false : true;
|
970 |
}
|
971 |
|
972 |
+
function rewriteSlug( $check ) {
|
973 |
+
return preg_match( '#[^a-zA-Z0-9\s\_\-\%]#', $check ) ? false : true;
|
974 |
}
|
975 |
|
976 |
/**
|
984 |
* @return mixed Return of Passed method, false on failure
|
985 |
* @access protected
|
986 |
* */
|
987 |
+
function _pass( $method, $check, $classPrefix ) {
|
988 |
+
$className = ucwords( $classPrefix ) . 'Validation';
|
989 |
+
if ( !class_exists( $className ) ) {
|
990 |
+
trigger_error( sprintf( __( 'Could not find %s class, unable to complete validation.',
|
991 |
+
true ), $className ), E_USER_WARNING );
|
992 |
return false;
|
993 |
}
|
994 |
+
if ( !is_callable( array($className, $method) ) ) {
|
995 |
+
trigger_error( sprintf( __( 'Method %s does not exist on %s unable to complete validation.',
|
996 |
+
true ), $method, $className ),
|
997 |
+
E_USER_WARNING );
|
998 |
return false;
|
999 |
}
|
1000 |
$check = (array) $check;
|
1001 |
+
return call_user_func_array( array($className, $method), $check );
|
1002 |
}
|
1003 |
|
1004 |
/**
|
1009 |
*/
|
1010 |
function _check() {
|
1011 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
1012 |
+
if ( preg_match( $_this->regex, $_this->check ) ) {
|
1013 |
$_this->error[] = false;
|
1014 |
return true;
|
1015 |
} else {
|
1026 |
* @return void
|
1027 |
* @access protected
|
1028 |
*/
|
1029 |
+
function _extract( $params ) {
|
1030 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
1031 |
+
extract( $params, EXTR_OVERWRITE );
|
1032 |
|
1033 |
+
if ( isset( $check ) ) {
|
1034 |
$_this->check = $check;
|
1035 |
}
|
1036 |
+
if ( isset( $regex ) ) {
|
1037 |
$_this->regex = $regex;
|
1038 |
}
|
1039 |
+
if ( isset( $country ) ) {
|
1040 |
+
$_this->country = strtolower( $country );
|
1041 |
}
|
1042 |
+
if ( isset( $deep ) ) {
|
1043 |
$_this->deep = $deep;
|
1044 |
}
|
1045 |
+
if ( isset( $type ) ) {
|
1046 |
$_this->type = $type;
|
1047 |
}
|
1048 |
}
|
1056 |
*/
|
1057 |
function _luhn() {
|
1058 |
$_this = &WPToolset_Cake_Validation::getInstance();
|
1059 |
+
if ( $_this->deep !== true ) {
|
1060 |
return true;
|
1061 |
}
|
1062 |
+
if ( $_this->check == 0 ) {
|
1063 |
return false;
|
1064 |
}
|
1065 |
$sum = 0;
|
1066 |
+
$length = strlen( $_this->check );
|
1067 |
|
1068 |
+
for ( $position = 1 - ($length % 2); $position < $length; $position += 2 ) {
|
1069 |
$sum += $_this->check[$position];
|
1070 |
}
|
1071 |
|
1072 |
+
for ( $position = ($length % 2); $position < $length; $position += 2 ) {
|
1073 |
$number = $_this->check[$position] * 2;
|
1074 |
$sum += ($number < 10) ? $number : $number - 9;
|
1075 |
}
|
1085 |
*/
|
1086 |
|
1087 |
function __populateIp() {
|
1088 |
+
if ( !isset( $this->__pattern['IPv6'] ) ) {
|
1089 |
$pattern = '((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}';
|
1090 |
$pattern .= '(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})';
|
1091 |
$pattern .= '|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})';
|
1103 |
|
1104 |
$this->__pattern['IPv6'] = $pattern;
|
1105 |
}
|
1106 |
+
if ( !isset( $this->__pattern['IPv4'] ) ) {
|
1107 |
$pattern = '(?:(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])';
|
1108 |
$this->__pattern['IPv4'] = $pattern;
|
1109 |
}
|
1124 |
$this->error = array();
|
1125 |
$this->errors = array();
|
1126 |
}
|
1127 |
+
|
1128 |
+
public static function required( $value )
|
1129 |
+
{
|
1130 |
+
return !( is_null( $value ) || $value === false || $value === '' );
|
1131 |
}
|
1132 |
|
1133 |
}
|
embedded/common/toolset-forms/lib/js/jquery-form-validation/jquery.validate.js
CHANGED
@@ -676,14 +676,10 @@ $.extend($.validator, {
|
|
676 |
// actually showing the wrapped element is handled elsewhere
|
677 |
label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
|
678 |
}
|
679 |
-
if ( !this.labelContainer.append(label).length )
|
680 |
-
if ( 'date' == $(element).data('wpt-type') ) {
|
681 |
-
element = $('input[type=text]', $(element).parent());
|
682 |
-
}
|
683 |
this.settings.errorPlacement
|
684 |
? this.settings.errorPlacement(label, $(element) )
|
685 |
: label.insertAfter(element);
|
686 |
-
}
|
687 |
}
|
688 |
if ( !message && this.settings.success ) {
|
689 |
label.text("");
|
676 |
// actually showing the wrapped element is handled elsewhere
|
677 |
label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
|
678 |
}
|
679 |
+
if ( !this.labelContainer.append(label).length )
|
|
|
|
|
|
|
680 |
this.settings.errorPlacement
|
681 |
? this.settings.errorPlacement(label, $(element) )
|
682 |
: label.insertAfter(element);
|
|
|
683 |
}
|
684 |
if ( !message && this.settings.success ) {
|
685 |
label.text("");
|
embedded/common/toolset-forms/readme.txt
CHANGED
@@ -8,149 +8,5 @@ To get HTML and rest of the scripts queued,
|
|
8 |
call function before queue_styles WP hook.
|
9 |
|
10 |
|
11 |
-
Filters:
|
12 |
|
13 |
-
toolset_valid_image_extentions
|
14 |
-
toolset_valid_video_extentions
|
15 |
-
|
16 |
-
Parameters:
|
17 |
-
- array - valid extension to be filtered
|
18 |
-
|
19 |
-
Output:
|
20 |
-
- array - filtered extension array
|
21 |
-
|
22 |
-
Example: add jfif extension:
|
23 |
-
|
24 |
-
add_filter( 'toolset_valid_image_extentions', 'my_toolset_valid_image_extentions' );
|
25 |
-
function my_toolset_valid_image_extentions($valid_extensions)
|
26 |
-
{
|
27 |
-
$valid_extensions[] = 'jfif';
|
28 |
-
return $valid_extensions;
|
29 |
-
}
|
30 |
-
|
31 |
-
= Changelog =
|
32 |
-
|
33 |
-
2015-03-25
|
34 |
-
|
35 |
-
- Fixed missing warning for date type field.
|
36 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196695908/comments
|
37 |
-
|
38 |
-
2015-02-06
|
39 |
-
|
40 |
-
- Fixed empty object in WPV_Handle_Users_Functions class when user is
|
41 |
-
not logged always return false.
|
42 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/194981023/comments
|
43 |
-
|
44 |
-
2014-12-29
|
45 |
-
|
46 |
-
- fixed display CPT in CT
|
47 |
-
|
48 |
-
2014-11-18 - plugins release - CRED 1.3.4, Types 1.6.4
|
49 |
-
|
50 |
-
2014-11-13
|
51 |
-
|
52 |
-
- Fixed a problem with missing taxonomies after form fail:
|
53 |
-
https://wp-types.com/forums/topic/cred-featured-image-and-tag-selector-empty-after-validation-refresh/
|
54 |
-
|
55 |
-
2014-11-10
|
56 |
-
|
57 |
-
- Fixed a problem with datepicker witch do not working inside a modal
|
58 |
-
dialog
|
59 |
-
https://wp-types.com/forums/topic/cred-forms-not-displaying-on-tabletmobile-browsers/
|
60 |
-
|
61 |
-
2014-11-03
|
62 |
-
|
63 |
-
- add filters to change taxonomies buttons text:
|
64 |
-
- toolset_button_show_popular_text
|
65 |
-
- toolset_button_hide_popular_text
|
66 |
-
- toolset_button_add_new_text
|
67 |
-
- toolset_button_cancel_text
|
68 |
-
- toolset_button_add_text
|
69 |
-
|
70 |
-
- add filters to change repetitive buttons text:
|
71 |
-
- toolset_button_delete_repetition_text
|
72 |
-
- toolset_button_add_repetition_text
|
73 |
-
https://wp-types.com/forums/topic/format-form-field-as-list/#post-255070
|
74 |
-
https://wp-types.com/forums/topic/hi/
|
75 |
-
https://wp-types.com/forums/topic/how-to-change-wpt-repdelete-button-value/
|
76 |
-
|
77 |
-
2014-10-23
|
78 |
-
- Fixed issue with missing previously saved data.
|
79 |
-
https://wp-types.com/forums/topic/date-not-recorded-in-a-postype
|
80 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/191003870/comments#comment_296586170
|
81 |
-
|
82 |
-
- Fixed a problem with not working build-in taxonomies (category,
|
83 |
-
post_tag) when we use this in CPT and this post are not included on
|
84 |
-
frontend.
|
85 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/190833102/comments
|
86 |
-
|
87 |
-
- Fixed a problem with WYSIWYG field description.
|
88 |
-
https://wp-types.com/forums/topic/add-a-link-in-the-custom-field-description/
|
89 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/191030746/comments
|
90 |
-
|
91 |
-
2014-10-21
|
92 |
-
- Fixed issue on checkbox after submit - there was wrong condition to
|
93 |
-
display checked checkbox.
|
94 |
-
https://wp-types.com/forums/topic/checkbox-value-not-saved/
|
95 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/190834414/comments
|
96 |
-
|
97 |
-
2014-10-13
|
98 |
-
|
99 |
-
- Fixed a wrong error message position, was under date field.
|
100 |
-
https://wp-types.com/forums/topic/some-issues-and-feedback-on-cred-1-3-3/
|
101 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/190493441/comments
|
102 |
-
|
103 |
-
2014-10-10
|
104 |
-
|
105 |
-
- Improved - add class for li element for checkboxes, radio, taxonomy
|
106 |
-
(both: flat and hierarchical), this class is based on checkbox label
|
107 |
-
and is sanitizet by "sanitize_title" function.
|
108 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/170609656/comments
|
109 |
-
http://wp-types.com/forums/topic/ugly-cred-taxonomy-cannot-style/
|
110 |
-
|
111 |
-
- Added filter "cred_item_li_class" which allow to change class of LI
|
112 |
-
element in checkboxes, radio and hierarchical taxonomy field.
|
113 |
-
|
114 |
-
2014-10-09
|
115 |
-
|
116 |
-
- Fixed warning on user site, when CRED is not installed and we check
|
117 |
-
CRED setting
|
118 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/190474262/comments
|
119 |
-
https://wp-types.com/forums/topic/i-just-updated-types-and-im-getting-this-error/
|
120 |
-
|
121 |
-
- Fixed problem with validation if is empty conditions, validation
|
122 |
-
should return true, not false.
|
123 |
-
https://wp-types.com/forums/topic/custom-types-fields-not-saving-changes/
|
124 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/190347235/comments#295158276
|
125 |
-
|
126 |
-
- Improved taxonomy buttons by adding extra class "btn-cancel" when it
|
127 |
-
is needed - on "Cancel" for hierarchical and on "Hide" on
|
128 |
-
non-hierarchical.
|
129 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/190492232/comments
|
130 |
-
|
131 |
-
2014-10-07
|
132 |
-
|
133 |
-
- Fixed problem with replacing @ char from filename
|
134 |
-
https://wp-types.com/forums/topic/types-sanitizes-sign-from-file-names/
|
135 |
-
|
136 |
-
2014-10-03
|
137 |
-
|
138 |
-
- Fixed a problem with abandon filter wpcf_fields_*_value_get - this
|
139 |
-
groups of filters was not copy to common library.
|
140 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/189095886/comments
|
141 |
-
http://wp-types.com/forums/topic/default-field-value-custom-function-no-longer-works/
|
142 |
-
|
143 |
-
2014-10-01
|
144 |
-
|
145 |
-
- Fixed a problem with not changed label, when adding new taxonomy.
|
146 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/190086914/comments
|
147 |
-
|
148 |
-
- Fixed changing the file name when upload the file
|
149 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/189560556/comments
|
150 |
-
http://wp-types.com/forums/topic/types-1-6-update-breaks-layout-that-worked-in-types-1-5-7/
|
151 |
-
|
152 |
-
2014-09-30
|
153 |
-
- Fixed a problem with multiple CRED form on one screen.
|
154 |
-
https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/189954041/comments
|
155 |
-
http://wp-types.com/forums/topic/cred-conditional-group-3/
|
156 |
|
8 |
call function before queue_styles WP hook.
|
9 |
|
10 |
|
|
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
embedded/common/toolset-forms/templates/metaform-item.php
CHANGED
@@ -1,40 +1,39 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
-
* $HeadURL:
|
5 |
-
* $LastChangedDate:
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
-
if (is_admin()) {
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
} else {
|
23 |
$toolset_repdrag_image = '';
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
echo '<div class="wpt-repctl">';
|
28 |
-
|
29 |
}
|
30 |
echo $out;
|
31 |
-
if ($cfg['repetitive']) {
|
32 |
-
if (array_key_exists('use_bootstrap', $cfg) && $cfg['use_bootstrap']) {
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
echo '
|
37 |
-
echo apply_filters('toolset_button_delete_repetition_text', esc_attr(__('Delete', 'wpv-views')) . " " . esc_attr($str), $cfg);
|
38 |
echo '" />';
|
39 |
echo '</div>';
|
40 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/templates/metaform-item.php $
|
5 |
+
* $LastChangedDate: 2014-08-05 18:49:11 +0200 (Tue, 05 Aug 2014) $
|
6 |
+
* $LastChangedRevision: 25660 $
|
7 |
+
* $LastChangedBy: juan $
|
8 |
*
|
9 |
*/
|
10 |
+
if ( is_admin() ) {
|
11 |
+
?>
|
12 |
+
<div class="js-wpt-field-item wpt-field-item">
|
13 |
+
<?php echo $out; ?>
|
14 |
+
<?php if ( @$cfg['repetitive'] ): ?>
|
15 |
+
<div class="wpt-repctl">
|
16 |
+
<div class="js-wpt-repdrag wpt-repdrag"> </div>
|
17 |
+
<a class="js-wpt-repdelete button button-small" data-wpt-type="<?php echo $cfg['type']; ?>" data-wpt-id="<?php echo $cfg['id']; ?>"><?php printf(__('Delete %s', 'wpv-views'), strtolower( $cfg['title'])); ?></a>
|
18 |
+
</div>
|
19 |
+
<?php endif; ?>
|
20 |
+
</div>
|
21 |
+
<?php
|
22 |
} else {
|
23 |
$toolset_repdrag_image = '';
|
24 |
+
$button_extra_classnames = '';
|
25 |
+
if ( $cfg['repetitive'] ) {
|
26 |
+
$toolset_repdrag_image = apply_filters( 'wptoolset_filter_wptoolset_repdrag_image', $toolset_repdrag_image );
|
27 |
echo '<div class="wpt-repctl">';
|
28 |
+
echo '<span class="js-wpt-repdrag wpt-repdrag"><img class="wpv-repdrag-image" src="' . $toolset_repdrag_image . '" /></span>';
|
29 |
}
|
30 |
echo $out;
|
31 |
+
if ( $cfg['repetitive'] ) {
|
32 |
+
if ( array_key_exists( 'use_bootstrap', $cfg ) && $cfg['use_bootstrap'] ) {
|
33 |
+
$button_extra_classnames = ' btn btn-default btn-sm';
|
34 |
+
}
|
35 |
+
echo '<input type="button" href="#" class="js-wpt-repdelete wpt-repdelete' . $button_extra_classnames . '" value="';
|
36 |
+
echo esc_attr( sprintf( __( 'Delete %s repetition', 'wpv-views' ), $cfg['title'] ) );
|
|
|
37 |
echo '" />';
|
38 |
echo '</div>';
|
39 |
}
|
embedded/common/toolset-forms/templates/metaform.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
-
* $HeadURL:
|
5 |
-
* $LastChangedDate: 2014-
|
6 |
-
* $LastChangedRevision:
|
7 |
-
* $LastChangedBy:
|
8 |
*
|
9 |
*/
|
10 |
|
@@ -19,7 +19,7 @@ if ( is_admin() ) {
|
|
19 |
include 'metaform-item.php';
|
20 |
endforeach; ?>
|
21 |
<?php if ( @$cfg['repetitive'] ): ?>
|
22 |
-
<a href="#" class="js-wpt-repadd wpt-repadd button button-small button-primary-toolset" data-wpt-type="<?php echo $cfg['type']; ?>" data-wpt-id="<?php echo $cfg['id']; ?>"><?php
|
23 |
<?php endif; ?>
|
24 |
</div>
|
25 |
</div>
|
@@ -60,7 +60,7 @@ if ( is_admin() ) {
|
|
60 |
}
|
61 |
if ( $cfg['repetitive'] ) {
|
62 |
echo '<input type="button" class="js-wpt-repadd wpt-repadd' . $button_extra_classnames . '" data-wpt-type="' . $cfg['type'] . '" data-wpt-id="' . $cfg['id'] . '" value="';
|
63 |
-
echo
|
64 |
echo '" />';
|
65 |
}
|
66 |
if ( $needs_wrapper) {
|
1 |
<?php
|
2 |
/**
|
3 |
*
|
4 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/templates/metaform.php $
|
5 |
+
* $LastChangedDate: 2014-08-18 17:18:52 +0200 (Mon, 18 Aug 2014) $
|
6 |
+
* $LastChangedRevision: 26059 $
|
7 |
+
* $LastChangedBy: riccardo $
|
8 |
*
|
9 |
*/
|
10 |
|
19 |
include 'metaform-item.php';
|
20 |
endforeach; ?>
|
21 |
<?php if ( @$cfg['repetitive'] ): ?>
|
22 |
+
<a href="#" class="js-wpt-repadd wpt-repadd button button-small button-primary-toolset" data-wpt-type="<?php echo $cfg['type']; ?>" data-wpt-id="<?php echo $cfg['id']; ?>"><?php printf(__('Add new %s', 'wpv-views'), $cfg['title']); ?></a>
|
23 |
<?php endif; ?>
|
24 |
</div>
|
25 |
</div>
|
60 |
}
|
61 |
if ( $cfg['repetitive'] ) {
|
62 |
echo '<input type="button" class="js-wpt-repadd wpt-repadd' . $button_extra_classnames . '" data-wpt-type="' . $cfg['type'] . '" data-wpt-id="' . $cfg['id'] . '" value="';
|
63 |
+
echo esc_attr( sprintf( __( 'Add new %s', 'wpv-views' ), $cfg['title'] ) );
|
64 |
echo '" />';
|
65 |
}
|
66 |
if ( $needs_wrapper) {
|
embedded/common/toolset-forms/test.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
add_action( 'admin_init', '_wptoolset_forms_test_fields' );
|
3 |
+
add_action( 'admin_init', '_wptoolset_forms_test_form' );
|
4 |
+
add_action( 'edit_form_after_editor', '_wptoolset_forms_test_fields_render' );
|
5 |
+
add_action( 'admin_footer', '_wptoolset_forms_test_form_render' );
|
6 |
+
|
7 |
+
function _wptoolset_forms_test_fields() {
|
8 |
+
global $_html_test;
|
9 |
+
$fields = types_get_fields(); //debug($fields);
|
10 |
+
foreach ( $fields as $field ) {
|
11 |
+
$config = wptoolset_forms_types_filter_field( $field, 'testme' );
|
12 |
+
$_html_test .= wptoolset_form_field( 'post', $config );
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
function _wptoolset_forms_test_form() {
|
17 |
+
global $_html_test_2;
|
18 |
+
$form = wptoolset_form( 'types-form' );
|
19 |
+
$fields = types_get_fields(); //debug($fields);
|
20 |
+
foreach ( $fields as $field ) {
|
21 |
+
$config = wptoolset_forms_types_filter_field( $field, 'testme' );
|
22 |
+
$form->addField( $config );
|
23 |
+
}
|
24 |
+
$form->addSubmit();
|
25 |
+
$_html_test_2 = $form->createForm( 'types-form' );
|
26 |
+
}
|
27 |
+
|
28 |
+
function _wptoolset_forms_test_fields_render() {
|
29 |
+
global $_html_test; //debug($_html_test);
|
30 |
+
echo '<h2>'.__('Test group of elements', 'wpv-views').'</h2>' . $_html_test;
|
31 |
+
}
|
32 |
+
|
33 |
+
function _wptoolset_forms_test_form_render() {
|
34 |
+
global $_html_test_2;
|
35 |
+
echo '<h2>'.__('Test form', 'wpv-views').'</h2>' . $_html_test_2;
|
36 |
+
}
|
embedded/common/utility/css/notifications.css
DELETED
@@ -1,342 +0,0 @@
|
|
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 |
-
display: table;
|
85 |
-
width: 100%;
|
86 |
-
background: #fff;
|
87 |
-
border: none;
|
88 |
-
}
|
89 |
-
|
90 |
-
.js-show-toolset-message {
|
91 |
-
display: none;
|
92 |
-
}
|
93 |
-
|
94 |
-
.toolset-help-content {
|
95 |
-
display: table-cell;
|
96 |
-
vertical-align: middle;
|
97 |
-
padding: 25px 25px 15px 180px;
|
98 |
-
height: 135px;
|
99 |
-
color: #4f4f4f;
|
100 |
-
border: solid 1px #cdcdcd;
|
101 |
-
}
|
102 |
-
|
103 |
-
.toolset-help-content a {
|
104 |
-
display: inline-block;
|
105 |
-
line-height: 18px;
|
106 |
-
text-decoration: underline;
|
107 |
-
}
|
108 |
-
.toolset-help-content p,
|
109 |
-
.toolset-help-content ul,
|
110 |
-
.toolset-help-content ol {
|
111 |
-
line-height: 1.6;
|
112 |
-
}
|
113 |
-
.toolset-help-content ul,
|
114 |
-
.toolset-help-content ol {
|
115 |
-
margin-left: 0;
|
116 |
-
list-style-position: inside;
|
117 |
-
}
|
118 |
-
.toolset-help-content ul li {
|
119 |
-
list-style-type: disc;
|
120 |
-
}
|
121 |
-
.toolset-help-content ol li {
|
122 |
-
list-style-type: decimal;
|
123 |
-
}
|
124 |
-
.toolset-help-content p:first-child {
|
125 |
-
margin-top: 0;
|
126 |
-
}
|
127 |
-
.toolset-help-content .btn {
|
128 |
-
margin: 0 10px 0 0;
|
129 |
-
padding: 4px 10px;
|
130 |
-
border: 0;
|
131 |
-
border-radius: 4px;
|
132 |
-
background: #11a99b;
|
133 |
-
color: #fff;
|
134 |
-
text-decoration: none;
|
135 |
-
text-shadow: none;
|
136 |
-
font-weight: bold;
|
137 |
-
}
|
138 |
-
|
139 |
-
.toolset-help-content .btn:hover {
|
140 |
-
background: #008C7D;
|
141 |
-
}
|
142 |
-
|
143 |
-
.toolset-help-content .toolset-help-content-toolbar {
|
144 |
-
margin: 20px 0 10px 0;
|
145 |
-
}
|
146 |
-
|
147 |
-
.toolset-help-sidebar {
|
148 |
-
position: absolute;
|
149 |
-
top: 1px;
|
150 |
-
left: 1px;
|
151 |
-
bottom: 1px;
|
152 |
-
width: 144px;
|
153 |
-
display: table-cell;
|
154 |
-
text-align: center;
|
155 |
-
vertical-align: middle;
|
156 |
-
background: url('../img/icon-help-message.png') center center no-repeat #333;
|
157 |
-
box-shadow: inset 0 0 15px #111;
|
158 |
-
}
|
159 |
-
.toolset-help-sidebar-ico {
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
.toolset-help-footer {
|
164 |
-
position: relative;
|
165 |
-
z-index: 1;
|
166 |
-
padding: 5px;
|
167 |
-
border-top: 1px solid #cdcdcd;
|
168 |
-
background: #fff;
|
169 |
-
text-align: right;
|
170 |
-
}
|
171 |
-
|
172 |
-
.toolset-help-footer [class^="button-"] {
|
173 |
-
margin-left: 5px;
|
174 |
-
}
|
175 |
-
|
176 |
-
|
177 |
-
.toolset-help .icon-remove-sign,
|
178 |
-
.toolset-help .icon-remove {
|
179 |
-
position: absolute;
|
180 |
-
top: 0;
|
181 |
-
right: 0;
|
182 |
-
color: #999;
|
183 |
-
opacity: 1;
|
184 |
-
background: #fff;
|
185 |
-
border: solid 1px #cdcdcd;
|
186 |
-
padding: 2px 4px;
|
187 |
-
font-size: 16px;
|
188 |
-
cursor: pointer;
|
189 |
-
}
|
190 |
-
|
191 |
-
.toolset-help .icon-remove-sign:hover,
|
192 |
-
.toolset-help .icon-remove:hover {
|
193 |
-
background: #b94a48;
|
194 |
-
color: #fff;
|
195 |
-
}
|
196 |
-
|
197 |
-
.toolset-help code {
|
198 |
-
display: inline-block;
|
199 |
-
}
|
200 |
-
|
201 |
-
/* TOOLTIP */
|
202 |
-
.toolset-tooltip {
|
203 |
-
position: absolute;
|
204 |
-
z-index: 999;
|
205 |
-
display: inline-block;
|
206 |
-
display: none;
|
207 |
-
padding: 3px 6px;
|
208 |
-
max-width: 300px;
|
209 |
-
background: #000;
|
210 |
-
background: rgba(0,0,0,.8);
|
211 |
-
color: #fff;
|
212 |
-
text-align: center;
|
213 |
-
}
|
214 |
-
|
215 |
-
.toolset-tooltip:after {
|
216 |
-
position: absolute;
|
217 |
-
bottom: -5px;
|
218 |
-
left: 50%;
|
219 |
-
margin-left: -5px;
|
220 |
-
width: 0;
|
221 |
-
height: 0;
|
222 |
-
border-width: 5px 5px 0 5px;
|
223 |
-
border-style: solid;
|
224 |
-
border-color: rgba(0,0,0,.8) transparent transparent transparent;
|
225 |
-
content: '';
|
226 |
-
}
|
227 |
-
|
228 |
-
/*highlight search */
|
229 |
-
.highlighted {
|
230 |
-
font-weight:bold;
|
231 |
-
|
232 |
-
}
|
233 |
-
|
234 |
-
.highlighted {
|
235 |
-
padding:1px 4px;
|
236 |
-
margin:0 -4px;
|
237 |
-
}
|
238 |
-
|
239 |
-
/* ---------------- */
|
240 |
-
/* TOOLSET POINTERS */
|
241 |
-
/* ---------------- */
|
242 |
-
|
243 |
-
.wp-toolset-pointer .wp-pointer-content {
|
244 |
-
border: 1px solid #EF6223;
|
245 |
-
background: #e9e9e9;
|
246 |
-
box-shadow: 0 0 5px #666;
|
247 |
-
}
|
248 |
-
|
249 |
-
.wp-toolset-pointer .wp-pointer-content h3 {
|
250 |
-
margin: 0 0 5px;
|
251 |
-
background: #ed8027;
|
252 |
-
border: none;
|
253 |
-
border-bottom: 1px solid #EF6223;
|
254 |
-
}
|
255 |
-
|
256 |
-
.wp-toolset-pointer .wp-pointer-content h3:before {
|
257 |
-
color: #ed8027;
|
258 |
-
content: "\f11a";
|
259 |
-
font-family: "onthegosystems-icons";
|
260 |
-
font: 28px/1.1;
|
261 |
-
border-radius: 5px;
|
262 |
-
}
|
263 |
-
|
264 |
-
.wp-toolset-pointer.wp-toolset-types-pointer .wp-pointer-content h3:before {
|
265 |
-
content: "\f11c";
|
266 |
-
}
|
267 |
-
|
268 |
-
.wp-toolset-pointer.wp-toolset-views-pointer .wp-pointer-content h3:before {
|
269 |
-
content: "\f11e";
|
270 |
-
}
|
271 |
-
|
272 |
-
.wp-toolset-pointer.wp-toolset-cred-pointer .wp-pointer-content h3:before {
|
273 |
-
content: "\f115";
|
274 |
-
}
|
275 |
-
|
276 |
-
.wp-toolset-pointer.wp-toolset-access-pointer .wp-pointer-content h3:before {
|
277 |
-
content: "\f111";
|
278 |
-
}
|
279 |
-
|
280 |
-
.wp-toolset-pointer.wp-toolset-layouts-pointer .wp-pointer-content h3:before {
|
281 |
-
content: "\f117";
|
282 |
-
}
|
283 |
-
|
284 |
-
.wp-toolset-pointer.wp-toolset-module-pointer .wp-pointer-content h3:before {
|
285 |
-
content: "\f119";
|
286 |
-
}
|
287 |
-
|
288 |
-
.wp-toolset-pointer.wp-toolset-bootstrap-pointer .wp-pointer-content h3:before {
|
289 |
-
content: "\f113";
|
290 |
-
}
|
291 |
-
|
292 |
-
.wp-toolset-pointer.wp-toolset-wpml-pointer .wp-pointer-content h3:before {
|
293 |
-
content: "\f11f";
|
294 |
-
}
|
295 |
-
|
296 |
-
.wp-toolset-pointer .wp-pointer-buttons {
|
297 |
-
|
298 |
-
}
|
299 |
-
|
300 |
-
.wp-toolset-pointer .wp-pointer-buttons button.alignright {
|
301 |
-
margin: 0 0 0 10px;
|
302 |
-
}
|
303 |
-
|
304 |
-
.wp-toolset-pointer .wp-pointer-buttons button.alignleft {
|
305 |
-
margin: 0 10px 0 0;
|
306 |
-
}
|
307 |
-
|
308 |
-
.wp-toolset-pointer.wp-pointer-top .wp-pointer-arrow-inner {
|
309 |
-
top: 2px;
|
310 |
-
border-color: transparent transparent #ed8027;
|
311 |
-
}
|
312 |
-
|
313 |
-
.wp-toolset-pointer.wp-pointer-top .wp-pointer-arrow {
|
314 |
-
border-bottom-color: #EF6223;
|
315 |
-
}
|
316 |
-
|
317 |
-
.wp-toolset-pointer.wp-pointer-right .wp-pointer-arrow-inner {
|
318 |
-
right: 2px;
|
319 |
-
border-color: transparent transparent transparent #e9e9e9;
|
320 |
-
}
|
321 |
-
|
322 |
-
.wp-toolset-pointer.wp-pointer-right .wp-pointer-arrow {
|
323 |
-
border-left-color: #EF6223;
|
324 |
-
}
|
325 |
-
|
326 |
-
.wp-toolset-pointer.wp-pointer-bottom .wp-pointer-arrow-inner {
|
327 |
-
bottom: 2px;
|
328 |
-
border-color: #e9e9e9 transparent transparent;
|
329 |
-
}
|
330 |
-
|
331 |
-
.wp-toolset-pointer.wp-pointer-bottom .wp-pointer-arrow {
|
332 |
-
border-top-color: #EF6223;
|
333 |
-
}
|
334 |
-
|
335 |
-
.wp-toolset-pointer.wp-pointer-left .wp-pointer-arrow-inner {
|
336 |
-
left: 2px;
|
337 |
-
border-color: transparent #e9e9e9 transparent transparent;
|
338 |
-
}
|
339 |
-
|
340 |
-
.wp-toolset-pointer.wp-pointer-left .wp-pointer-arrow {
|
341 |
-
border-right-color: #EF6223;
|
342 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/utility/css/select2/select2-overrides.css
DELETED
@@ -1,26 +0,0 @@
|
|
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
DELETED
Binary file
|
embedded/common/utility/css/select2/select2.css
DELETED
@@ -1,704 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
Version: 3.5.2 Timestamp: Sat Nov 1 14:43:36 EDT 2014
|
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 |
-
More Info : http://www.quirksmode.org/css/box.html
|
22 |
-
*/
|
23 |
-
-webkit-box-sizing: border-box; /* webkit */
|
24 |
-
-moz-box-sizing: border-box; /* firefox */
|
25 |
-
box-sizing: border-box; /* css3 */
|
26 |
-
}
|
27 |
-
|
28 |
-
.select2-container .select2-choice {
|
29 |
-
display: block;
|
30 |
-
height: 26px;
|
31 |
-
padding: 0 0 0 8px;
|
32 |
-
overflow: hidden;
|
33 |
-
position: relative;
|
34 |
-
|
35 |
-
border: 1px solid #aaa;
|
36 |
-
white-space: nowrap;
|
37 |
-
line-height: 26px;
|
38 |
-
color: #444;
|
39 |
-
text-decoration: none;
|
40 |
-
|
41 |
-
border-radius: 4px;
|
42 |
-
|
43 |
-
background-clip: padding-box;
|
44 |
-
|
45 |
-
-webkit-touch-callout: none;
|
46 |
-
-webkit-user-select: none;
|
47 |
-
-moz-user-select: none;
|
48 |
-
-ms-user-select: none;
|
49 |
-
user-select: none;
|
50 |
-
|
51 |
-
background-color: #fff;
|
52 |
-
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff));
|
53 |
-
background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
|
54 |
-
background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
|
55 |
-
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
|
56 |
-
background-image: linear-gradient(to top, #eee 0%, #fff 50%);
|
57 |
-
}
|
58 |
-
|
59 |
-
html[dir="rtl"] .select2-container .select2-choice {
|
60 |
-
padding: 0 8px 0 0;
|
61 |
-
}
|
62 |
-
|
63 |
-
.select2-container.select2-drop-above .select2-choice {
|
64 |
-
border-bottom-color: #aaa;
|
65 |
-
|
66 |
-
border-radius: 0 0 4px 4px;
|
67 |
-
|
68 |
-
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff));
|
69 |
-
background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
|
70 |
-
background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
|
71 |
-
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
|
72 |
-
background-image: linear-gradient(to bottom, #eee 0%, #fff 90%);
|
73 |
-
}
|
74 |
-
|
75 |
-
.select2-container.select2-allowclear .select2-choice .select2-chosen {
|
76 |
-
margin-right: 42px;
|
77 |
-
}
|
78 |
-
|
79 |
-
.select2-container .select2-choice > .select2-chosen {
|
80 |
-
margin-right: 26px;
|
81 |
-
display: block;
|
82 |
-
overflow: hidden;
|
83 |
-
|
84 |
-
white-space: nowrap;
|
85 |
-
|
86 |
-
text-overflow: ellipsis;
|
87 |
-
float: none;
|
88 |
-
width: auto;
|
89 |
-
}
|
90 |
-
|
91 |
-
html[dir="rtl"] .select2-container .select2-choice > .select2-chosen {
|
92 |
-
margin-left: 26px;
|
93 |
-
margin-right: 0;
|
94 |
-
}
|
95 |
-
|
96 |
-
.select2-container .select2-choice abbr {
|
97 |
-
display: none;
|
98 |
-
width: 12px;
|
99 |
-
height: 12px;
|
100 |
-
position: absolute;
|
101 |
-
right: 24px;
|
102 |
-
top: 8px;
|
103 |
-
|
104 |
-
font-size: 1px;
|
105 |
-
text-decoration: none;
|
106 |
-
|
107 |
-
border: 0;
|
108 |
-
background: url('select2.png') right top no-repeat;
|
109 |
-
cursor: pointer;
|
110 |
-
outline: 0;
|
111 |
-
}
|
112 |
-
|
113 |
-
.select2-container.select2-allowclear .select2-choice abbr {
|
114 |
-
display: inline-block;
|
115 |
-
}
|
116 |
-
|
117 |
-
.select2-container .select2-choice abbr:hover {
|
118 |
-
background-position: right -11px;
|
119 |
-
cursor: pointer;
|
120 |
-
}
|
121 |
-
|
122 |
-
.select2-drop-mask {
|
123 |
-
border: 0;
|
124 |
-
margin: 0;
|
125 |
-
padding: 0;
|
126 |
-
position: fixed;
|
127 |
-
left: 0;
|
128 |
-
top: 0;
|
129 |
-
min-height: 100%;
|
130 |
-
min-width: 100%;
|
131 |
-
height: auto;
|
132 |
-
width: auto;
|
133 |
-
opacity: 0;
|
134 |
-
z-index: 9998;
|
135 |
-
/* styles required for IE to work */
|
136 |
-
background-color: #fff;
|
137 |
-
filter: alpha(opacity=0);
|
138 |
-
}
|
139 |
-
|
140 |
-
.select2-drop {
|
141 |
-
width: 100%;
|
142 |
-
margin-top: -1px;
|
143 |
-
position: absolute;
|
144 |
-
z-index: 9999;
|
145 |
-
top: 100%;
|
146 |
-
|
147 |
-
background: #fff;
|
148 |
-
color: #000;
|
149 |
-
border: 1px solid #aaa;
|
150 |
-
border-top: 0;
|
151 |
-
|
152 |
-
border-radius: 0 0 4px 4px;
|
153 |
-
|
154 |
-
-webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
|
155 |
-
box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
|
156 |
-
}
|
157 |
-
|
158 |
-
.select2-drop.select2-drop-above {
|
159 |
-
margin-top: 1px;
|
160 |
-
border-top: 1px solid #aaa;
|
161 |
-
border-bottom: 0;
|
162 |
-
|
163 |
-
border-radius: 4px 4px 0 0;
|
164 |
-
|
165 |
-
-webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
|
166 |
-
box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
|
167 |
-
}
|
168 |
-
|
169 |
-
.select2-drop-active {
|
170 |
-
border: 1px solid #5897fb;
|
171 |
-
border-top: none;
|
172 |
-
}
|
173 |
-
|
174 |
-
.select2-drop.select2-drop-above.select2-drop-active {
|
175 |
-
border-top: 1px solid #5897fb;
|
176 |
-
}
|
177 |
-
|
178 |
-
.select2-drop-auto-width {
|
179 |
-
border-top: 1px solid #aaa;
|
180 |
-
width: auto;
|
181 |
-
}
|
182 |
-
|
183 |
-
.select2-drop-auto-width .select2-search {
|
184 |
-
padding-top: 4px;
|
185 |
-
}
|
186 |
-
|
187 |
-
.select2-container .select2-choice .select2-arrow {
|
188 |
-
display: inline-block;
|
189 |
-
width: 18px;
|
190 |
-
height: 100%;
|
191 |
-
position: absolute;
|
192 |
-
right: 0;
|
193 |
-
top: 0;
|
194 |
-
|
195 |
-
border-left: 1px solid #aaa;
|
196 |
-
border-radius: 0 4px 4px 0;
|
197 |
-
|
198 |
-
background-clip: padding-box;
|
199 |
-
|
200 |
-
background: #ccc;
|
201 |
-
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
|
202 |
-
background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
|
203 |
-
background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
|
204 |
-
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
|
205 |
-
background-image: linear-gradient(to top, #ccc 0%, #eee 60%);
|
206 |
-
}
|
207 |
-
|
208 |
-
html[dir="rtl"] .select2-container .select2-choice .select2-arrow {
|
209 |
-
left: 0;
|
210 |
-
right: auto;
|
211 |
-
|
212 |
-
border-left: none;
|
213 |
-
border-right: 1px solid #aaa;
|
214 |
-
border-radius: 4px 0 0 4px;
|
215 |
-
}
|
216 |
-
|
217 |
-
.select2-container .select2-choice .select2-arrow b {
|
218 |
-
display: block;
|
219 |
-
width: 100%;
|
220 |
-
height: 100%;
|
221 |
-
background: url('select2.png') no-repeat 0 1px;
|
222 |
-
}
|
223 |
-
|
224 |
-
html[dir="rtl"] .select2-container .select2-choice .select2-arrow b {
|
225 |
-
background-position: 2px 1px;
|
226 |
-
}
|
227 |
-
|
228 |
-
.select2-search {
|
229 |
-
display: inline-block;
|
230 |
-
width: 100%;
|
231 |
-
min-height: 26px;
|
232 |
-
margin: 0;
|
233 |
-
padding-left: 4px;
|
234 |
-
padding-right: 4px;
|
235 |
-
|
236 |
-
position: relative;
|
237 |
-
z-index: 10000;
|
238 |
-
|
239 |
-
white-space: nowrap;
|
240 |
-
}
|
241 |
-
|
242 |
-
.select2-search input {
|
243 |
-
width: 100%;
|
244 |
-
height: auto !important;
|
245 |
-
min-height: 26px;
|
246 |
-
padding: 4px 20px 4px 5px;
|
247 |
-
margin: 0;
|
248 |
-
|
249 |
-
outline: 0;
|
250 |
-
font-family: sans-serif;
|
251 |
-
font-size: 1em;
|
252 |
-
|
253 |
-
border: 1px solid #aaa;
|
254 |
-
border-radius: 0;
|
255 |
-
|
256 |
-
-webkit-box-shadow: none;
|
257 |
-
box-shadow: none;
|
258 |
-
|
259 |
-
background: #fff url('select2.png') no-repeat 100% -22px;
|
260 |
-
background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
|
261 |
-
background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
|
262 |
-
background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
|
263 |
-
background: url('select2.png') no-repeat 100% -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
|
264 |
-
}
|
265 |
-
|
266 |
-
html[dir="rtl"] .select2-search input {
|
267 |
-
padding: 4px 5px 4px 20px;
|
268 |
-
|
269 |
-
background: #fff url('select2.png') no-repeat -37px -22px;
|
270 |
-
background: url('select2.png') no-repeat -37px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
|
271 |
-
background: url('select2.png') no-repeat -37px -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
|
272 |
-
background: url('select2.png') no-repeat -37px -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
|
273 |
-
background: url('select2.png') no-repeat -37px -22px, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
|
274 |
-
}
|
275 |
-
|
276 |
-
.select2-drop.select2-drop-above .select2-search input {
|
277 |
-
margin-top: 4px;
|
278 |
-
}
|
279 |
-
|
280 |
-
.select2-search input.select2-active {
|
281 |
-
background: #fff url('select2-spinner.gif') no-repeat 100%;
|
282 |
-
background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
|
283 |
-
background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
|
284 |
-
background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
|
285 |
-
background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(to bottom, #fff 85%, #eee 99%) 0 0;
|
286 |
-
}
|
287 |
-
|
288 |
-
.select2-container-active .select2-choice,
|
289 |
-
.select2-container-active .select2-choices {
|
290 |
-
border: 1px solid #5897fb;
|
291 |
-
outline: none;
|
292 |
-
|
293 |
-
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
|
294 |
-
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
|
295 |
-
}
|
296 |
-
|
297 |
-
.select2-dropdown-open .select2-choice {
|
298 |
-
border-bottom-color: transparent;
|
299 |
-
-webkit-box-shadow: 0 1px 0 #fff inset;
|
300 |
-
box-shadow: 0 1px 0 #fff inset;
|
301 |
-
|
302 |
-
border-bottom-left-radius: 0;
|
303 |
-
border-bottom-right-radius: 0;
|
304 |
-
|
305 |
-
background-color: #eee;
|
306 |
-
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee));
|
307 |
-
background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
|
308 |
-
background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
|
309 |
-
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
|
310 |
-
background-image: linear-gradient(to top, #fff 0%, #eee 50%);
|
311 |
-
}
|
312 |
-
|
313 |
-
.select2-dropdown-open.select2-drop-above .select2-choice,
|
314 |
-
.select2-dropdown-open.select2-drop-above .select2-choices {
|
315 |
-
border: 1px solid #5897fb;
|
316 |
-
border-top-color: transparent;
|
317 |
-
|
318 |
-
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee));
|
319 |
-
background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
|
320 |
-
background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
|
321 |
-
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
|
322 |
-
background-image: linear-gradient(to bottom, #fff 0%, #eee 50%);
|
323 |
-
}
|
324 |
-
|
325 |
-
.select2-dropdown-open .select2-choice .select2-arrow {
|
326 |
-
background: transparent;
|
327 |
-
border-left: none;
|
328 |
-
filter: none;
|
329 |
-
}
|
330 |
-
html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow {
|
331 |
-
border-right: none;
|
332 |
-
}
|
333 |
-
|
334 |
-
.select2-dropdown-open .select2-choice .select2-arrow b {
|
335 |
-
background-position: -18px 1px;
|
336 |
-
}
|
337 |
-
|
338 |
-
html[dir="rtl"] .select2-dropdown-open .select2-choice .select2-arrow b {
|
339 |
-
background-position: -16px 1px;
|
340 |
-
}
|
341 |
-
|
342 |
-
.select2-hidden-accessible {
|
343 |
-
border: 0;
|
344 |
-
clip: rect(0 0 0 0);
|
345 |
-
height: 1px;
|
346 |
-
margin: -1px;
|
347 |
-
overflow: hidden;
|
348 |
-
padding: 0;
|
349 |
-
position: absolute;
|
350 |
-
width: 1px;
|
351 |
-
}
|
352 |
-
|
353 |
-
/* results */
|
354 |
-
.select2-results {
|
355 |
-
max-height: 200px;
|
356 |
-
padding: 0 0 0 4px;
|
357 |
-
margin: 4px 4px 4px 0;
|
358 |
-
position: relative;
|
359 |
-
overflow-x: hidden;
|
360 |
-
overflow-y: auto;
|
361 |
-
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
362 |
-
}
|
363 |
-
|
364 |
-
html[dir="rtl"] .select2-results {
|
365 |
-
padding: 0 4px 0 0;
|
366 |
-
margin: 4px 0 4px 4px;
|
367 |
-
}
|
368 |
-
|
369 |
-
.select2-results ul.select2-result-sub {
|
370 |
-
margin: 0;
|
371 |
-
padding-left: 0;
|
372 |
-
}
|
373 |
-
|
374 |
-
.select2-results li {
|
375 |
-
list-style: none;
|
376 |
-
display: list-item;
|
377 |
-
background-image: none;
|
378 |
-
}
|
379 |
-
|
380 |
-
.select2-results li.select2-result-with-children > .select2-result-label {
|
381 |
-
font-weight: bold;
|
382 |
-
}
|
383 |
-
|
384 |
-
.select2-results .select2-result-label {
|
385 |
-
padding: 3px 7px 4px;
|
386 |
-
margin: 0;
|
387 |
-
cursor: pointer;
|
388 |
-
|
389 |
-
min-height: 1em;
|
390 |
-
|
391 |
-
-webkit-touch-callout: none;
|
392 |
-
-webkit-user-select: none;
|
393 |
-
-moz-user-select: none;
|
394 |
-
-ms-user-select: none;
|
395 |
-
user-select: none;
|
396 |
-
}
|
397 |
-
|
398 |
-
.select2-results-dept-1 .select2-result-label { padding-left: 20px }
|
399 |
-
.select2-results-dept-2 .select2-result-label { padding-left: 40px }
|
400 |
-
.select2-results-dept-3 .select2-result-label { padding-left: 60px }
|
401 |
-
.select2-results-dept-4 .select2-result-label { padding-left: 80px }
|
402 |
-
.select2-results-dept-5 .select2-result-label { padding-left: 100px }
|
403 |
-
.select2-results-dept-6 .select2-result-label { padding-left: 110px }
|
404 |
-
.select2-results-dept-7 .select2-result-label { padding-left: 120px }
|
405 |
-
|
406 |
-
.select2-results .select2-highlighted {
|
407 |
-
background: #3875d7;
|
408 |
-
color: #fff;
|
409 |
-
}
|
410 |
-
|
411 |
-
.select2-results li em {
|
412 |
-
background: #feffde;
|
413 |
-
font-style: normal;
|
414 |
-
}
|
415 |
-
|
416 |
-
.select2-results .select2-highlighted em {
|
417 |
-
background: transparent;
|
418 |
-
}
|
419 |
-
|
420 |
-
.select2-results .select2-highlighted ul {
|
421 |
-
background: #fff;
|
422 |
-
color: #000;
|
423 |
-
}
|
424 |
-
|
425 |
-
.select2-results .select2-no-results,
|
426 |
-
.select2-results .select2-searching,
|
427 |
-
.select2-results .select2-ajax-error,
|
428 |
-
.select2-results .select2-selection-limit {
|
429 |
-
background: #f4f4f4;
|
430 |
-
display: list-item;
|
431 |
-
padding-left: 5px;
|
432 |
-
}
|
433 |
-
|
434 |
-
/*
|
435 |
-
disabled look for disabled choices in the results dropdown
|
436 |
-
*/
|
437 |
-
.select2-results .select2-disabled.select2-highlighted {
|
438 |
-
color: #666;
|
439 |
-
background: #f4f4f4;
|
440 |
-
display: list-item;
|
441 |
-
cursor: default;
|
442 |
-
}
|
443 |
-
.select2-results .select2-disabled {
|
444 |
-
background: #f4f4f4;
|
445 |
-
display: list-item;
|
446 |
-
cursor: default;
|
447 |
-
}
|
448 |
-
|
449 |
-
.select2-results .select2-selected {
|
450 |
-
display: none;
|
451 |
-
}
|
452 |
-
|
453 |
-
.select2-more-results.select2-active {
|
454 |
-
background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%;
|
455 |
-
}
|
456 |
-
|
457 |
-
.select2-results .select2-ajax-error {
|
458 |
-
background: rgba(255, 50, 50, .2);
|
459 |
-
}
|
460 |
-
|
461 |
-
.select2-more-results {
|
462 |
-
background: #f4f4f4;
|
463 |
-
display: list-item;
|
464 |
-
}
|
465 |
-
|
466 |
-
/* disabled styles */
|
467 |
-
|
468 |
-
.select2-container.select2-container-disabled .select2-choice {
|
469 |
-
background-color: #f4f4f4;
|
470 |
-
background-image: none;
|
471 |
-
border: 1px solid #ddd;
|
472 |
-
cursor: default;
|
473 |
-
}
|
474 |
-
|
475 |
-
.select2-container.select2-container-disabled .select2-choice .select2-arrow {
|
476 |
-
background-color: #f4f4f4;
|
477 |
-
background-image: none;
|
478 |
-
border-left: 0;
|
479 |
-
}
|
480 |
-
|
481 |
-
.select2-container.select2-container-disabled .select2-choice abbr {
|
482 |
-
display: none;
|
483 |
-
}
|
484 |
-
|
485 |
-
|
486 |
-
/* multiselect */
|
487 |
-
|
488 |
-
.select2-container-multi .select2-choices {
|
489 |
-
height: auto !important;
|
490 |
-
height: 1%;
|
491 |
-
margin: 0;
|
492 |
-
padding: 0 5px 0 0;
|
493 |
-
position: relative;
|
494 |
-
|
495 |
-
border: 1px solid #aaa;
|
496 |
-
cursor: text;
|
497 |
-
overflow: hidden;
|
498 |
-
|
499 |
-
background-color: #fff;
|
500 |
-
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
|
501 |
-
background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
|
502 |
-
background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
|
503 |
-
background-image: linear-gradient(to bottom, #eee 1%, #fff 15%);
|
504 |
-
}
|
505 |
-
|
506 |
-
html[dir="rtl"] .select2-container-multi .select2-choices {
|
507 |
-
padding: 0 0 0 5px;
|
508 |
-
}
|
509 |
-
|
510 |
-
.select2-locked {
|
511 |
-
padding: 3px 5px 3px 5px !important;
|
512 |
-
}
|
513 |
-
|
514 |
-
.select2-container-multi .select2-choices {
|
515 |
-
min-height: 26px;
|
516 |
-
}
|
517 |
-
|
518 |
-
.select2-container-multi.select2-container-active .select2-choices {
|
519 |
-
border: 1px solid #5897fb;
|
520 |
-
outline: none;
|
521 |
-
|
522 |
-
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
|
523 |
-
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
|
524 |
-
}
|
525 |
-
.select2-container-multi .select2-choices li {
|
526 |
-
float: left;
|
527 |
-
list-style: none;
|
528 |
-
}
|
529 |
-
html[dir="rtl"] .select2-container-multi .select2-choices li
|
530 |
-
{
|
531 |
-
float: right;
|
532 |
-
}
|
533 |
-
.select2-container-multi .select2-choices .select2-search-field {
|
534 |
-
margin: 0;
|
535 |
-
padding: 0;
|
536 |
-
white-space: nowrap;
|
537 |
-
}
|
538 |
-
|
539 |
-
.select2-container-multi .select2-choices .select2-search-field input {
|
540 |
-
padding: 5px;
|
541 |
-
margin: 1px 0;
|
542 |
-
|
543 |
-
font-family: sans-serif;
|
544 |
-
font-size: 100%;
|
545 |
-
color: #666;
|
546 |
-
outline: 0;
|
547 |
-
border: 0;
|
548 |
-
-webkit-box-shadow: none;
|
549 |
-
box-shadow: none;
|
550 |
-
background: transparent !important;
|
551 |
-
}
|
552 |
-
|
553 |
-
.select2-container-multi .select2-choices .select2-search-field input.select2-active {
|
554 |
-
background: #fff url('select2-spinner.gif') no-repeat 100% !important;
|
555 |
-
}
|
556 |
-
|
557 |
-
.select2-default {
|
558 |
-
color: #999 !important;
|
559 |
-
}
|
560 |
-
|
561 |
-
.select2-container-multi .select2-choices .select2-search-choice {
|
562 |
-
padding: 3px 5px 3px 18px;
|
563 |
-
margin: 3px 0 3px 5px;
|
564 |
-
position: relative;
|
565 |
-
|
566 |
-
line-height: 13px;
|
567 |
-
color: #333;
|
568 |
-
cursor: default;
|
569 |
-
border: 1px solid #aaaaaa;
|
570 |
-
|
571 |
-
border-radius: 3px;
|
572 |
-
|
573 |
-
-webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
|
574 |
-
box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
|
575 |
-
|
576 |
-
background-clip: padding-box;
|
577 |
-
|
578 |
-
-webkit-touch-callout: none;
|
579 |
-
-webkit-user-select: none;
|
580 |
-
-moz-user-select: none;
|
581 |
-
-ms-user-select: none;
|
582 |
-
user-select: none;
|
583 |
-
|
584 |
-
background-color: #e4e4e4;
|
585 |
-
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0);
|
586 |
-
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
|
587 |
-
background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
|
588 |
-
background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
|
589 |
-
background-image: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
|
590 |
-
}
|
591 |
-
html[dir="rtl"] .select2-container-multi .select2-choices .select2-search-choice
|
592 |
-
{
|
593 |
-
margin: 3px 5px 3px 0;
|
594 |
-
padding: 3px 18px 3px 5px;
|
595 |
-
}
|
596 |
-
.select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
|
597 |
-
cursor: default;
|
598 |
-
}
|
599 |
-
.select2-container-multi .select2-choices .select2-search-choice-focus {
|
600 |
-
background: #d4d4d4;
|
601 |
-
}
|
602 |
-
|
603 |
-
.select2-search-choice-close {
|
604 |
-
display: block;
|
605 |
-
width: 12px;
|
606 |
-
height: 13px;
|
607 |
-
position: absolute;
|
608 |
-
right: 3px;
|
609 |
-
top: 4px;
|
610 |
-
|
611 |
-
font-size: 1px;
|
612 |
-
outline: none;
|
613 |
-
background: url('select2.png') right top no-repeat;
|
614 |
-
}
|
615 |
-
html[dir="rtl"] .select2-search-choice-close {
|
616 |
-
right: auto;
|
617 |
-
left: 3px;
|
618 |
-
}
|
619 |
-
|
620 |
-
.select2-container-multi .select2-search-choice-close {
|
621 |
-
left: 3px;
|
622 |
-
}
|
623 |
-
|
624 |
-
html[dir="rtl"] .select2-container-multi .select2-search-choice-close {
|
625 |
-
left: auto;
|
626 |
-
right: 2px;
|
627 |
-
}
|
628 |
-
|
629 |
-
.select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
|
630 |
-
background-position: right -11px;
|
631 |
-
}
|
632 |
-
.select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close {
|
633 |
-
background-position: right -11px;
|
634 |
-
}
|
635 |
-
|
636 |
-
/* disabled styles */
|
637 |
-
.select2-container-multi.select2-container-disabled .select2-choices {
|
638 |
-
background-color: #f4f4f4;
|
639 |
-
background-image: none;
|
640 |
-
border: 1px solid #ddd;
|
641 |
-
cursor: default;
|
642 |
-
}
|
643 |
-
|
644 |
-
.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice {
|
645 |
-
padding: 3px 5px 3px 5px;
|
646 |
-
border: 1px solid #ddd;
|
647 |
-
background-image: none;
|
648 |
-
background-color: #f4f4f4;
|
649 |
-
}
|
650 |
-
|
651 |
-
.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none;
|
652 |
-
background: none;
|
653 |
-
}
|
654 |
-
/* end multiselect */
|
655 |
-
|
656 |
-
|
657 |
-
.select2-result-selectable .select2-match,
|
658 |
-
.select2-result-unselectable .select2-match {
|
659 |
-
text-decoration: underline;
|
660 |
-
}
|
661 |
-
|
662 |
-
.select2-offscreen, .select2-offscreen:focus {
|
663 |
-
clip: rect(0 0 0 0) !important;
|
664 |
-
width: 1px !important;
|
665 |
-
height: 1px !important;
|
666 |
-
border: 0 !important;
|
667 |
-
margin: 0 !important;
|
668 |
-
padding: 0 !important;
|
669 |
-
overflow: hidden !important;
|
670 |
-
position: absolute !important;
|
671 |
-
outline: 0 !important;
|
672 |
-
left: 0px !important;
|
673 |
-
top: 0px !important;
|
674 |
-
}
|
675 |
-
|
676 |
-
.select2-display-none {
|
677 |
-
display: none;
|
678 |
-
}
|
679 |
-
|
680 |
-
.select2-measure-scrollbar {
|
681 |
-
position: absolute;
|
682 |
-
top: -10000px;
|
683 |
-
left: -10000px;
|
684 |
-
width: 100px;
|
685 |
-
height: 100px;
|
686 |
-
overflow: scroll;
|
687 |
-
}
|
688 |
-
|
689 |
-
/* Retina-ize icons */
|
690 |
-
|
691 |
-
@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 2dppx) {
|
692 |
-
.select2-search input,
|
693 |
-
.select2-search-choice-close,
|
694 |
-
.select2-container .select2-choice abbr,
|
695 |
-
.select2-container .select2-choice .select2-arrow b {
|
696 |
-
background-image: url('select2x2.png') !important;
|
697 |
-
background-repeat: no-repeat !important;
|
698 |
-
background-size: 60px 40px !important;
|
699 |
-
}
|
700 |
-
|
701 |
-
.select2-search input {
|
702 |
-
background-position: 100% -21px !important;
|
703 |
-
}
|
704 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/utility/css/select2/select2.png
DELETED
Binary file
|
embedded/common/utility/css/select2/select2x2.png
DELETED
Binary file
|
embedded/common/utility/img/icon-help-message.png
DELETED
Binary file
|
embedded/common/utility/js/jstorage.min.js
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
// jStorage v0.4.7
|
2 |
-
(function(){function D(){var a="{}";if("userDataBehavior"==k){d.load("jStorage");try{a=d.getAttribute("jStorage")}catch(b){}try{r=d.getAttribute("jStorage_update")}catch(c){}h.jStorage=a}E();x();F()}function u(){var a;clearTimeout(G);G=setTimeout(function(){if("localStorage"==k||"globalStorage"==k)a=h.jStorage_update;else if("userDataBehavior"==k){d.load("jStorage");try{a=d.getAttribute("jStorage_update")}catch(b){}}if(a&&a!=r){r=a;var l=m.parse(m.stringify(c.__jstorage_meta.CRC32)),p;D();p=m.parse(m.stringify(c.__jstorage_meta.CRC32));
|
3 |
-
var e,z=[],f=[];for(e in l)l.hasOwnProperty(e)&&(p[e]?l[e]!=p[e]&&"2."==String(l[e]).substr(0,2)&&z.push(e):f.push(e));for(e in p)p.hasOwnProperty(e)&&(l[e]||z.push(e));s(z,"updated");s(f,"deleted")}},25)}function s(a,b){a=[].concat(a||[]);if("flushed"==b){a=[];for(var c in g)g.hasOwnProperty(c)&&a.push(c);b="deleted"}c=0;for(var p=a.length;c<p;c++){if(g[a[c]])for(var e=0,d=g[a[c]].length;e<d;e++)g[a[c]][e](a[c],b);if(g["*"])for(e=0,d=g["*"].length;e<d;e++)g["*"][e](a[c],b)}}function v(){var a=(+new Date).toString();
|
4 |
-
if("localStorage"==k||"globalStorage"==k)try{h.jStorage_update=a}catch(b){k=!1}else"userDataBehavior"==k&&(d.setAttribute("jStorage_update",a),d.save("jStorage"));u()}function E(){if(h.jStorage)try{c=m.parse(String(h.jStorage))}catch(a){h.jStorage="{}"}else h.jStorage="{}";A=h.jStorage?String(h.jStorage).length:0;c.__jstorage_meta||(c.__jstorage_meta={});c.__jstorage_meta.CRC32||(c.__jstorage_meta.CRC32={})}function w(){if(c.__jstorage_meta.PubSub){for(var a=+new Date-2E3,b=0,l=c.__jstorage_meta.PubSub.length;b<
|
5 |
-
l;b++)if(c.__jstorage_meta.PubSub[b][0]<=a){c.__jstorage_meta.PubSub.splice(b,c.__jstorage_meta.PubSub.length-b);break}c.__jstorage_meta.PubSub.length||delete c.__jstorage_meta.PubSub}try{h.jStorage=m.stringify(c),d&&(d.setAttribute("jStorage",h.jStorage),d.save("jStorage")),A=h.jStorage?String(h.jStorage).length:0}catch(p){}}function q(a){if(!a||"string"!=typeof a&&"number"!=typeof a)throw new TypeError("Key name must be string or numeric");if("__jstorage_meta"==a)throw new TypeError("Reserved key name");
|
6 |
-
return!0}function x(){var a,b,l,d,e=Infinity,h=!1,f=[];clearTimeout(H);if(c.__jstorage_meta&&"object"==typeof c.__jstorage_meta.TTL){a=+new Date;l=c.__jstorage_meta.TTL;d=c.__jstorage_meta.CRC32;for(b in l)l.hasOwnProperty(b)&&(l[b]<=a?(delete l[b],delete d[b],delete c[b],h=!0,f.push(b)):l[b]<e&&(e=l[b]));Infinity!=e&&(H=setTimeout(x,e-a));h&&(w(),v(),s(f,"deleted"))}}function F(){var a;if(c.__jstorage_meta.PubSub){var b,l=B;for(a=c.__jstorage_meta.PubSub.length-1;0<=a;a--)if(b=c.__jstorage_meta.PubSub[a],
|
7 |
-
b[0]>B){var l=b[0],d=b[1];b=b[2];if(t[d])for(var e=0,h=t[d].length;e<h;e++)try{t[d][e](d,m.parse(m.stringify(b)))}catch(f){}}B=l}}var y=window.jQuery||window.$||(window.$={}),m={parse:window.JSON&&(window.JSON.parse||window.JSON.decode)||String.prototype.evalJSON&&function(a){return String(a).evalJSON()}||y.parseJSON||y.evalJSON,stringify:Object.toJSON||window.JSON&&(window.JSON.stringify||window.JSON.encode)||y.toJSON};if(!("parse"in m&&"stringify"in m))throw Error("No JSON support found, include //cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js to page");
|
8 |
-
var c={__jstorage_meta:{CRC32:{}}},h={jStorage:"{}"},d=null,A=0,k=!1,g={},G=!1,r=0,t={},B=+new Date,H,C={isXML:function(a){return(a=(a?a.ownerDocument||a:0).documentElement)?"HTML"!==a.nodeName:!1},encode:function(a){if(!this.isXML(a))return!1;try{return(new XMLSerializer).serializeToString(a)}catch(b){try{return a.xml}catch(c){}}return!1},decode:function(a){var b="DOMParser"in window&&(new DOMParser).parseFromString||window.ActiveXObject&&function(a){var b=new ActiveXObject("Microsoft.XMLDOM");b.async=
|
9 |
-
"false";b.loadXML(a);return b};if(!b)return!1;a=b.call("DOMParser"in window&&new DOMParser||window,a,"text/xml");return this.isXML(a)?a:!1}};y.jStorage={version:"0.4.7",set:function(a,b,d){q(a);d=d||{};if("undefined"==typeof b)return this.deleteKey(a),b;if(C.isXML(b))b={_is_xml:!0,xml:C.encode(b)};else{if("function"==typeof b)return;b&&"object"==typeof b&&(b=m.parse(m.stringify(b)))}c[a]=b;for(var h=c.__jstorage_meta.CRC32,e=m.stringify(b),k=e.length,f=2538058380^k,g=0,n;4<=k;)n=e.charCodeAt(g)&255|
|
10 |
-
(e.charCodeAt(++g)&255)<<8|(e.charCodeAt(++g)&255)<<16|(e.charCodeAt(++g)&255)<<24,n=1540483477*(n&65535)+((1540483477*(n>>>16)&65535)<<16),n^=n>>>24,n=1540483477*(n&65535)+((1540483477*(n>>>16)&65535)<<16),f=1540483477*(f&65535)+((1540483477*(f>>>16)&65535)<<16)^n,k-=4,++g;switch(k){case 3:f^=(e.charCodeAt(g+2)&255)<<16;case 2:f^=(e.charCodeAt(g+1)&255)<<8;case 1:f^=e.charCodeAt(g)&255,f=1540483477*(f&65535)+((1540483477*(f>>>16)&65535)<<16)}f^=f>>>13;f=1540483477*(f&65535)+((1540483477*(f>>>16)&
|
11 |
-
65535)<<16);h[a]="2."+((f^f>>>15)>>>0);this.setTTL(a,d.TTL||0);s(a,"updated");return b},get:function(a,b){q(a);return a in c?c[a]&&"object"==typeof c[a]&&c[a]._is_xml?C.decode(c[a].xml):c[a]:"undefined"==typeof b?null:b},deleteKey:function(a){q(a);return a in c?(delete c[a],"object"==typeof c.__jstorage_meta.TTL&&a in c.__jstorage_meta.TTL&&delete c.__jstorage_meta.TTL[a],delete c.__jstorage_meta.CRC32[a],w(),v(),s(a,"deleted"),!0):!1},setTTL:function(a,b){var d=+new Date;q(a);b=Number(b)||0;return a in
|
12 |
-
c?(c.__jstorage_meta.TTL||(c.__jstorage_meta.TTL={}),0<b?c.__jstorage_meta.TTL[a]=d+b:delete c.__jstorage_meta.TTL[a],w(),x(),v(),!0):!1},getTTL:function(a){var b=+new Date;q(a);return a in c&&c.__jstorage_meta.TTL&&c.__jstorage_meta.TTL[a]?(a=c.__jstorage_meta.TTL[a]-b)||0:0},flush:function(){c={__jstorage_meta:{CRC32:{}}};w();v();s(null,"flushed");return!0},storageObj:function(){function a(){}a.prototype=c;return new a},index:function(){var a=[],b;for(b in c)c.hasOwnProperty(b)&&"__jstorage_meta"!=
|
13 |
-
b&&a.push(b);return a},storageSize:function(){return A},currentBackend:function(){return k},storageAvailable:function(){return!!k},listenKeyChange:function(a,b){q(a);g[a]||(g[a]=[]);g[a].push(b)},stopListening:function(a,b){q(a);if(g[a])if(b)for(var c=g[a].length-1;0<=c;c--)g[a][c]==b&&g[a].splice(c,1);else delete g[a]},subscribe:function(a,b){a=(a||"").toString();if(!a)throw new TypeError("Channel not defined");t[a]||(t[a]=[]);t[a].push(b)},publish:function(a,b){a=(a||"").toString();if(!a)throw new TypeError("Channel not defined");
|
14 |
-
c.__jstorage_meta||(c.__jstorage_meta={});c.__jstorage_meta.PubSub||(c.__jstorage_meta.PubSub=[]);c.__jstorage_meta.PubSub.unshift([+new Date,a,b]);w();v()},reInit:function(){D()},noConflict:function(a){delete window.$.jStorage;a&&(window.jStorage=this);return this}};(function(){var a=!1;if("localStorage"in window)try{window.localStorage.setItem("_tmptest","tmpval"),a=!0,window.localStorage.removeItem("_tmptest")}catch(b){}if(a)try{window.localStorage&&(h=window.localStorage,k="localStorage",r=h.jStorage_update)}catch(c){}else if("globalStorage"in
|
15 |
-
window)try{window.globalStorage&&(h="localhost"==window.location.hostname?window.globalStorage["localhost.localdomain"]:window.globalStorage[window.location.hostname],k="globalStorage",r=h.jStorage_update)}catch(g){}else if(d=document.createElement("link"),d.addBehavior){d.style.behavior="url(#default#userData)";document.getElementsByTagName("head")[0].appendChild(d);try{d.load("jStorage")}catch(e){d.setAttribute("jStorage","{}"),d.save("jStorage"),d.load("jStorage")}a="{}";try{a=d.getAttribute("jStorage")}catch(m){}try{r=
|
16 |
-
d.getAttribute("jStorage_update")}catch(f){}h.jStorage=a;k="userDataBehavior"}else{d=null;return}E();x();"localStorage"==k||"globalStorage"==k?"addEventListener"in window?window.addEventListener("storage",u,!1):document.attachEvent("onstorage",u):"userDataBehavior"==k&&setInterval(u,1E3);F();"addEventListener"in window&&window.addEventListener("pageshow",function(a){a.persisted&&u()},!1)})()})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/utility/js/keyboard.js
DELETED
@@ -1,961 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* Title: KeyboardJS
|
3 |
-
* Version: v0.4.1
|
4 |
-
* Description: KeyboardJS is a flexible and easy to use keyboard binding
|
5 |
-
* library.
|
6 |
-
* Author: Robert Hurst.
|
7 |
-
*
|
8 |
-
* Copyright 2011, Robert William Hurst
|
9 |
-
* Licenced under the BSD License.
|
10 |
-
* See https://raw.github.com/RobertWHurst/KeyboardJS/master/license.txt
|
11 |
-
*/
|
12 |
-
(function(context, factory) {
|
13 |
-
|
14 |
-
//INDEXOF POLLYFILL
|
15 |
-
[].indexOf||(Array.prototype.indexOf=function(a,b,c){for(c=this.length,b=(c+~~b)%c;b<c&&(!(b in this)||this[b]!==a);b++);return b^c?b:-1;});
|
16 |
-
|
17 |
-
//AMD
|
18 |
-
if(typeof define === 'function' && define.amd) { define(constructAMD); }
|
19 |
-
|
20 |
-
//CommonJS
|
21 |
-
else if(typeof module !== 'undefined') {constructCommonJS()}
|
22 |
-
|
23 |
-
//GLOBAL
|
24 |
-
else { constructGlobal(); }
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Construct AMD version of the library
|
28 |
-
*/
|
29 |
-
function constructAMD() {
|
30 |
-
|
31 |
-
//create a library instance
|
32 |
-
return init(context);
|
33 |
-
|
34 |
-
//spawns a library instance
|
35 |
-
function init(context) {
|
36 |
-
var library;
|
37 |
-
library = factory(context, 'amd');
|
38 |
-
library.fork = init;
|
39 |
-
return library;
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Construct CommonJS version of the library
|
45 |
-
*/
|
46 |
-
function constructCommonJS() {
|
47 |
-
|
48 |
-
//create a library instance
|
49 |
-
module.exports = init(context);
|
50 |
-
|
51 |
-
return;
|
52 |
-
|
53 |
-
//spawns a library instance
|
54 |
-
function init(context) {
|
55 |
-
var library;
|
56 |
-
library = factory(context, 'CommonJS');
|
57 |
-
library.fork = init;
|
58 |
-
return library;
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Construct a Global version of the library
|
66 |
-
*/
|
67 |
-
function constructGlobal() {
|
68 |
-
var library;
|
69 |
-
|
70 |
-
//create a library instance
|
71 |
-
library = init(context);
|
72 |
-
|
73 |
-
//spawns a library instance
|
74 |
-
function init(context) {
|
75 |
-
var library, namespaces = [], previousValues = {};
|
76 |
-
|
77 |
-
library = factory(context, 'global');
|
78 |
-
library.fork = init;
|
79 |
-
library.noConflict = noConflict;
|
80 |
-
library.noConflict('KeyboardJS', 'k');
|
81 |
-
return library;
|
82 |
-
|
83 |
-
//sets library namespaces
|
84 |
-
function noConflict( ) {
|
85 |
-
var args, nI, newNamespaces;
|
86 |
-
|
87 |
-
newNamespaces = Array.prototype.slice.apply(arguments);
|
88 |
-
|
89 |
-
for(nI = 0; nI < namespaces.length; nI += 1) {
|
90 |
-
if(typeof previousValues[namespaces[nI]] === 'undefined') {
|
91 |
-
delete context[namespaces[nI]];
|
92 |
-
} else {
|
93 |
-
context[namespaces[nI]] = previousValues[namespaces[nI]];
|
94 |
-
}
|
95 |
-
}
|
96 |
-
|
97 |
-
previousValues = {};
|
98 |
-
|
99 |
-
for(nI = 0; nI < newNamespaces.length; nI += 1) {
|
100 |
-
if(typeof newNamespaces[nI] !== 'string') {
|
101 |
-
throw new Error('Cannot replace namespaces. All new namespaces must be strings.');
|
102 |
-
}
|
103 |
-
previousValues[newNamespaces[nI]] = context[newNamespaces[nI]];
|
104 |
-
context[newNamespaces[nI]] = library;
|
105 |
-
}
|
106 |
-
|
107 |
-
namespaces = newNamespaces;
|
108 |
-
|
109 |
-
return namespaces;
|
110 |
-
}
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
})(this, function(targetWindow, env) {
|
115 |
-
var KeyboardJS = {}, locales = {}, locale, map, macros, activeKeys = [], bindings = [], activeBindings = [],
|
116 |
-
activeMacros = [], aI, usLocale;
|
117 |
-
targetWindow = targetWindow || window;
|
118 |
-
|
119 |
-
///////////////////////
|
120 |
-
// DEFAULT US LOCALE //
|
121 |
-
///////////////////////
|
122 |
-
|
123 |
-
//define US locale
|
124 |
-
//If you create a new locale please submit it as a pull request or post
|
125 |
-
// it in the issue tracker at
|
126 |
-
// http://github.com/RobertWhurst/KeyboardJS/issues/
|
127 |
-
usLocale = {
|
128 |
-
"map": {
|
129 |
-
|
130 |
-
//general
|
131 |
-
"3": ["cancel"],
|
132 |
-
"8": ["backspace"],
|
133 |
-
"9": ["tab"],
|
134 |
-
"12": ["clear"],
|
135 |
-
"13": ["enter"],
|
136 |
-
"16": ["shift"],
|
137 |
-
"17": ["ctrl"],
|
138 |
-
"18": ["alt", "menu"],
|
139 |
-
"19": ["pause", "break"],
|
140 |
-
"20": ["capslock"],
|
141 |
-
"27": ["escape", "esc"],
|
142 |
-
"32": ["space", "spacebar"],
|
143 |
-
"33": ["pageup"],
|
144 |
-
"34": ["pagedown"],
|
145 |
-
"35": ["end"],
|
146 |
-
"36": ["home"],
|
147 |
-
"37": ["left"],
|
148 |
-
"38": ["up"],
|
149 |
-
"39": ["right"],
|
150 |
-
"40": ["down"],
|
151 |
-
"41": ["select"],
|
152 |
-
"42": ["printscreen"],
|
153 |
-
"43": ["execute"],
|
154 |
-
"44": ["snapshot"],
|
155 |
-
"45": ["insert", "ins"],
|
156 |
-
"46": ["delete", "del"],
|
157 |
-
"47": ["help"],
|
158 |
-
"91": ["command", "windows", "win", "super", "leftcommand", "leftwindows", "leftwin", "leftsuper"],
|
159 |
-
"92": ["command", "windows", "win", "super", "rightcommand", "rightwindows", "rightwin", "rightsuper"],
|
160 |
-
"145": ["scrolllock", "scroll"],
|
161 |
-
"186": ["semicolon", ";"],
|
162 |
-
"187": ["equal", "equalsign", "="],
|
163 |
-
"188": ["comma", ","],
|
164 |
-
"189": ["dash", "-"],
|
165 |
-
"190": ["period", "."],
|
166 |
-
"191": ["slash", "forwardslash", "/"],
|
167 |
-
"192": ["graveaccent", "`"],
|
168 |
-
"219": ["openbracket", "["],
|
169 |
-
"220": ["backslash", "\\"],
|
170 |
-
"221": ["closebracket", "]"],
|
171 |
-
"222": ["apostrophe", "'"],
|
172 |
-
|
173 |
-
//0-9
|
174 |
-
"48": ["zero", "0"],
|
175 |
-
"49": ["one", "1"],
|
176 |
-
"50": ["two", "2"],
|
177 |
-
"51": ["three", "3"],
|
178 |
-
"52": ["four", "4"],
|
179 |
-
"53": ["five", "5"],
|
180 |
-
"54": ["six", "6"],
|
181 |
-
"55": ["seven", "7"],
|
182 |
-
"56": ["eight", "8"],
|
183 |
-
"57": ["nine", "9"],
|
184 |
-
|
185 |
-
//numpad
|
186 |
-
"96": ["numzero", "num0"],
|
187 |
-
"97": ["numone", "num1"],
|
188 |
-
"98": ["numtwo", "num2"],
|
189 |
-
"99": ["numthree", "num3"],
|
190 |
-
"100": ["numfour", "num4"],
|
191 |
-
"101": ["numfive", "num5"],
|
192 |
-
"102": ["numsix", "num6"],
|
193 |
-
"103": ["numseven", "num7"],
|
194 |
-
"104": ["numeight", "num8"],
|
195 |
-
"105": ["numnine", "num9"],
|
196 |
-
"106": ["nummultiply", "num*"],
|
197 |
-
"107": ["numadd", "num+"],
|
198 |
-
"108": ["numenter"],
|
199 |
-
"109": ["numsubtract", "num-"],
|
200 |
-
"110": ["numdecimal", "num."],
|
201 |
-
"111": ["numdivide", "num/"],
|
202 |
-
"144": ["numlock", "num"],
|
203 |
-
|
204 |
-
//function keys
|
205 |
-
"112": ["f1"],
|
206 |
-
"113": ["f2"],
|
207 |
-
"114": ["f3"],
|
208 |
-
"115": ["f4"],
|
209 |
-
"116": ["f5"],
|
210 |
-
"117": ["f6"],
|
211 |
-
"118": ["f7"],
|
212 |
-
"119": ["f8"],
|
213 |
-
"120": ["f9"],
|
214 |
-
"121": ["f10"],
|
215 |
-
"122": ["f11"],
|
216 |
-
"123": ["f12"]
|
217 |
-
},
|
218 |
-
"macros": [
|
219 |
-
|
220 |
-
//secondary key symbols
|
221 |
-
['shift + `', ["tilde", "~"]],
|
222 |
-
['shift + 1', ["exclamation", "exclamationpoint", "!"]],
|
223 |
-
['shift + 2', ["at", "@"]],
|
224 |
-
['shift + 3', ["number", "#"]],
|
225 |
-
['shift + 4', ["dollar", "dollars", "dollarsign", "$"]],
|
226 |
-
['shift + 5', ["percent", "%"]],
|
227 |
-
['shift + 6', ["caret", "^"]],
|
228 |
-
['shift + 7', ["ampersand", "and", "&"]],
|
229 |
-
['shift + 8', ["asterisk", "*"]],
|
230 |
-
['shift + 9', ["openparen", "("]],
|
231 |
-
['shift + 0', ["closeparen", ")"]],
|
232 |
-
['shift + -', ["underscore", "_"]],
|
233 |
-
['shift + =', ["plus", "+"]],
|
234 |
-
['shift + (', ["opencurlybrace", "opencurlybracket", "{"]],
|
235 |
-
['shift + )', ["closecurlybrace", "closecurlybracket", "}"]],
|
236 |
-
['shift + \\', ["verticalbar", "|"]],
|
237 |
-
['shift + ;', ["colon", ":"]],
|
238 |
-
['shift + \'', ["quotationmark", "\""]],
|
239 |
-
['shift + !,', ["openanglebracket", "<"]],
|
240 |
-
['shift + .', ["closeanglebracket", ">"]],
|
241 |
-
['shift + /', ["questionmark", "?"]]
|
242 |
-
]
|
243 |
-
};
|
244 |
-
//a-z and A-Z
|
245 |
-
for (aI = 65; aI <= 90; aI += 1) {
|
246 |
-
usLocale.map[aI] = String.fromCharCode(aI + 32);
|
247 |
-
usLocale.macros.push(['shift + ' + String.fromCharCode(aI + 32) + ', capslock + ' + String.fromCharCode(aI + 32), [String.fromCharCode(aI)]]);
|
248 |
-
}
|
249 |
-
registerLocale('us', usLocale);
|
250 |
-
getSetLocale('us');
|
251 |
-
|
252 |
-
|
253 |
-
//////////
|
254 |
-
// INIT //
|
255 |
-
//////////
|
256 |
-
|
257 |
-
//enable the library
|
258 |
-
enable();
|
259 |
-
|
260 |
-
|
261 |
-
/////////
|
262 |
-
// API //
|
263 |
-
/////////
|
264 |
-
|
265 |
-
//assemble the library and return it
|
266 |
-
KeyboardJS.enable = enable;
|
267 |
-
KeyboardJS.disable = disable;
|
268 |
-
KeyboardJS.activeKeys = getActiveKeys;
|
269 |
-
KeyboardJS.releaseKey = removeActiveKey;
|
270 |
-
KeyboardJS.pressKey = addActiveKey;
|
271 |
-
KeyboardJS.on = createBinding;
|
272 |
-
KeyboardJS.clear = removeBindingByKeyCombo;
|
273 |
-
KeyboardJS.clear.key = removeBindingByKeyName;
|
274 |
-
KeyboardJS.locale = getSetLocale;
|
275 |
-
KeyboardJS.locale.register = registerLocale;
|
276 |
-
KeyboardJS.macro = createMacro;
|
277 |
-
KeyboardJS.macro.remove = removeMacro;
|
278 |
-
KeyboardJS.key = {};
|
279 |
-
KeyboardJS.key.name = getKeyName;
|
280 |
-
KeyboardJS.key.code = getKeyCode;
|
281 |
-
KeyboardJS.combo = {};
|
282 |
-
KeyboardJS.combo.active = isSatisfiedCombo;
|
283 |
-
KeyboardJS.combo.parse = parseKeyCombo;
|
284 |
-
KeyboardJS.combo.stringify = stringifyKeyCombo;
|
285 |
-
return KeyboardJS;
|
286 |
-
|
287 |
-
|
288 |
-
//////////////////////
|
289 |
-
// INSTANCE METHODS //
|
290 |
-
//////////////////////
|
291 |
-
|
292 |
-
/**
|
293 |
-
* Enables KeyboardJS
|
294 |
-
*/
|
295 |
-
function enable() {
|
296 |
-
if(targetWindow.addEventListener) {
|
297 |
-
targetWindow.document.addEventListener('keydown', keydown, false);
|
298 |
-
targetWindow.document.addEventListener('keyup', keyup, false);
|
299 |
-
targetWindow.addEventListener('blur', reset, false);
|
300 |
-
targetWindow.addEventListener('webkitfullscreenchange', reset, false);
|
301 |
-
targetWindow.addEventListener('mozfullscreenchange', reset, false);
|
302 |
-
} else if(targetWindow.attachEvent) {
|
303 |
-
targetWindow.document.attachEvent('onkeydown', keydown);
|
304 |
-
targetWindow.document.attachEvent('onkeyup', keyup);
|
305 |
-
targetWindow.attachEvent('onblur', reset);
|
306 |
-
}
|
307 |
-
}
|
308 |
-
|
309 |
-
/**
|
310 |
-
* Exits all active bindings and disables KeyboardJS
|
311 |
-
*/
|
312 |
-
function disable() {
|
313 |
-
reset();
|
314 |
-
if(targetWindow.removeEventListener) {
|
315 |
-
targetWindow.document.removeEventListener('keydown', keydown, false);
|
316 |
-
targetWindow.document.removeEventListener('keyup', keyup, false);
|
317 |
-
targetWindow.removeEventListener('blur', reset, false);
|
318 |
-
targetWindow.removeEventListener('webkitfullscreenchange', reset, false);
|
319 |
-
targetWindow.removeEventListener('mozfullscreenchange', reset, false);
|
320 |
-
} else if(targetWindow.detachEvent) {
|
321 |
-
targetWindow.document.detachEvent('onkeydown', keydown);
|
322 |
-
targetWindow.document.detachEvent('onkeyup', keyup);
|
323 |
-
targetWindow.detachEvent('onblur', reset);
|
324 |
-
}
|
325 |
-
}
|
326 |
-
|
327 |
-
|
328 |
-
////////////////////
|
329 |
-
// EVENT HANDLERS //
|
330 |
-
////////////////////
|
331 |
-
|
332 |
-
/**
|
333 |
-
* Exits all active bindings. Optionally passes an event to all binding
|
334 |
-
* handlers.
|
335 |
-
* @param {KeyboardEvent} event [Optional]
|
336 |
-
*/
|
337 |
-
function reset(event) {
|
338 |
-
activeKeys = [];
|
339 |
-
pruneMacros();
|
340 |
-
pruneBindings(event);
|
341 |
-
}
|
342 |
-
|
343 |
-
/**
|
344 |
-
* Key down event handler.
|
345 |
-
* @param {KeyboardEvent} event
|
346 |
-
*/
|
347 |
-
function keydown(event) {
|
348 |
-
var keyNames, keyName, kI;
|
349 |
-
keyNames = getKeyName(event.keyCode);
|
350 |
-
if(keyNames.length < 1) { return; }
|
351 |
-
event.isRepeat = false;
|
352 |
-
for(kI = 0; kI < keyNames.length; kI += 1) {
|
353 |
-
keyName = keyNames[kI];
|
354 |
-
if (getActiveKeys().indexOf(keyName) != -1)
|
355 |
-
event.isRepeat = true;
|
356 |
-
addActiveKey(keyName);
|
357 |
-
}
|
358 |
-
executeMacros();
|
359 |
-
executeBindings(event);
|
360 |
-
}
|
361 |
-
|
362 |
-
/**
|
363 |
-
* Key up event handler.
|
364 |
-
* @param {KeyboardEvent} event
|
365 |
-
*/
|
366 |
-
function keyup(event) {
|
367 |
-
var keyNames, kI;
|
368 |
-
keyNames = getKeyName(event.keyCode);
|
369 |
-
if(keyNames.length < 1) { return; }
|
370 |
-
for(kI = 0; kI < keyNames.length; kI += 1) {
|
371 |
-
removeActiveKey(keyNames[kI]);
|
372 |
-
}
|
373 |
-
pruneMacros();
|
374 |
-
pruneBindings(event);
|
375 |
-
}
|
376 |
-
|
377 |
-
/**
|
378 |
-
* Accepts a key code and returns the key names defined by the current
|
379 |
-
* locale.
|
380 |
-
* @param {Number} keyCode
|
381 |
-
* @return {Array} keyNames An array of key names defined for the key
|
382 |
-
* code as defined by the current locale.
|
383 |
-
*/
|
384 |
-
function getKeyName(keyCode) {
|
385 |
-
return map[keyCode] || [];
|
386 |
-
}
|
387 |
-
|
388 |
-
/**
|
389 |
-
* Accepts a key name and returns the key code defined by the current
|
390 |
-
* locale.
|
391 |
-
* @param {Number} keyName
|
392 |
-
* @return {Number|false}
|
393 |
-
*/
|
394 |
-
function getKeyCode(keyName) {
|
395 |
-
var keyCode;
|
396 |
-
for(keyCode in map) {
|
397 |
-
if(!map.hasOwnProperty(keyCode)) { continue; }
|
398 |
-
if(map[keyCode].indexOf(keyName) > -1) { return keyCode; }
|
399 |
-
}
|
400 |
-
return false;
|
401 |
-
}
|
402 |
-
|
403 |
-
|
404 |
-
////////////
|
405 |
-
// MACROS //
|
406 |
-
////////////
|
407 |
-
|
408 |
-
/**
|
409 |
-
* Accepts a key combo and an array of key names to inject once the key
|
410 |
-
* combo is satisfied.
|
411 |
-
* @param {String} combo
|
412 |
-
* @param {Array} injectedKeys
|
413 |
-
*/
|
414 |
-
function createMacro(combo, injectedKeys) {
|
415 |
-
if(typeof combo !== 'string' && (typeof combo !== 'object' || typeof combo.push !== 'function')) {
|
416 |
-
throw new Error("Cannot create macro. The combo must be a string or array.");
|
417 |
-
}
|
418 |
-
if(typeof injectedKeys !== 'object' || typeof injectedKeys.push !== 'function') {
|
419 |
-
throw new Error("Cannot create macro. The injectedKeys must be an array.");
|
420 |
-
}
|
421 |
-
macros.push([combo, injectedKeys]);
|
422 |
-
}
|
423 |
-
|
424 |
-
/**
|
425 |
-
* Accepts a key combo and clears any and all macros bound to that key
|
426 |
-
* combo.
|
427 |
-
* @param {String} combo
|
428 |
-
*/
|
429 |
-
function removeMacro(combo) {
|
430 |
-
var macro;
|
431 |
-
if(typeof combo !== 'string' && (typeof combo !== 'object' || typeof combo.push !== 'function')) { throw new Error("Cannot remove macro. The combo must be a string or array."); }
|
432 |
-
for(mI = 0; mI < macros.length; mI += 1) {
|
433 |
-
macro = macros[mI];
|
434 |
-
if(compareCombos(combo, macro[0])) {
|
435 |
-
removeActiveKey(macro[1]);
|
436 |
-
macros.splice(mI, 1);
|
437 |
-
break;
|
438 |
-
}
|
439 |
-
}
|
440 |
-
}
|
441 |
-
|
442 |
-
/**
|
443 |
-
* Executes macros against the active keys. Each macro's key combo is
|
444 |
-
* checked and if found to be satisfied, the macro's key names are injected
|
445 |
-
* into active keys.
|
446 |
-
*/
|
447 |
-
function executeMacros() {
|
448 |
-
var mI, combo, kI;
|
449 |
-
for(mI = 0; mI < macros.length; mI += 1) {
|
450 |
-
combo = parseKeyCombo(macros[mI][0]);
|
451 |
-
if(activeMacros.indexOf(macros[mI]) === -1 && isSatisfiedCombo(combo)) {
|
452 |
-
activeMacros.push(macros[mI]);
|
453 |
-
for(kI = 0; kI < macros[mI][1].length; kI += 1) {
|
454 |
-
addActiveKey(macros[mI][1][kI]);
|
455 |
-
}
|
456 |
-
}
|
457 |
-
}
|
458 |
-
}
|
459 |
-
|
460 |
-
/**
|
461 |
-
* Prunes active macros. Checks each active macro's key combo and if found
|
462 |
-
* to no longer to be satisfied, each of the macro's key names are removed
|
463 |
-
* from active keys.
|
464 |
-
*/
|
465 |
-
function pruneMacros() {
|
466 |
-
var mI, combo, kI;
|
467 |
-
for(mI = 0; mI < activeMacros.length; mI += 1) {
|
468 |
-
combo = parseKeyCombo(activeMacros[mI][0]);
|
469 |
-
if(isSatisfiedCombo(combo) === false) {
|
470 |
-
for(kI = 0; kI < activeMacros[mI][1].length; kI += 1) {
|
471 |
-
removeActiveKey(activeMacros[mI][1][kI]);
|
472 |
-
}
|
473 |
-
activeMacros.splice(mI, 1);
|
474 |
-
mI -= 1;
|
475 |
-
}
|
476 |
-
}
|
477 |
-
}
|
478 |
-
|
479 |
-
|
480 |
-
//////////////
|
481 |
-
// BINDINGS //
|
482 |
-
//////////////
|
483 |
-
|
484 |
-
/**
|
485 |
-
* Creates a binding object, and, if provided, binds a key down hander and
|
486 |
-
* a key up handler. Returns a binding object that emits keyup and
|
487 |
-
* keydown events.
|
488 |
-
* @param {String} keyCombo
|
489 |
-
* @param {Function} keyDownCallback [Optional]
|
490 |
-
* @param {Function} keyUpCallback [Optional]
|
491 |
-
* @return {Object} binding
|
492 |
-
*/
|
493 |
-
function createBinding(keyCombo, keyDownCallback, keyUpCallback) {
|
494 |
-
var api = {}, binding, subBindings = [], bindingApi = {}, kI,
|
495 |
-
subCombo;
|
496 |
-
|
497 |
-
//break the combo down into a combo array
|
498 |
-
if(typeof keyCombo === 'string') {
|
499 |
-
keyCombo = parseKeyCombo(keyCombo);
|
500 |
-
}
|
501 |
-
|
502 |
-
//bind each sub combo contained within the combo string
|
503 |
-
for(kI = 0; kI < keyCombo.length; kI += 1) {
|
504 |
-
binding = {};
|
505 |
-
|
506 |
-
//stringify the combo again
|
507 |
-
subCombo = stringifyKeyCombo([keyCombo[kI]]);
|
508 |
-
|
509 |
-
//validate the sub combo
|
510 |
-
if(typeof subCombo !== 'string') { throw new Error('Failed to bind key combo. The key combo must be string.'); }
|
511 |
-
|
512 |
-
//create the binding
|
513 |
-
binding.keyCombo = subCombo;
|
514 |
-
binding.keyDownCallback = [];
|
515 |
-
binding.keyUpCallback = [];
|
516 |
-
|
517 |
-
//inject the key down and key up callbacks if given
|
518 |
-
if(keyDownCallback) { binding.keyDownCallback.push(keyDownCallback); }
|
519 |
-
if(keyUpCallback) { binding.keyUpCallback.push(keyUpCallback); }
|
520 |
-
|
521 |
-
//stash the new binding
|
522 |
-
bindings.push(binding);
|
523 |
-
subBindings.push(binding);
|
524 |
-
}
|
525 |
-
|
526 |
-
//build the binding api
|
527 |
-
api.clear = clear;
|
528 |
-
api.on = on;
|
529 |
-
return api;
|
530 |
-
|
531 |
-
/**
|
532 |
-
* Clears the binding
|
533 |
-
*/
|
534 |
-
function clear() {
|
535 |
-
var bI;
|
536 |
-
for(bI = 0; bI < subBindings.length; bI += 1) {
|
537 |
-
bindings.splice(bindings.indexOf(subBindings[bI]), 1);
|
538 |
-
}
|
539 |
-
}
|
540 |
-
|
541 |
-
/**
|
542 |
-
* Accepts an event name. and any number of callbacks. When the event is
|
543 |
-
* emitted, all callbacks are executed. Available events are key up and
|
544 |
-
* key down.
|
545 |
-
* @param {String} eventName
|
546 |
-
* @return {Object} subBinding
|
547 |
-
*/
|
548 |
-
function on(eventName ) {
|
549 |
-
var api = {}, callbacks, cI, bI;
|
550 |
-
|
551 |
-
//validate event name
|
552 |
-
if(typeof eventName !== 'string') { throw new Error('Cannot bind callback. The event name must be a string.'); }
|
553 |
-
if(eventName !== 'keyup' && eventName !== 'keydown') { throw new Error('Cannot bind callback. The event name must be a "keyup" or "keydown".'); }
|
554 |
-
|
555 |
-
//gather the callbacks
|
556 |
-
callbacks = Array.prototype.slice.apply(arguments, [1]);
|
557 |
-
|
558 |
-
//stash each the new binding
|
559 |
-
for(cI = 0; cI < callbacks.length; cI += 1) {
|
560 |
-
if(typeof callbacks[cI] === 'function') {
|
561 |
-
if(eventName === 'keyup') {
|
562 |
-
for(bI = 0; bI < subBindings.length; bI += 1) {
|
563 |
-
subBindings[bI].keyUpCallback.push(callbacks[cI]);
|
564 |
-
}
|
565 |
-
} else if(eventName === 'keydown') {
|
566 |
-
for(bI = 0; bI < subBindings.length; bI += 1) {
|
567 |
-
subBindings[bI].keyDownCallback.push(callbacks[cI]);
|
568 |
-
}
|
569 |
-
}
|
570 |
-
}
|
571 |
-
}
|
572 |
-
|
573 |
-
//construct and return the sub binding api
|
574 |
-
api.clear = clear;
|
575 |
-
return api;
|
576 |
-
|
577 |
-
/**
|
578 |
-
* Clears the binding
|
579 |
-
*/
|
580 |
-
function clear() {
|
581 |
-
var cI, bI;
|
582 |
-
for(cI = 0; cI < callbacks.length; cI += 1) {
|
583 |
-
if(typeof callbacks[cI] === 'function') {
|
584 |
-
if(eventName === 'keyup') {
|
585 |
-
for(bI = 0; bI < subBindings.length; bI += 1) {
|
586 |
-
subBindings[bI].keyUpCallback.splice(subBindings[bI].keyUpCallback.indexOf(callbacks[cI]), 1);
|
587 |
-
}
|
588 |
-
} else {
|
589 |
-
for(bI = 0; bI < subBindings.length; bI += 1) {
|
590 |
-
subBindings[bI].keyDownCallback.splice(subBindings[bI].keyDownCallback.indexOf(callbacks[cI]), 1);
|
591 |
-
}
|
592 |
-
}
|
593 |
-
}
|
594 |
-
}
|
595 |
-
}
|
596 |
-
}
|
597 |
-
}
|
598 |
-
|
599 |
-
/**
|
600 |
-
* Clears all binding attached to a given key combo. Key name order does not
|
601 |
-
* matter as long as the key combos equate.
|
602 |
-
* @param {String} keyCombo
|
603 |
-
*/
|
604 |
-
function removeBindingByKeyCombo(keyCombo) {
|
605 |
-
var bI, binding, keyName;
|
606 |
-
for(bI = 0; bI < bindings.length; bI += 1) {
|
607 |
-
binding = bindings[bI];
|
608 |
-
if(compareCombos(keyCombo, binding.keyCombo)) {
|
609 |
-
bindings.splice(bI, 1); bI -= 1;
|
610 |
-
}
|
611 |
-
}
|
612 |
-
}
|
613 |
-
|
614 |
-
/**
|
615 |
-
* Clears all binding attached to key combos containing a given key name.
|
616 |
-
* @param {String} keyName
|
617 |
-
*/
|
618 |
-
function removeBindingByKeyName(keyName) {
|
619 |
-
var bI, kI, binding;
|
620 |
-
if(keyName) {
|
621 |
-
for(bI = 0; bI < bindings.length; bI += 1) {
|
622 |
-
binding = bindings[bI];
|
623 |
-
for(kI = 0; kI < binding.keyCombo.length; kI += 1) {
|
624 |
-
if(binding.keyCombo[kI].indexOf(keyName) > -1) {
|
625 |
-
bindings.splice(bI, 1); bI -= 1;
|
626 |
-
break;
|
627 |
-
}
|
628 |
-
}
|
629 |
-
}
|
630 |
-
} else {
|
631 |
-
bindings = [];
|
632 |
-
}
|
633 |
-
}
|
634 |
-
|
635 |
-
/**
|
636 |
-
* Executes bindings that are active. Only allows the keys to be used once
|
637 |
-
* as to prevent binding overlap.
|
638 |
-
* @param {KeyboardEvent} event The keyboard event.
|
639 |
-
*/
|
640 |
-
function executeBindings(event) {
|
641 |
-
var bI, sBI, binding, bindingKeys, remainingKeys, cI, killEventBubble, kI, bindingKeysSatisfied,
|
642 |
-
index, sortedBindings = [], bindingWeight;
|
643 |
-
|
644 |
-
remainingKeys = [].concat(activeKeys);
|
645 |
-
for(bI = 0; bI < bindings.length; bI += 1) {
|
646 |
-
bindingWeight = extractComboKeys(bindings[bI].keyCombo).length;
|
647 |
-
if(!sortedBindings[bindingWeight]) { sortedBindings[bindingWeight] = []; }
|
648 |
-
sortedBindings[bindingWeight].push(bindings[bI]);
|
649 |
-
}
|
650 |
-
for(sBI = sortedBindings.length - 1; sBI >= 0; sBI -= 1) {
|
651 |
-
if(!sortedBindings[sBI]) { continue; }
|
652 |
-
for(bI = 0; bI < sortedBindings[sBI].length; bI += 1) {
|
653 |
-
binding = sortedBindings[sBI][bI];
|
654 |
-
bindingKeys = extractComboKeys(binding.keyCombo);
|
655 |
-
bindingKeysSatisfied = true;
|
656 |
-
for(kI = 0; kI < bindingKeys.length; kI += 1) {
|
657 |
-
if(remainingKeys.indexOf(bindingKeys[kI]) === -1) {
|
658 |
-
bindingKeysSatisfied = false;
|
659 |
-
break;
|
660 |
-
}
|
661 |
-
}
|
662 |
-
if(bindingKeysSatisfied && isSatisfiedCombo(binding.keyCombo)) {
|
663 |
-
activeBindings.push(binding);
|
664 |
-
for(kI = 0; kI < bindingKeys.length; kI += 1) {
|
665 |
-
index = remainingKeys.indexOf(bindingKeys[kI]);
|
666 |
-
if(index > -1) {
|
667 |
-
remainingKeys.splice(index, 1);
|
668 |
-
kI -= 1;
|
669 |
-
}
|
670 |
-
}
|
671 |
-
for(cI = 0; cI < binding.keyDownCallback.length; cI += 1) {
|
672 |
-
if (binding.keyDownCallback[cI](event, getActiveKeys(), binding.keyCombo) === false) {
|
673 |
-
killEventBubble = true;
|
674 |
-
}
|
675 |
-
}
|
676 |
-
if(killEventBubble === true) {
|
677 |
-
event.preventDefault();
|
678 |
-
event.stopPropagation();
|
679 |
-
}
|
680 |
-
}
|
681 |
-
}
|
682 |
-
}
|
683 |
-
}
|
684 |
-
|
685 |
-
/**
|
686 |
-
* Removes bindings that are no longer satisfied by the active keys. Also
|
687 |
-
* fires the key up callbacks.
|
688 |
-
* @param {KeyboardEvent} event
|
689 |
-
*/
|
690 |
-
function pruneBindings(event) {
|
691 |
-
var bI, cI, binding, killEventBubble;
|
692 |
-
for(bI = 0; bI < activeBindings.length; bI += 1) {
|
693 |
-
binding = activeBindings[bI];
|
694 |
-
if(isSatisfiedCombo(binding.keyCombo) === false) {
|
695 |
-
for(cI = 0; cI < binding.keyUpCallback.length; cI += 1) {
|
696 |
-
if (binding.keyUpCallback[cI](event, getActiveKeys(), binding.keyCombo) === false) {
|
697 |
-
killEventBubble = true;
|
698 |
-
}
|
699 |
-
}
|
700 |
-
if(killEventBubble === true) {
|
701 |
-
event.preventDefault();
|
702 |
-
event.stopPropagation();
|
703 |
-
}
|
704 |
-
activeBindings.splice(bI, 1);
|
705 |
-
bI -= 1;
|
706 |
-
}
|
707 |
-
}
|
708 |
-
}
|
709 |
-
|
710 |
-
|
711 |
-
///////////////////
|
712 |
-
// COMBO STRINGS //
|
713 |
-
///////////////////
|
714 |
-
|
715 |
-
/**
|
716 |
-
* Compares two key combos returning true when they are functionally
|
717 |
-
* equivalent.
|
718 |
-
* @param {String} keyComboArrayA keyCombo A key combo string or array.
|
719 |
-
* @param {String} keyComboArrayB keyCombo A key combo string or array.
|
720 |
-
* @return {Boolean}
|
721 |
-
*/
|
722 |
-
function compareCombos(keyComboArrayA, keyComboArrayB) {
|
723 |
-
var cI, sI, kI;
|
724 |
-
keyComboArrayA = parseKeyCombo(keyComboArrayA);
|
725 |
-
keyComboArrayB = parseKeyCombo(keyComboArrayB);
|
726 |
-
if(keyComboArrayA.length !== keyComboArrayB.length) { return false; }
|
727 |
-
for(cI = 0; cI < keyComboArrayA.length; cI += 1) {
|
728 |
-
if(keyComboArrayA[cI].length !== keyComboArrayB[cI].length) { return false; }
|
729 |
-
for(sI = 0; sI < keyComboArrayA[cI].length; sI += 1) {
|
730 |
-
if(keyComboArrayA[cI][sI].length !== keyComboArrayB[cI][sI].length) { return false; }
|
731 |
-
for(kI = 0; kI < keyComboArrayA[cI][sI].length; kI += 1) {
|
732 |
-
if(keyComboArrayB[cI][sI].indexOf(keyComboArrayA[cI][sI][kI]) === -1) { return false; }
|
733 |
-
}
|
734 |
-
}
|
735 |
-
}
|
736 |
-
return true;
|
737 |
-
}
|
738 |
-
|
739 |
-
/**
|
740 |
-
* Checks to see if a key combo string or key array is satisfied by the
|
741 |
-
* currently active keys. It does not take into account spent keys.
|
742 |
-
* @param {String} keyCombo A key combo string or array.
|
743 |
-
* @return {Boolean}
|
744 |
-
*/
|
745 |
-
function isSatisfiedCombo(keyCombo) {
|
746 |
-
var cI, sI, stage, kI, stageOffset = 0, index, comboMatches;
|
747 |
-
keyCombo = parseKeyCombo(keyCombo);
|
748 |
-
for(cI = 0; cI < keyCombo.length; cI += 1) {
|
749 |
-
comboMatches = true;
|
750 |
-
stageOffset = 0;
|
751 |
-
for(sI = 0; sI < keyCombo[cI].length; sI += 1) {
|
752 |
-
stage = [].concat(keyCombo[cI][sI]);
|
753 |
-
for(kI = stageOffset; kI < activeKeys.length; kI += 1) {
|
754 |
-
index = stage.indexOf(activeKeys[kI]);
|
755 |
-
if(index > -1) {
|
756 |
-
stage.splice(index, 1);
|
757 |
-
stageOffset = kI;
|
758 |
-
}
|
759 |
-
}
|
760 |
-
if(stage.length !== 0) { comboMatches = false; break; }
|
761 |
-
}
|
762 |
-
if(comboMatches) { return true; }
|
763 |
-
}
|
764 |
-
return false;
|
765 |
-
}
|
766 |
-
|
767 |
-
/**
|
768 |
-
* Accepts a key combo array or string and returns a flat array containing all keys referenced by
|
769 |
-
* the key combo.
|
770 |
-
* @param {String} keyCombo A key combo string or array.
|
771 |
-
* @return {Array}
|
772 |
-
*/
|
773 |
-
function extractComboKeys(keyCombo) {
|
774 |
-
var cI, sI, kI, keys = [];
|
775 |
-
keyCombo = parseKeyCombo(keyCombo);
|
776 |
-
for(cI = 0; cI < keyCombo.length; cI += 1) {
|
777 |
-
for(sI = 0; sI < keyCombo[cI].length; sI += 1) {
|
778 |
-
keys = keys.concat(keyCombo[cI][sI]);
|
779 |
-
}
|
780 |
-
}
|
781 |
-
return keys;
|
782 |
-
}
|
783 |
-
|
784 |
-
/**
|
785 |
-
* Parses a key combo string into a 3 dimensional array.
|
786 |
-
* - Level 1 - sub combos.
|
787 |
-
* - Level 2 - combo stages. A stage is a set of key name pairs that must
|
788 |
-
* be satisfied in the order they are defined.
|
789 |
-
* - Level 3 - each key name to the stage.
|
790 |
-
* @param {String|Array} keyCombo A key combo string.
|
791 |
-
* @return {Array}
|
792 |
-
*/
|
793 |
-
function parseKeyCombo(keyCombo) {
|
794 |
-
var s = keyCombo, i = 0, op = 0, ws = false, nc = false, combos = [], combo = [], stage = [], key = '';
|
795 |
-
|
796 |
-
if(typeof keyCombo === 'object' && typeof keyCombo.push === 'function') { return keyCombo; }
|
797 |
-
if(typeof keyCombo !== 'string') { throw new Error('Cannot parse "keyCombo" because its type is "' + (typeof keyCombo) + '". It must be a "string".'); }
|
798 |
-
|
799 |
-
//remove leading whitespace
|
800 |
-
while(s.charAt(i) === ' ') { i += 1; }
|
801 |
-
while(true) {
|
802 |
-
if(s.charAt(i) === ' ') {
|
803 |
-
//white space & next combo op
|
804 |
-
while(s.charAt(i) === ' ') { i += 1; }
|
805 |
-
ws = true;
|
806 |
-
} else if(s.charAt(i) === ',') {
|
807 |
-
if(op || nc) { throw new Error('Failed to parse key combo. Unexpected , at character index ' + i + '.'); }
|
808 |
-
nc = true;
|
809 |
-
i += 1;
|
810 |
-
} else if(s.charAt(i) === '+') {
|
811 |
-
//next key
|
812 |
-
if(key.length) { stage.push(key); key = ''; }
|
813 |
-
if(op || nc) { throw new Error('Failed to parse key combo. Unexpected + at character index ' + i + '.'); }
|
814 |
-
op = true;
|
815 |
-
i += 1;
|
816 |
-
} else if(s.charAt(i) === '>') {
|
817 |
-
//next stage op
|
818 |
-
if(key.length) { stage.push(key); key = ''; }
|
819 |
-
if(stage.length) { combo.push(stage); stage = []; }
|
820 |
-
if(op || nc) { throw new Error('Failed to parse key combo. Unexpected > at character index ' + i + '.'); }
|
821 |
-
op = true;
|
822 |
-
i += 1;
|
823 |
-
} else if(i < s.length - 1 && s.charAt(i) === '!' && (s.charAt(i + 1) === '>' || s.charAt(i + 1) === ',' || s.charAt(i + 1) === '+')) {
|
824 |
-
key += s.charAt(i + 1);
|
825 |
-
op = false;
|
826 |
-
ws = false;
|
827 |
-
nc = false;
|
828 |
-
i += 2;
|
829 |
-
} else if(i < s.length && s.charAt(i) !== '+' && s.charAt(i) !== '>' && s.charAt(i) !== ',' && s.charAt(i) !== ' ') {
|
830 |
-
//end combo
|
831 |
-
if(op === false && ws === true || nc === true) {
|
832 |
-
if(key.length) { stage.push(key); key = ''; }
|
833 |
-
if(stage.length) { combo.push(stage); stage = []; }
|
834 |
-
if(combo.length) { combos.push(combo); combo = []; }
|
835 |
-
}
|
836 |
-
op = false;
|
837 |
-
ws = false;
|
838 |
-
nc = false;
|
839 |
-
//key
|
840 |
-
while(i < s.length && s.charAt(i) !== '+' && s.charAt(i) !== '>' && s.charAt(i) !== ',' && s.charAt(i) !== ' ') {
|
841 |
-
key += s.charAt(i);
|
842 |
-
i += 1;
|
843 |
-
}
|
844 |
-
} else {
|
845 |
-
//unknown char
|
846 |
-
i += 1;
|
847 |
-
continue;
|
848 |
-
}
|
849 |
-
//end of combos string
|
850 |
-
if(i >= s.length) {
|
851 |
-
if(key.length) { stage.push(key); key = ''; }
|
852 |
-
if(stage.length) { combo.push(stage); stage = []; }
|
853 |
-
if(combo.length) { combos.push(combo); combo = []; }
|
854 |
-
break;
|
855 |
-
}
|
856 |
-
}
|
857 |
-
return combos;
|
858 |
-
}
|
859 |
-
|
860 |
-
/**
|
861 |
-
* Stringifys a key combo.
|
862 |
-
* @param {Array|String} keyComboArray A key combo array. If a key
|
863 |
-
* combo string is given it will be returned.
|
864 |
-
* @return {String}
|
865 |
-
*/
|
866 |
-
function stringifyKeyCombo(keyComboArray) {
|
867 |
-
var cI, ccI, output = [];
|
868 |
-
if(typeof keyComboArray === 'string') { return keyComboArray; }
|
869 |
-
if(typeof keyComboArray !== 'object' || typeof keyComboArray.push !== 'function') { throw new Error('Cannot stringify key combo.'); }
|
870 |
-
for(cI = 0; cI < keyComboArray.length; cI += 1) {
|
871 |
-
output[cI] = [];
|
872 |
-
for(ccI = 0; ccI < keyComboArray[cI].length; ccI += 1) {
|
873 |
-
output[cI][ccI] = keyComboArray[cI][ccI].join(' + ');
|
874 |
-
}
|
875 |
-
output[cI] = output[cI].join(' > ');
|
876 |
-
}
|
877 |
-
return output.join(' ');
|
878 |
-
}
|
879 |
-
|
880 |
-
|
881 |
-
/////////////////
|
882 |
-
// ACTIVE KEYS //
|
883 |
-
/////////////////
|
884 |
-
|
885 |
-
/**
|
886 |
-
* Returns the a copy of the active keys array.
|
887 |
-
* @return {Array}
|
888 |
-
*/
|
889 |
-
function getActiveKeys() {
|
890 |
-
return [].concat(activeKeys);
|
891 |
-
}
|
892 |
-
|
893 |
-
/**
|
894 |
-
* Adds a key to the active keys array, but only if it has not already been
|
895 |
-
* added.
|
896 |
-
* @param {String} keyName The key name string.
|
897 |
-
*/
|
898 |
-
function addActiveKey(keyName) {
|
899 |
-
if(keyName.match(/\s/)) { throw new Error('Cannot add key name ' + keyName + ' to active keys because it contains whitespace.'); }
|
900 |
-
if(activeKeys.indexOf(keyName) > -1) { return; }
|
901 |
-
activeKeys.push(keyName);
|
902 |
-
}
|
903 |
-
|
904 |
-
/**
|
905 |
-
* Removes a key from the active keys array.
|
906 |
-
* @param {String} keyNames The key name string.
|
907 |
-
*/
|
908 |
-
function removeActiveKey(keyName) {
|
909 |
-
var keyCode = getKeyCode(keyName);
|
910 |
-
if(keyCode === '91' || keyCode === '92') { activeKeys = []; } //remove all key on release of super.
|
911 |
-
else { activeKeys.splice(activeKeys.indexOf(keyName), 1); }
|
912 |
-
}
|
913 |
-
|
914 |
-
|
915 |
-
/////////////
|
916 |
-
// LOCALES //
|
917 |
-
/////////////
|
918 |
-
|
919 |
-
/**
|
920 |
-
* Registers a new locale. This is useful if you would like to add support for a new keyboard layout. It could also be useful for
|
921 |
-
* alternative key names. For example if you program games you could create a locale for your key mappings. Instead of key 65 mapped
|
922 |
-
* to 'a' you could map it to 'jump'.
|
923 |
-
* @param {String} localeName The name of the new locale.
|
924 |
-
* @param {Object} localeMap The locale map.
|
925 |
-
*/
|
926 |
-
function registerLocale(localeName, localeMap) {
|
927 |
-
|
928 |
-
//validate arguments
|
929 |
-
if(typeof localeName !== 'string') { throw new Error('Cannot register new locale. The locale name must be a string.'); }
|
930 |
-
if(typeof localeMap !== 'object') { throw new Error('Cannot register ' + localeName + ' locale. The locale map must be an object.'); }
|
931 |
-
if(typeof localeMap.map !== 'object') { throw new Error('Cannot register ' + localeName + ' locale. The locale map is invalid.'); }
|
932 |
-
|
933 |
-
//stash the locale
|
934 |
-
if(!localeMap.macros) { localeMap.macros = []; }
|
935 |
-
locales[localeName] = localeMap;
|
936 |
-
}
|
937 |
-
|
938 |
-
/**
|
939 |
-
* Swaps the current locale.
|
940 |
-
* @param {String} localeName The locale to activate.
|
941 |
-
* @return {Object}
|
942 |
-
*/
|
943 |
-
function getSetLocale(localeName) {
|
944 |
-
|
945 |
-
//if a new locale is given then set it
|
946 |
-
if(localeName) {
|
947 |
-
if(typeof localeName !== 'string') { throw new Error('Cannot set locale. The locale name must be a string.'); }
|
948 |
-
if(!locales[localeName]) { throw new Error('Cannot set locale to ' + localeName + ' because it does not exist. If you would like to submit a ' + localeName + ' locale map for KeyboardJS please submit it at https://github.com/RobertWHurst/KeyboardJS/issues.'); }
|
949 |
-
|
950 |
-
//set the current map and macros
|
951 |
-
map = locales[localeName].map;
|
952 |
-
macros = locales[localeName].macros;
|
953 |
-
|
954 |
-
//set the current locale
|
955 |
-
locale = localeName;
|
956 |
-
}
|
957 |
-
|
958 |
-
//return the current locale
|
959 |
-
return locale;
|
960 |
-
}
|
961 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/utility/js/keyboard.min.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
(function(e,b){[].indexOf||(Array.prototype.indexOf=function(g,f,h){for(h=this.length,f=(h+~~f)%h;f<h&&(!(f in this)||this[f]!==g);f++){}return f^h?f:-1});if(typeof define==="function"&&define.amd){define(a)}else{if(typeof module!=="undefined"){d()}else{c()}}function a(){return f(e);function f(h){var g;g=b(h,"amd");g.fork=f;return g}}function d(){module.exports=f(e);return;function f(h){var g;g=b(h,"CommonJS");g.fork=f;return g}}function c(){var f;f=g(e);function g(k){var j,l=[],h={};j=b(k,"global");j.fork=g;j.noConflict=i;j.noConflict("KeyboardJS","k");return j;function i(){var o,n,m;m=Array.prototype.slice.apply(arguments);for(n=0;n<l.length;n+=1){if(typeof h[l[n]]==="undefined"){delete k[l[n]]}else{k[l[n]]=h[l[n]]}}h={};for(n=0;n<m.length;n+=1){if(typeof m[n]!=="string"){throw new Error("Cannot replace namespaces. All new namespaces must be strings.")}h[m[n]]=k[m[n]];k[m[n]]=j}l=m;return l}}}})(this,function(H,e){var i={},w={},o,u,B,l=[],K=[],n=[],M=[],v,m;H=H||window;m={map:{"3":["cancel"],"8":["backspace"],"9":["tab"],"12":["clear"],"13":["enter"],"16":["shift"],"17":["ctrl"],"18":["alt","menu"],"19":["pause","break"],"20":["capslock"],"27":["escape","esc"],"32":["space","spacebar"],"33":["pageup"],"34":["pagedown"],"35":["end"],"36":["home"],"37":["left"],"38":["up"],"39":["right"],"40":["down"],"41":["select"],"42":["printscreen"],"43":["execute"],"44":["snapshot"],"45":["insert","ins"],"46":["delete","del"],"47":["help"],"91":["command","windows","win","super","leftcommand","leftwindows","leftwin","leftsuper"],"92":["command","windows","win","super","rightcommand","rightwindows","rightwin","rightsuper"],"145":["scrolllock","scroll"],"186":["semicolon",";"],"187":["equal","equalsign","="],"188":["comma",","],"189":["dash","-"],"190":["period","."],"191":["slash","forwardslash","/"],"192":["graveaccent","`"],"219":["openbracket","["],"220":["backslash","\\"],"221":["closebracket","]"],"222":["apostrophe","'"],"48":["zero","0"],"49":["one","1"],"50":["two","2"],"51":["three","3"],"52":["four","4"],"53":["five","5"],"54":["six","6"],"55":["seven","7"],"56":["eight","8"],"57":["nine","9"],"96":["numzero","num0"],"97":["numone","num1"],"98":["numtwo","num2"],"99":["numthree","num3"],"100":["numfour","num4"],"101":["numfive","num5"],"102":["numsix","num6"],"103":["numseven","num7"],"104":["numeight","num8"],"105":["numnine","num9"],"106":["nummultiply","num*"],"107":["numadd","num+"],"108":["numenter"],"109":["numsubtract","num-"],"110":["numdecimal","num."],"111":["numdivide","num/"],"144":["numlock","num"],"112":["f1"],"113":["f2"],"114":["f3"],"115":["f4"],"116":["f5"],"117":["f6"],"118":["f7"],"119":["f8"],"120":["f9"],"121":["f10"],"122":["f11"],"123":["f12"]},macros:[["shift + `",["tilde","~"]],["shift + 1",["exclamation","exclamationpoint","!"]],["shift + 2",["at","@"]],["shift + 3",["number","#"]],["shift + 4",["dollar","dollars","dollarsign","$"]],["shift + 5",["percent","%"]],["shift + 6",["caret","^"]],["shift + 7",["ampersand","and","&"]],["shift + 8",["asterisk","*"]],["shift + 9",["openparen","("]],["shift + 0",["closeparen",")"]],["shift + -",["underscore","_"]],["shift + =",["plus","+"]],["shift + (",["opencurlybrace","opencurlybracket","{"]],["shift + )",["closecurlybrace","closecurlybracket","}"]],["shift + \\",["verticalbar","|"]],["shift + ;",["colon",":"]],["shift + '",["quotationmark",'"']],["shift + !,",["openanglebracket","<"]],["shift + .",["closeanglebracket",">"]],["shift + /",["questionmark","?"]]]};for(v=65;v<=90;v+=1){m.map[v]=String.fromCharCode(v+32);m.macros.push(["shift + "+String.fromCharCode(v+32)+", capslock + "+String.fromCharCode(v+32),[String.fromCharCode(v)]])}C("us",m);g("us");f();i.enable=f;i.disable=d;i.activeKeys=L;i.releaseKey=k;i.pressKey=J;i.on=t;i.clear=A;i.clear.key=c;i.locale=g;i.locale.register=C;i.macro=G;i.macro.remove=h;i.key={};i.key.name=I;i.key.code=z;i.combo={};i.combo.active=a;i.combo.parse=q;i.combo.stringify=y;return i;function f(){if(H.addEventListener){H.document.addEventListener("keydown",p,false);H.document.addEventListener("keyup",F,false);H.addEventListener("blur",E,false);H.addEventListener("webkitfullscreenchange",E,false);H.addEventListener("mozfullscreenchange",E,false)}else{if(H.attachEvent){H.document.attachEvent("onkeydown",p);H.document.attachEvent("onkeyup",F);H.attachEvent("onblur",E)}}}function d(){E();if(H.removeEventListener){H.document.removeEventListener("keydown",p,false);H.document.removeEventListener("keyup",F,false);H.removeEventListener("blur",E,false);H.removeEventListener("webkitfullscreenchange",E,false);H.removeEventListener("mozfullscreenchange",E,false)}else{if(H.detachEvent){H.document.detachEvent("onkeydown",p);H.document.detachEvent("onkeyup",F);H.detachEvent("onblur",E)}}}function E(N){l=[];r();j(N)}function p(O){var Q,N,P;Q=I(O.keyCode);if(Q.length<1){return}O.isRepeat=false;for(P=0;P<Q.length;P+=1){N=Q[P];if(L().indexOf(N)!=-1){O.isRepeat=true}J(N)}s();b(O)}function F(N){var P,O;P=I(N.keyCode);if(P.length<1){return}for(O=0;O<P.length;O+=1){k(P[O])}r();j(N)}function I(N){return u[N]||[]}function z(N){var O;for(O in u){if(!u.hasOwnProperty(O)){continue}if(u[O].indexOf(N)>-1){return O}}return false}function G(O,N){if(typeof O!=="string"&&(typeof O!=="object"||typeof O.push!=="function")){throw new Error("Cannot create macro. The combo must be a string or array.")}if(typeof N!=="object"||typeof N.push!=="function"){throw new Error("Cannot create macro. The injectedKeys must be an array.")}B.push([O,N])}function h(O){var N;if(typeof O!=="string"&&(typeof O!=="object"||typeof O.push!=="function")){throw new Error("Cannot remove macro. The combo must be a string or array.")}for(mI=0;mI<B.length;mI+=1){N=B[mI];if(D(O,N[0])){k(N[1]);B.splice(mI,1);break}}}function s(){var N,P,O;for(N=0;N<B.length;N+=1){P=q(B[N][0]);if(M.indexOf(B[N])===-1&&a(P)){M.push(B[N]);for(O=0;O<B[N][1].length;O+=1){J(B[N][1][O])}}}}function r(){var N,P,O;for(N=0;N<M.length;N+=1){P=q(M[N][0]);if(a(P)===false){for(O=0;O<M[N][1].length;O+=1){k(M[N][1][O])}M.splice(N,1);N-=1}}}function t(V,X,O){var R={},U,N=[],Q={},T,W;if(typeof V==="string"){V=q(V)}for(T=0;T<V.length;T+=1){U={};W=y([V[T]]);if(typeof W!=="string"){throw new Error("Failed to bind key combo. The key combo must be string.")}U.keyCombo=W;U.keyDownCallback=[];U.keyUpCallback=[];if(X){U.keyDownCallback.push(X)}if(O){U.keyUpCallback.push(O)}K.push(U);N.push(U)}R.clear=P;R.on=S;return R;function P(){var Y;for(Y=0;Y<N.length;Y+=1){K.splice(K.indexOf(N[Y]),1)}}function S(aa){var ac={},ad,ab,Z;if(typeof aa!=="string"){throw new Error("Cannot bind callback. The event name must be a string.")}if(aa!=="keyup"&&aa!=="keydown"){throw new Error('Cannot bind callback. The event name must be a "keyup" or "keydown".')}ad=Array.prototype.slice.apply(arguments,[1]);for(ab=0;ab<ad.length;ab+=1){if(typeof ad[ab]==="function"){if(aa==="keyup"){for(Z=0;Z<N.length;Z+=1){N[Z].keyUpCallback.push(ad[ab])}}else{if(aa==="keydown"){for(Z=0;Z<N.length;Z+=1){N[Z].keyDownCallback.push(ad[ab])}}}}}ac.clear=Y;return ac;function Y(){var af,ae;for(af=0;af<ad.length;af+=1){if(typeof ad[af]==="function"){if(aa==="keyup"){for(ae=0;ae<N.length;ae+=1){N[ae].keyUpCallback.splice(N[ae].keyUpCallback.indexOf(ad[af]),1)}}else{for(ae=0;ae<N.length;ae+=1){N[ae].keyDownCallback.splice(N[ae].keyDownCallback.indexOf(ad[af]),1)}}}}}}}function A(Q){var N,P,O;for(N=0;N<K.length;N+=1){P=K[N];if(D(Q,P.keyCombo)){K.splice(N,1);N-=1}}}function c(O){var N,P,Q;if(O){for(N=0;N<K.length;N+=1){Q=K[N];for(P=0;P<Q.keyCombo.length;P+=1){if(Q.keyCombo[P].indexOf(O)>-1){K.splice(N,1);N-=1;break}}}}else{K=[]}}function b(O){var V,X,U,N,Z,Q,R,T,Y,S,P=[],W;Z=[].concat(l);for(V=0;V<K.length;V+=1){W=x(K[V].keyCombo).length;if(!P[W]){P[W]=[]}P[W].push(K[V])}for(X=P.length-1;X>=0;X-=1){if(!P[X]){continue}for(V=0;V<P[X].length;V+=1){U=P[X][V];N=x(U.keyCombo);Y=true;for(T=0;T<N.length;T+=1){if(Z.indexOf(N[T])===-1){Y=false;break}}if(Y&&a(U.keyCombo)){n.push(U);for(T=0;T<N.length;T+=1){S=Z.indexOf(N[T]);if(S>-1){Z.splice(S,1);T-=1}}for(Q=0;Q<U.keyDownCallback.length;Q+=1){if(U.keyDownCallback[Q](O,L(),U.keyCombo)===false){R=true}}if(R===true){O.preventDefault();O.stopPropagation()}}}}}function j(Q){var N,P,R,O;for(N=0;N<n.length;N+=1){R=n[N];if(a(R.keyCombo)===false){for(P=0;P<R.keyUpCallback.length;P+=1){if(R.keyUpCallback[P](Q,L(),R.keyCombo)===false){O=true}}if(O===true){Q.preventDefault();Q.stopPropagation()}n.splice(N,1);N-=1}}}function D(Q,P){var O,N,R;Q=q(Q);P=q(P);if(Q.length!==P.length){return false}for(O=0;O<Q.length;O+=1){if(Q[O].length!==P[O].length){return false}for(N=0;N<Q[O].length;N+=1){if(Q[O][N].length!==P[O][N].length){return false}for(R=0;R<Q[O][N].length;R+=1){if(P[O][N].indexOf(Q[O][N][R])===-1){return false}}}}return true}function a(U){var R,O,Q,T,S=0,P,N;U=q(U);for(R=0;R<U.length;R+=1){N=true;S=0;for(O=0;O<U[R].length;O+=1){Q=[].concat(U[R][O]);for(T=S;T<l.length;T+=1){P=Q.indexOf(l[T]);if(P>-1){Q.splice(P,1);S=T}}if(Q.length!==0){N=false;break}}if(N){return true}}return false}function x(R){var O,N,Q,P=[];R=q(R);for(O=0;O<R.length;O+=1){for(N=0;N<R[O].length;N+=1){P=P.concat(R[O][N])}}return P}function q(T){var V=T,P=0,Q=0,S=false,O=false,W=[],N=[],R=[],U="";if(typeof T==="object"&&typeof T.push==="function"){return T}if(typeof T!=="string"){throw new Error('Cannot parse "keyCombo" because its type is "'+(typeof T)+'". It must be a "string".')}while(V.charAt(P)===" "){P+=1}while(true){if(V.charAt(P)===" "){while(V.charAt(P)===" "){P+=1}S=true}else{if(V.charAt(P)===","){if(Q||O){throw new Error("Failed to parse key combo. Unexpected , at character index "+P+".")}O=true;P+=1}else{if(V.charAt(P)==="+"){if(U.length){R.push(U);U=""}if(Q||O){throw new Error("Failed to parse key combo. Unexpected + at character index "+P+".")}Q=true;P+=1}else{if(V.charAt(P)===">"){if(U.length){R.push(U);U=""}if(R.length){N.push(R);R=[]}if(Q||O){throw new Error("Failed to parse key combo. Unexpected > at character index "+P+".")}Q=true;P+=1}else{if(P<V.length-1&&V.charAt(P)==="!"&&(V.charAt(P+1)===">"||V.charAt(P+1)===","||V.charAt(P+1)==="+")){U+=V.charAt(P+1);Q=false;S=false;O=false;P+=2}else{if(P<V.length&&V.charAt(P)!=="+"&&V.charAt(P)!==">"&&V.charAt(P)!==","&&V.charAt(P)!==" "){if(Q===false&&S===true||O===true){if(U.length){R.push(U);U=""}if(R.length){N.push(R);R=[]}if(N.length){W.push(N);N=[]}}Q=false;S=false;O=false;while(P<V.length&&V.charAt(P)!=="+"&&V.charAt(P)!==">"&&V.charAt(P)!==","&&V.charAt(P)!==" "){U+=V.charAt(P);P+=1}}else{P+=1;continue}}}}}}if(P>=V.length){if(U.length){R.push(U);U=""}if(R.length){N.push(R);R=[]}if(N.length){W.push(N);N=[]}break}}return W}function y(N){var Q,P,O=[];if(typeof N==="string"){return N}if(typeof N!=="object"||typeof N.push!=="function"){throw new Error("Cannot stringify key combo.")}for(Q=0;Q<N.length;Q+=1){O[Q]=[];for(P=0;P<N[Q].length;P+=1){O[Q][P]=N[Q][P].join(" + ")}O[Q]=O[Q].join(" > ")}return O.join(" ")}function L(){return[].concat(l)}function J(N){if(N.match(/\s/)){throw new Error("Cannot add key name "+N+" to active keys because it contains whitespace.")}if(l.indexOf(N)>-1){return}l.push(N)}function k(N){var O=z(N);if(O==="91"||O==="92"){l=[]}else{l.splice(l.indexOf(N),1)}}function C(O,N){if(typeof O!=="string"){throw new Error("Cannot register new locale. The locale name must be a string.")}if(typeof N!=="object"){throw new Error("Cannot register "+O+" locale. The locale map must be an object.")}if(typeof N.map!=="object"){throw new Error("Cannot register "+O+" locale. The locale map is invalid.")}if(!N.macros){N.macros=[]}w[O]=N}function g(N){if(N){if(typeof N!=="string"){throw new Error("Cannot set locale. The locale name must be a string.")}if(!w[N]){throw new Error("Cannot set locale to "+N+" because it does not exist. If you would like to submit a "+N+" locale map for KeyboardJS please submit it at https://github.com/RobertWHurst/KeyboardJS/issues.")}u=w[N].map;B=w[N].macros;o=N}return o}});
|
|
embedded/common/utility/js/select2.min.js
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
Copyright 2014 Igor Vaynberg
|
3 |
-
|
4 |
-
Version: 3.5.2 Timestamp: Sat Nov 1 14:43:36 EDT 2014
|
5 |
-
|
6 |
-
This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
|
7 |
-
General Public License version 2 (the "GPL License"). You may choose either license to govern your
|
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(b){var c=a(document.createTextNode(""));b.before(c),c.before(b),c.remove()}function o(a){function b(a){return m[a]||a}return a.replace(/[^\u0000-\u007E]/g,b)}function p(a,b){for(var c=0,d=b.length;d>c;c+=1)if(r(a,b[c]))return c;return-1}function q(){var b=a(l);b.appendTo(document.body);var c={width:b.width()-b[0].clientWidth,height:b.height()-b[0].clientHeight};return b.remove(),c}function r(a,c){return a===c?!0:a===b||c===b?!1:null===a||null===c?!1:a.constructor===String?a+""==c+"":c.constructor===String?c+""==a+"":!1}function s(a,b,c){var d,e,f;if(null===a||a.length<1)return[];for(d=a.split(b),e=0,f=d.length;f>e;e+=1)d[e]=c(d[e]);return d}function t(a){return a.outerWidth(!1)-a.width()}function u(c){var d="keyup-change-value";c.on("keydown",function(){a.data(c,d)===b&&a.data(c,d,c.val())}),c.on("keyup",function(){var e=a.data(c,d);e!==b&&c.val()!==e&&(a.removeData(c,d),c.trigger("keyup-change"))})}function v(c){c.on("mousemove",function(c){var d=h;(d===b||d.x!==c.pageX||d.y!==c.pageY)&&a(c.target).trigger("mousemove-filtered",c)})}function w(a,c,d){d=d||b;var e;return function(){var b=arguments;window.clearTimeout(e),e=window.setTimeout(function(){c.apply(d,b)},a)}}function x(a,b){var c=w(a,function(a){b.trigger("scroll-debounced",a)});b.on("scroll",function(a){p(a.target,b.get())>=0&&c(a)})}function y(a){a[0]!==document.activeElement&&window.setTimeout(function(){var d,b=a[0],c=a.val().length;a.focus();var e=b.offsetWidth>0||b.offsetHeight>0;e&&b===document.activeElement&&(b.setSelectionRange?b.setSelectionRange(c,c):b.createTextRange&&(d=b.createTextRange(),d.collapse(!1),d.select()))},0)}function z(b){b=a(b)[0];var c=0,d=0;if("selectionStart"in b)c=b.selectionStart,d=b.selectionEnd-c;else if("selection"in document){b.focus();var e=document.selection.createRange();d=document.selection.createRange().text.length,e.moveStart("character",-b.value.length),c=e.text.length-d}return{offset:c,length:d}}function A(a){a.preventDefault(),a.stopPropagation()}function B(a){a.preventDefault(),a.stopImmediatePropagation()}function C(b){if(!g){var c=b[0].currentStyle||window.getComputedStyle(b[0],null);g=a(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:c.fontSize,fontFamily:c.fontFamily,fontStyle:c.fontStyle,fontWeight:c.fontWeight,letterSpacing:c.letterSpacing,textTransform:c.textTransform,whiteSpace:"nowrap"}),g.attr("class","select2-sizer"),a(document.body).append(g)}return g.text(b.val()),g.width()}function D(b,c,d){var e,g,f=[];e=a.trim(b.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each2(function(){0===this.indexOf("select2-")&&f.push(this)})),e=a.trim(c.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each2(function(){0!==this.indexOf("select2-")&&(g=d(this),g&&f.push(g))})),b.attr("class",f.join(" "))}function E(a,b,c,d){var e=o(a.toUpperCase()).indexOf(o(b.toUpperCase())),f=b.length;return 0>e?(c.push(d(a)),void 0):(c.push(d(a.substring(0,e))),c.push("<span class='select2-match'>"),c.push(d(a.substring(e,e+f))),c.push("</span>"),c.push(d(a.substring(e+f,a.length))),void 0)}function F(a){var b={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})}function G(c){var d,e=null,f=c.quietMillis||100,g=c.url,h=this;return function(i){window.clearTimeout(d),d=window.setTimeout(function(){var d=c.data,f=g,j=c.transport||a.fn.select2.ajaxDefaults.transport,k={type:c.type||"GET",cache:c.cache||!1,jsonpCallback:c.jsonpCallback||b,dataType:c.dataType||"json"},l=a.extend({},a.fn.select2.ajaxDefaults.params,k);d=d?d.call(h,i.term,i.page,i.context):null,f="function"==typeof f?f.call(h,i.term,i.page,i.context):f,e&&"function"==typeof e.abort&&e.abort(),c.params&&(a.isFunction(c.params)?a.extend(l,c.params.call(h)):a.extend(l,c.params)),a.extend(l,{url:f,dataType:c.dataType,data:d,success:function(a){var b=c.results(a,i.page,i);i.callback(b)},error:function(a,b,c){var d={hasError:!0,jqXHR:a,textStatus:b,errorThrown:c};i.callback(d)}}),e=j.call(h,l)},f)}}function H(b){var d,e,c=b,f=function(a){return""+a.text};a.isArray(c)&&(e=c,c={results:e}),a.isFunction(c)===!1&&(e=c,c=function(){return e});var g=c();return g.text&&(f=g.text,a.isFunction(f)||(d=g.text,f=function(a){return a[d]})),function(b){var g,d=b.term,e={results:[]};return""===d?(b.callback(c()),void 0):(g=function(c,e){var h,i;if(c=c[0],c.children){h={};for(i in c)c.hasOwnProperty(i)&&(h[i]=c[i]);h.children=[],a(c.children).each2(function(a,b){g(b,h.children)}),(h.children.length||b.matcher(d,f(h),c))&&e.push(h)}else b.matcher(d,f(c),c)&&e.push(c)},a(c().results).each2(function(a,b){g(b,e.results)}),b.callback(e),void 0)}}function I(c){var d=a.isFunction(c);return function(e){var f=e.term,g={results:[]},h=d?c(e):c;a.isArray(h)&&(a(h).each(function(){var a=this.text!==b,c=a?this.text:this;(""===f||e.matcher(f,c))&&g.results.push(a?this:{id:this,text:this})}),e.callback(g))}}function J(b,c){if(a.isFunction(b))return!0;if(!b)return!1;if("string"==typeof b)return!0;throw new Error(c+" must be a string, function, or falsy value")}function K(b,c){if(a.isFunction(b)){var d=Array.prototype.slice.call(arguments,2);return b.apply(c,d)}return b}function L(b){var c=0;return a.each(b,function(a,b){b.children?c+=L(b.children):c++}),c}function M(a,c,d,e){var h,i,j,k,l,f=a,g=!1;if(!e.createSearchChoice||!e.tokenSeparators||e.tokenSeparators.length<1)return b;for(;;){for(i=-1,j=0,k=e.tokenSeparators.length;k>j&&(l=e.tokenSeparators[j],i=a.indexOf(l),!(i>=0));j++);if(0>i)break;if(h=a.substring(0,i),a=a.substring(i+l.length),h.length>0&&(h=e.createSearchChoice.call(this,h,c),h!==b&&null!==h&&e.id(h)!==b&&null!==e.id(h))){for(g=!1,j=0,k=c.length;k>j;j++)if(r(e.id(h),e.id(c[j]))){g=!0;break}g||d(h)}}return f!==a?a:void 0}function N(){var b=this;a.each(arguments,function(a,c){b[c].remove(),b[c]=null})}function O(b,c){var d=function(){};return d.prototype=new b,d.prototype.constructor=d,d.prototype.parent=b.prototype,d.prototype=a.extend(d.prototype,c),d}if(window.Select2===b){var c,d,e,f,g,i,j,h={x:0,y:0},k={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(a){switch(a=a.which?a.which:a){case k.LEFT:case k.RIGHT:case k.UP:case k.DOWN:return!0}return!1},isControl:function(a){var b=a.which;switch(b){case k.SHIFT:case k.CTRL:case k.ALT:return!0}return a.metaKey?!0:!1},isFunctionKey:function(a){return a=a.which?a.which:a,a>=112&&123>=a}},l="<div class='select2-measure-scrollbar'></div>",m={"\u24b6":"A","\uff21":"A","\xc0":"A","\xc1":"A","\xc2":"A","\u1ea6":"A","\u1ea4":"A","\u1eaa":"A","\u1ea8":"A","\xc3":"A","\u0100":"A","\u0102":"A","\u1eb0":"A","\u1eae":"A","\u1eb4":"A","\u1eb2":"A","\u0226":"A","\u01e0":"A","\xc4":"A","\u01de":"A","\u1ea2":"A","\xc5":"A","\u01fa":"A","\u01cd":"A","\u0200":"A","\u0202":"A","\u1ea0":"A","\u1eac":"A","\u1eb6":"A","\u1e00":"A","\u0104":"A","\u023a":"A","\u2c6f":"A","\ua732":"AA","\xc6":"AE","\u01fc":"AE","\u01e2":"AE","\ua734":"AO","\ua736":"AU","\ua738":"AV","\ua73a":"AV","\ua73c":"AY","\u24b7":"B","\uff22":"B","\u1e02":"B","\u1e04":"B","\u1e06":"B","\u0243":"B","\u0182":"B","\u0181":"B","\u24b8":"C","\uff23":"C","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\xc7":"C","\u1e08":"C","\u0187":"C","\u023b":"C","\ua73e":"C","\u24b9":"D","\uff24":"D","\u1e0a":"D","\u010e":"D","\u1e0c":"D","\u1e10":"D","\u1e12":"D","\u1e0e":"D","\u0110":"D","\u018b":"D","\u018a":"D","\u0189":"D","\ua779":"D","\u01f1":"DZ","\u01c4":"DZ","\u01f2":"Dz","\u01c5":"Dz","\u24ba":"E","\uff25":"E","\xc8":"E","\xc9":"E","\xca":"E","\u1ec0":"E","\u1ebe":"E","\u1ec4":"E","\u1ec2":"E","\u1ebc":"E","\u0112":"E","\u1e14":"E","\u1e16":"E","\u0114":"E","\u0116":"E","\xcb":"E","\u1eba":"E","\u011a":"E","\u0204":"E","\u0206":"E","\u1eb8":"E","\u1ec6":"E","\u0228":"E","\u1e1c":"E","\u0118":"E","\u1e18":"E","\u1e1a":"E","\u0190":"E","\u018e":"E","\u24bb":"F","\uff26":"F","\u1e1e":"F","\u0191":"F","\ua77b":"F","\u24bc":"G","\uff27":"G","\u01f4":"G","\u011c":"G","\u1e20":"G","\u011e":"G","\u0120":"G","\u01e6":"G","\u0122":"G","\u01e4":"G","\u0193":"G","\ua7a0":"G","\ua77d":"G","\ua77e":"G","\u24bd":"H","\uff28":"H","\u0124":"H","\u1e22":"H","\u1e26":"H","\u021e":"H","\u1e24":"H","\u1e28":"H","\u1e2a":"H","\u0126":"H","\u2c67":"H","\u2c75":"H","\ua78d":"H","\u24be":"I","\uff29":"I","\xcc":"I","\xcd":"I","\xce":"I","\u0128":"I","\u012a":"I","\u012c":"I","\u0130":"I","\xcf":"I","\u1e2e":"I","\u1ec8":"I","\u01cf":"I","\u0208":"I","\u020a":"I","\u1eca":"I","\u012e":"I","\u1e2c":"I","\u0197":"I","\u24bf":"J","\uff2a":"J","\u0134":"J","\u0248":"J","\u24c0":"K","\uff2b":"K","\u1e30":"K","\u01e8":"K","\u1e32":"K","\u0136":"K","\u1e34":"K","\u0198":"K","\u2c69":"K","\ua740":"K","\ua742":"K","\ua744":"K","\ua7a2":"K","\u24c1":"L","\uff2c":"L","\u013f":"L","\u0139":"L","\u013d":"L","\u1e36":"L","\u1e38":"L","\u013b":"L","\u1e3c":"L","\u1e3a":"L","\u0141":"L","\u023d":"L","\u2c62":"L","\u2c60":"L","\ua748":"L","\ua746":"L","\ua780":"L","\u01c7":"LJ","\u01c8":"Lj","\u24c2":"M","\uff2d":"M","\u1e3e":"M","\u1e40":"M","\u1e42":"M","\u2c6e":"M","\u019c":"M","\u24c3":"N","\uff2e":"N","\u01f8":"N","\u0143":"N","\xd1":"N","\u1e44":"N","\u0147":"N","\u1e46":"N","\u0145":"N","\u1e4a":"N","\u1e48":"N","\u0220":"N","\u019d":"N","\ua790":"N","\ua7a4":"N","\u01ca":"NJ","\u01cb":"Nj","\u24c4":"O","\uff2f":"O","\xd2":"O","\xd3":"O","\xd4":"O","\u1ed2":"O","\u1ed0":"O","\u1ed6":"O","\u1ed4":"O","\xd5":"O","\u1e4c":"O","\u022c":"O","\u1e4e":"O","\u014c":"O","\u1e50":"O","\u1e52":"O","\u014e":"O","\u022e":"O","\u0230":"O","\xd6":"O","\u022a":"O","\u1ece":"O","\u0150":"O","\u01d1":"O","\u020c":"O","\u020e":"O","\u01a0":"O","\u1edc":"O","\u1eda":"O","\u1ee0":"O","\u1ede":"O","\u1ee2":"O","\u1ecc":"O","\u1ed8":"O","\u01ea":"O","\u01ec":"O","\xd8":"O","\u01fe":"O","\u0186":"O","\u019f":"O","\ua74a":"O","\ua74c":"O","\u01a2":"OI","\ua74e":"OO","\u0222":"OU","\u24c5":"P","\uff30":"P","\u1e54":"P","\u1e56":"P","\u01a4":"P","\u2c63":"P","\ua750":"P","\ua752":"P","\ua754":"P","\u24c6":"Q","\uff31":"Q","\ua756":"Q","\ua758":"Q","\u024a":"Q","\u24c7":"R","\uff32":"R","\u0154":"R","\u1e58":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1e5a":"R","\u1e5c":"R","\u0156":"R","\u1e5e":"R","\u024c":"R","\u2c64":"R","\ua75a":"R","\ua7a6":"R","\ua782":"R","\u24c8":"S","\uff33":"S","\u1e9e":"S","\u015a":"S","\u1e64":"S","\u015c":"S","\u1e60":"S","\u0160":"S","\u1e66":"S","\u1e62":"S","\u1e68":"S","\u0218":"S","\u015e":"S","\u2c7e":"S","\ua7a8":"S","\ua784":"S","\u24c9":"T","\uff34":"T","\u1e6a":"T","\u0164":"T","\u1e6c":"T","\u021a":"T","\u0162":"T","\u1e70":"T","\u1e6e":"T","\u0166":"T","\u01ac":"T","\u01ae":"T","\u023e":"T","\ua786":"T","\ua728":"TZ","\u24ca":"U","\uff35":"U","\xd9":"U","\xda":"U","\xdb":"U","\u0168":"U","\u1e78":"U","\u016a":"U","\u1e7a":"U","\u016c":"U","\xdc":"U","\u01db":"U","\u01d7":"U","\u01d5":"U","\u01d9":"U","\u1ee6":"U","\u016e":"U","\u0170":"U","\u01d3":"U","\u0214":"U","\u0216":"U","\u01af":"U","\u1eea":"U","\u1ee8":"U","\u1eee":"U","\u1eec":"U","\u1ef0":"U","\u1ee4":"U","\u1e72":"U","\u0172":"U","\u1e76":"U","\u1e74":"U","\u0244":"U","\u24cb":"V","\uff36":"V","\u1e7c":"V","\u1e7e":"V","\u01b2":"V","\ua75e":"V","\u0245":"V","\ua760":"VY","\u24cc":"W","\uff37":"W","\u1e80":"W","\u1e82":"W","\u0174":"W","\u1e86":"W","\u1e84":"W","\u1e88":"W","\u2c72":"W","\u24cd":"X","\uff38":"X","\u1e8a":"X","\u1e8c":"X","\u24ce":"Y","\uff39":"Y","\u1ef2":"Y","\xdd":"Y","\u0176":"Y","\u1ef8":"Y","\u0232":"Y","\u1e8e":"Y","\u0178":"Y","\u1ef6":"Y","\u1ef4":"Y","\u01b3":"Y","\u024e":"Y","\u1efe":"Y","\u24cf":"Z","\uff3a":"Z","\u0179":"Z","\u1e90":"Z","\u017b":"Z","\u017d":"Z","\u1e92":"Z","\u1e94":"Z","\u01b5":"Z","\u0224":"Z","\u2c7f":"Z","\u2c6b":"Z","\ua762":"Z","\u24d0":"a","\uff41":"a","\u1e9a":"a","\xe0":"a","\xe1":"a","\xe2":"a","\u1ea7":"a","\u1ea5":"a","\u1eab":"a","\u1ea9":"a","\xe3":"a","\u0101":"a","\u0103":"a","\u1eb1":"a","\u1eaf":"a","\u1eb5":"a","\u1eb3":"a","\u0227":"a","\u01e1":"a","\xe4":"a","\u01df":"a","\u1ea3":"a","\xe5":"a","\u01fb":"a","\u01ce":"a","\u0201":"a","\u0203":"a","\u1ea1":"a","\u1ead":"a","\u1eb7":"a","\u1e01":"a","\u0105":"a","\u2c65":"a","\u0250":"a","\ua733":"aa","\xe6":"ae","\u01fd":"ae","\u01e3":"ae","\ua735":"ao","\ua737":"au","\ua739":"av","\ua73b":"av","\ua73d":"ay","\u24d1":"b","\uff42":"b","\u1e03":"b","\u1e05":"b","\u1e07":"b","\u0180":"b","\u0183":"b","\u0253":"b","\u24d2":"c","\uff43":"c","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\xe7":"c","\u1e09":"c","\u0188":"c","\u023c":"c","\ua73f":"c","\u2184":"c","\u24d3":"d","\uff44":"d","\u1e0b":"d","\u010f":"d","\u1e0d":"d","\u1e11":"d","\u1e13":"d","\u1e0f":"d","\u0111":"d","\u018c":"d","\u0256":"d","\u0257":"d","\ua77a":"d","\u01f3":"dz","\u01c6":"dz","\u24d4":"e","\uff45":"e","\xe8":"e","\xe9":"e","\xea":"e","\u1ec1":"e","\u1ebf":"e","\u1ec5":"e","\u1ec3":"e","\u1ebd":"e","\u0113":"e","\u1e15":"e","\u1e17":"e","\u0115":"e","\u0117":"e","\xeb":"e","\u1ebb":"e","\u011b":"e","\u0205":"e","\u0207":"e","\u1eb9":"e","\u1ec7":"e","\u0229":"e","\u1e1d":"e","\u0119":"e","\u1e19":"e","\u1e1b":"e","\u0247":"e","\u025b":"e","\u01dd":"e","\u24d5":"f","\uff46":"f","\u1e1f":"f","\u0192":"f","\ua77c":"f","\u24d6":"g","\uff47":"g","\u01f5":"g","\u011d":"g","\u1e21":"g","\u011f":"g","\u0121":"g","\u01e7":"g","\u0123":"g","\u01e5":"g","\u0260":"g","\ua7a1":"g","\u1d79":"g","\ua77f":"g","\u24d7":"h","\uff48":"h","\u0125":"h","\u1e23":"h","\u1e27":"h","\u021f":"h","\u1e25":"h","\u1e29":"h","\u1e2b":"h","\u1e96":"h","\u0127":"h","\u2c68":"h","\u2c76":"h","\u0265":"h","\u0195":"hv","\u24d8":"i","\uff49":"i","\xec":"i","\xed":"i","\xee":"i","\u0129":"i","\u012b":"i","\u012d":"i","\xef":"i","\u1e2f":"i","\u1ec9":"i","\u01d0":"i","\u0209":"i","\u020b":"i","\u1ecb":"i","\u012f":"i","\u1e2d":"i","\u0268":"i","\u0131":"i","\u24d9":"j","\uff4a":"j","\u0135":"j","\u01f0":"j","\u0249":"j","\u24da":"k","\uff4b":"k","\u1e31":"k","\u01e9":"k","\u1e33":"k","\u0137":"k","\u1e35":"k","\u0199":"k","\u2c6a":"k","\ua741":"k","\ua743":"k","\ua745":"k","\ua7a3":"k","\u24db":"l","\uff4c":"l","\u0140":"l","\u013a":"l","\u013e":"l","\u1e37":"l","\u1e39":"l","\u013c":"l","\u1e3d":"l","\u1e3b":"l","\u017f":"l","\u0142":"l","\u019a":"l","\u026b":"l","\u2c61":"l","\ua749":"l","\ua781":"l","\ua747":"l","\u01c9":"lj","\u24dc":"m","\uff4d":"m","\u1e3f":"m","\u1e41":"m","\u1e43":"m","\u0271":"m","\u026f":"m","\u24dd":"n","\uff4e":"n","\u01f9":"n","\u0144":"n","\xf1":"n","\u1e45":"n","\u0148":"n","\u1e47":"n","\u0146":"n","\u1e4b":"n","\u1e49":"n","\u019e":"n","\u0272":"n","\u0149":"n","\ua791":"n","\ua7a5":"n","\u01cc":"nj","\u24de":"o","\uff4f":"o","\xf2":"o","\xf3":"o","\xf4":"o","\u1ed3":"o","\u1ed1":"o","\u1ed7":"o","\u1ed5":"o","\xf5":"o","\u1e4d":"o","\u022d":"o","\u1e4f":"o","\u014d":"o","\u1e51":"o","\u1e53":"o","\u014f":"o","\u022f":"o","\u0231":"o","\xf6":"o","\u022b":"o","\u1ecf":"o","\u0151":"o","\u01d2":"o","\u020d":"o","\u020f":"o","\u01a1":"o","\u1edd":"o","\u1edb":"o","\u1ee1":"o","\u1edf":"o","\u1ee3":"o","\u1ecd":"o","\u1ed9":"o","\u01eb":"o","\u01ed":"o","\xf8":"o","\u01ff":"o","\u0254":"o","\ua74b":"o","\ua74d":"o","\u0275":"o","\u01a3":"oi","\u0223":"ou","\ua74f":"oo","\u24df":"p","\uff50":"p","\u1e55":"p","\u1e57":"p","\u01a5":"p","\u1d7d":"p","\ua751":"p","\ua753":"p","\ua755":"p","\u24e0":"q","\uff51":"q","\u024b":"q","\ua757":"q","\ua759":"q","\u24e1":"r","\uff52":"r","\u0155":"r","\u1e59":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1e5b":"r","\u1e5d":"r","\u0157":"r","\u1e5f":"r","\u024d":"r","\u027d":"r","\ua75b":"r","\ua7a7":"r","\ua783":"r","\u24e2":"s","\uff53":"s","\xdf":"s","\u015b":"s","\u1e65":"s","\u015d":"s","\u1e61":"s","\u0161":"s","\u1e67":"s","\u1e63":"s","\u1e69":"s","\u0219":"s","\u015f":"s","\u023f":"s","\ua7a9":"s","\ua785":"s","\u1e9b":"s","\u24e3":"t","\uff54":"t","\u1e6b":"t","\u1e97":"t","\u0165":"t","\u1e6d":"t","\u021b":"t","\u0163":"t","\u1e71":"t","\u1e6f":"t","\u0167":"t","\u01ad":"t","\u0288":"t","\u2c66":"t","\ua787":"t","\ua729":"tz","\u24e4":"u","\uff55":"u","\xf9":"u","\xfa":"u","\xfb":"u","\u0169":"u","\u1e79":"u","\u016b":"u","\u1e7b":"u","\u016d":"u","\xfc":"u","\u01dc":"u","\u01d8":"u","\u01d6":"u","\u01da":"u","\u1ee7":"u","\u016f":"u","\u0171":"u","\u01d4":"u","\u0215":"u","\u0217":"u","\u01b0":"u","\u1eeb":"u","\u1ee9":"u","\u1eef":"u","\u1eed":"u","\u1ef1":"u","\u1ee5":"u","\u1e73":"u","\u0173":"u","\u1e77":"u","\u1e75":"u","\u0289":"u","\u24e5":"v","\uff56":"v","\u1e7d":"v","\u1e7f":"v","\u028b":"v","\ua75f":"v","\u028c":"v","\ua761":"vy","\u24e6":"w","\uff57":"w","\u1e81":"w","\u1e83":"w","\u0175":"w","\u1e87":"w","\u1e85":"w","\u1e98":"w","\u1e89":"w","\u2c73":"w","\u24e7":"x","\uff58":"x","\u1e8b":"x","\u1e8d":"x","\u24e8":"y","\uff59":"y","\u1ef3":"y","\xfd":"y","\u0177":"y","\u1ef9":"y","\u0233":"y","\u1e8f":"y","\xff":"y","\u1ef7":"y","\u1e99":"y","\u1ef5":"y","\u01b4":"y","\u024f":"y","\u1eff":"y","\u24e9":"z","\uff5a":"z","\u017a":"z","\u1e91":"z","\u017c":"z","\u017e":"z","\u1e93":"z","\u1e95":"z","\u01b6":"z","\u0225":"z","\u0240":"z","\u2c6c":"z","\ua763":"z","\u0386":"\u0391","\u0388":"\u0395","\u0389":"\u0397","\u038a":"\u0399","\u03aa":"\u0399","\u038c":"\u039f","\u038e":"\u03a5","\u03ab":"\u03a5","\u038f":"\u03a9","\u03ac":"\u03b1","\u03ad":"\u03b5","\u03ae":"\u03b7","\u03af":"\u03b9","\u03ca":"\u03b9","\u0390":"\u03b9","\u03cc":"\u03bf","\u03cd":"\u03c5","\u03cb":"\u03c5","\u03b0":"\u03c5","\u03c9":"\u03c9","\u03c2":"\u03c3"};i=a(document),f=function(){var a=1;return function(){return a++}}(),c=O(Object,{bind:function(a){var b=this;return function(){a.apply(b,arguments)}},init:function(c){var d,e,g=".select2-results";this.opts=c=this.prepareOpts(c),this.id=c.id,c.element.data("select2")!==b&&null!==c.element.data("select2")&&c.element.data("select2").destroy(),this.container=this.createContainer(),this.liveRegion=a(".select2-hidden-accessible"),0==this.liveRegion.length&&(this.liveRegion=a("<span>",{role:"status","aria-live":"polite"}).addClass("select2-hidden-accessible").appendTo(document.body)),this.containerId="s2id_"+(c.element.attr("id")||"autogen"+f()),this.containerEventName=this.containerId.replace(/([.])/g,"_").replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.container.attr("title",c.element.attr("title")),this.body=a(document.body),D(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.attr("style",c.element.attr("style")),this.container.css(K(c.containerCss,this.opts.element)),this.container.addClass(K(c.containerCssClass,this.opts.element)),this.elementTabIndex=this.opts.element.attr("tabindex"),this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",A),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),D(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(K(c.dropdownCssClass,this.opts.element)),this.dropdown.data("select2",this),this.dropdown.on("click",A),this.results=d=this.container.find(g),this.search=e=this.container.find("input.select2-input"),this.queryCount=0,this.resultsPage=0,this.context=null,this.initContainer(),this.container.on("click",A),v(this.results),this.dropdown.on("mousemove-filtered",g,this.bind(this.highlightUnderEvent)),this.dropdown.on("touchstart touchmove touchend",g,this.bind(function(a){this._touchEvent=!0,this.highlightUnderEvent(a)})),this.dropdown.on("touchmove",g,this.bind(this.touchMoved)),this.dropdown.on("touchstart touchend",g,this.bind(this.clearTouchMoved)),this.dropdown.on("click",this.bind(function(){this._touchEvent&&(this._touchEvent=!1,this.selectHighlighted())})),x(80,this.results),this.dropdown.on("scroll-debounced",g,this.bind(this.loadMoreIfNeeded)),a(this.container).on("change",".select2-input",function(a){a.stopPropagation()}),a(this.dropdown).on("change",".select2-input",function(a){a.stopPropagation()}),a.fn.mousewheel&&d.mousewheel(function(a,b,c,e){var f=d.scrollTop();e>0&&0>=f-e?(d.scrollTop(0),A(a)):0>e&&d.get(0).scrollHeight-d.scrollTop()+e<=d.height()&&(d.scrollTop(d.get(0).scrollHeight-d.height()),A(a))}),u(e),e.on("keyup-change input paste",this.bind(this.updateResults)),e.on("focus",function(){e.addClass("select2-focused")}),e.on("blur",function(){e.removeClass("select2-focused")}),this.dropdown.on("mouseup",g,this.bind(function(b){a(b.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(b),this.selectHighlighted(b))})),this.dropdown.on("click mouseup mousedown touchstart touchend focusin",function(a){a.stopPropagation()}),this.nextSearchTerm=b,a.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==c.maximumInputLength&&this.search.attr("maxlength",c.maximumInputLength);var h=c.element.prop("disabled");h===b&&(h=!1),this.enable(!h);var i=c.element.prop("readonly");i===b&&(i=!1),this.readonly(i),j=j||q(),this.autofocus=c.element.prop("autofocus"),c.element.prop("autofocus",!1),this.autofocus&&this.focus(),this.search.attr("placeholder",c.searchInputPlaceholder)},destroy:function(){var a=this.opts.element,c=a.data("select2"),d=this;this.close(),a.length&&a[0].detachEvent&&d._sync&&a.each(function(){d._sync&&this.detachEvent("onpropertychange",d._sync)}),this.propertyObserver&&(this.propertyObserver.disconnect(),this.propertyObserver=null),this._sync=null,c!==b&&(c.container.remove(),c.liveRegion.remove(),c.dropdown.remove(),a.show().removeData("select2").off(".select2").prop("autofocus",this.autofocus||!1),this.elementTabIndex?a.attr({tabindex:this.elementTabIndex}):a.removeAttr("tabindex"),a.show()),N.call(this,"container","liveRegion","dropdown","results","search")},optionToData:function(a){return a.is("option")?{id:a.prop("value"),text:a.text(),element:a.get(),css:a.attr("class"),disabled:a.prop("disabled"),locked:r(a.attr("locked"),"locked")||r(a.data("locked"),!0)}:a.is("optgroup")?{text:a.attr("label"),children:[],element:a.get(),css:a.attr("class")}:void 0},prepareOpts:function(c){var d,e,g,h,i=this;if(d=c.element,"select"===d.get(0).tagName.toLowerCase()&&(this.select=e=c.element),e&&a.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in c)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}),c=a.extend({},{populateResults:function(d,e,g){var h,j=this.opts.id,k=this.liveRegion;h=function(d,e,l){var m,n,o,p,q,r,s,t,u,v;d=c.sortResults(d,e,g);var w=[];for(m=0,n=d.length;n>m;m+=1)o=d[m],q=o.disabled===!0,p=!q&&j(o)!==b,r=o.children&&o.children.length>0,s=a("<li></li>"),s.addClass("select2-results-dept-"+l),s.addClass("select2-result"),s.addClass(p?"select2-result-selectable":"select2-result-unselectable"),q&&s.addClass("select2-disabled"),r&&s.addClass("select2-result-with-children"),s.addClass(i.opts.formatResultCssClass(o)),s.attr("role","presentation"),t=a(document.createElement("div")),t.addClass("select2-result-label"),t.attr("id","select2-result-label-"+f()),t.attr("role","option"),v=c.formatResult(o,t,g,i.opts.escapeMarkup),v!==b&&(t.html(v),s.append(t)),r&&(u=a("<ul></ul>"),u.addClass("select2-result-sub"),h(o.children,u,l+1),s.append(u)),s.data("select2-data",o),w.push(s[0]);e.append(w),k.text(c.formatMatches(d.length))},h(e,d,0)}},a.fn.select2.defaults,c),"function"!=typeof c.id&&(g=c.id,c.id=function(a){return a[g]}),a.isArray(c.element.data("select2Tags"))){if("tags"in c)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+c.element.attr("id");c.tags=c.element.data("select2Tags")}if(e?(c.query=this.bind(function(a){var f,g,h,c={results:[],more:!1},e=a.term;h=function(b,c){var d;b.is("option")?a.matcher(e,b.text(),b)&&c.push(i.optionToData(b)):b.is("optgroup")&&(d=i.optionToData(b),b.children().each2(function(a,b){h(b,d.children)}),d.children.length>0&&c.push(d))},f=d.children(),this.getPlaceholder()!==b&&f.length>0&&(g=this.getPlaceholderOption(),g&&(f=f.not(g))),f.each2(function(a,b){h(b,c.results)}),a.callback(c)}),c.id=function(a){return a.id}):"query"in c||("ajax"in c?(h=c.element.data("ajax-url"),h&&h.length>0&&(c.ajax.url=h),c.query=G.call(c.element,c.ajax)):"data"in c?c.query=H(c.data):"tags"in c&&(c.query=I(c.tags),c.createSearchChoice===b&&(c.createSearchChoice=function(b){return{id:a.trim(b),text:a.trim(b)}}),c.initSelection===b&&(c.initSelection=function(b,d){var e=[];a(s(b.val(),c.separator,c.transformVal)).each(function(){var b={id:this,text:this},d=c.tags;a.isFunction(d)&&(d=d()),a(d).each(function(){return r(this.id,b.id)?(b=this,!1):void 0}),e.push(b)}),d(e)}))),"function"!=typeof c.query)throw"query function not defined for Select2 "+c.element.attr("id");if("top"===c.createSearchChoicePosition)c.createSearchChoicePosition=function(a,b){a.unshift(b)};else if("bottom"===c.createSearchChoicePosition)c.createSearchChoicePosition=function(a,b){a.push(b)};else if("function"!=typeof c.createSearchChoicePosition)throw"invalid createSearchChoicePosition option must be 'top', 'bottom' or a custom function";return c},monitorSource:function(){var d,c=this.opts.element,e=this;c.on("change.select2",this.bind(function(){this.opts.element.data("select2-change-triggered")!==!0&&this.initSelection()})),this._sync=this.bind(function(){var a=c.prop("disabled");a===b&&(a=!1),this.enable(!a);var d=c.prop("readonly");d===b&&(d=!1),this.readonly(d),this.container&&(D(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.addClass(K(this.opts.containerCssClass,this.opts.element))),this.dropdown&&(D(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(K(this.opts.dropdownCssClass,this.opts.element)))}),c.length&&c[0].attachEvent&&c.each(function(){this.attachEvent("onpropertychange",e._sync)}),d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,d!==b&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new d(function(b){a.each(b,e._sync)}),this.propertyObserver.observe(c.get(0),{attributes:!0,subtree:!1}))},triggerSelect:function(b){var c=a.Event("select2-selecting",{val:this.id(b),object:b,choice:b});return this.opts.element.trigger(c),!c.isDefaultPrevented()},triggerChange:function(b){b=b||{},b=a.extend({},b,{type:"change",val:this.val()}),this.opts.element.data("select2-change-triggered",!0),this.opts.element.trigger(b),this.opts.element.data("select2-change-triggered",!1),this.opts.element.click(),this.opts.blurOnChange&&this.opts.element.blur()},isInterfaceEnabled:function(){return this.enabledInterface===!0},enableInterface:function(){var a=this._enabled&&!this._readonly,b=!a;return a===this.enabledInterface?!1:(this.container.toggleClass("select2-container-disabled",b),this.close(),this.enabledInterface=a,!0)},enable:function(a){a===b&&(a=!0),this._enabled!==a&&(this._enabled=a,this.opts.element.prop("disabled",!a),this.enableInterface())},disable:function(){this.enable(!1)},readonly:function(a){a===b&&(a=!1),this._readonly!==a&&(this._readonly=a,this.opts.element.prop("readonly",a),this.enableInterface())},opened:function(){return this.container?this.container.hasClass("select2-dropdown-open"):!1},positionDropdown:function(){var v,w,x,y,z,b=this.dropdown,c=this.container,d=c.offset(),e=c.outerHeight(!1),f=c.outerWidth(!1),g=b.outerHeight(!1),h=a(window),i=h.width(),k=h.height(),l=h.scrollLeft()+i,m=h.scrollTop()+k,n=d.top+e,o=d.left,p=m>=n+g,q=d.top-g>=h.scrollTop(),r=b.outerWidth(!1),s=function(){return l>=o+r},t=function(){return d.left+l+c.outerWidth(!1)>r},u=b.hasClass("select2-drop-above");u?(w=!0,!q&&p&&(x=!0,w=!1)):(w=!1,!p&&q&&(x=!0,w=!0)),x&&(b.hide(),d=this.container.offset(),e=this.container.outerHeight(!1),f=this.container.outerWidth(!1),g=b.outerHeight(!1),l=h.scrollLeft()+i,m=h.scrollTop()+k,n=d.top+e,o=d.left,r=b.outerWidth(!1),b.show(),this.focusSearch()),this.opts.dropdownAutoWidth?(z=a(".select2-results",b)[0],b.addClass("select2-drop-auto-width"),b.css("width",""),r=b.outerWidth(!1)+(z.scrollHeight===z.clientHeight?0:j.width),r>f?f=r:r=f,g=b.outerHeight(!1)):this.container.removeClass("select2-drop-auto-width"),"static"!==this.body.css("position")&&(v=this.body.offset(),n-=v.top,o-=v.left),!s()&&t()&&(o=d.left+this.container.outerWidth(!1)-r),y={left:o,width:f},w?(y.top=d.top-g,y.bottom="auto",this.container.addClass("select2-drop-above"),b.addClass("select2-drop-above")):(y.top=n,y.bottom="auto",this.container.removeClass("select2-drop-above"),b.removeClass("select2-drop-above")),y=a.extend(y,K(this.opts.dropdownCss,this.opts.element)),b.css(y)},shouldOpen:function(){var b;return this.opened()?!1:this._enabled===!1||this._readonly===!0?!1:(b=a.Event("select2-opening"),this.opts.element.trigger(b),!b.isDefaultPrevented())},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above")},open:function(){return this.shouldOpen()?(this.opening(),i.on("mousemove.select2Event",function(a){h.x=a.pageX,h.y=a.pageY}),!0):!1},opening:function(){var f,b=this.containerEventName,c="scroll."+b,d="resize."+b,e="orientationchange."+b;this.container.addClass("select2-dropdown-open").addClass("select2-container-active"),this.clearDropdownAlignmentPreference(),this.dropdown[0]!==this.body.children().last()[0]&&this.dropdown.detach().appendTo(this.body),f=a("#select2-drop-mask"),0===f.length&&(f=a(document.createElement("div")),f.attr("id","select2-drop-mask").attr("class","select2-drop-mask"),f.hide(),f.appendTo(this.body),f.on("mousedown touchstart click",function(b){n(f);var d,c=a("#select2-drop");c.length>0&&(d=c.data("select2"),d.opts.selectOnBlur&&d.selectHighlighted({noFocus:!0}),d.close(),b.preventDefault(),b.stopPropagation())})),this.dropdown.prev()[0]!==f[0]&&this.dropdown.before(f),a("#select2-drop").removeAttr("id"),this.dropdown.attr("id","select2-drop"),f.show(),this.positionDropdown(),this.dropdown.show(),this.positionDropdown(),this.dropdown.addClass("select2-drop-active");var g=this;this.container.parents().add(window).each(function(){a(this).on(d+" "+c+" "+e,function(){g.opened()&&g.positionDropdown()})})},close:function(){if(this.opened()){var b=this.containerEventName,c="scroll."+b,d="resize."+b,e="orientationchange."+b;this.container.parents().add(window).each(function(){a(this).off(c).off(d).off(e)}),this.clearDropdownAlignmentPreference(),a("#select2-drop-mask").hide(),this.dropdown.removeAttr("id"),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active"),this.results.empty(),i.off("mousemove.select2Event"),this.clearSearch(),this.search.removeClass("select2-active"),this.opts.element.trigger(a.Event("select2-close"))}},externalSearch:function(a){this.open(),this.search.val(a),this.updateResults(!1)},clearSearch:function(){},getMaximumSelectionSize:function(){return K(this.opts.maximumSelectionSize,this.opts.element)},ensureHighlightVisible:function(){var c,d,e,f,g,h,i,j,b=this.results;if(d=this.highlight(),!(0>d)){if(0==d)return b.scrollTop(0),void 0;c=this.findHighlightableChoices().find(".select2-result-label"),e=a(c[d]),j=(e.offset()||{}).top||0,f=j+e.outerHeight(!0),d===c.length-1&&(i=b.find("li.select2-more-results"),i.length>0&&(f=i.offset().top+i.outerHeight(!0))),g=b.offset().top+b.outerHeight(!1),f>g&&b.scrollTop(b.scrollTop()+(f-g)),h=j-b.offset().top,0>h&&"none"!=e.css("display")&&b.scrollTop(b.scrollTop()+h)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)")},moveHighlight:function(b){for(var c=this.findHighlightableChoices(),d=this.highlight();d>-1&&d<c.length;){d+=b;
|
22 |
-
var e=a(c[d]);if(e.hasClass("select2-result-selectable")&&!e.hasClass("select2-disabled")&&!e.hasClass("select2-selected")){this.highlight(d);break}}},highlight:function(b){var d,e,c=this.findHighlightableChoices();return 0===arguments.length?p(c.filter(".select2-highlighted")[0],c.get()):(b>=c.length&&(b=c.length-1),0>b&&(b=0),this.removeHighlight(),d=a(c[b]),d.addClass("select2-highlighted"),this.search.attr("aria-activedescendant",d.find(".select2-result-label").attr("id")),this.ensureHighlightVisible(),this.liveRegion.text(d.text()),e=d.data("select2-data"),e&&this.opts.element.trigger({type:"select2-highlight",val:this.id(e),choice:e}),void 0)},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},touchMoved:function(){this._touchMoved=!0},clearTouchMoved:function(){this._touchMoved=!1},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(b){var c=a(b.target).closest(".select2-result-selectable");if(c.length>0&&!c.is(".select2-highlighted")){var d=this.findHighlightableChoices();this.highlight(d.index(c))}else 0==c.length&&this.removeHighlight()},loadMoreIfNeeded:function(){var c,a=this.results,b=a.find("li.select2-more-results"),d=this.resultsPage+1,e=this,f=this.search.val(),g=this.context;0!==b.length&&(c=b.offset().top-a.offset().top-a.height(),c<=this.opts.loadMorePadding&&(b.addClass("select2-active"),this.opts.query({element:this.opts.element,term:f,page:d,context:g,matcher:this.opts.matcher,callback:this.bind(function(c){e.opened()&&(e.opts.populateResults.call(this,a,c.results,{term:f,page:d,context:g}),e.postprocessResults(c,!1,!1),c.more===!0?(b.detach().appendTo(a).html(e.opts.escapeMarkup(K(e.opts.formatLoadMore,e.opts.element,d+1))),window.setTimeout(function(){e.loadMoreIfNeeded()},10)):b.remove(),e.positionDropdown(),e.resultsPage=d,e.context=c.context,this.opts.element.trigger({type:"select2-loaded",items:c}))})})))},tokenize:function(){},updateResults:function(c){function m(){d.removeClass("select2-active"),h.positionDropdown(),e.find(".select2-no-results,.select2-selection-limit,.select2-searching").length?h.liveRegion.text(e.text()):h.liveRegion.text(h.opts.formatMatches(e.find('.select2-result-selectable:not(".select2-selected")').length))}function n(a){e.html(a),m()}var g,i,l,d=this.search,e=this.results,f=this.opts,h=this,j=d.val(),k=a.data(this.container,"select2-last-term");if((c===!0||!k||!r(j,k))&&(a.data(this.container,"select2-last-term",j),c===!0||this.showSearchInput!==!1&&this.opened())){l=++this.queryCount;var o=this.getMaximumSelectionSize();if(o>=1&&(g=this.data(),a.isArray(g)&&g.length>=o&&J(f.formatSelectionTooBig,"formatSelectionTooBig")))return n("<li class='select2-selection-limit'>"+K(f.formatSelectionTooBig,f.element,o)+"</li>"),void 0;if(d.val().length<f.minimumInputLength)return J(f.formatInputTooShort,"formatInputTooShort")?n("<li class='select2-no-results'>"+K(f.formatInputTooShort,f.element,d.val(),f.minimumInputLength)+"</li>"):n(""),c&&this.showSearch&&this.showSearch(!0),void 0;if(f.maximumInputLength&&d.val().length>f.maximumInputLength)return J(f.formatInputTooLong,"formatInputTooLong")?n("<li class='select2-no-results'>"+K(f.formatInputTooLong,f.element,d.val(),f.maximumInputLength)+"</li>"):n(""),void 0;f.formatSearching&&0===this.findHighlightableChoices().length&&n("<li class='select2-searching'>"+K(f.formatSearching,f.element)+"</li>"),d.addClass("select2-active"),this.removeHighlight(),i=this.tokenize(),i!=b&&null!=i&&d.val(i),this.resultsPage=1,f.query({element:f.element,term:d.val(),page:this.resultsPage,context:null,matcher:f.matcher,callback:this.bind(function(g){var i;if(l==this.queryCount){if(!this.opened())return this.search.removeClass("select2-active"),void 0;if(g.hasError!==b&&J(f.formatAjaxError,"formatAjaxError"))return n("<li class='select2-ajax-error'>"+K(f.formatAjaxError,f.element,g.jqXHR,g.textStatus,g.errorThrown)+"</li>"),void 0;if(this.context=g.context===b?null:g.context,this.opts.createSearchChoice&&""!==d.val()&&(i=this.opts.createSearchChoice.call(h,d.val(),g.results),i!==b&&null!==i&&h.id(i)!==b&&null!==h.id(i)&&0===a(g.results).filter(function(){return r(h.id(this),h.id(i))}).length&&this.opts.createSearchChoicePosition(g.results,i)),0===g.results.length&&J(f.formatNoMatches,"formatNoMatches"))return n("<li class='select2-no-results'>"+K(f.formatNoMatches,f.element,d.val())+"</li>"),void 0;e.empty(),h.opts.populateResults.call(this,e,g.results,{term:d.val(),page:this.resultsPage,context:null}),g.more===!0&&J(f.formatLoadMore,"formatLoadMore")&&(e.append("<li class='select2-more-results'>"+f.escapeMarkup(K(f.formatLoadMore,f.element,this.resultsPage))+"</li>"),window.setTimeout(function(){h.loadMoreIfNeeded()},10)),this.postprocessResults(g,c),m(),this.opts.element.trigger({type:"select2-loaded",items:g})}})})}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),this.close(),this.container.removeClass("select2-container-active"),this.search[0]===document.activeElement&&this.search.blur(),this.clearSearch(),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){y(this.search)},selectHighlighted:function(a){if(this._touchMoved)return this.clearTouchMoved(),void 0;var b=this.highlight(),c=this.results.find(".select2-highlighted"),d=c.closest(".select2-result").data("select2-data");d?(this.highlight(b),this.onSelect(d,a)):a&&a.noFocus&&this.close()},getPlaceholder:function(){var a;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((a=this.getPlaceholderOption())!==b?a.text():b)},getPlaceholderOption:function(){if(this.select){var c=this.select.children("option").first();if(this.opts.placeholderOption!==b)return"first"===this.opts.placeholderOption&&c||"function"==typeof this.opts.placeholderOption&&this.opts.placeholderOption(this.select);if(""===a.trim(c.text())&&""===c.val())return c}},initContainerWidth:function(){function c(){var c,d,e,f,g,h;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){if(c=this.opts.element.attr("style"),c!==b)for(d=c.split(";"),f=0,g=d.length;g>f;f+=1)if(h=d[f].replace(/\s/g,""),e=h.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i),null!==e&&e.length>=1)return e[1];return"resolve"===this.opts.width?(c=this.opts.element.css("width"),c.indexOf("%")>0?c:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px"):null}return a.isFunction(this.opts.width)?this.opts.width():this.opts.width}var d=c.call(this);null!==d&&this.container.css("width",d)}}),d=O(c,{createContainer:function(){var b=a(document.createElement("div")).attr({"class":"select2-container"}).html(["<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>"," <span class='select2-chosen'> </span><abbr class='select2-search-choice-close'></abbr>"," <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>","</a>","<label for='' class='select2-offscreen'></label>","<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />","<div class='select2-drop select2-display-none'>"," <div class='select2-search'>"," <label for='' class='select2-offscreen'></label>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'"," aria-autocomplete='list' />"," </div>"," <ul class='select2-results' role='listbox'>"," </ul>","</div>"].join(""));return b},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var c,d,e;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),this.showSearchInput!==!1&&this.search.val(this.focusser.val()),this.opts.shouldFocusInput(this)&&(this.search.focus(),c=this.search.get(0),c.createTextRange?(d=c.createTextRange(),d.collapse(!1),d.select()):c.setSelectionRange&&(e=this.search.val().length,c.setSelectionRange(e,e))),""===this.search.val()&&this.nextSearchTerm!=b&&(this.search.val(this.nextSearchTerm),this.search.select()),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger(a.Event("select2-open"))},close:function(){this.opened()&&(this.parent.close.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus()},destroy:function(){a("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments),N.call(this,"selection","focusser")},initContainer:function(){var b,g,c=this.container,d=this.dropdown,e=f();this.opts.minimumResultsForSearch<0?this.showSearch(!1):this.showSearch(!0),this.selection=b=c.find(".select2-choice"),this.focusser=c.find(".select2-focusser"),b.find(".select2-chosen").attr("id","select2-chosen-"+e),this.focusser.attr("aria-labelledby","select2-chosen-"+e),this.results.attr("id","select2-results-"+e),this.search.attr("aria-owns","select2-results-"+e),this.focusser.attr("id","s2id_autogen"+e),g=a("label[for='"+this.opts.element.attr("id")+"']"),this.opts.element.focus(this.bind(function(){this.focus()})),this.focusser.prev().text(g.text()).attr("for",this.focusser.attr("id"));var h=this.opts.element.attr("title");this.opts.element.attr("title",h||g.text()),this.focusser.attr("tabindex",this.elementTabIndex),this.search.attr("id",this.focusser.attr("id")+"_search"),this.search.prev().text(a("label[for='"+this.focusser.attr("id")+"']").text()).attr("for",this.search.attr("id")),this.search.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()&&229!=a.keyCode){if(a.which===k.PAGE_UP||a.which===k.PAGE_DOWN)return A(a),void 0;switch(a.which){case k.UP:case k.DOWN:return this.moveHighlight(a.which===k.UP?-1:1),A(a),void 0;case k.ENTER:return this.selectHighlighted(),A(a),void 0;case k.TAB:return this.selectHighlighted({noFocus:!0}),void 0;case k.ESC:return this.cancel(a),A(a),void 0}}})),this.search.on("blur",this.bind(function(){document.activeElement===this.body.get(0)&&window.setTimeout(this.bind(function(){this.opened()&&this.search.focus()}),0)})),this.focusser.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()&&a.which!==k.TAB&&!k.isControl(a)&&!k.isFunctionKey(a)&&a.which!==k.ESC){if(this.opts.openOnEnter===!1&&a.which===k.ENTER)return A(a),void 0;if(a.which==k.DOWN||a.which==k.UP||a.which==k.ENTER&&this.opts.openOnEnter){if(a.altKey||a.ctrlKey||a.shiftKey||a.metaKey)return;return this.open(),A(a),void 0}return a.which==k.DELETE||a.which==k.BACKSPACE?(this.opts.allowClear&&this.clear(),A(a),void 0):void 0}})),u(this.focusser),this.focusser.on("keyup-change input",this.bind(function(a){if(this.opts.minimumResultsForSearch>=0){if(a.stopPropagation(),this.opened())return;this.open()}})),b.on("mousedown touchstart","abbr",this.bind(function(a){this.isInterfaceEnabled()&&(this.clear(),B(a),this.close(),this.selection&&this.selection.focus())})),b.on("mousedown touchstart",this.bind(function(c){n(b),this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),A(c)})),d.on("mousedown touchstart",this.bind(function(){this.opts.shouldFocusInput(this)&&this.search.focus()})),b.on("focus",this.bind(function(a){A(a)})),this.focusser.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger(a.Event("select2-blur")))})),this.search.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.opts.element.hide(),this.setPlaceholder()},clear:function(b){var c=this.selection.data("select2-data");if(c){var d=a.Event("select2-clearing");if(this.opts.element.trigger(d),d.isDefaultPrevented())return;var e=this.getPlaceholderOption();this.opts.element.val(e?e.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),b!==!1&&(this.opts.element.trigger({type:"select2-removed",val:this.id(c),choice:c}),this.triggerChange({removed:c}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection(null),this.close(),this.setPlaceholder();else{var c=this;this.opts.initSelection.call(null,this.opts.element,function(a){a!==b&&null!==a&&(c.updateSelection(a),c.close(),c.setPlaceholder(),c.nextSearchTerm=c.opts.nextSearchTerm(a,c.search.val()))})}},isPlaceholderOptionSelected:function(){var a;return this.getPlaceholder()===b?!1:(a=this.getPlaceholderOption())!==b&&a.prop("selected")||""===this.opts.element.val()||this.opts.element.val()===b||null===this.opts.element.val()},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=a.find("option").filter(function(){return this.selected&&!this.disabled});b(c.optionToData(d))}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=c.val(),f=null;b.query({matcher:function(a,c,d){var g=r(e,b.id(d));return g&&(f=d),g},callback:a.isFunction(d)?function(){d(f)}:a.noop})}),b},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===b?b:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var a=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&a!==b){if(this.select&&this.getPlaceholderOption()===b)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(a)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(a,b,c){var d=0,e=this;if(this.findHighlightableChoices().each2(function(a,b){return r(e.id(b.data("select2-data")),e.opts.element.val())?(d=a,!1):void 0}),c!==!1&&(b===!0&&d>=0?this.highlight(d):this.highlight(0)),b===!0){var g=this.opts.minimumResultsForSearch;g>=0&&this.showSearch(L(a.results)>=g)}},showSearch:function(b){this.showSearchInput!==b&&(this.showSearchInput=b,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!b),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!b),a(this.dropdown,this.container).toggleClass("select2-with-searchbox",b))},onSelect:function(a,b){if(this.triggerSelect(a)){var c=this.opts.element.val(),d=this.data();this.opts.element.val(this.id(a)),this.updateSelection(a),this.opts.element.trigger({type:"select2-selected",val:this.id(a),choice:a}),this.nextSearchTerm=this.opts.nextSearchTerm(a,this.search.val()),this.close(),b&&b.noFocus||!this.opts.shouldFocusInput(this)||this.focusser.focus(),r(c,this.id(a))||this.triggerChange({added:a,removed:d})}},updateSelection:function(a){var d,e,c=this.selection.find(".select2-chosen");this.selection.data("select2-data",a),c.empty(),null!==a&&(d=this.opts.formatSelection(a,c,this.opts.escapeMarkup)),d!==b&&c.append(d),e=this.opts.formatSelectionCssClass(a,c),e!==b&&c.addClass(e),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==b&&this.container.addClass("select2-allowclear")},val:function(){var a,c=!1,d=null,e=this,f=this.data();if(0===arguments.length)return this.opts.element.val();if(a=arguments[0],arguments.length>1&&(c=arguments[1]),this.select)this.select.val(a).find("option").filter(function(){return this.selected}).each2(function(a,b){return d=e.optionToData(b),!1}),this.updateSelection(d),this.setPlaceholder(),c&&this.triggerChange({added:d,removed:f});else{if(!a&&0!==a)return this.clear(c),void 0;if(this.opts.initSelection===b)throw new Error("cannot call val() if initSelection() is not defined");this.opts.element.val(a),this.opts.initSelection(this.opts.element,function(a){e.opts.element.val(a?e.id(a):""),e.updateSelection(a),e.setPlaceholder(),c&&e.triggerChange({added:a,removed:f})})}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(a){var c,d=!1;return 0===arguments.length?(c=this.selection.data("select2-data"),c==b&&(c=null),c):(arguments.length>1&&(d=arguments[1]),a?(c=this.data(),this.opts.element.val(a?this.id(a):""),this.updateSelection(a),d&&this.triggerChange({added:a,removed:c})):this.clear(d),void 0)}}),e=O(c,{createContainer:function(){var b=a(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>"," <li class='select2-search-field'>"," <label for='' class='select2-offscreen'></label>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>"," </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return b},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=[];a.find("option").filter(function(){return this.selected&&!this.disabled}).each2(function(a,b){d.push(c.optionToData(b))}),b(d)}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=s(c.val(),b.separator,b.transformVal),f=[];b.query({matcher:function(c,d,g){var h=a.grep(e,function(a){return r(a,b.id(g))}).length;return h&&f.push(g),h},callback:a.isFunction(d)?function(){for(var a=[],c=0;c<e.length;c++)for(var g=e[c],h=0;h<f.length;h++){var i=f[h];if(r(g,b.id(i))){a.push(i),f.splice(h,1);break}}d(a)}:a.noop})}),b},selectChoice:function(a){var b=this.container.find(".select2-search-choice-focus");b.length&&a&&a[0]==b[0]||(b.length&&this.opts.element.trigger("choice-deselected",b),b.removeClass("select2-search-choice-focus"),a&&a.length&&(this.close(),a.addClass("select2-search-choice-focus"),this.opts.element.trigger("choice-selected",a)))},destroy:function(){a("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments),N.call(this,"searchContainer","selection")},initContainer:function(){var c,b=".select2-choices";this.searchContainer=this.container.find(".select2-search-field"),this.selection=c=this.container.find(b);var d=this;this.selection.on("click",".select2-container:not(.select2-container-disabled) .select2-search-choice:not(.select2-locked)",function(){d.search[0].focus(),d.selectChoice(a(this))}),this.search.attr("id","s2id_autogen"+f()),this.search.prev().text(a("label[for='"+this.opts.element.attr("id")+"']").text()).attr("for",this.search.attr("id")),this.opts.element.focus(this.bind(function(){this.focus()})),this.search.on("input paste",this.bind(function(){this.search.attr("placeholder")&&0==this.search.val().length||this.isInterfaceEnabled()&&(this.opened()||this.open())})),this.search.attr("tabindex",this.elementTabIndex),this.keydowns=0,this.search.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()){++this.keydowns;var b=c.find(".select2-search-choice-focus"),d=b.prev(".select2-search-choice:not(.select2-locked)"),e=b.next(".select2-search-choice:not(.select2-locked)"),f=z(this.search);if(b.length&&(a.which==k.LEFT||a.which==k.RIGHT||a.which==k.BACKSPACE||a.which==k.DELETE||a.which==k.ENTER)){var g=b;return a.which==k.LEFT&&d.length?g=d:a.which==k.RIGHT?g=e.length?e:null:a.which===k.BACKSPACE?this.unselect(b.first())&&(this.search.width(10),g=d.length?d:e):a.which==k.DELETE?this.unselect(b.first())&&(this.search.width(10),g=e.length?e:null):a.which==k.ENTER&&(g=null),this.selectChoice(g),A(a),g&&g.length||this.open(),void 0}if((a.which===k.BACKSPACE&&1==this.keydowns||a.which==k.LEFT)&&0==f.offset&&!f.length)return this.selectChoice(c.find(".select2-search-choice:not(.select2-locked)").last()),A(a),void 0;if(this.selectChoice(null),this.opened())switch(a.which){case k.UP:case k.DOWN:return this.moveHighlight(a.which===k.UP?-1:1),A(a),void 0;case k.ENTER:return this.selectHighlighted(),A(a),void 0;case k.TAB:return this.selectHighlighted({noFocus:!0}),this.close(),void 0;case k.ESC:return this.cancel(a),A(a),void 0}if(a.which!==k.TAB&&!k.isControl(a)&&!k.isFunctionKey(a)&&a.which!==k.BACKSPACE&&a.which!==k.ESC){if(a.which===k.ENTER){if(this.opts.openOnEnter===!1)return;if(a.altKey||a.ctrlKey||a.shiftKey||a.metaKey)return}this.open(),(a.which===k.PAGE_UP||a.which===k.PAGE_DOWN)&&A(a),a.which===k.ENTER&&A(a)}}})),this.search.on("keyup",this.bind(function(){this.keydowns=0,this.resizeSearch()})),this.search.on("blur",this.bind(function(b){this.container.removeClass("select2-container-active"),this.search.removeClass("select2-focused"),this.selectChoice(null),this.opened()||this.clearSearch(),b.stopImmediatePropagation(),this.opts.element.trigger(a.Event("select2-blur"))})),this.container.on("click",b,this.bind(function(b){this.isInterfaceEnabled()&&(a(b.target).closest(".select2-search-choice").length>0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.open(),this.focusSearch(),b.preventDefault()))})),this.container.on("focus",b,this.bind(function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.opts.element.hide(),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var c=this;this.opts.initSelection.call(null,this.opts.element,function(a){a!==b&&null!==a&&(c.updateSelection(a),c.close(),c.clearSearch())})}},clearSearch:function(){var a=this.getPlaceholder(),c=this.getMaxSearchWidth();a!==b&&0===this.getVal().length&&this.search.hasClass("select2-focused")===!1?(this.search.val(a).addClass("select2-default"),this.search.width(c>0?c:this.container.css("width"))):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),""===this.search.val()&&this.nextSearchTerm!=b&&(this.search.val(this.nextSearchTerm),this.search.select()),this.updateResults(!0),this.opts.shouldFocusInput(this)&&this.search.focus(),this.opts.element.trigger(a.Event("select2-open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(b){var c=[],d=[],e=this;a(b).each(function(){p(e.id(this),c)<0&&(c.push(e.id(this)),d.push(this))}),b=d,this.selection.find(".select2-search-choice").remove(),a(b).each(function(){e.addSelectedChoice(this)}),e.postprocessResults()},tokenize:function(){var a=this.search.val();a=this.opts.tokenizer.call(this,a,this.data(),this.bind(this.onSelect),this.opts),null!=a&&a!=b&&(this.search.val(a),a.length>0&&this.open())},onSelect:function(a,c){this.triggerSelect(a)&&""!==a.text&&(this.addSelectedChoice(a),this.opts.element.trigger({type:"selected",val:this.id(a),choice:a}),this.nextSearchTerm=this.opts.nextSearchTerm(a,this.search.val()),this.clearSearch(),this.updateResults(),(this.select||!this.opts.closeOnSelect)&&this.postprocessResults(a,!1,this.opts.closeOnSelect===!0),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()?this.updateResults(!0):this.nextSearchTerm!=b&&(this.search.val(this.nextSearchTerm),this.updateResults(),this.search.select()),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:a}),c&&c.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(c){var j,k,d=!c.locked,e=a("<li class='select2-search-choice'> <div></div> <a href='#' class='select2-search-choice-close' tabindex='-1'></a></li>"),f=a("<li class='select2-search-choice select2-locked'><div></div></li>"),g=d?e:f,h=this.id(c),i=this.getVal();j=this.opts.formatSelection(c,g.find("div"),this.opts.escapeMarkup),j!=b&&g.find("div").replaceWith(a("<div></div>").html(j)),k=this.opts.formatSelectionCssClass(c,g.find("div")),k!=b&&g.addClass(k),d&&g.find(".select2-search-choice-close").on("mousedown",A).on("click dblclick",this.bind(function(b){this.isInterfaceEnabled()&&(this.unselect(a(b.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),A(b),this.close(),this.focusSearch())})).on("focus",this.bind(function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),g.data("select2-data",c),g.insertBefore(this.searchContainer),i.push(h),this.setVal(i)},unselect:function(b){var d,e,c=this.getVal();if(b=b.closest(".select2-search-choice"),0===b.length)throw"Invalid argument: "+b+". Must be .select2-search-choice";if(d=b.data("select2-data")){var f=a.Event("select2-removing");if(f.val=this.id(d),f.choice=d,this.opts.element.trigger(f),f.isDefaultPrevented())return!1;for(;(e=p(this.id(d),c))>=0;)c.splice(e,1),this.setVal(c),this.select&&this.postprocessResults();return b.remove(),this.opts.element.trigger({type:"select2-removed",val:this.id(d),choice:d}),this.triggerChange({removed:d}),!0}},postprocessResults:function(a,b,c){var d=this.getVal(),e=this.results.find(".select2-result"),f=this.results.find(".select2-result-with-children"),g=this;e.each2(function(a,b){var c=g.id(b.data("select2-data"));p(c,d)>=0&&(b.addClass("select2-selected"),b.find(".select2-result-selectable").addClass("select2-selected"))}),f.each2(function(a,b){b.is(".select2-result-selectable")||0!==b.find(".select2-result-selectable:not(.select2-selected)").length||b.addClass("select2-selected")}),-1==this.highlight()&&c!==!1&&this.opts.closeOnSelect===!0&&g.highlight(0),!this.opts.createSearchChoice&&!e.filter(".select2-result:not(.select2-selected)").length>0&&(!a||a&&!a.more&&0===this.results.find(".select2-no-results").length)&&J(g.opts.formatNoMatches,"formatNoMatches")&&this.results.append("<li class='select2-no-results'>"+K(g.opts.formatNoMatches,g.opts.element,g.search.val())+"</li>")},getMaxSearchWidth:function(){return this.selection.width()-t(this.search)},resizeSearch:function(){var a,b,c,d,e,f=t(this.search);a=C(this.search)+10,b=this.search.offset().left,c=this.selection.width(),d=this.selection.offset().left,e=c-(b-d)-f,a>e&&(e=c-f),40>e&&(e=c-f),0>=e&&(e=a),this.search.width(Math.floor(e))},getVal:function(){var a;return this.select?(a=this.select.val(),null===a?[]:a):(a=this.opts.element.val(),s(a,this.opts.separator,this.opts.transformVal))},setVal:function(b){var c;this.select?this.select.val(b):(c=[],a(b).each(function(){p(this,c)<0&&c.push(this)}),this.opts.element.val(0===c.length?"":c.join(this.opts.separator)))},buildChangeDetails:function(a,b){for(var b=b.slice(0),a=a.slice(0),c=0;c<b.length;c++)for(var d=0;d<a.length;d++)r(this.opts.id(b[c]),this.opts.id(a[d]))&&(b.splice(c,1),c>0&&c--,a.splice(d,1),d--);return{added:b,removed:a}},val:function(c,d){var e,f=this;if(0===arguments.length)return this.getVal();if(e=this.data(),e.length||(e=[]),!c&&0!==c)return this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),d&&this.triggerChange({added:this.data(),removed:e}),void 0;if(this.setVal(c),this.select)this.opts.initSelection(this.select,this.bind(this.updateSelection)),d&&this.triggerChange(this.buildChangeDetails(e,this.data()));else{if(this.opts.initSelection===b)throw new Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(b){var c=a.map(b,f.id);f.setVal(c),f.updateSelection(b),f.clearSearch(),d&&f.triggerChange(f.buildChangeDetails(e,f.data()))})}this.clearSearch()},onSortStart:function(){if(this.select)throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var b=[],c=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){b.push(c.opts.id(a(this).data("select2-data")))}),this.setVal(b),this.triggerChange()},data:function(b,c){var e,f,d=this;return 0===arguments.length?this.selection.children(".select2-search-choice").map(function(){return a(this).data("select2-data")}).get():(f=this.data(),b||(b=[]),e=a.map(b,function(a){return d.opts.id(a)}),this.setVal(e),this.updateSelection(b),this.clearSearch(),c&&this.triggerChange(this.buildChangeDetails(f,this.data())),void 0)}}),a.fn.select2=function(){var d,e,f,g,h,c=Array.prototype.slice.call(arguments,0),i=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],j=["opened","isFocused","container","dropdown"],k=["val","data"],l={search:"externalSearch"};return this.each(function(){if(0===c.length||"object"==typeof c[0])d=0===c.length?{}:a.extend({},c[0]),d.element=a(this),"select"===d.element.get(0).tagName.toLowerCase()?h=d.element.prop("multiple"):(h=d.multiple||!1,"tags"in d&&(d.multiple=h=!0)),e=h?new window.Select2["class"].multi:new window.Select2["class"].single,e.init(d);else{if("string"!=typeof c[0])throw"Invalid arguments to select2 plugin: "+c;if(p(c[0],i)<0)throw"Unknown method: "+c[0];if(g=b,e=a(this).data("select2"),e===b)return;if(f=c[0],"container"===f?g=e.container:"dropdown"===f?g=e.dropdown:(l[f]&&(f=l[f]),g=e[f].apply(e,c.slice(1))),p(c[0],j)>=0||p(c[0],k)>=0&&1==c.length)return!1}}),g===b?this:g},a.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(a,b,c,d){var e=[];return E(this.text(a),c.term,e,d),e.join("")},transformVal:function(b){return a.trim(b)},formatSelection:function(a,c,d){return a?d(this.text(a)):b},sortResults:function(a){return a},formatResultCssClass:function(a){return a.css},formatSelectionCssClass:function(){return b},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(a){return a==b?null:a.id},text:function(b){return b&&this.data&&this.data.text?a.isFunction(this.data.text)?this.data.text(b):b[this.data.text]:b.text
|
23 |
-
},matcher:function(a,b){return o(""+b).toUpperCase().indexOf(o(""+a).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:M,escapeMarkup:F,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(a){return a},adaptDropdownCssClass:function(){return null},nextSearchTerm:function(){return b},searchInputPlaceholder:"",createSearchChoicePosition:"top",shouldFocusInput:function(a){var b="ontouchstart"in window||navigator.msMaxTouchPoints>0;return b?a.opts.minimumResultsForSearch<0?!1:!0:!0}},a.fn.select2.locales=[],a.fn.select2.locales.en={formatMatches:function(a){return 1===a?"One result is available, press enter to select it.":a+" results are available, use up and down arrow keys to navigate."},formatNoMatches:function(){return"No matches found"},formatAjaxError:function(){return"Loading failed"},formatInputTooShort:function(a,b){var c=b-a.length;return"Please enter "+c+" or more character"+(1==c?"":"s")},formatInputTooLong:function(a,b){var c=a.length-b;return"Please delete "+c+" character"+(1==c?"":"s")},formatSelectionTooBig:function(a){return"You can only select "+a+" item"+(1==a?"":"s")},formatLoadMore:function(){return"Loading more results\u2026"},formatSearching:function(){return"Searching\u2026"}},a.extend(a.fn.select2.defaults,a.fn.select2.locales.en),a.fn.select2.ajaxDefaults={transport:a.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:G,local:H,tags:I},util:{debounce:w,markMatch:E,escapeMarkup:F,stripDiacritics:o},"class":{"abstract":c,single:d,multi:e}}}}(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/utility/js/utils.js
DELETED
@@ -1,968 +0,0 @@
|
|
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.restoreEventPropagation = function( event ){
|
13 |
-
if( event.isImmediatePropagationStopped() === false && event.isPropagationStopped() === false ){
|
14 |
-
return event;
|
15 |
-
}
|
16 |
-
|
17 |
-
var refEvent = event.originalEvent;
|
18 |
-
refEvent.cancelBubble = false;
|
19 |
-
refEvent.defaultPrevented = false;
|
20 |
-
refEvent.returnValue = true;
|
21 |
-
refEvent.timeStamp = ( new Date() ).getTime();
|
22 |
-
|
23 |
-
if (event.target.dispatchEvent) {
|
24 |
-
event.target.dispatchEvent(refEvent);
|
25 |
-
} else if (event.target.fireEvent) {
|
26 |
-
event.target.fireEvent(refEvent);
|
27 |
-
}
|
28 |
-
|
29 |
-
return refEvent;
|
30 |
-
};
|
31 |
-
|
32 |
-
WPV_Toolset.Utils.do_ajax_post = function( params, callback_object )
|
33 |
-
{
|
34 |
-
jQuery.post(ajaxurl, params, function (response) {
|
35 |
-
|
36 |
-
if ( (typeof(response) !== 'undefined') && response !== null && ( response.message || response.Data ) ) {
|
37 |
-
|
38 |
-
if( callback_object && callback_object.success && typeof callback_object.success == 'function' )
|
39 |
-
callback_object.success.call( this, response, params );
|
40 |
-
WPV_Toolset.Utils.eventDispatcher.trigger('on_ajax_success_'+params.action, response, params);
|
41 |
-
}
|
42 |
-
else if( (typeof(response) !== 'undefined') && response !== null && response.error )
|
43 |
-
{
|
44 |
-
|
45 |
-
if( callback_object && callback_object.error && typeof callback_object.error == 'function' )
|
46 |
-
callback_object.error.call(this);
|
47 |
-
WPV_Toolset.Utils.eventDispatcher.trigger('on_ajax_error_'+params.action, response, params);
|
48 |
-
}
|
49 |
-
}, 'json')
|
50 |
-
.fail(function (jqXHR, textStatus, errorThrown) {
|
51 |
-
console.log('Ajax call failed', textStatus, errorThrown)
|
52 |
-
if( callback_object && callback_object.fail && typeof callback_object.fail == 'function' )
|
53 |
-
callback_object.fail.call(this, errorThrown);
|
54 |
-
WPV_Toolset.Utils.eventDispatcher.trigger('on_ajax_fail_'+params.action, textStatus, errorThrown, params );
|
55 |
-
})
|
56 |
-
.always(function () {
|
57 |
-
//console.log( arguments );
|
58 |
-
WPV_Toolset.Utils.eventDispatcher.trigger('on_ajax_complete_'+params.action, arguments, params);
|
59 |
-
});
|
60 |
-
};
|
61 |
-
|
62 |
-
;(function ( $, window, document, undefined ) {
|
63 |
-
|
64 |
-
// Create the defaults once
|
65 |
-
var pluginName = "wpvToolsetMessage",
|
66 |
-
dataPlugin = "plugin_" + pluginName,
|
67 |
-
defaults = {
|
68 |
-
text : "Enter a customized text to be displayed",
|
69 |
-
type: '',
|
70 |
-
inline: false,
|
71 |
-
position : "after",
|
72 |
-
header: false,
|
73 |
-
headerText: false,
|
74 |
-
close: false,
|
75 |
-
use_this: true,
|
76 |
-
fadeIn: 100,
|
77 |
-
fadeOut: 100,
|
78 |
-
stay: false,
|
79 |
-
onClose: false,
|
80 |
-
onOpen: false,
|
81 |
-
onDestroy:false,
|
82 |
-
args:[],
|
83 |
-
referTo: null,
|
84 |
-
offestX: -20,
|
85 |
-
offsetY: 0,
|
86 |
-
classname: '',
|
87 |
-
stay_for: 1200, // Ignored when 'msPerCharacter is given.
|
88 |
-
msPerCharacter: 50 // Ignered when 'stay_for' is given. This value is multiplied by the number of defaults.text characters count.
|
89 |
-
},
|
90 |
-
has_stay = false,
|
91 |
-
is_open = false,
|
92 |
-
prev = null,
|
93 |
-
prev_text = '';
|
94 |
-
|
95 |
-
// The actual plugin constructor
|
96 |
-
function Plugin(element, options) {
|
97 |
-
var self = this;
|
98 |
-
|
99 |
-
self.container = $(element);
|
100 |
-
|
101 |
-
self.prms = $.extend({}, defaults, options);
|
102 |
-
self._defaults = defaults;
|
103 |
-
self._name = pluginName;
|
104 |
-
|
105 |
-
self.box = null;
|
106 |
-
self.header = null;
|
107 |
-
self.remove = null;
|
108 |
-
self.tag = self.prms.inline ? 'span' : 'p';
|
109 |
-
self.bool = false;
|
110 |
-
|
111 |
-
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
|
112 |
-
self.prms.stay_for = self.prms.text.length * self.prms.msPerCharacter;
|
113 |
-
}
|
114 |
-
|
115 |
-
}
|
116 |
-
|
117 |
-
Plugin.prototype = {
|
118 |
-
init: function () {
|
119 |
-
var self = this;
|
120 |
-
|
121 |
-
if( self.container.data('has_message' ) )
|
122 |
-
{
|
123 |
-
self.destroy();
|
124 |
-
}
|
125 |
-
|
126 |
-
if( self.container.children().length > 0 )
|
127 |
-
{
|
128 |
-
self.container.children().each(function(i){
|
129 |
-
if( $(this).text() == self.prms.text )
|
130 |
-
{
|
131 |
-
self.bool = true;
|
132 |
-
}
|
133 |
-
});
|
134 |
-
}
|
135 |
-
|
136 |
-
if( self.bool ) return;
|
137 |
-
|
138 |
-
if( has_stay )
|
139 |
-
{
|
140 |
-
if( prev )
|
141 |
-
{
|
142 |
-
var rem = prev;
|
143 |
-
prev = null;
|
144 |
-
has_stay = false;
|
145 |
-
is_open = false;
|
146 |
-
rem.fadeTo( 0, 0, function(){
|
147 |
-
rem.remove();
|
148 |
-
rem = null;
|
149 |
-
});
|
150 |
-
}
|
151 |
-
}
|
152 |
-
|
153 |
-
if( self.prms.header && self.prms.headerText )
|
154 |
-
{
|
155 |
-
self.box = $('<div class="toolset-alert toolset-alert-'+self.prms.type+' '+self.prms.classname+'" />');
|
156 |
-
self.header = $('<h2 class="toolset-alert-self.header" />');
|
157 |
-
self.box.append(self.header);
|
158 |
-
self.header.text(self.prms.headerText);
|
159 |
-
self.box.append('<'+self.tag+'></'+self.tag+'>');
|
160 |
-
self.box.find(self.tag).html( self.prms.text );
|
161 |
-
}
|
162 |
-
else
|
163 |
-
{
|
164 |
-
self.box = $('<'+self.tag+' class="toolset-alert toolset-alert-'+self.prms.type+' '+self.prms.classname+'" />');
|
165 |
-
self.box.html( self.prms.text );
|
166 |
-
}
|
167 |
-
|
168 |
-
if( self.prms.close ){
|
169 |
-
self.remove = $('<i class="toolset-alert-close icon-remove-sign js-icon-remove-sign"></i>');
|
170 |
-
self.box.append( self.remove );
|
171 |
-
self.remove.on('click', function(event){
|
172 |
-
self.wpvMessageRemove();
|
173 |
-
});
|
174 |
-
}
|
175 |
-
|
176 |
-
|
177 |
-
//if( is_open ) self.wpvMessageRemove();
|
178 |
-
if ( self.prms.position == 'before' ) {
|
179 |
-
self.container.prepend( self.box );
|
180 |
-
} else {
|
181 |
-
self.container.append( self.box );
|
182 |
-
}
|
183 |
-
self.container.data('has_message', true );
|
184 |
-
self.box.hide();
|
185 |
-
|
186 |
-
if( null !== self.prms.referTo )
|
187 |
-
{
|
188 |
-
self.box.css({
|
189 |
-
"position":"absolute",
|
190 |
-
"z-index":10000,
|
191 |
-
"top": self.prms.referTo.position().top + self.prms.offestY + "px",
|
192 |
-
"left": self.prms.referTo.position().left + self.prms.referTo.width() + self.prms.offestX + "px"
|
193 |
-
});
|
194 |
-
}
|
195 |
-
|
196 |
-
self.container.data( 'message-box', self.box );
|
197 |
-
|
198 |
-
self.box.fadeTo( null != prev ? 0 : self.prms.fadeIn, 1, function(){
|
199 |
-
$(this).trigger('wpv-message-open');
|
200 |
-
prev = $(this);
|
201 |
-
prev_text = self.prms.text;
|
202 |
-
is_open = true;
|
203 |
-
if( self.prms.onOpen && typeof self.prms.onOpen == 'function' )
|
204 |
-
{
|
205 |
-
self.prms.onOpen.apply( self, self.prms.args );
|
206 |
-
}
|
207 |
-
if( self.prms.stay ){
|
208 |
-
has_stay = true;
|
209 |
-
}
|
210 |
-
else
|
211 |
-
{
|
212 |
-
var remove_message = _.bind(self.wpvMessageRemove, self);
|
213 |
-
_.delay( remove_message, self.prms.stay_for );
|
214 |
-
//self.wpvMessageRemove();
|
215 |
-
}
|
216 |
-
});
|
217 |
-
|
218 |
-
return self;
|
219 |
-
},
|
220 |
-
wpvMessageRemove: function () {
|
221 |
-
|
222 |
-
var self = this;
|
223 |
-
|
224 |
-
if( self.box || self.container.data( 'message-box') )
|
225 |
-
{
|
226 |
-
var box = self.box || self.container.data( 'message-box');
|
227 |
-
|
228 |
-
box.fadeTo( self.prms.fadeOut, 0, function(){
|
229 |
-
$(this).trigger('wpv-message-remove');
|
230 |
-
is_open = false;
|
231 |
-
prev = null;
|
232 |
-
prev_text = '';
|
233 |
-
has_stay = false;
|
234 |
-
if( self.prms.onClose && typeof self.prms.onClose == 'function' )
|
235 |
-
{
|
236 |
-
self.prms.onClose.apply( self, self.prms.args );
|
237 |
-
}
|
238 |
-
|
239 |
-
$( this ).remove();
|
240 |
-
self.container.data('has_message', false );
|
241 |
-
self.container.data( 'message-box', null );
|
242 |
-
self.box = null;
|
243 |
-
});
|
244 |
-
}
|
245 |
-
|
246 |
-
return self;
|
247 |
-
},
|
248 |
-
destroy:function()
|
249 |
-
{
|
250 |
-
$(this).trigger('wpv-message-remove');
|
251 |
-
this.container.empty();
|
252 |
-
if( this.prms.onDestroy && typeof this.prms.onDestroy == 'function' )
|
253 |
-
{
|
254 |
-
this.prms.onDestroy.apply( this, this.prms.args );
|
255 |
-
}
|
256 |
-
this.box = null;
|
257 |
-
this.container.data( 'message-box', null );
|
258 |
-
this.container.data('has_message', false );
|
259 |
-
},
|
260 |
-
has_message:function(){
|
261 |
-
return this.container.data('has_message');
|
262 |
-
}
|
263 |
-
};
|
264 |
-
|
265 |
-
|
266 |
-
$.fn[ pluginName ] = function ( arg ) {
|
267 |
-
|
268 |
-
return this.each(function(){
|
269 |
-
var args, instance;
|
270 |
-
|
271 |
-
if ( !( $(this).data( dataPlugin ) instanceof Plugin ) ) {
|
272 |
-
// if no instance, create one
|
273 |
-
$(this).data( dataPlugin, new Plugin( $(this), arg ) );
|
274 |
-
}
|
275 |
-
// do not use this one if you want the plugin to be a singleton bound to the DOM element
|
276 |
-
else
|
277 |
-
{
|
278 |
-
// if instance delete reference and do another one
|
279 |
-
$(this).data( dataPlugin, null );
|
280 |
-
$(this).data( dataPlugin, new Plugin( $(this), arg ) );
|
281 |
-
}
|
282 |
-
|
283 |
-
instance = $(this).data( dataPlugin );
|
284 |
-
|
285 |
-
instance.element = $(this);
|
286 |
-
|
287 |
-
// call Plugin.init( arg )
|
288 |
-
if (typeof arg === 'undefined' || typeof arg === 'object') {
|
289 |
-
|
290 |
-
if ( typeof instance['init'] === 'function' ) {
|
291 |
-
instance.init( arg );
|
292 |
-
}
|
293 |
-
|
294 |
-
// checks that the requested public method exists
|
295 |
-
} else if ( typeof arg === 'string' && typeof instance[arg] === 'function' ) {
|
296 |
-
|
297 |
-
// copy arguments & remove function name
|
298 |
-
args = Array.prototype.slice.call( arguments, 1 );
|
299 |
-
|
300 |
-
// call the method
|
301 |
-
return instance[arg].apply( instance, args );
|
302 |
-
|
303 |
-
} else {
|
304 |
-
|
305 |
-
$.error('Method ' + arg + ' does not exist on jQuery.' + pluginName);
|
306 |
-
|
307 |
-
}
|
308 |
-
});
|
309 |
-
};
|
310 |
-
})( jQuery, window, document );
|
311 |
-
|
312 |
-
(function ($) {
|
313 |
-
$.fn.insertAtIndex = function(index,selector){
|
314 |
-
var opts = $.extend({
|
315 |
-
index: 0,
|
316 |
-
selector: '<div/>'
|
317 |
-
}, {index: index, selector: selector});
|
318 |
-
return this.each(function() {
|
319 |
-
var p = $(this);
|
320 |
-
var i = ($.isNumeric(opts.index) ? parseInt(opts.index,10) : 0);
|
321 |
-
if (i <= 0)
|
322 |
-
p.prepend(opts.selector);
|
323 |
-
else if( i > p.children().length-1 )
|
324 |
-
p.append(opts.selector);
|
325 |
-
else
|
326 |
-
p.children().eq(i).before(opts.selector);
|
327 |
-
});
|
328 |
-
};
|
329 |
-
})( jQuery );
|
330 |
-
|
331 |
-
(function ($) {
|
332 |
-
|
333 |
-
$.fn.loaderOverlay = function( action,options )
|
334 |
-
// action: 'show'|'hide' attributes are optional.
|
335 |
-
// options: fadeInSpeed, fadeOutSpeed, displayOverlay, class. attributes are optional
|
336 |
-
{
|
337 |
-
|
338 |
-
var defaults = {
|
339 |
-
fadeInSpeed : 'fast',
|
340 |
-
fadeOutSpeed : 'fast',
|
341 |
-
displayLoader: true,
|
342 |
-
class: null
|
343 |
-
};
|
344 |
-
|
345 |
-
var prms = $.extend( defaults, options );
|
346 |
-
var $overlayContainer = this;
|
347 |
-
var $overlayEl = $('<div class="loader-overlay" />');
|
348 |
-
|
349 |
-
var showOverlay = function() {
|
350 |
-
if ( ! $overlayContainer.data('has-overlay') ) {
|
351 |
-
$overlayEl
|
352 |
-
.appendTo($overlayContainer)
|
353 |
-
.hide()
|
354 |
-
.fadeIn(prms.fadeInSpeed, function() {
|
355 |
-
$overlayContainer.data('has-overlay', true);
|
356 |
-
$overlayContainer.data('overlay-el', $overlayEl);
|
357 |
-
} );
|
358 |
-
}
|
359 |
-
};
|
360 |
-
|
361 |
-
var hideOverlay = function() {
|
362 |
-
if ( $overlayContainer.data('has-overlay') ) {
|
363 |
-
$overlayContainer.data('overlay-el')
|
364 |
-
.fadeOut(prms.fadeOutSpeed, function() {
|
365 |
-
$overlayEl.remove();
|
366 |
-
$overlayContainer.data('has-overlay', false);
|
367 |
-
} );
|
368 |
-
}
|
369 |
-
};
|
370 |
-
|
371 |
-
if ( prms.class !== null ) {
|
372 |
-
$overlayEl.addClass(prms.class);
|
373 |
-
}
|
374 |
-
if ( prms.displayLoader ) {
|
375 |
-
$('<div class="preloader" />').appendTo($overlayEl);
|
376 |
-
}
|
377 |
-
|
378 |
-
if ( typeof(action) !== 'undefined' ) { // When 'action' parameter is given
|
379 |
-
|
380 |
-
if ( action === 'show' ) {
|
381 |
-
showOverlay();
|
382 |
-
}
|
383 |
-
else if ( action === 'hide' ) {
|
384 |
-
hideOverlay();
|
385 |
-
}
|
386 |
-
|
387 |
-
}
|
388 |
-
else { // when the method is called without 'action' parameter
|
389 |
-
|
390 |
-
if ( $overlayContainer.data('has-overlay') ) { // hide overlay if it's displayed
|
391 |
-
hideOverlay();
|
392 |
-
}
|
393 |
-
else { // show overlay if not
|
394 |
-
showOverlay();
|
395 |
-
}
|
396 |
-
|
397 |
-
}
|
398 |
-
|
399 |
-
return this;
|
400 |
-
};
|
401 |
-
|
402 |
-
})( jQuery );
|
403 |
-
|
404 |
-
(function ($) {
|
405 |
-
/*
|
406 |
-
Basic usage:
|
407 |
-
$element.ddlWpPointer(); // will show a pointer if it's hidden OR hide a pointer if it's shown
|
408 |
-
|
409 |
-
1. $element have to be valid jQuery selector
|
410 |
-
2. data-toolipt-header HTML attribute is required to display the header
|
411 |
-
3. data-tooltip-content HTML attribute is required to display the content
|
412 |
-
|
413 |
-
Customization:
|
414 |
-
$element.ddlWpPointer('action', // action: 'show' | 'hide'
|
415 |
-
{
|
416 |
-
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>
|
417 |
-
edge: 'left' // 'left' | 'right' | 'top' | 'bottom'
|
418 |
-
align: 'center' // 'center' | 'right' | 'left'
|
419 |
-
offset: 'x y' // example: '0 15'
|
420 |
-
})
|
421 |
-
|
422 |
-
*/
|
423 |
-
$.fn.ddlWpPointer = function( action, options )
|
424 |
-
{
|
425 |
-
var $el = this;
|
426 |
-
|
427 |
-
//$.jStorage.flush();
|
428 |
-
|
429 |
-
var defaults = {
|
430 |
-
headerText: function() {
|
431 |
-
var header = $el.data('tooltip-header');
|
432 |
-
if ( header ) {
|
433 |
-
return header;
|
434 |
-
}
|
435 |
-
else {
|
436 |
-
return 'use <b>data-tooltip-header="header text"</b> attribute to create a header';
|
437 |
-
}
|
438 |
-
},
|
439 |
-
contentText : function() {
|
440 |
-
var content = $el.data('tooltip-content');
|
441 |
-
if ( content ) {
|
442 |
-
return content;
|
443 |
-
}
|
444 |
-
else {
|
445 |
-
return 'use <b>data-tooltip-content="content text"</b> attribute to create a content';
|
446 |
-
}
|
447 |
-
},
|
448 |
-
content: function() { // returns string by default (data-tooltip-header and data-tooltip-content attibutes), but can be overridden by jQuery obj
|
449 |
-
return '<h3>'+ defaults.headerText() +'</h3><p>'+ defaults.contentText() +'</p>';
|
450 |
-
},
|
451 |
-
edge : 'left',
|
452 |
-
align : 'center',
|
453 |
-
offset: '0 0',
|
454 |
-
stay_hidden: false
|
455 |
-
};
|
456 |
-
|
457 |
-
var prms = $.extend( defaults, options );
|
458 |
-
|
459 |
-
var showPointer = function() {
|
460 |
-
|
461 |
-
if ( ! $el.data('has-wppointer') ) {
|
462 |
-
$el
|
463 |
-
.pointer({
|
464 |
-
content: function() {
|
465 |
-
return prms.content;
|
466 |
-
},
|
467 |
-
position: {
|
468 |
-
edge: prms.edge,
|
469 |
-
align: prms.align,
|
470 |
-
offset: prms.offset
|
471 |
-
},
|
472 |
-
close: function() {
|
473 |
-
|
474 |
-
$el.data('has-wppointer', false);
|
475 |
-
$el.trigger('help_tooltip_closes', options );
|
476 |
-
}
|
477 |
-
})
|
478 |
-
.pointer('open');
|
479 |
-
|
480 |
-
$el.data('has-wppointer', true);
|
481 |
-
}
|
482 |
-
};
|
483 |
-
|
484 |
-
var hidePointer = function() {
|
485 |
-
|
486 |
-
if ( $el.data('has-wppointer') ) {
|
487 |
-
|
488 |
-
$el.pointer('close');
|
489 |
-
$el.data('has-wppointer', false);
|
490 |
-
|
491 |
-
}
|
492 |
-
|
493 |
-
};
|
494 |
-
|
495 |
-
if ( typeof(action) !== 'undefined' ) { // When 'action' parameter is given
|
496 |
-
|
497 |
-
if ( action === 'show' && prms.stay_hidden !== true ) {
|
498 |
-
showPointer();
|
499 |
-
}
|
500 |
-
else if ( action === 'hide' ) {
|
501 |
-
hidePointer();
|
502 |
-
}
|
503 |
-
|
504 |
-
}
|
505 |
-
else { // when the method is called without 'action' parameter
|
506 |
-
|
507 |
-
if ( $el.data('has-wppointer') ) { // hide pointer if it's displayed
|
508 |
-
hidePointer();
|
509 |
-
}
|
510 |
-
else if( prms.stay_hidden !== true ) { // show it if not
|
511 |
-
showPointer();
|
512 |
-
}
|
513 |
-
|
514 |
-
}
|
515 |
-
|
516 |
-
return this;
|
517 |
-
};
|
518 |
-
|
519 |
-
})( jQuery );
|
520 |
-
|
521 |
-
WPV_Toolset.Utils.Loader = function()
|
522 |
-
{
|
523 |
-
//fake comment
|
524 |
-
var self = this;
|
525 |
-
|
526 |
-
self.loading = false; self.el = null;
|
527 |
-
|
528 |
-
self.loader = jQuery('<div class="ajax-loader spinner"></div>');
|
529 |
-
|
530 |
-
self.loadShow = function( el, after )
|
531 |
-
{
|
532 |
-
self.el = el;
|
533 |
-
self.loading = true;
|
534 |
-
|
535 |
-
if( typeof after === 'undefined' )
|
536 |
-
{
|
537 |
-
self.loader.prependTo( self.el ).show();
|
538 |
-
}
|
539 |
-
else{
|
540 |
-
self.loader.insertAfter( self.el ).show();
|
541 |
-
}
|
542 |
-
|
543 |
-
return self.loader;
|
544 |
-
};
|
545 |
-
self.loadHide = function()
|
546 |
-
{
|
547 |
-
self.loader.fadeOut(400, function(){
|
548 |
-
|
549 |
-
self.loading = false;
|
550 |
-
jQuery(this).remove();
|
551 |
-
});
|
552 |
-
|
553 |
-
return self.loader;
|
554 |
-
};
|
555 |
-
};
|
556 |
-
|
557 |
-
if( typeof _ != 'undefined' )
|
558 |
-
{
|
559 |
-
WPV_Toolset.Utils.flatten = function(x, result, prefix) {
|
560 |
-
if(_.isObject(x)) {
|
561 |
-
_.each(x, function(v, k) {
|
562 |
-
WPV_Toolset.Utils.flatten(v, result, prefix ? prefix + '_' + k : k)
|
563 |
-
})
|
564 |
-
} else {
|
565 |
-
result[prefix] = x
|
566 |
-
}
|
567 |
-
return result
|
568 |
-
};
|
569 |
-
WPV_Toolset.Utils.flatten_filter_by_key = function( x, result, prefix, filter )
|
570 |
-
{
|
571 |
-
var res = [],
|
572 |
-
find = WPV_Toolset.Utils.flatten( x, result, prefix );
|
573 |
-
|
574 |
-
if ( !filter ) return _.values( find );
|
575 |
-
|
576 |
-
_.each(find, function( element, index, list ){
|
577 |
-
if( index.indexOf( prefix ? prefix + '_'+filter : filter ) !== -1 || filter === index )
|
578 |
-
res.push( element );
|
579 |
-
});
|
580 |
-
|
581 |
-
return res;
|
582 |
-
}
|
583 |
-
WPV_Toolset.Utils.containsObject = function (obj, list) {
|
584 |
-
var res = _.find(list, function(val){
|
585 |
-
return _.isEqual(obj, val);
|
586 |
-
});
|
587 |
-
return (_.isObject(res))? true:false;
|
588 |
-
};
|
589 |
-
};
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
(function($) {
|
594 |
-
$.fn.textWidth = function() {
|
595 |
-
var text = this.html() || this.text() || this.val();
|
596 |
-
return( $.textWidth( text ) );
|
597 |
-
};
|
598 |
-
$.textWidth = function(text) {
|
599 |
-
var div = $('#textWidth');
|
600 |
-
if (div.length === 0)
|
601 |
-
div = $('<div id="textWidth" style="display: none;"></div>').appendTo($('body'));
|
602 |
-
div.html(text);
|
603 |
-
return(div.width());
|
604 |
-
};
|
605 |
-
})(jQuery);
|
606 |
-
|
607 |
-
//Courtesy from http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
|
608 |
-
WPV_Toolset.Utils.escapeHtml = function(str) {
|
609 |
-
if (typeof(str) == "string"){
|
610 |
-
try{
|
611 |
-
var newStr = "";
|
612 |
-
var nextCode = 0;
|
613 |
-
for (var i = 0;i < str.length;i++){
|
614 |
-
nextCode = str.charCodeAt(i);
|
615 |
-
if (nextCode > 0 && nextCode < 128){
|
616 |
-
newStr += "&#"+nextCode+";";
|
617 |
-
}
|
618 |
-
else{
|
619 |
-
newStr += "?";
|
620 |
-
}
|
621 |
-
}
|
622 |
-
return newStr;
|
623 |
-
}
|
624 |
-
catch(err){
|
625 |
-
}
|
626 |
-
}
|
627 |
-
else{
|
628 |
-
return str;
|
629 |
-
}
|
630 |
-
};
|
631 |
-
|
632 |
-
WPV_Toolset.Utils.editor_decode64 = function(input) {
|
633 |
-
var output = "",
|
634 |
-
chr1, chr2, chr3 = "",
|
635 |
-
enc1, enc2, enc3, enc4 = "",
|
636 |
-
i = 0,
|
637 |
-
keyStr = "ABCDEFGHIJKLMNOP" +
|
638 |
-
"QRSTUVWXYZabcdef" +
|
639 |
-
"ghijklmnopqrstuv" +
|
640 |
-
"wxyz0123456789+/" +
|
641 |
-
"=";
|
642 |
-
|
643 |
-
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
|
644 |
-
var base64test = /[^A-Za-z0-9\+\/\=]/g;
|
645 |
-
if (base64test.exec(input)) {
|
646 |
-
alert("There were invalid base64 characters in the input text.\n" +
|
647 |
-
"Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" +
|
648 |
-
"Expect errors in decoding.");
|
649 |
-
}
|
650 |
-
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
651 |
-
|
652 |
-
do {
|
653 |
-
enc1 = keyStr.indexOf(input.charAt(i++));
|
654 |
-
enc2 = keyStr.indexOf(input.charAt(i++));
|
655 |
-
enc3 = keyStr.indexOf(input.charAt(i++));
|
656 |
-
enc4 = keyStr.indexOf(input.charAt(i++));
|
657 |
-
|
658 |
-
chr1 = (enc1 << 2) | (enc2 >> 4);
|
659 |
-
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
660 |
-
chr3 = ((enc3 & 3) << 6) | enc4;
|
661 |
-
|
662 |
-
output = output + String.fromCharCode(chr1);
|
663 |
-
|
664 |
-
if (enc3 != 64) {
|
665 |
-
output = output + String.fromCharCode(chr2);
|
666 |
-
}
|
667 |
-
if (enc4 != 64) {
|
668 |
-
output = output + String.fromCharCode(chr3);
|
669 |
-
}
|
670 |
-
|
671 |
-
chr1 = chr2 = chr3 = "";
|
672 |
-
enc1 = enc2 = enc3 = enc4 = "";
|
673 |
-
|
674 |
-
} while (i < input.length);
|
675 |
-
|
676 |
-
return WPV_Toolset.Utils.editor_utf8_decode( output );
|
677 |
-
};
|
678 |
-
|
679 |
-
WPV_Toolset.Utils.editor_utf8_decode = function (utftext) {
|
680 |
-
var string = "";
|
681 |
-
var i = 0;
|
682 |
-
var c = c1 = c2 = 0;
|
683 |
-
|
684 |
-
while ( i < utftext.length ) {
|
685 |
-
|
686 |
-
c = utftext.charCodeAt(i);
|
687 |
-
|
688 |
-
if (c < 128) {
|
689 |
-
string += String.fromCharCode(c);
|
690 |
-
i++;
|
691 |
-
}
|
692 |
-
else if((c > 191) && (c < 224)) {
|
693 |
-
c2 = utftext.charCodeAt(i+1);
|
694 |
-
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
695 |
-
i += 2;
|
696 |
-
}
|
697 |
-
else {
|
698 |
-
c2 = utftext.charCodeAt(i+1);
|
699 |
-
c3 = utftext.charCodeAt(i+2);
|
700 |
-
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
701 |
-
i += 3;
|
702 |
-
}
|
703 |
-
|
704 |
-
}
|
705 |
-
|
706 |
-
return string;
|
707 |
-
};
|
708 |
-
|
709 |
-
// convert unicode character to its corresponding numeric entity
|
710 |
-
WPV_Toolset.Utils.fixedCharCodeAt = function (str, idx) {
|
711 |
-
// ex. fixedCharCodeAt ('\uD800\uDC00', 0); // 65536
|
712 |
-
// ex. fixedCharCodeAt ('\uD800\uDC00', 1); // 65536
|
713 |
-
idx = idx || 0;
|
714 |
-
var code = str.charCodeAt(idx);
|
715 |
-
var hi, low;
|
716 |
-
if (0xD800 <= code && code <= 0xDBFF) { // High surrogate (could change last hex to 0xDB7F to treat high private surrogates as single characters)
|
717 |
-
hi = code;
|
718 |
-
low = str.charCodeAt(idx+1);
|
719 |
-
if (isNaN(low)) {
|
720 |
-
throw 'High surrogate not followed by low surrogate in fixedCharCodeAt()';
|
721 |
-
}
|
722 |
-
return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
|
723 |
-
}
|
724 |
-
if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
|
725 |
-
// We return false to allow loops to skip this iteration since should have already handled high surrogate above in the previous iteration
|
726 |
-
return false;
|
727 |
-
/*hi = str.charCodeAt(idx-1);
|
728 |
-
low = code;
|
729 |
-
return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;*/
|
730 |
-
}
|
731 |
-
return code;
|
732 |
-
};
|
733 |
-
|
734 |
-
WPV_Toolset.replace_unicode_characters = function(string)
|
735 |
-
{
|
736 |
-
// remove accents, swap ñ for n, etc
|
737 |
-
var from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;",
|
738 |
-
to = "aaaaaeeeeeiiiiooooouuuunc------";
|
739 |
-
for (var i=0, l=from.length ; i<l ; i++) {
|
740 |
-
string = string.replace( new RegExp(from.charAt(i), 'g'), to.charAt(i) );
|
741 |
-
}
|
742 |
-
|
743 |
-
var unicode = '!£$%&()=?^|#§';
|
744 |
-
|
745 |
-
for( var i=0; i<unicode.length; i++ )
|
746 |
-
{
|
747 |
-
string = string.replace( new RegExp(unicode.charAt(i).regexEscape(), 'g'), WPV_Toolset.Utils.fixedCharCodeAt( unicode.charAt(i) ) );
|
748 |
-
}
|
749 |
-
|
750 |
-
return string;
|
751 |
-
};
|
752 |
-
|
753 |
-
// escapes regex characters for use in regex constructor
|
754 |
-
String.prototype.regexEscape = function regexEscape() {
|
755 |
-
return this.replace(/[\.\?\+\*\^\$\|\(\{\[\]\\)]/g, '\\$&');
|
756 |
-
};
|
757 |
-
|
758 |
-
// THE TOOLTIP //
|
759 |
-
;
|
760 |
-
(function ($, window, document, undefined) {
|
761 |
-
|
762 |
-
// Create the defaults once
|
763 |
-
var pluginName = "toolsetTooltip",
|
764 |
-
dataPlugin = "plugin_" + pluginName,
|
765 |
-
undefined,
|
766 |
-
defaults = {
|
767 |
-
top: undefined,
|
768 |
-
text:'',
|
769 |
-
close:null,
|
770 |
-
open:null
|
771 |
-
};
|
772 |
-
|
773 |
-
// The actual plugin constructor
|
774 |
-
function Plugin(element, options) {
|
775 |
-
|
776 |
-
this.$element = element;
|
777 |
-
this.settings = $.extend({}, defaults, options);
|
778 |
-
this._defaults = defaults;
|
779 |
-
this._name = pluginName;
|
780 |
-
this._remove_tooltip = null;
|
781 |
-
}
|
782 |
-
|
783 |
-
// Avoid Plugin.prototype conflicts
|
784 |
-
$.extend(Plugin.prototype, {
|
785 |
-
init: function () {
|
786 |
-
var self = this;
|
787 |
-
this.$element.on('mouseenter', function(event) {
|
788 |
-
self.show(event);
|
789 |
-
jQuery(event.target).trigger('tooltip_show', event);
|
790 |
-
});
|
791 |
-
this.$element.on('mouseleave', function(event) {
|
792 |
-
self.hide(event);
|
793 |
-
jQuery(event.target).trigger('tooltip_hide', event);
|
794 |
-
});
|
795 |
-
},
|
796 |
-
show: function (event) {
|
797 |
-
var self = this,
|
798 |
-
$tooltip = $('<div class="toolset-tooltip" />'),
|
799 |
-
offset = self.$element.offset(),
|
800 |
-
offset_top = typeof self.settings.top === 'undefined' ? 20 : self.settings.top;
|
801 |
-
|
802 |
-
self._remove_tooltip = $tooltip;
|
803 |
-
|
804 |
-
$tooltip
|
805 |
-
.appendTo('body')
|
806 |
-
.text( this.settings.text || self.$element.data('tooltip-text') )
|
807 |
-
.css({
|
808 |
-
'top': offset.top - $tooltip.height() - offset_top,
|
809 |
-
'left': offset.left - ($tooltip.outerWidth() / 2) + (self.$element.outerWidth() / 2),
|
810 |
-
'zIndex': '9999999'
|
811 |
-
})
|
812 |
-
.fadeIn(100);
|
813 |
-
|
814 |
-
// Probably $elem doesn't is removed before 'click' event takes place
|
815 |
-
// So we need to call _manageCellTooltip( $elem, 'hide') somewhere... but i don't know where ;)
|
816 |
-
|
817 |
-
self.$element.on('mousedown', function () {
|
818 |
-
|
819 |
-
if ( self._remove_tooltip ){
|
820 |
-
self._remove_tooltip.remove();
|
821 |
-
self._remove_tooltip = null;
|
822 |
-
}
|
823 |
-
});
|
824 |
-
|
825 |
-
if( self.settings.open !== null && self.settings.open instanceof Function ){
|
826 |
-
self.settings.open.call(self);
|
827 |
-
}
|
828 |
-
|
829 |
-
return $tooltip;
|
830 |
-
},
|
831 |
-
hide: function (event) {
|
832 |
-
var self = this;
|
833 |
-
|
834 |
-
if ( self._remove_tooltip ) {
|
835 |
-
if( self.settings.close !== null && self.settings.close instanceof Function ){
|
836 |
-
self.settings.close.call(self);
|
837 |
-
}
|
838 |
-
self._remove_tooltip.remove();
|
839 |
-
self._remove_tooltip = null;
|
840 |
-
}
|
841 |
-
}
|
842 |
-
});
|
843 |
-
|
844 |
-
$.fn[ pluginName ] = function ( arg ) {
|
845 |
-
|
846 |
-
return this.each(function(){
|
847 |
-
var args, instance;
|
848 |
-
|
849 |
-
if ( !( $(this).data( dataPlugin ) instanceof Plugin ) ) {
|
850 |
-
// if no instance, create one
|
851 |
-
$(this).data( dataPlugin, new Plugin( $(this), arg ) );
|
852 |
-
}
|
853 |
-
|
854 |
-
instance = $(this).data( dataPlugin );
|
855 |
-
instance.element = $(this);
|
856 |
-
|
857 |
-
// call Plugin.init( arg )
|
858 |
-
if (typeof arg === 'undefined' || typeof arg === 'object') {
|
859 |
-
|
860 |
-
if ( typeof instance['init'] === 'function' ) {
|
861 |
-
instance.init( arg );
|
862 |
-
}
|
863 |
-
|
864 |
-
// checks that the requested public method exists
|
865 |
-
} else if ( typeof arg === 'string' && typeof instance[arg] === 'function' ) {
|
866 |
-
|
867 |
-
// copy arguments & remove function name
|
868 |
-
args = Array.prototype.slice.call( arguments, 1 );
|
869 |
-
|
870 |
-
// call the method
|
871 |
-
return instance[arg].apply( instance, args );
|
872 |
-
|
873 |
-
} else {
|
874 |
-
|
875 |
-
$.error('Method ' + arg + ' does not exist on jQuery.' + pluginName);
|
876 |
-
|
877 |
-
}
|
878 |
-
});
|
879 |
-
|
880 |
-
return this;
|
881 |
-
};
|
882 |
-
|
883 |
-
})(jQuery, window, document);
|
884 |
-
|
885 |
-
;(function($, window, document, undefined){
|
886 |
-
/*
|
887 |
-
|
888 |
-
highlight v3 !! Modified by Jon Raasch (http://jonraasch.com) to fix IE6 bug !!
|
889 |
-
|
890 |
-
Highlights arbitrary terms.
|
891 |
-
|
892 |
-
<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
|
893 |
-
|
894 |
-
MIT license.
|
895 |
-
|
896 |
-
Johann Burkard
|
897 |
-
<http://johannburkard.de>
|
898 |
-
<mailto:jb@eaio.com>
|
899 |
-
|
900 |
-
*/
|
901 |
-
var defaults = {
|
902 |
-
className:'highlighted'
|
903 |
-
},
|
904 |
-
options = {
|
905 |
-
|
906 |
-
};
|
907 |
-
|
908 |
-
jQuery.fn.highlight = function(pat, option) {
|
909 |
-
|
910 |
-
options = jQuery.extend( options, defaults, option )
|
911 |
-
|
912 |
-
function innerHighlight(node, pat) {
|
913 |
-
var skip = 0;
|
914 |
-
|
915 |
-
if ( node.nodeType == 3 ) {
|
916 |
-
var pos = node.data.toUpperCase().indexOf(pat);
|
917 |
-
if (pos >= 0) {
|
918 |
-
var spannode = document.createElement('span');
|
919 |
-
spannode.className = options.className;
|
920 |
-
var middlebit = node.splitText(pos);
|
921 |
-
var endbit = middlebit.splitText(pat.length);
|
922 |
-
var middleclone = middlebit.cloneNode(true);
|
923 |
-
spannode.appendChild(middleclone);
|
924 |
-
middlebit.parentNode.replaceChild(spannode, middlebit);
|
925 |
-
skip = 1;
|
926 |
-
}
|
927 |
-
}
|
928 |
-
else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
|
929 |
-
for (var i = 0; i < node.childNodes.length; ++i) {
|
930 |
-
i += innerHighlight(node.childNodes[i], pat);
|
931 |
-
}
|
932 |
-
}
|
933 |
-
return skip;
|
934 |
-
}
|
935 |
-
return this.each(function() {
|
936 |
-
innerHighlight(this, pat.toUpperCase());
|
937 |
-
});
|
938 |
-
};
|
939 |
-
|
940 |
-
jQuery.fn.removeHighlight = function() {
|
941 |
-
function newNormalize(node) {
|
942 |
-
for (var i = 0, children = node.childNodes, nodeCount = children.length; i < nodeCount; i++) {
|
943 |
-
var child = children[i];
|
944 |
-
if (child.nodeType == 1) {
|
945 |
-
newNormalize(child);
|
946 |
-
continue;
|
947 |
-
}
|
948 |
-
if (child.nodeType != 3) { continue; }
|
949 |
-
var next = child.nextSibling;
|
950 |
-
if (next == null || next.nodeType != 3) { continue; }
|
951 |
-
var combined_text = child.nodeValue + next.nodeValue;
|
952 |
-
new_node = node.ownerDocument.createTextNode(combined_text);
|
953 |
-
node.insertBefore(new_node, child);
|
954 |
-
node.removeChild(child);
|
955 |
-
node.removeChild(next);
|
956 |
-
i--;
|
957 |
-
nodeCount--;
|
958 |
-
}
|
959 |
-
}
|
960 |
-
|
961 |
-
return this.find("span."+options.className).each(function() {
|
962 |
-
var thisParent = this.parentNode;
|
963 |
-
thisParent.replaceChild(this.firstChild, this);
|
964 |
-
newNormalize(thisParent);
|
965 |
-
}).end();
|
966 |
-
};
|
967 |
-
|
968 |
-
}(jQuery, window, document))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embedded/common/utility/utils.php
DELETED
@@ -1,111 +0,0 @@
|
|
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/views/promote.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!function_exists('promote_types_and_views')) {
|
4 |
+
|
5 |
+
function is_promote_views() {
|
6 |
+
$promote_views = false;
|
7 |
+
if (defined('WPV_VERSION')) {
|
8 |
+
global $WP_Views;
|
9 |
+
if ($WP_Views) {
|
10 |
+
$promote_views = $WP_Views->is_embedded();
|
11 |
+
}
|
12 |
+
}
|
13 |
+
return $promote_views;
|
14 |
+
}
|
15 |
+
|
16 |
+
function promote_types_and_views() {
|
17 |
+
static $promoted = false;
|
18 |
+
|
19 |
+
if (!$promoted) {
|
20 |
+
$promote_types = defined('WPCF_RUNNING_EMBEDDED');
|
21 |
+
$promote_views = is_promote_views();
|
22 |
+
|
23 |
+
if ($promote_types || $promote_views) {
|
24 |
+
add_action('admin_menu', 'promote_types_and_views_menu');
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
function promote_types_and_views_menu() {
|
30 |
+
$promote_types = defined('WPCF_RUNNING_EMBEDDED');
|
31 |
+
$promote_views = is_promote_views();
|
32 |
+
if ($promote_types || $promote_views) {
|
33 |
+
add_theme_page(__('Get Types and Views', 'wpv-views'), 'Get Types and Views', 'manage_options', 'wpv-get-types-views', 'promote_types_and_views_admin');
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
function promote_types_and_views_admin() {
|
38 |
+
?>
|
39 |
+
<div class="wrap">
|
40 |
+
<?php
|
41 |
+
|
42 |
+
$promote_types = defined('WPCF_RUNNING_EMBEDDED');
|
43 |
+
$promote_views = is_promote_views();
|
44 |
+
$affiliate_url = '';
|
45 |
+
if (function_exists('wpv_get_affiliate_url')) {
|
46 |
+
$affiliate_url = wpv_get_affiliate_url();
|
47 |
+
}
|
48 |
+
|
49 |
+
$icon_url = icl_get_file_relpath(dirname(__FILE__) . '/res/img/views-32.png') . '/views-32.png';
|
50 |
+
?>
|
51 |
+
<div class="icon32" style='background:url("<?php echo $icon_url; ?>") no-repeat;'><br /></div>
|
52 |
+
<h2><?php _e('Get Types and Views', 'wpv-views') ?></h2>
|
53 |
+
|
54 |
+
<p style="font-size: 130%;"><?php _e('Your theme was created using <strong>Types</strong> and <strong>Views</strong>. Developers use these two plugins to build complex websites, without coding.', 'wpv-views'); ?></p>
|
55 |
+
<p style="font-size: 120%;"><?php _e("Right now, you're using the embedded version, which creates the layout but doesn't include the editing interface. You can upgrade to the full version and customize your site yourself - you don't even need to know how to program!", 'wpv-views'); ?></p>
|
56 |
+
|
57 |
+
<p style="font-size: 120%;"><?php echo sprintf(__('Once you have installed the full versions of Types and Views you\'ll be able to create and edit your own content types, layouts and listings.', 'wpv-views'),
|
58 |
+
'http://wordpress.org/extend/plugins/types/',
|
59 |
+
'http://wp-types.com' . $affiliate_url); ?></p>
|
60 |
+
|
61 |
+
<p style="font-size: 140%; font-weight: bold; "><?php echo sprintf(__('<a href="%s" target="_blank">Learn more</a>', 'wpv-views'),
|
62 |
+
'http://wp-types.com' . $affiliate_url); ?></p>
|
63 |
+
|
64 |
+
<br /><hr /><br />
|
65 |
+
<ol>
|
66 |
+
<li><?php _e('Every purchase of Views entitles you to commercial-grade support and upgrades for one year.','wpv-views'); ?></li>
|
67 |
+
<li><?php _e('You can use Types and Views for as many themes and websites as you like.','wpv-views'); ?></li>
|
68 |
+
</ol>
|
69 |
+
|
70 |
+
<?php
|
71 |
+
|
72 |
+
//if ($promote_types && $promote_views) {
|
73 |
+
//
|
74 |
+
// wpv_promote_views_admin();
|
75 |
+
// echo "<hr />\n";
|
76 |
+
// wpcf_promote_types_admin();
|
77 |
+
//} else {
|
78 |
+
// if ($promote_types) {
|
79 |
+
// wpcf_promote_types_admin();
|
80 |
+
// } else {
|
81 |
+
// wpv_promote_views_admin();
|
82 |
+
// }
|
83 |
+
//}
|
84 |
+
|
85 |
+
?>
|
86 |
+
</div>
|
87 |
+
<?php
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
}
|
93 |
+
|
embedded/common/views/res/img/views-32.png
ADDED
Binary file
|
embedded/common/visual-editor/editor-addon-generic.class.php
CHANGED
@@ -1,13 +1,4 @@
|
|
1 |
<?php
|
2 |
-
/**
|
3 |
-
* Editor_addon_generic class
|
4 |
-
*
|
5 |
-
* Defines EDITOR_ADDON_ABSPATH and EDITOR_ADDON_RELPATH if not already defined.
|
6 |
-
* Scripts and styles required for the icl_editor are also registered and possibly enqueued here.
|
7 |
-
*
|
8 |
-
* @since unknown
|
9 |
-
*/
|
10 |
-
|
11 |
|
12 |
if( !class_exists( 'Editor_addon_generic' ) )
|
13 |
{
|
@@ -20,104 +11,31 @@ if( !class_exists( 'Editor_addon_generic' ) )
|
|
20 |
define( 'EDITOR_ADDON_RELPATH', icl_get_file_relpath( __FILE__ ) );
|
21 |
}
|
22 |
|
23 |
-
add_action( '
|
24 |
|
25 |
-
if
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Register and optionally enqueue styles for icl_editor (in backend only).
|
30 |
-
*
|
31 |
-
* Styles:
|
32 |
-
*
|
33 |
-
* - editor_addon_menu
|
34 |
-
* - editor_addon_menu_scroll
|
35 |
-
*
|
36 |
-
* @since unknown
|
37 |
-
*/
|
38 |
-
function icl_editor_admin_enqueue_styles() {
|
39 |
-
|
40 |
-
wp_register_style( 'editor_addon_menu', EDITOR_ADDON_RELPATH . '/res/css/pro_dropdown_2.css' );
|
41 |
-
wp_register_style( 'editor_addon_menu_scroll', EDITOR_ADDON_RELPATH . '/res/css/scroll.css' );
|
42 |
-
|
43 |
global $pagenow;
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
$_GET['page'] == 'views-editor'
|
52 |
-
|| $_GET['page'] == 'view-archives-editor'
|
53 |
-
|| $_GET['page'] == 'dd_layouts_edit'
|
54 |
-
)
|
55 |
-
) // add the new Views edit screens
|
56 |
) {
|
57 |
-
wp_enqueue_style( 'editor_addon_menu'
|
58 |
-
|
|
|
|
|
59 |
}
|
60 |
}
|
61 |
}
|
62 |
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
if ( ! function_exists( 'icl_editor_admin_enqueue_scripts' ) ) {
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Register and optionally enqueue scripts for icl_editor (in backend only).
|
70 |
-
*
|
71 |
-
* Scripts:
|
72 |
-
*
|
73 |
-
* - icl_editor-script
|
74 |
-
* - icl_media-manager-js
|
75 |
-
*
|
76 |
-
* When icl_media-manager-js is enqueued, it also gets localized here.
|
77 |
-
*
|
78 |
-
* @since unknown
|
79 |
-
*/
|
80 |
-
function icl_editor_admin_enqueue_scripts() {
|
81 |
-
|
82 |
-
wp_register_script( 'icl_editor-script', EDITOR_ADDON_RELPATH . '/res/js/icl_editor_addon_plugin.js', array( 'jquery', 'quicktags', 'wplink' ) );
|
83 |
-
|
84 |
-
wp_register_script( 'icl_media-manager-js', EDITOR_ADDON_RELPATH . '/res/js/icl_media_manager.js', array( 'jquery', 'icl_editor-script' ) );
|
85 |
-
|
86 |
-
global $pagenow;
|
87 |
-
if (
|
88 |
-
$pagenow == 'post.php'
|
89 |
-
|| $pagenow == 'post-new.php'
|
90 |
-
|| (
|
91 |
-
$pagenow == 'admin.php'
|
92 |
-
&& isset( $_GET['page'] )
|
93 |
-
&& (
|
94 |
-
$_GET['page'] == 'views-editor'
|
95 |
-
|| $_GET['page'] == 'view-archives-editor'
|
96 |
-
|| $_GET['page'] == 'dd_layouts_edit'
|
97 |
-
)
|
98 |
-
)
|
99 |
-
) {
|
100 |
-
wp_enqueue_script( 'icl_editor-script' );
|
101 |
-
}
|
102 |
-
|
103 |
-
if (
|
104 |
-
$pagenow == 'admin.php'
|
105 |
-
&& isset( $_GET['page'] )
|
106 |
-
&& (
|
107 |
-
$_GET['page'] == 'views-editor'
|
108 |
-
|| $_GET['page'] == 'view-archives-editor'
|
109 |
-
|| $_GET['page'] == 'dd_layouts_edit'
|
110 |
-
)
|
111 |
-
&& !wp_script_is( 'views-redesign-media-manager-js', 'enqueued' )
|
112 |
-
) {
|
113 |
-
$media_manager_translations = array(
|
114 |
-
'only_img_allowed_here' => __( "You can only use an image file here", 'wpv-views' )
|
115 |
-
);
|
116 |
-
wp_enqueue_media();
|
117 |
-
wp_enqueue_script( 'icl_media-manager-js' );
|
118 |
-
wp_localize_script( 'icl_media-manager-js', 'icl_media_manager', $media_manager_translations );
|
119 |
-
}
|
120 |
-
}
|
121 |
}
|
122 |
|
123 |
class Editor_addon_generic
|
@@ -163,29 +81,30 @@ if( !class_exists( 'Editor_addon_generic' ) )
|
|
163 |
|
164 |
}
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
-
/**
|
168 |
-
* Add a menu item that will insert the shortcode.
|
169 |
-
*
|
170 |
-
* To use sub menus, add a '-!-' separator between levels in the $menu parameter.
|
171 |
-
* eg. Field-!-image
|
172 |
-
* This will create/use a menu "Field" and add a sub menu "image"
|
173 |
-
*
|
174 |
-
* $function_name is the javascript function to call for the on-click
|
175 |
-
* If it's left blank then a function will be created that just
|
176 |
-
* inserts the shortcode.
|
177 |
*/
|
|
|
178 |
public function add_insert_shortcode_menu( $text, $shortcode, $menu,
|
179 |
$function_name = '' ) {
|
180 |
$this->items[] = array($text, $shortcode, $menu, $function_name);
|
181 |
}
|
182 |
-
|
183 |
|
184 |
public function add_form_button( $context, $text_area, $standard_v, $add_views, $codemirror_button )
|
185 |
{
|
186 |
throw new Exception( 'You should implement this method '. __METHOD__ );
|
187 |
}
|
188 |
-
|
189 |
|
190 |
public static function getWpForbiddenNames()
|
191 |
{
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
if( !class_exists( 'Editor_addon_generic' ) )
|
4 |
{
|
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' );
|
30 |
+
wp_enqueue_style( 'editor_addon_menu_scroll',
|
31 |
+
EDITOR_ADDON_RELPATH . '/res/css/scroll.css' );
|
32 |
}
|
33 |
}
|
34 |
}
|
35 |
|
36 |
|
37 |
+
if ( is_admin() ) {
|
38 |
+
add_action( 'admin_print_scripts', 'editor_add_js' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
class Editor_addon_generic
|
81 |
|
82 |
}
|
83 |
|
84 |
+
/*
|
85 |
+
|
86 |
+
Add a menu item that will insert the shortcode.
|
87 |
+
|
88 |
+
To use sub menus, add a '-!-' separator between levels in
|
89 |
+
the $menu parameter.
|
90 |
+
eg. Field-!-image
|
91 |
+
This will create/use a menu "Field" and add a sub menu "image"
|
92 |
+
|
93 |
+
$function_name is the javascript function to call for the on-click
|
94 |
+
If it's left blank then a function will be created that just
|
95 |
+
inserts the shortcode.
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
*/
|
98 |
+
|
99 |
public function add_insert_shortcode_menu( $text, $shortcode, $menu,
|
100 |
$function_name = '' ) {
|
101 |
$this->items[] = array($text, $shortcode, $menu, $function_name);
|
102 |
}
|
|
|
103 |
|
104 |
public function add_form_button( $context, $text_area, $standard_v, $add_views, $codemirror_button )
|
105 |
{
|
106 |
throw new Exception( 'You should implement this method '. __METHOD__ );
|
107 |
}
|
|
|
108 |
|
109 |
public static function getWpForbiddenNames()
|
110 |
{
|
embedded/common/visual-editor/editor-addon.class.php
CHANGED
@@ -17,20 +17,9 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
17 |
* @param string $text_area
|
18 |
* @param boolean $standard_v is this a standard V button
|
19 |
*/
|
20 |
-
function add_form_button( $context, $text_area = '', $standard_v = true, $add_views = false, $codemirror_button = false )
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* turn off button
|
24 |
-
*/
|
25 |
-
if ( !apply_filters('toolset_editor_add_form_buttons', true) ) {
|
26 |
-
return;
|
27 |
-
}
|
28 |
-
|
29 |
global $wp_version;
|
30 |
|
31 |
-
if ( empty($context) && $text_area == '' ){
|
32 |
-
return;
|
33 |
-
}
|
34 |
// WP 3.3 changes ($context arg is actually a editor ID now)
|
35 |
if ( version_compare( $wp_version, '3.1.4', '>' ) && !empty( $context ) ) {
|
36 |
$text_area = $context;
|
@@ -69,7 +58,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
69 |
// add View Template links to the "Add Field" button
|
70 |
if ( !$standard_v ) {
|
71 |
$this->add_view_type( $menus, 'view-template',
|
72 |
-
__( '
|
73 |
$this->add_view_type( $menus, 'view',
|
74 |
__( 'Post View', 'wpv-views' ) );
|
75 |
$this->add_view_type( $menus, 'view',
|
@@ -92,19 +81,21 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
92 |
$menus = $this->sort_menus_alphabetically( $menus );
|
93 |
}
|
94 |
|
|
|
95 |
$this->_media_menu_direct_links = array();
|
96 |
-
$menus_output = $this->_output_media_menu( $menus, $text_area,
|
|
|
97 |
|
98 |
$direct_links = implode( ' ', $this->_media_menu_direct_links );
|
99 |
$dropdown_class = 'js-editor_addon_dropdown-'.$this->name;
|
100 |
$icon_class = 'js-wpv-shortcode-post-icon-'.$this->name;
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
|
109 |
if( '' !== $this->media_button_image )
|
110 |
{
|
@@ -129,7 +120,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
129 |
// Codemirror (new layout) button
|
130 |
if ( $codemirror_button ){
|
131 |
$addon_button = '<button class="js-code-editor-toolbar-button js-code-editor-toolbar-button-v-icon button-secondary">'.
|
132 |
-
'<i class="icon-views
|
133 |
}
|
134 |
// add search box
|
135 |
$searchbar = $this->get_search_bar();
|
@@ -163,13 +154,9 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
163 |
|
164 |
/**
|
165 |
* Adding a "V" button to the menu (for user fields)
|
166 |
-
*
|
167 |
-
* @global object $wpdb
|
168 |
-
*
|
169 |
* @param string $context
|
170 |
* @param string $text_area
|
171 |
* @param boolean $standard_v is this a standard V button
|
172 |
-
* DEPRECATED since Views 1.9, not used anywhere else :-)
|
173 |
*/
|
174 |
function add_users_form_button( $context, $text_area = 'textarea#content', $codemirror_button = false ) {
|
175 |
global $wp_version, $sitepress, $wpdb, $WP_Views;
|
@@ -203,18 +190,12 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
203 |
array(__('User Status', 'wpv-views'), 'wpv-user field="user_status"',__('Basic', 'wpv-views'),''),
|
204 |
array(__('User Spam Status', 'wpv-views'), 'wpv-user field="spam"',__('Basic', 'wpv-views'),'')
|
205 |
);
|
206 |
-
|
207 |
if ( isset( $sitepress ) && function_exists( 'wpml_string_shortcode' ) ) {
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
__('Basic', 'wpv-views'),
|
213 |
-
"WPViews.shortcodes_gui.wpv_insert_popup('wpml-string', '" . __( 'Translatable string', 'wpv-views' ) . "', {}, '" . $nonce . "', this )"
|
214 |
-
);
|
215 |
-
}
|
216 |
-
|
217 |
-
|
218 |
|
219 |
$meta_keys = get_user_meta_keys();
|
220 |
$all_types_fields = get_option( 'wpcf-fields', array() );
|
@@ -228,7 +209,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
228 |
if ( preg_match($exclude_these_hidden_var , $key) ){
|
229 |
continue;
|
230 |
}
|
231 |
-
$this->items[] = array($key,
|
232 |
'wpv-user field="'.$key.'"',
|
233 |
__('Users fields', 'wpv-views'),'');
|
234 |
}
|
@@ -237,16 +218,16 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
237 |
if ( preg_match($exclude_these_hidden_var , $key) ){
|
238 |
continue;
|
239 |
}
|
240 |
-
$this->items[] = array($key,
|
241 |
'wpv-user field="'.$key.'"',
|
242 |
__('User fields', 'wpv-views'),'');
|
243 |
}
|
244 |
-
|
245 |
}
|
246 |
-
|
247 |
if ( function_exists('wpcf_init') ){
|
248 |
//Get types groups and fields
|
249 |
-
$groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
|
250 |
$user_id = wpcf_usermeta_get_user();
|
251 |
$add = array();
|
252 |
if ( !empty( $groups ) ) {
|
@@ -257,16 +238,16 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
257 |
$fields = wpcf_admin_fields_get_fields_by_group( $group['id'],
|
258 |
'slug', true, false, true, 'wp-types-user-group',
|
259 |
'wpcf-usermeta' );
|
260 |
-
|
261 |
if ( !empty( $fields ) ) {
|
262 |
foreach ( $fields as $field_id => $field ) {
|
263 |
$add[] = $field['meta_key'];
|
264 |
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'views-usermeta\', -1)';
|
265 |
-
$this->items[] = array($field['name'],
|
266 |
'types usermeta="'.$field['meta_key'].'"][/types',
|
267 |
-
$group['name'],$callback);
|
268 |
-
|
269 |
-
|
270 |
}
|
271 |
}
|
272 |
}
|
@@ -277,20 +258,20 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
277 |
foreach ( $cf_types as $cf_id => $cf ) {
|
278 |
if ( !in_array( $cf['meta_key'], $add) ){
|
279 |
$callback = 'wpcfFieldsEditorCallback(\'' . $cf['id'] . '\', \'views-usermeta\', -1)';
|
280 |
-
$this->items[] = array($cf['name'],
|
281 |
'types usermeta="'.$cf['meta_key'].'"][/types',
|
282 |
-
__('Types fields', 'wpv-views'),$callback);
|
283 |
-
|
284 |
}
|
285 |
}
|
286 |
}
|
287 |
-
|
288 |
$view_available = $wpdb->get_results("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_type='view' AND post_status in ('publish')");
|
289 |
foreach($view_available as $view) {
|
290 |
|
291 |
$view_settings = get_post_meta($view->ID, '_wpv_settings', true);
|
292 |
if (isset($view_settings['query_type'][0]) && $view_settings['query_type'][0] == 'posts' && !$WP_Views->is_archive_view($view->ID)) {
|
293 |
-
|
294 |
$this->items[] = array($view->post_title,
|
295 |
$view->post_title,
|
296 |
__('Post View', 'wpv-views'),
|
@@ -298,12 +279,12 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
298 |
);
|
299 |
}
|
300 |
}
|
301 |
-
|
302 |
$out = array();
|
303 |
-
|
304 |
$menus = array();
|
305 |
$sub_menus = array();
|
306 |
-
|
307 |
if( $this->items )
|
308 |
foreach ( $this->items as $item ) {
|
309 |
$parts = explode( '-!-', $item[2] );
|
@@ -319,8 +300,8 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
319 |
$menu_level[$item[0]] = $item;
|
320 |
}
|
321 |
|
322 |
-
|
323 |
-
|
324 |
|
325 |
// Sort menus
|
326 |
if ( is_array( $menus ) ) {
|
@@ -336,7 +317,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
336 |
$dropdown_class = 'js-editor_addon_dropdown-'.$this->name;
|
337 |
$icon_class = 'js-wpv-shortcode-post-icon-'.$this->name;
|
338 |
if ( $this->name == 'wpv-views' ) {
|
339 |
-
$button_label = __( '
|
340 |
} else if ( $this->name == 'types' ) {
|
341 |
$button_label = __( 'Types', 'wpv-views' );
|
342 |
} else {
|
@@ -351,7 +332,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
351 |
// Codemirrir (new layout) button
|
352 |
if ( $codemirror_button ){
|
353 |
$addon_button = '<button class="js-code-editor-toolbar-button js-code-editor-toolbar-button-v-icon button-secondary">'.
|
354 |
-
'<i class="icon-views
|
355 |
}
|
356 |
// add search box
|
357 |
$searchbar = $this->get_search_bar();
|
@@ -380,7 +361,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
380 |
} else {
|
381 |
return apply_filters( 'wpv_add_media_buttons', $context . $out );
|
382 |
}
|
383 |
-
|
384 |
}
|
385 |
|
386 |
/**
|
@@ -391,16 +372,6 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
391 |
* @return string media menu
|
392 |
*/
|
393 |
function _output_media_menu( $menu, $text_area, $standard_v ) {
|
394 |
-
|
395 |
-
/**
|
396 |
-
* get current post id
|
397 |
-
*/
|
398 |
-
$post_id = 0;
|
399 |
-
global $post;
|
400 |
-
if ( is_object($post) && isset($post->ID) ) {
|
401 |
-
$post_id = $post->ID;
|
402 |
-
}
|
403 |
-
|
404 |
$all_post_types = implode( ' ',
|
405 |
get_post_types( array('public' => true) ) );
|
406 |
|
@@ -422,12 +393,7 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
422 |
'wpv_insert_view_form_popup' ) !== false) ) {
|
423 |
$out .= $this->wpv_parse_menu_item_from_addfield( $menu_item );
|
424 |
} else {
|
425 |
-
$out .=
|
426 |
-
'<li class="item" onclick="%s; return false;" data-post-id="%d">%s</li>',
|
427 |
-
$menu_item[3],
|
428 |
-
$post_id,
|
429 |
-
$menu_item[0]
|
430 |
-
);
|
431 |
}
|
432 |
}
|
433 |
} else {
|
@@ -530,8 +496,8 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
530 |
$slug = $menu_item[0];
|
531 |
}
|
532 |
// View Templates here
|
533 |
-
if ( $menu_item[2] == __( '
|
534 |
-
$param1 = '
|
535 |
}
|
536 |
if ( $menu_item[2] == __( 'Post View', 'wpv-views' ) || $menu_item[2] == __( 'Taxonomy View',
|
537 |
'wpv-views' ) || $menu_item[2] == __( 'User View', 'wpv-views' ) ) {
|
@@ -597,12 +563,12 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
597 |
|
598 |
// add parent groups for vew templates
|
599 |
function add_view_template_parent_groups( $items ) {
|
600 |
-
global $post
|
601 |
// get current View ID
|
602 |
$view_template_id = $post->ID;
|
603 |
|
604 |
// get all view templates attached in the Settings page for single view
|
605 |
-
$view_template_relations = $
|
606 |
|
607 |
// find view template groups and get their parents
|
608 |
$current_types = array();
|
@@ -639,11 +605,11 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
639 |
// keep main references if set (not set on every screen)
|
640 |
$menu_temp = array();
|
641 |
$menu_names = array(
|
|
|
642 |
__( 'User View', 'wpv-views' ),
|
643 |
-
__( 'Taxonomy View', 'wpv-views' ),
|
644 |
__( 'Post View', 'wpv-views' ),
|
645 |
__( 'View', 'wpv-views' ),
|
646 |
-
__( '
|
647 |
__( 'Taxonomy', 'wpv-views' ),
|
648 |
__( 'Basic', 'wpv-views' ),
|
649 |
__( 'Other Fields', 'wpv-views' )
|
@@ -686,25 +652,13 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
686 |
return $searchbar;
|
687 |
}
|
688 |
|
689 |
-
/**
|
690 |
-
*
|
691 |
-
* @global object $wpdb
|
692 |
-
*
|
693 |
-
*/
|
694 |
function add_view_type( &$menus, $post_type, $post_name ) {
|
695 |
global $wpdb;
|
696 |
$all_post_types = implode( ' ',
|
697 |
get_post_types( array('public' => true) ) );
|
698 |
|
699 |
-
$view_templates_available = $wpdb->get_results(
|
700 |
-
|
701 |
-
"SELECT ID, post_title, post_name FROM {$wpdb->posts}
|
702 |
-
WHERE post_type = %s
|
703 |
-
AND post_status in (%s)",
|
704 |
-
$post_type,
|
705 |
-
'publish'
|
706 |
-
)
|
707 |
-
);
|
708 |
$menus[$post_name] = array();
|
709 |
$menus[$post_name]['css'] = $all_post_types;
|
710 |
|
@@ -718,13 +672,13 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
718 |
'_wpv_settings', true );
|
719 |
$title = $vtemplate->post_title . ' - ' . __( 'Post View',
|
720 |
'wpv-views' );
|
721 |
-
if ( isset( $view_settings['query_type']
|
722 |
$title = $vtemplate->post_title . ' - ' . __( 'Taxonomy View',
|
723 |
'wpv-views' );
|
724 |
if ( $post_name == __( 'Post View', 'wpv-views' ) || $post_name == __( 'User View', 'wpv-views' ) ) {
|
725 |
continue;
|
726 |
}
|
727 |
-
} elseif ( isset( $view_settings['query_type']
|
728 |
$title = $vtemplate->post_title . ' - ' . __( 'User View',
|
729 |
'wpv-views' );
|
730 |
if ( $post_name == __( 'Post View', 'wpv-views' ) || $post_name == __( 'Taxonomy View', 'wpv-views' ) ) {
|
@@ -748,6 +702,22 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
748 |
$vtemplate_index++;
|
749 |
}
|
750 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
751 |
}
|
752 |
|
753 |
/*
|
@@ -755,7 +725,8 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
755 |
*/
|
756 |
function wpv_mce_add_button( $buttons )
|
757 |
{
|
758 |
-
array_push( $buttons, "separator",
|
|
|
759 |
return $buttons;
|
760 |
}
|
761 |
|
@@ -772,6 +743,29 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
772 |
return $plugin_array;
|
773 |
}
|
774 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
775 |
|
776 |
/**
|
777 |
* Renders JS for inserting shortcode from thickbox popup to editor.
|
@@ -802,6 +796,8 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
802 |
<?php
|
803 |
}
|
804 |
}
|
|
|
|
|
805 |
|
806 |
}
|
807 |
|
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;
|
58 |
// add View Template links to the "Add Field" button
|
59 |
if ( !$standard_v ) {
|
60 |
$this->add_view_type( $menus, 'view-template',
|
61 |
+
__( 'View templates', 'wpv-views' ) );
|
62 |
$this->add_view_type( $menus, 'view',
|
63 |
__( 'Post View', 'wpv-views' ) );
|
64 |
$this->add_view_type( $menus, 'view',
|
81 |
$menus = $this->sort_menus_alphabetically( $menus );
|
82 |
}
|
83 |
|
84 |
+
|
85 |
$this->_media_menu_direct_links = array();
|
86 |
+
$menus_output = $this->_output_media_menu( $menus, $text_area,
|
87 |
+
$standard_v );
|
88 |
|
89 |
$direct_links = implode( ' ', $this->_media_menu_direct_links );
|
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 {
|
97 |
+
$button_label = '';
|
98 |
+
}
|
99 |
|
100 |
if( '' !== $this->media_button_image )
|
101 |
{
|
120 |
// Codemirror (new layout) button
|
121 |
if ( $codemirror_button ){
|
122 |
$addon_button = '<button class="js-code-editor-toolbar-button js-code-editor-toolbar-button-v-icon button-secondary">'.
|
123 |
+
'<i class="icon-views ont-icon-25"></i><span class="button-label">'. __('Fields', 'wpv-views') .'</span></button>';
|
124 |
}
|
125 |
// add search box
|
126 |
$searchbar = $this->get_search_bar();
|
154 |
|
155 |
/**
|
156 |
* Adding a "V" button to the menu (for user fields)
|
|
|
|
|
|
|
157 |
* @param string $context
|
158 |
* @param string $text_area
|
159 |
* @param boolean $standard_v is this a standard V button
|
|
|
160 |
*/
|
161 |
function add_users_form_button( $context, $text_area = 'textarea#content', $codemirror_button = false ) {
|
162 |
global $wp_version, $sitepress, $wpdb, $WP_Views;
|
190 |
array(__('User Status', 'wpv-views'), 'wpv-user field="user_status"',__('Basic', 'wpv-views'),''),
|
191 |
array(__('User Spam Status', 'wpv-views'), 'wpv-user field="spam"',__('Basic', 'wpv-views'),'')
|
192 |
);
|
193 |
+
|
194 |
if ( isset( $sitepress ) && function_exists( 'wpml_string_shortcode' ) ) {
|
195 |
+
$this->items[] = array(__('Translatable string', 'wpv-views'), 'wpml-string',__('Basic', 'wpv-views'),'wpv_insert_translatable_string_popup()');
|
196 |
+
}
|
197 |
+
|
198 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
|
200 |
$meta_keys = get_user_meta_keys();
|
201 |
$all_types_fields = get_option( 'wpcf-fields', array() );
|
209 |
if ( preg_match($exclude_these_hidden_var , $key) ){
|
210 |
continue;
|
211 |
}
|
212 |
+
$this->items[] = array($key,
|
213 |
'wpv-user field="'.$key.'"',
|
214 |
__('Users fields', 'wpv-views'),'');
|
215 |
}
|
218 |
if ( preg_match($exclude_these_hidden_var , $key) ){
|
219 |
continue;
|
220 |
}
|
221 |
+
$this->items[] = array($key,
|
222 |
'wpv-user field="'.$key.'"',
|
223 |
__('User fields', 'wpv-views'),'');
|
224 |
}
|
225 |
+
|
226 |
}
|
227 |
+
|
228 |
if ( function_exists('wpcf_init') ){
|
229 |
//Get types groups and fields
|
230 |
+
$groups = wpcf_admin_fields_get_groups( 'wp-types-user-group' );
|
231 |
$user_id = wpcf_usermeta_get_user();
|
232 |
$add = array();
|
233 |
if ( !empty( $groups ) ) {
|
238 |
$fields = wpcf_admin_fields_get_fields_by_group( $group['id'],
|
239 |
'slug', true, false, true, 'wp-types-user-group',
|
240 |
'wpcf-usermeta' );
|
241 |
+
|
242 |
if ( !empty( $fields ) ) {
|
243 |
foreach ( $fields as $field_id => $field ) {
|
244 |
$add[] = $field['meta_key'];
|
245 |
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'views-usermeta\', -1)';
|
246 |
+
$this->items[] = array($field['name'],
|
247 |
'types usermeta="'.$field['meta_key'].'"][/types',
|
248 |
+
$group['name'],$callback);
|
249 |
+
|
250 |
+
|
251 |
}
|
252 |
}
|
253 |
}
|
258 |
foreach ( $cf_types as $cf_id => $cf ) {
|
259 |
if ( !in_array( $cf['meta_key'], $add) ){
|
260 |
$callback = 'wpcfFieldsEditorCallback(\'' . $cf['id'] . '\', \'views-usermeta\', -1)';
|
261 |
+
$this->items[] = array($cf['name'],
|
262 |
'types usermeta="'.$cf['meta_key'].'"][/types',
|
263 |
+
__('Types fields', 'wpv-views'),$callback);
|
264 |
+
|
265 |
}
|
266 |
}
|
267 |
}
|
268 |
+
|
269 |
$view_available = $wpdb->get_results("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_type='view' AND post_status in ('publish')");
|
270 |
foreach($view_available as $view) {
|
271 |
|
272 |
$view_settings = get_post_meta($view->ID, '_wpv_settings', true);
|
273 |
if (isset($view_settings['query_type'][0]) && $view_settings['query_type'][0] == 'posts' && !$WP_Views->is_archive_view($view->ID)) {
|
274 |
+
|
275 |
$this->items[] = array($view->post_title,
|
276 |
$view->post_title,
|
277 |
__('Post View', 'wpv-views'),
|
279 |
);
|
280 |
}
|
281 |
}
|
282 |
+
|
283 |
$out = array();
|
284 |
+
|
285 |
$menus = array();
|
286 |
$sub_menus = array();
|
287 |
+
|
288 |
if( $this->items )
|
289 |
foreach ( $this->items as $item ) {
|
290 |
$parts = explode( '-!-', $item[2] );
|
300 |
$menu_level[$item[0]] = $item;
|
301 |
}
|
302 |
|
303 |
+
|
304 |
+
|
305 |
|
306 |
// Sort menus
|
307 |
if ( is_array( $menus ) ) {
|
317 |
$dropdown_class = 'js-editor_addon_dropdown-'.$this->name;
|
318 |
$icon_class = 'js-wpv-shortcode-post-icon-'.$this->name;
|
319 |
if ( $this->name == 'wpv-views' ) {
|
320 |
+
$button_label = __( 'Views', 'wpv-views' );
|
321 |
} else if ( $this->name == 'types' ) {
|
322 |
$button_label = __( 'Types', 'wpv-views' );
|
323 |
} else {
|
332 |
// Codemirrir (new layout) button
|
333 |
if ( $codemirror_button ){
|
334 |
$addon_button = '<button class="js-code-editor-toolbar-button js-code-editor-toolbar-button-v-icon button-secondary">'.
|
335 |
+
'<i class="icon-views ont-icon-25"></i><span class="button-label">'. __('Fields', 'wpv-views') .'</span></button>';
|
336 |
}
|
337 |
// add search box
|
338 |
$searchbar = $this->get_search_bar();
|
361 |
} else {
|
362 |
return apply_filters( 'wpv_add_media_buttons', $context . $out );
|
363 |
}
|
364 |
+
|
365 |
}
|
366 |
|
367 |
/**
|
372 |
* @return string media menu
|
373 |
*/
|
374 |
function _output_media_menu( $menu, $text_area, $standard_v ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
375 |
$all_post_types = implode( ' ',
|
376 |
get_post_types( array('public' => true) ) );
|
377 |
|
393 |
'wpv_insert_view_form_popup' ) !== false) ) {
|
394 |
$out .= $this->wpv_parse_menu_item_from_addfield( $menu_item );
|
395 |
} else {
|
396 |
+
$out .= '<li class="item" onclick="' . $menu_item[3] . '; return false;">' . $menu_item[0] . "</li>\n";
|
|
|
|
|
|
|
|
|
|
|
397 |
}
|
398 |
}
|
399 |
} else {
|
496 |
$slug = $menu_item[0];
|
497 |
}
|
498 |
// View Templates here
|
499 |
+
if ( $menu_item[2] == __( 'View templates', 'wpv-views' ) ) {
|
500 |
+
$param1 = 'View template';
|
501 |
}
|
502 |
if ( $menu_item[2] == __( 'Post View', 'wpv-views' ) || $menu_item[2] == __( 'Taxonomy View',
|
503 |
'wpv-views' ) || $menu_item[2] == __( 'User View', 'wpv-views' ) ) {
|
563 |
|
564 |
// add parent groups for vew templates
|
565 |
function add_view_template_parent_groups( $items ) {
|
566 |
+
global $post;
|
567 |
// get current View ID
|
568 |
$view_template_id = $post->ID;
|
569 |
|
570 |
// get all view templates attached in the Settings page for single view
|
571 |
+
$view_template_relations = $this->get_view_template_settings();
|
572 |
|
573 |
// find view template groups and get their parents
|
574 |
$current_types = array();
|
605 |
// keep main references if set (not set on every screen)
|
606 |
$menu_temp = array();
|
607 |
$menu_names = array(
|
608 |
+
__( 'Taxonomy View', 'wpv-views' ),
|
609 |
__( 'User View', 'wpv-views' ),
|
|
|
610 |
__( 'Post View', 'wpv-views' ),
|
611 |
__( 'View', 'wpv-views' ),
|
612 |
+
__( 'View templates', 'wpv-views' ),
|
613 |
__( 'Taxonomy', 'wpv-views' ),
|
614 |
__( 'Basic', 'wpv-views' ),
|
615 |
__( 'Other Fields', 'wpv-views' )
|
652 |
return $searchbar;
|
653 |
}
|
654 |
|
|
|
|
|
|
|
|
|
|
|
655 |
function add_view_type( &$menus, $post_type, $post_name ) {
|
656 |
global $wpdb;
|
657 |
$all_post_types = implode( ' ',
|
658 |
get_post_types( array('public' => true) ) );
|
659 |
|
660 |
+
$view_templates_available = $wpdb->get_results( "SELECT ID, post_title, post_name FROM {$wpdb->posts} WHERE
|
661 |
+
post_type='{$post_type}' AND post_status in ('publish')" );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
662 |
$menus[$post_name] = array();
|
663 |
$menus[$post_name]['css'] = $all_post_types;
|
664 |
|
672 |
'_wpv_settings', true );
|
673 |
$title = $vtemplate->post_title . ' - ' . __( 'Post View',
|
674 |
'wpv-views' );
|
675 |
+
if ( isset( $view_settings['query_type'][0] ) && $view_settings['query_type'][0] == 'taxonomy' ) {
|
676 |
$title = $vtemplate->post_title . ' - ' . __( 'Taxonomy View',
|
677 |
'wpv-views' );
|
678 |
if ( $post_name == __( 'Post View', 'wpv-views' ) || $post_name == __( 'User View', 'wpv-views' ) ) {
|
679 |
continue;
|
680 |
}
|
681 |
+
} elseif ( isset( $view_settings['query_type'][0] ) && $view_settings['query_type'][0] == 'users' ) {
|
682 |
$title = $vtemplate->post_title . ' - ' . __( 'User View',
|
683 |
'wpv-views' );
|
684 |
if ( $post_name == __( 'Post View', 'wpv-views' ) || $post_name == __( 'Taxonomy View', 'wpv-views' ) ) {
|
702 |
$vtemplate_index++;
|
703 |
}
|
704 |
}
|
705 |
+
|
706 |
+
function get_view_template_settings() {
|
707 |
+
$post_types = get_post_types();
|
708 |
+
|
709 |
+
$options = array();
|
710 |
+
$wpv_options = get_option( 'wpv_options' );
|
711 |
+
|
712 |
+
foreach ( $post_types as $type ) {
|
713 |
+
if ( isset( $wpv_options['views_template_for_' . $type] ) && !empty( $wpv_options['views_template_for_' . $type] ) ) {
|
714 |
+
$options[$type] = $wpv_options['views_template_for_' . $type];
|
715 |
+
}
|
716 |
+
}
|
717 |
+
|
718 |
+
return $options;
|
719 |
+
}
|
720 |
+
|
721 |
}
|
722 |
|
723 |
/*
|
725 |
*/
|
726 |
function wpv_mce_add_button( $buttons )
|
727 |
{
|
728 |
+
array_push( $buttons, "separator",
|
729 |
+
str_replace( '-', '_', $this->name ) );
|
730 |
return $buttons;
|
731 |
}
|
732 |
|
743 |
return $plugin_array;
|
744 |
}
|
745 |
}
|
746 |
+
|
747 |
+
if( !function_exists('editor_add_js') )
|
748 |
+
{
|
749 |
+
function editor_add_js() {
|
750 |
+
global $pagenow;
|
751 |
+
|
752 |
+
if (
|
753 |
+
$pagenow == 'post.php' ||
|
754 |
+
$pagenow == 'post-new.php' ||
|
755 |
+
( $pagenow == 'admin.php' && ( isset( $_GET['page'] ) &&
|
756 |
+
( $_GET['page'] == 'views-editor' ||
|
757 |
+
$_GET['page'] == 'view-archives-editor' ||
|
758 |
+
$_GET['page'] == 'dd_layouts_edit') ) ) // add the new Views edit screens
|
759 |
+
) {
|
760 |
+
|
761 |
+
|
762 |
+
wp_enqueue_script( 'icl_editor-script',
|
763 |
+
EDITOR_ADDON_RELPATH . '/res/js/icl_editor_addon_plugin.js',
|
764 |
+
array() );
|
765 |
+
}
|
766 |
+
}
|
767 |
+
}
|
768 |
+
|
769 |
|
770 |
/**
|
771 |
* Renders JS for inserting shortcode from thickbox popup to editor.
|
796 |
<?php
|
797 |
}
|
798 |
}
|
799 |
+
|
800 |
+
|
801 |
|
802 |
}
|
803 |
|
embedded/common/visual-editor/res/js/icl_editor_addon_plugin.js
CHANGED
@@ -1,111 +1,3 @@
|
|
1 |
-
var WPV_Toolset = WPV_Toolset || {};
|
2 |
-
|
3 |
-
WPV_Toolset.activeUrlEditor = null;
|
4 |
-
|
5 |
-
if ( typeof WPV_Toolset.CodeMirror_instance === "undefined" ) {
|
6 |
-
WPV_Toolset.CodeMirror_instance = [];
|
7 |
-
}
|
8 |
-
|
9 |
-
if ( typeof WPV_Toolset.add_qt_editor_buttons !== 'function' ) {
|
10 |
-
WPV_Toolset.add_qt_editor_buttons = function( qt_instance, editor_instance ) {
|
11 |
-
QTags._buttonsInit();
|
12 |
-
WPV_Toolset.CodeMirror_instance[qt_instance.id] = editor_instance;
|
13 |
-
|
14 |
-
for ( var button_name in qt_instance.theButtons ) {
|
15 |
-
if ( qt_instance.theButtons.hasOwnProperty( button_name ) ) {
|
16 |
-
qt_instance.theButtons[button_name].old_callback = qt_instance.theButtons[button_name].callback;
|
17 |
-
if ( qt_instance.theButtons[button_name].id == 'img' ){
|
18 |
-
qt_instance.theButtons[button_name].callback = function( element, canvas, ed ) {
|
19 |
-
var t = this,
|
20 |
-
id = jQuery( canvas ).attr( 'id' ),
|
21 |
-
selection = WPV_Toolset.CodeMirror_instance[id].getSelection(),
|
22 |
-
e = "http://",
|
23 |
-
g = prompt( quicktagsL10n.enterImageURL, e ),
|
24 |
-
f = prompt( quicktagsL10n.enterImageDescription, "" );
|
25 |
-
t.tagStart = '<img src="'+g+'" alt="'+f+'" />';
|
26 |
-
selection = t.tagStart;
|
27 |
-
t.closeTag( element, ed );
|
28 |
-
WPV_Toolset.CodeMirror_instance[id].replaceSelection( selection, 'end' );
|
29 |
-
WPV_Toolset.CodeMirror_instance[id].focus();
|
30 |
-
}
|
31 |
-
} else if ( qt_instance.theButtons[button_name].id == 'close' ) {
|
32 |
-
|
33 |
-
} else if ( qt_instance.theButtons[button_name].id == 'link' ) {
|
34 |
-
var t = this;
|
35 |
-
qt_instance.theButtons[button_name].callback =
|
36 |
-
function ( b, c, d, e ) {
|
37 |
-
WPV_Toolset.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)))
|
38 |
-
};
|
39 |
-
if( WPV_Toolset.activeUrlEditor ){
|
40 |
-
jQuery( '#wp-link-submit' ).off();
|
41 |
-
jQuery( '#wp-link-submit' ).on( 'click', function() {
|
42 |
-
try{
|
43 |
-
var id = jQuery( WPV_Toolset.activeUrlEditor ).attr('id'),
|
44 |
-
selection = WPV_Toolset.CodeMirror_instance[id].getSelection(),
|
45 |
-
target = '';
|
46 |
-
if ( jQuery( '#link-target-checkbox' ).prop('checked') ) {
|
47 |
-
target = '_blank';
|
48 |
-
}
|
49 |
-
html = '<a href="' + jQuery('#url-field').val() + '"';
|
50 |
-
title = '';
|
51 |
-
if ( jQuery( '#link-title-field' ).val() ) {
|
52 |
-
title = jQuery( '#link-title-field' ).val().replace( /</g, '<' ).replace( />/g, '>' ).replace( /"/g, '"' );
|
53 |
-
html += ' title="' + title + '"';
|
54 |
-
}
|
55 |
-
if ( target ) {
|
56 |
-
html += ' target="' + target + '"';
|
57 |
-
}
|
58 |
-
html += '>';
|
59 |
-
if ( selection === '' ) {
|
60 |
-
html += title;
|
61 |
-
} else {
|
62 |
-
html += selection;
|
63 |
-
}
|
64 |
-
html += '</a>';
|
65 |
-
t.tagStart = html;
|
66 |
-
selection = t.tagStart;
|
67 |
-
WPV_Toolset.CodeMirror_instance[id].replaceSelection( selection, 'end' );
|
68 |
-
WPV_Toolset.CodeMirror_instance[id].focus();
|
69 |
-
jQuery( '#wp-link-backdrop,#wp-link-wrap' ).hide();
|
70 |
-
jQuery( document.body ).removeClass( 'modal-open' );
|
71 |
-
return false;
|
72 |
-
} catch( e ){
|
73 |
-
console.log( e.message, WPV_Toolset.activeUrlEditor );
|
74 |
-
}
|
75 |
-
|
76 |
-
});
|
77 |
-
}
|
78 |
-
|
79 |
-
} else {
|
80 |
-
qt_instance.theButtons[button_name].callback = function( element, canvas, ed ) {
|
81 |
-
var id = jQuery( canvas ).attr( 'id' ),
|
82 |
-
t = this,
|
83 |
-
selection = WPV_Toolset.CodeMirror_instance[id].getSelection();
|
84 |
-
if ( selection.length > 0 ) {
|
85 |
-
if ( !t.tagEnd ) {
|
86 |
-
selection = selection + t.tagStart;
|
87 |
-
} else {
|
88 |
-
selection = t.tagStart + selection + t.tagEnd;
|
89 |
-
}
|
90 |
-
} else {
|
91 |
-
if ( !t.tagEnd ) {
|
92 |
-
selection = t.tagStart;
|
93 |
-
} else if ( t.isOpen( ed ) === false ) {
|
94 |
-
selection = t.tagStart;
|
95 |
-
t.openTag( element, ed );
|
96 |
-
} else {
|
97 |
-
selection = t.tagEnd;
|
98 |
-
t.closeTag( element, ed );
|
99 |
-
}
|
100 |
-
}
|
101 |
-
WPV_Toolset.CodeMirror_instance[id].replaceSelection(selection, 'end');
|
102 |
-
WPV_Toolset.CodeMirror_instance[id].focus();
|
103 |
-
}
|
104 |
-
}
|
105 |
-
}
|
106 |
-
}
|
107 |
-
}
|
108 |
-
}
|
109 |
|
110 |
var iclEditorWidth = 550;
|
111 |
var iclEditorWidthMin = 195;
|
@@ -250,14 +142,14 @@ jQuery(document).ready(function(){
|
|
250 |
icl_editor_popup(drop_down);
|
251 |
|
252 |
jQuery(drop_down).find('.search_field').focus();
|
253 |
-
|
254 |
// Make sure the dialog fits on the screen when used in
|
255 |
// Layouts for the Post Content dialog
|
256 |
if (jQuery(drop_down).closest('#ddl-default-edit').length > 0) {
|
257 |
var dialog_bottom = jQuery(drop_down).offset().top + jQuery(drop_down).height();
|
258 |
dialog_bottom -= jQuery(window).scrollTop();
|
259 |
var window_height = jQuery(window).height();
|
260 |
-
|
261 |
if (dialog_bottom > window_height) {
|
262 |
var new_top = window_height - jQuery(drop_down).height() - 80;
|
263 |
if (new_top < 0) {
|
@@ -400,6 +292,20 @@ jQuery(document).ready(function(){
|
|
400 |
});
|
401 |
});
|
402 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
/**
|
404 |
*
|
405 |
* Main popup function
|
@@ -629,8 +535,8 @@ function insert_b64_shortcode_to_editor(b64_shortcode, text_area) {
|
|
629 |
if(shortcode.indexOf('[types') == 0 && shortcode.indexOf('[/types') === false) {
|
630 |
shortcode += '[/types]';
|
631 |
}
|
632 |
-
window.wpcfActiveEditor = text_area;
|
633 |
|
|
|
634 |
icl_editor.insert(shortcode);
|
635 |
}
|
636 |
|
@@ -812,77 +718,19 @@ var icl_editor = (function(window, $){
|
|
812 |
|
813 |
function isCodeMirror($textarea)
|
814 |
{
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
textareaNext.CodeMirror
|
826 |
-
&& $textarea[0] == textareaNext.CodeMirror.getTextArea()
|
827 |
-
) {
|
828 |
-
return textareaNext.CodeMirror;
|
829 |
-
}
|
830 |
-
// Juan: CodeMirror panels wrap the CodeMirror div and themselves into a div.
|
831 |
-
// Depending on the panels position, the CodeMirror div becomes the first or last child of that wrapper.
|
832 |
-
// We need to check if the relevant node contains the right CodeMirror div as a child node.
|
833 |
-
// Note that we will do the same below, so we can have CodeMirror panels in main editors too.
|
834 |
-
var textareaNextHasPanels = isCodeMirrorWithPanels( $textarea, textareaNext );
|
835 |
-
if ( textareaNextHasPanels ) {
|
836 |
-
return textareaNextHasPanels;
|
837 |
-
}
|
838 |
-
// Emerson: WordPress 4.0+ introduces 'content-textarea-clone' div which in some instances is loaded after our textarea and before the CodeMirror div.
|
839 |
-
// This core feature in WP is used in their auto-resize editor and distraction free writing.
|
840 |
-
// This is particularly found in pages and post affecting syntax highlighting in main editors.
|
841 |
-
// Let's skip that node and check if the nextsibling is really the CodeMirror div.
|
842 |
-
var textareaNextNext = textareaNext.nextSibling;
|
843 |
-
if ( textareaNextNext ) {
|
844 |
-
if (
|
845 |
-
textareaNextNext.CodeMirror
|
846 |
-
&& $textarea[0] == textareaNextNext.CodeMirror.getTextArea()
|
847 |
-
) {
|
848 |
-
return textareaNextNext.CodeMirror;
|
849 |
-
}
|
850 |
-
var textareaNextNextHasPanels = isCodeMirrorWithPanels( $textarea, textareaNextNext );
|
851 |
-
if ( textareaNextNextHasPanels ) {
|
852 |
-
return textareaNextNextHasPanels;
|
853 |
-
}
|
854 |
-
}
|
855 |
-
}
|
856 |
return false;
|
857 |
};
|
858 |
|
859 |
-
function isCodeMirrorWithPanels( $textarea, candidateNode ) {
|
860 |
-
if ( ! $textarea.is('textarea') ) {
|
861 |
-
return false;
|
862 |
-
}
|
863 |
-
if ( typeof candidateNode === 'undefined' ) {
|
864 |
-
return false;
|
865 |
-
}
|
866 |
-
if ( candidateNode ) {
|
867 |
-
var candidateNodeFirstChild = candidateNode.firstChild,
|
868 |
-
candidateNodeLastChiild = candidateNode.lastChild;
|
869 |
-
if (
|
870 |
-
candidateNodeFirstChild
|
871 |
-
&& candidateNodeFirstChild.CodeMirror
|
872 |
-
&& $textarea[0] == candidateNodeFirstChild.CodeMirror.getTextArea()
|
873 |
-
) {
|
874 |
-
return candidateNodeFirstChild.CodeMirror;
|
875 |
-
} else if (
|
876 |
-
candidateNodeLastChiild
|
877 |
-
&& candidateNodeLastChiild.CodeMirror
|
878 |
-
&& $textarea[0] == candidateNodeLastChiild.CodeMirror.getTextArea()
|
879 |
-
) {
|
880 |
-
return candidateNodeLastChiild.CodeMirror;
|
881 |
-
}
|
882 |
-
}
|
883 |
-
return false;
|
884 |
-
}
|
885 |
-
|
886 |
function getContent($area)
|
887 |
{
|
888 |
if (!$area) $area=$('#content');
|
@@ -1063,5 +911,4 @@ var icl_editor = (function(window, $){
|
|
1063 |
}
|
1064 |
};
|
1065 |
|
1066 |
-
|
1067 |
})(window, jQuery, undefined);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
var iclEditorWidth = 550;
|
3 |
var iclEditorWidthMin = 195;
|
142 |
icl_editor_popup(drop_down);
|
143 |
|
144 |
jQuery(drop_down).find('.search_field').focus();
|
145 |
+
|
146 |
// Make sure the dialog fits on the screen when used in
|
147 |
// Layouts for the Post Content dialog
|
148 |
if (jQuery(drop_down).closest('#ddl-default-edit').length > 0) {
|
149 |
var dialog_bottom = jQuery(drop_down).offset().top + jQuery(drop_down).height();
|
150 |
dialog_bottom -= jQuery(window).scrollTop();
|
151 |
var window_height = jQuery(window).height();
|
152 |
+
|
153 |
if (dialog_bottom > window_height) {
|
154 |
var new_top = window_height - jQuery(drop_down).height() - 80;
|
155 |
if (new_top < 0) {
|
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 |
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 |
|
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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
734 |
function getContent($area)
|
735 |
{
|
736 |
if (!$area) $area=$('#content');
|
911 |
}
|
912 |
};
|
913 |
|
|
|
914 |
})(window, jQuery, undefined);
|
embedded/common/visual-editor/res/js/icl_media_manager.js
DELETED
@@ -1,260 +0,0 @@
|
|
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/common/wplogger.php
CHANGED
@@ -4,12 +4,12 @@
|
|
4 |
*
|
5 |
*
|
6 |
*
|
7 |
-
Wordpress Logger
|
8 |
-
http://www.turingtarpit.com/2009/05/wordpress-logger-a-plugin-to-display-php-log-messages-in-safari-and-firefox/
|
9 |
-
Displays log messages in the browser console in Safari, Firefox and Opera. Useful for plugin and theme developers to debug PHP code.
|
10 |
-
0.3
|
11 |
-
Chandima Cumaranatunge
|
12 |
-
http://www.turingtarpit.com
|
13 |
|
14 |
This program is free software; you can redistribute it and/or modify
|
15 |
it under the terms of the GNU General Public License as published by
|
4 |
*
|
5 |
*
|
6 |
*
|
7 |
+
Plugin Name: Wordpress Logger
|
8 |
+
Plugin URI: http://www.turingtarpit.com/2009/05/wordpress-logger-a-plugin-to-display-php-log-messages-in-safari-and-firefox/
|
9 |
+
Description: Displays log messages in the browser console in Safari, Firefox and Opera. Useful for plugin and theme developers to debug PHP code.
|
10 |
+
Version: 0.3
|
11 |
+
Author: Chandima Cumaranatunge
|
12 |
+
Author URI: http://www.turingtarpit.com
|
13 |
|
14 |
This program is free software; you can redistribute it and/or modify
|
15 |
it under the terms of the GNU General Public License as published by
|
embedded/common/wpv-filter-date-embedded.php
CHANGED
@@ -124,7 +124,7 @@ if (!function_exists('wpv_filter_parse_date')) {
|
|
124 |
$date = Toolset_DateParser::parseDate( $date_string, $format );
|
125 |
if( is_object($date) && method_exists( $date, 'getTimestamp' ) )
|
126 |
{
|
127 |
-
$timestamp = $date->getTimestamp()
|
128 |
return $timestamp;
|
129 |
}
|
130 |
|
124 |
$date = Toolset_DateParser::parseDate( $date_string, $format );
|
125 |
if( is_object($date) && method_exists( $date, 'getTimestamp' ) )
|
126 |
{
|
127 |
+
$timestamp = $date->getTimestamp();
|
128 |
return $timestamp;
|
129 |
}
|
130 |
|
embedded/frontend.php
CHANGED
@@ -2,10 +2,10 @@
|
|
2 |
/*
|
3 |
* Frontend functions.
|
4 |
*
|
5 |
-
* $HeadURL:
|
6 |
-
* $LastChangedDate:
|
7 |
-
* $LastChangedRevision:
|
8 |
-
* $LastChangedBy:
|
9 |
*
|
10 |
*/
|
11 |
|
@@ -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 |
|
@@ -82,11 +82,8 @@ function wpcf_shortcode( $atts, $content = null, $code = '' ) {
|
|
82 |
* @param type $atts
|
83 |
* @return type
|
84 |
*/
|
85 |
-
function types_render_field( $field_id
|
86 |
{
|
87 |
-
if ( empty($field_id) ) {
|
88 |
-
return '';
|
89 |
-
}
|
90 |
|
91 |
global $wpcf;
|
92 |
|
@@ -239,11 +236,14 @@ function types_render_field_single( $field, $params, $content = null, $code = ''
|
|
239 |
$params = apply_filters( 'types_field_shortcode_parameters', $params,
|
240 |
$field, $post, $meta_id );
|
241 |
|
242 |
-
$params['field_value'] = apply_filters( 'wpcf_fields_value_display',
|
|
|
243 |
|
244 |
-
$params['field_value'] = apply_filters( 'wpcf_fields_slug_' . $field['slug'] . '_value_display',
|
|
|
245 |
|
246 |
-
$params['field_value'] = apply_filters( 'wpcf_fields_type_' . $field['type'] . '_value_display',
|
|
|
247 |
// To make sure
|
248 |
if ( is_string( $params['field_value'] ) ) {
|
249 |
$params['field_value'] = addslashes( stripslashes( strval( $params['field_value'] ) ) );
|
@@ -331,7 +331,7 @@ function types_render_field_single( $field, $params, $content = null, $code = ''
|
|
331 |
$output = strval( apply_filters( 'types_view', $output,
|
332 |
$params['field_value'], $field['type'], $field['slug'],
|
333 |
$field['name'], $params ) );
|
334 |
-
return
|
335 |
}
|
336 |
|
337 |
function wpcf_frontend_compat_html_output( $output, $field, $content, $params ) {
|
@@ -525,10 +525,6 @@ function wpcf_views_query( $query, $view_settings ) {
|
|
525 |
$field_name = $meta['key'];
|
526 |
if ( _wpcf_is_checkboxes_field( $field_name ) ) {
|
527 |
|
528 |
-
$orginal = $query['meta_query'][$index];
|
529 |
-
|
530 |
-
unset($query['meta_query'][$index]);
|
531 |
-
|
532 |
// We'll use SQL regexp to find the checked items.
|
533 |
// Note that we are creating something here that
|
534 |
// then gets modified to a proper SQL REGEXP in
|
@@ -537,77 +533,32 @@ function wpcf_views_query( $query, $view_settings ) {
|
|
537 |
$field_name = substr( $field_name, 5 );
|
538 |
|
539 |
$meta_filter_required = true;
|
|
|
|
|
|
|
|
|
|
|
540 |
|
541 |
-
/* According to http://codex.wordpress.org/Class_Reference/WP_Meta_Query#Accepted_Arguments,
|
542 |
-
* $meta['value'] can be an array or a string. In case of a string we additionally allow
|
543 |
-
* multiple comma-separated values. */
|
544 |
-
if( is_array( $meta['value'] ) ) {
|
545 |
-
$values = $meta['value'];
|
546 |
-
} elseif( is_string( $meta['value'] ) ) {
|
547 |
-
$values = explode( ',', $meta['value'] );
|
548 |
-
} else {
|
549 |
-
// This can happen if $meta['value'] is a number, for example.
|
550 |
-
$values = array( $meta['value'] );
|
551 |
-
}
|
552 |
$options = $opt[$field_name]['data']['options'];
|
553 |
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
// We can use nested meta_query entries
|
573 |
-
if ( count( $values ) < 2 ) {
|
574 |
-
// Only one value to filter by, so no need to add nested meta_query entries
|
575 |
-
foreach ( $values as $value ) {
|
576 |
-
foreach ( $options as $key => $option ) {
|
577 |
-
if ( $option['title'] == $value ) {
|
578 |
-
$query['meta_query'][] = array(
|
579 |
-
'key' => $meta['key'],
|
580 |
-
'compare' => in_array( $orginal['compare'], array( '!=', 'NOT LIKE', 'NOT IN' ) ) ? 'NOT LIKE' : 'LIKE',
|
581 |
-
'value' => $key,
|
582 |
-
'type' => 'CHAR',
|
583 |
-
);
|
584 |
-
break;
|
585 |
-
}
|
586 |
-
}
|
587 |
-
}
|
588 |
-
} else {
|
589 |
-
// We will translate each value into a meta_query clause and add them all as a nested meta_query entry
|
590 |
-
$inner_relation = in_array( $orginal['compare'], array( '!=', 'NOT LIKE', 'NOT IN' ) ) ? 'AND' : 'OR';
|
591 |
-
$inner_compare = in_array( $orginal['compare'], array( '!=', 'NOT LIKE', 'NOT IN' ) ) ? 'NOT LIKE' : 'LIKE';
|
592 |
-
$inner_meta_query = array(
|
593 |
-
'relation' => $inner_relation
|
594 |
-
);
|
595 |
-
foreach ( $values as $value ) {
|
596 |
-
foreach ( $options as $key => $option ) {
|
597 |
-
if ( $option['title'] == $value ) {
|
598 |
-
$inner_meta_query[] = array(
|
599 |
-
'key' => $meta['key'],
|
600 |
-
'compare' => $inner_compare,
|
601 |
-
'value' => $key,
|
602 |
-
'type' => 'CHAR',
|
603 |
-
);
|
604 |
-
break;
|
605 |
-
}
|
606 |
-
}
|
607 |
-
}
|
608 |
-
$query['meta_query'][] = $inner_meta_query;
|
609 |
-
}
|
610 |
-
}
|
611 |
}
|
612 |
}
|
613 |
}
|
@@ -616,6 +567,7 @@ function wpcf_views_query( $query, $view_settings ) {
|
|
616 |
if ( $meta_filter_required ) {
|
617 |
add_filter( 'get_meta_sql', 'wpcf_views_get_meta_sql', 10, 6 );
|
618 |
}
|
|
|
619 |
return $query;
|
620 |
}
|
621 |
|
2 |
/*
|
3 |
* Frontend functions.
|
4 |
*
|
5 |
+
* $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/embedded/frontend.php $
|
6 |
+
* $LastChangedDate: 2014-08-28 10:48:41 +0200 (Thu, 28 Aug 2014) $
|
7 |
+
* $LastChangedRevision: 26511 $
|
8 |
+
* $LastChangedBy: bruce $
|
9 |
*
|
10 |
*/
|
11 |
|
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 |
|
82 |
* @param type $atts
|
83 |
* @return type
|
84 |
*/
|
85 |
+
function types_render_field( $field_id, $params, $content = null, $code = '' )
|
86 |
{
|
|
|
|
|
|
|
87 |
|
88 |
global $wpcf;
|
89 |
|
236 |
$params = apply_filters( 'types_field_shortcode_parameters', $params,
|
237 |
$field, $post, $meta_id );
|
238 |
|
239 |
+
$params['field_value'] = apply_filters( 'wpcf_fields_value_display',
|
240 |
+
$params['field_value'], $params, $post->ID, $field['id'], $meta_id );
|
241 |
|
242 |
+
$params['field_value'] = apply_filters( 'wpcf_fields_slug_' . $field['slug'] . '_value_display',
|
243 |
+
$params['field_value'], $params, $post->ID, $field['id'], $meta_id );
|
244 |
|
245 |
+
$params['field_value'] = apply_filters( 'wpcf_fields_type_' . $field['type'] . '_value_display',
|
246 |
+
$params['field_value'], $params, $post->ID, $field['id'], $meta_id );
|
247 |
// To make sure
|
248 |
if ( is_string( $params['field_value'] ) ) {
|
249 |
$params['field_value'] = addslashes( stripslashes( strval( $params['field_value'] ) ) );
|
331 |
$output = strval( apply_filters( 'types_view', $output,
|
332 |
$params['field_value'], $field['type'], $field['slug'],
|
333 |
$field['name'], $params ) );
|
334 |
+
return $output;
|
335 |
}
|
336 |
|
337 |
function wpcf_frontend_compat_html_output( $output, $field, $content, $params ) {
|
525 |
$field_name = $meta['key'];
|
526 |
if ( _wpcf_is_checkboxes_field( $field_name ) ) {
|
527 |
|
|
|
|
|
|
|
|
|
528 |
// We'll use SQL regexp to find the checked items.
|
529 |
// Note that we are creating something here that
|
530 |
// then gets modified to a proper SQL REGEXP in
|
533 |
$field_name = substr( $field_name, 5 );
|
534 |
|
535 |
$meta_filter_required = true;
|
536 |
+
$meta['compare'] = '=';
|
537 |
+
|
538 |
+
$values = explode( ',', $meta['value'] );
|
539 |
+
|
540 |
+
$meta['value'] = ' REGEXP(';
|
541 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
$options = $opt[$field_name]['data']['options'];
|
543 |
|
544 |
+
$count = 0;
|
545 |
+
foreach ( $values as $value ) {
|
546 |
+
|
547 |
+
foreach ( $options as $key => $option ) {
|
548 |
+
if ( $option['title'] == $value ) {
|
549 |
+
if ( $count > 0 ) {
|
550 |
+
$meta['value'] .= '|';
|
551 |
+
}
|
552 |
+
$meta['value'] .= $key;
|
553 |
+
break;
|
554 |
+
}
|
555 |
+
}
|
556 |
+
$count++;
|
557 |
+
}
|
558 |
+
|
559 |
+
$meta['value'] .= ')';
|
560 |
+
|
561 |
+
$query['meta_query'][$index] = $meta;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
}
|
563 |
}
|
564 |
}
|
567 |
if ( $meta_filter_required ) {
|
568 |
add_filter( 'get_meta_sql', 'wpcf_views_get_meta_sql', 10, 6 );
|
569 |
}
|
570 |
+
|
571 |
return $query;
|
572 |
}
|
573 |
|
embedded/functions.php
CHANGED
@@ -1,711 +1,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.
|
7 |
-
* $LastChangedDate:
|
8 |
-
* $LastChangedRevision:
|
9 |
-
* $LastChangedBy:
|
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 |
-
}
|
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 |
-
$
|
48 |
-
$
|
49 |
-
$
|
50 |
-
$
|
51 |
-
|
52 |
-
|
53 |
-
$
|
54 |
-
$
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
{
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
}
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
*
|
108 |
-
*/
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
}
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
*
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
$
|
160 |
-
$
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
}
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
return
|
251 |
-
break;
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
*
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
*
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
$
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
);
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
*
|
390 |
-
* @
|
391 |
-
|
392 |
-
|
393 |
-
{
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
}
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
*
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
wp_enqueue_style( '
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
*
|
593 |
-
*
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
*
|
623 |
-
*
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
$wpcf->
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
*
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
*
|
698 |
-
*
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
}
|
|
|
|
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.2/embedded/functions.php $
|
7 |
+
* $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
|
8 |
+
* $LastChangedRevision: 970205 $
|
9 |
+
* $LastChangedBy: brucepearson $
|
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&_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&wpcf_action=dismiss_message&id='
|
136 |
+
. $timestamp . '&_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 |
+
}
|
embedded/includes/ajax.php
CHANGED
@@ -2,8 +2,6 @@
|
|
2 |
|
3 |
/**
|
4 |
* All AJAX calls go here.
|
5 |
-
*
|
6 |
-
* @todo auth
|
7 |
*/
|
8 |
function wpcf_ajax_embedded() {
|
9 |
|
@@ -13,10 +11,9 @@ function wpcf_ajax_embedded() {
|
|
13 |
}
|
14 |
} else {
|
15 |
|
16 |
-
if (
|
17 |
-
|
18 |
-
|
19 |
-
) {
|
20 |
die( 'Verification failed' );
|
21 |
}
|
22 |
}
|
@@ -25,80 +22,72 @@ function wpcf_ajax_embedded() {
|
|
25 |
|
26 |
switch ( $_REQUEST['wpcf_action'] ) {
|
27 |
|
28 |
-
case '
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
|
|
|
33 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/skype.php';
|
34 |
wpcf_fields_skype_meta_box_ajax();
|
35 |
break;
|
36 |
|
37 |
case 'editor_callback':
|
38 |
-
if( ! current_user_can( 'edit_posts' ) ) {
|
39 |
-
die( 'Authentication failed' );
|
40 |
-
}
|
41 |
-
|
42 |
// Determine Field type and context
|
43 |
$views_usermeta = false;
|
44 |
-
$field_id = sanitize_text_field( $_GET['field_id'] );
|
45 |
-
|
46 |
-
// todo this could be written in like four lines
|
47 |
if ( isset( $_GET['field_type'] ) && $_GET['field_type'] == 'usermeta' ) {
|
48 |
// Group filter
|
49 |
wp_enqueue_script( 'suggest' );
|
50 |
-
$field = types_get_field( $field_id, 'usermeta' );
|
51 |
$meta_type = 'usermeta';
|
52 |
}
|
53 |
elseif ( isset( $_GET['field_type'] ) && $_GET['field_type'] == 'views-usermeta' ){
|
54 |
-
$field = types_get_field( $field_id, 'usermeta' );
|
55 |
$meta_type = 'usermeta';
|
56 |
$views_usermeta = true;
|
57 |
}else {
|
58 |
-
$field = types_get_field( $field_id );
|
59 |
$meta_type = 'postmeta';
|
60 |
}
|
61 |
-
|
62 |
-
$parent_post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : null;
|
63 |
$shortcode = isset( $_GET['shortcode'] ) ? urldecode( $_GET['shortcode'] ) : null;
|
64 |
-
$callback = isset( $_GET['callback'] ) ?
|
65 |
if ( !empty( $field ) ) {
|
66 |
// Editor
|
67 |
WPCF_Loader::loadClass( 'editor' );
|
68 |
$editor = new WPCF_Editor();
|
69 |
-
$editor->frame( $field, $meta_type, $
|
70 |
$callback, $views_usermeta );
|
71 |
}
|
72 |
break;
|
73 |
|
74 |
case 'dismiss_message':
|
75 |
-
if( ! is_user_logged_in() ) {
|
76 |
-
die( 'Authentication failed' );
|
77 |
-
}
|
78 |
-
|
79 |
if ( isset( $_GET['id'] ) ) {
|
80 |
$messages = get_option( 'wpcf_dismissed_messages', array() );
|
81 |
-
$messages[] =
|
82 |
update_option( 'wpcf_dismissed_messages', $messages );
|
83 |
}
|
84 |
break;
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
case 'pr_add_child_post':
|
87 |
$output = 'Passed wrong parameters';
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
&& isset( $_GET['post_type_child'] )
|
92 |
-
&& isset( $_GET['post_type_parent'] ) )
|
93 |
-
{
|
94 |
|
95 |
$relationships = get_option( 'wpcf_post_relationship', array() );
|
96 |
-
$
|
97 |
-
|
98 |
-
|
99 |
-
$
|
100 |
-
$parent_post_type = sanitize_text_field( $_GET['post_type_parent'] );
|
101 |
-
// @todo isset & error handling
|
102 |
$data = $relationships[$parent_post_type][$post_type];
|
103 |
/*
|
104 |
* Since Types 1.1.5
|
@@ -106,16 +95,15 @@ function wpcf_ajax_embedded() {
|
|
106 |
* We save new post
|
107 |
* CHECKPOINT
|
108 |
*/
|
109 |
-
$id = $wpcf->relationship->add_new_child( $
|
|
|
110 |
|
111 |
-
if ( is_wp_error( $id ) ) {
|
112 |
-
$output = $id->get_error_message();
|
113 |
-
} else {
|
114 |
/*
|
115 |
* Here we set Relationship
|
116 |
* CHECKPOINT
|
117 |
*/
|
118 |
-
$parent = get_post( $
|
119 |
$child = get_post( $id );
|
120 |
if ( !empty( $parent->ID ) && !empty( $child->ID ) ) {
|
121 |
|
@@ -126,11 +114,14 @@ function wpcf_ajax_embedded() {
|
|
126 |
$wpcf->relationship->_set( $parent, $child, $data );
|
127 |
|
128 |
// Render new row
|
129 |
-
$output = $wpcf->relationship->child_row( $
|
130 |
$id, $data );
|
131 |
} else {
|
132 |
-
$output = __( 'Error creating post relationship',
|
|
|
133 |
}
|
|
|
|
|
134 |
}
|
135 |
} else {
|
136 |
$output = __( 'Error getting parent post', 'wpcf' );
|
@@ -151,17 +142,14 @@ function wpcf_ajax_embedded() {
|
|
151 |
|
152 |
case 'pr_save_all':
|
153 |
$output = '';
|
154 |
-
if (
|
155 |
|
156 |
$parent_id = intval( $_POST['post_id'] );
|
157 |
-
$post_type = sanitize_text_field( $_POST['post_type'] );
|
158 |
if ( isset( $_POST['wpcf_post_relationship'][$parent_id] ) ) {
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
$wpcf->relationship->save_children( $parent_id, $children );
|
163 |
$output = $wpcf->relationship->child_meta_form(
|
164 |
-
$parent_id, strval( $post_type )
|
165 |
);
|
166 |
}
|
167 |
}
|
@@ -184,7 +172,7 @@ function wpcf_ajax_embedded() {
|
|
184 |
case 'pr_save_child_post':
|
185 |
ob_start(); // Try to catch any errors
|
186 |
$output = '';
|
187 |
-
if (
|
188 |
&& isset( $_GET['parent_id'] )
|
189 |
&& isset( $_GET['post_type_parent'] )
|
190 |
&& isset( $_GET['post_type_child'] )
|
@@ -192,21 +180,20 @@ function wpcf_ajax_embedded() {
|
|
192 |
|
193 |
$parent_id = intval( $_GET['parent_id'] );
|
194 |
$child_id = intval( $_GET['post_id'] );
|
195 |
-
$parent_post_type =
|
196 |
-
$child_post_type =
|
197 |
-
|
198 |
if ( isset( $_POST['wpcf_post_relationship'][$parent_id][$child_id] ) ) {
|
199 |
-
$fields =
|
200 |
-
$wpcf->relationship->save_child( $parent_id, $child_id,
|
201 |
-
|
202 |
-
$output = $wpcf->relationship->child_row(
|
203 |
-
$parent_id,
|
204 |
$child_id,
|
205 |
-
$wpcf->relationship->settings( $parent_post_type,
|
206 |
-
|
207 |
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
|
208 |
-
|
209 |
-
|
|
|
210 |
}
|
211 |
}
|
212 |
}
|
@@ -228,7 +215,7 @@ function wpcf_ajax_embedded() {
|
|
228 |
case 'pr_delete_child_post':
|
229 |
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
230 |
$output = 'Passed wrong parameters';
|
231 |
-
if (
|
232 |
$output = wpcf_pr_admin_delete_child_item( intval( $_GET['post_id'] ) );
|
233 |
}
|
234 |
echo json_encode( array(
|
@@ -239,17 +226,10 @@ function wpcf_ajax_embedded() {
|
|
239 |
case 'pr-update-belongs':
|
240 |
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
241 |
$output = 'Passed wrong parameters';
|
242 |
-
if (
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
$parent_post_id = intval( $_POST['post_id'] );
|
247 |
-
$belongs_assignments = array();
|
248 |
-
foreach( $_POST['wpcf_pr_belongs'][$parent_post_id] as $post_type_raw => $post_id_raw ) {
|
249 |
-
$belongs_assignments[ sanitize_text_field( $post_type_raw) ] = intval( $post_id_raw );
|
250 |
-
}
|
251 |
-
|
252 |
-
$updated = wpcf_pr_admin_update_belongs( $parent_post_id, $belongs_assignments );
|
253 |
$output = is_wp_error( $updated ) ? $updated->get_error_message() : $updated;
|
254 |
}
|
255 |
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
|
@@ -269,10 +249,10 @@ function wpcf_ajax_embedded() {
|
|
269 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
270 |
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
271 |
$output = 'Passed wrong parameters';
|
272 |
-
if (
|
273 |
global $wpcf;
|
274 |
-
$parent = get_post(
|
275 |
-
$child_post_type =
|
276 |
|
277 |
if ( !empty( $parent->ID ) ) {
|
278 |
|
@@ -304,9 +284,9 @@ function wpcf_ajax_embedded() {
|
|
304 |
|
305 |
case 'pr_sort':
|
306 |
$output = 'Passed wrong parameters';
|
307 |
-
if (
|
308 |
$output = $wpcf->relationship->child_meta_form(
|
309 |
-
intval( $_GET['post_id'] ),
|
310 |
);
|
311 |
}
|
312 |
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
|
@@ -321,8 +301,7 @@ function wpcf_ajax_embedded() {
|
|
321 |
}
|
322 |
break;
|
323 |
|
324 |
-
|
325 |
-
/*case 'pr_sort_parent':
|
326 |
$output = 'Passed wrong parameters';
|
327 |
if ( isset( $_GET['field'] ) && isset( $_GET['sort'] ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
|
328 |
$output = $wpcf->relationship->child_meta_form(
|
@@ -339,23 +318,20 @@ function wpcf_ajax_embedded() {
|
|
339 |
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
|
340 |
) );
|
341 |
}
|
342 |
-
break
|
343 |
/* Usermeta */
|
344 |
case 'um_repetitive_add':
|
345 |
-
|
346 |
-
if ( isset( $_GET['user_id'] ) ) {
|
347 |
-
$user_id = $_GET['user_id'];
|
348 |
-
} else {
|
349 |
-
$user_id = wpcf_usermeta_get_user();
|
350 |
-
}
|
351 |
-
|
352 |
-
if ( isset( $_GET['field_id'] )
|
353 |
-
&& current_user_can( 'edit_user', $user_id ) ) {
|
2 |
|
3 |
/**
|
4 |
* All AJAX calls go here.
|
|
|
|
|
5 |
*/
|
6 |
function wpcf_ajax_embedded() {
|
7 |
|
11 |
}
|
12 |
} else {
|
13 |
|
14 |
+
if ( !isset( $_REQUEST['_wpnonce'] )
|
15 |
+
|| !wp_verify_nonce( $_REQUEST['_wpnonce'],
|
16 |
+
$_REQUEST['wpcf_action'] ) ) {
|
|
|
17 |
die( 'Verification failed' );
|
18 |
}
|
19 |
}
|
22 |
|
23 |
switch ( $_REQUEST['wpcf_action'] ) {
|
24 |
|
25 |
+
case 'editor_insert_date':
|
26 |
+
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/date.php';
|
27 |
+
wpcf_fields_date_editor_form();
|
28 |
+
break;
|
29 |
|
30 |
+
case 'insert_skype_button':
|
31 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/skype.php';
|
32 |
wpcf_fields_skype_meta_box_ajax();
|
33 |
break;
|
34 |
|
35 |
case 'editor_callback':
|
|
|
|
|
|
|
|
|
36 |
// Determine Field type and context
|
37 |
$views_usermeta = false;
|
|
|
|
|
|
|
38 |
if ( isset( $_GET['field_type'] ) && $_GET['field_type'] == 'usermeta' ) {
|
39 |
// Group filter
|
40 |
wp_enqueue_script( 'suggest' );
|
41 |
+
$field = types_get_field( $_GET['field_id'], 'usermeta' );
|
42 |
$meta_type = 'usermeta';
|
43 |
}
|
44 |
elseif ( isset( $_GET['field_type'] ) && $_GET['field_type'] == 'views-usermeta' ){
|
45 |
+
$field = types_get_field( $_GET['field_id'], 'usermeta' );
|
46 |
$meta_type = 'usermeta';
|
47 |
$views_usermeta = true;
|
48 |
}else {
|
49 |
+
$field = types_get_field( $_GET['field_id'] );
|
50 |
$meta_type = 'postmeta';
|
51 |
}
|
52 |
+
$post_id = isset( $_GET['post_id'] ) ? intval( $_GET['post_id'] ) : null;
|
|
|
53 |
$shortcode = isset( $_GET['shortcode'] ) ? urldecode( $_GET['shortcode'] ) : null;
|
54 |
+
$callback = isset( $_GET['callback'] ) ? $_GET['callback'] : false;
|
55 |
if ( !empty( $field ) ) {
|
56 |
// Editor
|
57 |
WPCF_Loader::loadClass( 'editor' );
|
58 |
$editor = new WPCF_Editor();
|
59 |
+
$editor->frame( $field, $meta_type, $post_id, $shortcode,
|
60 |
$callback, $views_usermeta );
|
61 |
}
|
62 |
break;
|
63 |
|
64 |
case 'dismiss_message':
|
|
|
|
|
|
|
|
|
65 |
if ( isset( $_GET['id'] ) ) {
|
66 |
$messages = get_option( 'wpcf_dismissed_messages', array() );
|
67 |
+
$messages[] = $_GET['id'];
|
68 |
update_option( 'wpcf_dismissed_messages', $messages );
|
69 |
}
|
70 |
break;
|
71 |
|
72 |
+
case '_dismiss_message':
|
73 |
+
if ( isset( $_GET['id'] ) ) {
|
74 |
+
$messages = get_option( '_wpcf_dismissed_messages', array() );
|
75 |
+
$messages[strval( $_GET['id'] )] = strval( $_GET['id'] );
|
76 |
+
update_option( '_wpcf_dismissed_messages', $messages );
|
77 |
+
}
|
78 |
+
break;
|
79 |
+
|
80 |
case 'pr_add_child_post':
|
81 |
$output = 'Passed wrong parameters';
|
82 |
+
if ( isset( $_GET['post_id'] )
|
83 |
+
&& isset( $_GET['post_type_child'] )
|
84 |
+
&& isset( $_GET['post_type_parent'] ) ) {
|
|
|
|
|
|
|
85 |
|
86 |
$relationships = get_option( 'wpcf_post_relationship', array() );
|
87 |
+
$post = get_post( intval( $_GET['post_id'] ) );
|
88 |
+
if ( !empty( $post->ID ) ) {
|
89 |
+
$post_type = strval( $_GET['post_type_child'] );
|
90 |
+
$parent_post_type = strval( $_GET['post_type_parent'] );
|
|
|
|
|
91 |
$data = $relationships[$parent_post_type][$post_type];
|
92 |
/*
|
93 |
* Since Types 1.1.5
|
95 |
* We save new post
|
96 |
* CHECKPOINT
|
97 |
*/
|
98 |
+
$id = $wpcf->relationship->add_new_child( $post->ID,
|
99 |
+
$post_type );
|
100 |
|
101 |
+
if ( !is_wp_error( $id ) ) {
|
|
|
|
|
102 |
/*
|
103 |
* Here we set Relationship
|
104 |
* CHECKPOINT
|
105 |
*/
|
106 |
+
$parent = get_post( intval( $_GET['post_id'] ) );
|
107 |
$child = get_post( $id );
|
108 |
if ( !empty( $parent->ID ) && !empty( $child->ID ) ) {
|
109 |
|
114 |
$wpcf->relationship->_set( $parent, $child, $data );
|
115 |
|
116 |
// Render new row
|
117 |
+
$output = $wpcf->relationship->child_row( $post->ID,
|
118 |
$id, $data );
|
119 |
} else {
|
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' );
|
142 |
|
143 |
case 'pr_save_all':
|
144 |
$output = '';
|
145 |
+
if ( isset( $_POST['post_id'] ) ) {
|
146 |
|
147 |
$parent_id = intval( $_POST['post_id'] );
|
|
|
148 |
if ( isset( $_POST['wpcf_post_relationship'][$parent_id] ) ) {
|
149 |
+
$wpcf->relationship->save_children( $parent_id,
|
150 |
+
(array) $_POST['wpcf_post_relationship'][$parent_id] );
|
|
|
|
|
151 |
$output = $wpcf->relationship->child_meta_form(
|
152 |
+
$parent_id, strval( $_POST['post_type'] )
|
153 |
);
|
154 |
}
|
155 |
}
|
172 |
case 'pr_save_child_post':
|
173 |
ob_start(); // Try to catch any errors
|
174 |
$output = '';
|
175 |
+
if ( isset( $_GET['post_id'] )
|
176 |
&& isset( $_GET['parent_id'] )
|
177 |
&& isset( $_GET['post_type_parent'] )
|
178 |
&& isset( $_GET['post_type_child'] )
|
180 |
|
181 |
$parent_id = intval( $_GET['parent_id'] );
|
182 |
$child_id = intval( $_GET['post_id'] );
|
183 |
+
$parent_post_type = strval( $_GET['post_type_parent'] );
|
184 |
+
$child_post_type = strval( $_GET['post_type_child'] );
|
|
|
185 |
if ( isset( $_POST['wpcf_post_relationship'][$parent_id][$child_id] ) ) {
|
186 |
+
$fields = (array) $_POST['wpcf_post_relationship'][$parent_id][$child_id];
|
187 |
+
$wpcf->relationship->save_child( $parent_id, $child_id,
|
188 |
+
$fields );
|
189 |
+
$output = $wpcf->relationship->child_row( $parent_id,
|
|
|
190 |
$child_id,
|
191 |
+
$wpcf->relationship->settings( $parent_post_type,
|
192 |
+
$child_post_type ) );
|
193 |
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
|
194 |
+
// TODO Move to conditional
|
195 |
+
$output .= '<script type="text/javascript">wpcfConditionalInit(\'#types-child-row-'
|
196 |
+
. $child_id . '\');</script>';
|
197 |
}
|
198 |
}
|
199 |
}
|
215 |
case 'pr_delete_child_post':
|
216 |
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
217 |
$output = 'Passed wrong parameters';
|
218 |
+
if ( isset( $_GET['post_id'] ) ) {
|
219 |
$output = wpcf_pr_admin_delete_child_item( intval( $_GET['post_id'] ) );
|
220 |
}
|
221 |
echo json_encode( array(
|
226 |
case 'pr-update-belongs':
|
227 |
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
228 |
$output = 'Passed wrong parameters';
|
229 |
+
if ( isset( $_POST['post_id'] ) && isset( $_POST['wpcf_pr_belongs'][$_POST['post_id']] ) ) {
|
230 |
+
$post_id = intval( $_POST['post_id'] );
|
231 |
+
$updated = wpcf_pr_admin_update_belongs( $post_id,
|
232 |
+
$_POST['wpcf_pr_belongs'][$post_id] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
$output = is_wp_error( $updated ) ? $updated->get_error_message() : $updated;
|
234 |
}
|
235 |
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
|
249 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
|
250 |
require_once WPCF_EMBEDDED_ABSPATH . '/includes/post-relationship.php';
|
251 |
$output = 'Passed wrong parameters';
|
252 |
+
if ( isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
|
253 |
global $wpcf;
|
254 |
+
$parent = get_post( esc_attr( $_GET['post_id'] ) );
|
255 |
+
$child_post_type = esc_attr( $_GET['post_type'] );
|
256 |
|
257 |
if ( !empty( $parent->ID ) ) {
|
258 |
|
284 |
|
285 |
case 'pr_sort':
|
286 |
$output = 'Passed wrong parameters';
|
287 |
+
if ( isset( $_GET['field'] ) && isset( $_GET['sort'] ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
|
288 |
$output = $wpcf->relationship->child_meta_form(
|
289 |
+
intval( $_GET['post_id'] ), strval( $_GET['post_type'] )
|
290 |
);
|
291 |
}
|
292 |
if ( !defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
|
301 |
}
|
302 |
break;
|
303 |
|
304 |
+
case 'pr_sort_parent':
|
|
|
305 |
$output = 'Passed wrong parameters';
|
306 |
if ( isset( $_GET['field'] ) && isset( $_GET['sort'] ) && isset( $_GET['post_id'] ) && isset( $_GET['post_type'] ) ) {
|
307 |
$output = $wpcf->relationship->child_meta_form(
|
318 |
'conditionals' => array('#post' => wptoolset_form_get_conditional_data( 'post' )),
|
319 |
) );
|
320 |
}
|
321 |
+
break;
|
322 |
/* Usermeta */
|
323 |
case 'um_repetitive_add':
|
324 |
+
if ( isset( $_GET['field_id'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|