Version Description
- Fixed a JavaScript error when using a flat taxonomy in the relationship post table.
- Fixed an issue where no value was stored for checkboxes when option to save 0 was selected.
- Fixed a validation issue for file, audio, video and embed fields affecting Types. Allowing URLs with non-latin characters, but only for URLs that point to attachments from the Media Library (validated by WordPress media upload mechanism).
- Removed the "Types Migration" page which was broken and not maintained.
- Fixed an incompatibility issue with Divi caused by double enqueuing of the jQuery UI Validation plugin.
- When inserting the types shortcode for an image field, we will always use placeholders for the title and alt text.
- Fixed an issue in the relationship post table where it wasn't possible to repeatedly set and remove a child post's featured image.
- Improved how the Types meta fields are registered in the Fields and Views dialog.
Download this release
Release Info
Developer | zaantar |
Plugin | Toolset Types – Custom Post Types, Custom Fields and Taxonomies |
Version | 2.2.7 |
Comparing to | |
See all releases |
Code changes from version 2.2.6 to 2.2.7
- application/controllers/asset/manager.php +54 -3
- application/controllers/interop/handler/divi.php +92 -0
- application/controllers/interop/handler/wpml.php +15 -0
- application/controllers/interop/handler_interface.php +14 -0
- application/controllers/interop/mediator.php +111 -0
- application/controllers/main.php +2 -0
- application/controllers/utils.php +1 -0
- library/toolset/onthego-resources/onthegosystems-icons/.fontcustom-manifest.json +10 -6
- library/toolset/onthego-resources/onthegosystems-icons/css/_onthegosystems-icons.scss +9 -6
- library/toolset/onthego-resources/onthegosystems-icons/css/onthegosystems-icons.css +8 -6
- library/toolset/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons-preview.html +22 -7
- library/toolset/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons_91cc76c6ec19609541b007a2169151af.woff +0 -0
- library/toolset/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_91cc76c6ec19609541b007a2169151af.eot → onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.eot} +0 -0
- library/toolset/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_91cc76c6ec19609541b007a2169151af.svg → onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.svg} +13 -10
- library/toolset/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_91cc76c6ec19609541b007a2169151af.ttf → onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.ttf} +0 -0
- library/toolset/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.woff +0 -0
- library/toolset/onthego-resources/onthegosystems-icons/vectors/toolset-export.svg +45 -0
- library/toolset/toolset-common/changelog.md +10 -1
- library/toolset/toolset-common/loader.php +1 -1
- library/toolset/toolset-common/toolset-common-loader.php +2 -2
- library/toolset/toolset-common/toolset-forms/classes/class.validation.php +32 -14
- library/toolset/toolset-common/toolset-forms/lib/CakePHP-Validation.php +49 -6
- library/toolset/toolset-common/utility/utils.php +51 -1
- library/toolset/types/admin.php +33 -75
- library/toolset/types/embedded/bootstrap.php +8 -26
- library/toolset/types/embedded/classes/field.php +32 -38
- library/toolset/types/embedded/classes/wpviews.php +398 -112
- library/toolset/types/embedded/functions.php +29 -30
- library/toolset/types/embedded/includes/fields-post.php +20 -47
- library/toolset/types/embedded/includes/fields.php +62 -17
- library/toolset/types/embedded/includes/fields/checkbox.php +93 -49
- library/toolset/types/embedded/includes/fields/checkboxes.php +10 -1
- library/toolset/types/embedded/includes/fields/image.php +14 -27
- library/toolset/types/embedded/includes/post-relationship.php +13 -12
- library/toolset/types/embedded/includes/usermeta-add-user.php +3 -4
- library/toolset/types/embedded/includes/usermeta-post.php +73 -245
- library/toolset/types/embedded/resources/js/post-relationship.js +252 -189
- library/toolset/types/embedded/usermeta-init.php +84 -90
- library/toolset/types/embedded/views/templates/editor-modal-image.tpl.php +18 -15
- library/toolset/types/includes/migration.php +0 -599
- readme.txt +13 -1
- wpcf.php +3 -3
application/controllers/asset/manager.php
CHANGED
@@ -9,6 +9,10 @@
|
|
9 |
*/
|
10 |
final class Types_Asset_Manager extends Toolset_Assets_Manager {
|
11 |
|
|
|
|
|
|
|
|
|
12 |
const SCRIPT_KNOCKOUT = 'knockout';
|
13 |
|
14 |
const SCRIPT_ADJUST_MENU_LINK = 'types-adjust-menu-link';
|
@@ -17,12 +21,15 @@ final class Types_Asset_Manager extends Toolset_Assets_Manager {
|
|
17 |
const SCRIPT_PAGE_EDIT_POST_TYPE = 'types-page-edit-post-type';
|
18 |
const SCRIPT_PAGE_EDIT_TAXONOMY = 'types-page-edit-taxonomy';
|
19 |
|
|
|
|
|
|
|
|
|
|
|
20 |
// Registered in Toolset common
|
21 |
|
22 |
const SCRIPT_DIALOG_BOXES = 'ddl-dialog-boxes';
|
23 |
-
|
24 |
const SCRIPT_UTILS = 'toolset-utils';
|
25 |
-
|
26 |
const SCRIPT_HEADJS = 'headjs';
|
27 |
|
28 |
// WordPress Core handles
|
@@ -47,7 +54,7 @@ final class Types_Asset_Manager extends Toolset_Assets_Manager {
|
|
47 |
|
48 |
$this->register_script(
|
49 |
self::SCRIPT_KNOCKOUT,
|
50 |
-
TYPES_RELPATH . '/library/knockout/knockout-3.4.0.debug.js',
|
51 |
array(),
|
52 |
'3.4.0'
|
53 |
);
|
@@ -80,11 +87,55 @@ final class Types_Asset_Manager extends Toolset_Assets_Manager {
|
|
80 |
TYPES_VERSION
|
81 |
);
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
return parent::__initialize_scripts();
|
85 |
}
|
86 |
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
/**
|
89 |
* @param Toolset_Script $script
|
90 |
*/
|
9 |
*/
|
10 |
final class Types_Asset_Manager extends Toolset_Assets_Manager {
|
11 |
|
12 |
+
// Script handles
|
13 |
+
//
|
14 |
+
// NEVER EVER use handles defined here as hardcoded strings, they may change at any time.
|
15 |
+
|
16 |
const SCRIPT_KNOCKOUT = 'knockout';
|
17 |
|
18 |
const SCRIPT_ADJUST_MENU_LINK = 'types-adjust-menu-link';
|
21 |
const SCRIPT_PAGE_EDIT_POST_TYPE = 'types-page-edit-post-type';
|
22 |
const SCRIPT_PAGE_EDIT_TAXONOMY = 'types-page-edit-taxonomy';
|
23 |
|
24 |
+
// Registered in legacy Types
|
25 |
+
|
26 |
+
const SCRIPT_JQUERY_UI_VALIDATION = 'wpcf-form-validation';
|
27 |
+
const SCRIPT_ADDITIONAL_VALIDATION_RULES = 'wpcf-form-validation-additional';
|
28 |
+
|
29 |
// Registered in Toolset common
|
30 |
|
31 |
const SCRIPT_DIALOG_BOXES = 'ddl-dialog-boxes';
|
|
|
32 |
const SCRIPT_UTILS = 'toolset-utils';
|
|
|
33 |
const SCRIPT_HEADJS = 'headjs';
|
34 |
|
35 |
// WordPress Core handles
|
54 |
|
55 |
$this->register_script(
|
56 |
self::SCRIPT_KNOCKOUT,
|
57 |
+
TYPES_RELPATH . '/library/knockout/' . $this->choose_script_version( 'knockout-3.4.0.js', 'knockout-3.4.0.debug.js' ),
|
58 |
array(),
|
59 |
'3.4.0'
|
60 |
);
|
87 |
TYPES_VERSION
|
88 |
);
|
89 |
|
90 |
+
$this->register_script(
|
91 |
+
self::SCRIPT_JQUERY_UI_VALIDATION,
|
92 |
+
WPCF_RES_RELPATH . '/js/jquery-form-validation/' . $this->choose_script_version( 'jquery.validate.min.js', 'jquery.validate.js'),
|
93 |
+
array( 'jquery' ),
|
94 |
+
'1.8.1'
|
95 |
+
);
|
96 |
+
|
97 |
+
|
98 |
+
$this->register_script(
|
99 |
+
self::SCRIPT_ADDITIONAL_VALIDATION_RULES,
|
100 |
+
$this->get_additional_validation_script_url(),
|
101 |
+
array( 'jquery', self::SCRIPT_JQUERY_UI_VALIDATION ),
|
102 |
+
TYPES_VERSION
|
103 |
+
);
|
104 |
+
|
105 |
|
106 |
return parent::__initialize_scripts();
|
107 |
}
|
108 |
|
109 |
|
110 |
+
/**
|
111 |
+
* Unfortunately, we need to have this public because of the Divi.
|
112 |
+
* And, unfortunately, we can't define it as a constant because PHP < 5.6 doesn't support that.
|
113 |
+
*
|
114 |
+
* @since 2.2.7
|
115 |
+
*/
|
116 |
+
public function get_additional_validation_script_url() {
|
117 |
+
return WPCF_RES_RELPATH . '/js/jquery-form-validation/additional-methods.min.js';
|
118 |
+
}
|
119 |
+
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Choose a production (usually minified) or debugging (non-minified) version of
|
123 |
+
* a script depending on the script debugging mode.
|
124 |
+
*
|
125 |
+
* See SCRIPT_DEBUG constant
|
126 |
+
*
|
127 |
+
* @param string $production_version File name of the production script version.
|
128 |
+
* @param string $debugging_version File name of the debugging script version.
|
129 |
+
*
|
130 |
+
* @return string
|
131 |
+
* @since 2.2.7
|
132 |
+
*/
|
133 |
+
private function choose_script_version( $production_version, $debugging_version ) {
|
134 |
+
$is_debug_mode = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG );
|
135 |
+
return ( $is_debug_mode ? $debugging_version : $production_version );
|
136 |
+
}
|
137 |
+
|
138 |
+
|
139 |
/**
|
140 |
* @param Toolset_Script $script
|
141 |
*/
|
application/controllers/interop/handler/divi.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Divi interoperability handler.
|
5 |
+
*
|
6 |
+
* @since 2.2.7
|
7 |
+
*/
|
8 |
+
class Types_Interop_Handler_Divi implements Types_Interop_Handler_Interface {
|
9 |
+
|
10 |
+
|
11 |
+
private static $instance;
|
12 |
+
|
13 |
+
public static function initialize() {
|
14 |
+
|
15 |
+
if ( null === self::$instance ) {
|
16 |
+
self::$instance = new self();
|
17 |
+
}
|
18 |
+
|
19 |
+
// Not giving away the instance on purpose.
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
private function __clone() {
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
private function __construct() {
|
29 |
+
|
30 |
+
// admin_enqueue_scripts is too late and init is too early ($typenow is not populated at that time).
|
31 |
+
// Actually, we need to load with even earlier priority because Types already enqueues things
|
32 |
+
// at load-post.php.
|
33 |
+
add_action( 'load-post.php', array( $this, 'fix_validation_method_extension_dependency' ), 8 );
|
34 |
+
add_action( 'load-post-new.php', array( $this, 'fix_validation_method_extension_dependency' ), 8 );
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Fix a compatibility issue that happens on the Edit Post page.
|
41 |
+
*
|
42 |
+
* Implemented for Divi 3.0.29.
|
43 |
+
*
|
44 |
+
* Types is extending the jQuery UI Validation plugin with some additional validation rules,
|
45 |
+
* some of which are used for custom field validation.
|
46 |
+
*
|
47 |
+
* The actual problem is that Divi is including the jQuery UI Validation plugin with a different
|
48 |
+
* script handler, 'validation', which was overwriting the instance enqueued by Types, and thus
|
49 |
+
* removing the additional validation rules.
|
50 |
+
*
|
51 |
+
* By registering the script with additional validation rules with a dependency on the Divi's
|
52 |
+
* jQuery UI Validation plugin instance, we avoid this issue.
|
53 |
+
*
|
54 |
+
* A more straightforward solution might be changing the script handler to 'validation'
|
55 |
+
* but that is a way too generic name and might cause issues elsewhere.
|
56 |
+
*
|
57 |
+
* Here, we're copying the logic of Divi's et_pb_admin_scripts_styles() and
|
58 |
+
* re-register the script only if Divi is about to enqueue its jQuery UI Validation plugin.
|
59 |
+
*
|
60 |
+
* @since 2.2.7
|
61 |
+
*/
|
62 |
+
public function fix_validation_method_extension_dependency() {
|
63 |
+
|
64 |
+
if ( ! function_exists( 'et_builder_get_builder_post_types' ) ) {
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
|
68 |
+
$post_types = et_builder_get_builder_post_types();
|
69 |
+
|
70 |
+
global $typenow;
|
71 |
+
|
72 |
+
if ( ! isset( $typenow ) || ! in_array( $typenow, $post_types ) ) {
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
|
76 |
+
// Now we know that Divi is about to enqueue its jQuery UI Validation plugin.
|
77 |
+
|
78 |
+
wp_deregister_script( Types_Asset_Manager::SCRIPT_ADDITIONAL_VALIDATION_RULES );
|
79 |
+
|
80 |
+
$asset_manager = Types_Asset_Manager::get_instance();
|
81 |
+
|
82 |
+
wp_register_script(
|
83 |
+
Types_Asset_Manager::SCRIPT_ADDITIONAL_VALIDATION_RULES,
|
84 |
+
$asset_manager->get_additional_validation_script_url(),
|
85 |
+
// add another dependency
|
86 |
+
array( 'jquery', 'validation', Types_Asset_Manager::SCRIPT_JQUERY_UI_VALIDATION ),
|
87 |
+
TYPES_VERSION
|
88 |
+
);
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
application/controllers/interop/handler/wpml.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* WPML interoperability handler.
|
5 |
+
*
|
6 |
+
* WIP - this stub is to be filled with everything WPML-related.
|
7 |
+
* Look into: library/toolset/types/embedded/includes/wpml.php
|
8 |
+
*/
|
9 |
+
class Types_Interop_Handler_Wpml implements Types_Interop_Handler_Interface {
|
10 |
+
|
11 |
+
public static function initialize() {
|
12 |
+
|
13 |
+
}
|
14 |
+
|
15 |
+
}
|
application/controllers/interop/handler_interface.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Interface Types_Interop_Handler_Interface
|
5 |
+
*
|
6 |
+
* See Types_Interop_Mediator for details.
|
7 |
+
*
|
8 |
+
* @since 2.2.7
|
9 |
+
*/
|
10 |
+
interface Types_Interop_Handler_Interface {
|
11 |
+
|
12 |
+
public static function initialize();
|
13 |
+
|
14 |
+
}
|
application/controllers/interop/mediator.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Provide interoperability with other plugins or themes when needed.
|
5 |
+
*
|
6 |
+
* Each plugin or a theme that Types needs to (actively) support should
|
7 |
+
* have a dedicated "interoperability handler" that, when initialized,
|
8 |
+
* will provide such support (preferably via actions and filters).
|
9 |
+
*
|
10 |
+
* Having everything located in one class will make it very easy to
|
11 |
+
* handle and implement future compatibility issues and it will
|
12 |
+
* reduce memory usage by loading the code only when needed.
|
13 |
+
*
|
14 |
+
* @since 2.2.7
|
15 |
+
*/
|
16 |
+
class Types_Interop_Mediator {
|
17 |
+
|
18 |
+
private static $instance;
|
19 |
+
|
20 |
+
public static function initialize() {
|
21 |
+
if( null === self::$instance ) {
|
22 |
+
self::$instance = new self();
|
23 |
+
}
|
24 |
+
|
25 |
+
// Not giving away the instance on purpose
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
private function __clone() { }
|
30 |
+
|
31 |
+
private function __construct() {
|
32 |
+
$this->initialize_interop_handlers();
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get definitions of all interop handlers.
|
38 |
+
*
|
39 |
+
* Each one has a method for checking whether the handler is needed
|
40 |
+
* and a name - there must be a corresponding class Types_Interop_Handler_{$name}
|
41 |
+
* implementing the Types_Interop_Handler_Interface.
|
42 |
+
*
|
43 |
+
* @return array
|
44 |
+
* @since 2.2.7
|
45 |
+
*/
|
46 |
+
private function get_interop_handler_definitions() {
|
47 |
+
|
48 |
+
$interop_handlers = array(
|
49 |
+
array(
|
50 |
+
'is_needed' => array( $this, 'is_wpml_active' ),
|
51 |
+
'class_name' => 'Wpml'
|
52 |
+
),
|
53 |
+
array(
|
54 |
+
'is_needed' => array( $this, 'is_divi_active'),
|
55 |
+
'class_name' => 'Divi'
|
56 |
+
)
|
57 |
+
);
|
58 |
+
|
59 |
+
return $interop_handlers;
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Load and initialize interop handlers if the relevant plugin/theme is active.
|
65 |
+
*
|
66 |
+
* @since 2.2.7
|
67 |
+
*/
|
68 |
+
private function initialize_interop_handlers() {
|
69 |
+
|
70 |
+
$interop_handlers = $this->get_interop_handler_definitions();
|
71 |
+
foreach( $interop_handlers as $handler_definition ) {
|
72 |
+
$is_needed = call_user_func( $handler_definition['is_needed'] );
|
73 |
+
|
74 |
+
if( $is_needed ) {
|
75 |
+
$handler_class_name = 'Types_Interop_Handler_' . $handler_definition['class_name'];
|
76 |
+
call_user_func( $handler_class_name . '::initialize' );
|
77 |
+
}
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Check whether WPML is active and configured.
|
84 |
+
*
|
85 |
+
* @return bool
|
86 |
+
* @since 2.2.7
|
87 |
+
*/
|
88 |
+
protected function is_wpml_active() {
|
89 |
+
|
90 |
+
global $sitepress;
|
91 |
+
$is_wpml_active = (
|
92 |
+
defined( 'ICL_SITEPRESS_VERSION' )
|
93 |
+
&& ! ICL_PLUGIN_INACTIVE
|
94 |
+
&& ! is_null( $sitepress )
|
95 |
+
&& class_exists( 'SitePress' )
|
96 |
+
);
|
97 |
+
|
98 |
+
return $is_wpml_active;
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Check whether the Divi theme is loaded.
|
104 |
+
*
|
105 |
+
* @return bool
|
106 |
+
*/
|
107 |
+
protected function is_divi_active() {
|
108 |
+
return function_exists( 'et_setup_theme' );
|
109 |
+
}
|
110 |
+
|
111 |
+
}
|
application/controllers/main.php
CHANGED
@@ -130,6 +130,8 @@ final class Types_Main {
|
|
130 |
}
|
131 |
|
132 |
Types_Api::initialize();
|
|
|
|
|
133 |
}
|
134 |
|
135 |
|
130 |
}
|
131 |
|
132 |
Types_Api::initialize();
|
133 |
+
|
134 |
+
Types_Interop_Mediator::initialize();
|
135 |
}
|
136 |
|
137 |
|
application/controllers/utils.php
CHANGED
@@ -183,6 +183,7 @@ final class Types_Utils {
|
|
183 |
* @param string $url URL of the file.
|
184 |
* @return int|null Attachment ID if it exists.
|
185 |
* @since 1.9.1
|
|
|
186 |
*/
|
187 |
public static function get_attachment_id_by_url( $url ) {
|
188 |
|
183 |
* @param string $url URL of the file.
|
184 |
* @return int|null Attachment ID if it exists.
|
185 |
* @since 1.9.1
|
186 |
+
* @deprecated Since 2.2.7. Use Toolset_Utils::get_attachment_id_by_url() instead. To be removed in 2.3 or later.
|
187 |
*/
|
188 |
public static function get_attachment_id_by_url( $url ) {
|
189 |
|
library/toolset/onthego-resources/onthegosystems-icons/.fontcustom-manifest.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
{
|
2 |
"checksum": {
|
3 |
-
"previous": "
|
4 |
-
"current": "
|
5 |
},
|
6 |
"fonts": [
|
7 |
-
"fonts/onthegosystems-
|
8 |
-
"fonts/onthegosystems-
|
9 |
-
"fonts/onthegosystems-
|
10 |
-
"fonts/onthegosystems-
|
11 |
],
|
12 |
"glyphs": {
|
13 |
"access": {
|
@@ -118,6 +118,10 @@
|
|
118 |
"codepoint": 61738,
|
119 |
"source": "vectors/toolset.svg"
|
120 |
},
|
|
|
|
|
|
|
|
|
121 |
"toolset-genesis-logo": {
|
122 |
"codepoint": 61736,
|
123 |
"source": "vectors/toolset-genesis-logo.svg"
|
1 |
{
|
2 |
"checksum": {
|
3 |
+
"previous": "c2bf5434fb5ba6db313a98fb4e1bf3479154a52d11ff65763e7707dfe4069a7b",
|
4 |
+
"current": "c2bf5434fb5ba6db313a98fb4e1bf3479154a52d11ff65763e7707dfe4069a7b"
|
5 |
},
|
6 |
"fonts": [
|
7 |
+
"fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.ttf",
|
8 |
+
"fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.svg",
|
9 |
+
"fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.woff",
|
10 |
+
"fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.eot"
|
11 |
],
|
12 |
"glyphs": {
|
13 |
"access": {
|
118 |
"codepoint": 61738,
|
119 |
"source": "vectors/toolset.svg"
|
120 |
},
|
121 |
+
"toolset-export": {
|
122 |
+
"codepoint": 61751,
|
123 |
+
"source": "vectors/toolset-export.svg"
|
124 |
+
},
|
125 |
"toolset-genesis-logo": {
|
126 |
"codepoint": 61736,
|
127 |
"source": "vectors/toolset-genesis-logo.svg"
|
library/toolset/onthego-resources/onthegosystems-icons/css/_onthegosystems-icons.scss
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
|
5 |
@font-face {
|
6 |
font-family: "onthegosystems-icons";
|
7 |
-
src: url("../fonts/onthegosystems-
|
8 |
-
src: url("../fonts/onthegosystems-
|
9 |
-
url("../fonts/onthegosystems-
|
10 |
-
url("../fonts/onthegosystems-
|
11 |
-
url("../fonts/onthegosystems-
|
12 |
font-weight: normal;
|
13 |
font-style: normal;
|
14 |
}
|
@@ -16,7 +16,7 @@
|
|
16 |
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
17 |
@font-face {
|
18 |
font-family: "onthegosystems-icons";
|
19 |
-
src: url("../fonts/onthegosystems-
|
20 |
}
|
21 |
}
|
22 |
|
@@ -50,6 +50,7 @@
|
|
50 |
.icon-packager-logo:before,
|
51 |
.icon-panels:before,
|
52 |
.icon-toolset:before,
|
|
|
53 |
.icon-toolset-genesis-logo:before,
|
54 |
.icon-toolset-logo:before,
|
55 |
.icon-toolset-map:before,
|
@@ -101,6 +102,7 @@
|
|
101 |
.icon-packager-logo:before { content: "\f121"; }
|
102 |
.icon-panels:before { content: "\f133"; }
|
103 |
.icon-toolset:before { content: "\f12a"; }
|
|
|
104 |
.icon-toolset-genesis-logo:before { content: "\f128"; }
|
105 |
.icon-toolset-logo:before { content: "\f11a"; }
|
106 |
.icon-toolset-map:before { content: "\f125"; }
|
@@ -139,6 +141,7 @@ $font-onthegosystems-icons-packager: "\f120";
|
|
139 |
$font-onthegosystems-icons-packager-logo: "\f121";
|
140 |
$font-onthegosystems-icons-panels: "\f133";
|
141 |
$font-onthegosystems-icons-toolset: "\f12a";
|
|
|
142 |
$font-onthegosystems-icons-toolset-genesis-logo: "\f128";
|
143 |
$font-onthegosystems-icons-toolset-logo: "\f11a";
|
144 |
$font-onthegosystems-icons-toolset-map: "\f125";
|
4 |
|
5 |
@font-face {
|
6 |
font-family: "onthegosystems-icons";
|
7 |
+
src: url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.eot");
|
8 |
+
src: url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.eot?#iefix") format("embedded-opentype"),
|
9 |
+
url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.woff") format("woff"),
|
10 |
+
url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.ttf") format("truetype"),
|
11 |
+
url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.svg#onthegosystems-icons") format("svg");
|
12 |
font-weight: normal;
|
13 |
font-style: normal;
|
14 |
}
|
16 |
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
17 |
@font-face {
|
18 |
font-family: "onthegosystems-icons";
|
19 |
+
src: url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.svg#onthegosystems-icons") format("svg");
|
20 |
}
|
21 |
}
|
22 |
|
50 |
.icon-packager-logo:before,
|
51 |
.icon-panels:before,
|
52 |
.icon-toolset:before,
|
53 |
+
.icon-toolset-export:before,
|
54 |
.icon-toolset-genesis-logo:before,
|
55 |
.icon-toolset-logo:before,
|
56 |
.icon-toolset-map:before,
|
102 |
.icon-packager-logo:before { content: "\f121"; }
|
103 |
.icon-panels:before { content: "\f133"; }
|
104 |
.icon-toolset:before { content: "\f12a"; }
|
105 |
+
.icon-toolset-export:before { content: "\f137"; }
|
106 |
.icon-toolset-genesis-logo:before { content: "\f128"; }
|
107 |
.icon-toolset-logo:before { content: "\f11a"; }
|
108 |
.icon-toolset-map:before { content: "\f125"; }
|
141 |
$font-onthegosystems-icons-packager-logo: "\f121";
|
142 |
$font-onthegosystems-icons-panels: "\f133";
|
143 |
$font-onthegosystems-icons-toolset: "\f12a";
|
144 |
+
$font-onthegosystems-icons-toolset-export: "\f137";
|
145 |
$font-onthegosystems-icons-toolset-genesis-logo: "\f128";
|
146 |
$font-onthegosystems-icons-toolset-logo: "\f11a";
|
147 |
$font-onthegosystems-icons-toolset-map: "\f125";
|
library/toolset/onthego-resources/onthegosystems-icons/css/onthegosystems-icons.css
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
|
5 |
@font-face {
|
6 |
font-family: "onthegosystems-icons";
|
7 |
-
src: url("../fonts/onthegosystems-
|
8 |
-
src: url("../fonts/onthegosystems-
|
9 |
-
url("../fonts/onthegosystems-
|
10 |
-
url("../fonts/onthegosystems-
|
11 |
-
url("../fonts/onthegosystems-
|
12 |
font-weight: normal;
|
13 |
font-style: normal;
|
14 |
}
|
@@ -16,7 +16,7 @@
|
|
16 |
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
17 |
@font-face {
|
18 |
font-family: "onthegosystems-icons";
|
19 |
-
src: url("../fonts/onthegosystems-
|
20 |
}
|
21 |
}
|
22 |
|
@@ -50,6 +50,7 @@
|
|
50 |
.icon-packager-logo:before,
|
51 |
.icon-panels:before,
|
52 |
.icon-toolset:before,
|
|
|
53 |
.icon-toolset-genesis-logo:before,
|
54 |
.icon-toolset-logo:before,
|
55 |
.icon-toolset-map:before,
|
@@ -101,6 +102,7 @@
|
|
101 |
.icon-packager-logo:before { content: "\f121"; }
|
102 |
.icon-panels:before { content: "\f133"; }
|
103 |
.icon-toolset:before { content: "\f12a"; }
|
|
|
104 |
.icon-toolset-genesis-logo:before { content: "\f128"; }
|
105 |
.icon-toolset-logo:before { content: "\f11a"; }
|
106 |
.icon-toolset-map:before { content: "\f125"; }
|
4 |
|
5 |
@font-face {
|
6 |
font-family: "onthegosystems-icons";
|
7 |
+
src: url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.eot");
|
8 |
+
src: url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.eot?#iefix") format("embedded-opentype"),
|
9 |
+
url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.woff") format("woff"),
|
10 |
+
url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.ttf") format("truetype"),
|
11 |
+
url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.svg#onthegosystems-icons") format("svg");
|
12 |
font-weight: normal;
|
13 |
font-style: normal;
|
14 |
}
|
16 |
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
17 |
@font-face {
|
18 |
font-family: "onthegosystems-icons";
|
19 |
+
src: url("../fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.svg#onthegosystems-icons") format("svg");
|
20 |
}
|
21 |
}
|
22 |
|
50 |
.icon-packager-logo:before,
|
51 |
.icon-panels:before,
|
52 |
.icon-toolset:before,
|
53 |
+
.icon-toolset-export:before,
|
54 |
.icon-toolset-genesis-logo:before,
|
55 |
.icon-toolset-logo:before,
|
56 |
.icon-toolset-map:before,
|
102 |
.icon-packager-logo:before { content: "\f121"; }
|
103 |
.icon-panels:before { content: "\f133"; }
|
104 |
.icon-toolset:before { content: "\f12a"; }
|
105 |
+
.icon-toolset-export:before { content: "\f137"; }
|
106 |
.icon-toolset-genesis-logo:before { content: "\f128"; }
|
107 |
.icon-toolset-logo:before { content: "\f11a"; }
|
108 |
.icon-toolset-map:before { content: "\f125"; }
|
library/toolset/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons-preview.html
CHANGED
@@ -141,11 +141,11 @@
|
|
141 |
|
142 |
@font-face {
|
143 |
font-family: "onthegosystems-icons";
|
144 |
-
src: url("./onthegosystems-
|
145 |
-
src: url("./onthegosystems-
|
146 |
-
url("./onthegosystems-
|
147 |
-
url("./onthegosystems-
|
148 |
-
url("./onthegosystems-
|
149 |
font-weight: normal;
|
150 |
font-style: normal;
|
151 |
}
|
@@ -153,7 +153,7 @@
|
|
153 |
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
154 |
@font-face {
|
155 |
font-family: "onthegosystems-icons";
|
156 |
-
src: url("./onthegosystems-
|
157 |
}
|
158 |
}
|
159 |
|
@@ -187,6 +187,7 @@
|
|
187 |
.icon-packager-logo:before,
|
188 |
.icon-panels:before,
|
189 |
.icon-toolset:before,
|
|
|
190 |
.icon-toolset-genesis-logo:before,
|
191 |
.icon-toolset-logo:before,
|
192 |
.icon-toolset-map:before,
|
@@ -238,6 +239,7 @@
|
|
238 |
.icon-packager-logo:before { content: "\f121"; }
|
239 |
.icon-panels:before { content: "\f133"; }
|
240 |
.icon-toolset:before { content: "\f12a"; }
|
|
|
241 |
.icon-toolset-genesis-logo:before { content: "\f128"; }
|
242 |
.icon-toolset-logo:before { content: "\f11a"; }
|
243 |
.icon-toolset-map:before { content: "\f125"; }
|
@@ -263,7 +265,7 @@
|
|
263 |
<body class="characters-off">
|
264 |
<div id="page" class="container">
|
265 |
<header>
|
266 |
-
<h1>onthegosystems-icons contains
|
267 |
<a onclick="toggleCharacters(); return false;" href="#">Toggle Preview Characters</a>
|
268 |
</header>
|
269 |
|
@@ -619,6 +621,19 @@
|
|
619 |
</div>
|
620 |
</div>
|
621 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
<div class="glyph">
|
623 |
<div class="preview-glyphs">
|
624 |
<span class="step size-12"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-14"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-16"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-18"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-21"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-24"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-36"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-48"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-60"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-72"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span>
|
141 |
|
142 |
@font-face {
|
143 |
font-family: "onthegosystems-icons";
|
144 |
+
src: url("./onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.eot");
|
145 |
+
src: url("./onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.eot?#iefix") format("embedded-opentype"),
|
146 |
+
url("./onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.woff") format("woff"),
|
147 |
+
url("./onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.ttf") format("truetype"),
|
148 |
+
url("./onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.svg#onthegosystems-icons") format("svg");
|
149 |
font-weight: normal;
|
150 |
font-style: normal;
|
151 |
}
|
153 |
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
154 |
@font-face {
|
155 |
font-family: "onthegosystems-icons";
|
156 |
+
src: url("./onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.svg#onthegosystems-icons") format("svg");
|
157 |
}
|
158 |
}
|
159 |
|
187 |
.icon-packager-logo:before,
|
188 |
.icon-panels:before,
|
189 |
.icon-toolset:before,
|
190 |
+
.icon-toolset-export:before,
|
191 |
.icon-toolset-genesis-logo:before,
|
192 |
.icon-toolset-logo:before,
|
193 |
.icon-toolset-map:before,
|
239 |
.icon-packager-logo:before { content: "\f121"; }
|
240 |
.icon-panels:before { content: "\f133"; }
|
241 |
.icon-toolset:before { content: "\f12a"; }
|
242 |
+
.icon-toolset-export:before { content: "\f137"; }
|
243 |
.icon-toolset-genesis-logo:before { content: "\f128"; }
|
244 |
.icon-toolset-logo:before { content: "\f11a"; }
|
245 |
.icon-toolset-map:before { content: "\f125"; }
|
265 |
<body class="characters-off">
|
266 |
<div id="page" class="container">
|
267 |
<header>
|
268 |
+
<h1>onthegosystems-icons contains 38 glyphs:</h1>
|
269 |
<a onclick="toggleCharacters(); return false;" href="#">Toggle Preview Characters</a>
|
270 |
</header>
|
271 |
|
621 |
</div>
|
622 |
</div>
|
623 |
|
624 |
+
<div class="glyph">
|
625 |
+
<div class="preview-glyphs">
|
626 |
+
<span class="step size-12"><span class="letters">Pp</span><i id="icon-toolset-export" class="icon-toolset-export"></i></span><span class="step size-14"><span class="letters">Pp</span><i id="icon-toolset-export" class="icon-toolset-export"></i></span><span class="step size-16"><span class="letters">Pp</span><i id="icon-toolset-export" class="icon-toolset-export"></i></span><span class="step size-18"><span class="letters">Pp</span><i id="icon-toolset-export" class="icon-toolset-export"></i></span><span class="step size-21"><span class="letters">Pp</span><i id="icon-toolset-export" class="icon-toolset-export"></i></span><span class="step size-24"><span class="letters">Pp</span><i id="icon-toolset-export" class="icon-toolset-export"></i></span><span class="step size-36"><span class="letters">Pp</span><i id="icon-toolset-export" class="icon-toolset-export"></i></span><span class="step size-48"><span class="letters">Pp</span><i id="icon-toolset-export" class="icon-toolset-export"></i></span><span class="step size-60"><span class="letters">Pp</span><i id="icon-toolset-export" class="icon-toolset-export"></i></span><span class="step size-72"><span class="letters">Pp</span><i id="icon-toolset-export" class="icon-toolset-export"></i></span>
|
627 |
+
</div>
|
628 |
+
<div class="preview-scale">
|
629 |
+
<span class="step">12</span><span class="step">14</span><span class="step">16</span><span class="step">18</span><span class="step">21</span><span class="step">24</span><span class="step">36</span><span class="step">48</span><span class="step">60</span><span class="step">72</span>
|
630 |
+
</div>
|
631 |
+
<div class="usage">
|
632 |
+
<input class="class" type="text" readonly="readonly" onClick="this.select();" value=".icon-toolset-export" />
|
633 |
+
<input class="point" type="text" readonly="readonly" onClick="this.select();" value="&#xf137;" />
|
634 |
+
</div>
|
635 |
+
</div>
|
636 |
+
|
637 |
<div class="glyph">
|
638 |
<div class="preview-glyphs">
|
639 |
<span class="step size-12"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-14"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-16"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-18"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-21"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-24"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-36"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-48"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-60"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span><span class="step size-72"><span class="letters">Pp</span><i id="icon-toolset-genesis-logo" class="icon-toolset-genesis-logo"></i></span>
|
library/toolset/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons_91cc76c6ec19609541b007a2169151af.woff
DELETED
Binary file
|
library/toolset/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_91cc76c6ec19609541b007a2169151af.eot → onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.eot}
RENAMED
Binary file
|
library/toolset/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_91cc76c6ec19609541b007a2169151af.svg → onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.svg}
RENAMED
@@ -1,13 +1,13 @@
|
|
1 |
<?xml version="1.0" standalone="no"?>
|
2 |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
3 |
<!--
|
4 |
-
|
5 |
-->
|
6 |
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
|
7 |
<metadata>
|
8 |
-
Created by FontForge 20150302 at
|
9 |
By Riccardo Strobbia
|
10 |
-
Copyright (c)
|
11 |
</metadata>
|
12 |
<defs>
|
13 |
<font id="onthegosystems-icons" horiz-adv-x="512" >
|
@@ -19,10 +19,10 @@ Copyright (c) 2016, Riccardo Strobbia
|
|
19 |
panose-1="2 0 5 3 0 0 0 0 0 0"
|
20 |
ascent="448"
|
21 |
descent="-64"
|
22 |
-
bbox="
|
23 |
underline-thickness="25.6"
|
24 |
underline-position="-51.2"
|
25 |
-
unicode-range="U+0020-
|
26 |
/>
|
27 |
<missing-glyph />
|
28 |
<glyph glyph-name="space" unicode=" " horiz-adv-x="200"
|
@@ -65,6 +65,11 @@ c2.45801 -6.91113 5.85645 -12.748 10.1953 -17.5098c4.33984 -4.76172 9.48535 -8.3
|
|
65 |
<glyph glyph-name="uniF130" unicode=""
|
66 |
d="M204.961 -49.2695v102.285h421.251v-102.285h-421.251zM204.961 330.962v102.331h421.251v-102.331h-421.251zM204.961 140.846v102.331h421.251v-102.331h-421.251zM18.5225 -49.2695v102.285h133.262v-102.285h-133.262zM18.5225 330.962v102.331h133.262v-102.331
|
67 |
h-133.262zM18.5225 140.846v102.331h133.262v-102.331h-133.262z" />
|
|
|
|
|
|
|
|
|
|
|
68 |
<glyph glyph-name="uniF135" unicode=""
|
69 |
d="M672.731 -44.9854v476.32h476.538v-476.32h-476.538zM60.1328 -44.9854v476.32h476.451v-476.32h-476.451zM1308.57 -44.9854v476.32h476.581v-476.32h-476.581zM264.289 263.99h-0.783203l-50.2998 -24.0186l-10.3555 46.4268l70.4014 32.5469h50.8652v-264.551
|
70 |
h-59.8281v209.596zM826.414 54.3945v37.4199l33.7646 30.458c58.1758 52.2139 86.2842 81.8018 86.6758 112.738c0.0332031 0.585938 0.0595703 1.53613 0.0595703 2.12207c0 20.584 -16.7051 37.2891 -37.2891 37.2891c-1.63574 0 -4.27539 -0.208984 -5.89062 -0.467773
|
@@ -386,11 +391,9 @@ d="M69.9062 -52.7617l-58.0127 58.0127l315.346 315.347l58.0137 -58.0127zM440.184
|
|
386 |
c-12.873 12.873 2.03027 18.8018 14.8857 31.6562c12.8545 12.8555 18.7832 27.7773 31.6562 14.9043zM512.218 379.737l18.4023 -24.6943l-30.7861 0.43457l-17.7686 -25.1113l-9.11914 29.3359l-29.3184 9.12012l25.0752 17.7861l-0.398438 30.75l24.6943 -18.4023
|
387 |
l29.0635 9.88086zM327.826 405.41l15.3203 -20.5244l-25.6191 0.327148l-14.8125 -20.9238l-7.5791 24.4775l-24.4766 7.57812l20.9229 14.8135l-0.326172 25.6191l20.5244 -15.3213l24.2588 8.23145zM476.463 268.322l9.33789 -12.5283l-15.6289 0.235352
|
388 |
l-8.95703 -12.6914l-4.58691 14.8311l-14.8672 4.62305l12.71 8.93848l-0.236328 15.6289l12.5293 -9.33691l14.7041 5.00391z" />
|
389 |
-
<glyph glyph-name="
|
390 |
-
d="
|
391 |
-
|
392 |
-
c-1.90723 3.23828 -2.53418 6.38672 -0.614258 9.63184l33.3057 79.2959c1.90039 3.92285 5.10742 6.49609 9.58105 6.49609h31.9863v-21.1777h-24.9658l-24.96 -58.2275h248.346l-25.0049 58.2275h-28.1406v21.1777h34.5469c4.47363 0 7.73145 -2.56641 9.63184 -6.49609
|
393 |
-
l33.3125 -79.2959c3.14844 -3.24512 2.47656 -7.05273 0.556641 -9.63184zM233.6 195.2c0 -20.7656 16.835 -37.6006 37.6006 -37.6006s37.5996 16.835 37.5996 37.6006s-16.834 37.5996 -37.5996 37.5996s-37.6006 -16.834 -37.6006 -37.5996z" />
|
394 |
<glyph glyph-name="uniF12C" unicode=""
|
395 |
d="M20.8887 280.548v149.814h564.48v-149.814h-564.48zM20.8887 114.135v88.8184h564.48v-88.8184h-564.48zM20.8887 -46.3623v88.8184h564.48v-88.8184h-564.48z" />
|
396 |
<glyph glyph-name="uniF12A" unicode=""
|
1 |
<?xml version="1.0" standalone="no"?>
|
2 |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
3 |
<!--
|
4 |
+
2017-1-23: Created with FontForge (http://fontforge.org)
|
5 |
-->
|
6 |
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
|
7 |
<metadata>
|
8 |
+
Created by FontForge 20150302 at Mon Jan 23 11:13:46 2017
|
9 |
By Riccardo Strobbia
|
10 |
+
Copyright (c) 2017, Riccardo Strobbia
|
11 |
</metadata>
|
12 |
<defs>
|
13 |
<font id="onthegosystems-icons" horiz-adv-x="512" >
|
19 |
panose-1="2 0 5 3 0 0 0 0 0 0"
|
20 |
ascent="448"
|
21 |
descent="-64"
|
22 |
+
bbox="0 -64 2082.65 448"
|
23 |
underline-thickness="25.6"
|
24 |
underline-position="-51.2"
|
25 |
+
unicode-range="U+0020-F137"
|
26 |
/>
|
27 |
<missing-glyph />
|
28 |
<glyph glyph-name="space" unicode=" " horiz-adv-x="200"
|
65 |
<glyph glyph-name="uniF130" unicode=""
|
66 |
d="M204.961 -49.2695v102.285h421.251v-102.285h-421.251zM204.961 330.962v102.331h421.251v-102.331h-421.251zM204.961 140.846v102.331h421.251v-102.331h-421.251zM18.5225 -49.2695v102.285h133.262v-102.285h-133.262zM18.5225 330.962v102.331h133.262v-102.331
|
67 |
h-133.262zM18.5225 140.846v102.331h133.262v-102.331h-133.262z" />
|
68 |
+
<glyph glyph-name="uniF125" unicode=""
|
69 |
+
d="M270.061 278.381c47.4307 0 85.7793 -38.4131 85.7793 -85.7471c0 -62.7969 -72.333 -135.693 -75.4814 -138.938c-2.5791 -2.5791 -6.49609 -4.49316 -10.2979 -4.49316c-3.82715 0 -7.01367 1.34375 -10.2139 4.49316
|
70 |
+
c-3.19434 3.23828 -75.5264 76.1406 -75.5264 138.938c0 47.3281 38.4062 85.7471 85.7402 85.7471zM420.448 16.5762c-1.90137 -3.16211 -5.05664 -4.49316 -8.9668 -4.49316h-279.642c-3.2002 0 -7.02051 1.90723 -8.97266 4.49316
|
71 |
+
c-1.90723 3.23828 -2.53418 6.38672 -0.614258 9.63184l33.3057 79.2959c1.90039 3.92285 5.10742 6.49609 9.58105 6.49609h31.9863v-21.1777h-24.9658l-24.96 -58.2275h248.346l-25.0049 58.2275h-28.1406v21.1777h34.5469c4.47363 0 7.73145 -2.56641 9.63184 -6.49609
|
72 |
+
l33.3125 -79.2959c3.14844 -3.24512 2.47656 -7.05273 0.556641 -9.63184zM233.6 195.2c0 -20.7656 16.835 -37.6006 37.6006 -37.6006s37.5996 16.835 37.5996 37.6006s-16.834 37.5996 -37.5996 37.5996s-37.6006 -16.834 -37.6006 -37.5996z" />
|
73 |
<glyph glyph-name="uniF135" unicode=""
|
74 |
d="M672.731 -44.9854v476.32h476.538v-476.32h-476.538zM60.1328 -44.9854v476.32h476.451v-476.32h-476.451zM1308.57 -44.9854v476.32h476.581v-476.32h-476.581zM264.289 263.99h-0.783203l-50.2998 -24.0186l-10.3555 46.4268l70.4014 32.5469h50.8652v-264.551
|
75 |
h-59.8281v209.596zM826.414 54.3945v37.4199l33.7646 30.458c58.1758 52.2139 86.2842 81.8018 86.6758 112.738c0.0332031 0.585938 0.0595703 1.53613 0.0595703 2.12207c0 20.584 -16.7051 37.2891 -37.2891 37.2891c-1.63574 0 -4.27539 -0.208984 -5.89062 -0.467773
|
391 |
c-12.873 12.873 2.03027 18.8018 14.8857 31.6562c12.8545 12.8555 18.7832 27.7773 31.6562 14.9043zM512.218 379.737l18.4023 -24.6943l-30.7861 0.43457l-17.7686 -25.1113l-9.11914 29.3359l-29.3184 9.12012l25.0752 17.7861l-0.398438 30.75l24.6943 -18.4023
|
392 |
l29.0635 9.88086zM327.826 405.41l15.3203 -20.5244l-25.6191 0.327148l-14.8125 -20.9238l-7.5791 24.4775l-24.4766 7.57812l20.9229 14.8135l-0.326172 25.6191l20.5244 -15.3213l24.2588 8.23145zM476.463 268.322l9.33789 -12.5283l-15.6289 0.235352
|
393 |
l-8.95703 -12.6914l-4.58691 14.8311l-14.8672 4.62305l12.71 8.93848l-0.236328 15.6289l12.5293 -9.33691l14.7041 5.00391z" />
|
394 |
+
<glyph glyph-name="uniF137" unicode=""
|
395 |
+
d="M340.283 362.665h85.0703v-426.665h-425.354v426.665h85.0703v85.335h85.0713v-85.335h85.0703v85.335h85.0713v-85.335zM65.9414 104.803l65.2051 -65.4062v49.0303h114.185v32.752h-114.185v49.0293zM294.207 206.789h-114.081v-32.752h114.081v-49.0303
|
396 |
+
l65.2051 65.4062l-65.2051 65.4053v-49.0293zM294.207 219.341z" />
|
|
|
|
|
397 |
<glyph glyph-name="uniF12C" unicode=""
|
398 |
d="M20.8887 280.548v149.814h564.48v-149.814h-564.48zM20.8887 114.135v88.8184h564.48v-88.8184h-564.48zM20.8887 -46.3623v88.8184h564.48v-88.8184h-564.48z" />
|
399 |
<glyph glyph-name="uniF12A" unicode=""
|
library/toolset/onthego-resources/onthegosystems-icons/fonts/{onthegosystems-icons_91cc76c6ec19609541b007a2169151af.ttf → onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.ttf}
RENAMED
Binary file
|
library/toolset/onthego-resources/onthegosystems-icons/fonts/onthegosystems-icons_c2bf5434fb5ba6db313a98fb4e1bf347.woff
ADDED
Binary file
|
library/toolset/onthego-resources/onthegosystems-icons/vectors/toolset-export.svg
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3 |
+
<svg version="1.1" baseProfile="tiny" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
4 |
+
x="0px" y="0px" viewBox="0 0 108 130" xml:space="preserve">
|
5 |
+
<g>
|
6 |
+
<g>
|
7 |
+
<polygon fill="#F05A29" points="86.4,21.667 86.4,0 64.8,0 64.8,21.667 43.2,21.667 43.2,0 21.6,0 21.6,21.667 0,21.667 0,130
|
8 |
+
108,130 108,21.667 "/>
|
9 |
+
</g>
|
10 |
+
<g>
|
11 |
+
<path fill="#FFFFFF" d="M16.743,87.14l16.556,16.607V91.298h28.992v-8.316H33.299V70.533L16.743,87.14z M74.701,61.245H45.735
|
12 |
+
v8.316h28.966V82.01l16.556-16.607L74.701,48.796V61.245z M74.701,58.058"/>
|
13 |
+
</g>
|
14 |
+
</g>
|
15 |
+
<g>
|
16 |
+
</g>
|
17 |
+
<g>
|
18 |
+
</g>
|
19 |
+
<g>
|
20 |
+
</g>
|
21 |
+
<g>
|
22 |
+
</g>
|
23 |
+
<g>
|
24 |
+
</g>
|
25 |
+
<g>
|
26 |
+
</g>
|
27 |
+
<g>
|
28 |
+
</g>
|
29 |
+
<g>
|
30 |
+
</g>
|
31 |
+
<g>
|
32 |
+
</g>
|
33 |
+
<g>
|
34 |
+
</g>
|
35 |
+
<g>
|
36 |
+
</g>
|
37 |
+
<g>
|
38 |
+
</g>
|
39 |
+
<g>
|
40 |
+
</g>
|
41 |
+
<g>
|
42 |
+
</g>
|
43 |
+
<g>
|
44 |
+
</g>
|
45 |
+
</svg>
|
library/toolset/toolset-common/changelog.md
CHANGED
@@ -5,12 +5,21 @@
|
|
5 |
- Extend the post objects relationships management with two actions to gather data on demand.
|
6 |
- Only include the jQuery datepicker stylesheet on demand when the current page contains a datepicker from Toolset.
|
7 |
- Include the user editors in the common bootstrap class.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
## 2.2.6
|
10 |
|
11 |
- Fix a CRED issue with added validation rules (types-988).
|
12 |
- Handle several issues related to using "0" as a default field value and saving it to the database (toolsetcommon-106).
|
13 |
- Minor compatibility fixes for the upcoming CRED 1.8.4 release.
|
|
|
14 |
|
15 |
## 2.2.5 (November 5, 2016)
|
16 |
|
@@ -22,7 +31,7 @@
|
|
22 |
|
23 |
## 2.2.3 (October 10, 2016)
|
24 |
|
25 |
-
- Fixed select2 edge cases when methods are called on non-select2 initialised element
|
26 |
- Refined special handling of old inputs by making sure target is only a select and not the hidden relative element
|
27 |
- Extended the valid date formats that Types and CRED supports for the Date field.
|
28 |
|
5 |
- Extend the post objects relationships management with two actions to gather data on demand.
|
6 |
- Only include the jQuery datepicker stylesheet on demand when the current page contains a datepicker from Toolset.
|
7 |
- Include the user editors in the common bootstrap class.
|
8 |
+
- Include knockout.js (toolsetcommon-127)
|
9 |
+
|
10 |
+
## 2.2.9
|
11 |
+
|
12 |
+
- Fix a validation issue for file, audio, video and embed fields affecting Types.
|
13 |
+
Allow URLs with non-latin characters, but only for URLs that point to attachments
|
14 |
+
from the Media Library (validated by WordPress media upload mechanism) (types-1013).
|
15 |
+
- Improve the validation for non-required Skype fields (toolsetcommon-128).
|
16 |
|
17 |
## 2.2.6
|
18 |
|
19 |
- Fix a CRED issue with added validation rules (types-988).
|
20 |
- Handle several issues related to using "0" as a default field value and saving it to the database (toolsetcommon-106).
|
21 |
- Minor compatibility fixes for the upcoming CRED 1.8.4 release.
|
22 |
+
- Extend WPToolset_Cake_Validation with the "url2" validation as a counterpart to the validation method in JQuery UI (types-988).
|
23 |
|
24 |
## 2.2.5 (November 5, 2016)
|
25 |
|
31 |
|
32 |
## 2.2.3 (October 10, 2016)
|
33 |
|
34 |
+
- Fixed select2 edge cases when methods are called on non-select2 initialised element.
|
35 |
- Refined special handling of old inputs by making sure target is only a select and not the hidden relative element
|
36 |
- Extended the valid date formats that Types and CRED supports for the Date field.
|
37 |
|
library/toolset/toolset-common/loader.php
CHANGED
@@ -30,7 +30,7 @@
|
|
30 |
* Now that we have a unique version for all plugins
|
31 |
* we define the version here
|
32 |
*/
|
33 |
-
$toolset_common_version =
|
34 |
|
35 |
|
36 |
// ----------------------------------------------------------------------//
|
30 |
* Now that we have a unique version for all plugins
|
31 |
* we define the version here
|
32 |
*/
|
33 |
+
$toolset_common_version = 229000;
|
34 |
|
35 |
|
36 |
// ----------------------------------------------------------------------//
|
library/toolset/toolset-common/toolset-common-loader.php
CHANGED
@@ -5,11 +5,11 @@ if ( class_exists( 'Toolset_Common_Bootstrap' ) ) {
|
|
5 |
};
|
6 |
|
7 |
if( !defined('TOOLSET_VERSION') ){
|
8 |
-
define('TOOLSET_VERSION', '2.2.
|
9 |
}
|
10 |
|
11 |
if ( ! defined('TOOLSET_COMMON_VERSION' ) ) {
|
12 |
-
define( 'TOOLSET_COMMON_VERSION', '2.2.
|
13 |
}
|
14 |
|
15 |
if ( ! defined('TOOLSET_COMMON_PATH' ) ) {
|
5 |
};
|
6 |
|
7 |
if( !defined('TOOLSET_VERSION') ){
|
8 |
+
define('TOOLSET_VERSION', '2.2.9');
|
9 |
}
|
10 |
|
11 |
if ( ! defined('TOOLSET_COMMON_VERSION' ) ) {
|
12 |
+
define( 'TOOLSET_COMMON_VERSION', '2.2.9' );
|
13 |
}
|
14 |
|
15 |
if ( ! defined('TOOLSET_COMMON_PATH' ) ) {
|
library/toolset/toolset-common/toolset-forms/classes/class.validation.php
CHANGED
@@ -136,16 +136,16 @@ class WPToolset_Forms_Validation {
|
|
136 |
/**
|
137 |
* Bulk PHP validation.
|
138 |
*
|
139 |
-
* @param
|
140 |
-
* @param type $value
|
141 |
* @return \WP_Error|boolean
|
142 |
* @throws Exception
|
143 |
*/
|
144 |
-
public function validateField($field) {
|
145 |
-
$value = apply_filters('wptoolset_validation_value_' . $field->getType(), $field->getValue());
|
146 |
-
$rules = $this->_parseRules($field->getValidationData(), $value);
|
|
|
147 |
// If not required but empty - skip
|
148 |
-
if (!isset($rules['required']) && (
|
149 |
return true;
|
150 |
}
|
151 |
|
@@ -153,16 +153,15 @@ class WPToolset_Forms_Validation {
|
|
153 |
$errors = array();
|
154 |
foreach ($rules as $rule => $args) {
|
155 |
if (!$this->validate($rule, $args['args'])) {
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
*
|
161 |
-
* @since x.x.x
|
162 |
*
|
163 |
-
* @param boolean $var show field title in message
|
164 |
*/
|
165 |
-
if
|
166 |
$errors[] = $field->getTitle() . ' ' . $args['message'];
|
167 |
} else {
|
168 |
$errors[] = $args['message'];
|
@@ -178,6 +177,25 @@ class WPToolset_Forms_Validation {
|
|
178 |
return true;
|
179 |
}
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
protected function _parseRules($rules, $value) {
|
182 |
$_rules = array();
|
183 |
foreach ($rules as $rule => $args) {
|
136 |
/**
|
137 |
* Bulk PHP validation.
|
138 |
*
|
139 |
+
* @param FieldFactory $field Field instance.
|
|
|
140 |
* @return \WP_Error|boolean
|
141 |
* @throws Exception
|
142 |
*/
|
143 |
+
public function validateField( $field ) {
|
144 |
+
$value = apply_filters( 'wptoolset_validation_value_' . $field->getType(), $field->getValue() );
|
145 |
+
$rules = $this->_parseRules( $field->getValidationData(), $value );
|
146 |
+
|
147 |
// If not required but empty - skip
|
148 |
+
if ( ! isset( $rules['required'] ) && $this->is_field_semantically_empty( $value, $field->getType() ) ) {
|
149 |
return true;
|
150 |
}
|
151 |
|
153 |
$errors = array();
|
154 |
foreach ($rules as $rule => $args) {
|
155 |
if (!$this->validate($rule, $args['args'])) {
|
156 |
+
|
157 |
+
/**
|
158 |
+
* toolset_common_validation_add_field_name_to_error
|
159 |
+
*
|
160 |
+
* Allow to avoid using the field name in the validation error message.
|
|
|
161 |
*
|
162 |
+
* @param boolean $var show field title in message. Default is true.
|
163 |
*/
|
164 |
+
if( apply_filters( 'toolset_common_validation_add_field_name_to_error', true ) ) {
|
165 |
$errors[] = $field->getTitle() . ' ' . $args['message'];
|
166 |
} else {
|
167 |
$errors[] = $args['message'];
|
177 |
return true;
|
178 |
}
|
179 |
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Check that the semantic (display) value is empty, opposed to checking the raw data from *meta database row.
|
183 |
+
*
|
184 |
+
* @param mixed|string $value Raw field value.
|
185 |
+
* @param string $field_type Field type slug.
|
186 |
+
* @return bool
|
187 |
+
* @since 2.3
|
188 |
+
*/
|
189 |
+
protected function is_field_semantically_empty( $value, $field_type ) {
|
190 |
+
switch( $field_type ) {
|
191 |
+
case 'skype':
|
192 |
+
// Check the emptiness of skype name only, ignore the rest.
|
193 |
+
return $this->is_field_semantically_empty( toolset_getarr( $value, 'skypename' ), 'textfield' );
|
194 |
+
default:
|
195 |
+
return ( is_null( $value ) || $value === false || $value === '' );
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
protected function _parseRules($rules, $value) {
|
200 |
$_rules = array();
|
201 |
foreach ($rules as $rule => $args) {
|
library/toolset/toolset-common/toolset-forms/lib/CakePHP-Validation.php
CHANGED
@@ -96,9 +96,7 @@ class WPToolset_Cake_Validation {
|
|
96 |
/**
|
97 |
* Gets a reference to the Validation object instance
|
98 |
*
|
99 |
-
* @return
|
100 |
-
* @access public
|
101 |
-
* @static
|
102 |
*/
|
103 |
function &getInstance() {
|
104 |
static $instance = array();
|
@@ -971,14 +969,59 @@ class WPToolset_Cake_Validation {
|
|
971 |
* It is less strict than the standard 'url' because it doesn't require the TLD to be present in the hostname.
|
972 |
* Parameters are directly passed to self::url().
|
973 |
*
|
974 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
975 |
* @param bool $strict
|
976 |
*
|
977 |
* @return bool Validation result.
|
978 |
* @since 2.2.6
|
979 |
*/
|
980 |
-
function url2( $
|
981 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
982 |
}
|
983 |
|
984 |
|
96 |
/**
|
97 |
* Gets a reference to the Validation object instance
|
98 |
*
|
99 |
+
* @return WPToolset_Cake_Validation Validation instance
|
|
|
|
|
100 |
*/
|
101 |
function &getInstance() {
|
102 |
static $instance = array();
|
969 |
* It is less strict than the standard 'url' because it doesn't require the TLD to be present in the hostname.
|
970 |
* Parameters are directly passed to self::url().
|
971 |
*
|
972 |
+
* Since WordPress allows for non-latin characters to be part of files uploaded via Media Upload,
|
973 |
+
* we go especially easy on URLs resulting from that. If an URL is identified as one of an attachment,
|
974 |
+
* no further validation is done (but the goal is achieved, now we know that the user entered a value
|
975 |
+
* that is correct).
|
976 |
+
*
|
977 |
+
* This method isn't bulletproof, though, and if it doesn't work in some special scenario,
|
978 |
+
* it is possible to make use of the toolset_validate_file_url filter to override the validation result.
|
979 |
+
*
|
980 |
+
* @param string $value_to_check Value to check.
|
981 |
* @param bool $strict
|
982 |
*
|
983 |
* @return bool Validation result.
|
984 |
* @since 2.2.6
|
985 |
*/
|
986 |
+
function url2( $value_to_check, $strict = false ) {
|
987 |
+
|
988 |
+
if( $this->is_attachment_url( $value_to_check ) ) {
|
989 |
+
$is_valid_url = true;
|
990 |
+
} else {
|
991 |
+
$is_valid_url = $this->url( $value_to_check, $strict, false );
|
992 |
+
}
|
993 |
+
|
994 |
+
/**
|
995 |
+
* toolset_validate_file_url
|
996 |
+
*
|
997 |
+
* Allow for overriding the url2 validation result used for file fields.
|
998 |
+
*
|
999 |
+
* @param bool $validation_result
|
1000 |
+
* @param string $value_to_check
|
1001 |
+
* @since 2.2.9
|
1002 |
+
*/
|
1003 |
+
return (bool) apply_filters( 'toolset_validate_file_url', $is_valid_url, $value_to_check );
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
|
1007 |
+
/**
|
1008 |
+
* Determine if a provided URL belongs to an attachment from the media library.
|
1009 |
+
*
|
1010 |
+
* @param string $url
|
1011 |
+
* @return bool
|
1012 |
+
* @since 2.2.9
|
1013 |
+
*/
|
1014 |
+
private function is_attachment_url( $url ) {
|
1015 |
+
|
1016 |
+
$url_parts = parse_url( $url );
|
1017 |
+
if( false === $url_parts ) {
|
1018 |
+
// Seriously malformed URL here.
|
1019 |
+
return false;
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
$attachment_id = Toolset_Utils::get_attachment_id_by_url( $url );
|
1023 |
+
|
1024 |
+
return ( null != $attachment_id && 0 != $attachment_id );
|
1025 |
}
|
1026 |
|
1027 |
|
library/toolset/toolset-common/utility/utils.php
CHANGED
@@ -30,7 +30,7 @@ if (!class_exists('Toolset_Utils')) {
|
|
30 |
*
|
31 |
* Creates the HTML version for the wpvToolsetHelp() javascript function
|
32 |
*
|
33 |
-
* @param data
|
34 |
* text => The content to show inside the help box.
|
35 |
* tutorial-button-text => Optional button anchor text.
|
36 |
* tutorial-button-url => Optional button url.
|
@@ -115,6 +115,56 @@ if (!class_exists('Toolset_Utils')) {
|
|
115 |
return $is_truly_empty;
|
116 |
}
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
}
|
119 |
|
120 |
}
|
30 |
*
|
31 |
* Creates the HTML version for the wpvToolsetHelp() javascript function
|
32 |
*
|
33 |
+
* @param array $data Data containing the attributes
|
34 |
* text => The content to show inside the help box.
|
35 |
* tutorial-button-text => Optional button anchor text.
|
36 |
* tutorial-button-url => Optional button url.
|
115 |
return $is_truly_empty;
|
116 |
}
|
117 |
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Return an ID of an attachment by searching the database with the file URL.
|
121 |
+
*
|
122 |
+
* First checks to see if the $url is pointing to a file that exists in
|
123 |
+
* the wp-content directory. If so, then we search the database for a
|
124 |
+
* partial match consisting of the remaining path AFTER the wp-content
|
125 |
+
* directory. Finally, if a match is found the attachment ID will be
|
126 |
+
* returned.
|
127 |
+
*
|
128 |
+
* Taken from:
|
129 |
+
* @link http://frankiejarrett.com/get-an-attachment-id-by-url-in-wordpress/
|
130 |
+
*
|
131 |
+
* @param string $url URL of the file.
|
132 |
+
* @return int|null Attachment ID if it exists.
|
133 |
+
* @since 2.2.9
|
134 |
+
*/
|
135 |
+
public static function get_attachment_id_by_url( $url ) {
|
136 |
+
|
137 |
+
// Split the $url into two parts with the wp-content directory as the separator.
|
138 |
+
$parsed_url = explode( parse_url( WP_CONTENT_URL, PHP_URL_PATH ), $url );
|
139 |
+
|
140 |
+
// Get the host of the current site and the host of the $url, ignoring www.
|
141 |
+
$this_host = str_ireplace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) );
|
142 |
+
$file_host = str_ireplace( 'www.', '', parse_url( $url, PHP_URL_HOST ) );
|
143 |
+
|
144 |
+
// Return nothing if there aren't any $url parts or if the current host and $url host do not match.
|
145 |
+
$attachment_path = toolset_getarr( $parsed_url, 1 );
|
146 |
+
if ( ! isset( $attachment_path ) || empty( $attachment_path ) || ( $this_host != $file_host ) ) {
|
147 |
+
return null;
|
148 |
+
}
|
149 |
+
|
150 |
+
// Now we're going to quickly search the DB for any attachment GUID with a partial path match.
|
151 |
+
// Example: /uploads/2013/05/test-image.jpg
|
152 |
+
global $wpdb;
|
153 |
+
|
154 |
+
$query = $wpdb->prepare(
|
155 |
+
"SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND guid LIKE %s",
|
156 |
+
'%' . $attachment_path
|
157 |
+
);
|
158 |
+
|
159 |
+
$attachment = $wpdb->get_col( $query );
|
160 |
+
|
161 |
+
if ( is_array( $attachment ) && ! empty( $attachment ) ) {
|
162 |
+
return (int) array_shift( $attachment );
|
163 |
+
}
|
164 |
+
|
165 |
+
return null;
|
166 |
+
}
|
167 |
+
|
168 |
}
|
169 |
|
170 |
}
|
library/toolset/types/admin.php
CHANGED
@@ -358,23 +358,6 @@ function wpcf_admin_toolset_register_menu_pages( $pages ) {
|
|
358 |
}
|
359 |
|
360 |
|
361 |
-
if (
|
362 |
-
(class_exists( 'Acf') && !class_exists('acf_pro'))
|
363 |
-
|| defined( 'CPT_VERSION' )
|
364 |
-
) {
|
365 |
-
$pages['wpcf-migration'] = array(
|
366 |
-
'slug' => 'wpcf-migration',
|
367 |
-
'menu_title' => __( 'Types Migration', 'wpcf' ),
|
368 |
-
'page_title' => __( 'Types Migration', 'wpcf' ),
|
369 |
-
'callback' => 'wpcf_admin_menu_migration',
|
370 |
-
'capability' => 'manage_options',
|
371 |
-
);
|
372 |
-
$pages['wpcf-migration']['capability'] = wpcf_admin_calculate_menu_page_capability( $pages['wpcf-migration'] );
|
373 |
-
$pages['wpcf-migration']['load_hook'] = wpcf_admin_calculate_menu_page_load_hook( $pages['wpcf-migration'] );
|
374 |
-
$pages['wpcf-migration']['contextual_help_legacy'] = wpcf_admin_help( 'wpcf-migration' );
|
375 |
-
$pages['wpcf-migration']['contextual_help_hook'] = 'wpcf_admin_help_add_tabs_load_hook';
|
376 |
-
}
|
377 |
-
|
378 |
if ( 'installer' == $current_page ) {
|
379 |
// @todo Having a page with a slug "installer" is a direct path to a third-party plugin conflict. Just saying. Not to mention the callback funciton "installer_content", for god's sake
|
380 |
$pages['installer'] = array(
|
@@ -446,6 +429,8 @@ function wpcf_admin_menu_summary()
|
|
446 |
function wpcf_admin_enqueue_group_edit_page_assets() {
|
447 |
do_action( 'wpcf_admin_page_init' );
|
448 |
|
|
|
|
|
449 |
/*
|
450 |
* Enqueue scripts
|
451 |
*/
|
@@ -453,15 +438,15 @@ function wpcf_admin_enqueue_group_edit_page_assets() {
|
|
453 |
wp_enqueue_script( 'wpcf-filter-js',
|
454 |
WPCF_EMBEDDED_RES_RELPATH
|
455 |
. '/js/custom-fields-form-filter.js', array('jquery'), WPCF_VERSION );
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
// Scroll
|
466 |
wp_enqueue_script( 'wpcf-scrollbar',
|
467 |
WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/visual-editor/res/js/scrollbar.js',
|
@@ -640,20 +625,21 @@ function wpcf_admin_menu_edit_type_hook()
|
|
640 |
wp_enqueue_script( 'wpcf-custom-types-form',
|
641 |
WPCF_RES_RELPATH . '/js/'
|
642 |
. 'custom-types-form.js', array('jquery', 'jquery-ui-dialog', 'jquery-masonry'), WPCF_VERSION );
|
643 |
-
|
644 |
-
WPCF_RES_RELPATH . '/js/'
|
645 |
-
. 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
|
646 |
-
WPCF_VERSION );
|
647 |
-
wp_enqueue_script( 'wpcf-form-validation-additional',
|
648 |
-
WPCF_RES_RELPATH . '/js/'
|
649 |
-
. 'jquery-form-validation/additional-methods.min.js',
|
650 |
-
array('jquery'), WPCF_VERSION );
|
651 |
wp_enqueue_style('wp-jquery-ui-dialog');
|
652 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
653 |
wpcf_post_relationship_init();
|
654 |
|
655 |
// New page controller script.
|
656 |
-
$asset_manager = Types_Asset_Manager::get_instance();
|
657 |
$asset_manager->enqueue_scripts( Types_Asset_Manager::SCRIPT_PAGE_EDIT_POST_TYPE );
|
658 |
|
659 |
/**
|
@@ -704,21 +690,22 @@ function wpcf_admin_menu_edit_type()
|
|
704 |
function wpcf_admin_menu_edit_tax_hook()
|
705 |
{
|
706 |
do_action( 'wpcf_admin_page_init' );
|
707 |
-
|
708 |
-
WPCF_RES_RELPATH . '/js/'
|
709 |
-
. 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
|
710 |
-
WPCF_VERSION );
|
711 |
-
wp_enqueue_script( 'wpcf-form-validation-additional',
|
712 |
-
WPCF_RES_RELPATH . '/js/'
|
713 |
-
. 'jquery-form-validation/additional-methods.min.js',
|
714 |
-
array('jquery'), WPCF_VERSION );
|
715 |
wp_enqueue_script( 'wpcf-taxonomy-form',
|
716 |
WPCF_RES_RELPATH . '/js/'
|
717 |
. 'taxonomy-form.js', array( 'jquery' ), WPCF_VERSION );
|
718 |
|
719 |
-
|
720 |
$asset_manager = Types_Asset_Manager::get_instance();
|
721 |
-
$asset_manager->enqueue_scripts(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
722 |
|
723 |
add_action( 'admin_footer', 'wpcf_admin_tax_form_js_validation' );
|
724 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
|
@@ -896,35 +883,6 @@ function wpcf_render_import_form() {
|
|
896 |
}
|
897 |
|
898 |
|
899 |
-
|
900 |
-
/**
|
901 |
-
* Menu page hook.
|
902 |
-
*/
|
903 |
-
function wpcf_admin_menu_migration_hook()
|
904 |
-
{
|
905 |
-
do_action( 'wpcf_admin_page_init' );
|
906 |
-
require_once WPCF_INC_ABSPATH . '/fields.php';
|
907 |
-
require_once WPCF_INC_ABSPATH . '/custom-types.php';
|
908 |
-
require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
|
909 |
-
require_once WPCF_INC_ABSPATH . '/migration.php';
|
910 |
-
$form = wpcf_admin_migration_form();
|
911 |
-
wpcf_form( 'wpcf_form_migration', $form );
|
912 |
-
}
|
913 |
-
|
914 |
-
/**
|
915 |
-
* Menu page display.
|
916 |
-
*/
|
917 |
-
function wpcf_admin_menu_migration()
|
918 |
-
{
|
919 |
-
wpcf_add_admin_header( __( 'Migration', 'wpcf' ) );
|
920 |
-
echo '<form method="post" action="" id="wpcf-migration-form" class="wpcf-migration-form '
|
921 |
-
. 'wpcf-form-validate" enctype="multipart/form-data">';
|
922 |
-
$form = wpcf_form( 'wpcf_form_migration' );
|
923 |
-
echo $form->renderForm();
|
924 |
-
echo '</form>';
|
925 |
-
wpcf_add_admin_footer();
|
926 |
-
}
|
927 |
-
|
928 |
add_filter( 'toolset_filter_toolset_register_settings_section', 'wpcf_register_settings_custom_content_section', 20 );
|
929 |
|
930 |
function wpcf_register_settings_custom_content_section( $sections ) {
|
358 |
}
|
359 |
|
360 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
if ( 'installer' == $current_page ) {
|
362 |
// @todo Having a page with a slug "installer" is a direct path to a third-party plugin conflict. Just saying. Not to mention the callback funciton "installer_content", for god's sake
|
363 |
$pages['installer'] = array(
|
429 |
function wpcf_admin_enqueue_group_edit_page_assets() {
|
430 |
do_action( 'wpcf_admin_page_init' );
|
431 |
|
432 |
+
$asset_manager = Types_Asset_Manager::get_instance();
|
433 |
+
|
434 |
/*
|
435 |
* Enqueue scripts
|
436 |
*/
|
438 |
wp_enqueue_script( 'wpcf-filter-js',
|
439 |
WPCF_EMBEDDED_RES_RELPATH
|
440 |
. '/js/custom-fields-form-filter.js', array('jquery'), WPCF_VERSION );
|
441 |
+
|
442 |
+
|
443 |
+
$asset_manager->enqueue_scripts(
|
444 |
+
array(
|
445 |
+
Types_Asset_Manager::SCRIPT_JQUERY_UI_VALIDATION,
|
446 |
+
Types_Asset_Manager::SCRIPT_ADDITIONAL_VALIDATION_RULES,
|
447 |
+
)
|
448 |
+
);
|
449 |
+
|
450 |
// Scroll
|
451 |
wp_enqueue_script( 'wpcf-scrollbar',
|
452 |
WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/visual-editor/res/js/scrollbar.js',
|
625 |
wp_enqueue_script( 'wpcf-custom-types-form',
|
626 |
WPCF_RES_RELPATH . '/js/'
|
627 |
. 'custom-types-form.js', array('jquery', 'jquery-ui-dialog', 'jquery-masonry'), WPCF_VERSION );
|
628 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
629 |
wp_enqueue_style('wp-jquery-ui-dialog');
|
630 |
+
|
631 |
+
$asset_manager = Types_Asset_Manager::get_instance();
|
632 |
+
$asset_manager->enqueue_scripts(
|
633 |
+
array(
|
634 |
+
Types_Asset_Manager::SCRIPT_JQUERY_UI_VALIDATION,
|
635 |
+
Types_Asset_Manager::SCRIPT_ADDITIONAL_VALIDATION_RULES,
|
636 |
+
)
|
637 |
+
);
|
638 |
+
|
639 |
+
add_action( 'admin_footer', 'wpcf_admin_types_form_js_validation' );
|
640 |
wpcf_post_relationship_init();
|
641 |
|
642 |
// New page controller script.
|
|
|
643 |
$asset_manager->enqueue_scripts( Types_Asset_Manager::SCRIPT_PAGE_EDIT_POST_TYPE );
|
644 |
|
645 |
/**
|
690 |
function wpcf_admin_menu_edit_tax_hook()
|
691 |
{
|
692 |
do_action( 'wpcf_admin_page_init' );
|
693 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
694 |
wp_enqueue_script( 'wpcf-taxonomy-form',
|
695 |
WPCF_RES_RELPATH . '/js/'
|
696 |
. 'taxonomy-form.js', array( 'jquery' ), WPCF_VERSION );
|
697 |
|
698 |
+
|
699 |
$asset_manager = Types_Asset_Manager::get_instance();
|
700 |
+
$asset_manager->enqueue_scripts(
|
701 |
+
array(
|
702 |
+
Types_Asset_Manager::SCRIPT_JQUERY_UI_VALIDATION,
|
703 |
+
Types_Asset_Manager::SCRIPT_ADDITIONAL_VALIDATION_RULES,
|
704 |
+
|
705 |
+
// New page controller script.
|
706 |
+
Types_Asset_Manager::SCRIPT_PAGE_EDIT_TAXONOMY
|
707 |
+
)
|
708 |
+
);
|
709 |
|
710 |
add_action( 'admin_footer', 'wpcf_admin_tax_form_js_validation' );
|
711 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
|
883 |
}
|
884 |
|
885 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
886 |
add_filter( 'toolset_filter_toolset_register_settings_section', 'wpcf_register_settings_custom_content_section', 20 );
|
887 |
|
888 |
function wpcf_register_settings_custom_content_section( $sections ) {
|
library/toolset/types/embedded/bootstrap.php
CHANGED
@@ -157,7 +157,7 @@ function wpcf_embedded_init() {
|
|
157 |
|
158 |
// Toolset Forms
|
159 |
if ( ! defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
|
160 |
-
$toolset_common_bootstrap = Toolset_Common_Bootstrap::
|
161 |
$toolset_common_sections = array(
|
162 |
'toolset_forms'
|
163 |
);
|
@@ -190,14 +190,6 @@ function wpcf_embedded_init() {
|
|
190 |
define( 'WPCF_EMBEDDED_RES_RELPATH', WPCF_EMBEDDED_RELPATH . '/resources' );
|
191 |
|
192 |
// TODO INCLUDES!
|
193 |
-
//
|
194 |
-
// Please add all required includes here
|
195 |
-
// Since Types 1.2 we can consider existing code as core.
|
196 |
-
// All new functionalities should be added as includes HERE
|
197 |
-
// and marked with @since Types $version.
|
198 |
-
//
|
199 |
-
// Thanks!
|
200 |
-
//
|
201 |
|
202 |
// Basic
|
203 |
/*
|
@@ -243,25 +235,16 @@ function wpcf_embedded_init() {
|
|
243 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/cred.php';
|
244 |
}
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
* TODO This is a must for now.
|
250 |
-
* See if any fields need to be loaded.
|
251 |
-
*
|
252 |
-
* 1. Checkboxes - may be missing when submitted
|
253 |
-
*/
|
254 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/checkbox.php';
|
255 |
|
|
|
|
|
|
|
256 |
|
257 |
-
|
258 |
-
*
|
259 |
-
*
|
260 |
-
* Use this call to load basic scripts and styles if necesary
|
261 |
-
* wpcf_enqueue_scripts();
|
262 |
-
*/
|
263 |
-
require_once WPCF_EMBEDDED_ABSPATH . '/usermeta-init.php';
|
264 |
-
// Include frontend or admin code
|
265 |
if ( is_admin() ) {
|
266 |
|
267 |
require_once WPCF_EMBEDDED_ABSPATH . '/admin.php';
|
@@ -279,7 +262,6 @@ function wpcf_embedded_init() {
|
|
279 |
|
280 |
global $wpcf;
|
281 |
|
282 |
-
// TODO since Types 1.2 Continue adding new functionalities HERE
|
283 |
/*
|
284 |
* Consider code already there as core.
|
285 |
* Use hooks to add new functionalities
|
157 |
|
158 |
// Toolset Forms
|
159 |
if ( ! defined( 'WPTOOLSET_FORMS_VERSION' ) ) {
|
160 |
+
$toolset_common_bootstrap = Toolset_Common_Bootstrap::get_instance();
|
161 |
$toolset_common_sections = array(
|
162 |
'toolset_forms'
|
163 |
);
|
190 |
define( 'WPCF_EMBEDDED_RES_RELPATH', WPCF_EMBEDDED_RELPATH . '/resources' );
|
191 |
|
192 |
// TODO INCLUDES!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
|
194 |
// Basic
|
195 |
/*
|
235 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/cred.php';
|
236 |
}
|
237 |
|
238 |
+
// This is a must for now.
|
239 |
+
// See if any fields need to be loaded.
|
240 |
+
// 1. Checkboxes - may be missing when submitted
|
|
|
|
|
|
|
|
|
|
|
241 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/checkbox.php';
|
242 |
|
243 |
+
// Use this call to load basic scripts and styles if necesary
|
244 |
+
// wpcf_enqueue_scripts();
|
245 |
+
require_once WPCF_EMBEDDED_ABSPATH . '/usermeta-init.php';
|
246 |
|
247 |
+
// Include frontend or admin code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
if ( is_admin() ) {
|
249 |
|
250 |
require_once WPCF_EMBEDDED_ABSPATH . '/admin.php';
|
262 |
|
263 |
global $wpcf;
|
264 |
|
|
|
265 |
/*
|
266 |
* Consider code already there as core.
|
267 |
* Use hooks to add new functionalities
|
library/toolset/types/embedded/classes/field.php
CHANGED
@@ -46,19 +46,17 @@ class WPCF_Field
|
|
46 |
* /embedded/includes/fields/$field_type.php
|
47 |
* /includes/fields/$field_type.php
|
48 |
*
|
49 |
-
* @var
|
50 |
*/
|
51 |
var $cf = array();
|
52 |
|
53 |
/**
|
54 |
* All Types created fields
|
55 |
-
* @var type
|
56 |
*/
|
57 |
var $fields = null;
|
58 |
|
59 |
/**
|
60 |
* Field saved data
|
61 |
-
* @var type
|
62 |
*/
|
63 |
var $meta = null;
|
64 |
|
@@ -67,7 +65,7 @@ class WPCF_Field
|
|
67 |
*
|
68 |
* Use it to set default configuration.
|
69 |
*
|
70 |
-
* @var
|
71 |
*/
|
72 |
var $config = array(
|
73 |
'use_form' => false,
|
@@ -75,7 +73,7 @@ class WPCF_Field
|
|
75 |
|
76 |
/**
|
77 |
* Form object
|
78 |
-
* @var
|
79 |
*/
|
80 |
var $form = array();
|
81 |
|
@@ -86,32 +84,31 @@ class WPCF_Field
|
|
86 |
|
87 |
/**
|
88 |
* CF slug
|
89 |
-
* @var
|
90 |
*/
|
91 |
var $slug = '';
|
92 |
|
93 |
/**
|
94 |
* Use cache flag
|
95 |
-
* @var
|
96 |
*/
|
97 |
var $use_cache = true;
|
98 |
|
99 |
/**
|
100 |
* Cache.DEPRECATED
|
101 |
*
|
102 |
-
* @var
|
103 |
*/
|
104 |
var $cache = array();
|
105 |
|
106 |
/**
|
107 |
* Add to editor flas
|
108 |
-
* @var
|
109 |
*/
|
110 |
var $add_to_editor = true;
|
111 |
|
112 |
/**
|
113 |
* Context in which class is called
|
114 |
-
* @var type
|
115 |
*/
|
116 |
var $context = 'group';
|
117 |
|
@@ -119,7 +116,6 @@ class WPCF_Field
|
|
119 |
* Invalid fields
|
120 |
*
|
121 |
* @todo Revise
|
122 |
-
* @var type
|
123 |
*/
|
124 |
var $invalid_fields = array();
|
125 |
|
@@ -138,12 +134,14 @@ class WPCF_Field
|
|
138 |
extract( wp_parse_args( (array) $config, $this->config ) );
|
139 |
}
|
140 |
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
147 |
function set( $post, $cf ) {
|
148 |
|
149 |
global $wpcf;
|
@@ -360,27 +358,23 @@ class WPCF_Field
|
|
360 |
*/
|
361 |
$_value = $this->_filter_save_postmeta_value( $value );
|
362 |
$_value = $this->_filter_save_value( $_value );
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
&& preg_match( '/^0$/', $value )
|
381 |
-
&& preg_match( '/^0$/', $this->cf['data']['set_value'] )
|
382 |
-
)
|
383 |
-
) {
|
384 |
$mid = add_post_meta( $this->post->ID, $this->slug, $_value );
|
385 |
/*
|
386 |
* Use these hooks to add future functionality.
|
46 |
* /embedded/includes/fields/$field_type.php
|
47 |
* /includes/fields/$field_type.php
|
48 |
*
|
49 |
+
* @var array
|
50 |
*/
|
51 |
var $cf = array();
|
52 |
|
53 |
/**
|
54 |
* All Types created fields
|
|
|
55 |
*/
|
56 |
var $fields = null;
|
57 |
|
58 |
/**
|
59 |
* Field saved data
|
|
|
60 |
*/
|
61 |
var $meta = null;
|
62 |
|
65 |
*
|
66 |
* Use it to set default configuration.
|
67 |
*
|
68 |
+
* @var array
|
69 |
*/
|
70 |
var $config = array(
|
71 |
'use_form' => false,
|
73 |
|
74 |
/**
|
75 |
* Form object
|
76 |
+
* @var array
|
77 |
*/
|
78 |
var $form = array();
|
79 |
|
84 |
|
85 |
/**
|
86 |
* CF slug
|
87 |
+
* @var string
|
88 |
*/
|
89 |
var $slug = '';
|
90 |
|
91 |
/**
|
92 |
* Use cache flag
|
93 |
+
* @var boolean
|
94 |
*/
|
95 |
var $use_cache = true;
|
96 |
|
97 |
/**
|
98 |
* Cache.DEPRECATED
|
99 |
*
|
100 |
+
* @var
|
101 |
*/
|
102 |
var $cache = array();
|
103 |
|
104 |
/**
|
105 |
* Add to editor flas
|
106 |
+
* @var boolean
|
107 |
*/
|
108 |
var $add_to_editor = true;
|
109 |
|
110 |
/**
|
111 |
* Context in which class is called
|
|
|
112 |
*/
|
113 |
var $context = 'group';
|
114 |
|
116 |
* Invalid fields
|
117 |
*
|
118 |
* @todo Revise
|
|
|
119 |
*/
|
120 |
var $invalid_fields = array();
|
121 |
|
134 |
extract( wp_parse_args( (array) $config, $this->config ) );
|
135 |
}
|
136 |
|
137 |
+
/**
|
138 |
+
* Set current post and field.
|
139 |
+
*
|
140 |
+
* @param $post
|
141 |
+
* @param $cf
|
142 |
+
*
|
143 |
+
* @return bool
|
144 |
+
*/
|
145 |
function set( $post, $cf ) {
|
146 |
|
147 |
global $wpcf;
|
358 |
*/
|
359 |
$_value = $this->_filter_save_postmeta_value( $value );
|
360 |
$_value = $this->_filter_save_value( $_value );
|
361 |
+
|
362 |
+
// Save field if needed
|
363 |
+
$value_is_empty = ( is_null( $value ) || $value === false || $value === '' );
|
364 |
+
$should_save_empty_value = (
|
365 |
+
isset( $this->cf['data']['save_empty'] ) && 'yes' == $this->cf['data']['save_empty']
|
366 |
+
);
|
367 |
+
|
368 |
+
// This is a special case where we are supposed to save zero as a value when the field is set
|
369 |
+
// (applies for checkbox, checkboxes or other boolean-ish fields).
|
370 |
+
$saving_zero_as_set_value = (
|
371 |
+
array_key_exists( 'set_value', $this->cf['data'] )
|
372 |
+
&& preg_match( '/^0$/', $value )
|
373 |
+
&& preg_match( '/^0$/', $this->cf['data']['set_value'] )
|
374 |
+
);
|
375 |
+
|
376 |
+
if ( ! $value_is_empty || $should_save_empty_value || $saving_zero_as_set_value ) {
|
377 |
+
|
|
|
|
|
|
|
|
|
378 |
$mid = add_post_meta( $this->post->ID, $this->slug, $_value );
|
379 |
/*
|
380 |
* Use these hooks to add future functionality.
|
library/toolset/types/embedded/classes/wpviews.php
CHANGED
@@ -1,50 +1,318 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class WPCF_WPViews
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
add_action( 'current_screen', array( 'WPCF_WPViews', 'include_types_fields_on_views_dialog_on_demand' ) );
|
15 |
-
|
16 |
-
add_action( 'wpv_action_wpv_add_types_postmeta_usermeta_to_editor_menus', array(
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
/**
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
public static function include_types_fields_on_views_dialog_on_demand( $current_screen ) {
|
24 |
-
|
25 |
/**
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
$force_include_types_in_fields_and_views_dialog = apply_filters( 'wpcf_filter_force_include_types_fields_on_views_dialog', false, $current_screen );
|
38 |
-
|
39 |
if ( $force_include_types_in_fields_and_views_dialog ) {
|
40 |
self::editScreenInit();
|
41 |
}
|
42 |
}
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
48 |
if ( ! wp_script_is( 'types', 'enqueued' ) ) {
|
49 |
wp_enqueue_script( 'types' );
|
50 |
}
|
@@ -57,116 +325,134 @@ class WPCF_WPViews
|
|
57 |
if ( ! wp_style_is( 'toolset-colorbox', 'enqueued' ) ) {
|
58 |
wp_enqueue_style( 'toolset-colorbox' );
|
59 |
}
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
73 |
public static function wpcf_wpv_admin_post_add_postmeta_usermeta_to_editor_js() {
|
74 |
-
add_action( 'wpv_action_wpv_add_types_postmeta_to_editor', array(
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
-
|
|
|
78 |
public static function wpcf_admin_post_add_postmeta_to_editor_on_demand( $editor ) {
|
79 |
add_action( 'admin_footer', 'wpcf_admin_post_js_validation' );
|
80 |
wpcf_enqueue_scripts();
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
$current_post = apply_filters( 'wpcf_filter_wpcf_admin_get_current_edited_post', null );
|
85 |
if ( empty( $current_post ) ) {
|
86 |
-
$current_post = (object) array('ID' => -1);
|
87 |
}
|
88 |
|
89 |
$fields = wpcf_admin_post_add_to_editor( 'get' );
|
90 |
$groups = wpcf_admin_post_get_post_groups_fields( $current_post );
|
91 |
-
if (
|
92 |
-
! empty( $fields )
|
93 |
-
&& ! empty( $groups )
|
94 |
) {
|
95 |
foreach ( $groups as $group ) {
|
96 |
if ( empty( $group['fields'] ) ) {
|
97 |
continue;
|
98 |
}
|
99 |
foreach ( $group['fields'] as $group_field_id => $group_field ) {
|
100 |
-
if ( isset( $fields[$group_field_id] ) ) {
|
101 |
-
$field = $fields[$group_field_id];
|
102 |
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $current_post->ID . ')';
|
103 |
-
$editor->add_insert_shortcode_menu(
|
104 |
stripslashes( $field['name'] ),
|
105 |
trim( wpcf_fields_get_shortcode( $field ), '[]' ),
|
106 |
$group['name'],
|
107 |
-
$callback
|
108 |
);
|
109 |
}
|
110 |
}
|
111 |
}
|
112 |
}
|
113 |
}
|
114 |
-
|
|
|
115 |
public static function wpcf_admin_post_add_usermeta_to_editor_on_demand() {
|
116 |
add_action( 'admin_footer', 'wpcf_admin_post_js_validation' );
|
117 |
wpcf_enqueue_scripts();
|
118 |
-
|
119 |
-
|
120 |
add_filter( 'editor_addon_menus_wpv-views', 'wpcf_admin_post_add_usermeta_to_editor_js' );
|
121 |
}
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
130 |
$post = apply_filters( 'wpcf_filter_wpcf_admin_get_current_edited_post', null );
|
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 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class WPCF_WPViews {
|
4 |
+
|
5 |
+
static $types_shortcodes_assets_added = false;
|
6 |
+
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Init called from WPCF_Loader.
|
10 |
+
*/
|
11 |
+
public static function init() {
|
12 |
+
add_action( 'load-post.php', array(
|
13 |
+
'WPCF_WPViews',
|
14 |
+
'wpcf_wpv_admin_post_add_postmeta_usermeta_to_editor_js'
|
15 |
+
) );
|
16 |
+
add_action( 'load-post-new.php', array(
|
17 |
+
'WPCF_WPViews',
|
18 |
+
'wpcf_wpv_admin_post_add_postmeta_usermeta_to_editor_js'
|
19 |
+
) );
|
20 |
+
add_action( 'views_edit_screen', array( 'WPCF_WPViews', 'editScreenInit' ) );
|
21 |
+
add_action( 'layouts_edit_screen', array( 'WPCF_WPViews', 'editScreenInit' ) );
|
22 |
add_action( 'current_screen', array( 'WPCF_WPViews', 'include_types_fields_on_views_dialog_on_demand' ) );
|
23 |
+
add_action( 'views_ct_inline_editor', array( 'WPCF_WPViews', 'addEditorDropdownFilter' ) );
|
24 |
+
add_action( 'wpv_action_wpv_add_types_postmeta_usermeta_to_editor_menus', array(
|
25 |
+
'WPCF_WPViews',
|
26 |
+
'addEditorDropdownFilter'
|
27 |
+
) );
|
28 |
+
|
29 |
+
WPCF_WPViews::register_types_shortcodes_dialog_groups();
|
30 |
+
add_action( 'wpv_action_wpv_enforce_shortcodes_assets', array(
|
31 |
+
'WPCF_WPViews',
|
32 |
+
'enforce_types_shortcodes_assets'
|
33 |
+
) );
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Register the Types meta fields groups into the Fields and Views dialog for Views.
|
39 |
+
*
|
40 |
+
* Depending on the current admin page, we register different meta types (post, term, user),
|
41 |
+
* and also only for some targets (posts, taxonomy, users) et by the Fields and Views button itself.
|
42 |
+
*
|
43 |
+
* @note We keep the old registering mechanism too as it is needed by the Views Loop Wizard,
|
44 |
+
* and for backwards compatibility.
|
45 |
+
*
|
46 |
+
* @since 2.2.7
|
47 |
+
*/
|
48 |
+
public static function register_types_shortcodes_dialog_groups() {
|
49 |
+
|
50 |
+
global $pagenow;
|
51 |
+
|
52 |
+
if (
|
53 |
+
$pagenow == 'admin.php'
|
54 |
+
&& isset( $_GET['page'] )
|
55 |
+
&& in_array( $_GET['page'], array(
|
56 |
+
'views-editor',
|
57 |
+
'ct-editor',
|
58 |
+
'view-archives-editor',
|
59 |
+
'dd_layouts_edit'
|
60 |
+
) )
|
61 |
+
) {
|
62 |
+
// We are on a Views object edit page, so add all Types postmeta groups and usermeta groups
|
63 |
+
// We can also be on a Layouts object edit page, so we add all postmeta and usermeta groups too
|
64 |
+
WPCF_WPViews::register_types_postmeta_shortcodes_dialog_groups();
|
65 |
+
WPCF_WPViews::register_types_termmeta_shortcodes_dialog_groups();
|
66 |
+
WPCF_WPViews::register_types_usermeta_shortcodes_dialog_groups();
|
67 |
+
} else if ( in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) {
|
68 |
+
// We are on a post edit page, add the relevant(?) postmeta and usermeta groups
|
69 |
+
WPCF_WPViews::register_types_postmeta_shortcodes_dialog_groups();
|
70 |
+
WPCF_WPViews::register_types_usermeta_shortcodes_dialog_groups();
|
71 |
+
} else if ( in_array( $pagenow, array( 'term.php' ) ) ) {
|
72 |
+
WPCF_WPViews::register_types_termmeta_shortcodes_dialog_groups();
|
73 |
+
} else if ( in_array( $pagenow, array( 'profile.php', 'user-new.php', 'user-edit.php' ) ) ) {
|
74 |
+
WPCF_WPViews::register_types_usermeta_shortcodes_dialog_groups();
|
75 |
+
} else {
|
76 |
+
WPCF_WPViews::register_types_postmeta_shortcodes_dialog_groups();
|
77 |
+
WPCF_WPViews::register_types_usermeta_shortcodes_dialog_groups();
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Enforce the Types shortcodes assets when registered in a Fields and Views dialog.
|
85 |
+
*
|
86 |
+
* @note Only enforce this one per requst, by using the $types_shortcodes_assets_added boolean flag.
|
87 |
+
*
|
88 |
+
* @since 2.2.7
|
89 |
+
*/
|
90 |
+
public static function enforce_types_shortcodes_assets() {
|
91 |
+
if ( WPCF_WPViews::$types_shortcodes_assets_added ) {
|
92 |
+
return;
|
93 |
+
}
|
94 |
+
if ( ! is_admin() ) {
|
95 |
+
$types_fields_shortcodes_settings = array(
|
96 |
+
'wpnonce' => wp_create_nonce( '_typesnonce' ),
|
97 |
+
'validation' => array()
|
98 |
+
);
|
99 |
+
echo '
|
100 |
+
<style>
|
101 |
+
#colorbox.js-wpcf-colorbox-with-iframe { z-index: 110000 !important; }
|
102 |
+
</style>
|
103 |
+
<script type="text/javascript">
|
104 |
+
//<![CDATA[
|
105 |
+
var types = ' . json_encode( $types_fields_shortcodes_settings ) . ';
|
106 |
+
//]]>
|
107 |
+
</script>';
|
108 |
+
}
|
109 |
+
wp_enqueue_script( 'types' );
|
110 |
+
wp_enqueue_script( 'types-wp-views' );
|
111 |
+
wp_enqueue_script( 'toolset-colorbox' );
|
112 |
+
wp_enqueue_style( 'toolset-colorbox' );
|
113 |
+
WPCF_WPViews::$types_shortcodes_assets_added = true;
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Register postmeta fields groups in the relevant Fields and Views dialogs.
|
119 |
+
* Should work in backend and frontend.
|
120 |
+
*
|
121 |
+
* @since 2.2.7
|
122 |
+
*/
|
123 |
+
public static function register_types_postmeta_shortcodes_dialog_groups() {
|
124 |
+
$current_post = WPCF_WPViews::get_current_post();
|
125 |
+
$groups = wpcf_admin_fields_get_groups( TYPES_CUSTOM_FIELD_GROUP_CPT_NAME, 'group_active' );
|
126 |
+
$all_post_types = implode( ' ', get_post_types( array( 'public' => true ) ) );
|
127 |
+
if ( ! empty( $groups ) ) {
|
128 |
+
foreach ( $groups as $group ) {
|
129 |
+
$fields = wpcf_admin_fields_get_fields_by_group( $group['id'], 'slug', true, false, true );
|
130 |
+
if ( ! empty( $fields ) ) {
|
131 |
+
|
132 |
+
$group_id = 'types-postmeta-' . $group['id'];
|
133 |
+
$group_data = array(
|
134 |
+
'name' => $group['name'],
|
135 |
+
'target' => array( 'posts' ),
|
136 |
+
'fields' => array()
|
137 |
+
);
|
138 |
+
|
139 |
+
foreach ( $fields as $field ) {
|
140 |
+
$group_data['fields'][ $field['id'] ] = array(
|
141 |
+
'name' => stripslashes( $field['name'] ),
|
142 |
+
'shortcode' => trim( wpcf_fields_get_shortcode( $field ), '[]' ),
|
143 |
+
'callback' => 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $current_post->ID . ')'
|
144 |
+
);
|
145 |
+
}
|
146 |
+
|
147 |
+
do_action( 'wpv_action_wpv_register_dialog_group', $group_id, $group_data );
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Register termmeta fields groups in the relevant Fields and Views dialogs.
|
156 |
+
* Should work in backend and frontend.
|
157 |
+
*
|
158 |
+
* @todo set the target to posts when on a WPA edit page
|
159 |
+
*
|
160 |
+
* @since 2.2.7
|
161 |
+
*/
|
162 |
+
public static function register_types_termmeta_shortcodes_dialog_groups() {
|
163 |
+
//Get types groups and fields
|
164 |
+
$groups = wpcf_admin_fields_get_groups( TYPES_TERM_META_FIELD_GROUP_CPT_NAME, 'group_active' );
|
165 |
+
$add = array();
|
166 |
+
if ( ! empty( $groups ) ) {
|
167 |
+
foreach ( $groups as $group_id => $group ) {
|
168 |
+
$fields = wpcf_admin_fields_get_fields_by_group( $group['id'], 'slug', true, false, true, TYPES_TERM_META_FIELD_GROUP_CPT_NAME, 'wpcf-termmeta' );
|
169 |
+
if ( ! empty( $fields ) ) {
|
170 |
+
|
171 |
+
$group_id = 'types-termmeta-' . $group['id'];
|
172 |
+
$group_data = array(
|
173 |
+
'name' => $group['name'],
|
174 |
+
'target' => array( 'taxonomy' ),
|
175 |
+
'fields' => array()
|
176 |
+
);
|
177 |
+
|
178 |
+
foreach ( $fields as $field_id => $field ) {
|
179 |
+
$group_data['fields'][ $field['id'] ] = array(
|
180 |
+
'name' => stripslashes( $field['name'] ),
|
181 |
+
'shortcode' => 'types termmeta="' . $field['id'] . '"][/types',
|
182 |
+
'callback' => 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'views-termmeta\', -1)'
|
183 |
+
);
|
184 |
+
}
|
185 |
+
|
186 |
+
do_action( 'wpv_action_wpv_register_dialog_group', $group_id, $group_data );
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Register usermeta fields groups in the relevant Fields and Views dialogs.
|
195 |
+
* Should work in backend and frontend.
|
196 |
+
*
|
197 |
+
* @note We register each group twice for post-based edit pags and for user-based edit pages,
|
198 |
+
* including an "(Usermeta fields)" group name suffix in the first case.
|
199 |
+
*
|
200 |
+
* @since 2.2.7
|
201 |
+
*/
|
202 |
+
public static function register_types_usermeta_shortcodes_dialog_groups() {
|
203 |
+
global $wpcf;
|
204 |
+
$current_post = WPCF_WPViews::get_current_post();
|
205 |
+
$groups = wpcf_admin_fields_get_groups( TYPES_USER_META_FIELD_GROUP_CPT_NAME, 'group_active' );
|
206 |
+
$user_id = wpcf_usermeta_get_user();
|
207 |
+
if ( ! empty( $groups ) ) {
|
208 |
+
foreach ( $groups as $group_id => $group ) {
|
209 |
+
$group_name = sprintf( __( '%s (Usermeta fields)', 'wpcf' ), $group['name'] );
|
210 |
+
$fields = wpcf_admin_fields_get_fields_by_group( $group['id'], 'slug', true, false, true, TYPES_USER_META_FIELD_GROUP_CPT_NAME, 'wpcf-usermeta' );
|
211 |
+
if ( ! empty( $fields ) ) {
|
212 |
+
|
213 |
+
$group_id_generic = 'types-usermeta-generic-' . $group['id'];
|
214 |
+
$group_data_generic = array(
|
215 |
+
'name' => sprintf( __( '%s (Usermeta fields)', 'wpcf' ), $group['name'] ),
|
216 |
+
'target' => array( 'posts' ),
|
217 |
+
'fields' => array()
|
218 |
+
);
|
219 |
+
|
220 |
+
$group_id_specific = 'types-usermeta-specific-' . $group['id'];
|
221 |
+
$group_data_specific = array(
|
222 |
+
'name' => $group['name'],
|
223 |
+
'target' => array( 'users' ),
|
224 |
+
'fields' => array()
|
225 |
+
);
|
226 |
+
|
227 |
+
foreach ( $fields as $field_id => $field ) {
|
228 |
+
|
229 |
+
$group_data_generic['fields'][ $field['id'] ] = array(
|
230 |
+
'name' => stripslashes( $field['name'] ),
|
231 |
+
'shortcode' => trim( wpcf_usermeta_get_shortcode( $field ), '[]' ),
|
232 |
+
'callback' => 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'usermeta\', ' . $current_post->ID . ')'
|
233 |
+
);
|
234 |
+
|
235 |
+
$group_data_specific['fields'][ $field['id'] ] = array(
|
236 |
+
'name' => stripslashes( $field['name'] ),
|
237 |
+
'shortcode' => trim( wpcf_usermeta_get_shortcode( $field ), '[]' ),
|
238 |
+
'callback' => 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'views-usermeta\', ' . $current_post->ID . ')'
|
239 |
+
);
|
240 |
+
|
241 |
+
}
|
242 |
+
|
243 |
+
do_action( 'wpv_action_wpv_register_dialog_group', $group_id_generic, $group_data_generic );
|
244 |
+
do_action( 'wpv_action_wpv_register_dialog_group', $group_id_specific, $group_data_specific );
|
245 |
+
|
246 |
+
}
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
|
252 |
/**
|
253 |
+
* Get the currently edited post eithwe in backend or frontend, if any, or a dummy object otherwise.
|
254 |
+
*
|
255 |
+
* In the backend, uses the wpcf_filter_wpcf_admin_get_current_edited_post which gets the current post
|
256 |
+
* based on GET, POST parameters and also the global $post_id.
|
257 |
+
* In the frontend, uses the global $post.
|
258 |
+
*
|
259 |
+
* @return WP_Post|object
|
260 |
+
*
|
261 |
+
* @since 2.2.7
|
262 |
+
*/
|
263 |
+
public static function get_current_post() {
|
264 |
+
|
265 |
+
if ( is_admin() ) {
|
266 |
+
$current_post = apply_filters( 'wpcf_filter_wpcf_admin_get_current_edited_post', null );
|
267 |
+
if ( ! $current_post ) {
|
268 |
+
$current_post = (object) array( 'ID' => - 1 );
|
269 |
+
}
|
270 |
+
} else {
|
271 |
+
global $post;
|
272 |
+
if ( $post instanceof WP_Post ) {
|
273 |
+
$current_post = $post;
|
274 |
+
} else {
|
275 |
+
$current_post = (object) array( 'ID' => - 1 );
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
return $current_post;
|
280 |
+
|
281 |
+
}
|
282 |
+
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Include the Types custom fields and usermeta fields, along with the needed scripts to mange them,
|
286 |
+
* in the Fields and Views dialog, on demand.
|
287 |
+
*
|
288 |
+
* @param $current_screen
|
289 |
+
*/
|
290 |
public static function include_types_fields_on_views_dialog_on_demand( $current_screen ) {
|
291 |
+
|
292 |
/**
|
293 |
+
* wpcf_filter_force_include_types_fields_on_views_dialog
|
294 |
+
*
|
295 |
+
* Force include the Types fields and usermeta fields as groups on the Fields and Views popup.
|
296 |
+
* This adds assets as well as menu items.
|
297 |
+
* Note that this happens on current_screen so this filter need to be added before that.
|
298 |
+
*
|
299 |
+
* @param (bool) Whether to include those items or not.
|
300 |
+
* @param $current_screen (object) The current WP_Screen object.
|
301 |
+
*
|
302 |
+
* @since 1.7
|
303 |
+
*/
|
304 |
$force_include_types_in_fields_and_views_dialog = apply_filters( 'wpcf_filter_force_include_types_fields_on_views_dialog', false, $current_screen );
|
305 |
+
|
306 |
if ( $force_include_types_in_fields_and_views_dialog ) {
|
307 |
self::editScreenInit();
|
308 |
}
|
309 |
}
|
310 |
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Actions for Views edit screens.
|
314 |
+
*/
|
315 |
+
public static function editScreenInit() {
|
316 |
if ( ! wp_script_is( 'types', 'enqueued' ) ) {
|
317 |
wp_enqueue_script( 'types' );
|
318 |
}
|
325 |
if ( ! wp_style_is( 'toolset-colorbox', 'enqueued' ) ) {
|
326 |
wp_enqueue_style( 'toolset-colorbox' );
|
327 |
}
|
328 |
+
self::addEditorDropdownFilter();
|
329 |
+
}
|
330 |
+
|
331 |
+
|
332 |
+
/**
|
333 |
+
* Adds filtering editor dropdown items.
|
334 |
+
*/
|
335 |
+
public static function addEditorDropdownFilter() {
|
336 |
+
add_filter( 'editor_addon_menus_wpv-views',
|
337 |
+
array( 'WPCF_WPViews', 'editorDropdownFilter' ) );
|
338 |
+
add_filter( 'editor_addon_menus_wpv-views',
|
339 |
+
'wpcf_admin_post_add_usermeta_to_editor_js', 20 );
|
340 |
+
}
|
341 |
+
|
342 |
+
|
343 |
public static function wpcf_wpv_admin_post_add_postmeta_usermeta_to_editor_js() {
|
344 |
+
add_action( 'wpv_action_wpv_add_types_postmeta_to_editor', array(
|
345 |
+
'WPCF_WPViews',
|
346 |
+
'wpcf_admin_post_add_postmeta_to_editor_on_demand'
|
347 |
+
) );
|
348 |
+
add_action( 'wpv_action_wpv_add_types_post_usermeta_to_editor', array(
|
349 |
+
'WPCF_WPViews',
|
350 |
+
'wpcf_admin_post_add_usermeta_to_editor_on_demand'
|
351 |
+
) );
|
352 |
}
|
353 |
+
|
354 |
+
|
355 |
public static function wpcf_admin_post_add_postmeta_to_editor_on_demand( $editor ) {
|
356 |
add_action( 'admin_footer', 'wpcf_admin_post_js_validation' );
|
357 |
wpcf_enqueue_scripts();
|
358 |
+
wp_enqueue_script( 'toolset-colorbox' );
|
359 |
+
wp_enqueue_style( 'toolset-colorbox' );
|
360 |
+
|
361 |
$current_post = apply_filters( 'wpcf_filter_wpcf_admin_get_current_edited_post', null );
|
362 |
if ( empty( $current_post ) ) {
|
363 |
+
$current_post = (object) array( 'ID' => - 1 );
|
364 |
}
|
365 |
|
366 |
$fields = wpcf_admin_post_add_to_editor( 'get' );
|
367 |
$groups = wpcf_admin_post_get_post_groups_fields( $current_post );
|
368 |
+
if (
|
369 |
+
! empty( $fields )
|
370 |
+
&& ! empty( $groups )
|
371 |
) {
|
372 |
foreach ( $groups as $group ) {
|
373 |
if ( empty( $group['fields'] ) ) {
|
374 |
continue;
|
375 |
}
|
376 |
foreach ( $group['fields'] as $group_field_id => $group_field ) {
|
377 |
+
if ( isset( $fields[ $group_field_id ] ) ) {
|
378 |
+
$field = $fields[ $group_field_id ];
|
379 |
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $current_post->ID . ')';
|
380 |
+
$editor->add_insert_shortcode_menu(
|
381 |
stripslashes( $field['name'] ),
|
382 |
trim( wpcf_fields_get_shortcode( $field ), '[]' ),
|
383 |
$group['name'],
|
384 |
+
$callback
|
385 |
);
|
386 |
}
|
387 |
}
|
388 |
}
|
389 |
}
|
390 |
}
|
391 |
+
|
392 |
+
|
393 |
public static function wpcf_admin_post_add_usermeta_to_editor_on_demand() {
|
394 |
add_action( 'admin_footer', 'wpcf_admin_post_js_validation' );
|
395 |
wpcf_enqueue_scripts();
|
396 |
+
wp_enqueue_script( 'toolset-colorbox' );
|
397 |
+
wp_enqueue_style( 'toolset-colorbox' );
|
398 |
add_filter( 'editor_addon_menus_wpv-views', 'wpcf_admin_post_add_usermeta_to_editor_js' );
|
399 |
}
|
400 |
|
401 |
+
|
402 |
+
/**
|
403 |
+
* Adds items to view dropdown.
|
404 |
+
*
|
405 |
+
* @param $menu
|
406 |
+
*
|
407 |
+
* @return mixed
|
408 |
+
*/
|
409 |
+
public static function editorDropdownFilter( $menu ) {
|
410 |
$post = apply_filters( 'wpcf_filter_wpcf_admin_get_current_edited_post', null );
|
411 |
+
if ( ! $post ) {
|
412 |
+
$post = (object) array( 'ID' => - 1 );
|
413 |
+
}
|
414 |
+
$groups = wpcf_admin_fields_get_groups( TYPES_CUSTOM_FIELD_GROUP_CPT_NAME, 'group_active' );
|
415 |
+
$all_post_types = implode( ' ',
|
416 |
+
get_post_types( array( 'public' => true ) ) );
|
417 |
+
$add = array();
|
418 |
+
if ( ! empty( $groups ) ) {
|
419 |
+
// $group_id is blank therefore not equal to $group['id']
|
420 |
+
// use array for item key and CSS class
|
421 |
+
$item_styles = array();
|
422 |
+
|
423 |
+
foreach ( $groups as $group ) {
|
424 |
+
$fields = wpcf_admin_fields_get_fields_by_group( $group['id'],
|
425 |
+
'slug', true, false, true );
|
426 |
+
if ( ! empty( $fields ) ) {
|
427 |
+
// code from Types used here without breaking the flow
|
428 |
+
// get post types list for every group or apply all
|
429 |
+
$post_types = get_post_meta( $group['id'],
|
430 |
+
'_wp_types_group_post_types', true );
|
431 |
+
if ( $post_types == 'all' ) {
|
432 |
+
$post_types = $all_post_types;
|
433 |
+
}
|
434 |
+
$post_types = trim( str_replace( ',', ' ', $post_types ) );
|
435 |
+
$item_styles[ $group['name'] ] = $post_types;
|
436 |
+
|
437 |
+
foreach ( $fields as $field ) {
|
438 |
+
$callback = 'wpcfFieldsEditorCallback(\'' . $field['id']
|
439 |
+
. '\', \'postmeta\', ' . $post->ID . ')';
|
440 |
+
$menu[ $group['name'] ][ stripslashes( $field['name'] ) ] = array(
|
441 |
+
stripslashes( $field['name'] ),
|
442 |
+
trim( wpcf_fields_get_shortcode( $field ),
|
443 |
+
'[]' ),
|
444 |
+
$group['name'],
|
445 |
+
$callback
|
446 |
+
);
|
447 |
+
// TODO Remove - it's not post edit screen (meta box JS and CSS)
|
448 |
+
WPCF_Fields::enqueueScript( $field['type'] );
|
449 |
+
WPCF_Fields::enqueueStyle( $field['type'] );
|
450 |
+
}
|
451 |
+
}
|
452 |
+
}
|
453 |
+
}
|
454 |
+
|
455 |
+
return $menu;
|
456 |
+
}
|
457 |
|
458 |
}
|
library/toolset/types/embedded/functions.php
CHANGED
@@ -627,40 +627,36 @@ function wpcf_enqueue_scripts()
|
|
627 |
* Load all scripts required on edit post screen.
|
628 |
*
|
629 |
* @since 1.2.1
|
630 |
-
* @todo Make loading JS more clear for all components.
|
631 |
*/
|
632 |
-
function wpcf_edit_post_screen_scripts()
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
array('wpcf-css-embedded'), WPCF_VERSION );
|
655 |
-
wp_enqueue_script( 'toolset-colorbox' );
|
656 |
-
wp_enqueue_style( 'toolset-colorbox' );
|
657 |
-
wp_enqueue_style( 'font-awesome' );
|
658 |
}
|
659 |
|
660 |
/**
|
661 |
* Check if running embedded version.
|
662 |
*
|
663 |
-
* @return
|
|
|
664 |
*/
|
665 |
function wpcf_is_embedded()
|
666 |
{
|
@@ -735,8 +731,11 @@ function wpcf_field_enqueue_scripts($type)
|
|
735 |
* Get file URL.
|
736 |
*
|
737 |
* @uses WPCF_Path (functions taken from CRED_Loader)
|
738 |
-
*
|
739 |
-
* @
|
|
|
|
|
|
|
740 |
*/
|
741 |
function wpcf_get_file_url($file, $use_baseurl = true)
|
742 |
{
|
627 |
* Load all scripts required on edit post screen.
|
628 |
*
|
629 |
* @since 1.2.1
|
|
|
630 |
*/
|
631 |
+
function wpcf_edit_post_screen_scripts() {
|
632 |
+
wpcf_enqueue_scripts();
|
633 |
+
|
634 |
+
$asset_manager = Types_Asset_Manager::get_instance();
|
635 |
+
$asset_manager->enqueue_scripts(
|
636 |
+
array(
|
637 |
+
Types_Asset_Manager::SCRIPT_JQUERY_UI_VALIDATION,
|
638 |
+
Types_Asset_Manager::SCRIPT_ADDITIONAL_VALIDATION_RULES,
|
639 |
+
)
|
640 |
+
);
|
641 |
+
|
642 |
+
wp_enqueue_style( 'wpcf-css-embedded',
|
643 |
+
WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION );
|
644 |
+
wp_enqueue_style( 'wpcf-fields-post',
|
645 |
+
WPCF_EMBEDDED_RES_RELPATH . '/css/fields-post.css',
|
646 |
+
array( 'wpcf-css-embedded' ), WPCF_VERSION );
|
647 |
+
wp_enqueue_style( 'wpcf-usermeta',
|
648 |
+
WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css',
|
649 |
+
array( 'wpcf-css-embedded' ), WPCF_VERSION );
|
650 |
+
wp_enqueue_script( 'toolset-colorbox' );
|
651 |
+
wp_enqueue_style( 'toolset-colorbox' );
|
652 |
+
wp_enqueue_style( 'font-awesome' );
|
|
|
|
|
|
|
|
|
653 |
}
|
654 |
|
655 |
/**
|
656 |
* Check if running embedded version.
|
657 |
*
|
658 |
+
* @return boolean
|
659 |
+
* @deprecated
|
660 |
*/
|
661 |
function wpcf_is_embedded()
|
662 |
{
|
731 |
* Get file URL.
|
732 |
*
|
733 |
* @uses WPCF_Path (functions taken from CRED_Loader)
|
734 |
+
*
|
735 |
+
* @param string $file
|
736 |
+
* @param bool $use_baseurl
|
737 |
+
*
|
738 |
+
* @return string
|
739 |
*/
|
740 |
function wpcf_get_file_url($file, $use_baseurl = true)
|
741 |
{
|
library/toolset/types/embedded/includes/fields-post.php
CHANGED
@@ -619,35 +619,20 @@ function wpcf_admin_post_save_post_hook( $post_ID, $post ) {
|
|
619 |
return;
|
620 |
}
|
621 |
|
622 |
-
$
|
623 |
-
if ( ! empty( $_POST['wpcf'] ) ) {
|
624 |
-
$_post_wpcf = $_POST['wpcf'];
|
625 |
-
}
|
626 |
-
|
627 |
-
// handle checkbox
|
628 |
-
if ( array_key_exists( '_wptoolset_checkbox', $_POST ) && is_array( $_POST['_wptoolset_checkbox'] ) ) {
|
629 |
-
foreach ( $_POST['_wptoolset_checkbox'] as $key => $field_value ) {
|
630 |
-
$field_slug = preg_replace( '/^wpcf\-/', '', $key );
|
631 |
-
if ( array_key_exists( $field_slug, $_post_wpcf ) ) {
|
632 |
-
continue;
|
633 |
-
}
|
634 |
-
$_post_wpcf[ $field_slug ] = false;
|
635 |
-
}
|
636 |
-
}
|
637 |
|
638 |
-
//
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
continue;
|
644 |
-
}
|
645 |
-
$_post_wpcf[ $field_slug ] = false;
|
646 |
-
}
|
647 |
-
}
|
648 |
|
|
|
|
|
|
|
|
|
649 |
|
650 |
-
if ( count( $
|
651 |
$add_error_message = true;
|
652 |
if ( isset( $_POST['post_id'] ) && $_POST['post_id'] != $post_ID ) {
|
653 |
$add_error_message = false;
|
@@ -661,7 +646,7 @@ function wpcf_admin_post_save_post_hook( $post_ID, $post ) {
|
|
661 |
$images_to_delete[ $image ] = 1;
|
662 |
}
|
663 |
}
|
664 |
-
foreach ( $
|
665 |
// Get field by slug
|
666 |
$field = wpcf_fields_get_field_by_slug( $field_slug );
|
667 |
if ( empty( $field ) ) {
|
@@ -680,7 +665,7 @@ function wpcf_admin_post_save_post_hook( $post_ID, $post ) {
|
|
680 |
$_field_value = ! types_is_repetitive( $field ) ? array( $field_value ) : $field_value;
|
681 |
|
682 |
// Set config
|
683 |
-
$config = wptoolset_form_filter_types_field( $field, $post_ID, $
|
684 |
|
685 |
// remove from images_to_delete if user add again
|
686 |
if ( $delete_attachments && 'image' == $config['type'] ) {
|
@@ -717,7 +702,8 @@ function wpcf_admin_post_save_post_hook( $post_ID, $post ) {
|
|
717 |
}
|
718 |
}
|
719 |
}
|
720 |
-
remove_filter( 'toolset_common_validation_add_field_name_to_error', '__return_false', 1234
|
|
|
721 |
// Save field
|
722 |
if ( types_is_repetitive( $field ) ) {
|
723 |
$wpcf->repeater->set( $post_ID, $field );
|
@@ -727,22 +713,11 @@ function wpcf_admin_post_save_post_hook( $post_ID, $post ) {
|
|
727 |
$wpcf->field->save( $field_value );
|
728 |
}
|
729 |
do_action( 'wpcf_post_field_saved', $post_ID, $field );
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
if ( ! isset( $_POST['wpcf'][ $field['id'] ][ $option_id ] ) ) {
|
736 |
-
if ( isset( $field['data']['save_empty'] ) && $field['data']['save_empty'] == 'yes' ) {
|
737 |
-
$update_data[ $option_id ] = 0;
|
738 |
-
}
|
739 |
-
} else {
|
740 |
-
$update_data[ $option_id ] = $_POST['wpcf'][ $field['id'] ][ $option_id ];
|
741 |
-
}
|
742 |
-
}
|
743 |
-
update_post_meta( $post_ID, $field['meta_key'], $update_data );
|
744 |
-
}
|
745 |
-
}
|
746 |
}
|
747 |
|
748 |
// delete images
|
@@ -765,8 +740,6 @@ function wpcf_admin_post_save_post_hook( $post_ID, $post ) {
|
|
765 |
update_post_meta( $post_ID, '__wpcf-invalid-fields', true );
|
766 |
}
|
767 |
do_action( 'wpcf_post_saved', $post_ID );
|
768 |
-
|
769 |
-
return;
|
770 |
}
|
771 |
|
772 |
|
619 |
return;
|
620 |
}
|
621 |
|
622 |
+
$wpcf_form_data = wpcf_ensarr( wpcf_getarr( $_POST, 'wpcf' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
623 |
|
624 |
+
// Check wpcf_adjust_form_input_for_checkboxlike_fields() for information about side effects.
|
625 |
+
$wpcf_form_data = wpcf_adjust_form_input_for_checkboxlike_fields(
|
626 |
+
$wpcf_form_data,
|
627 |
+
wpcf_ensarr( wpcf_getarr( $_POST, '_wptoolset_checkbox' ) )
|
628 |
+
);
|
|
|
|
|
|
|
|
|
|
|
629 |
|
630 |
+
$wpcf_form_data = wpcf_adjust_form_input_for_checkboxlike_fields(
|
631 |
+
$wpcf_form_data,
|
632 |
+
wpcf_ensarr( wpcf_getarr( $_POST, '_wptoolset_radios' ) )
|
633 |
+
);
|
634 |
|
635 |
+
if ( count( $wpcf_form_data ) ) {
|
636 |
$add_error_message = true;
|
637 |
if ( isset( $_POST['post_id'] ) && $_POST['post_id'] != $post_ID ) {
|
638 |
$add_error_message = false;
|
646 |
$images_to_delete[ $image ] = 1;
|
647 |
}
|
648 |
}
|
649 |
+
foreach ( $wpcf_form_data as $field_slug => $field_value ) {
|
650 |
// Get field by slug
|
651 |
$field = wpcf_fields_get_field_by_slug( $field_slug );
|
652 |
if ( empty( $field ) ) {
|
665 |
$_field_value = ! types_is_repetitive( $field ) ? array( $field_value ) : $field_value;
|
666 |
|
667 |
// Set config
|
668 |
+
$config = wptoolset_form_filter_types_field( $field, $post_ID, $wpcf_form_data );
|
669 |
|
670 |
// remove from images_to_delete if user add again
|
671 |
if ( $delete_attachments && 'image' == $config['type'] ) {
|
702 |
}
|
703 |
}
|
704 |
}
|
705 |
+
remove_filter( 'toolset_common_validation_add_field_name_to_error', '__return_false', 1234 );
|
706 |
+
|
707 |
// Save field
|
708 |
if ( types_is_repetitive( $field ) ) {
|
709 |
$wpcf->repeater->set( $post_ID, $field );
|
713 |
$wpcf->field->save( $field_value );
|
714 |
}
|
715 |
do_action( 'wpcf_post_field_saved', $post_ID, $field );
|
716 |
+
|
717 |
+
// Note: Checkboxes fields used to be handled as a special case here, that was now moved
|
718 |
+
// to wpcf_update_checkboxes_field() and is executed on *each* save_post by
|
719 |
+
// wpcf_fields_checkbox_save_check().
|
720 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
721 |
}
|
722 |
|
723 |
// delete images
|
740 |
update_post_meta( $post_ID, '__wpcf-invalid-fields', true );
|
741 |
}
|
742 |
do_action( 'wpcf_post_saved', $post_ID );
|
|
|
|
|
743 |
}
|
744 |
|
745 |
|
library/toolset/types/embedded/includes/fields.php
CHANGED
@@ -367,10 +367,10 @@ function wpcf_admin_fields_get_field( $field_id, $only_active = false,
|
|
367 |
|
368 |
/**
|
369 |
* Gets field by slug.
|
370 |
-
* Modified by Gen, 13.02.2013
|
371 |
*
|
372 |
-
* @param
|
373 |
-
* @
|
|
|
374 |
*/
|
375 |
function wpcf_fields_get_field_by_slug( $slug, $meta_name = 'wpcf-fields' ) {
|
376 |
return wpcf_admin_fields_get_field( $slug, false, false, false, $meta_name );
|
@@ -942,26 +942,34 @@ function wpcf_admin_fields_get_groups_by_field( $field_id,
|
|
942 |
/**
|
943 |
* Saves last field settings when inserting from toolbar.
|
944 |
*
|
945 |
-
* @param
|
946 |
-
* @param
|
947 |
-
* @param
|
|
|
948 |
*/
|
949 |
-
function wpcf_admin_fields_save_field_last_settings(
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
|
|
|
|
|
|
|
|
959 |
}
|
960 |
|
|
|
961 |
/**
|
962 |
* Gets last field settings when inserting from toolbar.
|
963 |
*
|
964 |
-
* @param
|
|
|
|
|
965 |
*/
|
966 |
function wpcf_admin_fields_get_field_last_settings( $field_id ) {
|
967 |
$data = get_user_meta( get_current_user_id(), 'wpcf-field-settings', true );
|
@@ -1044,3 +1052,40 @@ function wpcf_get_all_field_slugs_except_current_group( $current_group = false )
|
|
1044 |
return $all_slugs;
|
1045 |
}
|
1046 |
add_action('wp_ajax_wpcf_get_all_field_slugs_except_current_group', 'wpcf_get_all_field_slugs_except_current_group');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
|
368 |
/**
|
369 |
* Gets field by slug.
|
|
|
370 |
*
|
371 |
+
* @param string $slug
|
372 |
+
* @param string $meta_name
|
373 |
+
* @return array
|
374 |
*/
|
375 |
function wpcf_fields_get_field_by_slug( $slug, $meta_name = 'wpcf-fields' ) {
|
376 |
return wpcf_admin_fields_get_field( $slug, false, false, false, $meta_name );
|
942 |
/**
|
943 |
* Saves last field settings when inserting from toolbar.
|
944 |
*
|
945 |
+
* @param $field_id
|
946 |
+
* @param $settings
|
947 |
+
* @param bool $append
|
948 |
+
* @param bool $overwrite
|
949 |
*/
|
950 |
+
function wpcf_admin_fields_save_field_last_settings(
|
951 |
+
$field_id, $settings, $append = false, $overwrite = false
|
952 |
+
) {
|
953 |
+
$data = wpcf_ensarr( get_user_meta( get_current_user_id(), 'wpcf-field-settings', true ) );
|
954 |
+
if ( $append && isset( $data[ $field_id ] ) && is_array( $data[ $field_id ] ) ) {
|
955 |
+
$data[ $field_id ] = (
|
956 |
+
$overwrite
|
957 |
+
? array_merge( $data[ $field_id ], $settings )
|
958 |
+
: array_merge( $settings, $data[ $field_id ] )
|
959 |
+
);
|
960 |
+
} else {
|
961 |
+
$data[ $field_id ] = $settings;
|
962 |
+
}
|
963 |
+
update_user_meta( get_current_user_id(), 'wpcf-field-settings', $data );
|
964 |
}
|
965 |
|
966 |
+
|
967 |
/**
|
968 |
* Gets last field settings when inserting from toolbar.
|
969 |
*
|
970 |
+
* @param $field_id
|
971 |
+
*
|
972 |
+
* @return array
|
973 |
*/
|
974 |
function wpcf_admin_fields_get_field_last_settings( $field_id ) {
|
975 |
$data = get_user_meta( get_current_user_id(), 'wpcf-field-settings', true );
|
1052 |
return $all_slugs;
|
1053 |
}
|
1054 |
add_action('wp_ajax_wpcf_get_all_field_slugs_except_current_group', 'wpcf_get_all_field_slugs_except_current_group');
|
1055 |
+
|
1056 |
+
|
1057 |
+
/**
|
1058 |
+
* Helper function used on submitting a form with custom fields.
|
1059 |
+
*
|
1060 |
+
* When there's nothing checked in a checkbox/checkboxes/radio fields, there is no corresponding element
|
1061 |
+
* in $_POST['wpcf'][ $field_slug ], which would lead to _not removing_ the value from the database because of
|
1062 |
+
* the way the submission data is further processed.
|
1063 |
+
*
|
1064 |
+
* Here, we just create the key for the field without any further notification, and actual saving
|
1065 |
+
* these fields' values will be handled later as a special case via wpcf_update_checkboxes_field().
|
1066 |
+
*
|
1067 |
+
* @param array $wpcf_form_data Form data, usually coming from $_POST['wpcf'].
|
1068 |
+
* @param array $fields An associative array with checkbox/checkboxes/radio fields,
|
1069 |
+
* where keys are field slugs with the 'wpcf-' prefix.
|
1070 |
+
*
|
1071 |
+
* @return array Updated form data with added keys for provided fields.
|
1072 |
+
* @since 2.2.7
|
1073 |
+
*/
|
1074 |
+
function wpcf_adjust_form_input_for_checkboxlike_fields( $wpcf_form_data, $fields ) {
|
1075 |
+
|
1076 |
+
if( ! is_array( $wpcf_form_data ) ) {
|
1077 |
+
return array();
|
1078 |
+
}
|
1079 |
+
|
1080 |
+
if( is_array( $fields ) ) {
|
1081 |
+
foreach ( $fields as $field_key => $field_value ) {
|
1082 |
+
$field_slug = preg_replace( '/^wpcf\-/', '', $field_key );
|
1083 |
+
if ( array_key_exists( $field_slug, $wpcf_form_data ) ) {
|
1084 |
+
continue;
|
1085 |
+
}
|
1086 |
+
$wpcf_form_data[ $field_slug ] = false;
|
1087 |
+
}
|
1088 |
+
}
|
1089 |
+
|
1090 |
+
return $wpcf_form_data;
|
1091 |
+
}
|
library/toolset/types/embedded/includes/fields/checkbox.php
CHANGED
@@ -1,8 +1,17 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* Register data (called automatically).
|
4 |
*
|
5 |
-
* @return
|
6 |
*/
|
7 |
function wpcf_fields_checkbox()
|
8 |
{
|
@@ -20,10 +29,6 @@ function wpcf_fields_checkbox()
|
|
20 |
);
|
21 |
}
|
22 |
|
23 |
-
/**
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*/
|
27 |
|
28 |
add_action( 'save_post', 'wpcf_fields_checkbox_save_check', 15, 1 );
|
29 |
add_action( 'edit_attachment', 'wpcf_fields_checkbox_save_check', 15, 1 );
|
@@ -31,8 +36,10 @@ add_action( 'edit_attachment', 'wpcf_fields_checkbox_save_check', 15, 1 );
|
|
31 |
/**
|
32 |
* Form data for post edit page.
|
33 |
*
|
34 |
-
* @param
|
|
|
35 |
*
|
|
|
36 |
* @deprecated seems
|
37 |
*/
|
38 |
function wpcf_fields_checkbox_meta_box_form($field, $field_object)
|
@@ -240,9 +247,9 @@ function wpcf_fields_checkbox_view($params)
|
|
240 |
/**
|
241 |
* Check if checkbox is submitted.
|
242 |
*
|
243 |
-
* Currently used on Relationship saving.
|
244 |
*
|
245 |
-
* @param
|
246 |
*/
|
247 |
function wpcf_fields_checkbox_save_check($post_id)
|
248 |
{
|
@@ -250,9 +257,7 @@ function wpcf_fields_checkbox_save_check($post_id)
|
|
250 |
$meta_to_unset[$post_id] = array();
|
251 |
$cf = new WPCF_Field();
|
252 |
|
253 |
-
/*
|
254 |
-
*
|
255 |
-
* We hve several calls on this:
|
256 |
* 1. Saving post with Update
|
257 |
* 2. Saving all children
|
258 |
* 3. Saving child
|
@@ -270,9 +275,7 @@ function wpcf_fields_checkbox_save_check($post_id)
|
|
270 |
}
|
271 |
}
|
272 |
|
273 |
-
|
274 |
-
* update edited post chechboxes
|
275 |
-
*/
|
276 |
switch( $mode ) {
|
277 |
case 'save_main':
|
278 |
if( isset($_POST['_wptoolset_checkbox']) ){
|
@@ -391,40 +394,81 @@ function wpcf_fields_checkbox_save_check($post_id)
|
|
391 |
}
|
392 |
}
|
393 |
|
394 |
-
function wpcf_fields_checkbox_update_one($post_id, $slug, $array_to_check)
|
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 |
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
IMPORTANT NOTE
|
4 |
+
|
5 |
+
Some checkboxes-related functionality is - for historical reasons - shared with checkbox fields in a
|
6 |
+
very unclear way. It's defined in this file.
|
7 |
+
|
8 |
+
That is the reason (at least one of them) why this file needs to be included on every request.
|
9 |
+
*/
|
10 |
+
|
11 |
/**
|
12 |
* Register data (called automatically).
|
13 |
*
|
14 |
+
* @return array
|
15 |
*/
|
16 |
function wpcf_fields_checkbox()
|
17 |
{
|
29 |
);
|
30 |
}
|
31 |
|
|
|
|
|
|
|
|
|
32 |
|
33 |
add_action( 'save_post', 'wpcf_fields_checkbox_save_check', 15, 1 );
|
34 |
add_action( 'edit_attachment', 'wpcf_fields_checkbox_save_check', 15, 1 );
|
36 |
/**
|
37 |
* Form data for post edit page.
|
38 |
*
|
39 |
+
* @param $field
|
40 |
+
* @param $field_object
|
41 |
*
|
42 |
+
* @return array
|
43 |
* @deprecated seems
|
44 |
*/
|
45 |
function wpcf_fields_checkbox_meta_box_form($field, $field_object)
|
247 |
/**
|
248 |
* Check if checkbox is submitted.
|
249 |
*
|
250 |
+
* Currently used on Relationship saving.
|
251 |
*
|
252 |
+
* @param int $post_id
|
253 |
*/
|
254 |
function wpcf_fields_checkbox_save_check($post_id)
|
255 |
{
|
257 |
$meta_to_unset[$post_id] = array();
|
258 |
$cf = new WPCF_Field();
|
259 |
|
260 |
+
/* We have several calls on this:
|
|
|
|
|
261 |
* 1. Saving post with Update
|
262 |
* 2. Saving all children
|
263 |
* 3. Saving child
|
275 |
}
|
276 |
}
|
277 |
|
278 |
+
// Update edited post's checkboxes
|
|
|
|
|
279 |
switch( $mode ) {
|
280 |
case 'save_main':
|
281 |
if( isset($_POST['_wptoolset_checkbox']) ){
|
394 |
}
|
395 |
}
|
396 |
|
397 |
+
function wpcf_fields_checkbox_update_one($post_id, $slug, $array_to_check) {
|
398 |
+
$cf = new WPCF_Field();
|
399 |
+
$field_slug = $cf->__get_slug_no_prefix( $slug );
|
400 |
+
|
401 |
+
$cf->set( $post_id, $field_slug );
|
402 |
+
|
403 |
+
// Abort if the field doesn't exist.
|
404 |
+
if ( ! array_key_exists( 'data', $cf->cf ) ) {
|
405 |
+
return;
|
406 |
+
}
|
407 |
+
|
408 |
+
if ( 'checkbox' == $cf->cf['type'] ) {
|
409 |
+
if ( array_key_exists( $field_slug, $array_to_check ) || array_key_exists( $slug, $array_to_check ) ) {
|
410 |
+
|
411 |
+
update_post_meta( $post_id, $slug, $cf->cf['data']['set_value'] );
|
412 |
+
return;
|
413 |
+
}
|
414 |
+
|
415 |
+
$cf->set( $post_id, $field_slug );
|
416 |
+
|
417 |
+
if ( $cf->cf['data']['save_empty'] != 'no' ) {
|
418 |
+
update_post_meta( $post_id, $cf->slug, 0 );
|
419 |
+
} else {
|
420 |
+
delete_post_meta( $post_id, $cf->slug );
|
421 |
+
}
|
422 |
+
|
423 |
+
} else if ( 'checkboxes' == $cf->cf['type'] ) {
|
424 |
+
wpcf_update_checkboxes_field( $cf->cf, 'post', $post_id, $array_to_check );
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
|
429 |
+
/**
|
430 |
+
* This actually handles saving checkboxes field properly from Types, overwriting the default method
|
431 |
+
* WPCF_Field::save().
|
432 |
+
*
|
433 |
+
* It (finally) respects the "save_empty" field option properly.
|
434 |
+
*
|
435 |
+
* @param array $field_definition_array Checkboxes field definition array, basic keys are assumed.
|
436 |
+
* @param string $meta_type 'post'|'user'|'term'
|
437 |
+
* @param int $object_id ID of an existing post that is to be updated.
|
438 |
+
* @param array $wpcf_form_data Form data, usually coming from $_POST['wpcf'].
|
439 |
+
*
|
440 |
+
* @since 2.2.7
|
441 |
+
*/
|
442 |
+
function wpcf_update_checkboxes_field( $field_definition_array, $meta_type, $object_id, $wpcf_form_data ) {
|
443 |
+
|
444 |
+
if( ! in_array( $meta_type, array( 'post', 'user', 'term ') ) ) {
|
445 |
+
return;
|
446 |
+
}
|
447 |
+
|
448 |
+
// We'll save an empty array if there's nothing else to save (done for historical reasons).
|
449 |
+
$meta_value = array();
|
450 |
+
|
451 |
+
$field_options = wpcf_getnest( $field_definition_array, array( 'data', 'options' ), null );
|
452 |
+
|
453 |
+
if( is_array( $field_options ) ) {
|
454 |
+
$field_id = wpcf_getarr( $field_definition_array, 'id' );
|
455 |
+
$save_zero_if_empty = ( 'yes' == wpcf_getnest( $field_definition_array, array( 'data', 'save_empty' ) ) );
|
456 |
+
|
457 |
+
foreach( $field_options as $option_id => $option_settings ) {
|
458 |
+
$is_option_checked = isset( $wpcf_form_data[ $field_id ][ $option_id ] );
|
459 |
+
|
460 |
+
if( $is_option_checked ) {
|
461 |
+
// Use actual option value coming from the form submission.
|
462 |
+
$meta_value[ $option_id ] = $wpcf_form_data[ $field_id ][ $option_id ];
|
463 |
+
|
464 |
+
} elseif( $save_zero_if_empty ) {
|
465 |
+
$meta_value[ $option_id ] = 0;
|
466 |
+
}
|
467 |
+
|
468 |
+
// Otherwise, skip the key
|
469 |
+
}
|
470 |
+
}
|
471 |
+
|
472 |
+
update_metadata( $meta_type, $object_id, wpcf_getarr( $field_definition_array, 'meta_key' ), $meta_value );
|
473 |
}
|
474 |
|
library/toolset/types/embedded/includes/fields/checkboxes.php
CHANGED
@@ -1,8 +1,17 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* Register data (called automatically).
|
4 |
*
|
5 |
-
* @return
|
6 |
*/
|
7 |
function wpcf_fields_checkboxes() {
|
8 |
return array(
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
IMPORTANT NOTE
|
4 |
+
|
5 |
+
Some checkboxes-related functionality is - for historical reasons - shared with checkbox fields in a
|
6 |
+
very unclear way. It's defined in ./checkbox.php.
|
7 |
+
|
8 |
+
Namely wpcf_update_checkboxes_field() which is invoked by wpcf_fields_checkbox_save_check() at save_post.
|
9 |
+
*/
|
10 |
+
|
11 |
/**
|
12 |
* Register data (called automatically).
|
13 |
*
|
14 |
+
* @return array
|
15 |
*/
|
16 |
function wpcf_fields_checkboxes() {
|
17 |
return array(
|
library/toolset/types/embedded/includes/fields/image.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Register data (called automatically).
|
4 |
-
*
|
|
|
5 |
*/
|
6 |
function wpcf_fields_image() {
|
7 |
return array(
|
@@ -18,10 +19,6 @@ function wpcf_fields_image() {
|
|
18 |
);
|
19 |
}
|
20 |
|
21 |
-
/**
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*/
|
25 |
|
26 |
add_filter( 'wpcf_fields_type_image_value_get', 'wpcf_fields_image_value_filter' );
|
27 |
add_filter( 'wpcf_fields_type_image_value_save', 'wpcf_fields_image_value_filter' );
|
@@ -29,6 +26,7 @@ add_filter( 'wpcf_fields_type_image_value_save', 'wpcf_fields_image_value_filter
|
|
29 |
// Do not wrap if 'url' is TRUE
|
30 |
add_filter( 'types_view', 'wpcf_fields_image_view_filter', 10, 6 );
|
31 |
|
|
|
32 |
/**
|
33 |
* return array of valid extensions
|
34 |
*
|
@@ -53,10 +51,16 @@ function wpcf_fields_image_valid_extension()
|
|
53 |
/**
|
54 |
* Editor callback form.
|
55 |
*
|
56 |
-
* @
|
|
|
|
|
|
|
57 |
*
|
|
|
58 |
*/
|
59 |
-
function wpcf_fields_image_editor_callback(
|
|
|
|
|
60 |
|
61 |
// Get post_ID
|
62 |
$post_ID = !empty( $post->ID ) ? $post->ID : false;
|
@@ -107,26 +111,9 @@ function wpcf_fields_image_editor_callback( $field, $data, $context, $post ) {
|
|
107 |
$data['preview'] = $attachment_id ? wp_get_attachment_image( $attachment_id,
|
108 |
'thumbnail' ) : '';
|
109 |
|
110 |
-
//
|
111 |
-
|
112 |
-
|
113 |
-
'_wp_attachment_image_alt', true ) ) );
|
114 |
-
$attachment_post = get_post( $attachment_id );
|
115 |
-
if ( !empty( $attachment_post ) ) {
|
116 |
-
$title = trim( strip_tags( $attachment_post->post_title ) );
|
117 |
-
} else if ( !empty( $alt ) ) {
|
118 |
-
$title = $alt;
|
119 |
-
}
|
120 |
-
if ( empty( $alt ) ) {
|
121 |
-
$alt = $title;
|
122 |
-
}
|
123 |
-
if ( !isset( $data['title'] ) ) {
|
124 |
-
$data['title'] = $title;
|
125 |
-
}
|
126 |
-
if ( !isset( $data['alt'] ) ) {
|
127 |
-
$data['alt'] = $alt;
|
128 |
-
}
|
129 |
-
}
|
130 |
|
131 |
// Align options
|
132 |
$data['alignment_options'] = array(
|
1 |
<?php
|
2 |
/**
|
3 |
* Register data (called automatically).
|
4 |
+
*
|
5 |
+
* @return array
|
6 |
*/
|
7 |
function wpcf_fields_image() {
|
8 |
return array(
|
19 |
);
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
22 |
|
23 |
add_filter( 'wpcf_fields_type_image_value_get', 'wpcf_fields_image_value_filter' );
|
24 |
add_filter( 'wpcf_fields_type_image_value_save', 'wpcf_fields_image_value_filter' );
|
26 |
// Do not wrap if 'url' is TRUE
|
27 |
add_filter( 'types_view', 'wpcf_fields_image_view_filter', 10, 6 );
|
28 |
|
29 |
+
|
30 |
/**
|
31 |
* return array of valid extensions
|
32 |
*
|
51 |
/**
|
52 |
* Editor callback form.
|
53 |
*
|
54 |
+
* @param $field
|
55 |
+
* @param $data
|
56 |
+
* @param $context
|
57 |
+
* @param $post
|
58 |
*
|
59 |
+
* @return array
|
60 |
*/
|
61 |
+
function wpcf_fields_image_editor_callback(
|
62 |
+
$field, $data, /** @noinspection PhpUnusedParameterInspection */ $context, $post
|
63 |
+
) {
|
64 |
|
65 |
// Get post_ID
|
66 |
$post_ID = !empty( $post->ID ) ? $post->ID : false;
|
111 |
$data['preview'] = $attachment_id ? wp_get_attachment_image( $attachment_id,
|
112 |
'thumbnail' ) : '';
|
113 |
|
114 |
+
// Use the title/alt placeholders for all images instead of "hardcoding" specific values.
|
115 |
+
$data['title'] = '%%TITLE%%';
|
116 |
+
$data['alt'] = '%%ALT%%';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
// Align options
|
119 |
$data['alignment_options'] = array(
|
library/toolset/types/embedded/includes/post-relationship.php
CHANGED
@@ -55,10 +55,10 @@ if ( is_admin() ) {
|
|
55 |
*
|
56 |
* Enqueues styles and scripts on post edit page.
|
57 |
*
|
58 |
-
* @param
|
59 |
-
* @param
|
60 |
-
* @param
|
61 |
-
* @param
|
62 |
*/
|
63 |
function wpcf_pr_admin_post_init_action( $post_type, $post, $groups, $wpcf_active )
|
64 |
{
|
@@ -107,14 +107,15 @@ function wpcf_pr_admin_post_init_action( $post_type, $post, $groups, $wpcf_activ
|
|
107 |
wp_enqueue_style( 'wpcf-pr-post',
|
108 |
WPCF_EMBEDDED_RES_RELPATH . '/css/fields-post.css',
|
109 |
array(), WPCF_VERSION );
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
118 |
}
|
119 |
wpcf_admin_add_js_settings( 'wpcf_pr_del_warning',
|
120 |
'\'' . __( 'Are you sure about deleting this post?', 'wpcf' ) . '\'' );
|
55 |
*
|
56 |
* Enqueues styles and scripts on post edit page.
|
57 |
*
|
58 |
+
* @param $post_type
|
59 |
+
* @param $post
|
60 |
+
* @param $groups
|
61 |
+
* @param $wpcf_active
|
62 |
*/
|
63 |
function wpcf_pr_admin_post_init_action( $post_type, $post, $groups, $wpcf_active )
|
64 |
{
|
107 |
wp_enqueue_style( 'wpcf-pr-post',
|
108 |
WPCF_EMBEDDED_RES_RELPATH . '/css/fields-post.css',
|
109 |
array(), WPCF_VERSION );
|
110 |
+
|
111 |
+
$asset_manager = Types_Asset_Manager::get_instance();
|
112 |
+
$asset_manager->enqueue_scripts(
|
113 |
+
array(
|
114 |
+
Types_Asset_Manager::SCRIPT_JQUERY_UI_VALIDATION,
|
115 |
+
Types_Asset_Manager::SCRIPT_ADDITIONAL_VALIDATION_RULES,
|
116 |
+
)
|
117 |
+
);
|
118 |
+
|
119 |
}
|
120 |
wpcf_admin_add_js_settings( 'wpcf_pr_del_warning',
|
121 |
'\'' . __( 'Are you sure about deleting this post?', 'wpcf' ) . '\'' );
|
library/toolset/types/embedded/includes/usermeta-add-user.php
CHANGED
@@ -26,12 +26,11 @@ function wpcf_usermeta_add_user_templates() {
|
|
26 |
|
27 |
/**
|
28 |
* Hooks to 'user_register'
|
29 |
-
*
|
|
|
30 |
*/
|
31 |
function wpcf_usermets_add_user_submit( $user_id ) {
|
32 |
-
|
33 |
-
wpcf_admin_userprofilesave_init( $user_id );
|
34 |
-
}
|
35 |
}
|
36 |
|
37 |
/**
|
26 |
|
27 |
/**
|
28 |
* Hooks to 'user_register'
|
29 |
+
*
|
30 |
+
* @param int $user_id
|
31 |
*/
|
32 |
function wpcf_usermets_add_user_submit( $user_id ) {
|
33 |
+
wpcf_admin_userprofilesave_init( $user_id );
|
|
|
|
|
34 |
}
|
35 |
|
36 |
/**
|
library/toolset/types/embedded/includes/usermeta-post.php
CHANGED
@@ -150,14 +150,15 @@ function wpcf_admin_userprofile_init($user_id){
|
|
150 |
wp_enqueue_script( 'wpcf-fields-post',
|
151 |
WPCF_EMBEDDED_RES_RELPATH . '/js/fields-post.js',
|
152 |
array('jquery'), WPCF_VERSION );
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
|
|
161 |
wp_enqueue_style( 'wpcf-css-embedded',
|
162 |
WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(),
|
163 |
WPCF_VERSION );
|
@@ -326,256 +327,83 @@ function wpcf_admin_profile_js_validation(){
|
|
326 |
}
|
327 |
|
328 |
|
329 |
-
|
330 |
-
* Save user profile custom fields
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
global $wpcf;
|
337 |
-
$errors = false;
|
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 |
-
if ( 'yes' == $field['data']['save_empty'] ) {
|
363 |
-
$_POST['wpcf'][$field['slug']] = 0;
|
364 |
-
} else {
|
365 |
-
delete_user_meta($user_id, $field['meta_key']);
|
366 |
-
}
|
367 |
-
}
|
368 |
-
break;
|
369 |
-
}
|
370 |
-
}
|
371 |
}
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
$
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
if ( is_wp_error( $valid ) ) {
|
393 |
-
$errors = true;
|
394 |
-
$_errors = $valid->get_error_data();
|
395 |
-
$_msg = sprintf( __( 'Field "%s" not updated:', 'wpcf' ),
|
396 |
-
$field['name'] );
|
397 |
-
wpcf_admin_message_store( $_msg . ' ' . implode( ', ',
|
398 |
-
$_errors ), 'error' );
|
399 |
-
if ( types_is_repetitive( $field ) ) {
|
400 |
-
unset( $field_value[$_k] );
|
401 |
-
} else {
|
402 |
-
break;
|
403 |
-
}
|
404 |
-
}
|
405 |
-
}
|
406 |
-
// Save field
|
407 |
-
if ( types_is_repetitive( $field ) ) {
|
408 |
-
$wpcf->usermeta_repeater->set( $user_id, $field );
|
409 |
-
$wpcf->usermeta_repeater->save( $field_value );
|
410 |
} else {
|
411 |
-
|
412 |
-
$wpcf->usermeta_field->usermeta_save( $field_value );
|
413 |
-
}
|
414 |
-
|
415 |
-
do_action( 'wpcf_user_field_saved', $user_id, $field );
|
416 |
-
|
417 |
-
// TODO Move to checkboxes
|
418 |
-
|
419 |
-
if ( $field['type'] == 'checkboxes' ) {
|
420 |
-
$field_data = wpcf_admin_fields_get_field( $field['id'], false, false, false, 'wpcf-usermeta' );
|
421 |
-
if ( !empty( $field_data['data']['options'] ) ) {
|
422 |
-
$update_data = array();
|
423 |
-
foreach ( $field_data['data']['options'] as $option_id => $option_data ) {
|
424 |
-
if ( !isset( $_POST['wpcf'][$field['id']][$option_id] ) ) {
|
425 |
-
if ( isset( $field_data['data']['save_empty'] ) && $field_data['data']['save_empty'] == 'yes' ) {
|
426 |
-
$update_data[$option_id] = 0;
|
427 |
-
}
|
428 |
-
} else {
|
429 |
-
$update_data[$option_id] = $_POST['wpcf'][$field['id']][$option_id];
|
430 |
-
}
|
431 |
-
}
|
432 |
-
update_user_meta( $user_id, $field['meta_key'], $update_data );
|
433 |
-
}
|
434 |
}
|
435 |
}
|
436 |
}
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
global $wpcf;
|
445 |
-
|
446 |
-
$all_fields = array();
|
447 |
-
$_not_valid = array();
|
448 |
-
$_error = false;
|
449 |
-
$error = '';
|
450 |
-
|
451 |
-
$groups = $groups = wpcf_admin_usermeta_get_groups_fields();
|
452 |
-
if ( empty( $groups ) ) {
|
453 |
-
return false;
|
454 |
-
}
|
455 |
-
|
456 |
-
foreach ( $groups as $group ) {
|
457 |
-
// Process fields
|
458 |
-
|
459 |
-
$fields = wpcf_admin_usermeta_process_fields( $user_id , $group['fields'], true,
|
460 |
-
false, 'validation' );
|
461 |
-
// Validate fields
|
462 |
-
$form = wpcf_form_simple_validate( $fields );
|
463 |
-
|
464 |
-
$all_fields = $all_fields + $fields;
|
465 |
-
|
466 |
-
// Collect all not valid fields
|
467 |
-
if ( $form->isError() ) {
|
468 |
-
$_error = true; // Set error only to true
|
469 |
-
$_not_valid = array_merge( $_not_valid,
|
470 |
-
(array) $form->get_not_valid() );
|
471 |
-
}
|
472 |
-
}
|
473 |
-
|
474 |
-
// Set fields
|
475 |
-
foreach ( $all_fields as $k => $v ) {
|
476 |
-
// only Types field
|
477 |
-
if ( empty( $v['wpcf-id'] ) ) {
|
478 |
-
continue;
|
479 |
-
}
|
480 |
-
$_temp = new WPCF_Usermeta_Field();
|
481 |
-
$_temp->set( $user_id, $v['wpcf-id'] );
|
482 |
-
$all_fields[$k]['_field'] = $_temp;
|
483 |
-
}
|
484 |
-
foreach ( $_not_valid as $k => $v ) {
|
485 |
-
// only Types field
|
486 |
-
if ( empty( $v['wpcf-id'] ) ) {
|
487 |
-
continue;
|
488 |
}
|
489 |
-
$_temp = new WPCF_Usermeta_Field();
|
490 |
-
$_temp->set( $user_id, $v['wpcf-id'] );
|
491 |
-
$_not_valid[$k]['_field'] = $_temp;
|
492 |
-
}
|
493 |
-
|
494 |
-
$not_valid = apply_filters( 'wpcf_post_form_not_valid', $_not_valid,
|
495 |
-
$_error, $all_fields );
|
496 |
|
|
|
497 |
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
__( 'Please check your input data', 'wpcf' ), 'error' );
|
502 |
}
|
503 |
|
504 |
-
|
505 |
-
|
506 |
-
*/
|
507 |
-
if ( !empty( $not_valid ) ) {
|
508 |
-
update_user_meta( $user_id, 'wpcf-invalid-fields', $not_valid );
|
509 |
}
|
510 |
|
511 |
-
|
512 |
-
if ( !empty( $_POST['wpcf'] ) ) {
|
513 |
-
foreach ( $_POST['wpcf'] as $field_slug => $field_value ) {
|
514 |
-
|
515 |
-
$field = wpcf_fields_get_field_by_slug( $field_slug, 'wpcf-usermeta' );
|
516 |
-
if ( empty( $field ) ) {
|
517 |
-
continue;
|
518 |
-
}
|
519 |
-
|
520 |
-
|
521 |
-
$wpcf->usermeta_field->set( $user_id, $field );
|
522 |
-
if ( isset( $_POST['wpcf_repetitive_copy'][$field['slug']] ) ) {
|
523 |
-
continue;
|
524 |
-
}
|
525 |
-
|
526 |
-
if ( isset( $_POST['__wpcf_repetitive'][$wpcf->usermeta_field->slug] ) ) {
|
527 |
-
$wpcf->usermeta_repeater->set( $user_id, $field );
|
528 |
-
$wpcf->usermeta_repeater->save();
|
529 |
-
} else {
|
530 |
-
$wpcf->usermeta_field->usermeta_save();
|
531 |
-
}
|
532 |
-
|
533 |
-
do_action('wpcf_post_field_saved', '', $field);
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
}//end foreach
|
538 |
-
|
539 |
-
}//end if
|
540 |
-
|
541 |
-
foreach ( $all_fields as $field ) {
|
542 |
-
if ( !isset( $field['#type'] ) ) {
|
543 |
-
continue;
|
544 |
-
}
|
545 |
-
if ( $field['#type'] == 'checkbox') {
|
546 |
-
$field_data = wpcf_admin_fields_get_field( $field['wpcf-id'], false,
|
547 |
-
false, false, 'wpcf-usermeta' );
|
548 |
-
if ( !isset( $_POST['wpcf'][$field['wpcf-slug']] ) ){
|
549 |
-
if ( isset( $field_data['data']['save_empty'] )
|
550 |
-
&& $field_data['data']['save_empty'] == 'yes' ) {
|
551 |
-
update_user_meta($user_id, wpcf_types_get_meta_prefix( $field ) . $field['wpcf-slug'], 0);
|
552 |
-
}
|
553 |
-
else{
|
554 |
-
delete_user_meta($user_id, wpcf_types_get_meta_prefix( $field ) . $field['wpcf-slug']);
|
555 |
-
}
|
556 |
-
}
|
557 |
-
}
|
558 |
-
if ( $field['#type'] == 'checkboxes' ) {
|
559 |
-
$field_data = wpcf_admin_fields_get_field( $field['wpcf-id'], false,
|
560 |
-
false, false, 'wpcf-usermeta' );
|
561 |
-
if ( !empty( $field_data['data']['options'] ) ) {
|
562 |
-
$update_data = array();
|
563 |
-
foreach ( $field_data['data']['options'] as $option_id => $option_data ) {
|
564 |
-
if ( !isset( $_POST['wpcf'][$field['wpcf-slug']][$option_id] ) ) {
|
565 |
-
if ( isset( $field_data['data']['save_empty'] ) && $field_data['data']['save_empty'] == 'yes' ) {
|
566 |
-
$update_data[$option_id] = 0;
|
567 |
-
}
|
568 |
-
} else {
|
569 |
-
$update_data[$option_id] = $_POST['wpcf'][$field['wpcf-slug']][$option_id];
|
570 |
-
}
|
571 |
-
}
|
572 |
-
update_user_meta( $user_id,
|
573 |
-
wpcf_types_get_meta_prefix( $field ) . $field['wpcf-slug'],
|
574 |
-
$update_data );
|
575 |
-
}
|
576 |
-
}
|
577 |
-
}
|
578 |
-
|
579 |
|
580 |
}
|
581 |
|
150 |
wp_enqueue_script( 'wpcf-fields-post',
|
151 |
WPCF_EMBEDDED_RES_RELPATH . '/js/fields-post.js',
|
152 |
array('jquery'), WPCF_VERSION );
|
153 |
+
|
154 |
+
$asset_manager = Types_Asset_Manager::get_instance();
|
155 |
+
$asset_manager->enqueue_scripts(
|
156 |
+
array(
|
157 |
+
Types_Asset_Manager::SCRIPT_JQUERY_UI_VALIDATION,
|
158 |
+
Types_Asset_Manager::SCRIPT_ADDITIONAL_VALIDATION_RULES,
|
159 |
+
)
|
160 |
+
);
|
161 |
+
|
162 |
wp_enqueue_style( 'wpcf-css-embedded',
|
163 |
WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(),
|
164 |
WPCF_VERSION );
|
327 |
}
|
328 |
|
329 |
|
330 |
+
/**
|
331 |
+
* Save user profile custom fields.
|
332 |
+
*
|
333 |
+
* @since unknown
|
334 |
+
* @param $user_id
|
335 |
+
*/
|
336 |
+
function wpcf_admin_userprofilesave_init( $user_id ) {
|
|
|
|
|
337 |
|
338 |
+
global $wpcf;
|
339 |
+
$has_errors = false;
|
340 |
+
|
341 |
+
$wpcf_form_data = wpcf_ensarr( wpcf_getarr( $_POST, 'wpcf' ) );
|
342 |
+
|
343 |
+
// Check wpcf_adjust_form_input_for_checkboxlike_fields() for information about side effects.
|
344 |
+
$wpcf_form_data = wpcf_adjust_form_input_for_checkboxlike_fields(
|
345 |
+
$wpcf_form_data,
|
346 |
+
wpcf_ensarr( wpcf_getarr( $_POST, '_wptoolset_checkbox' ) )
|
347 |
+
);
|
348 |
+
|
349 |
+
$wpcf_form_data = wpcf_adjust_form_input_for_checkboxlike_fields(
|
350 |
+
$wpcf_form_data,
|
351 |
+
wpcf_ensarr( wpcf_getarr( $_POST, '_wptoolset_radios' ) )
|
352 |
+
);
|
353 |
+
|
354 |
+
// Save meta fields
|
355 |
+
foreach ( $wpcf_form_data as $field_slug => $field_value ) {
|
356 |
+
// Get field by slug
|
357 |
+
$field_definition_array = wpcf_fields_get_field_by_slug( $field_slug, 'wpcf-usermeta' );
|
358 |
+
if ( empty( $field_definition_array ) ) {
|
359 |
+
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
}
|
361 |
+
// Skip copied fields
|
362 |
+
if ( isset( $_POST['wpcf_repetitive_copy'][$field_definition_array['slug']] ) ) {
|
363 |
+
continue;
|
364 |
+
}
|
365 |
+
$_field_value = !types_is_repetitive( $field_definition_array ) ? array($field_value) : $field_value;
|
366 |
+
// Set config
|
367 |
+
$config = wptoolset_form_filter_types_field( $field_definition_array, $user_id );
|
368 |
+
foreach ( $_field_value as $_k => $_val ) {
|
369 |
+
// Check if valid
|
370 |
+
$valid = wptoolset_form_validate_field( 'your-profile', $config,
|
371 |
+
$_val );
|
372 |
+
if ( is_wp_error( $valid ) ) {
|
373 |
+
$has_errors = true;
|
374 |
+
$_errors = $valid->get_error_data();
|
375 |
+
$_msg = sprintf( __( 'Field "%s" not updated:', 'wpcf' ),
|
376 |
+
$field_definition_array['name'] );
|
377 |
+
wpcf_admin_message_store( $_msg . ' ' . implode( ', ',
|
378 |
+
$_errors ), 'error' );
|
379 |
+
if ( types_is_repetitive( $field_definition_array ) ) {
|
380 |
+
unset( $field_value[$_k] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
} else {
|
382 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
}
|
384 |
}
|
385 |
}
|
386 |
+
// Save field
|
387 |
+
if ( types_is_repetitive( $field_definition_array ) ) {
|
388 |
+
$wpcf->usermeta_repeater->set( $user_id, $field_definition_array );
|
389 |
+
$wpcf->usermeta_repeater->save( $field_value );
|
390 |
+
} else {
|
391 |
+
$wpcf->usermeta_field->set( $user_id, $field_definition_array );
|
392 |
+
$wpcf->usermeta_field->usermeta_save( $field_value );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
|
395 |
+
do_action( 'wpcf_user_field_saved', $user_id, $field_definition_array );
|
396 |
|
397 |
+
// Note: Checkboxes fields used to be handled as a special case here, that was now moved
|
398 |
+
// to wpcf_update_checkboxes_field(). Unlike for posts, we need to call this funcion manually from here.
|
399 |
+
wpcf_update_checkboxes_field( $field_definition_array, 'user', $user_id, $wpcf_form_data );
|
|
|
400 |
}
|
401 |
|
402 |
+
if ( $has_errors ) {
|
403 |
+
update_post_meta( $user_id, '__wpcf-invalid-fields', true );
|
|
|
|
|
|
|
404 |
}
|
405 |
|
406 |
+
do_action( 'wpcf_user_saved', $user_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
|
408 |
}
|
409 |
|
library/toolset/types/embedded/resources/js/post-relationship.js
CHANGED
@@ -127,7 +127,7 @@ var tChildTable = (function($) {
|
|
127 |
|
128 |
tTagBox = {
|
129 |
clean: function(tags) {
|
130 |
-
var comma =
|
131 |
if (',' !== comma)
|
132 |
tags = tags.replace(new RegExp(comma, 'g'), ',');
|
133 |
tags = tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, '');
|
@@ -137,8 +137,9 @@ var tChildTable = (function($) {
|
|
137 |
},
|
138 |
parseTags: function(el) {
|
139 |
var id = el.id, num = id.split('-check-num-')[1], taxbox = $(el).closest('.js-types-child-tagsdiv'),
|
140 |
-
thetags = taxbox.find('.the-tags'), comma =
|
141 |
current_tags = thetags.val().split(comma), new_tags = [];
|
|
|
142 |
delete current_tags[num];
|
143 |
|
144 |
$.each(current_tags, function(key, val) {
|
@@ -158,7 +159,7 @@ var tChildTable = (function($) {
|
|
158 |
tagchecklist = $('.tagchecklist', el),
|
159 |
id = $(el).attr('id'),
|
160 |
current_tags, disabled,
|
161 |
-
comma =
|
162 |
|
163 |
if (!thetags.length) {
|
164 |
return;
|
@@ -198,7 +199,7 @@ var tChildTable = (function($) {
|
|
198 |
a = a || false;
|
199 |
var tags = $('.the-tags', el),
|
200 |
newtag = $('input.js-types-newtag', el),
|
201 |
-
comma =
|
202 |
newtags, text;
|
203 |
|
204 |
text = a ? $(a).text() : newtag.val();
|
@@ -270,7 +271,7 @@ var tChildTable = (function($) {
|
|
270 |
}
|
271 |
}).each(function() {
|
272 |
var tax = $(this).data('types-tax'),
|
273 |
-
comma =
|
274 |
$(this).suggest(ajaxurl + '?action=ajax-tag-search&tax=' + tax, {delay: 500, minchars: 2, multiple: true, multipleSep: comma + ' '});
|
275 |
});
|
276 |
|
@@ -302,7 +303,7 @@ jQuery(document).ready(function($) {
|
|
302 |
var frame_relationship = [];
|
303 |
window.wpcf_pr_edited = false;
|
304 |
// Mark as edited field
|
305 |
-
$('#wpcf-post-relationship table').on('click', ':input', function() {
|
306 |
window.wpcf_pr_edited = true;
|
307 |
$(this).parent().addClass('wpcf-pr-edited');
|
308 |
});
|
@@ -310,11 +311,11 @@ jQuery(document).ready(function($) {
|
|
310 |
/*
|
311 |
* Parent form
|
312 |
*/
|
313 |
-
jQuery('.wpcf-pr-has-apply').click(function() {
|
314 |
var $thiz = jQuery(this);
|
315 |
jQuery(this).parent().slideUp().parent().parent().find('.wpcf-pr-edit').fadeIn();
|
316 |
var txt = new Array();
|
317 |
-
jQuery(this).parent().find('input:checked').each(function() {
|
318 |
txt.push(jQuery(this).next().html());
|
319 |
});
|
320 |
if (txt.length < 1) {
|
@@ -325,11 +326,11 @@ jQuery(document).ready(function($) {
|
|
325 |
}
|
326 |
jQuery(this).parent().parent().parent().find('.wpcf-pr-has-summary').html(wpcf_pr_has_update);
|
327 |
});
|
328 |
-
jQuery('.wpcf-pr-belongs-apply').click(function() {
|
329 |
var $thiz = jQuery(this);
|
330 |
jQuery(this).parent().slideUp().parent().parent().find('.wpcf-pr-edit').fadeIn();
|
331 |
var txt = new Array();
|
332 |
-
jQuery(this).parent().find('input:checked').each(function() {
|
333 |
txt.push(jQuery(this).next().html());
|
334 |
});
|
335 |
if (txt.length < 1) {
|
@@ -341,30 +342,30 @@ jQuery(document).ready(function($) {
|
|
341 |
jQuery(this).parent().parent().parent().find('.wpcf-pr-belongs-summary').html(wpcf_pr_belongs_update);
|
342 |
return false;
|
343 |
});
|
344 |
-
jQuery('.wpcf-pr-has-cancel').click(function() {
|
345 |
jQuery(this).parent().find('.checkbox').removeAttr('checked');
|
346 |
for (var checkbox in window.wpcf_pr_has_snapshot) {
|
347 |
jQuery('#' + window.wpcf_pr_has_snapshot[checkbox]).attr('checked', 'checked');
|
348 |
}
|
349 |
jQuery(this).parent().slideUp().parent().parent().find('.wpcf-pr-edit').fadeIn();
|
350 |
});
|
351 |
-
jQuery('.wpcf-pr-belongs-cancel').click(function() {
|
352 |
jQuery(this).parent().find('.checkbox').removeAttr('checked');
|
353 |
for (var checkbox in window.wpcf_pr_belongs_snapshot) {
|
354 |
jQuery('#' + window.wpcf_pr_belongs_snapshot[checkbox]).attr('checked', 'checked');
|
355 |
}
|
356 |
jQuery(this).parent().slideUp().parent().parent().find('.wpcf-pr-edit').fadeIn();
|
357 |
});
|
358 |
-
jQuery('.wpcf-pr-edit').click(function() {
|
359 |
window.wpcf_pr_has_snapshot = new Array();
|
360 |
window.wpcf_pr_belongs_snapshot = new Array();
|
361 |
var this_id = jQuery(this).attr('id');
|
362 |
if (this_id == 'wpcf-pr-has-edit') {
|
363 |
-
jQuery(this).next().find('.checkbox:checked').each(function() {
|
364 |
window.wpcf_pr_has_snapshot.push(jQuery(this).attr('id'));
|
365 |
});
|
366 |
} else {
|
367 |
-
jQuery(this).next().find('input:checked').each(function() {
|
368 |
window.wpcf_pr_belongs_snapshot.push(jQuery(this).attr('id'));
|
369 |
});
|
370 |
}
|
@@ -374,8 +375,8 @@ jQuery(document).ready(function($) {
|
|
374 |
/**
|
375 |
* POST EDIT SCREEN
|
376 |
*/
|
377 |
-
$('#wpcf-post-relationship').on('click', '.js-types-add-child', function() {
|
378 |
-
if(
|
379 |
return false;
|
380 |
|
381 |
wpcfInitValueOfSelect2DoneClear();
|
@@ -388,10 +389,10 @@ jQuery(document).ready(function($) {
|
|
388 |
type: 'get',
|
389 |
dataType: 'json',
|
390 |
cache: false,
|
391 |
-
beforeSend: function() {
|
392 |
$button.after('<div style="margin-top:20px;"></div>').next().addClass('wpcf-ajax-loading-small');
|
393 |
},
|
394 |
-
success: function(data) {
|
395 |
if (data != null) {
|
396 |
if (typeof data.output != 'undefined') {
|
397 |
$('tbody', $table).prepend(data.output);
|
@@ -405,37 +406,37 @@ jQuery(document).ready(function($) {
|
|
405 |
wptCond.addConditionals(data.conditionals);
|
406 |
}
|
407 |
if ('undefined' != typeof data.child_id) {
|
408 |
-
$('#types-child-row-'+data.child_id).on('click', '.js-wpt-file-upload', function(event) {
|
409 |
wptFile.bindOpen($(this), false);
|
410 |
});
|
411 |
}
|
412 |
}
|
413 |
-
$button.next().fadeOut(function() {
|
414 |
$(this).remove();
|
415 |
});
|
416 |
-
if (
|
417 |
wptFile.init();
|
418 |
}
|
419 |
/**
|
420 |
* select2
|
421 |
*/
|
422 |
wpcfBindSelect2($);
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
},
|
431 |
-
complete: function() {
|
432 |
typesRelationControlsAjaxComplete();
|
433 |
}
|
434 |
});
|
435 |
return false;
|
436 |
});
|
437 |
-
jQuery('.wpcf-pr-delete-ajax').live('click', function() {
|
438 |
-
if(
|
439 |
return false;
|
440 |
|
441 |
wpcfInitValueOfSelect2DoneClear();
|
@@ -453,30 +454,30 @@ jQuery(document).ready(function($) {
|
|
453 |
type: 'get',
|
454 |
dataType: 'json',
|
455 |
cache: false,
|
456 |
-
beforeSend: function() {
|
457 |
object.after('<div style="margin-top:20px;"></div>').next()
|
458 |
-
|
459 |
},
|
460 |
-
success: function(data) {
|
461 |
if (data != null) {
|
462 |
if (typeof data.output != 'undefined') {
|
463 |
-
object.parent().parent().fadeOut(function() {
|
464 |
jQuery(this).remove();
|
465 |
wpcfRelationshipInit('', 'delete');
|
466 |
});
|
467 |
}
|
468 |
}
|
469 |
-
object.next().fadeOut(function() {
|
470 |
jQuery(this).remove();
|
471 |
});
|
472 |
/**
|
473 |
* reload
|
474 |
*/
|
475 |
selectedIndex = $('#wpcf-post-relationship .wpcf-pr-pagination-select').prop('selectedIndex');
|
476 |
-
if (
|
477 |
-
if (
|
478 |
selectedIndex--;
|
479 |
-
$('#wpcf-post-relationship .wpcf-pr-pagination-select').prop(
|
480 |
}
|
481 |
}
|
482 |
$('#wpcf-post-relationship .wpcf-pr-pagination-select').trigger('change');
|
@@ -484,21 +485,21 @@ jQuery(document).ready(function($) {
|
|
484 |
* select2
|
485 |
*/
|
486 |
wpcfBindSelect2($);
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
},
|
495 |
-
complete: function() {
|
496 |
typesRelationControlsAjaxComplete();
|
497 |
}
|
498 |
});
|
499 |
return false;
|
500 |
});
|
501 |
-
jQuery('.wpcf-pr-update-belongs').live('click', function() {
|
502 |
var object = jQuery(this);
|
503 |
jQuery.ajax({
|
504 |
url: jQuery(this).attr('href'),
|
@@ -506,19 +507,19 @@ jQuery(document).ready(function($) {
|
|
506 |
dataType: 'json',
|
507 |
data: jQuery(this).attr('href') + '&' + object.prev().serialize(),
|
508 |
cache: false,
|
509 |
-
beforeSend: function() {
|
510 |
object.after('<div style="margin-top:20px;"></div>').next()
|
511 |
-
|
512 |
},
|
513 |
-
success: function(data) {
|
514 |
-
object.next().fadeOut(2000, function() {
|
515 |
jQuery(this).remove();
|
516 |
});
|
517 |
}
|
518 |
});
|
519 |
return false;
|
520 |
});
|
521 |
-
$('#wpcf-post-relationship').on('click', '.wpcf-pr-pagination-link', function() {
|
522 |
if (wpcfPrIsEdited()) {
|
523 |
var answer = confirm(wpcf_pr_pagination_warning);
|
524 |
if (answer == false) {
|
@@ -533,11 +534,11 @@ jQuery(document).ready(function($) {
|
|
533 |
type: 'get',
|
534 |
dataType: 'json',
|
535 |
cache: false,
|
536 |
-
beforeSend: function() {
|
537 |
$button.after('<div style="margin-top:20px;"></div>').next()
|
538 |
-
|
539 |
},
|
540 |
-
success: function(data) {
|
541 |
if (data != null) {
|
542 |
if (typeof data.output != 'undefined') {
|
543 |
$update.html(data.output);
|
@@ -547,30 +548,30 @@ jQuery(document).ready(function($) {
|
|
547 |
}
|
548 |
}
|
549 |
if (typeof data.conditionals != 'undefined'
|
550 |
-
|
551 |
wptCond.addConditionals(data.conditionals);
|
552 |
}
|
553 |
}
|
554 |
-
$button.next().fadeOut(function() {
|
555 |
$(this).remove();
|
556 |
});
|
557 |
/**
|
558 |
* select2
|
559 |
*/
|
560 |
wpcfBindSelect2($);
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
}
|
570 |
});
|
571 |
return false;
|
572 |
});
|
573 |
-
$('#wpcf-post-relationship').on('change', '.wpcf-pr-pagination-select', function() {
|
574 |
if (wpcfPrIsEdited()) {
|
575 |
var answer = confirm(wpcf_pr_pagination_warning);
|
576 |
if (answer == false) {
|
@@ -585,10 +586,10 @@ jQuery(document).ready(function($) {
|
|
585 |
type: 'get',
|
586 |
dataType: 'json',
|
587 |
cache: false,
|
588 |
-
beforeSend: function() {
|
589 |
$button.after('<div style="margin-top:20px;"></div>').next().addClass('wpcf-ajax-loading-small');
|
590 |
},
|
591 |
-
success: function(data) {
|
592 |
if (data != null) {
|
593 |
if (typeof data.output != 'undefined') {
|
594 |
$update.html(data.output);
|
@@ -601,26 +602,26 @@ jQuery(document).ready(function($) {
|
|
601 |
wptCond.addConditionals(data.conditionals);
|
602 |
}
|
603 |
}
|
604 |
-
$button.next().fadeOut(function() {
|
605 |
$(this).remove();
|
606 |
});
|
607 |
/**
|
608 |
* select2
|
609 |
*/
|
610 |
wpcfBindSelect2($);
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
}
|
620 |
});
|
621 |
return false;
|
622 |
});
|
623 |
-
$('#wpcf-post-relationship').on('click', '.wpcf-sortable a', function() {
|
624 |
if (wpcfPrIsEdited()) {
|
625 |
var answer = confirm(wpcf_pr_pagination_warning);
|
626 |
if (answer == false) {
|
@@ -635,10 +636,10 @@ jQuery(document).ready(function($) {
|
|
635 |
type: 'get',
|
636 |
dataType: 'json',
|
637 |
cache: false,
|
638 |
-
beforeSend: function() {
|
639 |
$button.after('<div style="margin-top:20px;"></div>').next().addClass('wpcf-ajax-loading-small');
|
640 |
},
|
641 |
-
success: function(data) {
|
642 |
if (data != null) {
|
643 |
if (typeof data.output != 'undefined') {
|
644 |
$update.html(data.output);
|
@@ -648,50 +649,50 @@ jQuery(document).ready(function($) {
|
|
648 |
}
|
649 |
}
|
650 |
if (typeof data.conditionals != 'undefined'
|
651 |
-
|
652 |
wptCond.addConditionals(data.conditionals);
|
653 |
}
|
654 |
}
|
655 |
-
$button.next().fadeOut(function() {
|
656 |
$(this).remove();
|
657 |
});
|
658 |
/**
|
659 |
* select2
|
660 |
*/
|
661 |
wpcfBindSelect2($);
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
}
|
671 |
});
|
672 |
return false;
|
673 |
});
|
674 |
-
$('#wpcf-post-relationship').on('click', '.wpcf-pr-save-ajax', function() {
|
675 |
-
if(
|
676 |
return false;
|
677 |
|
678 |
wpcfInitValueOfSelect2DoneClear();
|
679 |
|
680 |
-
var $button = $(this), $row = $button.parents('tr'), rowId = $row.attr('id'), valid = true, $table = $row.closest(
|
681 |
if (typeof wptValidation == 'undefined') {
|
682 |
-
$('.js-types-validate', $row).each(function() {
|
683 |
if ($('#post').validate().element($(this)) == false) {
|
684 |
if (typeof typesValidation == 'undefined'
|
685 |
-
|
686 |
valid = false;
|
687 |
}
|
688 |
}
|
689 |
});
|
690 |
} else {
|
691 |
-
$('.js-wpt-validate', $row).each(function() {
|
692 |
if ($('#post').validate().element($(this)) == false) {
|
693 |
if (typeof wptValidation == 'undefined'
|
694 |
-
|
695 |
valid = false;
|
696 |
}
|
697 |
}
|
@@ -701,7 +702,7 @@ jQuery(document).ready(function($) {
|
|
701 |
return false;
|
702 |
}
|
703 |
$button.parents('.js-types-relationship-child-posts')
|
704 |
-
|
705 |
var height = $row.height(), rand = Math.round(Math.random() * 10000);
|
706 |
window.wpcf_pr_edited = false;
|
707 |
|
@@ -713,61 +714,64 @@ jQuery(document).ready(function($) {
|
|
713 |
dataType: 'json',
|
714 |
data: $row.find(':input').serialize(),
|
715 |
cache: false,
|
716 |
-
beforeSend: function() {
|
717 |
$row.after('<tr id="wpcf-pr-update-' + rand + '"><td style="height: ' + height + 'px;"><div style="margin-top:20px;" class="wpcf-ajax-loading-small"></div></td></tr>').hide();
|
718 |
},
|
719 |
-
success: function(data) {
|
720 |
-
if(
|
721 |
-
if(
|
722 |
-
$
|
|
|
|
|
|
|
723 |
wpcfDisableControls();
|
724 |
-
$(
|
725 |
-
wpcfRelationshipInit(
|
726 |
tChildTable.reset();
|
727 |
-
if(
|
728 |
-
wptCallbacks.reset.fire(
|
729 |
}
|
730 |
-
if(
|
731 |
wptFile.init();
|
732 |
}
|
733 |
}
|
734 |
-
if(
|
735 |
-
wptCond.addConditionals(
|
736 |
}
|
737 |
/**
|
738 |
* rebind images
|
739 |
*/
|
740 |
-
if(
|
741 |
bind_colorbox_to_thumbnail_preview();
|
742 |
}
|
743 |
/**
|
744 |
* show errors
|
745 |
*/
|
746 |
-
$(
|
747 |
-
if(
|
748 |
-
$(
|
749 |
}
|
750 |
/**
|
751 |
* select2
|
752 |
*/
|
753 |
wpcfInitValueOfSelect2DoneClear();
|
754 |
-
wpcfBindSelect2(
|
755 |
|
756 |
var data_for_events = {
|
757 |
table: $table
|
758 |
};
|
759 |
|
760 |
-
$(
|
761 |
-
|
762 |
}
|
763 |
},
|
764 |
-
complete: function() {
|
765 |
typesRelationControlsAjaxComplete();
|
766 |
}
|
767 |
});
|
768 |
return false;
|
769 |
});
|
770 |
-
$('#wpcf-post-relationship').on('click', '.wpcf-pr-save-all-link', function() {
|
771 |
var $button = jQuery(this);
|
772 |
if ($button.attr('disabled') == 'disabled') {
|
773 |
return false;
|
@@ -775,18 +779,18 @@ jQuery(document).ready(function($) {
|
|
775 |
$button.attr('disabled', 'disabled');
|
776 |
var $update = $button.parents('.js-types-relationship-child-posts'), updateId = $update.attr('id'), $table = $('table', $update), valid = true;
|
777 |
if (typeof wptValidation == 'undefined') {
|
778 |
-
$('.js-types-validate', $table).each(function() {
|
779 |
if (typeof typesValidation == 'undefined'
|
780 |
-
|
781 |
if ($('#post').validate().element($(this)) == false) {
|
782 |
valid = false;
|
783 |
}
|
784 |
}
|
785 |
});
|
786 |
} else {
|
787 |
-
$('.js-wpt-validate', $table).each(function() {
|
788 |
if (typeof wptValidation == 'undefined'
|
789 |
-
|
790 |
if ($('#post').validate().element($(this)) == false) {
|
791 |
valid = false;
|
792 |
}
|
@@ -806,10 +810,10 @@ jQuery(document).ready(function($) {
|
|
806 |
dataType: 'json',
|
807 |
data: $(this).attr('href') + '&' + $(':input', $update).serialize(),
|
808 |
cache: false,
|
809 |
-
beforeSend: function() {
|
810 |
$('tbody', $table).empty().prepend('<tr id="wpcf-pr-update-' + rand + '"><td style="height: ' + height + 'px;"><div style="margin-top:20px;" class="wpcf-ajax-loading-small"></div></td></tr>');
|
811 |
},
|
812 |
-
success: function(data) {
|
813 |
if (data != null) {
|
814 |
if (typeof data.output != 'undefined') {
|
815 |
$update.replaceWith(data.output);
|
@@ -817,26 +821,26 @@ jQuery(document).ready(function($) {
|
|
817 |
wpcfRelationshipInit('', 'save_all');
|
818 |
tChildTable.reset();
|
819 |
if (typeof wptCallbacks != 'undefined') {
|
820 |
-
wptCallbacks.reset.fire('#'+updateId);
|
821 |
}
|
822 |
}
|
823 |
if (typeof data.conditionals != 'undefined' && typeof wptCond != 'undefined') {
|
824 |
wptCond.addConditionals(data.conditionals);
|
825 |
}
|
826 |
-
if (
|
827 |
wptFile.init();
|
828 |
}
|
829 |
/**
|
830 |
* rebind images
|
831 |
*/
|
832 |
-
if (
|
833 |
bind_colorbox_to_thumbnail_preview();
|
834 |
}
|
835 |
/**
|
836 |
* show errors
|
837 |
*/
|
838 |
$('#wpcf-post-relationship div.message').detach();
|
839 |
-
if ('undefined' != typeof data.errors && 0 < data.errors.length
|
840 |
$('#wpcf-post-relationship h3.hndle').after(data.errors);
|
841 |
}
|
842 |
}
|
@@ -844,74 +848,112 @@ jQuery(document).ready(function($) {
|
|
844 |
* select2
|
845 |
*/
|
846 |
wpcfBindSelect2($);
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
}
|
856 |
});
|
857 |
return false;
|
858 |
});
|
859 |
|
860 |
/**
|
861 |
-
*
|
|
|
|
|
862 |
*/
|
863 |
-
|
864 |
-
var $
|
865 |
-
var $
|
866 |
-
|
867 |
-
|
868 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
869 |
event.preventDefault();
|
870 |
}
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
875 |
}
|
876 |
-
|
877 |
-
frame_relationship[$id] = wp.media.frames.customHeader = wp.media({
|
878 |
-
// Set the title of the modal.
|
879 |
-
title: $el.html(),
|
880 |
-
// Tell the modal to show only images.
|
881 |
-
library: {
|
882 |
-
type: "image"
|
883 |
-
},
|
884 |
-
});
|
885 |
// When an image is selected, run a callback.
|
886 |
-
frame_relationship[$id].on(
|
|
|
887 |
// Grab the selected attachment.
|
888 |
var attachment = frame_relationship[$id].state().get('selection').first();
|
889 |
|
890 |
-
|
891 |
-
|
892 |
-
$('.wpt-file-preview', $parent).append('<img src="">');
|
893 |
-
}
|
894 |
-
if ( 'undefined' != typeof attachment.id ) {
|
895 |
-
$('.feature-image-id', $el.parent()).val(attachment.id);
|
896 |
-
$el.html($data.remove);
|
897 |
}
|
898 |
-
|
899 |
-
|
|
|
900 |
}
|
|
|
901 |
frame_relationship[$id].close();
|
902 |
});
|
|
|
903 |
frame_relationship[$id].open();
|
904 |
-
} else {
|
905 |
-
$('.feature-image-id', $el.parent()).val(0);
|
906 |
-
$('.wpt-file-preview', $el.parent()).html('');
|
907 |
|
908 |
-
|
|
|
|
|
909 |
}
|
910 |
return false;
|
911 |
-
}
|
912 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
913 |
|
914 |
-
|
|
|
915 |
var name = jQuery(this).find('td').html();
|
916 |
if (name.search(/^_wpcf_belongs_.*?_id/) != -1) {
|
917 |
jQuery(this).hide();
|
@@ -920,7 +962,7 @@ jQuery(document).ready(function($) {
|
|
920 |
});
|
921 |
|
922 |
// Pagination
|
923 |
-
$('#wpcf-post-relationship').on('change', '.wpcf-relationship-items-per-page', function() {
|
924 |
var $button = $(this), $update = $button.parents('.js-types-relationship-child-posts');
|
925 |
$.ajax({
|
926 |
url: ajaxurl,
|
@@ -928,21 +970,23 @@ jQuery(document).ready(function($) {
|
|
928 |
dataType: 'json',
|
929 |
data: $button.data('action') + '&_wpcf_relationship_items_per_page=' + $button.val(), //+'&'+update.find('.wpcf-pagination-top :input').serialize(),
|
930 |
cache: false,
|
931 |
-
beforeSend: function() {
|
932 |
$button.after('<div style="margin-top:20px;" class="wpcf-ajax-loading-small"></div>');
|
933 |
},
|
934 |
-
success: function(data) {
|
935 |
if (data != null) {
|
936 |
if (typeof data.output != 'undefined') {
|
937 |
$update.html(data.output);
|
938 |
-
$button.next().fadeOut(function(){
|
|
|
|
|
939 |
tChildTable.reset();
|
940 |
if (typeof wptCallbacks != 'undefined') {
|
941 |
wptCallbacks.reset.fire($update);
|
942 |
}
|
943 |
}
|
944 |
if (typeof data.conditionals != 'undefined'
|
945 |
-
|
946 |
wptCond.addConditionals(data.conditionals);
|
947 |
}
|
948 |
}
|
@@ -950,14 +994,14 @@ jQuery(document).ready(function($) {
|
|
950 |
* select2
|
951 |
*/
|
952 |
wpcfBindSelect2($);
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
}
|
962 |
});
|
963 |
});
|
@@ -966,6 +1010,7 @@ jQuery(document).ready(function($) {
|
|
966 |
* Init
|
967 |
*/
|
968 |
wpcfRelationshipInit('', 'init');
|
|
|
969 |
});
|
970 |
|
971 |
|
@@ -1132,6 +1177,7 @@ function wpcfBindSelect2For( element ) {
|
|
1132 |
jQuery(document).ready(function($) {
|
1133 |
wpcfBindSelect2($);
|
1134 |
|
|
|
1135 |
$( '.wpcf-pr-belongs[data-belongs-title]' ).each( function() {
|
1136 |
var inputRelationId = $( this ),
|
1137 |
inputShowRelationTitle = $( '<input type="textfield" readonly="readonly" style="cursor:pointer; width: 100%; max-width:300px;">' );
|
@@ -1149,6 +1195,23 @@ jQuery(document).ready(function($) {
|
|
1149 |
} );
|
1150 |
});
|
1151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1152 |
|
1153 |
/**
|
1154 |
* Fix for Select2
|
127 |
|
128 |
tTagBox = {
|
129 |
clean: function(tags) {
|
130 |
+
var comma = wpcfGetCommaSign();
|
131 |
if (',' !== comma)
|
132 |
tags = tags.replace(new RegExp(comma, 'g'), ',');
|
133 |
tags = tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, '');
|
137 |
},
|
138 |
parseTags: function(el) {
|
139 |
var id = el.id, num = id.split('-check-num-')[1], taxbox = $(el).closest('.js-types-child-tagsdiv'),
|
140 |
+
thetags = taxbox.find('.the-tags'), comma = wpcfGetCommaSign(),
|
141 |
current_tags = thetags.val().split(comma), new_tags = [];
|
142 |
+
|
143 |
delete current_tags[num];
|
144 |
|
145 |
$.each(current_tags, function(key, val) {
|
159 |
tagchecklist = $('.tagchecklist', el),
|
160 |
id = $(el).attr('id'),
|
161 |
current_tags, disabled,
|
162 |
+
comma = wpcfGetCommaSign();
|
163 |
|
164 |
if (!thetags.length) {
|
165 |
return;
|
199 |
a = a || false;
|
200 |
var tags = $('.the-tags', el),
|
201 |
newtag = $('input.js-types-newtag', el),
|
202 |
+
comma = wpcfGetCommaSign(),
|
203 |
newtags, text;
|
204 |
|
205 |
text = a ? $(a).text() : newtag.val();
|
271 |
}
|
272 |
}).each(function() {
|
273 |
var tax = $(this).data('types-tax'),
|
274 |
+
comma = wpcfGetCommaSign();
|
275 |
$(this).suggest(ajaxurl + '?action=ajax-tag-search&tax=' + tax, {delay: 500, minchars: 2, multiple: true, multipleSep: comma + ' '});
|
276 |
});
|
277 |
|
303 |
var frame_relationship = [];
|
304 |
window.wpcf_pr_edited = false;
|
305 |
// Mark as edited field
|
306 |
+
$('#wpcf-post-relationship table').on('click', ':input', function () {
|
307 |
window.wpcf_pr_edited = true;
|
308 |
$(this).parent().addClass('wpcf-pr-edited');
|
309 |
});
|
311 |
/*
|
312 |
* Parent form
|
313 |
*/
|
314 |
+
jQuery('.wpcf-pr-has-apply').click(function () {
|
315 |
var $thiz = jQuery(this);
|
316 |
jQuery(this).parent().slideUp().parent().parent().find('.wpcf-pr-edit').fadeIn();
|
317 |
var txt = new Array();
|
318 |
+
jQuery(this).parent().find('input:checked').each(function () {
|
319 |
txt.push(jQuery(this).next().html());
|
320 |
});
|
321 |
if (txt.length < 1) {
|
326 |
}
|
327 |
jQuery(this).parent().parent().parent().find('.wpcf-pr-has-summary').html(wpcf_pr_has_update);
|
328 |
});
|
329 |
+
jQuery('.wpcf-pr-belongs-apply').click(function () {
|
330 |
var $thiz = jQuery(this);
|
331 |
jQuery(this).parent().slideUp().parent().parent().find('.wpcf-pr-edit').fadeIn();
|
332 |
var txt = new Array();
|
333 |
+
jQuery(this).parent().find('input:checked').each(function () {
|
334 |
txt.push(jQuery(this).next().html());
|
335 |
});
|
336 |
if (txt.length < 1) {
|
342 |
jQuery(this).parent().parent().parent().find('.wpcf-pr-belongs-summary').html(wpcf_pr_belongs_update);
|
343 |
return false;
|
344 |
});
|
345 |
+
jQuery('.wpcf-pr-has-cancel').click(function () {
|
346 |
jQuery(this).parent().find('.checkbox').removeAttr('checked');
|
347 |
for (var checkbox in window.wpcf_pr_has_snapshot) {
|
348 |
jQuery('#' + window.wpcf_pr_has_snapshot[checkbox]).attr('checked', 'checked');
|
349 |
}
|
350 |
jQuery(this).parent().slideUp().parent().parent().find('.wpcf-pr-edit').fadeIn();
|
351 |
});
|
352 |
+
jQuery('.wpcf-pr-belongs-cancel').click(function () {
|
353 |
jQuery(this).parent().find('.checkbox').removeAttr('checked');
|
354 |
for (var checkbox in window.wpcf_pr_belongs_snapshot) {
|
355 |
jQuery('#' + window.wpcf_pr_belongs_snapshot[checkbox]).attr('checked', 'checked');
|
356 |
}
|
357 |
jQuery(this).parent().slideUp().parent().parent().find('.wpcf-pr-edit').fadeIn();
|
358 |
});
|
359 |
+
jQuery('.wpcf-pr-edit').click(function () {
|
360 |
window.wpcf_pr_has_snapshot = new Array();
|
361 |
window.wpcf_pr_belongs_snapshot = new Array();
|
362 |
var this_id = jQuery(this).attr('id');
|
363 |
if (this_id == 'wpcf-pr-has-edit') {
|
364 |
+
jQuery(this).next().find('.checkbox:checked').each(function () {
|
365 |
window.wpcf_pr_has_snapshot.push(jQuery(this).attr('id'));
|
366 |
});
|
367 |
} else {
|
368 |
+
jQuery(this).next().find('input:checked').each(function () {
|
369 |
window.wpcf_pr_belongs_snapshot.push(jQuery(this).attr('id'));
|
370 |
});
|
371 |
}
|
375 |
/**
|
376 |
* POST EDIT SCREEN
|
377 |
*/
|
378 |
+
$('#wpcf-post-relationship').on('click', '.js-types-add-child', function () {
|
379 |
+
if ($(this).hasClass('disabled'))
|
380 |
return false;
|
381 |
|
382 |
wpcfInitValueOfSelect2DoneClear();
|
389 |
type: 'get',
|
390 |
dataType: 'json',
|
391 |
cache: false,
|
392 |
+
beforeSend: function () {
|
393 |
$button.after('<div style="margin-top:20px;"></div>').next().addClass('wpcf-ajax-loading-small');
|
394 |
},
|
395 |
+
success: function (data) {
|
396 |
if (data != null) {
|
397 |
if (typeof data.output != 'undefined') {
|
398 |
$('tbody', $table).prepend(data.output);
|
406 |
wptCond.addConditionals(data.conditionals);
|
407 |
}
|
408 |
if ('undefined' != typeof data.child_id) {
|
409 |
+
$('#types-child-row-' + data.child_id).on('click', '.js-wpt-file-upload', function (event) {
|
410 |
wptFile.bindOpen($(this), false);
|
411 |
});
|
412 |
}
|
413 |
}
|
414 |
+
$button.next().fadeOut(function () {
|
415 |
$(this).remove();
|
416 |
});
|
417 |
+
if ('undefined' != typeof wptFile) {
|
418 |
wptFile.init();
|
419 |
}
|
420 |
/**
|
421 |
* select2
|
422 |
*/
|
423 |
wpcfBindSelect2($);
|
424 |
+
|
425 |
+
var data_for_events = {
|
426 |
+
table: $table
|
427 |
+
};
|
428 |
+
|
429 |
+
$(document).trigger('js_event_wpcf_types_relationship_child_added', [data_for_events]);
|
430 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_changed', [data_for_events]);
|
431 |
},
|
432 |
+
complete: function () {
|
433 |
typesRelationControlsAjaxComplete();
|
434 |
}
|
435 |
});
|
436 |
return false;
|
437 |
});
|
438 |
+
jQuery('.wpcf-pr-delete-ajax').live('click', function () {
|
439 |
+
if ($(this).hasClass('disabled'))
|
440 |
return false;
|
441 |
|
442 |
wpcfInitValueOfSelect2DoneClear();
|
454 |
type: 'get',
|
455 |
dataType: 'json',
|
456 |
cache: false,
|
457 |
+
beforeSend: function () {
|
458 |
object.after('<div style="margin-top:20px;"></div>').next()
|
459 |
+
.addClass('wpcf-ajax-loading-small');
|
460 |
},
|
461 |
+
success: function (data) {
|
462 |
if (data != null) {
|
463 |
if (typeof data.output != 'undefined') {
|
464 |
+
object.parent().parent().fadeOut(function () {
|
465 |
jQuery(this).remove();
|
466 |
wpcfRelationshipInit('', 'delete');
|
467 |
});
|
468 |
}
|
469 |
}
|
470 |
+
object.next().fadeOut(function () {
|
471 |
jQuery(this).remove();
|
472 |
});
|
473 |
/**
|
474 |
* reload
|
475 |
*/
|
476 |
selectedIndex = $('#wpcf-post-relationship .wpcf-pr-pagination-select').prop('selectedIndex');
|
477 |
+
if ($('tbody tr', $table).length < 2) {
|
478 |
+
if (selectedIndex) {
|
479 |
selectedIndex--;
|
480 |
+
$('#wpcf-post-relationship .wpcf-pr-pagination-select').prop('selectedIndex', selectedIndex);
|
481 |
}
|
482 |
}
|
483 |
$('#wpcf-post-relationship .wpcf-pr-pagination-select').trigger('change');
|
485 |
* select2
|
486 |
*/
|
487 |
wpcfBindSelect2($);
|
488 |
+
|
489 |
+
var data_for_events = {
|
490 |
+
table: $table
|
491 |
+
};
|
492 |
+
|
493 |
+
$(document).trigger('js_event_wpcf_types_relationship_child_deleted', [data_for_events]);
|
494 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_changed', [data_for_events]);
|
495 |
},
|
496 |
+
complete: function () {
|
497 |
typesRelationControlsAjaxComplete();
|
498 |
}
|
499 |
});
|
500 |
return false;
|
501 |
});
|
502 |
+
jQuery('.wpcf-pr-update-belongs').live('click', function () {
|
503 |
var object = jQuery(this);
|
504 |
jQuery.ajax({
|
505 |
url: jQuery(this).attr('href'),
|
507 |
dataType: 'json',
|
508 |
data: jQuery(this).attr('href') + '&' + object.prev().serialize(),
|
509 |
cache: false,
|
510 |
+
beforeSend: function () {
|
511 |
object.after('<div style="margin-top:20px;"></div>').next()
|
512 |
+
.addClass('wpcf-ajax-loading-small');
|
513 |
},
|
514 |
+
success: function (data) {
|
515 |
+
object.next().fadeOut(2000, function () {
|
516 |
jQuery(this).remove();
|
517 |
});
|
518 |
}
|
519 |
});
|
520 |
return false;
|
521 |
});
|
522 |
+
$('#wpcf-post-relationship').on('click', '.wpcf-pr-pagination-link', function () {
|
523 |
if (wpcfPrIsEdited()) {
|
524 |
var answer = confirm(wpcf_pr_pagination_warning);
|
525 |
if (answer == false) {
|
534 |
type: 'get',
|
535 |
dataType: 'json',
|
536 |
cache: false,
|
537 |
+
beforeSend: function () {
|
538 |
$button.after('<div style="margin-top:20px;"></div>').next()
|
539 |
+
.addClass('wpcf-ajax-loading-small');
|
540 |
},
|
541 |
+
success: function (data) {
|
542 |
if (data != null) {
|
543 |
if (typeof data.output != 'undefined') {
|
544 |
$update.html(data.output);
|
548 |
}
|
549 |
}
|
550 |
if (typeof data.conditionals != 'undefined'
|
551 |
+
&& typeof wptCond != 'undefined') {
|
552 |
wptCond.addConditionals(data.conditionals);
|
553 |
}
|
554 |
}
|
555 |
+
$button.next().fadeOut(function () {
|
556 |
$(this).remove();
|
557 |
});
|
558 |
/**
|
559 |
* select2
|
560 |
*/
|
561 |
wpcfBindSelect2($);
|
562 |
+
|
563 |
+
var $table = $update.find('table'),
|
564 |
+
data_for_events = {
|
565 |
+
table: $table
|
566 |
+
};
|
567 |
+
|
568 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_paged', [data_for_events]);
|
569 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_changed', [data_for_events]);
|
570 |
}
|
571 |
});
|
572 |
return false;
|
573 |
});
|
574 |
+
$('#wpcf-post-relationship').on('change', '.wpcf-pr-pagination-select', function () {
|
575 |
if (wpcfPrIsEdited()) {
|
576 |
var answer = confirm(wpcf_pr_pagination_warning);
|
577 |
if (answer == false) {
|
586 |
type: 'get',
|
587 |
dataType: 'json',
|
588 |
cache: false,
|
589 |
+
beforeSend: function () {
|
590 |
$button.after('<div style="margin-top:20px;"></div>').next().addClass('wpcf-ajax-loading-small');
|
591 |
},
|
592 |
+
success: function (data) {
|
593 |
if (data != null) {
|
594 |
if (typeof data.output != 'undefined') {
|
595 |
$update.html(data.output);
|
602 |
wptCond.addConditionals(data.conditionals);
|
603 |
}
|
604 |
}
|
605 |
+
$button.next().fadeOut(function () {
|
606 |
$(this).remove();
|
607 |
});
|
608 |
/**
|
609 |
* select2
|
610 |
*/
|
611 |
wpcfBindSelect2($);
|
612 |
+
|
613 |
+
var $table = $update.find('table'),
|
614 |
+
data_for_events = {
|
615 |
+
table: $table
|
616 |
+
};
|
617 |
+
|
618 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_paged', [data_for_events]);
|
619 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_changed', [data_for_events]);
|
620 |
}
|
621 |
});
|
622 |
return false;
|
623 |
});
|
624 |
+
$('#wpcf-post-relationship').on('click', '.wpcf-sortable a', function () {
|
625 |
if (wpcfPrIsEdited()) {
|
626 |
var answer = confirm(wpcf_pr_pagination_warning);
|
627 |
if (answer == false) {
|
636 |
type: 'get',
|
637 |
dataType: 'json',
|
638 |
cache: false,
|
639 |
+
beforeSend: function () {
|
640 |
$button.after('<div style="margin-top:20px;"></div>').next().addClass('wpcf-ajax-loading-small');
|
641 |
},
|
642 |
+
success: function (data) {
|
643 |
if (data != null) {
|
644 |
if (typeof data.output != 'undefined') {
|
645 |
$update.html(data.output);
|
649 |
}
|
650 |
}
|
651 |
if (typeof data.conditionals != 'undefined'
|
652 |
+
&& typeof wptCond != 'undefined') {
|
653 |
wptCond.addConditionals(data.conditionals);
|
654 |
}
|
655 |
}
|
656 |
+
$button.next().fadeOut(function () {
|
657 |
$(this).remove();
|
658 |
});
|
659 |
/**
|
660 |
* select2
|
661 |
*/
|
662 |
wpcfBindSelect2($);
|
663 |
+
|
664 |
+
var $table = $update.find('table'),
|
665 |
+
data_for_events = {
|
666 |
+
table: $table
|
667 |
+
};
|
668 |
+
|
669 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_sorted', [data_for_events]);
|
670 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_changed', [data_for_events]);
|
671 |
}
|
672 |
});
|
673 |
return false;
|
674 |
});
|
675 |
+
$('#wpcf-post-relationship').on('click', '.wpcf-pr-save-ajax', function () {
|
676 |
+
if ($(this).hasClass('disabled'))
|
677 |
return false;
|
678 |
|
679 |
wpcfInitValueOfSelect2DoneClear();
|
680 |
|
681 |
+
var $button = $(this), $row = $button.parents('tr'), rowId = $row.attr('id'), valid = true, $table = $row.closest('.js-types-child-table');
|
682 |
if (typeof wptValidation == 'undefined') {
|
683 |
+
$('.js-types-validate', $row).each(function () {
|
684 |
if ($('#post').validate().element($(this)) == false) {
|
685 |
if (typeof typesValidation == 'undefined'
|
686 |
+
|| typesValidation.conditionalIsHidden($(this)) == false) {
|
687 |
valid = false;
|
688 |
}
|
689 |
}
|
690 |
});
|
691 |
} else {
|
692 |
+
$('.js-wpt-validate', $row).each(function () {
|
693 |
if ($('#post').validate().element($(this)) == false) {
|
694 |
if (typeof wptValidation == 'undefined'
|
695 |
+
|| !wptValidation.isIgnored($(this))) {
|
696 |
valid = false;
|
697 |
}
|
698 |
}
|
702 |
return false;
|
703 |
}
|
704 |
$button.parents('.js-types-relationship-child-posts')
|
705 |
+
.find('.wpcf-pr-edited').removeClass('wpcf-pr-edited');
|
706 |
var height = $row.height(), rand = Math.round(Math.random() * 10000);
|
707 |
window.wpcf_pr_edited = false;
|
708 |
|
714 |
dataType: 'json',
|
715 |
data: $row.find(':input').serialize(),
|
716 |
cache: false,
|
717 |
+
beforeSend: function () {
|
718 |
$row.after('<tr id="wpcf-pr-update-' + rand + '"><td style="height: ' + height + 'px;"><div style="margin-top:20px;" class="wpcf-ajax-loading-small"></div></td></tr>').hide();
|
719 |
},
|
720 |
+
success: function (data) {
|
721 |
+
if (data != null) {
|
722 |
+
if (typeof data.output != 'undefined') {
|
723 |
+
var $updatedRowContent = $(data.output);
|
724 |
+
bindRowEventHandlers(false);
|
725 |
+
$row.replaceWith($updatedRowContent);
|
726 |
+
bindRowEventHandlers(true);
|
727 |
wpcfDisableControls();
|
728 |
+
$('#wpcf-pr-update-' + rand + '').remove();
|
729 |
+
wpcfRelationshipInit('', 'save');
|
730 |
tChildTable.reset();
|
731 |
+
if (typeof wptCallbacks != 'undefined') {
|
732 |
+
wptCallbacks.reset.fire('#' + rowId);
|
733 |
}
|
734 |
+
if ('undefined' != typeof wptFile) {
|
735 |
wptFile.init();
|
736 |
}
|
737 |
}
|
738 |
+
if (typeof data.conditionals != 'undefined' && typeof wptCond != 'undefined') {
|
739 |
+
wptCond.addConditionals(data.conditionals);
|
740 |
}
|
741 |
/**
|
742 |
* rebind images
|
743 |
*/
|
744 |
+
if ('function' == typeof bind_colorbox_to_thumbnail_preview) {
|
745 |
bind_colorbox_to_thumbnail_preview();
|
746 |
}
|
747 |
/**
|
748 |
* show errors
|
749 |
*/
|
750 |
+
$('#wpcf-post-relationship div.message').detach();
|
751 |
+
if ('undefined' != typeof data.errors && 0 < data.errors.length) {
|
752 |
+
$('#wpcf-post-relationship h3.hndle').after(data.errors);
|
753 |
}
|
754 |
/**
|
755 |
* select2
|
756 |
*/
|
757 |
wpcfInitValueOfSelect2DoneClear();
|
758 |
+
wpcfBindSelect2($);
|
759 |
|
760 |
var data_for_events = {
|
761 |
table: $table
|
762 |
};
|
763 |
|
764 |
+
$(document).trigger('js_event_wpcf_types_relationship_child_saved', [data_for_events]);
|
765 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_changed', [data_for_events]);
|
766 |
}
|
767 |
},
|
768 |
+
complete: function () {
|
769 |
typesRelationControlsAjaxComplete();
|
770 |
}
|
771 |
});
|
772 |
return false;
|
773 |
});
|
774 |
+
$('#wpcf-post-relationship').on('click', '.wpcf-pr-save-all-link', function () {
|
775 |
var $button = jQuery(this);
|
776 |
if ($button.attr('disabled') == 'disabled') {
|
777 |
return false;
|
779 |
$button.attr('disabled', 'disabled');
|
780 |
var $update = $button.parents('.js-types-relationship-child-posts'), updateId = $update.attr('id'), $table = $('table', $update), valid = true;
|
781 |
if (typeof wptValidation == 'undefined') {
|
782 |
+
$('.js-types-validate', $table).each(function () {
|
783 |
if (typeof typesValidation == 'undefined'
|
784 |
+
|| typesValidation.conditionalIsHidden($(this)) == false) {
|
785 |
if ($('#post').validate().element($(this)) == false) {
|
786 |
valid = false;
|
787 |
}
|
788 |
}
|
789 |
});
|
790 |
} else {
|
791 |
+
$('.js-wpt-validate', $table).each(function () {
|
792 |
if (typeof wptValidation == 'undefined'
|
793 |
+
|| !wptValidation.isIgnored($(this))) {
|
794 |
if ($('#post').validate().element($(this)) == false) {
|
795 |
valid = false;
|
796 |
}
|
810 |
dataType: 'json',
|
811 |
data: $(this).attr('href') + '&' + $(':input', $update).serialize(),
|
812 |
cache: false,
|
813 |
+
beforeSend: function () {
|
814 |
$('tbody', $table).empty().prepend('<tr id="wpcf-pr-update-' + rand + '"><td style="height: ' + height + 'px;"><div style="margin-top:20px;" class="wpcf-ajax-loading-small"></div></td></tr>');
|
815 |
},
|
816 |
+
success: function (data) {
|
817 |
if (data != null) {
|
818 |
if (typeof data.output != 'undefined') {
|
819 |
$update.replaceWith(data.output);
|
821 |
wpcfRelationshipInit('', 'save_all');
|
822 |
tChildTable.reset();
|
823 |
if (typeof wptCallbacks != 'undefined') {
|
824 |
+
wptCallbacks.reset.fire('#' + updateId);
|
825 |
}
|
826 |
}
|
827 |
if (typeof data.conditionals != 'undefined' && typeof wptCond != 'undefined') {
|
828 |
wptCond.addConditionals(data.conditionals);
|
829 |
}
|
830 |
+
if ('undefined' != typeof wptFile) {
|
831 |
wptFile.init();
|
832 |
}
|
833 |
/**
|
834 |
* rebind images
|
835 |
*/
|
836 |
+
if ('function' == typeof bind_colorbox_to_thumbnail_preview) {
|
837 |
bind_colorbox_to_thumbnail_preview();
|
838 |
}
|
839 |
/**
|
840 |
* show errors
|
841 |
*/
|
842 |
$('#wpcf-post-relationship div.message').detach();
|
843 |
+
if ('undefined' != typeof data.errors && 0 < data.errors.length) {
|
844 |
$('#wpcf-post-relationship h3.hndle').after(data.errors);
|
845 |
}
|
846 |
}
|
848 |
* select2
|
849 |
*/
|
850 |
wpcfBindSelect2($);
|
851 |
+
|
852 |
+
var $table = $update.find('table'),
|
853 |
+
data_for_events = {
|
854 |
+
table: $table
|
855 |
+
};
|
856 |
+
|
857 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_saved', [data_for_events]);
|
858 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_changed', [data_for_events]);
|
859 |
}
|
860 |
});
|
861 |
return false;
|
862 |
});
|
863 |
|
864 |
/**
|
865 |
+
* Handle the click on a link to set or remove a featured image.
|
866 |
+
*
|
867 |
+
* @since unknown
|
868 |
*/
|
869 |
+
var setRemoveFeaturedImageHandler = function (event) {
|
870 |
+
var $setRemoveLink = $(this);
|
871 |
+
var $featuredImageContainer = $setRemoveLink.parent();
|
872 |
+
|
873 |
+
var $data = $setRemoveLink.data();
|
874 |
+
var $id = $setRemoveLink.attr('id');
|
875 |
+
|
876 |
+
var currentAttachmentId = function (newValue) {
|
877 |
+
if (typeof newValue == 'undefined') {
|
878 |
+
return $('.feature-image-id', $setRemoveLink.parent()).val();
|
879 |
+
} else {
|
880 |
+
$setRemoveLink.html(0 == newValue ? $data.set : $data.remove);
|
881 |
+
$setRemoveLink.parent().find('.feature-image-id').val(newValue);
|
882 |
+
}
|
883 |
+
};
|
884 |
+
|
885 |
+
var setImagePreview = function (url) {
|
886 |
+
var $imagePreviewContainer = $featuredImageContainer.find('.wpt-file-preview');
|
887 |
+
if (null == url || url.length == 0) {
|
888 |
+
$imagePreviewContainer.html('');
|
889 |
+
} else {
|
890 |
+
if (0 == $imagePreviewContainer.find('img').length) {
|
891 |
+
$imagePreviewContainer.append('<img src="">');
|
892 |
+
}
|
893 |
+
$imagePreviewContainer.find('img').attr('src', url);
|
894 |
+
}
|
895 |
+
};
|
896 |
+
|
897 |
+
if (0 == currentAttachmentId()) {
|
898 |
+
if (event) {
|
899 |
event.preventDefault();
|
900 |
}
|
901 |
+
|
902 |
+
// If the media frame already exists, we're going to reopen it,
|
903 |
+
// but in all cases, we need to overwrite the callback.
|
904 |
+
//
|
905 |
+
// When a row is updated (replaced with new element), the callback would
|
906 |
+
// still hold reference to elements from the old row and break.
|
907 |
+
if (!frame_relationship[$id]) {
|
908 |
+
|
909 |
+
// No media frame exists yet, create it.
|
910 |
+
frame_relationship[$id] = wp.media.frames.customHeader = wp.media({
|
911 |
+
title: $setRemoveLink.html(),
|
912 |
+
|
913 |
+
// Tell the modal to show only images.
|
914 |
+
library: {
|
915 |
+
type: "image"
|
916 |
+
}
|
917 |
+
});
|
918 |
}
|
919 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
920 |
// When an image is selected, run a callback.
|
921 |
+
frame_relationship[$id].on('select', function () {
|
922 |
+
|
923 |
// Grab the selected attachment.
|
924 |
var attachment = frame_relationship[$id].state().get('selection').first();
|
925 |
|
926 |
+
if ('undefined' != typeof attachment.id) {
|
927 |
+
currentAttachmentId(attachment.id);
|
|
|
|
|
|
|
|
|
|
|
928 |
}
|
929 |
+
|
930 |
+
if ('undefined' != typeof attachment.attributes.sizes.thumbnail) {
|
931 |
+
setImagePreview(attachment.attributes.sizes.thumbnail.url);
|
932 |
}
|
933 |
+
|
934 |
frame_relationship[$id].close();
|
935 |
});
|
936 |
+
|
937 |
frame_relationship[$id].open();
|
|
|
|
|
|
|
938 |
|
939 |
+
} else {
|
940 |
+
setImagePreview(null);
|
941 |
+
currentAttachmentId(0);
|
942 |
}
|
943 |
return false;
|
944 |
+
};
|
945 |
+
|
946 |
+
var bindRowEventHandlers = function (bind) {
|
947 |
+
var $postRelationshipTable = $('#wpcf-post-relationship');
|
948 |
+
if (bind) {
|
949 |
+
$postRelationshipTable.on('click', '.feature-image', setRemoveFeaturedImageHandler);
|
950 |
+
} else {
|
951 |
+
$postRelationshipTable.off('click', '.feature-image', setRemoveFeaturedImageHandler);
|
952 |
+
}
|
953 |
+
};
|
954 |
|
955 |
+
// We need to hide the _wpcf_belongs_xxxx_id field for WPML.
|
956 |
+
jQuery('#icl_mcs_details table tbody tr').each(function () {
|
957 |
var name = jQuery(this).find('td').html();
|
958 |
if (name.search(/^_wpcf_belongs_.*?_id/) != -1) {
|
959 |
jQuery(this).hide();
|
962 |
});
|
963 |
|
964 |
// Pagination
|
965 |
+
$('#wpcf-post-relationship').on('change', '.wpcf-relationship-items-per-page', function () {
|
966 |
var $button = $(this), $update = $button.parents('.js-types-relationship-child-posts');
|
967 |
$.ajax({
|
968 |
url: ajaxurl,
|
970 |
dataType: 'json',
|
971 |
data: $button.data('action') + '&_wpcf_relationship_items_per_page=' + $button.val(), //+'&'+update.find('.wpcf-pagination-top :input').serialize(),
|
972 |
cache: false,
|
973 |
+
beforeSend: function () {
|
974 |
$button.after('<div style="margin-top:20px;" class="wpcf-ajax-loading-small"></div>');
|
975 |
},
|
976 |
+
success: function (data) {
|
977 |
if (data != null) {
|
978 |
if (typeof data.output != 'undefined') {
|
979 |
$update.html(data.output);
|
980 |
+
$button.next().fadeOut(function () {
|
981 |
+
$(this).remove();
|
982 |
+
});
|
983 |
tChildTable.reset();
|
984 |
if (typeof wptCallbacks != 'undefined') {
|
985 |
wptCallbacks.reset.fire($update);
|
986 |
}
|
987 |
}
|
988 |
if (typeof data.conditionals != 'undefined'
|
989 |
+
&& typeof wptCond != 'undefined') {
|
990 |
wptCond.addConditionals(data.conditionals);
|
991 |
}
|
992 |
}
|
994 |
* select2
|
995 |
*/
|
996 |
wpcfBindSelect2($);
|
997 |
+
|
998 |
+
var $table = $update.find('table'),
|
999 |
+
data_for_events = {
|
1000 |
+
table: $table
|
1001 |
+
};
|
1002 |
+
|
1003 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_reloaded', [data_for_events]);
|
1004 |
+
$(document).trigger('js_event_wpcf_types_relationship_children_changed', [data_for_events]);
|
1005 |
}
|
1006 |
});
|
1007 |
});
|
1010 |
* Init
|
1011 |
*/
|
1012 |
wpcfRelationshipInit('', 'init');
|
1013 |
+
bindRowEventHandlers(true);
|
1014 |
});
|
1015 |
|
1016 |
|
1177 |
jQuery(document).ready(function($) {
|
1178 |
wpcfBindSelect2($);
|
1179 |
|
1180 |
+
|
1181 |
$( '.wpcf-pr-belongs[data-belongs-title]' ).each( function() {
|
1182 |
var inputRelationId = $( this ),
|
1183 |
inputShowRelationTitle = $( '<input type="textfield" readonly="readonly" style="cursor:pointer; width: 100%; max-width:300px;">' );
|
1195 |
} );
|
1196 |
});
|
1197 |
|
1198 |
+
/**
|
1199 |
+
* Returns comma sign
|
1200 |
+
*
|
1201 |
+
* Using postL10 if not undefined, otherwise tagsBoxL10n
|
1202 |
+
* and if both not defined it will return ','
|
1203 |
+
*/
|
1204 |
+
function wpcfGetCommaSign() {
|
1205 |
+
var comma = ',';
|
1206 |
+
|
1207 |
+
if( typeof postL10n !== 'undefined' && postL10n.comma !== undefined ) {
|
1208 |
+
comma = postL10n.comma;
|
1209 |
+
} else if( typeof window.tagsBoxL10n !== 'undefined' && window.tagsBoxL10n.tagDelimiter !== undefined ) {
|
1210 |
+
comma = window.tagsBoxL10n.tagDelimiter;
|
1211 |
+
}
|
1212 |
+
|
1213 |
+
return comma;
|
1214 |
+
}
|
1215 |
|
1216 |
/**
|
1217 |
* Fix for Select2
|
library/toolset/types/embedded/usermeta-init.php
CHANGED
@@ -1,102 +1,98 @@
|
|
1 |
<?php
|
|
|
2 |
// Add usermeta and post fileds groups to access.
|
3 |
$usermeta_access = new Usermeta_Access;
|
4 |
$fields_access = new Post_Fields_Access;
|
5 |
-
|
6 |
|
7 |
/**
|
8 |
* Add User Fields menus hook
|
9 |
*
|
10 |
-
* @
|
11 |
-
* @since Types 1.3
|
12 |
-
*
|
13 |
-
*
|
14 |
*/
|
15 |
function wpcf_admin_menu_edit_user_fields_hook() {
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
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 |
-
. '/js/fields-form.js', array('wpcf-js') );
|
66 |
-
|
67 |
-
/**
|
68 |
-
* fields form to manipulate fields
|
69 |
-
*/
|
70 |
-
wp_enqueue_script(
|
71 |
-
'wpcf-admin-fields-form',
|
72 |
-
WPCF_RES_RELPATH.'/js/fields-form.js',
|
73 |
-
array(),
|
74 |
-
WPCF_VERSION
|
75 |
-
);
|
76 |
-
|
77 |
-
/*
|
78 |
-
* Enqueue styles
|
79 |
-
*/
|
80 |
-
wp_enqueue_style( 'wpcf-scroll', WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/visual-editor/res/css/scroll.css' );
|
81 |
-
wp_enqueue_style( 'font-awesome' );
|
82 |
-
|
83 |
-
add_action( 'admin_footer', 'wpcf_admin_fields_form_js_validation' );
|
84 |
-
require_once WPCF_INC_ABSPATH . '/fields.php';
|
85 |
-
require_once WPCF_INC_ABSPATH . '/usermeta.php';
|
86 |
-
require_once WPCF_INC_ABSPATH . '/fields-form.php';
|
87 |
-
require_once WPCF_INC_ABSPATH . '/usermeta-form.php';
|
88 |
-
|
89 |
-
require_once WPCF_INC_ABSPATH.'/classes/class.types.admin.edit.meta.fields.group.php';
|
90 |
-
$wpcf_admin = new Types_Admin_Edit_Meta_Fields_Group();
|
91 |
-
$wpcf_admin->init_admin();
|
92 |
-
$form = $wpcf_admin->form();
|
93 |
-
wpcf_form( 'wpcf_form_fields', $form );
|
94 |
-
|
95 |
-
return;
|
96 |
-
|
97 |
-
$form = wpcf_admin_usermeta_form();
|
98 |
-
wpcf_form( 'wpcf_form_fields', $form );
|
99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
|
102 |
/**
|
@@ -431,8 +427,6 @@ function wpcf_admin_user_profile_save_hook( $user_id )
|
|
431 |
|
432 |
/*
|
433 |
* Register Usermeta Groups in Types Access
|
434 |
-
*
|
435 |
-
*
|
436 |
*/
|
437 |
|
438 |
class Usermeta_Access
|
1 |
<?php
|
2 |
+
|
3 |
// Add usermeta and post fileds groups to access.
|
4 |
$usermeta_access = new Usermeta_Access;
|
5 |
$fields_access = new Post_Fields_Access;
|
6 |
+
|
7 |
|
8 |
/**
|
9 |
* Add User Fields menus hook
|
10 |
*
|
11 |
+
* @since 1.3
|
|
|
|
|
|
|
12 |
*/
|
13 |
function wpcf_admin_menu_edit_user_fields_hook() {
|
14 |
+
do_action( 'wpcf_admin_page_init' );
|
15 |
+
|
16 |
+
// Group filter
|
17 |
+
wp_enqueue_script( 'wpcf-filter-js',
|
18 |
+
WPCF_EMBEDDED_RES_RELPATH
|
19 |
+
. '/js/custom-fields-form-filter.js', array( 'jquery' ), WPCF_VERSION );
|
20 |
+
|
21 |
+
// Form
|
22 |
+
$asset_manager = Types_Asset_Manager::get_instance();
|
23 |
+
$asset_manager->enqueue_scripts(
|
24 |
+
array(
|
25 |
+
Types_Asset_Manager::SCRIPT_JQUERY_UI_VALIDATION,
|
26 |
+
Types_Asset_Manager::SCRIPT_ADDITIONAL_VALIDATION_RULES,
|
27 |
+
)
|
28 |
+
);
|
29 |
+
|
30 |
+
// Scroll
|
31 |
+
wp_enqueue_script( 'wpcf-scrollbar',
|
32 |
+
WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/visual-editor/res/js/scrollbar.js',
|
33 |
+
array( 'jquery' ) );
|
34 |
+
wp_enqueue_script( 'wpcf-mousewheel',
|
35 |
+
WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/visual-editor/res/js/mousewheel.js',
|
36 |
+
array( 'wpcf-scrollbar' ) );
|
37 |
+
//Css editor
|
38 |
+
wp_enqueue_script( 'wpcf-form-codemirror',
|
39 |
+
WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.js',
|
40 |
+
array( 'wpcf-js' ) );
|
41 |
+
wp_enqueue_script( 'wpcf-form-codemirror-css-editor',
|
42 |
+
WPCF_RELPATH . '/resources/js/codemirror234/mode/css/css.js',
|
43 |
+
array( 'wpcf-js' ) );
|
44 |
+
wp_enqueue_script( 'wpcf-form-codemirror-html-editor',
|
45 |
+
WPCF_RELPATH . '/resources/js/codemirror234/mode/xml/xml.js',
|
46 |
+
array( 'wpcf-js' ) );
|
47 |
+
wp_enqueue_script( 'wpcf-form-codemirror-html-editor2',
|
48 |
+
WPCF_RELPATH . '/resources/js/codemirror234/mode/htmlmixed/htmlmixed.js',
|
49 |
+
array( 'wpcf-js' ) );
|
50 |
+
wp_enqueue_script( 'wpcf-form-codemirror-editor-resize',
|
51 |
+
WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.resizable.min.js',
|
52 |
+
array( 'wpcf-js' ) );
|
53 |
+
|
54 |
+
wp_enqueue_style( 'wpcf-css-editor',
|
55 |
+
WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.css' );
|
56 |
+
wp_enqueue_style( 'wpcf-usermeta',
|
57 |
+
WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css' );
|
58 |
+
|
59 |
+
// MAIN
|
60 |
+
wp_enqueue_script( 'wpcf-fields-form',
|
61 |
+
WPCF_EMBEDDED_RES_RELPATH
|
62 |
+
. '/js/fields-form.js', array( 'wpcf-js' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
+
/**
|
65 |
+
* fields form to manipulate fields
|
66 |
+
*/
|
67 |
+
wp_enqueue_script(
|
68 |
+
'wpcf-admin-fields-form',
|
69 |
+
WPCF_RES_RELPATH . '/js/fields-form.js',
|
70 |
+
array(),
|
71 |
+
WPCF_VERSION
|
72 |
+
);
|
73 |
+
|
74 |
+
/*
|
75 |
+
* Enqueue styles
|
76 |
+
*/
|
77 |
+
wp_enqueue_style( 'wpcf-scroll', WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/visual-editor/res/css/scroll.css' );
|
78 |
+
wp_enqueue_style( 'font-awesome' );
|
79 |
+
|
80 |
+
add_action( 'admin_footer', 'wpcf_admin_fields_form_js_validation' );
|
81 |
+
require_once WPCF_INC_ABSPATH . '/fields.php';
|
82 |
+
require_once WPCF_INC_ABSPATH . '/usermeta.php';
|
83 |
+
require_once WPCF_INC_ABSPATH . '/fields-form.php';
|
84 |
+
require_once WPCF_INC_ABSPATH . '/usermeta-form.php';
|
85 |
+
|
86 |
+
require_once WPCF_INC_ABSPATH . '/classes/class.types.admin.edit.meta.fields.group.php';
|
87 |
+
$wpcf_admin = new Types_Admin_Edit_Meta_Fields_Group();
|
88 |
+
$wpcf_admin->init_admin();
|
89 |
+
$form = $wpcf_admin->form();
|
90 |
+
wpcf_form( 'wpcf_form_fields', $form );
|
91 |
+
|
92 |
+
return;
|
93 |
+
|
94 |
+
$form = wpcf_admin_usermeta_form();
|
95 |
+
wpcf_form( 'wpcf_form_fields', $form );
|
96 |
}
|
97 |
|
98 |
/**
|
427 |
|
428 |
/*
|
429 |
* Register Usermeta Groups in Types Access
|
|
|
|
|
430 |
*/
|
431 |
|
432 |
class Usermeta_Access
|
library/toolset/types/embedded/views/templates/editor-modal-image.tpl.php
CHANGED
@@ -11,21 +11,24 @@ if ( !isset( $data ) ) {
|
|
11 |
$data = array();
|
12 |
}
|
13 |
|
14 |
-
$data = array_merge(
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
29 |
|
30 |
if ($data['warning_remote']) {
|
31 |
if ( wpcf_is_embedded() ) {
|
11 |
$data = array();
|
12 |
}
|
13 |
|
14 |
+
$data = array_merge(
|
15 |
+
array(
|
16 |
+
'alignment' => 'none',
|
17 |
+
'alignment_options' => array(),
|
18 |
+
'alt' => '',
|
19 |
+
'height' => '',
|
20 |
+
'image' => '',
|
21 |
+
'image_size' => 'full',
|
22 |
+
'preview' => '',
|
23 |
+
'size_options' => array(),
|
24 |
+
'title' => '',
|
25 |
+
'warning_remote' => false,
|
26 |
+
'width' => '',
|
27 |
+
'url' => false,
|
28 |
+
'onload' => '',
|
29 |
+
),
|
30 |
+
(array) $data
|
31 |
+
);
|
32 |
|
33 |
if ($data['warning_remote']) {
|
34 |
if ( wpcf_is_embedded() ) {
|
library/toolset/types/includes/migration.php
DELETED
@@ -1,599 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Migration functions
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Migration form.
|
10 |
-
*
|
11 |
-
* @global object $wpdb
|
12 |
-
*
|
13 |
-
* @return array
|
14 |
-
*/
|
15 |
-
function wpcf_admin_migration_form()
|
16 |
-
{
|
17 |
-
global $wpdb;
|
18 |
-
$wpcf_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
|
19 |
-
$wpcf_taxonomies = get_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array());
|
20 |
-
$wpcf_types_defaults = wpcf_custom_types_default();
|
21 |
-
$wpcf_taxonomies_defaults = wpcf_custom_taxonomies_default();
|
22 |
-
|
23 |
-
$form = array();
|
24 |
-
$form['#form']['callback'] = 'wpcf_admin_migration_form_submit';
|
25 |
-
|
26 |
-
$cfui_types = get_option('cpt_custom_post_types', array());
|
27 |
-
$cfui_types_migrated = array();
|
28 |
-
|
29 |
-
$cfui_taxonomies = get_option('cpt_custom_tax_types', array());
|
30 |
-
$cfui_tax_migrated = array();
|
31 |
-
|
32 |
-
if (!empty($cfui_types)) {
|
33 |
-
$form['types_title'] = array(
|
34 |
-
'#type' => 'markup',
|
35 |
-
'#markup' => '<h3>' . __('Custom Types UI Post Types', 'wpcf') . '</h3>',
|
36 |
-
);
|
37 |
-
|
38 |
-
foreach ($cfui_types as $key => $cfui_type) {
|
39 |
-
$exists = array_key_exists(sanitize_title($cfui_type['name']),
|
40 |
-
$wpcf_types);
|
41 |
-
if ($exists) {
|
42 |
-
$attributes = array('readonly' => 'readonly', 'disabled' => 'disabled');
|
43 |
-
$add = __('(exists)', 'wpcf');
|
44 |
-
} else {
|
45 |
-
$attributes = array();
|
46 |
-
$add = '';
|
47 |
-
}
|
48 |
-
$slug = $id = sanitize_title($cfui_type['name']);
|
49 |
-
$form['types-' . $slug] = array(
|
50 |
-
'#type' => 'checkbox',
|
51 |
-
'#name' => 'cfui[types][]',
|
52 |
-
'#value' => $slug,
|
53 |
-
'#title' => !empty($cfui_type['label']) ? $cfui_type['label'] . ' ' . $add : $slug . ' ' . $add,
|
54 |
-
'#inline' => true,
|
55 |
-
'#after' => ' ',
|
56 |
-
'#default_value' => $exists ? 0 : 1,
|
57 |
-
'#attributes' => $attributes,
|
58 |
-
);
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
if (!empty($cfui_taxonomies)) {
|
63 |
-
$form['tax_titles'] = array(
|
64 |
-
'#type' => 'markup',
|
65 |
-
'#markup' => '<h3>' . __('Custom Types UI Taxonomies', 'wpcf') . '</h3>',
|
66 |
-
);
|
67 |
-
|
68 |
-
foreach ($cfui_taxonomies as $key => $cfui_tax) {
|
69 |
-
$title = !empty($cfui_tax['label']) ? $cfui_tax['label'] : $slug;
|
70 |
-
$exists = array_key_exists(sanitize_title($cfui_tax['name']),
|
71 |
-
$wpcf_taxonomies);
|
72 |
-
if ($exists) {
|
73 |
-
$attributes = array('readonly' => 'readonly', 'disabled' => 'disabled');
|
74 |
-
$add = __('(exists)', 'wpcf');
|
75 |
-
} else {
|
76 |
-
$attributes = array();
|
77 |
-
$add = '';
|
78 |
-
}
|
79 |
-
$slug = $id = sanitize_title($cfui_tax['name']);
|
80 |
-
$form['types-' . $slug] = array(
|
81 |
-
'#type' => 'checkbox',
|
82 |
-
'#name' => 'cfui[tax][]',
|
83 |
-
'#value' => $slug,
|
84 |
-
'#title' => $title . ' ' . $add,
|
85 |
-
'#inline' => true,
|
86 |
-
'#after' => ' ',
|
87 |
-
'#default_value' => $exists ? 0 : 1,
|
88 |
-
'#attributes' => $attributes,
|
89 |
-
);
|
90 |
-
}
|
91 |
-
}
|
92 |
-
|
93 |
-
if (!empty($cfui_types) || !empty($cfui_taxonomies)) {
|
94 |
-
$form['deactivate-cfui'] = array(
|
95 |
-
'#type' => 'checkbox',
|
96 |
-
'#name' => 'deactivate-cfui',
|
97 |
-
'#before' => '<br /><br />',
|
98 |
-
'#default_value' => 1,
|
99 |
-
'#title' => __('Disable Custom Types UI after importing the configuration (leave this checked to avoid defining custom types twice)', 'wpcf'),
|
100 |
-
);
|
101 |
-
};
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Advanced Custom Fields
|
105 |
-
*/
|
106 |
-
if (class_exists('acf') && !class_exists('acf_pro')) {
|
107 |
-
$acf_groups = get_posts('post_type=acf&status=publish&numberposts=-1');
|
108 |
-
if (!empty($acf_groups)) {
|
109 |
-
$wpcf_types = wpcf_admin_fields_get_available_types();
|
110 |
-
$wpcf_types_options = array();
|
111 |
-
foreach ($wpcf_types as $type => $data) {
|
112 |
-
$wpcf_types_options[$type] = array(
|
113 |
-
'#title' => $data['title'],
|
114 |
-
'#value' => $type,
|
115 |
-
);
|
116 |
-
}
|
117 |
-
$acf_types = array(
|
118 |
-
'text' => 'textfield',
|
119 |
-
'textarea' => 'textarea',
|
120 |
-
'wysiwyg' => 'wysiwyg',
|
121 |
-
'image' => 'image',
|
122 |
-
'file' => 'file',
|
123 |
-
'select' => 'select',
|
124 |
-
'checkbox' => 'checkbox',
|
125 |
-
'radio' => 'radio',
|
126 |
-
'true_false' => 'radio',
|
127 |
-
'page_link' => 'textfield',
|
128 |
-
'post_object' => false,
|
129 |
-
'relationship' => 'textfield',
|
130 |
-
'date_picker' => 'date',
|
131 |
-
'color_picker' => false,
|
132 |
-
'repeater' => false,
|
133 |
-
);
|
134 |
-
|
135 |
-
if (!empty($acf_groups)) {
|
136 |
-
$form['acf_title'] = array(
|
137 |
-
'#type' => 'markup',
|
138 |
-
'#markup' => '<h3>' . __('Advanced Custom Fields', 'wpcf') . '</h3>',
|
139 |
-
);
|
140 |
-
}
|
141 |
-
|
142 |
-
foreach ($acf_groups as $acf_key => $acf_post) {
|
143 |
-
$group_id = $wpdb->get_var(
|
144 |
-
$wpdb->prepare(
|
145 |
-
"SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = %s",
|
146 |
-
$acf_post->post_title,
|
147 |
-
TYPES_CUSTOM_FIELD_GROUP_CPT_NAME
|
148 |
-
)
|
149 |
-
);
|
150 |
-
if (empty($group_id)) {
|
151 |
-
$add = __('Group will be created', 'wpcf');
|
152 |
-
} else {
|
153 |
-
$add = __('Group will be updated', 'wpcf');
|
154 |
-
}
|
155 |
-
$form[$acf_post->ID . '_post'] = array(
|
156 |
-
'#type' => 'checkbox',
|
157 |
-
'#title' => $acf_post->post_title . ' (' . $add . ')',
|
158 |
-
'#value' => $acf_post->ID,
|
159 |
-
'#default_value' => 1,
|
160 |
-
'#name' => 'acf_posts[migrate_groups][]',
|
161 |
-
'#inline' => true,
|
162 |
-
'#after' => '<br />',
|
163 |
-
'#attributes' => array('onclick' => 'if (jQuery(this).is(\':checked\')) { jQuery(this).parent().find(\'table .checkbox\').attr(\'checked\',\'checked\'); } else { jQuery(this).parent().find(\'table .checkbox\').removeAttr(\'checked\'); }'),
|
164 |
-
);
|
165 |
-
$form[$acf_post->ID . '_post_title'] = array(
|
166 |
-
'#type' => 'hidden',
|
167 |
-
'#name' => 'acf_posts[' . $acf_post->ID . '][post_title]',
|
168 |
-
'#value' => $acf_post->post_title,
|
169 |
-
);
|
170 |
-
$form[$acf_post->ID . '_post_content'] = array(
|
171 |
-
'#type' => 'hidden',
|
172 |
-
'#name' => 'acf_posts[' . $acf_post->ID . '][post_content]',
|
173 |
-
'#value' => addslashes($acf_post->post_content),
|
174 |
-
);
|
175 |
-
$form[$acf_post->ID . '_fields_table'] = array(
|
176 |
-
'#type' => 'markup',
|
177 |
-
'#markup' => '<table style="margin-bottom: 40px;">',
|
178 |
-
);
|
179 |
-
$metas = get_post_custom($acf_post->ID);
|
180 |
-
$acf_fields = array();
|
181 |
-
foreach ($metas as $meta_name => $meta) {
|
182 |
-
if (strpos($meta_name, 'field_') === 0) {
|
183 |
-
$data = unserialize($meta[0]);
|
184 |
-
$exists = wpcf_types_cf_under_control('check_exists',
|
185 |
-
$data['name']);
|
186 |
-
$outsider = wpcf_types_cf_under_control('check_outsider',
|
187 |
-
$data['name']);
|
188 |
-
$supported = !empty($acf_types[$data['type']]);
|
189 |
-
if (!$supported) {
|
190 |
-
$attributes = array('style' => 'margin-left: 20px;', 'readonly' => 'readonly', 'disabled' => 'disabled');
|
191 |
-
$add = __('Field conversion not supported by Types', 'wpcf');
|
192 |
-
} else if ($exists && !$outsider) {
|
193 |
-
$attributes = array('style' => 'margin-left: 20px;', 'readonly' => 'readonly', 'disabled' => 'disabled');
|
194 |
-
$add = __('Field with same name is already controlled by Types', 'wpcf');
|
195 |
-
} else if ($exists && $outsider) {
|
196 |
-
$attributes = array('style' => 'margin-left: 20px;');
|
197 |
-
$add = __('Field will be updated', 'wpcf');
|
198 |
-
} else {
|
199 |
-
$attributes = array('style' => 'margin-left: 20px;');
|
200 |
-
$add = __('Field will be created', 'wpcf');
|
201 |
-
}
|
202 |
-
$form[$acf_post->ID . '_acf_field_' . $meta_name . '_checkbox'] = array(
|
203 |
-
'#type' => 'checkbox',
|
204 |
-
'#title' => $data['name'] . ' (' . $add . ')',
|
205 |
-
'#value' => $meta_name,
|
206 |
-
'#default_value' => (($exists && !$outsider) || !$supported) ? 0 : 1,
|
207 |
-
'#name' => 'acf_posts[' . $acf_post->ID . '][migrate_fields][]',
|
208 |
-
'#inline' => true,
|
209 |
-
'#attributes' => $attributes,
|
210 |
-
'#before' => '<tr><td>',
|
211 |
-
);
|
212 |
-
$form[$acf_post->ID . '_acf_field_' . $meta_name . '_details_description'] = array(
|
213 |
-
'#type' => 'hidden',
|
214 |
-
'#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][description]',
|
215 |
-
'#value' => esc_attr($data['instructions']),
|
216 |
-
'#inline' => true,
|
217 |
-
);
|
218 |
-
$form[$acf_post->ID . '_acf_field_' . $meta_name . '_details_name'] = array(
|
219 |
-
'#type' => 'hidden',
|
220 |
-
'#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][name]',
|
221 |
-
'#value' => esc_attr($data['label']),
|
222 |
-
);
|
223 |
-
$form[$acf_post->ID . '_acf_field_' . $meta_name . '_details_slug'] = array(
|
224 |
-
'#type' => 'hidden',
|
225 |
-
'#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][slug]',
|
226 |
-
'#value' => esc_attr($data['name']),
|
227 |
-
);
|
228 |
-
// Add options for radios and select
|
229 |
-
if (in_array($data['type'], array('radio', 'select'))
|
230 |
-
&& !empty($data['choices'])) {
|
231 |
-
foreach ($data['choices'] as $option_value => $option_title) {
|
232 |
-
if (strpos($option_value, ':') !== false) {
|
233 |
-
$temp = explode(':', $option_value);
|
234 |
-
$option_value = trim($temp[0]);
|
235 |
-
$option_title = trim($temp[1]);
|
236 |
-
} else if (strpos($option_title, ':') !== false) {
|
237 |
-
$temp = explode(':', $option_title);
|
238 |
-
$option_value = trim($temp[0]);
|
239 |
-
$option_title = trim($temp[1]);
|
240 |
-
}
|
241 |
-
|
242 |
-
$_key = sanitize_title($option_value);
|
243 |
-
|
244 |
-
$form[$acf_post->ID . '_acf_field_' . $meta_name . '_option_' . $_key . '_value'] = array(
|
245 |
-
'#type' => 'hidden',
|
246 |
-
'#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][options][' . $_key . '][value]',
|
247 |
-
'#value' => esc_attr($option_value),
|
248 |
-
);
|
249 |
-
$form[$acf_post->ID . '_acf_field_' . $meta_name . '_option_' . $_key . '_title'] = array(
|
250 |
-
'#type' => 'hidden',
|
251 |
-
'#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][options][' . $_key . '][title]',
|
252 |
-
'#value' => esc_attr($option_title),
|
253 |
-
);
|
254 |
-
}
|
255 |
-
if (!empty($data['default_value'])) {
|
256 |
-
$form[$acf_post->ID . '_acf_field_' . $meta_name . '_option_default'] = array(
|
257 |
-
'#type' => 'hidden',
|
258 |
-
'#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][options][default]',
|
259 |
-
'#value' => esc_attr($data['default_value']),
|
260 |
-
);
|
261 |
-
}
|
262 |
-
}
|
263 |
-
if (($exists && !$outsider) || !$supported) {
|
264 |
-
$attributes = array('disabled' => 'disabled');
|
265 |
-
if ($exists) {
|
266 |
-
}
|
267 |
-
} else {
|
268 |
-
$attributes = array();
|
269 |
-
}
|
270 |
-
$default_value = isset($acf_types[$data['type']]) && !empty($acf_types[$data['type']]) ? $acf_types[$data['type']] : 'textfield';
|
271 |
-
$form[$acf_post->ID . '_acf_field_' . $meta_name . '_details_type'] = array(
|
272 |
-
'#type' => 'select',
|
273 |
-
'#name' => 'acf_posts[' . $acf_post->ID . '][fields][' . $meta_name . '][type]',
|
274 |
-
'#options' => $wpcf_types_options,
|
275 |
-
'#default_value' => $default_value,
|
276 |
-
'#inline' => true,
|
277 |
-
'#attributes' => $attributes,
|
278 |
-
'#before' => '</td><td>',
|
279 |
-
'#after' => '</td></tr>',
|
280 |
-
);
|
281 |
-
}
|
282 |
-
}
|
283 |
-
$acf_groups[$acf_key] = $acf_post;
|
284 |
-
$form[$acf_post->ID . '_fields_table_close'] = array(
|
285 |
-
'#type' => 'markup',
|
286 |
-
'#markup' => '</table>',
|
287 |
-
);
|
288 |
-
}
|
289 |
-
}
|
290 |
-
}
|
291 |
-
|
292 |
-
$form['submit'] = array(
|
293 |
-
'#type' => 'submit',
|
294 |
-
'#name' => 'submit',
|
295 |
-
'#value' => __('Import custom field settings', 'wpcf'),
|
296 |
-
'#attributes' => array('class' => 'button-primary'),
|
297 |
-
);
|
298 |
-
|
299 |
-
return $form;
|
300 |
-
}
|
301 |
-
|
302 |
-
/**
|
303 |
-
* Adds 3rd party created types, taxonomies and fields
|
304 |
-
*/
|
305 |
-
function wpcf_admin_migration_form_submit() {
|
306 |
-
$cfui_types = get_option('cpt_custom_post_types', array());
|
307 |
-
$cfui_taxonomies = get_option('cpt_custom_tax_types', array());
|
308 |
-
$wpcf_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
|
309 |
-
$wpcf_taxonomies = get_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array());
|
310 |
-
$redirect_page = 'wpcf-ctt';
|
311 |
-
|
312 |
-
if (!empty($_POST['cfui']['types'])) {
|
313 |
-
$data = array();
|
314 |
-
foreach ($_POST['cfui']['types'] as $key => $types_slug) {
|
315 |
-
if (array_key_exists(sanitize_title($types_slug), $wpcf_types)) {
|
316 |
-
continue;
|
317 |
-
}
|
318 |
-
foreach ($cfui_types as $cfui_type) {
|
319 |
-
if (sanitize_title($cfui_type['name']) == $types_slug) {
|
320 |
-
$data[$types_slug] = wpcf_admin_migrate_get_cfui_type_data($cfui_type);
|
321 |
-
wpcf_admin_message_store(
|
322 |
-
sprintf(__("Post Type %s added", 'wpcf'),
|
323 |
-
'<em>' . $cfui_type['name'] . '</em>')
|
324 |
-
);
|
325 |
-
}
|
326 |
-
}
|
327 |
-
}
|
328 |
-
$wpcf_types = array_merge($wpcf_types, $data);
|
329 |
-
}
|
330 |
-
if (!empty($_POST['cfui']['tax'])) {
|
331 |
-
$data = array();
|
332 |
-
foreach ($_POST['cfui']['tax'] as $key => $tax_slug) {
|
333 |
-
if (array_key_exists(sanitize_title($tax_slug), $wpcf_taxonomies)) {
|
334 |
-
continue;
|
335 |
-
}
|
336 |
-
foreach ($cfui_taxonomies as $cfui_tax) {
|
337 |
-
if (sanitize_title($cfui_tax['name']) == $tax_slug) {
|
338 |
-
$data[$tax_slug] = wpcf_admin_migrate_get_cfui_tax_data($cfui_tax);
|
339 |
-
wpcf_admin_message_store(
|
340 |
-
sprintf(__("Taxonomy %s added", 'wpcf'),
|
341 |
-
'<em>' . $cfui_tax['name'] . '</em>')
|
342 |
-
);
|
343 |
-
if (
|
344 |
-
array_key_exists(1,$cfui_tax)
|
345 |
-
&& !empty($cfui_tax[1])
|
346 |
-
&& is_array($cfui_tax[1])
|
347 |
-
) {
|
348 |
-
foreach( $cfui_tax[1] as $key) {
|
349 |
-
$types_slug = sanitize_title($key);
|
350 |
-
if ( array_key_exists($types_slug, $wpcf_types) ) {
|
351 |
-
if ( !array_key_exists('taxonomies', $wpcf_types[$types_slug] )) {
|
352 |
-
$wpcf_types[$types_slug]['taxonomies'] = array();
|
353 |
-
}
|
354 |
-
$wpcf_types[$types_slug]['taxonomies'][$tax_slug] = 1;
|
355 |
-
$wpcf_types[$types_slug][TOOLSET_EDIT_LAST] = time();
|
356 |
-
}
|
357 |
-
}
|
358 |
-
|
359 |
-
}
|
360 |
-
}
|
361 |
-
}
|
362 |
-
}
|
363 |
-
$wpcf_taxonomies = array_merge($wpcf_taxonomies, $data);
|
364 |
-
update_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, $wpcf_taxonomies);
|
365 |
-
}
|
366 |
-
update_option(WPCF_OPTION_NAME_CUSTOM_TYPES, $wpcf_types);
|
367 |
-
|
368 |
-
// ACF
|
369 |
-
|
370 |
-
if (!empty($_POST['acf_posts']['migrate_groups'])) {
|
371 |
-
foreach ($_POST['acf_posts']['migrate_groups'] as $acf_group_id) {
|
372 |
-
if (empty($_POST['acf_posts'][$acf_group_id])) {
|
373 |
-
continue;
|
374 |
-
}
|
375 |
-
global $wpdb;
|
376 |
-
$group = $wpdb->get_row(
|
377 |
-
$wpdb->prepare(
|
378 |
-
"SELECT ID, post_title FROM $wpdb->posts WHERE post_title = %s AND post_type = %s",
|
379 |
-
$_POST['acf_posts'][$acf_group_id]['post_title'],
|
380 |
-
TYPES_CUSTOM_FIELD_GROUP_CPT_NAME
|
381 |
-
)
|
382 |
-
);
|
383 |
-
if (empty($group)) {
|
384 |
-
// @todo Maybe sanitize here
|
385 |
-
$group = array();
|
386 |
-
$group['name'] = $_POST['acf_posts'][$acf_group_id]['post_title'];
|
387 |
-
$group['description'] = $_POST['acf_posts'][$acf_group_id]['post_content'];
|
388 |
-
$group_id = wpcf_admin_fields_save_group($group);
|
389 |
-
wpcf_admin_message_store(sprintf(__("Group %s added", 'wpcf'),
|
390 |
-
'<em>' . $group['name'] . '</em>'));
|
391 |
-
} else {
|
392 |
-
$group_id = $group->ID;
|
393 |
-
wpcf_admin_message_store(sprintf(__("Group %s updated", 'wpcf'),
|
394 |
-
'<em>' . $group->post_title . '</em>'));
|
395 |
-
}
|
396 |
-
$fields_to_add = array();
|
397 |
-
if ($group_id && !empty($_POST['acf_posts'][$acf_group_id]['fields'])) {
|
398 |
-
foreach ($_POST['acf_posts'][$acf_group_id]['fields'] as $field_id => $field) {
|
399 |
-
if (!in_array($field_id,
|
400 |
-
$_POST['acf_posts'][$acf_group_id]['migrate_fields'])) {
|
401 |
-
continue;
|
402 |
-
}
|
403 |
-
if (!wpcf_types_cf_under_control('check_exists',
|
404 |
-
$field['slug'])
|
405 |
-
|| wpcf_types_cf_under_control('check_outsider',
|
406 |
-
$field['slug'])) {
|
407 |
-
// save field
|
408 |
-
$field['controlled'] = 1;
|
409 |
-
$temp = wpcf_admin_fields_save_field($field);
|
410 |
-
$fields_to_add[] = $temp;
|
411 |
-
wpcf_admin_message_store(sprintf(__("Field %s added", 'wpcf'),
|
412 |
-
'<em>' . $temp . '</em>'));
|
413 |
-
}
|
414 |
-
}
|
415 |
-
wpcf_admin_fields_save_group_fields($group_id, $fields_to_add,
|
416 |
-
false);
|
417 |
-
}
|
418 |
-
wpcf_admin_fields_save_group_post_types($group_id, array());
|
419 |
-
wpcf_admin_fields_save_group_terms($group_id, array());
|
420 |
-
}
|
421 |
-
$redirect_page = 'wpcf';
|
422 |
-
}
|
423 |
-
flush_rewrite_rules();
|
424 |
-
|
425 |
-
// Deactivate plugins
|
426 |
-
if (!empty($_POST['deactivate-cfui'])) {
|
427 |
-
$active_plugins = get_option('active_plugins', array());
|
428 |
-
foreach ($active_plugins as $key => $file) {
|
429 |
-
if (strpos($file, 'custom-post-type-ui.php') !== false) {
|
430 |
-
unset($active_plugins[$key]);
|
431 |
-
}
|
432 |
-
}
|
433 |
-
update_option('active_plugins', array_values($active_plugins));
|
434 |
-
}
|
435 |
-
wp_safe_redirect(esc_url_raw(admin_url('admin.php?page=' . $redirect_page)));
|
436 |
-
die();
|
437 |
-
}
|
438 |
-
|
439 |
-
/**
|
440 |
-
* Gets types data.
|
441 |
-
*
|
442 |
-
* @param type $cfui_type
|
443 |
-
* @return type
|
444 |
-
*/
|
445 |
-
function wpcf_admin_migrate_get_cfui_type_data($cfui_type) {
|
446 |
-
$cfui_types_migrated = array();
|
447 |
-
$supports = array();
|
448 |
-
if (!empty($cfui_type[0])) {
|
449 |
-
foreach ($cfui_type[0] as $temp_key => $support) {
|
450 |
-
$supports[$support] = 1;
|
451 |
-
}
|
452 |
-
}
|
453 |
-
|
454 |
-
$taxonomies = array();
|
455 |
-
if (!empty($cfui_type[1])) {
|
456 |
-
foreach ($cfui_type[1] as $key => $tax) {
|
457 |
-
$taxonomies[$tax] = 1;
|
458 |
-
}
|
459 |
-
}
|
460 |
-
$wpcf_types_defaults = wpcf_custom_types_default();
|
461 |
-
$slug = $id = sanitize_title($cfui_type['name']);
|
462 |
-
|
463 |
-
// Set labels
|
464 |
-
$labels = isset($cfui_type[2]) ? $cfui_type[2] : array();
|
465 |
-
$labels['name'] = !empty($cfui_type['label']) ? $cfui_type['label'] : $slug;
|
466 |
-
$labels['singular_name'] = !empty($cfui_type['singular_label']) ? $cfui_type['singular_label'] : $slug;
|
467 |
-
foreach ($wpcf_types_defaults['labels'] as $label_id => $label_text) {
|
468 |
-
if (empty($labels[$label_id])) {
|
469 |
-
$labels[$label_id] = $label_text;
|
470 |
-
}
|
471 |
-
}
|
472 |
-
foreach ($labels as $label_id => $label_text) {
|
473 |
-
if (!isset($wpcf_types_defaults['labels'][$label_id])) {
|
474 |
-
unset($labels[$label_id]);
|
475 |
-
}
|
476 |
-
}
|
477 |
-
// Force menu_name label
|
478 |
-
if (empty($labels['menu_name'])) {
|
479 |
-
$labels['menu_name'] = $labels['name'];
|
480 |
-
}
|
481 |
-
|
482 |
-
// Set rewrite
|
483 |
-
$rewrite = empty($cfui_type['rewrite']) ? 0 : array();
|
484 |
-
if (is_array($rewrite)) {
|
485 |
-
$rewrite = array(
|
486 |
-
'enabled' => 1,
|
487 |
-
'custom' => !empty($cfui_type['rewrite_slug']) ? 'custom' : 'normal',
|
488 |
-
'slug' => !empty($cfui_type['rewrite_slug']) ? $cfui_type['rewrite_slug'] : '',
|
489 |
-
'with_front' => 1,
|
490 |
-
'feeds' => 1,
|
491 |
-
'pages' => 1,
|
492 |
-
);
|
493 |
-
}
|
494 |
-
|
495 |
-
$cfui_types_migrated[$slug] = array(
|
496 |
-
'labels' => $labels,
|
497 |
-
'supports' => $supports,
|
498 |
-
'slug' => $slug,
|
499 |
-
'rewrite' => $rewrite,
|
500 |
-
'slug' => $slug,
|
501 |
-
'id' => $id,
|
502 |
-
'public' => empty($cfui_type['public']) ? 'hidden' : 'public',
|
503 |
-
'publicly_queryable' => empty($cfui_type['public']) ? false : true,
|
504 |
-
'query_var_enabled' => (bool) $cfui_type['query_var'],
|
505 |
-
'query_var' => '',
|
506 |
-
'show_in_menu' => (bool) $cfui_type['show_in_menu'],
|
507 |
-
'show_in_menu_page' => $cfui_type['show_in_menu_string'],
|
508 |
-
'has_archive' => (bool) $cfui_type['has_archive'],
|
509 |
-
'taxonomies' => $taxonomies,
|
510 |
-
'can_export' => true,
|
511 |
-
'show_in_nav_menus' => true,
|
512 |
-
);
|
513 |
-
|
514 |
-
unset($cfui_type[0], $cfui_type[1], $cfui_type[2], $cfui_type['public'],
|
515 |
-
$cfui_type['rewrite'], $cfui_type['name'], $cfui_type['label'],
|
516 |
-
$cfui_type['singular_label'], $cfui_type['capability_type'],
|
517 |
-
$cfui_type['rewrite_slug'], $cfui_type['show_in_menu'],
|
518 |
-
$cfui_type['show_in_menu_string'], $cfui_type['publicly_queryable'],
|
519 |
-
$cfui_type['capabilities'], $cfui_type['has_archive'],
|
520 |
-
$cfui_type['show_in_nav_menus']);
|
521 |
-
|
522 |
-
$cfui_types_migrated[$slug] = array_merge($cfui_type,
|
523 |
-
$cfui_types_migrated[$slug]);
|
524 |
-
|
525 |
-
return $cfui_types_migrated[$slug];
|
526 |
-
}
|
527 |
-
|
528 |
-
/**
|
529 |
-
* Gets taxonomies data.
|
530 |
-
*
|
531 |
-
* @param type $cfui_tax
|
532 |
-
* @return type
|
533 |
-
*/
|
534 |
-
function wpcf_admin_migrate_get_cfui_tax_data($cfui_tax) {
|
535 |
-
$cfui_tax_migrated = array();
|
536 |
-
$supports = array();
|
537 |
-
if (!empty($cfui_tax[1])) {
|
538 |
-
foreach ($cfui_tax[1] as $temp_key => $support) {
|
539 |
-
$supports[$support] = 1;
|
540 |
-
}
|
541 |
-
}
|
542 |
-
|
543 |
-
$wpcf_taxonomies_defaults = wpcf_custom_taxonomies_default();
|
544 |
-
$slug = $id = sanitize_title($cfui_tax['name']);
|
545 |
-
|
546 |
-
// Set labels
|
547 |
-
$labels = isset($cfui_tax[0]) ? $cfui_tax[0] : array();
|
548 |
-
$labels['name'] = !empty($cfui_tax['label']) ? $cfui_tax['label'] : $slug;
|
549 |
-
$labels['singular_name'] = !empty($cfui_tax['singular_label']) ? $cfui_tax['singular_label'] : $slug;
|
550 |
-
foreach ($wpcf_taxonomies_defaults['labels'] as $label_id => $label_text) {
|
551 |
-
if (empty($labels[$label_id])) {
|
552 |
-
$labels[$label_id] = $label_text;
|
553 |
-
}
|
554 |
-
}
|
555 |
-
foreach ($labels as $label_id => $label_text) {
|
556 |
-
if (!isset($wpcf_taxonomies_defaults['labels'][$label_id])) {
|
557 |
-
unset($labels[$label_id]);
|
558 |
-
}
|
559 |
-
}
|
560 |
-
// Force menu_name label
|
561 |
-
if (empty($labels['menu_name'])) {
|
562 |
-
$labels['menu_name'] = $labels['name'];
|
563 |
-
}
|
564 |
-
|
565 |
-
// Set rewrite
|
566 |
-
$rewrite = empty($cfui_tax['rewrite']) ? 0 : array();
|
567 |
-
if (is_array($rewrite)) {
|
568 |
-
$rewrite = array(
|
569 |
-
'enabled' => 1,
|
570 |
-
'slug' => !empty($cfui_tax['rewrite_slug']) ? $cfui_tax['rewrite_slug'] : '',
|
571 |
-
'with_front' => 1,
|
572 |
-
'hierarchical' => (bool) $cfui_tax['hierarchical'],
|
573 |
-
);
|
574 |
-
}
|
575 |
-
|
576 |
-
$cfui_tax_migrated[$slug] = array(
|
577 |
-
'labels' => $labels,
|
578 |
-
'supports' => $supports,
|
579 |
-
'slug' => $slug,
|
580 |
-
'wpcf-tax' => $slug,
|
581 |
-
'rewrite' => $rewrite,
|
582 |
-
'slug' => $slug,
|
583 |
-
'id' => $id,
|
584 |
-
'public' => 'public',
|
585 |
-
'query_var_enabled' => (bool) $cfui_tax['query_var'],
|
586 |
-
'query_var' => '',
|
587 |
-
'hierarchical' => (bool) $cfui_tax['hierarchical'] ? 'hierarchical' : 'flat',
|
588 |
-
);
|
589 |
-
|
590 |
-
unset($cfui_tax[0], $cfui_tax[1], $cfui_tax['rewrite'], $cfui_tax['name'],
|
591 |
-
$cfui_tax['label'], $cfui_tax['singular_label'],
|
592 |
-
$cfui_tax['rewrite_slug'], $cfui_tax['capabilities'],
|
593 |
-
$cfui_tax['hierarchical']);
|
594 |
-
|
595 |
-
$cfui_tax_migrated[$slug] = array_merge($wpcf_taxonomies_defaults,
|
596 |
-
array_merge($cfui_tax, $cfui_tax_migrated[$slug]));
|
597 |
-
|
598 |
-
return $cfui_tax_migrated[$slug];
|
599 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Domain Path: /embedded/locale
|
|
7 |
License: GPLv2
|
8 |
Requires at least: 3.7
|
9 |
Tested up to: 4.7.1
|
10 |
-
Stable tag: 2.2.
|
11 |
|
12 |
The complete and reliable plugin for managing custom post types, custom taxonomies and custom fields.
|
13 |
|
@@ -160,7 +160,19 @@ Additionally, Types is the only plugin that lets you define parent/child relatio
|
|
160 |
|
161 |
== Changelog ==
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
= 2.2.6 =
|
|
|
164 |
* Updated Installer to 1.7.15.
|
165 |
* Fix several issues with the Styling editor.
|
166 |
* Fixed a compatibility with Layouts, child themes of Layouts-integrated themes haven't been recognized as such.
|
7 |
License: GPLv2
|
8 |
Requires at least: 3.7
|
9 |
Tested up to: 4.7.1
|
10 |
+
Stable tag: 2.2.7
|
11 |
|
12 |
The complete and reliable plugin for managing custom post types, custom taxonomies and custom fields.
|
13 |
|
160 |
|
161 |
== Changelog ==
|
162 |
|
163 |
+
= 2.2.7 =
|
164 |
+
|
165 |
+
* Fixed a JavaScript error when using a flat taxonomy in the relationship post table.
|
166 |
+
* Fixed an issue where no value was stored for checkboxes when option to save 0 was selected.
|
167 |
+
* Fixed a validation issue for file, audio, video and embed fields affecting Types. Allowing URLs with non-latin characters, but only for URLs that point to attachments from the Media Library (validated by WordPress media upload mechanism).
|
168 |
+
* Removed the "Types Migration" page which was broken and not maintained.
|
169 |
+
* Fixed an incompatibility issue with Divi caused by double enqueuing of the jQuery UI Validation plugin.
|
170 |
+
* When inserting the types shortcode for an image field, we will always use placeholders for the title and alt text.
|
171 |
+
* Fixed an issue in the relationship post table where it wasn't possible to repeatedly set and remove a child post's featured image.
|
172 |
+
* Improved how the Types meta fields are registered in the Fields and Views dialog.
|
173 |
+
|
174 |
= 2.2.6 =
|
175 |
+
|
176 |
* Updated Installer to 1.7.15.
|
177 |
* Fix several issues with the Styling editor.
|
178 |
* Fixed a compatibility with Layouts, child themes of Layouts-integrated themes haven't been recognized as such.
|
wpcf.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://wordpress.org/extend/plugins/types/
|
|
5 |
Description: Toolset Types defines custom content in WordPress. Easily create custom post types, fields and taxonomy and connect everything together.
|
6 |
Author: OnTheGoSystems
|
7 |
Author URI: http://www.onthegosystems.com
|
8 |
-
Version: 2.2.
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
Types is free software: you can redistribute it and/or modify
|
@@ -28,7 +28,7 @@ if( !function_exists( 'add_action' ) )
|
|
28 |
|
29 |
// version
|
30 |
if( ! defined( 'TYPES_VERSION' ) )
|
31 |
-
define( 'TYPES_VERSION', '2.2.
|
32 |
|
33 |
// backward compatibility
|
34 |
if ( ! defined( 'WPCF_VERSION' ) )
|
@@ -37,7 +37,7 @@ if ( ! defined( 'WPCF_VERSION' ) )
|
|
37 |
// release notes
|
38 |
if( ! defined( 'TYPES_RELEASE_NOTES' ) )
|
39 |
// Mind the end of the URL string, it contains the plugin version.
|
40 |
-
define( 'TYPES_RELEASE_NOTES', 'https://wp-types.com/version/types-2-2-
|
41 |
|
42 |
/*
|
43 |
* Path Constants
|
5 |
Description: Toolset Types defines custom content in WordPress. Easily create custom post types, fields and taxonomy and connect everything together.
|
6 |
Author: OnTheGoSystems
|
7 |
Author URI: http://www.onthegosystems.com
|
8 |
+
Version: 2.2.7
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
Types is free software: you can redistribute it and/or modify
|
28 |
|
29 |
// version
|
30 |
if( ! defined( 'TYPES_VERSION' ) )
|
31 |
+
define( 'TYPES_VERSION', '2.2.7' );
|
32 |
|
33 |
// backward compatibility
|
34 |
if ( ! defined( 'WPCF_VERSION' ) )
|
37 |
// release notes
|
38 |
if( ! defined( 'TYPES_RELEASE_NOTES' ) )
|
39 |
// Mind the end of the URL string, it contains the plugin version.
|
40 |
+
define( 'TYPES_RELEASE_NOTES', 'https://wp-types.com/version/types-2-2-7/?utm_source=typesplugin&utm_campaign=types&utm_medium=release-notes-admin-notice&utm_term=Types%202.2.7%20release%20notes' );
|
41 |
|
42 |
/*
|
43 |
* Path Constants
|