Version Description
- Fixed a compatibility issue with Beaver Builder
- Fixed an issue with extra backslashes when using quotes in field name
- Removed the Toolset overlay while saving
- Removed the dependency of GLOB_BRACE
Download this release
Release Info
Developer | christianglingener |
Plugin | Toolset Types – Custom Post Types, Custom Fields and Taxonomies |
Version | 2.2.21 |
Comparing to | |
See all releases |
Code changes from version 2.2.20 to 2.2.21
- application/controllers/page/field_control.php +1 -1
- application/models/field/type/definition_factory.php +1 -1
- readme.txt +7 -1
- vendor/autoload.php +1 -1
- vendor/composer/autoload_classmap.php +13 -1
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +18 -6
- vendor/composer/installed.json +4 -4
- vendor/toolset/toolset-common/autoload_classmap.php +2 -0
- vendor/toolset/toolset-common/bootstrap.php +1 -0
- vendor/toolset/toolset-common/build/list_subdirs.php +98 -0
- vendor/toolset/toolset-common/changelog.md +15 -0
- vendor/toolset/toolset-common/inc/autoloaded/element/element.php +2 -2
- vendor/toolset/toolset-common/inc/autoloaded/element/exception_element_doesnt_exist.php +65 -0
- vendor/toolset/toolset-common/inc/autoloaded/element/post.php +4 -2
- vendor/toolset/toolset-common/inc/autoloaded/field/definition_abstract.php +1 -1
- vendor/toolset/toolset-common/inc/autoloaded/field/renderer/toolset_forms.php +1 -0
- vendor/toolset/toolset-common/inc/autoloaded/field/renderer/toolset_forms_repeatable_group.php +1 -0
- vendor/toolset/toolset-common/inc/autoloaded/field/type/definition_factory.php +1 -1
- vendor/toolset/toolset-common/inc/autoloaded/post_type/from_types.php +2 -1
- vendor/toolset/toolset-common/inc/autoloaded/relationship_service.php +63 -7
- vendor/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/id.php +21 -1
- vendor/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/legacy.php +10 -2
- vendor/toolset/toolset-common/inc/autoloaded/upgrade/command/m2m_v1_database_structure_upgrade.php +26 -0
- vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_definition.php +11 -2
- vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_definition_repository.php +1 -1
- vendor/toolset/toolset-common/inc/autoloaded/upgrade/controller.php +41 -6
- vendor/toolset/toolset-common/inc/autoloaded/upgrade/executed_commands.php +58 -0
- vendor/toolset/toolset-common/inc/controller/admin/notices.php +78 -16
- vendor/toolset/toolset-common/inc/m2m/association_query.php +27 -4
- vendor/toolset/toolset-common/inc/m2m/association_repository.php +5 -3
- vendor/toolset/toolset-common/inc/m2m/autoload_classmap.php +10 -1
- vendor/toolset/toolset-common/inc/m2m/controller.php +61 -2
- vendor/toolset/toolset-common/inc/m2m/database/issue/interface.php +7 -0
- vendor/toolset/toolset-common/inc/m2m/database/issue/missing_element.php +160 -0
- vendor/toolset/toolset-common/inc/m2m/database/operations.php +62 -20
- vendor/toolset/toolset-common/inc/m2m/definition/definition.php +31 -64
- vendor/toolset/toolset-common/inc/m2m/{i_definition.php → definition/interface.php} +15 -1
- vendor/toolset/toolset-common/inc/m2m/definition/persistence.php +28 -2
- vendor/toolset/toolset-common/inc/m2m/definition/repository.php +21 -23
- vendor/toolset/toolset-common/inc/m2m/definition/translator.php +4 -11
- vendor/toolset/toolset-common/inc/m2m/driver.php +9 -2
- vendor/toolset/toolset-common/inc/m2m/driver_base.php +19 -7
- vendor/toolset/toolset-common/inc/m2m/element_type.php +3 -6
- vendor/toolset/toolset-common/inc/m2m/migration_associations.php +9 -2
- vendor/toolset/toolset-common/inc/m2m/multilingual_mode.php +3 -0
- vendor/toolset/toolset-common/inc/m2m/potential_association/query_interface.php +21 -0
- vendor/toolset/toolset-common/inc/m2m/potential_association/query_posts.php +139 -6
- vendor/toolset/toolset-common/inc/m2m/query_base.php +1 -1
- vendor/toolset/toolset-common/inc/m2m/query_factory.php +20 -2
- vendor/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/conjunction.php +29 -0
- vendor/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/factory.php +157 -0
- vendor/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/interface.php +11 -0
- vendor/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/operators.php +32 -0
- vendor/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/single.php +90 -0
- vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/has_cardinality.php +107 -0
- vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/origin.php +1 -1
- vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/tautology.php +24 -0
- vendor/toolset/toolset-common/inc/m2m/relationship_query/condition_factory.php +23 -0
- vendor/toolset/toolset-common/inc/m2m/relationship_query/relationship_query_v2.php +101 -16
- vendor/toolset/toolset-common/inc/m2m/relationship_role/role.php +5 -1
- vendor/toolset/toolset-common/inc/toolset.assets.manager.class.php +27 -24
- vendor/toolset/toolset-common/inc/toolset.shortcode.generator.class.php +475 -41
- vendor/toolset/toolset-common/inc/toolset.shortcode.transformer.class.php +39 -0
- vendor/toolset/toolset-common/loader.php +1 -1
- vendor/toolset/toolset-common/res/css/toolset-admin-notices.css +31 -3
- vendor/toolset/toolset-common/res/css/toolset-dialogs.css +48 -7
- vendor/toolset/toolset-common/res/images/third-party/logos/bb.svg +57 -0
- vendor/toolset/toolset-common/res/images/third-party/logos/vc.svg +10 -0
- vendor/toolset/toolset-common/res/images/third-party/logos/vc_old.svg +28 -0
- vendor/toolset/toolset-common/res/js/toolset-admin-notices.js +6 -0
- vendor/toolset/toolset-common/res/js/toolset-shortcode.js +276 -28
- vendor/toolset/toolset-common/templates/admin/notice/types-free-version-ends.phtml +61 -0
- vendor/toolset/toolset-common/templates/admin/notice/types-move-to-toolset.phtml +18 -0
- vendor/toolset/toolset-common/toolset-common-loader.php +12 -2
- vendor/toolset/toolset-common/toolset-forms/autoload_classmap.php +1 -0
- vendor/toolset/toolset-common/toolset-forms/classes/class.checkboxes.php +1 -1
- vendor/toolset/toolset-common/toolset-forms/classes/class.field_factory.php +5 -0
- vendor/toolset/toolset-common/user-editors/editor/abstract.php +11 -0
- vendor/toolset/toolset-common/user-editors/editor/avada.php +2 -0
- vendor/toolset/toolset-common/user-editors/editor/beaver.php +2 -0
- vendor/toolset/toolset-common/user-editors/editor/divi.php +2 -0
- vendor/toolset/toolset-common/user-editors/editor/interface.php +1 -0
- vendor/toolset/toolset-common/user-editors/editor/screen/avada/backend.php +2 -1
- vendor/toolset/toolset-common/user-editors/editor/screen/avada/backend_editor.css +7 -1
- vendor/toolset/toolset-common/user-editors/editor/screen/basic/backend.css +11 -0
- vendor/toolset/toolset-common/user-editors/editor/screen/basic/backend.php +9 -0
- vendor/toolset/toolset-common/user-editors/editor/screen/beaver/backend.php +3 -1
- vendor/toolset/toolset-common/user-editors/editor/screen/beaver/frontend.php +19 -0
- vendor/toolset/toolset-common/user-editors/editor/screen/divi/backend.php +2 -1
- vendor/toolset/toolset-common/user-editors/editor/screen/native/backend.php +2 -1
- vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/backend.php +13 -9
- vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/frontend.php +47 -4
- vendor/toolset/toolset-common/user-editors/editor/visual-composer.php +17 -4
- vendor/toolset/toolset-common/user-editors/medium/content-template.php +8 -1
- vendor/toolset/toolset-common/user-editors/medium/interface.php +1 -1
- vendor/toolset/toolset-common/user-editors/medium/screen/content-template/frontend-editor.css +4 -0
- vendor/toolset/toolset-common/user-editors/medium/screen/content-template/frontend-editor.js +23 -0
- vendor/toolset/toolset-common/utility/admin/notice/abstract.php +6 -0
- vendor/toolset/toolset-common/utility/admin/notices/manager.php +1 -1
- vendor/toolset/toolset-common/utility/condition/theme/layouts-support/native/available.php +16 -2
- vendor/toolset/toolset-common/utility/dialogs/css/dd-dialogs-forms.css +7 -1
- vendor/toolset/toolset-common/utility/gui-base/js/ListingViewModel.js +1 -1
- vendor/toolset/toolset-common/utility/gui-base/main.php +0 -1
- vendor/toolset/toolset-common/utility/gui-base/toolset-gui-base.css +4 -0
- vendor/toolset/toolset-common/utility/gui-base/twig_autoloader.php +7 -0
- vendor/toolset/toolset-common/utility/js/utils.js +6 -0
- vendor/toolset/toolset-common/utility/utils.php +1 -1
- vendor/toolset/toolset-common/visual-editor/editor-addon.class.php +2 -0
- vendor/toolset/types/embedded/classes/field/definition_abstract.php +1 -1
- vendor/toolset/types/embedded/includes/conditional-display.php +1 -1
- vendor/toolset/types/embedded/resources/js/basic.js +2 -2
- vendor/toolset/types/embedded/resources/js/modal.js +0 -280
- vendor/toolset/types/includes/classes/class.types.admin.edit.fields.php +1 -1
- vendor/toolset/types/includes/classes/class.wpcf.marketing.messages.php +0 -3
- vendor/toolset/types/includes/conditional-display.php +2 -2
- wpcf.php +2 -2
application/controllers/page/field_control.php
CHANGED
@@ -440,7 +440,7 @@ final class Types_Page_Field_Control extends Types_Page_Abstract {
|
|
440 |
foreach( $groups as $group ) {
|
441 |
$group_data[ $group->get_slug() ] = array(
|
442 |
'slug' => $group->get_slug(),
|
443 |
-
'displayName' => $group->get_display_name()
|
444 |
);
|
445 |
}
|
446 |
|
440 |
foreach( $groups as $group ) {
|
441 |
$group_data[ $group->get_slug() ] = array(
|
442 |
'slug' => $group->get_slug(),
|
443 |
+
'displayName' => stripslashes( $group->get_display_name() )
|
444 |
);
|
445 |
}
|
446 |
|
application/models/field/type/definition_factory.php
CHANGED
@@ -220,7 +220,7 @@ class Types_Field_Type_Definition_Factory {
|
|
220 |
foreach( $field_types as $field_type ) {
|
221 |
$field_type_names[ $field_type->get_slug() ] = array(
|
222 |
'slug' => $field_type->get_slug(),
|
223 |
-
'displayName' => $field_type->get_display_name(),
|
224 |
'canBeRepetitive' => $field_type->can_be_repetitive(),
|
225 |
'iconClasses' => $field_type->get_icon_classes()
|
226 |
);
|
220 |
foreach( $field_types as $field_type ) {
|
221 |
$field_type_names[ $field_type->get_slug() ] = array(
|
222 |
'slug' => $field_type->get_slug(),
|
223 |
+
'displayName' => stripslashes( $field_type->get_display_name() ),
|
224 |
'canBeRepetitive' => $field_type->can_be_repetitive(),
|
225 |
'iconClasses' => $field_type->get_icon_classes()
|
226 |
);
|
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.9
|
10 |
-
Stable tag: 2.2.
|
11 |
|
12 |
The complete and reliable plugin for managing custom post types, custom taxonomies and custom fields.
|
13 |
|
@@ -158,6 +158,12 @@ Additionally, Types is the only plugin that lets you define parent/child relatio
|
|
158 |
|
159 |
== Changelog ==
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
= 2.2.20 =
|
162 |
* Fixed an issue that field title was not available on filter "wpt_field_options"
|
163 |
* Fixed an issue with the background when resizing transparent indexed colored PNGs
|
7 |
License: GPLv2
|
8 |
Requires at least: 3.7
|
9 |
Tested up to: 4.9
|
10 |
+
Stable tag: 2.2.21
|
11 |
|
12 |
The complete and reliable plugin for managing custom post types, custom taxonomies and custom fields.
|
13 |
|
158 |
|
159 |
== Changelog ==
|
160 |
|
161 |
+
= 2.2.21 =
|
162 |
+
* Fixed a compatibility issue with Beaver Builder
|
163 |
+
* Fixed an issue with extra backslashes when using quotes in field name
|
164 |
+
* Removed the Toolset overlay while saving
|
165 |
+
* Removed the dependency of GLOB_BRACE
|
166 |
+
|
167 |
= 2.2.20 =
|
168 |
* Fixed an issue that field title was not available on filter "wpt_field_options"
|
169 |
* Fixed an issue with the background when resizing transparent indexed colored PNGs
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInita469bff8809f0826cf254ebc61c9ca28::getLoader();
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -104,8 +104,10 @@ return array(
|
|
104 |
'IToolset_Post_Type_Registered' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type_registered.php',
|
105 |
'IToolset_Potential_Association_Query' => $vendorDir . '/toolset/toolset-common/inc/m2m/potential_association/query_interface.php',
|
106 |
'IToolset_Query' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/i_query.php',
|
107 |
-
'
|
|
|
108 |
'IToolset_Relationship_Origin' => $vendorDir . '/toolset/toolset-common/inc/m2m/origin/interface.php',
|
|
|
109 |
'IToolset_Relationship_Query_Condition' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/i_condition.php',
|
110 |
'IToolset_Relationship_Role' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_role/interface.php',
|
111 |
'IToolset_Relationship_Role_Parent_Child' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_role/parent_child_interface.php',
|
@@ -176,6 +178,7 @@ return array(
|
|
176 |
'Toolset_DialogBoxes' => $vendorDir . '/toolset/toolset-common/utility/dialogs/toolset.dialog-boxes.class.php',
|
177 |
'Toolset_Element' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element/element.php',
|
178 |
'Toolset_Element_Domain' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element/domain.php',
|
|
|
179 |
'Toolset_Element_Factory' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element/element_factory.php',
|
180 |
'Toolset_ErrorHandler' => $vendorDir . '/toolset/toolset-common/utility/utils.php',
|
181 |
'Toolset_Export_Import_Screen' => $vendorDir . '/toolset/toolset-common/inc/toolset.export.import.screen.class.php',
|
@@ -268,6 +271,7 @@ return array(
|
|
268 |
'Toolset_Regex' => $vendorDir . '/toolset/toolset-common/expression-parser/parser.php',
|
269 |
'Toolset_Relationship_Cardinality' => $vendorDir . '/toolset/toolset-common/inc/m2m/cardinality.php',
|
270 |
'Toolset_Relationship_Controller' => $vendorDir . '/toolset/toolset-common/inc/m2m/controller.php',
|
|
|
271 |
'Toolset_Relationship_Database_Operations' => $vendorDir . '/toolset/toolset-common/inc/m2m/database/operations.php',
|
272 |
'Toolset_Relationship_Database_Unique_Table_Alias' => $vendorDir . '/toolset/toolset-common/inc/m2m/database/unique_table_alias.php',
|
273 |
'Toolset_Relationship_Definition' => $vendorDir . '/toolset/toolset-common/inc/m2m/definition/definition.php',
|
@@ -288,10 +292,15 @@ return array(
|
|
288 |
'Toolset_Relationship_Query' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/relationship_query.php',
|
289 |
'Toolset_Relationship_Query_Base' => $vendorDir . '/toolset/toolset-common/inc/m2m/query_base.php',
|
290 |
'Toolset_Relationship_Query_Cache' => $vendorDir . '/toolset/toolset-common/inc/m2m/query_cache.php',
|
|
|
|
|
|
|
|
|
291 |
'Toolset_Relationship_Query_Condition' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/abstract.php',
|
292 |
'Toolset_Relationship_Query_Condition_And' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/and.php',
|
293 |
'Toolset_Relationship_Query_Condition_Factory' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition_factory.php',
|
294 |
'Toolset_Relationship_Query_Condition_Has_Active_Types' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/has_active_types.php',
|
|
|
295 |
'Toolset_Relationship_Query_Condition_Has_Domain' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/has_domain.php',
|
296 |
'Toolset_Relationship_Query_Condition_Is_Active' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/is_active.php',
|
297 |
'Toolset_Relationship_Query_Condition_Is_Boolean_Flag' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/is_boolean_flag.php',
|
@@ -299,6 +308,7 @@ return array(
|
|
299 |
'Toolset_Relationship_Query_Condition_Operator' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/operator.php',
|
300 |
'Toolset_Relationship_Query_Condition_Or' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/or.php',
|
301 |
'Toolset_Relationship_Query_Condition_Origin' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/origin.php',
|
|
|
302 |
'Toolset_Relationship_Query_Condition_Type' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/type.php',
|
303 |
'Toolset_Relationship_Query_Factory' => $vendorDir . '/toolset/toolset-common/inc/m2m/query_factory.php',
|
304 |
'Toolset_Relationship_Query_Sql_Expression_Builder' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/sql_expression_builder.php',
|
@@ -327,6 +337,7 @@ return array(
|
|
327 |
'Toolset_Shortcode_Attr_Item_Legacy' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/legacy.php',
|
328 |
'Toolset_Shortcode_Attr_Item_M2M' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/m2m.php',
|
329 |
'Toolset_Shortcode_Generator' => $vendorDir . '/toolset/toolset-common/inc/toolset.shortcode.generator.class.php',
|
|
|
330 |
'Toolset_Stack' => $vendorDir . '/toolset/toolset-common/expression-parser/parser.php',
|
331 |
'Toolset_Style' => $vendorDir . '/toolset/toolset-common/inc/toolset.assets.manager.class.php',
|
332 |
'Toolset_Tokenizer' => $vendorDir . '/toolset/toolset-common/expression-parser/parser.php',
|
@@ -339,6 +350,7 @@ return array(
|
|
339 |
'Toolset_Upgrade_Command_Factory' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/upgrade/command_factory.php',
|
340 |
'Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/upgrade/command/m2m_v1_database_structure_upgrade.php',
|
341 |
'Toolset_Upgrade_Controller' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/upgrade/controller.php',
|
|
|
342 |
'Toolset_User_Editors_Editor_Abstract' => $vendorDir . '/toolset/toolset-common/user-editors/editor/abstract.php',
|
343 |
'Toolset_User_Editors_Editor_Avada' => $vendorDir . '/toolset/toolset-common/user-editors/editor/avada.php',
|
344 |
'Toolset_User_Editors_Editor_Basic' => $vendorDir . '/toolset/toolset-common/user-editors/editor/basic.php',
|
104 |
'IToolset_Post_Type_Registered' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type_registered.php',
|
105 |
'IToolset_Potential_Association_Query' => $vendorDir . '/toolset/toolset-common/inc/m2m/potential_association/query_interface.php',
|
106 |
'IToolset_Query' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/i_query.php',
|
107 |
+
'IToolset_Relationship_Database_Issue' => $vendorDir . '/toolset/toolset-common/inc/m2m/database/issue/interface.php',
|
108 |
+
'IToolset_Relationship_Definition' => $vendorDir . '/toolset/toolset-common/inc/m2m/definition/interface.php',
|
109 |
'IToolset_Relationship_Origin' => $vendorDir . '/toolset/toolset-common/inc/m2m/origin/interface.php',
|
110 |
+
'IToolset_Relationship_Query_Cardinality_Match' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/interface.php',
|
111 |
'IToolset_Relationship_Query_Condition' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/i_condition.php',
|
112 |
'IToolset_Relationship_Role' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_role/interface.php',
|
113 |
'IToolset_Relationship_Role_Parent_Child' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_role/parent_child_interface.php',
|
178 |
'Toolset_DialogBoxes' => $vendorDir . '/toolset/toolset-common/utility/dialogs/toolset.dialog-boxes.class.php',
|
179 |
'Toolset_Element' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element/element.php',
|
180 |
'Toolset_Element_Domain' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element/domain.php',
|
181 |
+
'Toolset_Element_Exception_Element_Doesnt_Exist' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element/exception_element_doesnt_exist.php',
|
182 |
'Toolset_Element_Factory' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element/element_factory.php',
|
183 |
'Toolset_ErrorHandler' => $vendorDir . '/toolset/toolset-common/utility/utils.php',
|
184 |
'Toolset_Export_Import_Screen' => $vendorDir . '/toolset/toolset-common/inc/toolset.export.import.screen.class.php',
|
271 |
'Toolset_Regex' => $vendorDir . '/toolset/toolset-common/expression-parser/parser.php',
|
272 |
'Toolset_Relationship_Cardinality' => $vendorDir . '/toolset/toolset-common/inc/m2m/cardinality.php',
|
273 |
'Toolset_Relationship_Controller' => $vendorDir . '/toolset/toolset-common/inc/m2m/controller.php',
|
274 |
+
'Toolset_Relationship_Database_Issue_Missing_Element' => $vendorDir . '/toolset/toolset-common/inc/m2m/database/issue/missing_element.php',
|
275 |
'Toolset_Relationship_Database_Operations' => $vendorDir . '/toolset/toolset-common/inc/m2m/database/operations.php',
|
276 |
'Toolset_Relationship_Database_Unique_Table_Alias' => $vendorDir . '/toolset/toolset-common/inc/m2m/database/unique_table_alias.php',
|
277 |
'Toolset_Relationship_Definition' => $vendorDir . '/toolset/toolset-common/inc/m2m/definition/definition.php',
|
292 |
'Toolset_Relationship_Query' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/relationship_query.php',
|
293 |
'Toolset_Relationship_Query_Base' => $vendorDir . '/toolset/toolset-common/inc/m2m/query_base.php',
|
294 |
'Toolset_Relationship_Query_Cache' => $vendorDir . '/toolset/toolset-common/inc/m2m/query_cache.php',
|
295 |
+
'Toolset_Relationship_Query_Cardinality_Match_Conjunction' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/conjunction.php',
|
296 |
+
'Toolset_Relationship_Query_Cardinality_Match_Factory' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/factory.php',
|
297 |
+
'Toolset_Relationship_Query_Cardinality_Match_Operators' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/operators.php',
|
298 |
+
'Toolset_Relationship_Query_Cardinality_Match_Single' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/single.php',
|
299 |
'Toolset_Relationship_Query_Condition' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/abstract.php',
|
300 |
'Toolset_Relationship_Query_Condition_And' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/and.php',
|
301 |
'Toolset_Relationship_Query_Condition_Factory' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition_factory.php',
|
302 |
'Toolset_Relationship_Query_Condition_Has_Active_Types' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/has_active_types.php',
|
303 |
+
'Toolset_Relationship_Query_Condition_Has_Cardinality' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/has_cardinality.php',
|
304 |
'Toolset_Relationship_Query_Condition_Has_Domain' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/has_domain.php',
|
305 |
'Toolset_Relationship_Query_Condition_Is_Active' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/is_active.php',
|
306 |
'Toolset_Relationship_Query_Condition_Is_Boolean_Flag' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/is_boolean_flag.php',
|
308 |
'Toolset_Relationship_Query_Condition_Operator' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/operator.php',
|
309 |
'Toolset_Relationship_Query_Condition_Or' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/or.php',
|
310 |
'Toolset_Relationship_Query_Condition_Origin' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/origin.php',
|
311 |
+
'Toolset_Relationship_Query_Condition_Tautology' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/tautology.php',
|
312 |
'Toolset_Relationship_Query_Condition_Type' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/type.php',
|
313 |
'Toolset_Relationship_Query_Factory' => $vendorDir . '/toolset/toolset-common/inc/m2m/query_factory.php',
|
314 |
'Toolset_Relationship_Query_Sql_Expression_Builder' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/sql_expression_builder.php',
|
337 |
'Toolset_Shortcode_Attr_Item_Legacy' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/legacy.php',
|
338 |
'Toolset_Shortcode_Attr_Item_M2M' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/m2m.php',
|
339 |
'Toolset_Shortcode_Generator' => $vendorDir . '/toolset/toolset-common/inc/toolset.shortcode.generator.class.php',
|
340 |
+
'Toolset_Shortcode_Transformer' => $vendorDir . '/toolset/toolset-common/inc/toolset.shortcode.transformer.class.php',
|
341 |
'Toolset_Stack' => $vendorDir . '/toolset/toolset-common/expression-parser/parser.php',
|
342 |
'Toolset_Style' => $vendorDir . '/toolset/toolset-common/inc/toolset.assets.manager.class.php',
|
343 |
'Toolset_Tokenizer' => $vendorDir . '/toolset/toolset-common/expression-parser/parser.php',
|
350 |
'Toolset_Upgrade_Command_Factory' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/upgrade/command_factory.php',
|
351 |
'Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/upgrade/command/m2m_v1_database_structure_upgrade.php',
|
352 |
'Toolset_Upgrade_Controller' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/upgrade/controller.php',
|
353 |
+
'Toolset_Upgrade_Executed_Commands' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/upgrade/executed_commands.php',
|
354 |
'Toolset_User_Editors_Editor_Abstract' => $vendorDir . '/toolset/toolset-common/user-editors/editor/abstract.php',
|
355 |
'Toolset_User_Editors_Editor_Avada' => $vendorDir . '/toolset/toolset-common/user-editors/editor/avada.php',
|
356 |
'Toolset_User_Editors_Editor_Basic' => $vendorDir . '/toolset/toolset-common/user-editors/editor/basic.php',
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit98453dc040b2a0c9d9e4e0ebe2a806a4
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit98453dc040b2a0c9d9e4e0ebe2a806a4
|
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
-
$includeFiles = Composer\Autoload\
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
-
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
function
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInita469bff8809f0826cf254ebc61c9ca28
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInita469bff8809f0826cf254ebc61c9ca28', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInita469bff8809f0826cf254ebc61c9ca28', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInita469bff8809f0826cf254ebc61c9ca28::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
+
$includeFiles = Composer\Autoload\ComposerStaticInita469bff8809f0826cf254ebc61c9ca28::$files;
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
+
composerRequirea469bff8809f0826cf254ebc61c9ca28($fileIdentifier, $file);
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
function composerRequirea469bff8809f0826cf254ebc61c9ca28($fileIdentifier, $file)
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'a52c1eba913b4ecdd3571194b37baea9' => __DIR__ . '/../..' . '/application/functions.php',
|
@@ -133,8 +133,10 @@ class ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4
|
|
133 |
'IToolset_Post_Type_Registered' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type_registered.php',
|
134 |
'IToolset_Potential_Association_Query' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/potential_association/query_interface.php',
|
135 |
'IToolset_Query' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/i_query.php',
|
136 |
-
'
|
|
|
137 |
'IToolset_Relationship_Origin' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/origin/interface.php',
|
|
|
138 |
'IToolset_Relationship_Query_Condition' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/i_condition.php',
|
139 |
'IToolset_Relationship_Role' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_role/interface.php',
|
140 |
'IToolset_Relationship_Role_Parent_Child' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_role/parent_child_interface.php',
|
@@ -205,6 +207,7 @@ class ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4
|
|
205 |
'Toolset_DialogBoxes' => __DIR__ . '/..' . '/toolset/toolset-common/utility/dialogs/toolset.dialog-boxes.class.php',
|
206 |
'Toolset_Element' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element/element.php',
|
207 |
'Toolset_Element_Domain' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element/domain.php',
|
|
|
208 |
'Toolset_Element_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element/element_factory.php',
|
209 |
'Toolset_ErrorHandler' => __DIR__ . '/..' . '/toolset/toolset-common/utility/utils.php',
|
210 |
'Toolset_Export_Import_Screen' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.export.import.screen.class.php',
|
@@ -297,6 +300,7 @@ class ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4
|
|
297 |
'Toolset_Regex' => __DIR__ . '/..' . '/toolset/toolset-common/expression-parser/parser.php',
|
298 |
'Toolset_Relationship_Cardinality' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/cardinality.php',
|
299 |
'Toolset_Relationship_Controller' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/controller.php',
|
|
|
300 |
'Toolset_Relationship_Database_Operations' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/database/operations.php',
|
301 |
'Toolset_Relationship_Database_Unique_Table_Alias' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/database/unique_table_alias.php',
|
302 |
'Toolset_Relationship_Definition' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/definition/definition.php',
|
@@ -317,10 +321,15 @@ class ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4
|
|
317 |
'Toolset_Relationship_Query' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/relationship_query.php',
|
318 |
'Toolset_Relationship_Query_Base' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/query_base.php',
|
319 |
'Toolset_Relationship_Query_Cache' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/query_cache.php',
|
|
|
|
|
|
|
|
|
320 |
'Toolset_Relationship_Query_Condition' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/abstract.php',
|
321 |
'Toolset_Relationship_Query_Condition_And' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/and.php',
|
322 |
'Toolset_Relationship_Query_Condition_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition_factory.php',
|
323 |
'Toolset_Relationship_Query_Condition_Has_Active_Types' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/has_active_types.php',
|
|
|
324 |
'Toolset_Relationship_Query_Condition_Has_Domain' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/has_domain.php',
|
325 |
'Toolset_Relationship_Query_Condition_Is_Active' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/is_active.php',
|
326 |
'Toolset_Relationship_Query_Condition_Is_Boolean_Flag' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/is_boolean_flag.php',
|
@@ -328,6 +337,7 @@ class ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4
|
|
328 |
'Toolset_Relationship_Query_Condition_Operator' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/operator.php',
|
329 |
'Toolset_Relationship_Query_Condition_Or' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/or.php',
|
330 |
'Toolset_Relationship_Query_Condition_Origin' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/origin.php',
|
|
|
331 |
'Toolset_Relationship_Query_Condition_Type' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/type.php',
|
332 |
'Toolset_Relationship_Query_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/query_factory.php',
|
333 |
'Toolset_Relationship_Query_Sql_Expression_Builder' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/sql_expression_builder.php',
|
@@ -356,6 +366,7 @@ class ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4
|
|
356 |
'Toolset_Shortcode_Attr_Item_Legacy' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/legacy.php',
|
357 |
'Toolset_Shortcode_Attr_Item_M2M' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/m2m.php',
|
358 |
'Toolset_Shortcode_Generator' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.shortcode.generator.class.php',
|
|
|
359 |
'Toolset_Stack' => __DIR__ . '/..' . '/toolset/toolset-common/expression-parser/parser.php',
|
360 |
'Toolset_Style' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.assets.manager.class.php',
|
361 |
'Toolset_Tokenizer' => __DIR__ . '/..' . '/toolset/toolset-common/expression-parser/parser.php',
|
@@ -368,6 +379,7 @@ class ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4
|
|
368 |
'Toolset_Upgrade_Command_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/upgrade/command_factory.php',
|
369 |
'Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/upgrade/command/m2m_v1_database_structure_upgrade.php',
|
370 |
'Toolset_Upgrade_Controller' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/upgrade/controller.php',
|
|
|
371 |
'Toolset_User_Editors_Editor_Abstract' => __DIR__ . '/..' . '/toolset/toolset-common/user-editors/editor/abstract.php',
|
372 |
'Toolset_User_Editors_Editor_Avada' => __DIR__ . '/..' . '/toolset/toolset-common/user-editors/editor/avada.php',
|
373 |
'Toolset_User_Editors_Editor_Basic' => __DIR__ . '/..' . '/toolset/toolset-common/user-editors/editor/basic.php',
|
@@ -764,10 +776,10 @@ class ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4
|
|
764 |
public static function getInitializer(ClassLoader $loader)
|
765 |
{
|
766 |
return \Closure::bind(function () use ($loader) {
|
767 |
-
$loader->prefixLengthsPsr4 =
|
768 |
-
$loader->prefixDirsPsr4 =
|
769 |
-
$loader->prefixesPsr0 =
|
770 |
-
$loader->classMap =
|
771 |
|
772 |
}, null, ClassLoader::class);
|
773 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInita469bff8809f0826cf254ebc61c9ca28
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'a52c1eba913b4ecdd3571194b37baea9' => __DIR__ . '/../..' . '/application/functions.php',
|
133 |
'IToolset_Post_Type_Registered' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type_registered.php',
|
134 |
'IToolset_Potential_Association_Query' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/potential_association/query_interface.php',
|
135 |
'IToolset_Query' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/i_query.php',
|
136 |
+
'IToolset_Relationship_Database_Issue' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/database/issue/interface.php',
|
137 |
+
'IToolset_Relationship_Definition' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/definition/interface.php',
|
138 |
'IToolset_Relationship_Origin' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/origin/interface.php',
|
139 |
+
'IToolset_Relationship_Query_Cardinality_Match' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/interface.php',
|
140 |
'IToolset_Relationship_Query_Condition' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/i_condition.php',
|
141 |
'IToolset_Relationship_Role' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_role/interface.php',
|
142 |
'IToolset_Relationship_Role_Parent_Child' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_role/parent_child_interface.php',
|
207 |
'Toolset_DialogBoxes' => __DIR__ . '/..' . '/toolset/toolset-common/utility/dialogs/toolset.dialog-boxes.class.php',
|
208 |
'Toolset_Element' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element/element.php',
|
209 |
'Toolset_Element_Domain' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element/domain.php',
|
210 |
+
'Toolset_Element_Exception_Element_Doesnt_Exist' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element/exception_element_doesnt_exist.php',
|
211 |
'Toolset_Element_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element/element_factory.php',
|
212 |
'Toolset_ErrorHandler' => __DIR__ . '/..' . '/toolset/toolset-common/utility/utils.php',
|
213 |
'Toolset_Export_Import_Screen' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.export.import.screen.class.php',
|
300 |
'Toolset_Regex' => __DIR__ . '/..' . '/toolset/toolset-common/expression-parser/parser.php',
|
301 |
'Toolset_Relationship_Cardinality' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/cardinality.php',
|
302 |
'Toolset_Relationship_Controller' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/controller.php',
|
303 |
+
'Toolset_Relationship_Database_Issue_Missing_Element' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/database/issue/missing_element.php',
|
304 |
'Toolset_Relationship_Database_Operations' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/database/operations.php',
|
305 |
'Toolset_Relationship_Database_Unique_Table_Alias' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/database/unique_table_alias.php',
|
306 |
'Toolset_Relationship_Definition' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/definition/definition.php',
|
321 |
'Toolset_Relationship_Query' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/relationship_query.php',
|
322 |
'Toolset_Relationship_Query_Base' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/query_base.php',
|
323 |
'Toolset_Relationship_Query_Cache' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/query_cache.php',
|
324 |
+
'Toolset_Relationship_Query_Cardinality_Match_Conjunction' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/conjunction.php',
|
325 |
+
'Toolset_Relationship_Query_Cardinality_Match_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/factory.php',
|
326 |
+
'Toolset_Relationship_Query_Cardinality_Match_Operators' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/operators.php',
|
327 |
+
'Toolset_Relationship_Query_Cardinality_Match_Single' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/single.php',
|
328 |
'Toolset_Relationship_Query_Condition' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/abstract.php',
|
329 |
'Toolset_Relationship_Query_Condition_And' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/and.php',
|
330 |
'Toolset_Relationship_Query_Condition_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition_factory.php',
|
331 |
'Toolset_Relationship_Query_Condition_Has_Active_Types' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/has_active_types.php',
|
332 |
+
'Toolset_Relationship_Query_Condition_Has_Cardinality' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/has_cardinality.php',
|
333 |
'Toolset_Relationship_Query_Condition_Has_Domain' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/has_domain.php',
|
334 |
'Toolset_Relationship_Query_Condition_Is_Active' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/is_active.php',
|
335 |
'Toolset_Relationship_Query_Condition_Is_Boolean_Flag' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/is_boolean_flag.php',
|
337 |
'Toolset_Relationship_Query_Condition_Operator' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/operator.php',
|
338 |
'Toolset_Relationship_Query_Condition_Or' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/or.php',
|
339 |
'Toolset_Relationship_Query_Condition_Origin' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/origin.php',
|
340 |
+
'Toolset_Relationship_Query_Condition_Tautology' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/tautology.php',
|
341 |
'Toolset_Relationship_Query_Condition_Type' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/type.php',
|
342 |
'Toolset_Relationship_Query_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/query_factory.php',
|
343 |
'Toolset_Relationship_Query_Sql_Expression_Builder' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/sql_expression_builder.php',
|
366 |
'Toolset_Shortcode_Attr_Item_Legacy' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/legacy.php',
|
367 |
'Toolset_Shortcode_Attr_Item_M2M' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/m2m.php',
|
368 |
'Toolset_Shortcode_Generator' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.shortcode.generator.class.php',
|
369 |
+
'Toolset_Shortcode_Transformer' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.shortcode.transformer.class.php',
|
370 |
'Toolset_Stack' => __DIR__ . '/..' . '/toolset/toolset-common/expression-parser/parser.php',
|
371 |
'Toolset_Style' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.assets.manager.class.php',
|
372 |
'Toolset_Tokenizer' => __DIR__ . '/..' . '/toolset/toolset-common/expression-parser/parser.php',
|
379 |
'Toolset_Upgrade_Command_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/upgrade/command_factory.php',
|
380 |
'Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/upgrade/command/m2m_v1_database_structure_upgrade.php',
|
381 |
'Toolset_Upgrade_Controller' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/upgrade/controller.php',
|
382 |
+
'Toolset_Upgrade_Executed_Commands' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/upgrade/executed_commands.php',
|
383 |
'Toolset_User_Editors_Editor_Abstract' => __DIR__ . '/..' . '/toolset/toolset-common/user-editors/editor/abstract.php',
|
384 |
'Toolset_User_Editors_Editor_Avada' => __DIR__ . '/..' . '/toolset/toolset-common/user-editors/editor/avada.php',
|
385 |
'Toolset_User_Editors_Editor_Basic' => __DIR__ . '/..' . '/toolset/toolset-common/user-editors/editor/basic.php',
|
776 |
public static function getInitializer(ClassLoader $loader)
|
777 |
{
|
778 |
return \Closure::bind(function () use ($loader) {
|
779 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInita469bff8809f0826cf254ebc61c9ca28::$prefixLengthsPsr4;
|
780 |
+
$loader->prefixDirsPsr4 = ComposerStaticInita469bff8809f0826cf254ebc61c9ca28::$prefixDirsPsr4;
|
781 |
+
$loader->prefixesPsr0 = ComposerStaticInita469bff8809f0826cf254ebc61c9ca28::$prefixesPsr0;
|
782 |
+
$loader->classMap = ComposerStaticInita469bff8809f0826cf254ebc61c9ca28::$classMap;
|
783 |
|
784 |
}, null, ClassLoader::class);
|
785 |
}
|
vendor/composer/installed.json
CHANGED
@@ -217,12 +217,12 @@
|
|
217 |
},
|
218 |
{
|
219 |
"name": "toolset/toolset-common",
|
220 |
-
"version": "2.5.
|
221 |
-
"version_normalized": "2.5.
|
222 |
"source": {
|
223 |
"type": "git",
|
224 |
"url": "ssh://git@git.onthegosystems.com:10022/toolset/toolset-common.git",
|
225 |
-
"reference": "
|
226 |
},
|
227 |
"require": {
|
228 |
"php": ">=5.2.0"
|
@@ -233,7 +233,7 @@
|
|
233 |
"otgs/unit-tests-framework": "~1.2.0",
|
234 |
"phpunit/php-token-stream": "<2.0"
|
235 |
},
|
236 |
-
"time": "2017-
|
237 |
"type": "library",
|
238 |
"extra": {
|
239 |
"branch-alias": {
|
217 |
},
|
218 |
{
|
219 |
"name": "toolset/toolset-common",
|
220 |
+
"version": "2.5.8",
|
221 |
+
"version_normalized": "2.5.8.0",
|
222 |
"source": {
|
223 |
"type": "git",
|
224 |
"url": "ssh://git@git.onthegosystems.com:10022/toolset/toolset-common.git",
|
225 |
+
"reference": "afd2128b775ac8942402ea6c3ab0bbeb85e0dc0b"
|
226 |
},
|
227 |
"require": {
|
228 |
"php": ">=5.2.0"
|
233 |
"otgs/unit-tests-framework": "~1.2.0",
|
234 |
"phpunit/php-token-stream": "<2.0"
|
235 |
},
|
236 |
+
"time": "2017-12-07T11:25:32+00:00",
|
237 |
"type": "library",
|
238 |
"extra": {
|
239 |
"branch-alias": {
|
vendor/toolset/toolset-common/autoload_classmap.php
CHANGED
@@ -58,6 +58,7 @@ return array(
|
|
58 |
'Toolset_Date_Utils' => dirname( __FILE__ ) . '/inc/autoloaded/date_utils.php',
|
59 |
'Toolset_Element' => dirname( __FILE__ ) . '/inc/autoloaded/element/element.php',
|
60 |
'Toolset_Element_Domain' => dirname( __FILE__ ) . '/inc/autoloaded/element/domain.php',
|
|
|
61 |
'Toolset_Element_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/element/element_factory.php',
|
62 |
'Toolset_Field_Accessor_Abstract' => dirname( __FILE__ ) . '/inc/autoloaded/field/accessor/abstract.php',
|
63 |
'Toolset_Field_Accessor_Dummy' => dirname( __FILE__ ) . '/inc/autoloaded/field/accessor/dummy.php',
|
@@ -152,6 +153,7 @@ return array(
|
|
152 |
'Toolset_Upgrade_Command_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/upgrade/command_factory.php',
|
153 |
'Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade' => dirname( __FILE__ ) . '/inc/autoloaded/upgrade/command/m2m_v1_database_structure_upgrade.php',
|
154 |
'Toolset_Upgrade_Controller' => dirname( __FILE__ ) . '/inc/autoloaded/upgrade/controller.php',
|
|
|
155 |
'Toolset_User_Editors_Editor_Abstract' => dirname( __FILE__ ) . '/user-editors/editor/abstract.php',
|
156 |
'Toolset_User_Editors_Editor_Avada' => dirname( __FILE__ ) . '/user-editors/editor/avada.php',
|
157 |
'Toolset_User_Editors_Editor_Basic' => dirname( __FILE__ ) . '/user-editors/editor/basic.php',
|
58 |
'Toolset_Date_Utils' => dirname( __FILE__ ) . '/inc/autoloaded/date_utils.php',
|
59 |
'Toolset_Element' => dirname( __FILE__ ) . '/inc/autoloaded/element/element.php',
|
60 |
'Toolset_Element_Domain' => dirname( __FILE__ ) . '/inc/autoloaded/element/domain.php',
|
61 |
+
'Toolset_Element_Exception_Element_Doesnt_Exist' => dirname( __FILE__ ) . '/inc/autoloaded/element/exception_element_doesnt_exist.php',
|
62 |
'Toolset_Element_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/element/element_factory.php',
|
63 |
'Toolset_Field_Accessor_Abstract' => dirname( __FILE__ ) . '/inc/autoloaded/field/accessor/abstract.php',
|
64 |
'Toolset_Field_Accessor_Dummy' => dirname( __FILE__ ) . '/inc/autoloaded/field/accessor/dummy.php',
|
153 |
'Toolset_Upgrade_Command_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/upgrade/command_factory.php',
|
154 |
'Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade' => dirname( __FILE__ ) . '/inc/autoloaded/upgrade/command/m2m_v1_database_structure_upgrade.php',
|
155 |
'Toolset_Upgrade_Controller' => dirname( __FILE__ ) . '/inc/autoloaded/upgrade/controller.php',
|
156 |
+
'Toolset_Upgrade_Executed_Commands' => dirname( __FILE__ ) . '/inc/autoloaded/upgrade/executed_commands.php',
|
157 |
'Toolset_User_Editors_Editor_Abstract' => dirname( __FILE__ ) . '/user-editors/editor/abstract.php',
|
158 |
'Toolset_User_Editors_Editor_Avada' => dirname( __FILE__ ) . '/user-editors/editor/avada.php',
|
159 |
'Toolset_User_Editors_Editor_Basic' => dirname( __FILE__ ) . '/user-editors/editor/basic.php',
|
vendor/toolset/toolset-common/bootstrap.php
CHANGED
@@ -458,6 +458,7 @@ class Toolset_Common_Bootstrap {
|
|
458 |
if ( ! $this->is_section_loaded( self::TOOLSET_SHORTCODE_GENERATOR ) ) {
|
459 |
$this->add_section_loaded( self::TOOLSET_SHORTCODE_GENERATOR );
|
460 |
require_once( TOOLSET_COMMON_PATH . '/inc/toolset.shortcode.generator.class.php' );
|
|
|
461 |
$this->apply_filters_on_sections_loaded( 'toolset_register_shortcode_generator_section' );
|
462 |
}
|
463 |
}
|
458 |
if ( ! $this->is_section_loaded( self::TOOLSET_SHORTCODE_GENERATOR ) ) {
|
459 |
$this->add_section_loaded( self::TOOLSET_SHORTCODE_GENERATOR );
|
460 |
require_once( TOOLSET_COMMON_PATH . '/inc/toolset.shortcode.generator.class.php' );
|
461 |
+
require_once( TOOLSET_COMMON_PATH . '/inc/toolset.shortcode.transformer.class.php' );
|
462 |
$this->apply_filters_on_sections_loaded( 'toolset_register_shortcode_generator_section' );
|
463 |
}
|
464 |
}
|
vendor/toolset/toolset-common/build/list_subdirs.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Generate a simple HTML file with links to subdirectories, and save it to "public/index.html".
|
4 |
+
*
|
5 |
+
* This is used when generating the documentation with Sami, and it's expected to be copied to the root directory
|
6 |
+
* of the repository before running.
|
7 |
+
*
|
8 |
+
* @since 2.5.6
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @param string $dir Path to a directory
|
14 |
+
* @return string[] Names of its subdirectories
|
15 |
+
*/
|
16 |
+
function getFileList( $dir ) {
|
17 |
+
// array to hold return value
|
18 |
+
$retval = array();
|
19 |
+
|
20 |
+
// add trailing slash if missing
|
21 |
+
if ( substr( $dir, - 1 ) != "/" ) {
|
22 |
+
$dir .= "/";
|
23 |
+
}
|
24 |
+
|
25 |
+
// open pointer to directory and read list of files
|
26 |
+
$d = dir( $dir ) or die( "getFileList: Failed opening directory $dir for reading" );
|
27 |
+
while ( false !== ( $entry = $d->read() ) ) {
|
28 |
+
// skip hidden files
|
29 |
+
if ( $entry[0] == "." ) {
|
30 |
+
continue;
|
31 |
+
}
|
32 |
+
if ( is_dir( "$dir$entry" ) ) {
|
33 |
+
$retval[] = $entry;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
$d->close();
|
37 |
+
|
38 |
+
return $retval;
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
$subdirs = getFileList( __DIR__ . '/public' );
|
43 |
+
|
44 |
+
// Sort versions master > develop > anything else, which gets sorted by version_compare in descening order.
|
45 |
+
//
|
46 |
+
//
|
47 |
+
usort( $subdirs, function( $a, $b ) {
|
48 |
+
if( 'master' === $a ) {
|
49 |
+
if( 'master' === $b ) {
|
50 |
+
return 0;
|
51 |
+
} else {
|
52 |
+
return -1; // $a < $b
|
53 |
+
}
|
54 |
+
} elseif( 'master' === $b ) {
|
55 |
+
// at this point, $a is develop or a specific version
|
56 |
+
return 1; // $a > $b
|
57 |
+
} elseif( 'develop' === $a ) {
|
58 |
+
// at this point, $b is only develop or a specific version
|
59 |
+
if( 'develop' === $b ) {
|
60 |
+
return 0;
|
61 |
+
} else {
|
62 |
+
return -1; // $a < $b
|
63 |
+
}
|
64 |
+
} elseif( 'develop' === $b ) {
|
65 |
+
// at this point, $a is always a specific version
|
66 |
+
return 1; // $a > $b
|
67 |
+
} else {
|
68 |
+
return version_compare( $a, $b ) * -1;
|
69 |
+
}
|
70 |
+
} );
|
71 |
+
|
72 |
+
|
73 |
+
// Generate the index file contents.
|
74 |
+
//
|
75 |
+
//
|
76 |
+
ob_start();
|
77 |
+
|
78 |
+
?>
|
79 |
+
<h1>Toolset Common Documentation</h1>
|
80 |
+
<ul>
|
81 |
+
<?php
|
82 |
+
foreach( $subdirs as $subdir ) {
|
83 |
+
printf(
|
84 |
+
"\t<li><a href=\"%s\">%s</a></li>\n",
|
85 |
+
$subdir, $subdir
|
86 |
+
);
|
87 |
+
}
|
88 |
+
?>
|
89 |
+
</ul>
|
90 |
+
<?php
|
91 |
+
|
92 |
+
$output = ob_get_clean();
|
93 |
+
|
94 |
+
// Save the index file.
|
95 |
+
//
|
96 |
+
//
|
97 |
+
echo "rendered output for index.html: \n\n$output\n\n";
|
98 |
+
file_put_contents( __DIR__ . '/public/index.html', $output );
|
vendor/toolset/toolset-common/changelog.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1 |
# Toolset Common Library
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
## 2.5.5
|
4 |
* Released with Types 2.2.20 and Views 2.5.1
|
5 |
* Fix the way we determine whether the m2m API should be enabled on fresh sites without post relationships by default (types-1252).
|
1 |
# Toolset Common Library
|
2 |
|
3 |
+
## 2.5.8
|
4 |
+
* New admin notice about Types becoming commercial
|
5 |
+
|
6 |
+
## 2.5.7
|
7 |
+
* (toolsetcommon-305) Improve the database structure for relationships and associations.
|
8 |
+
* (types-1213) Implement a mechanism for handling database integrity issues within the m2m API.
|
9 |
+
* (types-1265) Introduce a QUERY_HAS_TRASHED_POSTS argument to Toolset_Association_Query
|
10 |
+
* Many improvements to the m2m API, especially to the relationship query.
|
11 |
+
* (toolsetcommon-328) Enforce cardinality limits when creating associations between two elements.
|
12 |
+
* (toolsetcommon-330) Prevent upgrade routines from running repeatedly. Fix a m2m activation issue.
|
13 |
+
* (toolsetcommon-249) The Toolset_Twig_Autoloader now bails out when it's possible to load the Twig_Environment class.
|
14 |
+
|
15 |
+
## 2.5.6
|
16 |
+
* Fixed a but that prevented CRED attributes offered as select2 instances from getting their values in the final shortcode.
|
17 |
+
|
18 |
## 2.5.5
|
19 |
* Released with Types 2.2.20 and Views 2.5.1
|
20 |
* Fix the way we determine whether the m2m API should be enabled on fresh sites without post relationships by default (types-1252).
|
vendor/toolset/toolset-common/inc/autoloaded/element/element.php
CHANGED
@@ -64,7 +64,7 @@ abstract class Toolset_Element implements IToolset_Element {
|
|
64 |
|
65 |
switch( $domain ) {
|
66 |
|
67 |
-
case Toolset_Field_Utils::DOMAIN_POSTS:
|
68 |
|
69 |
if( $object_source instanceof IToolset_Post ) {
|
70 |
// todo handle Toolset_Post where we should be returning Toolset_Post_Translation_Set
|
@@ -105,7 +105,7 @@ abstract class Toolset_Element implements IToolset_Element {
|
|
105 |
}
|
106 |
|
107 |
// No WPML, simply return the post object.
|
108 |
-
return self::get_untranslated_instance( $domain, $object_source )
|
109 |
|
110 |
|
111 |
default:
|
64 |
|
65 |
switch( $domain ) {
|
66 |
|
67 |
+
/*case Toolset_Field_Utils::DOMAIN_POSTS:
|
68 |
|
69 |
if( $object_source instanceof IToolset_Post ) {
|
70 |
// todo handle Toolset_Post where we should be returning Toolset_Post_Translation_Set
|
105 |
}
|
106 |
|
107 |
// No WPML, simply return the post object.
|
108 |
+
return self::get_untranslated_instance( $domain, $object_source );*/
|
109 |
|
110 |
|
111 |
default:
|
vendor/toolset/toolset-common/inc/autoloaded/element/exception_element_doesnt_exist.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Exception indicating that an element (post, user, term) doesn't exist when it should.
|
5 |
+
*
|
6 |
+
* It can be used to catch and safely handle a case of data corruption (e.g. post being deleted
|
7 |
+
* while Toolset plugins are inactive).
|
8 |
+
*
|
9 |
+
* @since 2.5.6
|
10 |
+
*/
|
11 |
+
class Toolset_Element_Exception_Element_Doesnt_Exist extends Exception {
|
12 |
+
|
13 |
+
|
14 |
+
/** @var int */
|
15 |
+
private $element_id;
|
16 |
+
|
17 |
+
|
18 |
+
/** @var string */
|
19 |
+
private $domain;
|
20 |
+
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Toolset_Element_Exception_Element_Doesnt_Exist constructor.
|
24 |
+
*
|
25 |
+
* @param string $domain One of the Toolset_Element_Domain values.
|
26 |
+
* @param int|mixed $element_source This should be an ID of the element, but other value
|
27 |
+
* will be also accepted for the purpose of rendering an error message.
|
28 |
+
*/
|
29 |
+
public function __construct( $domain, $element_source ) {
|
30 |
+
|
31 |
+
if( Toolset_Utils::is_natural_numeric( $element_source ) ) {
|
32 |
+
$this->element_id = (int) $element_source;
|
33 |
+
} else {
|
34 |
+
$this->element_id = 0;
|
35 |
+
}
|
36 |
+
|
37 |
+
$this->domain = $domain;
|
38 |
+
|
39 |
+
parent::__construct(
|
40 |
+
sprintf(
|
41 |
+
__( 'Unable to load %s %d (%s).', 'wpcf' ),
|
42 |
+
$domain,
|
43 |
+
$this->element_id,
|
44 |
+
esc_html( print_r( $element_source, true ) )
|
45 |
+
)
|
46 |
+
);
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @return int Element ID or zero if it wasn't provided.
|
52 |
+
*/
|
53 |
+
public function get_element_id() {
|
54 |
+
return $this->element_id;
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @return string Element domain (needs to be validated).
|
60 |
+
*/
|
61 |
+
public function get_domain() {
|
62 |
+
return $this->domain;
|
63 |
+
}
|
64 |
+
|
65 |
+
}
|
vendor/toolset/toolset-common/inc/autoloaded/element/post.php
CHANGED
@@ -28,6 +28,7 @@ class Toolset_Post extends Toolset_Element implements IToolset_Post {
|
|
28 |
* determined first time it's needed).
|
29 |
* @param null|Toolset_Field_Group_Post_Factory $group_post_factory DI for phpunit
|
30 |
*
|
|
|
31 |
* @since m2m
|
32 |
*/
|
33 |
protected function __construct( $object_source, $language_code = null, $group_post_factory = null ) {
|
@@ -39,8 +40,9 @@ class Toolset_Post extends Toolset_Element implements IToolset_Post {
|
|
39 |
}
|
40 |
|
41 |
if( ! $post instanceof WP_Post ) {
|
42 |
-
throw new
|
43 |
-
|
|
|
44 |
);
|
45 |
}
|
46 |
|
28 |
* determined first time it's needed).
|
29 |
* @param null|Toolset_Field_Group_Post_Factory $group_post_factory DI for phpunit
|
30 |
*
|
31 |
+
* @throws Toolset_Element_Exception_Element_Doesnt_Exist
|
32 |
* @since m2m
|
33 |
*/
|
34 |
protected function __construct( $object_source, $language_code = null, $group_post_factory = null ) {
|
40 |
}
|
41 |
|
42 |
if( ! $post instanceof WP_Post ) {
|
43 |
+
throw new Toolset_Element_Exception_Element_Doesnt_Exist(
|
44 |
+
Toolset_Element_Domain::POSTS,
|
45 |
+
$object_source
|
46 |
);
|
47 |
}
|
48 |
|
vendor/toolset/toolset-common/inc/autoloaded/field/definition_abstract.php
CHANGED
@@ -89,7 +89,7 @@ abstract class Toolset_Field_Definition_Abstract {
|
|
89 |
'isUnderTypesControl' => $this->is_under_types_control(),
|
90 |
'slug' => $this->get_slug(),
|
91 |
'metaKey' => $this->get_slug(),
|
92 |
-
'displayName' => $this->get_name(),
|
93 |
'groups' => $this->get_group_slugs()
|
94 |
);
|
95 |
|
89 |
'isUnderTypesControl' => $this->is_under_types_control(),
|
90 |
'slug' => $this->get_slug(),
|
91 |
'metaKey' => $this->get_slug(),
|
92 |
+
'displayName' => stripslashes( $this->get_name() ),
|
93 |
'groups' => $this->get_group_slugs()
|
94 |
);
|
95 |
|
vendor/toolset/toolset-common/inc/autoloaded/field/renderer/toolset_forms.php
CHANGED
@@ -49,6 +49,7 @@ class Toolset_Field_Renderer_Toolset_Forms extends Toolset_Field_Renderer_Abstra
|
|
49 |
|
50 |
if( $this->hide_field_title ) {
|
51 |
$field_config['title'] = '';
|
|
|
52 |
}
|
53 |
|
54 |
$value_in_intermediate_format = $this->field->get_value();
|
49 |
|
50 |
if( $this->hide_field_title ) {
|
51 |
$field_config['title'] = '';
|
52 |
+
$field_config['hide_field_title'] = true;
|
53 |
}
|
54 |
|
55 |
$value_in_intermediate_format = $this->field->get_value();
|
vendor/toolset/toolset-common/inc/autoloaded/field/renderer/toolset_forms_repeatable_group.php
CHANGED
@@ -18,6 +18,7 @@ class Toolset_Field_Renderer_Toolset_Forms_Repeatable_Group extends Toolset_Fiel
|
|
18 |
$field_config = $this->get_toolset_forms_config();
|
19 |
if ( $this->hide_field_title ) {
|
20 |
$field_config['title'] = '';
|
|
|
21 |
}
|
22 |
|
23 |
if ( $field_config['type'] == 'wysiwyg' ) {
|
18 |
$field_config = $this->get_toolset_forms_config();
|
19 |
if ( $this->hide_field_title ) {
|
20 |
$field_config['title'] = '';
|
21 |
+
$field_config['hide_field_title'] = true;
|
22 |
}
|
23 |
|
24 |
if ( $field_config['type'] == 'wysiwyg' ) {
|
vendor/toolset/toolset-common/inc/autoloaded/field/type/definition_factory.php
CHANGED
@@ -223,7 +223,7 @@ class Toolset_Field_Type_Definition_Factory {
|
|
223 |
foreach( $field_types as $field_type ) {
|
224 |
$field_type_names[ $field_type->get_slug() ] = array(
|
225 |
'slug' => $field_type->get_slug(),
|
226 |
-
'displayName' => $field_type->get_display_name(),
|
227 |
'canBeRepetitive' => $field_type->can_be_repetitive(),
|
228 |
'iconClasses' => $field_type->get_icon_classes()
|
229 |
);
|
223 |
foreach( $field_types as $field_type ) {
|
224 |
$field_type_names[ $field_type->get_slug() ] = array(
|
225 |
'slug' => $field_type->get_slug(),
|
226 |
+
'displayName' => stripslashes( $field_type->get_display_name() ),
|
227 |
'canBeRepetitive' => $field_type->can_be_repetitive(),
|
228 |
'iconClasses' => $field_type->get_icon_classes()
|
229 |
);
|
vendor/toolset/toolset-common/inc/autoloaded/post_type/from_types.php
CHANGED
@@ -194,7 +194,7 @@ class Toolset_Post_Type_From_Types implements IToolset_Post_Type_From_Types {
|
|
194 |
),
|
195 |
'slug' => '',
|
196 |
'description' => '',
|
197 |
-
'public' =>
|
198 |
'capabilities' => array(),
|
199 |
'menu_position' => null,
|
200 |
'menu_icon' => '',
|
@@ -449,6 +449,7 @@ class Toolset_Post_Type_From_Types implements IToolset_Post_Type_From_Types {
|
|
449 |
*/
|
450 |
public function set_is_repeating_field_group( $value ) {
|
451 |
$this->set_flag_to_definition( self::DEF_IS_REPEATING_FIELD_GROUP, (bool) $value );
|
|
|
452 |
}
|
453 |
|
454 |
|
194 |
),
|
195 |
'slug' => '',
|
196 |
'description' => '',
|
197 |
+
'public' => self::DEF_PUBLIC,
|
198 |
'capabilities' => array(),
|
199 |
'menu_position' => null,
|
200 |
'menu_icon' => '',
|
449 |
*/
|
450 |
public function set_is_repeating_field_group( $value ) {
|
451 |
$this->set_flag_to_definition( self::DEF_IS_REPEATING_FIELD_GROUP, (bool) $value );
|
452 |
+
$this->set_is_public( false );
|
453 |
}
|
454 |
|
455 |
|
vendor/toolset/toolset-common/inc/autoloaded/relationship_service.php
CHANGED
@@ -196,27 +196,83 @@ class Toolset_Relationship_Service {
|
|
196 |
return false;
|
197 |
}
|
198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
$qry_args = array(
|
200 |
-
Toolset_Association_Query::QUERY_PARENT_ID
|
201 |
-
Toolset_Association_Query::OPTION_RETURN
|
202 |
);
|
203 |
|
204 |
$associations_parent = $this->query_association( $qry_args );
|
205 |
-
|
|
|
206 |
? $associations_parent
|
207 |
: array();
|
|
|
208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
$qry_args = array(
|
210 |
-
Toolset_Association_Query::QUERY_CHILD_ID
|
211 |
-
Toolset_Association_Query::OPTION_RETURN
|
212 |
);
|
213 |
|
214 |
$associations_child = $this->query_association( $qry_args );
|
215 |
-
|
|
|
216 |
? $associations_child
|
217 |
: array();
|
|
|
218 |
|
219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
}
|
221 |
|
222 |
/**
|
196 |
return false;
|
197 |
}
|
198 |
|
199 |
+
$associations_parent = $this->find_associations_by_parent_id( $post_id );
|
200 |
+
$associations_child = $this->find_associations_by_child_id( $post_id );
|
201 |
+
|
202 |
+
return array_merge( $associations_parent, $associations_child );
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Find associations (IToolset_Associations[]) by parent id
|
207 |
+
*
|
208 |
+
* @param $id
|
209 |
+
*
|
210 |
+
* @return IToolset_Association[]
|
211 |
+
*/
|
212 |
+
private function find_associations_by_parent_id( $id ) {
|
213 |
$qry_args = array(
|
214 |
+
Toolset_Association_Query::QUERY_PARENT_ID => $id,
|
215 |
+
Toolset_Association_Query::OPTION_RETURN => Toolset_Association_Query::RETURN_ASSOCIATIONS
|
216 |
);
|
217 |
|
218 |
$associations_parent = $this->query_association( $qry_args );
|
219 |
+
|
220 |
+
return is_array( $associations_parent )
|
221 |
? $associations_parent
|
222 |
: array();
|
223 |
+
}
|
224 |
|
225 |
+
/**
|
226 |
+
* Find associations (IToolset_Associations[]) by child id
|
227 |
+
*
|
228 |
+
* @param $id
|
229 |
+
*
|
230 |
+
* @return IToolset_Association[]
|
231 |
+
*/
|
232 |
+
private function find_associations_by_child_id( $id ) {
|
233 |
$qry_args = array(
|
234 |
+
Toolset_Association_Query::QUERY_CHILD_ID => $id,
|
235 |
+
Toolset_Association_Query::OPTION_RETURN => Toolset_Association_Query::RETURN_ASSOCIATIONS
|
236 |
);
|
237 |
|
238 |
$associations_child = $this->query_association( $qry_args );
|
239 |
+
|
240 |
+
return is_array( $associations_child )
|
241 |
? $associations_child
|
242 |
: array();
|
243 |
+
}
|
244 |
|
245 |
+
/**
|
246 |
+
* Function to find parents (Toolset_Element[]) by child id and parent slug.
|
247 |
+
*
|
248 |
+
* @param $child_id
|
249 |
+
* @param $parent_slug
|
250 |
+
*
|
251 |
+
* @return Toolset_Element[]
|
252 |
+
*/
|
253 |
+
public function find_parents_by_child_id_and_parent_slug( $child_id, $parent_slug ) {
|
254 |
+
if( ! $this->is_m2m_enabled() ) {
|
255 |
+
return false;
|
256 |
+
}
|
257 |
+
|
258 |
+
$associations = $this->find_associations_by_child_id( $child_id );
|
259 |
+
$associations_matched = array();
|
260 |
+
|
261 |
+
foreach( $associations as $association ) {
|
262 |
+
$parent = $association->get_element( Toolset_Relationship_Role::PARENT );
|
263 |
+
$parent_underlying_obj = $parent->get_underlying_object();
|
264 |
+
|
265 |
+
if( ! property_exists( $parent_underlying_obj, 'post_type' ) ) {
|
266 |
+
// only post elements supported
|
267 |
+
continue;
|
268 |
+
}
|
269 |
+
|
270 |
+
if( $parent_underlying_obj->post_type == $parent_slug ) {
|
271 |
+
$associations_matched[] = $parent;
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
return $associations_matched;
|
276 |
}
|
277 |
|
278 |
/**
|
vendor/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/id.php
CHANGED
@@ -16,14 +16,34 @@ class Toolset_Shortcode_Attr_Item_Id implements Toolset_Shortcode_Attr_Interface
|
|
16 |
*/
|
17 |
public function get( array $data ) {
|
18 |
if( ! $role_id = $this->handle_attr_synonyms( $data ) ) {
|
|
|
19 |
global $post;
|
20 |
|
21 |
if ( is_object( $post ) && property_exists( $post, 'ID' ) ) {
|
22 |
$role_id = $post->ID;
|
23 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
-
return $this->return_single_id( $
|
27 |
}
|
28 |
|
29 |
/**
|
16 |
*/
|
17 |
public function get( array $data ) {
|
18 |
if( ! $role_id = $this->handle_attr_synonyms( $data ) ) {
|
19 |
+
// no 'id' attribute used, means current post should be shown
|
20 |
global $post;
|
21 |
|
22 |
if ( is_object( $post ) && property_exists( $post, 'ID' ) ) {
|
23 |
$role_id = $post->ID;
|
24 |
}
|
25 |
+
|
26 |
+
return $this->return_single_id( $role_id );
|
27 |
+
}
|
28 |
+
|
29 |
+
$single_id = $this->return_single_id( $role_id );
|
30 |
+
|
31 |
+
if( ! $single_id
|
32 |
+
&& ( // check if legacy attribute ('id' or 'post_id') is in use
|
33 |
+
( isset( $data['id'] ) && ! empty( $data['id'] ) )
|
34 |
+
|| ( isset( $data['post_id'] ) && ! empty( $data['post_id'] ) )
|
35 |
+
)
|
36 |
+
) {
|
37 |
+
// 'id' attribute used, but no valid id given -> use current global post
|
38 |
+
// NOTE: we just keep this behaviour as legacy introduced it and we want to max backward compatibilty
|
39 |
+
global $post;
|
40 |
+
|
41 |
+
if ( is_object( $post ) && property_exists( $post, 'ID' ) ) {
|
42 |
+
$single_id = $post->ID;
|
43 |
+
}
|
44 |
}
|
45 |
|
46 |
+
return $this->return_single_id( $single_id );
|
47 |
}
|
48 |
|
49 |
/**
|
vendor/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/legacy.php
CHANGED
@@ -74,8 +74,16 @@ class Toolset_Shortcode_Attr_Item_Legacy extends Toolset_Shortcode_Attr_Item_Id
|
|
74 |
return $this->chain_link->get( $data );
|
75 |
}
|
76 |
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
|
81 |
return $this->chain_link->get( $data );
|
74 |
return $this->chain_link->get( $data );
|
75 |
}
|
76 |
|
77 |
+
// find parent by using the slug (to support legacy use of the shortcode [types id="$parent_slug"])
|
78 |
+
$parents_with_specific_slug = $this->service_relationship->find_parents_by_child_id_and_parent_slug( $post->ID, $role_slug );
|
79 |
+
|
80 |
+
if( count( $parents_with_specific_slug ) > 1 ) {
|
81 |
+
// todo show a message to the admin that he should replace the old shortcode structure by the new
|
82 |
+
// as long as this message is not implemented we show the first found item (with the foreach after this if block).
|
83 |
+
}
|
84 |
+
|
85 |
+
foreach( $parents_with_specific_slug as $parent ) {
|
86 |
+
return $this->return_single_id( $parent->get_id() );
|
87 |
}
|
88 |
|
89 |
return $this->chain_link->get( $data );
|
vendor/toolset/toolset-common/inc/autoloaded/upgrade/command/m2m_v1_database_structure_upgrade.php
CHANGED
@@ -52,6 +52,7 @@ class Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade implements ITool
|
|
52 |
$this->_database_operations = $relationship_database_operations_di;
|
53 |
}
|
54 |
|
|
|
55 |
/**
|
56 |
* Run the command.
|
57 |
*
|
@@ -64,6 +65,14 @@ class Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade implements ITool
|
|
64 |
return new Toolset_Result( true );
|
65 |
}
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
$results = new Toolset_Result_Set();
|
68 |
|
69 |
$this->create_post_type_set_table();
|
@@ -82,9 +91,26 @@ class Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade implements ITool
|
|
82 |
|
83 |
$this->add_indexes_for_associations_table();
|
84 |
|
|
|
|
|
85 |
return $results;
|
86 |
}
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
private function create_post_type_set_table() {
|
89 |
|
90 |
// Note that dbDelta is very sensitive about details, almost nothing here is arbitrary.
|
52 |
$this->_database_operations = $relationship_database_operations_di;
|
53 |
}
|
54 |
|
55 |
+
|
56 |
/**
|
57 |
* Run the command.
|
58 |
*
|
65 |
return new Toolset_Result( true );
|
66 |
}
|
67 |
|
68 |
+
if( $this->is_database_already_up_to_date() ) {
|
69 |
+
// Nothing to do here: This happens when Types is activated on a fresh site: It creates
|
70 |
+
// the tables according to the new structure but runs the upgrade routine at the same time.
|
71 |
+
return new Toolset_Result( true );
|
72 |
+
}
|
73 |
+
|
74 |
+
error_log( 'The routine Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade::run() is starting' );
|
75 |
+
|
76 |
$results = new Toolset_Result_Set();
|
77 |
|
78 |
$this->create_post_type_set_table();
|
91 |
|
92 |
$this->add_indexes_for_associations_table();
|
93 |
|
94 |
+
error_log( 'The routine Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade::run() has finished' );
|
95 |
+
|
96 |
return $results;
|
97 |
}
|
98 |
|
99 |
+
|
100 |
+
/**
|
101 |
+
* If the type set table exists, it means that we're dealing with a more recent database structure than this
|
102 |
+
* command aims to improve.
|
103 |
+
*
|
104 |
+
* @return bool
|
105 |
+
*/
|
106 |
+
private function is_database_already_up_to_date() {
|
107 |
+
$table_name = $this->get_type_set_table_name();
|
108 |
+
$query = $this->wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name );
|
109 |
+
$type_set_table_already_exists = ( $this->wpdb->get_var( $query ) == $table_name );
|
110 |
+
return $type_set_table_already_exists;
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
private function create_post_type_set_table() {
|
115 |
|
116 |
// Note that dbDelta is very sensitive about details, almost nothing here is arbitrary.
|
vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_definition.php
CHANGED
@@ -51,8 +51,8 @@ class Toolset_Upgrade_Command_Definition {
|
|
51 |
*
|
52 |
* @return bool
|
53 |
*/
|
54 |
-
public function should_run( $from_version, $to_version ) {
|
55 |
-
return ( $from_version < $this->upgrade_version
|
56 |
}
|
57 |
|
58 |
|
@@ -66,6 +66,15 @@ class Toolset_Upgrade_Command_Definition {
|
|
66 |
}
|
67 |
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
/**
|
70 |
* @return Toolset_Upgrade_Command_Factory
|
71 |
*/
|
51 |
*
|
52 |
* @return bool
|
53 |
*/
|
54 |
+
public function should_run( $from_version, /** @noinspection PhpUnusedParameterInspection */ $to_version ) {
|
55 |
+
return ( $from_version < $this->upgrade_version );
|
56 |
}
|
57 |
|
58 |
|
66 |
}
|
67 |
|
68 |
|
69 |
+
/**
|
70 |
+
* @return string Unique command name.
|
71 |
+
* @since 2.5.7
|
72 |
+
*/
|
73 |
+
public function get_command_name() {
|
74 |
+
return $this->command_class_name;
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
/**
|
79 |
* @return Toolset_Upgrade_Command_Factory
|
80 |
*/
|
vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_definition_repository.php
CHANGED
@@ -14,7 +14,7 @@ class Toolset_Upgrade_Command_Definition_Repository {
|
|
14 |
$upgrade_commands = array(
|
15 |
new Toolset_Upgrade_Command_Definition(
|
16 |
'Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade',
|
17 |
-
|
18 |
)
|
19 |
);
|
20 |
|
14 |
$upgrade_commands = array(
|
15 |
new Toolset_Upgrade_Command_Definition(
|
16 |
'Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade',
|
17 |
+
254002
|
18 |
)
|
19 |
);
|
20 |
|
vendor/toolset/toolset-common/inc/autoloaded/upgrade/controller.php
CHANGED
@@ -35,6 +35,10 @@ class Toolset_Upgrade_Controller {
|
|
35 |
private $_command_definition_repository;
|
36 |
|
37 |
|
|
|
|
|
|
|
|
|
38 |
public static function get_instance() {
|
39 |
if( null == self::$instance ) {
|
40 |
self::$instance = new self();
|
@@ -43,7 +47,7 @@ class Toolset_Upgrade_Controller {
|
|
43 |
return self::$instance;
|
44 |
}
|
45 |
|
46 |
-
|
47 |
public function initialize() {
|
48 |
if( $this->is_initialized ) {
|
49 |
return;
|
@@ -58,10 +62,12 @@ class Toolset_Upgrade_Controller {
|
|
58 |
|
59 |
public function __construct(
|
60 |
Toolset_Constants $constants_di = null,
|
61 |
-
Toolset_Upgrade_Command_Definition_Repository $command_definition_repository_di = null
|
|
|
62 |
) {
|
63 |
$this->constants = ( null === $constants_di ? new Toolset_Constants() : $constants_di );
|
64 |
$this->_command_definition_repository = $command_definition_repository_di;
|
|
|
65 |
}
|
66 |
|
67 |
|
@@ -150,18 +156,34 @@ class Toolset_Upgrade_Controller {
|
|
150 |
|
151 |
$command_definitions = $this->get_upgrade_commands();
|
152 |
|
153 |
-
foreach( $command_definitions as $command_definition ) {
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
// Ignore errors as we don't have a proper way to display any output from this yet.
|
156 |
try {
|
157 |
$command = $command_definition->get_command();
|
158 |
$command->run();
|
159 |
-
} catch(Throwable $e) {
|
160 |
// PHP 7
|
161 |
-
} catch(Exception $e) {
|
162 |
// PHP 5
|
163 |
}
|
164 |
}
|
|
|
|
|
165 |
}
|
166 |
}
|
167 |
|
@@ -183,4 +205,17 @@ class Toolset_Upgrade_Controller {
|
|
183 |
}
|
184 |
|
185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
}
|
35 |
private $_command_definition_repository;
|
36 |
|
37 |
|
38 |
+
/** @var Toolset_Upgrade_Executed_Commands|null */
|
39 |
+
private $_executed_commands;
|
40 |
+
|
41 |
+
|
42 |
public static function get_instance() {
|
43 |
if( null == self::$instance ) {
|
44 |
self::$instance = new self();
|
47 |
return self::$instance;
|
48 |
}
|
49 |
|
50 |
+
|
51 |
public function initialize() {
|
52 |
if( $this->is_initialized ) {
|
53 |
return;
|
62 |
|
63 |
public function __construct(
|
64 |
Toolset_Constants $constants_di = null,
|
65 |
+
Toolset_Upgrade_Command_Definition_Repository $command_definition_repository_di = null,
|
66 |
+
Toolset_Upgrade_Executed_Commands $executed_commands_di = null
|
67 |
) {
|
68 |
$this->constants = ( null === $constants_di ? new Toolset_Constants() : $constants_di );
|
69 |
$this->_command_definition_repository = $command_definition_repository_di;
|
70 |
+
$this->_executed_commands = $executed_commands_di;
|
71 |
}
|
72 |
|
73 |
|
156 |
|
157 |
$command_definitions = $this->get_upgrade_commands();
|
158 |
|
159 |
+
foreach ( $command_definitions as $command_definition ) {
|
160 |
+
|
161 |
+
if ( ! $command_definition->should_run( $from_version, $to_version ) ) {
|
162 |
+
continue;
|
163 |
+
}
|
164 |
+
|
165 |
+
if( $this->get_executed_commands()->was_executed( $command_definition->get_command_name() ) ) {
|
166 |
+
continue;
|
167 |
+
}
|
168 |
+
|
169 |
+
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
170 |
+
|
171 |
+
$command = $command_definition->get_command();
|
172 |
+
$command->run();
|
173 |
+
|
174 |
+
} else {
|
175 |
// Ignore errors as we don't have a proper way to display any output from this yet.
|
176 |
try {
|
177 |
$command = $command_definition->get_command();
|
178 |
$command->run();
|
179 |
+
} catch ( Throwable $e ) {
|
180 |
// PHP 7
|
181 |
+
} catch ( Exception $e ) {
|
182 |
// PHP 5
|
183 |
}
|
184 |
}
|
185 |
+
|
186 |
+
$this->get_executed_commands()->add_executed_command( $command_definition->get_command_name() );
|
187 |
}
|
188 |
}
|
189 |
|
205 |
}
|
206 |
|
207 |
|
208 |
+
/**
|
209 |
+
* @return Toolset_Upgrade_Executed_Commands
|
210 |
+
* @since 2.5.7
|
211 |
+
*/
|
212 |
+
public function get_executed_commands() {
|
213 |
+
if( null === $this->_executed_commands ) {
|
214 |
+
$this->_executed_commands = new Toolset_Upgrade_Executed_Commands();
|
215 |
+
}
|
216 |
+
|
217 |
+
return $this->_executed_commands;
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
}
|
vendor/toolset/toolset-common/inc/autoloaded/upgrade/executed_commands.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Manages the list of commands that have already been executed on the site.
|
5 |
+
*
|
6 |
+
* @since 2.5.7
|
7 |
+
*/
|
8 |
+
class Toolset_Upgrade_Executed_Commands {
|
9 |
+
|
10 |
+
|
11 |
+
/** The option is used to store an array of command names. */
|
12 |
+
const OPTION_NAME = 'toolset_executed_upgrade_commands';
|
13 |
+
|
14 |
+
|
15 |
+
/** @var string[] Cache for the array of executed command names. */
|
16 |
+
private $executed_commands;
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Check whether a particular command was executed.
|
21 |
+
*
|
22 |
+
* @param string $command_name
|
23 |
+
*
|
24 |
+
* @return bool
|
25 |
+
*/
|
26 |
+
public function was_executed( $command_name ) {
|
27 |
+
$executed_commands = $this->get_option();
|
28 |
+
return in_array( $command_name, $executed_commands, true );
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Store the information that a particular command has been executed.
|
34 |
+
*
|
35 |
+
* @param string $command_name
|
36 |
+
*/
|
37 |
+
public function add_executed_command( $command_name ) {
|
38 |
+
if( $this->was_executed( $command_name ) ) {
|
39 |
+
// Already added.
|
40 |
+
return;
|
41 |
+
}
|
42 |
+
|
43 |
+
$executed_commands = $this->get_option();
|
44 |
+
$executed_commands[] = $command_name;
|
45 |
+
$this->executed_commands[] = $command_name;
|
46 |
+
update_option( self::OPTION_NAME, $executed_commands, false );
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
private function get_option() {
|
51 |
+
if( null === $this->executed_commands ) {
|
52 |
+
$this->executed_commands = toolset_ensarr( get_option( self::OPTION_NAME ) );
|
53 |
+
}
|
54 |
+
|
55 |
+
return $this->executed_commands;
|
56 |
+
}
|
57 |
+
|
58 |
+
}
|
vendor/toolset/toolset-common/inc/controller/admin/notices.php
CHANGED
@@ -87,22 +87,31 @@ class Toolset_Controller_Admin_Notices {
|
|
87 |
|
88 |
// If Types is active and any of the Commercial Plugins is active, but site is not registered,
|
89 |
// then display a notice to force user to register Toolset.
|
90 |
-
if ( $this->is_types_active ) {
|
91 |
-
$
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
|
|
|
|
106 |
}
|
107 |
|
108 |
/**
|
@@ -140,13 +149,25 @@ class Toolset_Controller_Admin_Notices {
|
|
140 |
|| $current_screen_id == 'toolset_page_CRED_User_Forms' // User Forms
|
141 |
|| $current_screen_id == 'toolset_page_dd_layouts' // Layouts
|
142 |
|| $current_screen_id == 'toolset_page_dd_layout_CSS_JS' // Layouts CSS JS
|
|
|
|
|
|
|
143 |
// || $current_screen_id == 'toolset_page_toolset-settings' // Toolset Settings
|
144 |
// || $current_screen_id == 'toolset_page_toolset-export-import' // Toolset Settings
|
145 |
|
146 |
) {
|
147 |
$this->notices_compilation_introduction();
|
148 |
-
|
149 |
$this->notice_wpml_version_doesnt_support_m2m();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
}
|
152 |
|
@@ -198,6 +219,11 @@ class Toolset_Controller_Admin_Notices {
|
|
198 |
|
199 |
$this->notices_compilation_introduction();
|
200 |
$this->notice_wpml_version_doesnt_support_m2m();
|
|
|
|
|
|
|
|
|
|
|
201 |
}
|
202 |
|
203 |
/**
|
@@ -321,6 +347,42 @@ class Toolset_Controller_Admin_Notices {
|
|
321 |
return $notice;
|
322 |
}
|
323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
/**
|
325 |
* @return Toolset_Admin_Notice_Dismissible
|
326 |
*/
|
87 |
|
88 |
// If Types is active and any of the Commercial Plugins is active, but site is not registered,
|
89 |
// then display a notice to force user to register Toolset.
|
90 |
+
if ( $this->is_types_active && $this->is_commercial_active_but_not_registered() ) {
|
91 |
+
$this->commercial_plugin_installed_but_not_registered();
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
protected function is_commercial_active_but_not_registered( $abort_for_development_sites = true ) {
|
96 |
+
$repository_id = 'toolset';
|
97 |
+
|
98 |
+
if( $abort_for_development_sites && $this->is_development_environment() ) {
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
|
102 |
+
if( class_exists( 'WP_Installer' )
|
103 |
+
&& ! WP_Installer()->repository_has_valid_subscription( $repository_id )
|
104 |
+
&& (
|
105 |
+
$this->is_views_active
|
106 |
+
|| $this->is_access_active
|
107 |
+
|| $this->is_cred_active
|
108 |
+
|| $this->is_layouts_active
|
109 |
+
)
|
110 |
+
) {
|
111 |
+
return true;
|
112 |
}
|
113 |
+
|
114 |
+
return false;
|
115 |
}
|
116 |
|
117 |
/**
|
149 |
|| $current_screen_id == 'toolset_page_CRED_User_Forms' // User Forms
|
150 |
|| $current_screen_id == 'toolset_page_dd_layouts' // Layouts
|
151 |
|| $current_screen_id == 'toolset_page_dd_layout_CSS_JS' // Layouts CSS JS
|
152 |
+
|| $current_screen_id == 'toplevel_page_toolset-dashboard' // Dashboard
|
153 |
+
|| $current_screen_id == 'toolset_page_types-custom-fields' // m2m Custom Fields
|
154 |
+
|| $current_screen_id == 'toolset_page_types-relationships' // m2m Relationships
|
155 |
// || $current_screen_id == 'toolset_page_toolset-settings' // Toolset Settings
|
156 |
// || $current_screen_id == 'toolset_page_toolset-export-import' // Toolset Settings
|
157 |
|
158 |
) {
|
159 |
$this->notices_compilation_introduction();
|
|
|
160 |
$this->notice_wpml_version_doesnt_support_m2m();
|
161 |
+
|
162 |
+
if( $this->only_types_active() || $this->is_commercial_active_but_not_registered( false ) ) {
|
163 |
+
// notice: types free version support ends
|
164 |
+
if( $notice = $this->types_free_version_support_ends() ) {
|
165 |
+
if( $current_screen_id == 'toplevel_page_toolset-dashboard'
|
166 |
+
&& Toolset_Admin_Notices_Manager::is_notice_dismissed( $notice ) ) {
|
167 |
+
$this->types_free_version_support_ends_undissmisble();
|
168 |
+
}
|
169 |
+
};
|
170 |
+
}
|
171 |
}
|
172 |
}
|
173 |
|
219 |
|
220 |
$this->notices_compilation_introduction();
|
221 |
$this->notice_wpml_version_doesnt_support_m2m();
|
222 |
+
|
223 |
+
if( $this->only_types_active() || $this->is_commercial_active_but_not_registered( false ) ) {
|
224 |
+
// notice: types free version support ends
|
225 |
+
$this->types_free_version_support_ends();
|
226 |
+
}
|
227 |
}
|
228 |
|
229 |
/**
|
347 |
return $notice;
|
348 |
}
|
349 |
|
350 |
+
|
351 |
+
/**
|
352 |
+
* @return Toolset_Admin_Notice_Dismissible
|
353 |
+
*/
|
354 |
+
protected function types_free_version_support_ends() {
|
355 |
+
if( class_exists( 'WP_Installer' )
|
356 |
+
&& WP_Installer()->repository_has_valid_subscription( 'toolset' ) ) {
|
357 |
+
return false;
|
358 |
+
}
|
359 |
+
|
360 |
+
$notice = new Toolset_Admin_Notice_Dismissible( 'types_free_version_support_ends', '', $this->constants );
|
361 |
+
$notice->set_content( $this->tpl_path . '/types-free-version-ends.phtml' );
|
362 |
+
Toolset_Admin_Notices_Manager::add_notice( $notice );
|
363 |
+
|
364 |
+
return $notice;
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* @return Toolset_Admin_Notice_Undismissible
|
369 |
+
*/
|
370 |
+
protected function types_free_version_support_ends_undissmisble() {
|
371 |
+
if( class_exists( 'WP_Installer' )
|
372 |
+
&& WP_Installer()->repository_has_valid_subscription( 'toolset' ) ) {
|
373 |
+
return false;
|
374 |
+
}
|
375 |
+
|
376 |
+
$notice = new Toolset_Admin_Notice_Undismissible( 'types_free_version_support_ends_undissmisble', '', $this->constants );
|
377 |
+
$notice->set_template_path( $this->tpl_path . '/types-move-to-toolset.phtml' );
|
378 |
+
$notice->set_content( $this->tpl_path . '/types-free-version-ends.phtml' );
|
379 |
+
Toolset_Admin_Notices_Manager::add_notice( $notice );
|
380 |
+
|
381 |
+
return $notice;
|
382 |
+
}
|
383 |
+
|
384 |
+
|
385 |
+
|
386 |
/**
|
387 |
* @return Toolset_Admin_Notice_Dismissible
|
388 |
*/
|
vendor/toolset/toolset-common/inc/m2m/association_query.php
CHANGED
@@ -37,6 +37,7 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
|
|
37 |
const QUERY_LIMIT = 'limit';
|
38 |
const QUERY_SELECT_FIELDS = 'select_fields';
|
39 |
const QUERY_RELATIONSHIP_SLUG = 'relationship_slug';
|
|
|
40 |
const QUERY_PARENT_ID = 'parent_id';
|
41 |
const QUERY_CHILD_ID = 'child_id';
|
42 |
const QUERY_HAS_FIELDS = 'has_fields';
|
@@ -45,6 +46,7 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
|
|
45 |
const QUERY_CHILD_DOMAIN = 'child_domain';
|
46 |
const QUERY_CHILD_QUERY = 'child_query';
|
47 |
const QUERY_LANGUAGE = 'language';
|
|
|
48 |
|
49 |
const RETURN_ASSOCIATION_IDS = 'association_ids';
|
50 |
const RETURN_ASSOCIATIONS = 'associations';
|
@@ -72,6 +74,7 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
|
|
72 |
|
73 |
// Default value of these needs to be null
|
74 |
$this->parse_query_arg( $query, self::QUERY_RELATIONSHIP_SLUG, 'strval' );
|
|
|
75 |
$this->parse_query_arg( $query, self::QUERY_PARENT_ID, 'absint' );
|
76 |
$this->parse_query_arg( $query, self::QUERY_CHILD_ID, 'absint' );
|
77 |
$this->parse_query_arg( $query, self::QUERY_LIMIT, 'absint' );
|
@@ -82,7 +85,7 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
|
|
82 |
$this->parse_query_arg( $query, self::QUERY_PARENT_QUERY, null ); // todo sanitize?
|
83 |
$this->parse_query_arg( $query, self::QUERY_CHILD_DOMAIN, null, null, array( Toolset_Field_Utils::DOMAIN_POSTS ) );
|
84 |
$this->parse_query_arg( $query, self::QUERY_CHILD_QUERY, null ); // todo sanitize?
|
85 |
-
$this->parse_query_arg( $query, self::
|
86 |
}
|
87 |
|
88 |
|
@@ -168,6 +171,15 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
|
|
168 |
);
|
169 |
}
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
if( $this->has_query_var( self::QUERY_PARENT_ID ) ) {
|
172 |
$where_clauses[] = $wpdb->prepare(
|
173 |
"parent_id = %d",
|
@@ -177,6 +189,17 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
|
|
177 |
$has_language_specific_query = true;
|
178 |
}
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
if( $this->has_query_var( self::QUERY_CHILD_ID ) ) {
|
181 |
$where_clauses[] = $wpdb->prepare(
|
182 |
"child_id = %d",
|
@@ -759,14 +782,14 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
|
|
759 |
add_filter( 'posts_pre_query', $dont_query_anyting, $very_late );
|
760 |
|
761 |
// Avoid WPML messing with the results because we already know in which language we want to query
|
762 |
-
|
763 |
-
do_action( 'wpml_switch_language', 'all' );
|
764 |
|
765 |
// This will immediately run the query.
|
766 |
new WP_Query( $query_args );
|
767 |
|
768 |
// Switch back to the current language so that we don't break anything else down the road.
|
769 |
-
do_action( 'wpml_switch_language', $current_language );
|
770 |
|
771 |
// Clean up
|
772 |
remove_filter( 'posts_clauses', $catch_clauses, $very_late );
|
37 |
const QUERY_LIMIT = 'limit';
|
38 |
const QUERY_SELECT_FIELDS = 'select_fields';
|
39 |
const QUERY_RELATIONSHIP_SLUG = 'relationship_slug';
|
40 |
+
const QUERY_RELATIONSHIP_ID = 'relationship_id';
|
41 |
const QUERY_PARENT_ID = 'parent_id';
|
42 |
const QUERY_CHILD_ID = 'child_id';
|
43 |
const QUERY_HAS_FIELDS = 'has_fields';
|
46 |
const QUERY_CHILD_DOMAIN = 'child_domain';
|
47 |
const QUERY_CHILD_QUERY = 'child_query';
|
48 |
const QUERY_LANGUAGE = 'language';
|
49 |
+
const QUERY_HAS_TRASHED_POSTS = 'has_trashed_posts';
|
50 |
|
51 |
const RETURN_ASSOCIATION_IDS = 'association_ids';
|
52 |
const RETURN_ASSOCIATIONS = 'associations';
|
74 |
|
75 |
// Default value of these needs to be null
|
76 |
$this->parse_query_arg( $query, self::QUERY_RELATIONSHIP_SLUG, 'strval' );
|
77 |
+
$this->parse_query_arg( $query, self::QUERY_RELATIONSHIP_ID, 'absint' );
|
78 |
$this->parse_query_arg( $query, self::QUERY_PARENT_ID, 'absint' );
|
79 |
$this->parse_query_arg( $query, self::QUERY_CHILD_ID, 'absint' );
|
80 |
$this->parse_query_arg( $query, self::QUERY_LIMIT, 'absint' );
|
85 |
$this->parse_query_arg( $query, self::QUERY_PARENT_QUERY, null ); // todo sanitize?
|
86 |
$this->parse_query_arg( $query, self::QUERY_CHILD_DOMAIN, null, null, array( Toolset_Field_Utils::DOMAIN_POSTS ) );
|
87 |
$this->parse_query_arg( $query, self::QUERY_CHILD_QUERY, null ); // todo sanitize?
|
88 |
+
$this->parse_query_arg( $query, self::QUERY_HAS_TRASHED_POSTS, 'boolval' );
|
89 |
}
|
90 |
|
91 |
|
171 |
);
|
172 |
}
|
173 |
|
174 |
+
if( $this->has_query_var( self::QUERY_RELATIONSHIP_ID ) ) {
|
175 |
+
$relationship_id = $this->get_query_var( self::QUERY_RELATIONSHIP_ID );
|
176 |
+
|
177 |
+
$where_clauses[] = $wpdb->prepare(
|
178 |
+
"association.relationship_id = %d",
|
179 |
+
$relationship_id
|
180 |
+
);
|
181 |
+
}
|
182 |
+
|
183 |
if( $this->has_query_var( self::QUERY_PARENT_ID ) ) {
|
184 |
$where_clauses[] = $wpdb->prepare(
|
185 |
"parent_id = %d",
|
189 |
$has_language_specific_query = true;
|
190 |
}
|
191 |
|
192 |
+
if( $this->has_query_var( self::QUERY_HAS_TRASHED_POSTS ) ) {
|
193 |
+
// Note: This is not very nice from the performance point of view, but it's only a hotfix.
|
194 |
+
// The query class will go through a refactoring very soon.
|
195 |
+
$join_clauses[] = " JOIN {$wpdb->posts} as wp_parent_post ON ( wp_parent_post.ID = association.parent_id ) ";
|
196 |
+
$join_clauses[] = " JOIN {$wpdb->posts} as wp_child_post ON ( wp_child_post.ID = association.child_id ) ";
|
197 |
+
|
198 |
+
$operator = ( $this->get_query_var( self::QUERY_HAS_TRASHED_POSTS ) ? '=' : '!=' );
|
199 |
+
$where_clauses[] = "wp_parent_post.post_status $operator 'trash'";
|
200 |
+
$where_clauses[] = "wp_child_post.post_status $operator 'trash'";
|
201 |
+
}
|
202 |
+
|
203 |
if( $this->has_query_var( self::QUERY_CHILD_ID ) ) {
|
204 |
$where_clauses[] = $wpdb->prepare(
|
205 |
"child_id = %d",
|
782 |
add_filter( 'posts_pre_query', $dont_query_anyting, $very_late );
|
783 |
|
784 |
// Avoid WPML messing with the results because we already know in which language we want to query
|
785 |
+
//$current_language = apply_filters( 'wpml_current_language', '' );
|
786 |
+
//do_action( 'wpml_switch_language', 'all' );
|
787 |
|
788 |
// This will immediately run the query.
|
789 |
new WP_Query( $query_args );
|
790 |
|
791 |
// Switch back to the current language so that we don't break anything else down the road.
|
792 |
+
//do_action( 'wpml_switch_language', $current_language );
|
793 |
|
794 |
// Clean up
|
795 |
remove_filter( 'posts_clauses', $catch_clauses, $very_late );
|
vendor/toolset/toolset-common/inc/m2m/association_repository.php
CHANGED
@@ -108,7 +108,8 @@ class Toolset_Association_Repository {
|
|
108 |
return null;
|
109 |
}
|
110 |
|
111 |
-
$relationship_definition = Toolset_Relationship_Definition_Repository::get_instance()
|
|
|
112 |
|
113 |
if ( null === $relationship_definition ) {
|
114 |
return null;
|
@@ -221,7 +222,8 @@ class Toolset_Association_Repository {
|
|
221 |
}
|
222 |
}
|
223 |
|
224 |
-
|
|
|
225 |
}
|
226 |
|
227 |
|
@@ -255,4 +257,4 @@ class Toolset_Association_Repository {
|
|
255 |
|
256 |
}
|
257 |
|
258 |
-
}
|
108 |
return null;
|
109 |
}
|
110 |
|
111 |
+
$relationship_definition = Toolset_Relationship_Definition_Repository::get_instance()
|
112 |
+
->get_definition_by_row_id( $row->relationship_id );
|
113 |
|
114 |
if ( null === $relationship_definition ) {
|
115 |
return null;
|
222 |
}
|
223 |
}
|
224 |
|
225 |
+
/** @var Toolset_Relationship_Definition $relationship_definition */
|
226 |
+
return $this->get_database_operations()->delete_associations_by_relationship( $relationship_definition->get_row_id() );
|
227 |
}
|
228 |
|
229 |
|
257 |
|
258 |
}
|
259 |
|
260 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/autoload_classmap.php
CHANGED
@@ -3,8 +3,10 @@
|
|
3 |
return array(
|
4 |
'IToolset_Association' => dirname( __FILE__ ) . '/i_association.php',
|
5 |
'IToolset_Potential_Association_Query' => dirname( __FILE__ ) . '/potential_association/query_interface.php',
|
6 |
-
'
|
|
|
7 |
'IToolset_Relationship_Origin' => dirname( __FILE__ ) . '/origin/interface.php',
|
|
|
8 |
'IToolset_Relationship_Query_Condition' => dirname( __FILE__ ) . '/relationship_query/condition/i_condition.php',
|
9 |
'IToolset_Relationship_Role' => dirname( __FILE__ ) . '/relationship_role/interface.php',
|
10 |
'IToolset_Relationship_Role_Parent_Child' => dirname( __FILE__ ) . '/relationship_role/parent_child_interface.php',
|
@@ -18,6 +20,7 @@ return array(
|
|
18 |
'Toolset_Potential_Association_Query_Posts' => dirname( __FILE__ ) . '/potential_association/query_posts.php',
|
19 |
'Toolset_Relationship_Cardinality' => dirname( __FILE__ ) . '/cardinality.php',
|
20 |
'Toolset_Relationship_Controller' => dirname( __FILE__ ) . '/controller.php',
|
|
|
21 |
'Toolset_Relationship_Database_Operations' => dirname( __FILE__ ) . '/database/operations.php',
|
22 |
'Toolset_Relationship_Database_Unique_Table_Alias' => dirname( __FILE__ ) . '/database/unique_table_alias.php',
|
23 |
'Toolset_Relationship_Definition' => dirname( __FILE__ ) . '/definition/definition.php',
|
@@ -37,10 +40,15 @@ return array(
|
|
37 |
'Toolset_Relationship_Origin_Wizard' => dirname( __FILE__ ) . '/origin/wizard.php',
|
38 |
'Toolset_Relationship_Query_Base' => dirname( __FILE__ ) . '/query_base.php',
|
39 |
'Toolset_Relationship_Query_Cache' => dirname( __FILE__ ) . '/query_cache.php',
|
|
|
|
|
|
|
|
|
40 |
'Toolset_Relationship_Query_Condition_And' => dirname( __FILE__ ) . '/relationship_query/condition/and.php',
|
41 |
'Toolset_Relationship_Query_Condition' => dirname( __FILE__ ) . '/relationship_query/condition/abstract.php',
|
42 |
'Toolset_Relationship_Query_Condition_Factory' => dirname( __FILE__ ) . '/relationship_query/condition_factory.php',
|
43 |
'Toolset_Relationship_Query_Condition_Has_Active_Types' => dirname( __FILE__ ) . '/relationship_query/condition/has_active_types.php',
|
|
|
44 |
'Toolset_Relationship_Query_Condition_Has_Domain' => dirname( __FILE__ ) . '/relationship_query/condition/has_domain.php',
|
45 |
'Toolset_Relationship_Query_Condition_Is_Active' => dirname( __FILE__ ) . '/relationship_query/condition/is_active.php',
|
46 |
'Toolset_Relationship_Query_Condition_Is_Boolean_Flag' => dirname( __FILE__ ) . '/relationship_query/condition/is_boolean_flag.php',
|
@@ -48,6 +56,7 @@ return array(
|
|
48 |
'Toolset_Relationship_Query_Condition_Operator' => dirname( __FILE__ ) . '/relationship_query/condition/operator.php',
|
49 |
'Toolset_Relationship_Query_Condition_Or' => dirname( __FILE__ ) . '/relationship_query/condition/or.php',
|
50 |
'Toolset_Relationship_Query_Condition_Origin' => dirname( __FILE__ ) . '/relationship_query/condition/origin.php',
|
|
|
51 |
'Toolset_Relationship_Query_Condition_Type' => dirname( __FILE__ ) . '/relationship_query/condition/type.php',
|
52 |
'Toolset_Relationship_Query' => dirname( __FILE__ ) . '/relationship_query/relationship_query.php',
|
53 |
'Toolset_Relationship_Query_Factory' => dirname( __FILE__ ) . '/query_factory.php',
|
3 |
return array(
|
4 |
'IToolset_Association' => dirname( __FILE__ ) . '/i_association.php',
|
5 |
'IToolset_Potential_Association_Query' => dirname( __FILE__ ) . '/potential_association/query_interface.php',
|
6 |
+
'IToolset_Relationship_Database_Issue' => dirname( __FILE__ ) . '/database/issue/interface.php',
|
7 |
+
'IToolset_Relationship_Definition' => dirname( __FILE__ ) . '/definition/interface.php',
|
8 |
'IToolset_Relationship_Origin' => dirname( __FILE__ ) . '/origin/interface.php',
|
9 |
+
'IToolset_Relationship_Query_Cardinality_Match' => dirname( __FILE__ ) . '/relationship_query/cardinality_match/interface.php',
|
10 |
'IToolset_Relationship_Query_Condition' => dirname( __FILE__ ) . '/relationship_query/condition/i_condition.php',
|
11 |
'IToolset_Relationship_Role' => dirname( __FILE__ ) . '/relationship_role/interface.php',
|
12 |
'IToolset_Relationship_Role_Parent_Child' => dirname( __FILE__ ) . '/relationship_role/parent_child_interface.php',
|
20 |
'Toolset_Potential_Association_Query_Posts' => dirname( __FILE__ ) . '/potential_association/query_posts.php',
|
21 |
'Toolset_Relationship_Cardinality' => dirname( __FILE__ ) . '/cardinality.php',
|
22 |
'Toolset_Relationship_Controller' => dirname( __FILE__ ) . '/controller.php',
|
23 |
+
'Toolset_Relationship_Database_Issue_Missing_Element' => dirname( __FILE__ ) . '/database/issue/missing_element.php',
|
24 |
'Toolset_Relationship_Database_Operations' => dirname( __FILE__ ) . '/database/operations.php',
|
25 |
'Toolset_Relationship_Database_Unique_Table_Alias' => dirname( __FILE__ ) . '/database/unique_table_alias.php',
|
26 |
'Toolset_Relationship_Definition' => dirname( __FILE__ ) . '/definition/definition.php',
|
40 |
'Toolset_Relationship_Origin_Wizard' => dirname( __FILE__ ) . '/origin/wizard.php',
|
41 |
'Toolset_Relationship_Query_Base' => dirname( __FILE__ ) . '/query_base.php',
|
42 |
'Toolset_Relationship_Query_Cache' => dirname( __FILE__ ) . '/query_cache.php',
|
43 |
+
'Toolset_Relationship_Query_Cardinality_Match_Conjunction' => dirname( __FILE__ ) . '/relationship_query/cardinality_match/conjunction.php',
|
44 |
+
'Toolset_Relationship_Query_Cardinality_Match_Factory' => dirname( __FILE__ ) . '/relationship_query/cardinality_match/factory.php',
|
45 |
+
'Toolset_Relationship_Query_Cardinality_Match_Operators' => dirname( __FILE__ ) . '/relationship_query/cardinality_match/operators.php',
|
46 |
+
'Toolset_Relationship_Query_Cardinality_Match_Single' => dirname( __FILE__ ) . '/relationship_query/cardinality_match/single.php',
|
47 |
'Toolset_Relationship_Query_Condition_And' => dirname( __FILE__ ) . '/relationship_query/condition/and.php',
|
48 |
'Toolset_Relationship_Query_Condition' => dirname( __FILE__ ) . '/relationship_query/condition/abstract.php',
|
49 |
'Toolset_Relationship_Query_Condition_Factory' => dirname( __FILE__ ) . '/relationship_query/condition_factory.php',
|
50 |
'Toolset_Relationship_Query_Condition_Has_Active_Types' => dirname( __FILE__ ) . '/relationship_query/condition/has_active_types.php',
|
51 |
+
'Toolset_Relationship_Query_Condition_Has_Cardinality' => dirname( __FILE__ ) . '/relationship_query/condition/has_cardinality.php',
|
52 |
'Toolset_Relationship_Query_Condition_Has_Domain' => dirname( __FILE__ ) . '/relationship_query/condition/has_domain.php',
|
53 |
'Toolset_Relationship_Query_Condition_Is_Active' => dirname( __FILE__ ) . '/relationship_query/condition/is_active.php',
|
54 |
'Toolset_Relationship_Query_Condition_Is_Boolean_Flag' => dirname( __FILE__ ) . '/relationship_query/condition/is_boolean_flag.php',
|
56 |
'Toolset_Relationship_Query_Condition_Operator' => dirname( __FILE__ ) . '/relationship_query/condition/operator.php',
|
57 |
'Toolset_Relationship_Query_Condition_Or' => dirname( __FILE__ ) . '/relationship_query/condition/or.php',
|
58 |
'Toolset_Relationship_Query_Condition_Origin' => dirname( __FILE__ ) . '/relationship_query/condition/origin.php',
|
59 |
+
'Toolset_Relationship_Query_Condition_Tautology' => dirname( __FILE__ ) . '/relationship_query/condition/tautology.php',
|
60 |
'Toolset_Relationship_Query_Condition_Type' => dirname( __FILE__ ) . '/relationship_query/condition/type.php',
|
61 |
'Toolset_Relationship_Query' => dirname( __FILE__ ) . '/relationship_query/relationship_query.php',
|
62 |
'Toolset_Relationship_Query_Factory' => dirname( __FILE__ ) . '/query_factory.php',
|
vendor/toolset/toolset-common/inc/m2m/controller.php
CHANGED
@@ -46,7 +46,7 @@ class Toolset_Relationship_Controller {
|
|
46 |
/**
|
47 |
* We need WPML to fire certain actions when it updates its icl_translations table.
|
48 |
*/
|
49 |
-
const MINIMAL_WPML_VERSION = '3.
|
50 |
|
51 |
|
52 |
private $is_autoloader_initialized = false;
|
@@ -181,6 +181,7 @@ class Toolset_Relationship_Controller {
|
|
181 |
*/
|
182 |
add_action( 'toolset_do_m2m_full_init', array( $this, 'initialize_full' ) );
|
183 |
|
|
|
184 |
// If the m2m feature is not enabled, nothing else should happen now.
|
185 |
if( ! $this->is_m2m_enabled() ) {
|
186 |
return;
|
@@ -201,7 +202,7 @@ class Toolset_Relationship_Controller {
|
|
201 |
* @since m2m
|
202 |
*/
|
203 |
if( true == apply_filters( 'toolset_use_default_m2m_wpml_interoperability_manager', true ) ) {
|
204 |
-
add_action( 'wpml_translation_update', array( $this, 'on_wpml_translation_update' ), 10 );
|
205 |
}
|
206 |
|
207 |
/**
|
@@ -215,6 +216,23 @@ class Toolset_Relationship_Controller {
|
|
215 |
* @since m2m
|
216 |
*/
|
217 |
add_filter( 'toolset_relationship_query', array( $this, 'on_toolset_relationship_query' ), 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
}
|
219 |
|
220 |
|
@@ -246,6 +264,31 @@ class Toolset_Relationship_Controller {
|
|
246 |
}
|
247 |
|
248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
/**
|
250 |
* Register all Toolset_Relationship_* classes in the Toolset autoloader.
|
251 |
*
|
@@ -344,4 +387,20 @@ class Toolset_Relationship_Controller {
|
|
344 |
public function force_autoloader_initialization() {
|
345 |
$this->initialize_autoloader();
|
346 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
}
|
46 |
/**
|
47 |
* We need WPML to fire certain actions when it updates its icl_translations table.
|
48 |
*/
|
49 |
+
const MINIMAL_WPML_VERSION = '3.9.0';
|
50 |
|
51 |
|
52 |
private $is_autoloader_initialized = false;
|
181 |
*/
|
182 |
add_action( 'toolset_do_m2m_full_init', array( $this, 'initialize_full' ) );
|
183 |
|
184 |
+
|
185 |
// If the m2m feature is not enabled, nothing else should happen now.
|
186 |
if( ! $this->is_m2m_enabled() ) {
|
187 |
return;
|
202 |
* @since m2m
|
203 |
*/
|
204 |
if( true == apply_filters( 'toolset_use_default_m2m_wpml_interoperability_manager', true ) ) {
|
205 |
+
// add_action( 'wpml_translation_update', array( $this, 'on_wpml_translation_update' ), 10 );
|
206 |
}
|
207 |
|
208 |
/**
|
216 |
* @since m2m
|
217 |
*/
|
218 |
add_filter( 'toolset_relationship_query', array( $this, 'on_toolset_relationship_query' ), 10, 2 );
|
219 |
+
|
220 |
+
/**
|
221 |
+
* On change of cpt slug.
|
222 |
+
*
|
223 |
+
* @since 2.5.6
|
224 |
+
*/
|
225 |
+
add_action( 'wpcf_post_type_renamed', array( $this, 'on_types_cpt_rename_slug' ), 10, 2 );
|
226 |
+
|
227 |
+
/**
|
228 |
+
* toolset_report_m2m_integrity_issue
|
229 |
+
*
|
230 |
+
* Allow for reporting that there is some sort of data corruption in the database.
|
231 |
+
*
|
232 |
+
* @param IToolset_Relationship_Database_Issue $issue
|
233 |
+
* @since 2.5.6
|
234 |
+
*/
|
235 |
+
add_action( 'toolset_report_m2m_integrity_issue', array( $this, 'report_integrity_issue' ) );
|
236 |
}
|
237 |
|
238 |
|
264 |
}
|
265 |
|
266 |
|
267 |
+
/**
|
268 |
+
* Hooked into the wpcf_post_type_renamed action.
|
269 |
+
* To update the slug in the relationship definition when the cpt slug is changed on the cpt edit page.
|
270 |
+
*
|
271 |
+
* @param $new_slug
|
272 |
+
* @param $old_slug
|
273 |
+
* @since 2.5.6
|
274 |
+
*/
|
275 |
+
public function on_types_cpt_rename_slug( $new_slug, $old_slug ) {
|
276 |
+
if( $new_slug === $old_slug ) {
|
277 |
+
// no change
|
278 |
+
return;
|
279 |
+
}
|
280 |
+
|
281 |
+
$this->initialize_full();
|
282 |
+
|
283 |
+
$database = new Toolset_Relationship_Database_Operations();
|
284 |
+
$result = $database->update_type_on_type_sets( $new_slug, $old_slug );
|
285 |
+
|
286 |
+
if( $result->is_error() ) {
|
287 |
+
error_log( $result->get_message() );
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
+
|
292 |
/**
|
293 |
* Register all Toolset_Relationship_* classes in the Toolset autoloader.
|
294 |
*
|
387 |
public function force_autoloader_initialization() {
|
388 |
$this->initialize_autoloader();
|
389 |
}
|
390 |
+
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Handle the toolset_report_m2m_integrity_issue action by passing it over to a dedicated class.
|
394 |
+
*
|
395 |
+
* @param IToolset_Relationship_Database_Issue $issue
|
396 |
+
*
|
397 |
+
* @since 2.5.6
|
398 |
+
*/
|
399 |
+
public function report_integrity_issue( $issue ) {
|
400 |
+
$this->initialize_full();
|
401 |
+
|
402 |
+
if( $issue instanceof IToolset_Relationship_Database_Issue ) {
|
403 |
+
$issue->handle();
|
404 |
+
}
|
405 |
+
}
|
406 |
}
|
vendor/toolset/toolset-common/inc/m2m/database/issue/interface.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
interface IToolset_Relationship_Database_Issue {
|
4 |
+
|
5 |
+
public function handle();
|
6 |
+
|
7 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/database/issue/missing_element.php
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Handle a missing element that might be involved in a number of associations.
|
5 |
+
*
|
6 |
+
* This will delete all affected associations and also intermediary posts of such associations.
|
7 |
+
* If invalid parameters are provided, the method does nothing.
|
8 |
+
*
|
9 |
+
* @since 2.5.6
|
10 |
+
*/
|
11 |
+
class Toolset_Relationship_Database_Issue_Missing_Element implements IToolset_Relationship_Database_Issue {
|
12 |
+
|
13 |
+
|
14 |
+
/** @var wpdb */
|
15 |
+
private $wpdb;
|
16 |
+
|
17 |
+
/** @var Toolset_Relationship_Table_Name */
|
18 |
+
private $table_name;
|
19 |
+
|
20 |
+
/** @var Toolset_Relationship_Query_Factory */
|
21 |
+
private $query_factory;
|
22 |
+
|
23 |
+
/** @var Toolset_Relationship_Database_Operations */
|
24 |
+
private $database_operations;
|
25 |
+
|
26 |
+
/** @var string */
|
27 |
+
private $domain;
|
28 |
+
|
29 |
+
/** @var int */
|
30 |
+
private $element_id;
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Toolset_Relationship_Database_Issue_Missing_Element constructor.
|
35 |
+
*
|
36 |
+
* @param string $domain Element domain.
|
37 |
+
* @param int $element_id ID of the missing element.
|
38 |
+
* @param wpdb|null $wpdb_di
|
39 |
+
* @param Toolset_Relationship_Table_Name|null $table_name_di
|
40 |
+
* @param Toolset_Relationship_Query_Factory|null $query_factory_di
|
41 |
+
* @param Toolset_Relationship_Database_Operations|null $database_operations_di
|
42 |
+
*/
|
43 |
+
public function __construct(
|
44 |
+
$domain, $element_id,
|
45 |
+
wpdb $wpdb_di = null, Toolset_Relationship_Table_Name $table_name_di = null,
|
46 |
+
Toolset_Relationship_Query_Factory $query_factory_di = null,
|
47 |
+
Toolset_Relationship_Database_Operations $database_operations_di = null
|
48 |
+
) {
|
49 |
+
if( null === $wpdb_di ) {
|
50 |
+
global $wpdb;
|
51 |
+
$this->wpdb = $wpdb;
|
52 |
+
} else {
|
53 |
+
$this->wpdb = $wpdb_di;
|
54 |
+
}
|
55 |
+
|
56 |
+
$this->table_name = (
|
57 |
+
null === $table_name_di
|
58 |
+
? new Toolset_Relationship_Table_Name()
|
59 |
+
: $table_name_di
|
60 |
+
);
|
61 |
+
|
62 |
+
$this->query_factory = (
|
63 |
+
null === $query_factory_di
|
64 |
+
? new Toolset_Relationship_Query_Factory()
|
65 |
+
: $query_factory_di
|
66 |
+
);
|
67 |
+
|
68 |
+
$this->database_operations = (
|
69 |
+
null === $database_operations_di
|
70 |
+
? new Toolset_Relationship_Database_Operations()
|
71 |
+
: $database_operations_di
|
72 |
+
);
|
73 |
+
|
74 |
+
if(
|
75 |
+
! in_array( $domain, Toolset_Element_Domain::all(), true )
|
76 |
+
|| ! Toolset_Utils::is_natural_numeric( $element_id )
|
77 |
+
) {
|
78 |
+
throw new InvalidArgumentException();
|
79 |
+
}
|
80 |
+
|
81 |
+
$this->domain = $domain;
|
82 |
+
$this->element_id = $element_id;
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Handle the issue.
|
88 |
+
*/
|
89 |
+
public function handle() {
|
90 |
+
|
91 |
+
// Gather in relationships that have the correct domain in one and in the other role.
|
92 |
+
$results = array();
|
93 |
+
foreach( Toolset_Relationship_Role::parent_child() as $role ) {
|
94 |
+
$query = $this->query_factory->relationships_v2();
|
95 |
+
$relationships = $query->do_not_add_default_conditions()
|
96 |
+
->add( $query->has_domain( $this->domain, $role ) )
|
97 |
+
->get_results();
|
98 |
+
|
99 |
+
$results[ $role->get_name() ] = $relationships;
|
100 |
+
}
|
101 |
+
|
102 |
+
// Delete what needs to be deleted. Note that we might be performing a lot of MySQL queries here,
|
103 |
+
// but it's an one-time thing, so I prefer a cleaner, safer implementation over performance.
|
104 |
+
foreach( $results as $role_name => $relationships ) {
|
105 |
+
/** @var Toolset_Relationship_Definition $relationship */
|
106 |
+
foreach( $relationships as $relationship ) {
|
107 |
+
$this->delete_intermediary_posts( $relationship, $role_name, $this->element_id );
|
108 |
+
$this->delete_associations( $relationship, $role_name, $this->element_id );
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Delete intermediary posts from all associations in a given relationship that have
|
116 |
+
* the given element in the given role.
|
117 |
+
*
|
118 |
+
* @param Toolset_Relationship_Definition $relationship
|
119 |
+
* @param string $element_role_name
|
120 |
+
* @param int $element_id
|
121 |
+
*/
|
122 |
+
private function delete_intermediary_posts( $relationship, $element_role_name, $element_id ) {
|
123 |
+
$element_id_column = $this->database_operations->role_to_column( $element_role_name, Toolset_Relationship_Database_Operations::COLUMN_ID );
|
124 |
+
|
125 |
+
$intermediary_post_ids = $this->wpdb->get_col(
|
126 |
+
$this->wpdb->prepare(
|
127 |
+
"SELECT intermediary_id FROM {$this->table_name->association_table()}
|
128 |
+
WHERE relationship_id = %d AND {$element_id_column} = %d",
|
129 |
+
$relationship->get_row_id(),
|
130 |
+
$element_id
|
131 |
+
)
|
132 |
+
);
|
133 |
+
|
134 |
+
foreach( $intermediary_post_ids as $post_id ) {
|
135 |
+
wp_delete_post( $post_id );
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Delete all associations of a given relationships that have the given element in the given role.
|
142 |
+
*
|
143 |
+
* @param Toolset_Relationship_Definition $relationship
|
144 |
+
* @param string $element_role_name
|
145 |
+
* @param int $element_id
|
146 |
+
*/
|
147 |
+
private function delete_associations( $relationship, $element_role_name, $element_id ) {
|
148 |
+
$element_id_column = $this->database_operations->role_to_column( $element_role_name, Toolset_Relationship_Database_Operations::COLUMN_ID );
|
149 |
+
|
150 |
+
$this->wpdb->delete(
|
151 |
+
$this->table_name->association_table(),
|
152 |
+
array(
|
153 |
+
'relationship_id' => $relationship->get_row_id(),
|
154 |
+
$element_id_column => $element_id
|
155 |
+
),
|
156 |
+
array( '%d', '%d' )
|
157 |
+
);
|
158 |
+
}
|
159 |
+
|
160 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/database/operations.php
CHANGED
@@ -120,6 +120,8 @@ class Toolset_Relationship_Database_Operations {
|
|
120 |
// Columns in the relationships table
|
121 |
const COLUMN_DOMAIN = '_domain';
|
122 |
const COLUMN_TYPES = '_types';
|
|
|
|
|
123 |
|
124 |
|
125 |
/**
|
@@ -139,6 +141,11 @@ class Toolset_Relationship_Database_Operations {
|
|
139 |
$role_name = $role;
|
140 |
}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
142 |
return $role_name . $column;
|
143 |
}
|
144 |
|
@@ -335,24 +342,25 @@ class Toolset_Relationship_Database_Operations {
|
|
335 |
* The usage of this method is strictly limited to the m2m API, always change the slug via
|
336 |
* Toolset_Relationship_Definition_Repository::change_definition_slug().
|
337 |
*
|
338 |
-
* @param
|
339 |
-
* @param
|
340 |
*
|
341 |
* @return Toolset_Result
|
342 |
*
|
343 |
* @since m2m
|
344 |
*/
|
345 |
-
public
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
array( '
|
354 |
-
'
|
355 |
-
'%
|
|
|
356 |
);
|
357 |
|
358 |
$is_success = ( false !== $rows_updated );
|
@@ -361,12 +369,12 @@ class Toolset_Relationship_Database_Operations {
|
|
361 |
$is_success
|
362 |
? sprintf(
|
363 |
__( 'The association table has been updated with the new relationship slug "%s". %d rows have been updated.', 'wpcf' ),
|
364 |
-
$
|
365 |
$rows_updated
|
366 |
)
|
367 |
: sprintf(
|
368 |
__( 'There has been an error when updating the assocation table with the new relationship slug: %s', 'wpcf' ),
|
369 |
-
$wpdb->last_error
|
370 |
)
|
371 |
);
|
372 |
|
@@ -377,18 +385,18 @@ class Toolset_Relationship_Database_Operations {
|
|
377 |
/**
|
378 |
* Delete all associations from a given relationship.
|
379 |
*
|
380 |
-
* @param
|
381 |
*
|
382 |
* @return Toolset_Result_Updated
|
383 |
*/
|
384 |
-
public function delete_associations_by_relationship( $
|
385 |
|
386 |
$associations_table = $this->table_name->association_table();
|
387 |
|
388 |
$result = $this->wpdb->delete(
|
389 |
$associations_table,
|
390 |
-
array( '
|
391 |
-
array( '%
|
392 |
);
|
393 |
|
394 |
if( false === $result ) {
|
@@ -399,7 +407,7 @@ class Toolset_Relationship_Database_Operations {
|
|
399 |
} else {
|
400 |
return new Toolset_Result_Updated(
|
401 |
true, $result,
|
402 |
-
sprintf( __( 'Deleted all associations for the relationship
|
403 |
);
|
404 |
}
|
405 |
}
|
@@ -503,4 +511,38 @@ class Toolset_Relationship_Database_Operations {
|
|
503 |
return $rows;
|
504 |
}
|
505 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
}
|
120 |
// Columns in the relationships table
|
121 |
const COLUMN_DOMAIN = '_domain';
|
122 |
const COLUMN_TYPES = '_types';
|
123 |
+
const COLUMN_CARDINALITY_MAX = 'cardinality_%s_max';
|
124 |
+
const COLUMN_CARDINALITY_MIN = 'cardinality_%s_min';
|
125 |
|
126 |
|
127 |
/**
|
141 |
$role_name = $role;
|
142 |
}
|
143 |
|
144 |
+
// Special cases
|
145 |
+
if( in_array( $column, array( self::COLUMN_CARDINALITY_MAX, self::COLUMN_CARDINALITY_MIN ) ) ) {
|
146 |
+
return sprintf( $column, $role_name );
|
147 |
+
}
|
148 |
+
|
149 |
return $role_name . $column;
|
150 |
}
|
151 |
|
342 |
* The usage of this method is strictly limited to the m2m API, always change the slug via
|
343 |
* Toolset_Relationship_Definition_Repository::change_definition_slug().
|
344 |
*
|
345 |
+
* @param Toolset_Relationship_Definition $old_definition
|
346 |
+
* @param Toolset_Relationship_Definition $new_definition
|
347 |
*
|
348 |
* @return Toolset_Result
|
349 |
*
|
350 |
* @since m2m
|
351 |
*/
|
352 |
+
public function update_associations_on_definition_renaming(
|
353 |
+
Toolset_Relationship_Definition $old_definition,
|
354 |
+
Toolset_Relationship_Definition $new_definition
|
355 |
+
) {
|
356 |
+
$associations_table = new Toolset_Relationship_Table_Name;
|
357 |
+
|
358 |
+
$rows_updated = $this->wpdb->update(
|
359 |
+
$associations_table->association_table(),
|
360 |
+
array( 'relationship_id' => $new_definition->get_row_id() ),
|
361 |
+
array( 'relationship_id' => $old_definition->get_row_id() ),
|
362 |
+
'%d',
|
363 |
+
'%d'
|
364 |
);
|
365 |
|
366 |
$is_success = ( false !== $rows_updated );
|
369 |
$is_success
|
370 |
? sprintf(
|
371 |
__( 'The association table has been updated with the new relationship slug "%s". %d rows have been updated.', 'wpcf' ),
|
372 |
+
$new_definition->get_slug(),
|
373 |
$rows_updated
|
374 |
)
|
375 |
: sprintf(
|
376 |
__( 'There has been an error when updating the assocation table with the new relationship slug: %s', 'wpcf' ),
|
377 |
+
$this->wpdb->last_error
|
378 |
)
|
379 |
);
|
380 |
|
385 |
/**
|
386 |
* Delete all associations from a given relationship.
|
387 |
*
|
388 |
+
* @param int $relationship_row_id
|
389 |
*
|
390 |
* @return Toolset_Result_Updated
|
391 |
*/
|
392 |
+
public function delete_associations_by_relationship( $relationship_row_id ) {
|
393 |
|
394 |
$associations_table = $this->table_name->association_table();
|
395 |
|
396 |
$result = $this->wpdb->delete(
|
397 |
$associations_table,
|
398 |
+
array( 'relationship_id' => $relationship_row_id ),
|
399 |
+
array( '%d' )
|
400 |
);
|
401 |
|
402 |
if( false === $result ) {
|
407 |
} else {
|
408 |
return new Toolset_Result_Updated(
|
409 |
true, $result,
|
410 |
+
sprintf( __( 'Deleted all associations for the relationship #%d', 'wpcf'), $relationship_row_id )
|
411 |
);
|
412 |
}
|
413 |
}
|
511 |
return $rows;
|
512 |
}
|
513 |
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Update 'type' on 'toolset_type_sets'
|
517 |
+
*
|
518 |
+
* @param string $new_type
|
519 |
+
* @param string $old_type
|
520 |
+
*
|
521 |
+
* @return Toolset_Result
|
522 |
+
*/
|
523 |
+
public function update_type_on_type_sets( $new_type, $old_type ) {
|
524 |
+
$rows_updated = $this->wpdb->update(
|
525 |
+
$this->table_name->type_set_table(),
|
526 |
+
array( 'type' => $new_type ),
|
527 |
+
array( 'type' => $old_type ),
|
528 |
+
'%s',
|
529 |
+
'%s'
|
530 |
+
);
|
531 |
+
|
532 |
+
$is_success = ( false !== $rows_updated );
|
533 |
+
|
534 |
+
$message = $is_success
|
535 |
+
? sprintf(
|
536 |
+
__( 'The type_sets table has been updated with the new type "%s". %d rows have been updated.', 'wpcf' ),
|
537 |
+
$new_type,
|
538 |
+
$rows_updated
|
539 |
+
)
|
540 |
+
: sprintf(
|
541 |
+
__( 'There has been an error when updating the type_sets table with the new type "%s": %s', 'wpcf' ),
|
542 |
+
$new_type,
|
543 |
+
$this->wpdb->last_error
|
544 |
+
);
|
545 |
+
|
546 |
+
return new Toolset_Result( $is_success, $message );
|
547 |
+
}
|
548 |
}
|
vendor/toolset/toolset-common/inc/m2m/definition/definition.php
CHANGED
@@ -114,15 +114,26 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
|
|
114 |
const OWNER_IS_CHILD = 'child';
|
115 |
|
116 |
|
|
|
|
|
|
|
|
|
117 |
/**
|
118 |
* Toolset_Relationship_Definition constructor.
|
119 |
*
|
120 |
* @param array $definition_array Valid definition array.
|
121 |
-
* @
|
|
|
122 |
* @since m2m
|
123 |
*/
|
124 |
-
public function __construct( $definition_array ) {
|
125 |
$this->read_definition_array( $definition_array );
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
|
128 |
|
@@ -417,7 +428,7 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
|
|
417 |
* @since m2m
|
418 |
*/
|
419 |
public function is_post( $element_role ) {
|
420 |
-
return (
|
421 |
}
|
422 |
|
423 |
|
@@ -554,11 +565,17 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
|
|
554 |
* @return bool
|
555 |
* @throws InvalidArgumentException
|
556 |
* @since m2m
|
557 |
-
*
|
558 |
-
*
|
559 |
*/
|
560 |
public function can_associate( $parent_or_elements, $child = null ) {
|
561 |
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
if( $parent_or_elements instanceof Toolset_Element ) {
|
563 |
$elements = array(
|
564 |
Toolset_Relationship_Role::PARENT => $parent_or_elements,
|
@@ -570,45 +587,19 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
|
|
570 |
throw new InvalidArgumentException( 'Invalid argument - wrong element types in can_associate().');
|
571 |
}
|
572 |
|
573 |
-
|
574 |
-
|
575 |
-
|
|
|
|
|
576 |
|
577 |
-
|
578 |
-
if( $this->is_distinct() ) {
|
579 |
-
// todo (we need the rel query for this)
|
580 |
-
}
|
581 |
|
582 |
-
|
583 |
-
|
584 |
-
$scope = $this->get_scope();
|
585 |
-
if ( ! $scope->can_associate( $elements ) ) {
|
586 |
-
return false;
|
587 |
-
}
|
588 |
}
|
589 |
|
590 |
-
|
591 |
-
* toolset_can_create_association
|
592 |
-
*
|
593 |
-
* Allows for forbidding an association between two elements to be created.
|
594 |
-
* Note that it cannot be used to force-allow an association. The filter will be applied only if all
|
595 |
-
* conditions defined by the relationship are met.
|
596 |
-
*
|
597 |
-
* @param bool $result
|
598 |
-
* @param int $parent_id
|
599 |
-
* @param int $child_id
|
600 |
-
* @param string $relationship_slug
|
601 |
-
* @since m2m
|
602 |
-
*/
|
603 |
-
$filtered_result = apply_filters(
|
604 |
-
'toolset_can_create_association',
|
605 |
-
true,
|
606 |
-
$elements[ Toolset_Relationship_Role::PARENT ]->get_id(),
|
607 |
-
$elements[ Toolset_Relationship_Role::CHILD ]->get_id(),
|
608 |
-
$this->get_slug()
|
609 |
-
);
|
610 |
-
|
611 |
-
return $filtered_result;
|
612 |
}
|
613 |
|
614 |
|
@@ -641,30 +632,6 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
|
|
641 |
}
|
642 |
|
643 |
|
644 |
-
/**
|
645 |
-
* Make sure that both required elements are present and they match the domains and types allowed by the relationship
|
646 |
-
* definition.
|
647 |
-
*
|
648 |
-
* @param Toolset_Element[] $elements Array of (two) elements indexed by element keys.
|
649 |
-
* @return bool
|
650 |
-
* @throws InvalidArgumentException
|
651 |
-
* @since m2m
|
652 |
-
*/
|
653 |
-
private function elements_match_relationship_types( $elements ) {
|
654 |
-
foreach( Toolset_Relationship_Role::parent_child_role_names() as $element_role ) {
|
655 |
-
$element = toolset_getarr( $elements, $element_role, null );
|
656 |
-
if( ! $element instanceof Toolset_Element ) {
|
657 |
-
throw new InvalidArgumentException( 'Missing or invalid element instance.' );
|
658 |
-
}
|
659 |
-
if( ! $this->get_element_type( $element_role )->is_match( $element ) ) {
|
660 |
-
return false;
|
661 |
-
}
|
662 |
-
}
|
663 |
-
|
664 |
-
return true;
|
665 |
-
}
|
666 |
-
|
667 |
-
|
668 |
/**
|
669 |
* Determine or set whether the relationship is distinct, which means that only one association between
|
670 |
* each two elements can exist.
|
114 |
const OWNER_IS_CHILD = 'child';
|
115 |
|
116 |
|
117 |
+
/** @var Toolset_Potential_Association_Query_Factory */
|
118 |
+
private $potential_association_query_factory;
|
119 |
+
|
120 |
+
|
121 |
/**
|
122 |
* Toolset_Relationship_Definition constructor.
|
123 |
*
|
124 |
* @param array $definition_array Valid definition array.
|
125 |
+
* @param Toolset_Potential_Association_Query_Factory|null $potential_association_query_factory_di
|
126 |
+
*
|
127 |
* @since m2m
|
128 |
*/
|
129 |
+
public function __construct( $definition_array, Toolset_Potential_Association_Query_Factory $potential_association_query_factory_di = null ) {
|
130 |
$this->read_definition_array( $definition_array );
|
131 |
+
|
132 |
+
$this->potential_association_query_factory = (
|
133 |
+
null === $potential_association_query_factory_di
|
134 |
+
? new Toolset_Potential_Association_Query_Factory()
|
135 |
+
: $potential_association_query_factory_di
|
136 |
+
);
|
137 |
}
|
138 |
|
139 |
|
428 |
* @since m2m
|
429 |
*/
|
430 |
public function is_post( $element_role ) {
|
431 |
+
return ( Toolset_Element_Domain::POSTS == $this->get_element_type( $element_role )->get_domain() );
|
432 |
}
|
433 |
|
434 |
|
565 |
* @return bool
|
566 |
* @throws InvalidArgumentException
|
567 |
* @since m2m
|
568 |
+
* @since 2.5.7 Deprecated.
|
569 |
+
* @deprecated Use IToolset_Potential_Association_Query::check_single_element() instead.
|
570 |
*/
|
571 |
public function can_associate( $parent_or_elements, $child = null ) {
|
572 |
|
573 |
+
_doing_it_wrong(
|
574 |
+
__FUNCTION__,
|
575 |
+
'Toolset_Relationship_Definition::can_associate() is replaced by IToolset_Potential_Association_Query::check_single_element()',
|
576 |
+
'2.5.7'
|
577 |
+
);
|
578 |
+
|
579 |
if( $parent_or_elements instanceof Toolset_Element ) {
|
580 |
$elements = array(
|
581 |
Toolset_Relationship_Role::PARENT => $parent_or_elements,
|
587 |
throw new InvalidArgumentException( 'Invalid argument - wrong element types in can_associate().');
|
588 |
}
|
589 |
|
590 |
+
$potential_association = $this->potential_association_query_factory->create(
|
591 |
+
$this,
|
592 |
+
new Toolset_Relationship_Role_Child(),
|
593 |
+
$elements[ Toolset_Relationship_Role::PARENT ]
|
594 |
+
);
|
595 |
|
596 |
+
$result = $potential_association->check_single_element( $elements[ Toolset_Relationship_Role::CHILD ] );
|
|
|
|
|
|
|
597 |
|
598 |
+
if( ! $result->is_success() ) {
|
599 |
+
return false;
|
|
|
|
|
|
|
|
|
600 |
}
|
601 |
|
602 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
603 |
}
|
604 |
|
605 |
|
632 |
}
|
633 |
|
634 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
635 |
/**
|
636 |
* Determine or set whether the relationship is distinct, which means that only one association between
|
637 |
* each two elements can exist.
|
vendor/toolset/toolset-common/inc/m2m/{i_definition.php → definition/interface.php}
RENAMED
@@ -93,7 +93,7 @@ interface IToolset_Relationship_Definition {
|
|
93 |
|
94 |
|
95 |
/**
|
96 |
-
* Get a
|
97 |
*
|
98 |
* @param string|IToolset_Relationship_Role $element_role
|
99 |
*
|
@@ -103,6 +103,20 @@ interface IToolset_Relationship_Definition {
|
|
103 |
public function get_element_type( $element_role );
|
104 |
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
/**
|
107 |
* Determine if there are posts on the given side of the relationship.
|
108 |
*
|
93 |
|
94 |
|
95 |
/**
|
96 |
+
* Get a type of elements that can take a role in the relationship.
|
97 |
*
|
98 |
* @param string|IToolset_Relationship_Role $element_role
|
99 |
*
|
103 |
public function get_element_type( $element_role );
|
104 |
|
105 |
|
106 |
+
/**
|
107 |
+
* Set a type of elements that can take a role in the relationship.
|
108 |
+
*
|
109 |
+
* Use with caution. Without further adjustments, this can cause a database inconsistency.
|
110 |
+
*
|
111 |
+
* @param Toolset_Relationship_Element_Type $element_type
|
112 |
+
* @param IToolset_Relationship_Role_Parent_Child|string $role
|
113 |
+
*
|
114 |
+
* @return void
|
115 |
+
* @since 2.5.6
|
116 |
+
*/
|
117 |
+
public function set_element_type( $role, Toolset_Relationship_Element_Type $element_type );
|
118 |
+
|
119 |
+
|
120 |
/**
|
121 |
* Determine if there are posts on the given side of the relationship.
|
122 |
*
|
vendor/toolset/toolset-common/inc/m2m/definition/persistence.php
CHANGED
@@ -62,7 +62,7 @@ class Toolset_Relationship_Definition_Persistence {
|
|
62 |
$this->wpdb->update(
|
63 |
$this->table_name->relationship_table(),
|
64 |
$row,
|
65 |
-
array( '
|
66 |
$this->definition_translator->get_database_row_formats(),
|
67 |
'%s'
|
68 |
);
|
@@ -73,15 +73,41 @@ class Toolset_Relationship_Definition_Persistence {
|
|
73 |
* Insert a new relationship definition record into the database.
|
74 |
*
|
75 |
* @param Toolset_Relationship_Definition $relationship_definition
|
|
|
|
|
76 |
*/
|
77 |
public function insert_definition( Toolset_Relationship_Definition $relationship_definition ) {
|
78 |
$row = $this->definition_translator->to_database_row( $relationship_definition );
|
79 |
$row = $this->update_definition_type_sets( $relationship_definition, $row );
|
|
|
80 |
$this->wpdb->insert(
|
81 |
$this->table_name->relationship_table(),
|
82 |
$row,
|
83 |
$this->definition_translator->get_database_row_formats()
|
84 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
|
87 |
|
@@ -206,4 +232,4 @@ class Toolset_Relationship_Definition_Persistence {
|
|
206 |
}
|
207 |
|
208 |
|
209 |
-
}
|
62 |
$this->wpdb->update(
|
63 |
$this->table_name->relationship_table(),
|
64 |
$row,
|
65 |
+
array( 'id' => $relationship_definition->get_row_id() ),
|
66 |
$this->definition_translator->get_database_row_formats(),
|
67 |
'%s'
|
68 |
);
|
73 |
* Insert a new relationship definition record into the database.
|
74 |
*
|
75 |
* @param Toolset_Relationship_Definition $relationship_definition
|
76 |
+
*
|
77 |
+
* @return null|Toolset_Relationship_Definition
|
78 |
*/
|
79 |
public function insert_definition( Toolset_Relationship_Definition $relationship_definition ) {
|
80 |
$row = $this->definition_translator->to_database_row( $relationship_definition );
|
81 |
$row = $this->update_definition_type_sets( $relationship_definition, $row );
|
82 |
+
|
83 |
$this->wpdb->insert(
|
84 |
$this->table_name->relationship_table(),
|
85 |
$row,
|
86 |
$this->definition_translator->get_database_row_formats()
|
87 |
);
|
88 |
+
|
89 |
+
// Create a new relationship definition instance from the exact data that has been sent to the
|
90 |
+
// database (row ID and type set IDs).
|
91 |
+
$row['id'] = $this->wpdb->insert_id;
|
92 |
+
$row['parent_types_set_id'] = $row['parent_types'];
|
93 |
+
$row['child_types_set_id'] = $row['child_types'];
|
94 |
+
|
95 |
+
// Work around some differences caused between the data sent when updating relationship
|
96 |
+
// rows and data retrieved when querying (and appending the concatenated list of parent
|
97 |
+
// and child types).
|
98 |
+
$definition_array = $relationship_definition->get_definition_array();
|
99 |
+
$row['parent_types'] = implode(
|
100 |
+
Toolset_Relationship_Database_Operations::GROUP_CONCAT_DELIMITER,
|
101 |
+
$definition_array[ Toolset_Relationship_Definition::DA_PARENT_TYPE ][ Toolset_Relationship_Element_Type::DA_TYPES ]
|
102 |
+
);
|
103 |
+
$row['child_types'] = implode(
|
104 |
+
Toolset_Relationship_Database_Operations::GROUP_CONCAT_DELIMITER,
|
105 |
+
$definition_array[ Toolset_Relationship_Definition::DA_CHILD_TYPE ][ Toolset_Relationship_Element_Type::DA_TYPES ]
|
106 |
+
);
|
107 |
+
|
108 |
+
$updated_relationship_definition = $this->definition_translator->from_database_row( (object) $row );
|
109 |
+
|
110 |
+
return $updated_relationship_definition;
|
111 |
}
|
112 |
|
113 |
|
232 |
}
|
233 |
|
234 |
|
235 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/definition/repository.php
CHANGED
@@ -17,13 +17,15 @@
|
|
17 |
class Toolset_Relationship_Definition_Repository {
|
18 |
|
19 |
|
|
|
20 |
private static $instance = null;
|
21 |
|
22 |
|
23 |
-
|
24 |
-
|
|
|
25 |
public static function get_instance() {
|
26 |
-
if( null
|
27 |
self::$instance = new self();
|
28 |
self::$instance->load_definitions();
|
29 |
}
|
@@ -46,6 +48,7 @@ class Toolset_Relationship_Definition_Repository {
|
|
46 |
/** @var Toolset_Relationship_Definition_Translator */
|
47 |
private $definition_translator;
|
48 |
|
|
|
49 |
public function __construct(
|
50 |
Toolset_Association_Repository $association_repository_di = null,
|
51 |
Toolset_Relationship_Database_Operations $database_operations_di = null,
|
@@ -207,7 +210,7 @@ class Toolset_Relationship_Definition_Repository {
|
|
207 |
*/
|
208 |
public function get_definition_by_row_id( $row_id ) {
|
209 |
foreach( $this->definitions as $definition ) {
|
210 |
-
if( $row_id === $definition->get_row_id() ) {
|
211 |
return $definition;
|
212 |
}
|
213 |
}
|
@@ -217,9 +220,7 @@ class Toolset_Relationship_Definition_Repository {
|
|
217 |
|
218 |
|
219 |
/**
|
220 |
-
* Create a new definition and start managing it.
|
221 |
-
*
|
222 |
-
* Note that it doesn't save anything to database automatically.
|
223 |
*
|
224 |
* @param string $slug Valid (sanitized) relationship slug.
|
225 |
* @param Toolset_Relationship_Element_Type $parent Parent entity type.
|
@@ -229,6 +230,7 @@ class Toolset_Relationship_Definition_Repository {
|
|
229 |
*
|
230 |
* @return IToolset_Relationship_Definition
|
231 |
* @since m2m
|
|
|
232 |
*/
|
233 |
public function create_definition( $slug, $parent, $child, $allow_slug_adjustment = true ) {
|
234 |
if( $slug != sanitize_title( $slug ) ) {
|
@@ -260,11 +262,12 @@ class Toolset_Relationship_Definition_Repository {
|
|
260 |
|
261 |
$new_definition = new Toolset_Relationship_Definition( $definition_array );
|
262 |
|
263 |
-
|
|
|
264 |
|
265 |
-
$this->add_to_cache( $
|
266 |
|
267 |
-
return $
|
268 |
}
|
269 |
|
270 |
/**
|
@@ -281,7 +284,7 @@ class Toolset_Relationship_Definition_Repository {
|
|
281 |
*/
|
282 |
public function create_definition_post_reference_field( $field_slug, $field_group_slug, $post_reference_type, $parent, $child ) {
|
283 |
return $this->create_definition(
|
284 |
-
$field_slug
|
285 |
$parent,
|
286 |
$child,
|
287 |
false
|
@@ -384,19 +387,14 @@ class Toolset_Relationship_Definition_Repository {
|
|
384 |
$previous_slug = $relationship_definition->get_slug();
|
385 |
$relationship_definition->set_slug( $new_slug );
|
386 |
|
387 |
-
//
|
388 |
-
$this->
|
389 |
-
$this->add_to_cache( $relationship_definition );
|
390 |
-
$this->persist_definition( $relationship_definition );
|
391 |
|
392 |
-
//
|
393 |
-
$
|
394 |
-
$previous_slug, $new_slug
|
395 |
-
);
|
396 |
|
397 |
-
|
398 |
-
|
399 |
-
}
|
400 |
|
401 |
return new Toolset_Result(
|
402 |
true,
|
@@ -443,4 +441,4 @@ class Toolset_Relationship_Definition_Repository {
|
|
443 |
return $this->_definition_persistence;
|
444 |
}
|
445 |
|
446 |
-
}
|
17 |
class Toolset_Relationship_Definition_Repository {
|
18 |
|
19 |
|
20 |
+
/** @var null|Toolset_Relationship_Definition_Repository */
|
21 |
private static $instance = null;
|
22 |
|
23 |
|
24 |
+
/**
|
25 |
+
* @return Toolset_Relationship_Definition_Repository
|
26 |
+
*/
|
27 |
public static function get_instance() {
|
28 |
+
if( null === self::$instance ) {
|
29 |
self::$instance = new self();
|
30 |
self::$instance->load_definitions();
|
31 |
}
|
48 |
/** @var Toolset_Relationship_Definition_Translator */
|
49 |
private $definition_translator;
|
50 |
|
51 |
+
|
52 |
public function __construct(
|
53 |
Toolset_Association_Repository $association_repository_di = null,
|
54 |
Toolset_Relationship_Database_Operations $database_operations_di = null,
|
210 |
*/
|
211 |
public function get_definition_by_row_id( $row_id ) {
|
212 |
foreach( $this->definitions as $definition ) {
|
213 |
+
if( (int) $row_id === (int) $definition->get_row_id() ) {
|
214 |
return $definition;
|
215 |
}
|
216 |
}
|
220 |
|
221 |
|
222 |
/**
|
223 |
+
* Create a new definition, persist it in the database and start managing it.
|
|
|
|
|
224 |
*
|
225 |
* @param string $slug Valid (sanitized) relationship slug.
|
226 |
* @param Toolset_Relationship_Element_Type $parent Parent entity type.
|
230 |
*
|
231 |
* @return IToolset_Relationship_Definition
|
232 |
* @since m2m
|
233 |
+
* @since 2.5.5 persists the relationship in the database.
|
234 |
*/
|
235 |
public function create_definition( $slug, $parent, $child, $allow_slug_adjustment = true ) {
|
236 |
if( $slug != sanitize_title( $slug ) ) {
|
262 |
|
263 |
$new_definition = new Toolset_Relationship_Definition( $definition_array );
|
264 |
|
265 |
+
// The definition will be augmented when inserting (with IDs)
|
266 |
+
$persisted_definition = $this->get_definition_persistence()->insert_definition( $new_definition );
|
267 |
|
268 |
+
$this->add_to_cache( $persisted_definition );
|
269 |
|
270 |
+
return $persisted_definition;
|
271 |
}
|
272 |
|
273 |
/**
|
284 |
*/
|
285 |
public function create_definition_post_reference_field( $field_slug, $field_group_slug, $post_reference_type, $parent, $child ) {
|
286 |
return $this->create_definition(
|
287 |
+
$field_slug,
|
288 |
$parent,
|
289 |
$child,
|
290 |
false
|
387 |
$previous_slug = $relationship_definition->get_slug();
|
388 |
$relationship_definition->set_slug( $new_slug );
|
389 |
|
390 |
+
// Remove old definition from cache
|
391 |
+
unset( $this->definitions[ $previous_slug ] );
|
|
|
|
|
392 |
|
393 |
+
// Add updated definition to cache
|
394 |
+
$this->add_to_cache( $relationship_definition );
|
|
|
|
|
395 |
|
396 |
+
// Store changes to db
|
397 |
+
$this->persist_definition( $relationship_definition );
|
|
|
398 |
|
399 |
return new Toolset_Result(
|
400 |
true,
|
441 |
return $this->_definition_persistence;
|
442 |
}
|
443 |
|
444 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/definition/translator.php
CHANGED
@@ -122,22 +122,15 @@ class Toolset_Relationship_Definition_Translator {
|
|
122 |
/**
|
123 |
* Load a single relationship definition from a definition array.
|
124 |
*
|
125 |
-
* @param
|
126 |
* @return null|Toolset_Relationship_Definition The relationship definition or null if it was not
|
127 |
* possible to load it (which means that the definition array was invalid).
|
128 |
* @since m2m
|
129 |
*/
|
130 |
public function from_database_row( $database_row ) {
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
$definition = $this->definition_factory->create( $definition_array );
|
135 |
-
return $definition;
|
136 |
-
/*} catch( Exception $e ) {
|
137 |
-
// todo og the error somehow
|
138 |
-
return null;
|
139 |
-
}*/
|
140 |
-
|
141 |
}
|
142 |
|
143 |
|
122 |
/**
|
123 |
* Load a single relationship definition from a definition array.
|
124 |
*
|
125 |
+
* @param object $database_row
|
126 |
* @return null|Toolset_Relationship_Definition The relationship definition or null if it was not
|
127 |
* possible to load it (which means that the definition array was invalid).
|
128 |
* @since m2m
|
129 |
*/
|
130 |
public function from_database_row( $database_row ) {
|
131 |
+
$definition_array = $this->from_database_row_to_definition_array( $database_row );
|
132 |
+
$definition = $this->definition_factory->create( $definition_array );
|
133 |
+
return $definition;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
|
136 |
|
vendor/toolset/toolset-common/inc/m2m/driver.php
CHANGED
@@ -36,8 +36,15 @@ class Toolset_Relationship_Driver extends Toolset_Relationship_Driver_Base {
|
|
36 |
$child = Toolset_Element::get_untranslated_instance( $relationship_definition->get_child_domain(), $child_source );
|
37 |
|
38 |
// We need to make sure the association is allowed.
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
|
43 |
$intermediary_id = (int) toolset_getarr( $args, 'intermediary_id', 0 );
|
36 |
$child = Toolset_Element::get_untranslated_instance( $relationship_definition->get_child_domain(), $child_source );
|
37 |
|
38 |
// We need to make sure the association is allowed.
|
39 |
+
$potential_association_query = $this->get_potential_association_query_factory()->create(
|
40 |
+
$this->get_relationship_definition(),
|
41 |
+
new Toolset_Relationship_Role_Child(),
|
42 |
+
$parent
|
43 |
+
);
|
44 |
+
|
45 |
+
$can_associate_check = $potential_association_query->check_single_element( $child );
|
46 |
+
if ( $can_associate_check->is_error() ) {
|
47 |
+
return $can_associate_check;
|
48 |
}
|
49 |
|
50 |
$intermediary_id = (int) toolset_getarr( $args, 'intermediary_id', 0 );
|
vendor/toolset/toolset-common/inc/m2m/driver_base.php
CHANGED
@@ -15,24 +15,24 @@ abstract class Toolset_Relationship_Driver_Base {
|
|
15 |
/** @var array Driver setup array provided by the relationship definition. */
|
16 |
private $setup;
|
17 |
|
|
|
|
|
18 |
|
19 |
/**
|
20 |
* Toolset_Relationship_Driver_Base constructor.
|
21 |
*
|
22 |
* @param Toolset_Relationship_Definition $definition Relationship definition that is going to be using this driver.
|
23 |
* @param array $setup Driver setup array provided by the relationship definition.
|
|
|
24 |
*
|
25 |
* @since m2m
|
26 |
*/
|
27 |
-
public function __construct(
|
28 |
-
|
29 |
-
|
30 |
-
throw new InvalidArgumentException();
|
31 |
-
}
|
32 |
-
|
33 |
$this->definition = $definition;
|
34 |
-
|
35 |
$this->setup = toolset_ensarr( $setup );
|
|
|
36 |
}
|
37 |
|
38 |
|
@@ -132,4 +132,16 @@ abstract class Toolset_Relationship_Driver_Base {
|
|
132 |
return ( $association instanceof Toolset_Association_Base && $association->get_driver() === $this );
|
133 |
}
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
}
|
15 |
/** @var array Driver setup array provided by the relationship definition. */
|
16 |
private $setup;
|
17 |
|
18 |
+
/** @var null|Toolset_Potential_Association_Query_Factory */
|
19 |
+
private $_potential_association_query_factory;
|
20 |
|
21 |
/**
|
22 |
* Toolset_Relationship_Driver_Base constructor.
|
23 |
*
|
24 |
* @param Toolset_Relationship_Definition $definition Relationship definition that is going to be using this driver.
|
25 |
* @param array $setup Driver setup array provided by the relationship definition.
|
26 |
+
* @param Toolset_Potential_Association_Query_Factory|null $pa_query_factory_di
|
27 |
*
|
28 |
* @since m2m
|
29 |
*/
|
30 |
+
public function __construct(
|
31 |
+
Toolset_Relationship_Definition $definition, $setup, Toolset_Potential_Association_Query_Factory $pa_query_factory_di = null
|
32 |
+
) {
|
|
|
|
|
|
|
33 |
$this->definition = $definition;
|
|
|
34 |
$this->setup = toolset_ensarr( $setup );
|
35 |
+
$this->_potential_association_query_factory = $pa_query_factory_di;
|
36 |
}
|
37 |
|
38 |
|
132 |
return ( $association instanceof Toolset_Association_Base && $association->get_driver() === $this );
|
133 |
}
|
134 |
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @return Toolset_Potential_Association_Query_Factory
|
138 |
+
* @since 2.5.6
|
139 |
+
*/
|
140 |
+
protected function get_potential_association_query_factory() {
|
141 |
+
if( null === $this->_potential_association_query_factory ) {
|
142 |
+
$this->_potential_association_query_factory = new Toolset_Potential_Association_Query_Factory();
|
143 |
+
}
|
144 |
+
|
145 |
+
return $this->_potential_association_query_factory;
|
146 |
+
}
|
147 |
}
|
vendor/toolset/toolset-common/inc/m2m/element_type.php
CHANGED
@@ -142,7 +142,7 @@ class Toolset_Relationship_Element_Type {
|
|
142 |
/**
|
143 |
* Determine whether an element matches this type.
|
144 |
*
|
145 |
-
* @param
|
146 |
* @return bool
|
147 |
* @since m2m
|
148 |
*/
|
@@ -158,13 +158,10 @@ class Toolset_Relationship_Element_Type {
|
|
158 |
|
159 |
// If the domain matches, we'll check by the type (where applicable).
|
160 |
switch( $this->get_domain() ) {
|
161 |
-
case
|
162 |
-
/** @var
|
163 |
$post = $element;
|
164 |
return in_array( $post->get_type(), $this->get_types() );
|
165 |
-
|
166 |
-
case Toolset_Field_Utils::DOMAIN_USERS:
|
167 |
-
case Toolset_Field_Utils::DOMAIN_TERMS:
|
168 |
default:
|
169 |
throw new RuntimeException( 'Not implemented.' );
|
170 |
}
|
142 |
/**
|
143 |
* Determine whether an element matches this type.
|
144 |
*
|
145 |
+
* @param IToolset_Element $element
|
146 |
* @return bool
|
147 |
* @since m2m
|
148 |
*/
|
158 |
|
159 |
// If the domain matches, we'll check by the type (where applicable).
|
160 |
switch( $this->get_domain() ) {
|
161 |
+
case Toolset_Element_Domain::POSTS:
|
162 |
+
/** @var IToolset_Post $post */
|
163 |
$post = $element;
|
164 |
return in_array( $post->get_type(), $this->get_types() );
|
|
|
|
|
|
|
165 |
default:
|
166 |
throw new RuntimeException( 'Not implemented.' );
|
167 |
}
|
vendor/toolset/toolset-common/inc/m2m/migration_associations.php
CHANGED
@@ -70,7 +70,14 @@ class Toolset_Relationship_Migration_Associations {
|
|
70 |
return new Toolset_Result( $e, $display_message );
|
71 |
}
|
72 |
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
return new Toolset_Result(
|
75 |
false,
|
76 |
sprintf(
|
@@ -109,4 +116,4 @@ class Toolset_Relationship_Migration_Associations {
|
|
109 |
|
110 |
}
|
111 |
|
112 |
-
}
|
70 |
return new Toolset_Result( $e, $display_message );
|
71 |
}
|
72 |
|
73 |
+
$potential_association_query_factory = new Toolset_Potential_Association_Query_Factory();
|
74 |
+
$potential_association = $potential_association_query_factory->create(
|
75 |
+
$relationship_definition,
|
76 |
+
new Toolset_Relationship_Role_Child(),
|
77 |
+
$parent
|
78 |
+
);
|
79 |
+
|
80 |
+
if( ! $potential_association->check_single_element( $child ) ) {
|
81 |
return new Toolset_Result(
|
82 |
false,
|
83 |
sprintf(
|
116 |
|
117 |
}
|
118 |
|
119 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/multilingual_mode.php
CHANGED
@@ -115,6 +115,9 @@ class Toolset_Relationship_Multilingual_Mode {
|
|
115 |
|
116 |
private function get_multilingual_mode() {
|
117 |
|
|
|
|
|
|
|
118 |
if( null === $this->current_multilingual_mode ) {
|
119 |
|
120 |
$stored_mode = $this->load_multilingual_mode_option();
|
115 |
|
116 |
private function get_multilingual_mode() {
|
117 |
|
118 |
+
// Allways off since this functionality is about to be removed.
|
119 |
+
return self::MODE_OFF;
|
120 |
+
|
121 |
if( null === $this->current_multilingual_mode ) {
|
122 |
|
123 |
$stored_mode = $this->load_multilingual_mode_option();
|
vendor/toolset/toolset-common/inc/m2m/potential_association/query_interface.php
CHANGED
@@ -39,4 +39,25 @@ interface IToolset_Potential_Association_Query extends IToolset_Query {
|
|
39 |
*/
|
40 |
public function get_found_elements();
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
39 |
*/
|
40 |
public function get_found_elements();
|
41 |
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Check whether a specific single element can be associated.
|
45 |
+
*
|
46 |
+
* The relationship, target role and the other element are those provided in the constructor.
|
47 |
+
*
|
48 |
+
* @param IToolset_Element $association_candidate Element that wants to be associated.
|
49 |
+
* @return Toolset_Result Result with an user-friendly message in case the association is denied.
|
50 |
+
* @since 2.5.6
|
51 |
+
*/
|
52 |
+
public function check_single_element( IToolset_Element $association_candidate );
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Check whether the element provided in the constructor can accept any new association whatsoever.
|
57 |
+
*
|
58 |
+
* @return Toolset_Result Result with an user-friendly message in case the association is denied.
|
59 |
+
* @since 2.5.6
|
60 |
+
*/
|
61 |
+
public function can_connect_another_element();
|
62 |
+
|
63 |
}
|
vendor/toolset/toolset-common/inc/m2m/potential_association/query_posts.php
CHANGED
@@ -60,8 +60,8 @@ class Toolset_Potential_Association_Query_Posts implements IToolset_Potential_As
|
|
60 |
$this->target_role = $target_role;
|
61 |
$this->args = $args;
|
62 |
|
63 |
-
if( $relationship->get_element_type( $target_role->get_name() )->
|
64 |
-
throw new InvalidArgumentException( '
|
65 |
}
|
66 |
|
67 |
$this->query_factory = ( null === $query_factory_di ? new Toolset_Relationship_Query_Factory() : $query_factory_di );
|
@@ -194,14 +194,147 @@ class Toolset_Potential_Association_Query_Posts implements IToolset_Potential_As
|
|
194 |
*
|
195 |
* The relationship, target role and the other element are those provided in the constructor.
|
196 |
*
|
197 |
-
*
|
|
|
|
|
198 |
*/
|
199 |
-
public function check_single_element() {
|
200 |
-
// todo move the logic from Toolset_Relationship_Definition here
|
201 |
|
202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
}
|
204 |
|
205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
}
|
60 |
$this->target_role = $target_role;
|
61 |
$this->args = $args;
|
62 |
|
63 |
+
if( ! $relationship->get_element_type( $target_role->other()->get_name() )->is_match( $for_element ) ) {
|
64 |
+
throw new InvalidArgumentException( 'The element to connect with doesn\'t belong to the relationship definition provided.' );
|
65 |
}
|
66 |
|
67 |
$this->query_factory = ( null === $query_factory_di ? new Toolset_Relationship_Query_Factory() : $query_factory_di );
|
194 |
*
|
195 |
* The relationship, target role and the other element are those provided in the constructor.
|
196 |
*
|
197 |
+
* @param IToolset_Element $association_candidate Element that wants to be associated.
|
198 |
+
* @return Toolset_Result Result with an user-friendly message in case the association is denied.
|
199 |
+
* @since 2.5.6
|
200 |
*/
|
201 |
+
public function check_single_element( IToolset_Element $association_candidate ) {
|
|
|
202 |
|
203 |
+
if( ! $this->relationship->get_element_type( $this->target_role )->is_match( $association_candidate ) ) {
|
204 |
+
return new Toolset_Result( false, __( 'The element has a wrong type or a domain for this relationship.', 'wpcf' ) );
|
205 |
+
}
|
206 |
+
|
207 |
+
if( $this->relationship->is_distinct() && $this->is_element_already_associated( $association_candidate ) ) {
|
208 |
+
return new Toolset_Result( false,
|
209 |
+
__( 'These two elements are already associated and the relationship doesn\'t allow non-distinct associations.', 'wpcf' )
|
210 |
+
);
|
211 |
+
}
|
212 |
+
|
213 |
+
$cardinality_check_result = $this->check_cardinality_for_role( $this->for_element, $this->target_role->other() );
|
214 |
+
if( $cardinality_check_result->is_error() ) {
|
215 |
+
return $cardinality_check_result;
|
216 |
+
}
|
217 |
+
|
218 |
+
$cardinality_check_result = $this->check_cardinality_for_role( $association_candidate, $this->target_role );
|
219 |
+
if( $cardinality_check_result->is_error() ) {
|
220 |
+
return $cardinality_check_result;
|
221 |
+
}
|
222 |
+
|
223 |
+
// We also need to check $this->relationship->has_scope() when/if the scope support is implemented.
|
224 |
+
|
225 |
+
/** @var IToolset_Element[] $parent_and_child */
|
226 |
+
$parent_and_child = Toolset_Relationship_Role::sort_elements( $association_candidate, $this->for_element, $this->target_role );
|
227 |
+
|
228 |
+
/**
|
229 |
+
* toolset_can_create_association
|
230 |
+
*
|
231 |
+
* Allows for forbidding an association between two elements to be created.
|
232 |
+
* Note that it cannot be used to force-allow an association. The filter will be applied only if all
|
233 |
+
* conditions defined by the relationship are met.
|
234 |
+
*
|
235 |
+
* @param bool $result
|
236 |
+
* @param int $parent_id
|
237 |
+
* @param int $child_id
|
238 |
+
* @param string $relationship_slug
|
239 |
+
* @since m2m
|
240 |
+
*/
|
241 |
+
$filtered_result = apply_filters(
|
242 |
+
'toolset_can_create_association',
|
243 |
+
true,
|
244 |
+
$parent_and_child[0]->get_id(),
|
245 |
+
$parent_and_child[1]->get_id(),
|
246 |
+
$this->relationship->get_slug()
|
247 |
+
);
|
248 |
+
|
249 |
+
if( true !== $filtered_result ) {
|
250 |
+
if( is_string( $filtered_result ) ) {
|
251 |
+
$message = esc_html( $filtered_result );
|
252 |
+
} else {
|
253 |
+
$message = __( 'The association was disabled by a third-party filter.', 'wpcf' );
|
254 |
+
}
|
255 |
+
return new Toolset_Result( false, $message );
|
256 |
+
}
|
257 |
+
|
258 |
+
return new Toolset_Result( true );
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
private function is_element_already_associated( IToolset_Element $element ) {
|
263 |
+
|
264 |
+
/** @var IToolset_Element[] $parent_and_child */
|
265 |
+
$parent_and_child = Toolset_Relationship_Role::sort_elements( $element, $this->for_element, $this->target_role );
|
266 |
+
|
267 |
+
$query = $this->query_factory->associations( array(
|
268 |
+
Toolset_Association_Query::QUERY_RELATIONSHIP_SLUG => $this->relationship->get_slug(),
|
269 |
+
Toolset_Association_Query::QUERY_PARENT_ID => $parent_and_child[0]->get_id(),
|
270 |
+
Toolset_Association_Query::QUERY_CHILD_ID => $parent_and_child[1]->get_id(),
|
271 |
+
Toolset_Association_Query::QUERY_LIMIT => 1,
|
272 |
+
) );
|
273 |
+
|
274 |
+
$results = $query->get_results();
|
275 |
+
|
276 |
+
return ( count( $results ) > 0 );
|
277 |
}
|
278 |
|
279 |
|
280 |
+
/**
|
281 |
+
* @param IToolset_Element $element Element to check.
|
282 |
+
* @param IToolset_Relationship_Role_Parent_Child $role Provided element's role in the relationship.
|
283 |
+
*
|
284 |
+
* @return Toolset_Result
|
285 |
+
*/
|
286 |
+
private function check_cardinality_for_role( IToolset_Element $element, IToolset_Relationship_Role_Parent_Child $role ) {
|
287 |
+
$maximum_limit = $this->relationship->get_cardinality()->get_limit( $role->other()->get_name(), Toolset_Relationship_Cardinality::MAX );
|
288 |
+
|
289 |
+
if( $maximum_limit !== Toolset_Relationship_Cardinality::INFINITY ) {
|
290 |
+
$association_count = $this->get_number_of_already_associated_elements( $role, $element );
|
291 |
+
if( $association_count >= $maximum_limit ) {
|
292 |
+
$message = sprintf(
|
293 |
+
__( 'The element %s has already the maximum allowed amount of associations (%d) as %s in the relationship %s.', 'wpcf' ),
|
294 |
+
$element->get_title(),
|
295 |
+
$maximum_limit, // this will be always a meaningful number - for INFINITY, this block is skipped entirely.
|
296 |
+
$this->relationship->get_role_name( $role ),
|
297 |
+
$this->relationship->get_display_name()
|
298 |
+
);
|
299 |
+
return new Toolset_Result( false, esc_html( $message ) );
|
300 |
+
}
|
301 |
+
}
|
302 |
+
|
303 |
+
return new Toolset_Result( true );
|
304 |
+
}
|
305 |
+
|
306 |
+
|
307 |
+
private function get_number_of_already_associated_elements(
|
308 |
+
IToolset_Relationship_Role_Parent_Child $role, IToolset_Element $element
|
309 |
+
) {
|
310 |
+
$for_element_role_query = (
|
311 |
+
$role instanceof Toolset_Relationship_Role_Parent
|
312 |
+
? Toolset_Association_Query::QUERY_PARENT_ID
|
313 |
+
: Toolset_Association_Query::QUERY_CHILD_ID
|
314 |
+
);
|
315 |
|
316 |
+
$query = $this->query_factory->associations( array(
|
317 |
+
Toolset_Association_Query::QUERY_RELATIONSHIP_SLUG => $this->relationship->get_slug(),
|
318 |
+
$for_element_role_query => $element->get_id()
|
319 |
+
) );
|
320 |
+
|
321 |
+
$results = $query->get_results();
|
322 |
+
|
323 |
+
return count( $results );
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Check whether the element provided in the constructor can accept any new association whatsoever.
|
328 |
+
*
|
329 |
+
* @return Toolset_Result Result with an user-friendly message in case the association is denied.
|
330 |
+
* @since 2.5.6
|
331 |
+
*/
|
332 |
+
public function can_connect_another_element() {
|
333 |
+
$cardinality_check_result = $this->check_cardinality_for_role( $this->for_element, $this->target_role->other() );
|
334 |
+
if( $cardinality_check_result->is_error() ) {
|
335 |
+
return $cardinality_check_result;
|
336 |
+
}
|
337 |
+
|
338 |
+
return new Toolset_Result( true );
|
339 |
+
}
|
340 |
}
|
vendor/toolset/toolset-common/inc/m2m/query_base.php
CHANGED
@@ -89,7 +89,7 @@ abstract class Toolset_Relationship_Query_Base {
|
|
89 |
* @return bool
|
90 |
*/
|
91 |
protected function has_query_var( $var_name ) {
|
92 |
-
return ( isset( $this->query_vars[ $var_name ] ) && null
|
93 |
}
|
94 |
|
95 |
|
89 |
* @return bool
|
90 |
*/
|
91 |
protected function has_query_var( $var_name ) {
|
92 |
+
return ( isset( $this->query_vars[ $var_name ] ) && null !== $this->query_vars[ $var_name ] );
|
93 |
}
|
94 |
|
95 |
|
vendor/toolset/toolset-common/inc/m2m/query_factory.php
CHANGED
@@ -19,6 +19,17 @@ class Toolset_Relationship_Query_Factory {
|
|
19 |
return new Toolset_Relationship_Query( $args );
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
/**
|
23 |
* @param IToolset_Relationship_Definition $relationship
|
24 |
* @param IToolset_Relationship_Role_Parent_Child $target_role Target role of the relationships (future role of
|
@@ -56,6 +67,13 @@ class Toolset_Relationship_Query_Factory {
|
|
56 |
}
|
57 |
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
|
61 |
-
}
|
19 |
return new Toolset_Relationship_Query( $args );
|
20 |
}
|
21 |
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @return Toolset_Relationship_Query_V2
|
25 |
+
*
|
26 |
+
* @return Toolset_Relationship_Query_V2
|
27 |
+
*/
|
28 |
+
public function relationships_v2() {
|
29 |
+
return new Toolset_Relationship_Query_V2();
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
/**
|
34 |
* @param IToolset_Relationship_Definition $relationship
|
35 |
* @param IToolset_Relationship_Role_Parent_Child $target_role Target role of the relationships (future role of
|
67 |
}
|
68 |
|
69 |
|
70 |
+
/**
|
71 |
+
* @param $args
|
72 |
+
*
|
73 |
+
* @return Toolset_Association_Query
|
74 |
+
*/
|
75 |
+
public function associations( $args ) {
|
76 |
+
return new Toolset_Association_Query( $args );
|
77 |
+
}
|
78 |
|
79 |
+
}
|
|
vendor/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/conjunction.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Cardinality matcher that holds a set of single matchers.
|
5 |
+
*
|
6 |
+
* @since 2.5.5
|
7 |
+
*/
|
8 |
+
class Toolset_Relationship_Query_Cardinality_Match_Conjunction implements IToolset_Relationship_Query_Cardinality_Match {
|
9 |
+
|
10 |
+
/** @var Toolset_Relationship_Query_Cardinality_Match_Single[] */
|
11 |
+
private $matchers;
|
12 |
+
|
13 |
+
|
14 |
+
public function __construct( $matchers ) {
|
15 |
+
foreach( $matchers as $matcher ) {
|
16 |
+
if( ! $matcher instanceof Toolset_Relationship_Query_Cardinality_Match_Single ) {
|
17 |
+
throw new InvalidArgumentException();
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
$this->matchers = $matchers;
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
public function get_matchers() {
|
26 |
+
return $this->matchers;
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/factory.php
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Factory for building cardinality matchers, especially for the most common cases.
|
5 |
+
*
|
6 |
+
* Do not use this directly outside of the m2m API, but go through
|
7 |
+
* Toolset_Relationship_Query_V2::cardinality().
|
8 |
+
*
|
9 |
+
* Hide away the complexity involving cardinalities and comparing, especially if there are custom limits.
|
10 |
+
*
|
11 |
+
* @since 2.5.5
|
12 |
+
*/
|
13 |
+
class Toolset_Relationship_Query_Cardinality_Match_Factory {
|
14 |
+
|
15 |
+
|
16 |
+
private function create( IToolset_Relationship_Role_Parent_Child $role, $boundary, $operator, $value ) {
|
17 |
+
return new Toolset_Relationship_Query_Cardinality_Match_Single( $role, $boundary, $operator, $value );
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Matches all one-to-many relationships.
|
23 |
+
*
|
24 |
+
* @return Toolset_Relationship_Query_Cardinality_Match_Conjunction
|
25 |
+
*/
|
26 |
+
public function one_to_many() {
|
27 |
+
return new Toolset_Relationship_Query_Cardinality_Match_Conjunction( array(
|
28 |
+
$this->create(
|
29 |
+
new Toolset_Relationship_Role_Parent(),
|
30 |
+
Toolset_Relationship_Cardinality::MAX,
|
31 |
+
Toolset_Relationship_Query_Cardinality_Match_Operators::EQUAL,
|
32 |
+
1
|
33 |
+
),
|
34 |
+
$this->create(
|
35 |
+
new Toolset_Relationship_Role_Child(),
|
36 |
+
Toolset_Relationship_Cardinality::MAX,
|
37 |
+
Toolset_Relationship_Query_Cardinality_Match_Operators::NOT_EQUAL,
|
38 |
+
1
|
39 |
+
)
|
40 |
+
) );
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Matches all one-to-one relationships.
|
46 |
+
*
|
47 |
+
* @return Toolset_Relationship_Query_Cardinality_Match_Conjunction
|
48 |
+
*/
|
49 |
+
public function one_to_one() {
|
50 |
+
return new Toolset_Relationship_Query_Cardinality_Match_Conjunction( array(
|
51 |
+
$this->create(
|
52 |
+
new Toolset_Relationship_Role_Parent(),
|
53 |
+
Toolset_Relationship_Cardinality::MAX,
|
54 |
+
Toolset_Relationship_Query_Cardinality_Match_Operators::EQUAL,
|
55 |
+
1
|
56 |
+
),
|
57 |
+
$this->create(
|
58 |
+
new Toolset_Relationship_Role_Child(),
|
59 |
+
Toolset_Relationship_Cardinality::MAX,
|
60 |
+
Toolset_Relationship_Query_Cardinality_Match_Operators::EQUAL,
|
61 |
+
1
|
62 |
+
)
|
63 |
+
) );
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Matches all one-to-one and one-to-many relationships.
|
70 |
+
*
|
71 |
+
* @return Toolset_Relationship_Query_Cardinality_Match_Single
|
72 |
+
*/
|
73 |
+
public function one_to_something() {
|
74 |
+
return $this->create(
|
75 |
+
new Toolset_Relationship_Role_Parent(),
|
76 |
+
Toolset_Relationship_Cardinality::MAX,
|
77 |
+
Toolset_Relationship_Query_Cardinality_Match_Operators::EQUAL,
|
78 |
+
1
|
79 |
+
);
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Matches all many-to-many relationships.
|
85 |
+
*
|
86 |
+
* @return Toolset_Relationship_Query_Cardinality_Match_Conjunction
|
87 |
+
*/
|
88 |
+
public function many_to_many() {
|
89 |
+
return new Toolset_Relationship_Query_Cardinality_Match_Conjunction( array(
|
90 |
+
$this->create(
|
91 |
+
new Toolset_Relationship_Role_Parent(),
|
92 |
+
Toolset_Relationship_Cardinality::MAX,
|
93 |
+
Toolset_Relationship_Query_Cardinality_Match_Operators::NOT_EQUAL,
|
94 |
+
1
|
95 |
+
),
|
96 |
+
$this->create(
|
97 |
+
new Toolset_Relationship_Role_Child(),
|
98 |
+
Toolset_Relationship_Cardinality::MAX,
|
99 |
+
Toolset_Relationship_Query_Cardinality_Match_Operators::NOT_EQUAL,
|
100 |
+
1
|
101 |
+
)
|
102 |
+
) );
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Matches all relationships with the exact cardinality.
|
108 |
+
*
|
109 |
+
* Keep in mind the implications for relationships with custom limits.
|
110 |
+
* Always prefer another method if you can.
|
111 |
+
*
|
112 |
+
* @param Toolset_Relationship_Cardinality $cardinality
|
113 |
+
*
|
114 |
+
* @return Toolset_Relationship_Query_Cardinality_Match_Conjunction
|
115 |
+
*/
|
116 |
+
public function by_cardinality( Toolset_Relationship_Cardinality $cardinality ) {
|
117 |
+
return new Toolset_Relationship_Query_Cardinality_Match_Conjunction( array(
|
118 |
+
$this->create(
|
119 |
+
new Toolset_Relationship_Role_Parent(),
|
120 |
+
Toolset_Relationship_Cardinality::MAX,
|
121 |
+
Toolset_Relationship_Query_Cardinality_Match_Operators::EQUAL,
|
122 |
+
$cardinality->get_limit(
|
123 |
+
Toolset_Relationship_Role::PARENT,
|
124 |
+
Toolset_Relationship_Cardinality::MAX
|
125 |
+
)
|
126 |
+
),
|
127 |
+
$this->create(
|
128 |
+
new Toolset_Relationship_Role_Parent(),
|
129 |
+
Toolset_Relationship_Cardinality::MIN,
|
130 |
+
Toolset_Relationship_Query_Cardinality_Match_Operators::EQUAL,
|
131 |
+
$cardinality->get_limit(
|
132 |
+
Toolset_Relationship_Role::PARENT,
|
133 |
+
Toolset_Relationship_Cardinality::MIN
|
134 |
+
)
|
135 |
+
),
|
136 |
+
$this->create(
|
137 |
+
new Toolset_Relationship_Role_Child(),
|
138 |
+
Toolset_Relationship_Cardinality::MAX,
|
139 |
+
Toolset_Relationship_Query_Cardinality_Match_Operators::EQUAL,
|
140 |
+
$cardinality->get_limit(
|
141 |
+
Toolset_Relationship_Role::CHILD,
|
142 |
+
Toolset_Relationship_Cardinality::MAX
|
143 |
+
)
|
144 |
+
),
|
145 |
+
$this->create(
|
146 |
+
new Toolset_Relationship_Role_Child(),
|
147 |
+
Toolset_Relationship_Cardinality::MIN,
|
148 |
+
Toolset_Relationship_Query_Cardinality_Match_Operators::EQUAL,
|
149 |
+
$cardinality->get_limit(
|
150 |
+
Toolset_Relationship_Role::CHILD,
|
151 |
+
Toolset_Relationship_Cardinality::MIN
|
152 |
+
)
|
153 |
+
),
|
154 |
+
) );
|
155 |
+
}
|
156 |
+
|
157 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/interface.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* An empty interface just to recognize cardinality matchers accepted by
|
5 |
+
* Toolset_Relationship_Query_Condition_Has_Cardinality.
|
6 |
+
*
|
7 |
+
* @since 2.5.5
|
8 |
+
*/
|
9 |
+
interface IToolset_Relationship_Query_Cardinality_Match {
|
10 |
+
|
11 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/operators.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Enum class with accepted operators for Toolset_Relationship_Query_Cardinality_Match_Single.
|
5 |
+
*
|
6 |
+
* @since 2.5.5
|
7 |
+
*/
|
8 |
+
class Toolset_Relationship_Query_Cardinality_Match_Operators {
|
9 |
+
|
10 |
+
// these must be valid MySQL operators
|
11 |
+
const EQUAL = '=';
|
12 |
+
const LOWER_THAN = '<';
|
13 |
+
const LOWER_OR_EQUAL = '<=';
|
14 |
+
const HIGHER_THAN = '>';
|
15 |
+
const HIGHER_OR_EQUAL = '>=';
|
16 |
+
const NOT_EQUAL = '!=';
|
17 |
+
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return string[] All valid operators.
|
21 |
+
*/
|
22 |
+
public static function all() {
|
23 |
+
return array(
|
24 |
+
self::EQUAL,
|
25 |
+
self::LOWER_THAN,
|
26 |
+
self::LOWER_OR_EQUAL,
|
27 |
+
self::HIGHER_THAN,
|
28 |
+
self::HIGHER_OR_EQUAL,
|
29 |
+
self::NOT_EQUAL
|
30 |
+
);
|
31 |
+
}
|
32 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/relationship_query/cardinality_match/single.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Cardinality matcher that holds a single rule for one of the four cardinality values.
|
5 |
+
*
|
6 |
+
* These can be conjuncted together via Toolset_Relationship_Query_Cardinality_Match_Conjunction.
|
7 |
+
* @since 2.5.5
|
8 |
+
*/
|
9 |
+
class Toolset_Relationship_Query_Cardinality_Match_Single implements IToolset_Relationship_Query_Cardinality_Match {
|
10 |
+
|
11 |
+
|
12 |
+
/** @var IToolset_Relationship_Role_Parent_Child */
|
13 |
+
private $role;
|
14 |
+
|
15 |
+
/** @var string */
|
16 |
+
private $boundary;
|
17 |
+
|
18 |
+
/** @var string */
|
19 |
+
private $operator;
|
20 |
+
|
21 |
+
/** @var int */
|
22 |
+
private $value;
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Toolset_Relationship_Query_Cardinality_Match_Single constructor.
|
27 |
+
*
|
28 |
+
* @param IToolset_Relationship_Role_Parent_Child $role
|
29 |
+
* @param string $boundary Which cardinality boundary this involves (use MIN or MAX constants
|
30 |
+
* on the Toolset_Relationship_Cardinality class).
|
31 |
+
* @param string $operator Operator to compare the cardinality with given value (use one of the
|
32 |
+
* operators defined in Toolset_Relationship_Query_Cardinality_Match_Operators).
|
33 |
+
* @param int $value Value to compare the cardinality to.
|
34 |
+
*/
|
35 |
+
public function __construct(
|
36 |
+
IToolset_Relationship_Role_Parent_Child $role,
|
37 |
+
$boundary,
|
38 |
+
$operator,
|
39 |
+
$value
|
40 |
+
) {
|
41 |
+
if (
|
42 |
+
! in_array(
|
43 |
+
$boundary,
|
44 |
+
array( Toolset_Relationship_Cardinality::MAX, Toolset_Relationship_Cardinality::MIN )
|
45 |
+
)
|
46 |
+
|| ! in_array( $operator, Toolset_Relationship_Query_Cardinality_Match_Operators::all() )
|
47 |
+
|| ! Toolset_Utils::is_integer( $value )
|
48 |
+
|| $value <= Toolset_Relationship_Cardinality::INVALID_VALUE
|
49 |
+
) {
|
50 |
+
throw new InvalidArgumentException();
|
51 |
+
}
|
52 |
+
|
53 |
+
$this->role = $role;
|
54 |
+
$this->boundary = $boundary;
|
55 |
+
$this->operator = $operator;
|
56 |
+
$this->value = (int) $value;
|
57 |
+
}
|
58 |
+
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return IToolset_Relationship_Role_Parent_Child
|
62 |
+
*/
|
63 |
+
public function get_role() {
|
64 |
+
return $this->role;
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
public function get_boundary() {
|
72 |
+
return $this->boundary;
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @return string
|
78 |
+
*/
|
79 |
+
public function get_operator() {
|
80 |
+
return $this->operator;
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @return int
|
86 |
+
*/
|
87 |
+
public function get_value() {
|
88 |
+
return $this->value;
|
89 |
+
}
|
90 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/has_cardinality.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Condition that a relationship cardinality matches certain constraints.
|
5 |
+
*
|
6 |
+
* The constraits are defined by a "matcher" object. See the "has_cardinality" method on the
|
7 |
+
* query class for more information.
|
8 |
+
*
|
9 |
+
* @since 2.5.5
|
10 |
+
*/
|
11 |
+
class Toolset_Relationship_Query_Condition_Has_Cardinality extends Toolset_Relationship_Query_Condition {
|
12 |
+
|
13 |
+
/** @var IToolset_Relationship_Query_Cardinality_Match */
|
14 |
+
private $cardinality_match;
|
15 |
+
|
16 |
+
|
17 |
+
/** @var Toolset_Relationship_Database_Operations */
|
18 |
+
private $database_operations;
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Toolset_Relationship_Query_Condition_Has_Cardinality constructor.
|
23 |
+
*
|
24 |
+
* @param IToolset_Relationship_Query_Cardinality_Match $cardinality_match
|
25 |
+
* @param Toolset_Relationship_Database_Operations|null $database_operations_di
|
26 |
+
*/
|
27 |
+
public function __construct(
|
28 |
+
IToolset_Relationship_Query_Cardinality_Match $cardinality_match,
|
29 |
+
Toolset_Relationship_Database_Operations $database_operations_di = null
|
30 |
+
) {
|
31 |
+
$this->cardinality_match = $cardinality_match;
|
32 |
+
$this->database_operations = (
|
33 |
+
null === $database_operations_di
|
34 |
+
? new Toolset_Relationship_Database_Operations()
|
35 |
+
: $database_operations_di
|
36 |
+
);
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get a part of the WHERE clause that applies the condition.
|
42 |
+
*
|
43 |
+
* @return string Valid part of a MySQL query, so that it can be
|
44 |
+
* used in WHERE ( $condition1 ) AND ( $condition2 ) AND ( $condition3 ) ...
|
45 |
+
*/
|
46 |
+
public function get_where_clause() {
|
47 |
+
if( $this->cardinality_match instanceof Toolset_Relationship_Query_Cardinality_Match_Single ) {
|
48 |
+
return $this->process_matcher_set( array( $this->cardinality_match ) );
|
49 |
+
} elseif( $this->cardinality_match instanceof Toolset_Relationship_Query_Cardinality_Match_Conjunction ) {
|
50 |
+
return $this->process_matcher_set( $this->cardinality_match->get_matchers() );
|
51 |
+
} else {
|
52 |
+
throw new RuntimeException( 'Unsupported cardinality matcher.' );
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Process a set of single matchers into a single WHERE clause (conjunction).
|
59 |
+
*
|
60 |
+
* @param Toolset_Relationship_Query_Cardinality_Match_Single[] $matchers
|
61 |
+
*
|
62 |
+
* @return string
|
63 |
+
*/
|
64 |
+
private function process_matcher_set( $matchers ) {
|
65 |
+
$where_clauses = array();
|
66 |
+
foreach( $matchers as $matcher ) {
|
67 |
+
$where_clauses[] = $this->process_single_matcher_rule( $matcher );
|
68 |
+
}
|
69 |
+
|
70 |
+
$result = ' ( ' . implode( ' ) AND ( ', $where_clauses ) . ' ) ';
|
71 |
+
|
72 |
+
return $result;
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Turn a single cardinality matcher into a MySQL WHERE clause.
|
78 |
+
*
|
79 |
+
* @param Toolset_Relationship_Query_Cardinality_Match_Single $matcher
|
80 |
+
*
|
81 |
+
* @return string
|
82 |
+
*/
|
83 |
+
private function process_single_matcher_rule( $matcher ) {
|
84 |
+
|
85 |
+
$column_id = (
|
86 |
+
$matcher->get_boundary() === Toolset_Relationship_Cardinality::MAX
|
87 |
+
? Toolset_Relationship_Database_Operations::COLUMN_CARDINALITY_MAX
|
88 |
+
: Toolset_Relationship_Database_Operations::COLUMN_CARDINALITY_MIN
|
89 |
+
);
|
90 |
+
|
91 |
+
$column_name = $this->database_operations->role_to_column(
|
92 |
+
$matcher->get_role(),
|
93 |
+
$column_id
|
94 |
+
);
|
95 |
+
|
96 |
+
$where = sprintf(
|
97 |
+
'relationships.%s %s %d',
|
98 |
+
$column_name,
|
99 |
+
$matcher->get_operator(),
|
100 |
+
$matcher->get_value()
|
101 |
+
);
|
102 |
+
|
103 |
+
return $where;
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/origin.php
CHANGED
@@ -34,7 +34,7 @@ class Toolset_Relationship_Query_Condition_Origin extends Toolset_Relationship_Q
|
|
34 |
*/
|
35 |
public function get_where_clause() {
|
36 |
return sprintf(
|
37 |
-
"
|
38 |
esc_sql( $this->origin )
|
39 |
);
|
40 |
}
|
34 |
*/
|
35 |
public function get_where_clause() {
|
36 |
return sprintf(
|
37 |
+
"relationships.origin = '%s'",
|
38 |
esc_sql( $this->origin )
|
39 |
);
|
40 |
}
|
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/tautology.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* A condition that is always true.
|
5 |
+
*
|
6 |
+
* It can be useful in situations where we need to return a condition object but don't want to influence
|
7 |
+
* the query.
|
8 |
+
*
|
9 |
+
* Remember, the first rule of the Tautology Club is the first rule of the Tautology Club!
|
10 |
+
*
|
11 |
+
* @since 2.5.6
|
12 |
+
*/
|
13 |
+
class Toolset_Relationship_Query_Condition_Tautology extends Toolset_Relationship_Query_Condition {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Get a part of the WHERE clause that applies the condition.
|
17 |
+
*
|
18 |
+
* @return string Valid part of a MySQL query, so that it can be
|
19 |
+
* used in WHERE ( $condition1 ) AND ( $condition2 ) AND ( $condition3 ) ...
|
20 |
+
*/
|
21 |
+
public function get_where_clause() {
|
22 |
+
return ' 1 = 1 ';
|
23 |
+
}
|
24 |
+
}
|
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition_factory.php
CHANGED
@@ -108,4 +108,27 @@ class Toolset_Relationship_Query_Condition_Factory {
|
|
108 |
}
|
109 |
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
}
|
108 |
}
|
109 |
|
110 |
|
111 |
+
/**
|
112 |
+
* Condition that a relationship cardinality matches certain constraints.
|
113 |
+
*
|
114 |
+
* @param IToolset_Relationship_Query_Cardinality_Match $cardinality_match
|
115 |
+
*
|
116 |
+
* @return Toolset_Relationship_Query_Condition_Has_Cardinality
|
117 |
+
*/
|
118 |
+
public function has_cardinality( IToolset_Relationship_Query_Cardinality_Match $cardinality_match ) {
|
119 |
+
return new Toolset_Relationship_Query_Condition_Has_Cardinality( $cardinality_match );
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
/**
|
124 |
+
* A condition that is always true.
|
125 |
+
*
|
126 |
+
* @since 2.5.6
|
127 |
+
* @return Toolset_Relationship_Query_Condition_Tautology
|
128 |
+
*/
|
129 |
+
public function tautology() {
|
130 |
+
return new Toolset_Relationship_Query_Condition_Tautology();
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
}
|
vendor/toolset/toolset-common/inc/m2m/relationship_query/relationship_query_v2.php
CHANGED
@@ -31,10 +31,12 @@
|
|
31 |
* ->get_results();
|
32 |
*
|
33 |
* Note:
|
34 |
-
* - If no is_active() condition is
|
35 |
* active and non-active relationship definitions, you need to manually add is_active('*').
|
36 |
-
* - If no has_active_post_types() condition is
|
37 |
-
* for both parent and child role.
|
|
|
|
|
38 |
*
|
39 |
* @since m2m
|
40 |
*/
|
@@ -68,6 +70,10 @@ class Toolset_Relationship_Query_V2 implements IToolset_Query {
|
|
68 |
private $condition_factory;
|
69 |
|
70 |
|
|
|
|
|
|
|
|
|
71 |
/**
|
72 |
* Toolset_Relationship_Query_V2 constructor.
|
73 |
*
|
@@ -77,6 +83,7 @@ class Toolset_Relationship_Query_V2 implements IToolset_Query {
|
|
77 |
* @param Toolset_Relationship_Database_Operations|null $database_operations_di
|
78 |
* @param Toolset_Relationship_Query_Sql_Expression_Builder|null $expression_builder_di
|
79 |
* @param Toolset_Relationship_Query_Condition_Factory|null $condition_factory_di
|
|
|
80 |
*/
|
81 |
public function __construct(
|
82 |
wpdb $wpdb_di = null,
|
@@ -84,7 +91,8 @@ class Toolset_Relationship_Query_V2 implements IToolset_Query {
|
|
84 |
Toolset_Relationship_Database_Unique_Table_Alias $unique_table_alias_di = null,
|
85 |
Toolset_Relationship_Database_Operations $database_operations_di = null,
|
86 |
Toolset_Relationship_Query_Sql_Expression_Builder $expression_builder_di = null,
|
87 |
-
Toolset_Relationship_Query_Condition_Factory $condition_factory_di = null
|
|
|
88 |
) {
|
89 |
|
90 |
if( null === $wpdb_di ) {
|
@@ -117,6 +125,8 @@ class Toolset_Relationship_Query_V2 implements IToolset_Query {
|
|
117 |
? new Toolset_Relationship_Query_Condition_Factory()
|
118 |
: $condition_factory_di
|
119 |
);
|
|
|
|
|
120 |
}
|
121 |
|
122 |
|
@@ -129,15 +139,6 @@ class Toolset_Relationship_Query_V2 implements IToolset_Query {
|
|
129 |
*/
|
130 |
public function add( IToolset_Relationship_Query_Condition $condition ) {
|
131 |
$this->conditions[] = $condition;
|
132 |
-
|
133 |
-
if( $condition instanceof Toolset_Relationship_Query_Condition_Is_Active ) {
|
134 |
-
$this->has_is_active_condition = true;
|
135 |
-
}
|
136 |
-
|
137 |
-
if( $condition instanceof Toolset_Relationship_Query_Condition_Has_Active_Types ) {
|
138 |
-
$this->has_is_post_type_active_condition = true;
|
139 |
-
}
|
140 |
-
|
141 |
return $this;
|
142 |
}
|
143 |
|
@@ -245,7 +246,7 @@ class Toolset_Relationship_Query_V2 implements IToolset_Query {
|
|
245 |
/**
|
246 |
* Condition that the relationship involves a certain domain.
|
247 |
*
|
248 |
-
* @param string $domain_name
|
249 |
* @param IToolset_Relationship_Role_Parent_Child|null $in_role If null is provided, the type
|
250 |
* can be in both parent or child role for the condition to be true.
|
251 |
*
|
@@ -296,6 +297,32 @@ class Toolset_Relationship_Query_V2 implements IToolset_Query {
|
|
296 |
}
|
297 |
|
298 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
/**
|
300 |
* Condition that the relationship was migrated from the legacy implementation.
|
301 |
*
|
@@ -316,6 +343,7 @@ class Toolset_Relationship_Query_V2 implements IToolset_Query {
|
|
316 |
* @return IToolset_Relationship_Query_Condition
|
317 |
*/
|
318 |
public function is_active( $should_be_active = true ) {
|
|
|
319 |
return $this->condition_factory->is_active( $should_be_active );
|
320 |
}
|
321 |
|
@@ -326,17 +354,74 @@ class Toolset_Relationship_Query_V2 implements IToolset_Query {
|
|
326 |
* @param bool $has_active_post_types
|
327 |
* @param IToolset_Relationship_Role_Parent_Child|null $in_role
|
328 |
*
|
329 |
-
* @return IToolset_Relationship_Query_Condition
|
330 |
*/
|
331 |
public function has_active_post_types( $has_active_post_types = true, IToolset_Relationship_Role_Parent_Child $in_role = null ) {
|
332 |
if( null === $in_role ) {
|
333 |
-
return $this->
|
334 |
$this->has_active_post_types( $has_active_post_types, new Toolset_Relationship_Role_Parent() ),
|
335 |
$this->has_active_post_types( $has_active_post_types, new Toolset_Relationship_Role_Child() )
|
336 |
);
|
337 |
}
|
338 |
|
|
|
339 |
return $this->condition_factory->has_active_post_types( $has_active_post_types, $in_role );
|
340 |
}
|
341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
}
|
31 |
* ->get_results();
|
32 |
*
|
33 |
* Note:
|
34 |
+
* - If no is_active() condition is used when constructing the query, is_active(true) is used. To get both
|
35 |
* active and non-active relationship definitions, you need to manually add is_active('*').
|
36 |
+
* - If no has_active_post_types() condition is used when constructing the query, has_active_post_types(true)
|
37 |
+
* is used for both parent and child role.
|
38 |
+
* - This mechanism doesn't recognize where, how and if these conditions are actually applied, so even
|
39 |
+
* $query->do_if( false, $query->is_active( true ) ) will disable the default is_active() condition.
|
40 |
*
|
41 |
* @since m2m
|
42 |
*/
|
70 |
private $condition_factory;
|
71 |
|
72 |
|
73 |
+
/** @var null|Toolset_Relationship_Query_Cardinality_Match_Factory */
|
74 |
+
private $_cardinality_match_factory;
|
75 |
+
|
76 |
+
|
77 |
/**
|
78 |
* Toolset_Relationship_Query_V2 constructor.
|
79 |
*
|
83 |
* @param Toolset_Relationship_Database_Operations|null $database_operations_di
|
84 |
* @param Toolset_Relationship_Query_Sql_Expression_Builder|null $expression_builder_di
|
85 |
* @param Toolset_Relationship_Query_Condition_Factory|null $condition_factory_di
|
86 |
+
* @param Toolset_Relationship_Query_Cardinality_Match_Factory|null $cardinality_match_factory_di
|
87 |
*/
|
88 |
public function __construct(
|
89 |
wpdb $wpdb_di = null,
|
91 |
Toolset_Relationship_Database_Unique_Table_Alias $unique_table_alias_di = null,
|
92 |
Toolset_Relationship_Database_Operations $database_operations_di = null,
|
93 |
Toolset_Relationship_Query_Sql_Expression_Builder $expression_builder_di = null,
|
94 |
+
Toolset_Relationship_Query_Condition_Factory $condition_factory_di = null,
|
95 |
+
Toolset_Relationship_Query_Cardinality_Match_Factory $cardinality_match_factory_di = null
|
96 |
) {
|
97 |
|
98 |
if( null === $wpdb_di ) {
|
125 |
? new Toolset_Relationship_Query_Condition_Factory()
|
126 |
: $condition_factory_di
|
127 |
);
|
128 |
+
|
129 |
+
$this->_cardinality_match_factory = $cardinality_match_factory_di;
|
130 |
}
|
131 |
|
132 |
|
139 |
*/
|
140 |
public function add( IToolset_Relationship_Query_Condition $condition ) {
|
141 |
$this->conditions[] = $condition;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
return $this;
|
143 |
}
|
144 |
|
246 |
/**
|
247 |
* Condition that the relationship involves a certain domain.
|
248 |
*
|
249 |
+
* @param string $domain_name One of the Toolset_Element_Domain values.
|
250 |
* @param IToolset_Relationship_Role_Parent_Child|null $in_role If null is provided, the type
|
251 |
* can be in both parent or child role for the condition to be true.
|
252 |
*
|
297 |
}
|
298 |
|
299 |
|
300 |
+
/**
|
301 |
+
* Condition that the relationship has a certain type and a domain in a given role.
|
302 |
+
*
|
303 |
+
* @param string $type
|
304 |
+
* @param string $domain One of the Toolset_Element_Domain values.
|
305 |
+
* @param IToolset_Relationship_Role_Parent_Child|null $in_role If null is provided, the type
|
306 |
+
* can be in both parent or child role for the condition to be true.
|
307 |
+
*
|
308 |
+
* @return IToolset_Relationship_Query_Condition
|
309 |
+
* @since 2.5.6
|
310 |
+
*/
|
311 |
+
public function has_domain_and_type( $type, $domain, $in_role = null ) {
|
312 |
+
if( null === $in_role ) {
|
313 |
+
return $this->do_or(
|
314 |
+
$this->has_domain_and_type( $type, $domain, new Toolset_Relationship_Role_Parent() ),
|
315 |
+
$this->has_domain_and_type( $type, $domain, new Toolset_Relationship_Role_Child() )
|
316 |
+
);
|
317 |
+
}
|
318 |
+
|
319 |
+
return $this->do_and(
|
320 |
+
$this->condition_factory->has_domain( $domain, $in_role ),
|
321 |
+
$this->condition_factory->has_type( $type, $in_role )
|
322 |
+
);
|
323 |
+
}
|
324 |
+
|
325 |
+
|
326 |
/**
|
327 |
* Condition that the relationship was migrated from the legacy implementation.
|
328 |
*
|
343 |
* @return IToolset_Relationship_Query_Condition
|
344 |
*/
|
345 |
public function is_active( $should_be_active = true ) {
|
346 |
+
$this->has_is_active_condition = true;
|
347 |
return $this->condition_factory->is_active( $should_be_active );
|
348 |
}
|
349 |
|
354 |
* @param bool $has_active_post_types
|
355 |
* @param IToolset_Relationship_Role_Parent_Child|null $in_role
|
356 |
*
|
357 |
+
* @return IToolset_Relationship_Query_Condition
|
358 |
*/
|
359 |
public function has_active_post_types( $has_active_post_types = true, IToolset_Relationship_Role_Parent_Child $in_role = null ) {
|
360 |
if( null === $in_role ) {
|
361 |
+
return $this->do_and(
|
362 |
$this->has_active_post_types( $has_active_post_types, new Toolset_Relationship_Role_Parent() ),
|
363 |
$this->has_active_post_types( $has_active_post_types, new Toolset_Relationship_Role_Child() )
|
364 |
);
|
365 |
}
|
366 |
|
367 |
+
$this->has_is_post_type_active_condition = true;
|
368 |
return $this->condition_factory->has_active_post_types( $has_active_post_types, $in_role );
|
369 |
}
|
370 |
|
371 |
+
|
372 |
+
/**
|
373 |
+
* Get a factory of cardinality constrains, which can be used as an argument for $this->has_cardinality().
|
374 |
+
*
|
375 |
+
* @return Toolset_Relationship_Query_Cardinality_Match_Factory
|
376 |
+
*/
|
377 |
+
public function cardinality() {
|
378 |
+
if( null === $this->_cardinality_match_factory ) {
|
379 |
+
$this->_cardinality_match_factory = new Toolset_Relationship_Query_Cardinality_Match_Factory();
|
380 |
+
}
|
381 |
+
|
382 |
+
return $this->_cardinality_match_factory;
|
383 |
+
}
|
384 |
+
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Condition that a relationship has a certain cardinality.
|
388 |
+
*
|
389 |
+
* Use methods on $this->cardinality() to obtain a valid argument for this method.
|
390 |
+
*
|
391 |
+
* @param IToolset_Relationship_Query_Cardinality_Match $cardinality_match Object
|
392 |
+
* that holds cardinality constraints.
|
393 |
+
*
|
394 |
+
* @return IToolset_Relationship_Query_Condition
|
395 |
+
*/
|
396 |
+
public function has_cardinality( IToolset_Relationship_Query_Cardinality_Match $cardinality_match ) {
|
397 |
+
return $this->condition_factory->has_cardinality( $cardinality_match );
|
398 |
+
}
|
399 |
+
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Choose a query condition depending on a boolean expression.
|
403 |
+
*
|
404 |
+
* @param bool $statement A boolean condition statement.
|
405 |
+
* @param IToolset_Relationship_Query_Condition $if_branch Query condition that will be used
|
406 |
+
* if the statement is true.
|
407 |
+
* @param IToolset_Relationship_Query_Condition|null $else_branch Query condition that will be
|
408 |
+
* used if the statement is false. If none is provided, a tautology is used (always true).
|
409 |
+
*
|
410 |
+
* @return IToolset_Relationship_Query_Condition
|
411 |
+
* @since 2.5.6
|
412 |
+
*/
|
413 |
+
public function do_if(
|
414 |
+
$statement,
|
415 |
+
IToolset_Relationship_Query_Condition $if_branch,
|
416 |
+
IToolset_Relationship_Query_Condition $else_branch = null
|
417 |
+
) {
|
418 |
+
if( $statement ) {
|
419 |
+
return $if_branch;
|
420 |
+
} elseif( null !== $else_branch ) {
|
421 |
+
return $else_branch;
|
422 |
+
} else {
|
423 |
+
return $this->condition_factory->tautology();
|
424 |
+
}
|
425 |
+
}
|
426 |
+
|
427 |
}
|
vendor/toolset/toolset-common/inc/m2m/relationship_role/role.php
CHANGED
@@ -117,12 +117,16 @@ abstract class Toolset_Relationship_Role {
|
|
117 |
*
|
118 |
* @param $first_element
|
119 |
* @param $second_element
|
120 |
-
* @param string $first_role Role of the first element (parent or child expected)
|
121 |
*
|
122 |
* @return array Two provided elements orderd as parent and child.
|
123 |
*/
|
124 |
public static function sort_elements( $first_element, $second_element, $first_role ) {
|
125 |
|
|
|
|
|
|
|
|
|
126 |
if( self::PARENT === $first_role ) {
|
127 |
return array( $first_element, $second_element );
|
128 |
} elseif( self::CHILD === $first_role ) {
|
117 |
*
|
118 |
* @param $first_element
|
119 |
* @param $second_element
|
120 |
+
* @param string|IToolset_Relationship_Role_Parent_Child $first_role Role of the first element (parent or child expected)
|
121 |
*
|
122 |
* @return array Two provided elements orderd as parent and child.
|
123 |
*/
|
124 |
public static function sort_elements( $first_element, $second_element, $first_role ) {
|
125 |
|
126 |
+
if( $first_role instanceof IToolset_Relationship_Role_Parent_Child ) {
|
127 |
+
$first_role = $first_role->get_name();
|
128 |
+
}
|
129 |
+
|
130 |
if( self::PARENT === $first_role ) {
|
131 |
return array( $first_element, $second_element );
|
132 |
} elseif( self::CHILD === $first_role ) {
|
vendor/toolset/toolset-common/inc/toolset.assets.manager.class.php
CHANGED
@@ -808,34 +808,37 @@ class Toolset_Assets_Manager {
|
|
808 |
);
|
809 |
|
810 |
global $pagenow;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
811 |
|
812 |
$this->localize_script(
|
813 |
self::SCRIPT_TOOLSET_SHORTCODE,
|
814 |
'toolset_shortcode_i18n',
|
815 |
-
|
816 |
-
'action' => array(
|
817 |
-
'insert' => __( 'Insert shortcode', 'wpv-views' ),
|
818 |
-
'create' => __( 'Create shortcode', 'wpv-views' ),
|
819 |
-
'update' => __( 'Update shortcode', 'wpv-views' ),
|
820 |
-
'close' => __( 'Close', 'wpv-views' ),
|
821 |
-
'cancel' => __( 'Cancel', 'wpv-views' ),
|
822 |
-
'back' => __( 'Back', 'wpv-views' ),
|
823 |
-
'save' => __( 'Save settings', 'wpv-views' ),
|
824 |
-
'loading' => __( 'Loading...', 'wpv-views' ),
|
825 |
-
),
|
826 |
-
'title' => array(
|
827 |
-
'generated' => __( 'Generated shortcode', 'wpv-views' ),
|
828 |
-
),
|
829 |
-
'validation' => array(
|
830 |
-
'mandatory' => __( 'This option is mandatory ', 'wpv-views' ),
|
831 |
-
'number' => __( 'Please enter a valid number', 'wpv-views' ),
|
832 |
-
'numberlist' => __( 'Please enter a valid comma separated number list', 'wpv-views' ),
|
833 |
-
'url' => __( 'Please enter a valid URL', 'wpv-views' ),
|
834 |
-
|
835 |
-
),
|
836 |
-
'ajaxurl' => admin_url( 'admin-ajax.php', ( is_ssl() ? 'https' : 'http' ) ),
|
837 |
-
'pagenow' => $pagenow
|
838 |
-
)
|
839 |
);
|
840 |
|
841 |
return apply_filters( 'toolset_add_registered_script', $this->scripts );
|
808 |
);
|
809 |
|
810 |
global $pagenow;
|
811 |
+
$toolset_shortcode_i18n = array(
|
812 |
+
'action' => array(
|
813 |
+
'insert' => __( 'Insert shortcode', 'wpv-views' ),
|
814 |
+
'create' => __( 'Create shortcode', 'wpv-views' ),
|
815 |
+
'update' => __( 'Update shortcode', 'wpv-views' ),
|
816 |
+
'close' => __( 'Close', 'wpv-views' ),
|
817 |
+
'cancel' => __( 'Cancel', 'wpv-views' ),
|
818 |
+
'back' => __( 'Back', 'wpv-views' ),
|
819 |
+
'save' => __( 'Save settings', 'wpv-views' ),
|
820 |
+
'loading' => __( 'Loading...', 'wpv-views' ),
|
821 |
+
),
|
822 |
+
'title' => array(
|
823 |
+
'generated' => __( 'Generated shortcode', 'wpv-views' ),
|
824 |
+
),
|
825 |
+
'validation' => array(
|
826 |
+
'mandatory' => __( 'This option is mandatory ', 'wpv-views' ),
|
827 |
+
'number' => __( 'Please enter a valid number', 'wpv-views' ),
|
828 |
+
'numberlist' => __( 'Please enter a valid comma separated number list', 'wpv-views' ),
|
829 |
+
'url' => __( 'Please enter a valid URL', 'wpv-views' ),
|
830 |
+
|
831 |
+
),
|
832 |
+
'ajaxurl' => admin_url( 'admin-ajax.php', ( is_ssl() ? 'https' : 'http' ) ),
|
833 |
+
'pagenow' => $pagenow
|
834 |
+
);
|
835 |
+
|
836 |
+
$toolset_shortcode_i18n = apply_filters( 'toolset_filter_shortcode_script_i18n', $toolset_shortcode_i18n );
|
837 |
|
838 |
$this->localize_script(
|
839 |
self::SCRIPT_TOOLSET_SHORTCODE,
|
840 |
'toolset_shortcode_i18n',
|
841 |
+
$toolset_shortcode_i18n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
842 |
);
|
843 |
|
844 |
return apply_filters( 'toolset_add_registered_script', $this->scripts );
|
vendor/toolset/toolset-common/inc/toolset.shortcode.generator.class.php
CHANGED
@@ -1,30 +1,32 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
*
|
9 |
-
*
|
10 |
-
*
|
11 |
-
*
|
12 |
-
*
|
13 |
-
*
|
14 |
-
*
|
15 |
-
*
|
16 |
-
*
|
17 |
-
*
|
18 |
-
* '
|
19 |
-
* '
|
20 |
-
*
|
21 |
-
*
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
|
|
|
|
|
28 |
|
29 |
abstract class Toolset_Shortcode_Generator {
|
30 |
|
@@ -33,17 +35,20 @@ abstract class Toolset_Shortcode_Generator {
|
|
33 |
private static $target_dialog_added = false;
|
34 |
|
35 |
function __construct() {
|
|
|
36 |
|
37 |
add_action( 'admin_init', array( $this, 'register_shortcodes_admin_bar_items' ), 99 );
|
38 |
add_action( 'admin_bar_menu', array( $this, 'display_shortcodes_admin_bar_items' ), 99 );
|
39 |
add_action( 'admin_footer', array( $this, 'display_shortcodes_target_dialog' ) );
|
40 |
|
41 |
-
add_action( 'toolset_action_require_shortcodes_templates',
|
42 |
|
43 |
-
add_action( 'wp_ajax_toolset_select2_suggest_posts_by_title',
|
44 |
-
add_action( 'wp_ajax_nopriv_toolset_select2_suggest_posts_by_title',
|
45 |
-
add_action( 'wp_ajax_toolset_select2_suggest_users',
|
46 |
-
add_action( 'wp_ajax_nopriv_toolset_select2_suggest_users',
|
|
|
|
|
47 |
}
|
48 |
|
49 |
public function register_shortcodes_admin_bar_items() {
|
@@ -88,7 +93,7 @@ abstract class Toolset_Shortcode_Generator {
|
|
88 |
|
89 |
}
|
90 |
|
91 |
-
|
92 |
* Add admin bar main item for shortcodes
|
93 |
*/
|
94 |
public function display_shortcodes_admin_bar_items( $wp_admin_bar ) {
|
@@ -106,9 +111,8 @@ abstract class Toolset_Shortcode_Generator {
|
|
106 |
}
|
107 |
}
|
108 |
|
109 |
-
|
110 |
* General function for creating admin bar menu items
|
111 |
-
*
|
112 |
*/
|
113 |
public static function create_admin_bar_item( $wp_admin_bar, $id, $name, $href, $parent, $classes = null ) {
|
114 |
$args = array(
|
@@ -122,8 +126,6 @@ abstract class Toolset_Shortcode_Generator {
|
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
-
* is_admin_editor_page
|
126 |
-
*
|
127 |
* Helper method to check whether we are on an admin editor page.
|
128 |
* This covers edit pages for posts, terms and users,
|
129 |
* as well as Toolset object edit pages.
|
@@ -160,8 +162,6 @@ abstract class Toolset_Shortcode_Generator {
|
|
160 |
}
|
161 |
|
162 |
/**
|
163 |
-
* is_frontend_editor_page
|
164 |
-
*
|
165 |
* Helper method to check whether we are on an frontend editor page.
|
166 |
* This should cover as many frontend editors as possible.
|
167 |
*
|
@@ -214,7 +214,8 @@ abstract class Toolset_Shortcode_Generator {
|
|
214 |
* Generate the shared Toolset shortcode GUI templates.
|
215 |
*
|
216 |
* @since 2.5.4
|
217 |
-
* @
|
|
|
218 |
*/
|
219 |
public function print_shortcodes_templates() {
|
220 |
|
@@ -228,7 +229,7 @@ abstract class Toolset_Shortcode_Generator {
|
|
228 |
<# if ( _.has( data, 'parameters' ) ) {
|
229 |
_.each( data.parameters, function( parameterValue, parameterKey ) {
|
230 |
#>
|
231 |
-
<span class="toolset-shortcode-gui-attribute-wrapper js-toolset-shortcode-gui-attribute-wrapper js-toolset-shortcode-gui-attribute-wrapper-for-
|
232 |
<input type="hidden" name="{{{parameterKey}}}" value="{{{parameterValue}}}" disabled="disabled" />
|
233 |
</span>
|
234 |
<#
|
@@ -238,22 +239,36 @@ abstract class Toolset_Shortcode_Generator {
|
|
238 |
<# if ( _.size( data.attributes ) > 1 ) { #>
|
239 |
<ul class="js-toolset-shortcode-gui-tabs-list">
|
240 |
<# _.each( data.attributes, function( attributesGroup, groupKey ) { #>
|
|
|
|
|
|
|
|
|
241 |
<li>
|
242 |
<a href="#{{{data.shortcode}}}-{{{groupKey}}}">{{{attributesGroup.header}}}</a>
|
243 |
</li>
|
|
|
244 |
<# }); #>
|
245 |
</ul>
|
246 |
<# } #>
|
247 |
<# _.each( data.attributes, function( attributesGroup, groupKey ) { #>
|
|
|
|
|
|
|
|
|
248 |
<div id="{{{data.shortcode}}}-{{{groupKey}}}">
|
249 |
<h2>{{{attributesGroup.header}}}</h2>
|
250 |
<# _.each( attributesGroup.fields, function( attributeData, attributeKey ) {
|
251 |
if ( _.has( data.templates, 'attributeWrapper' ) ) {
|
252 |
attributeData = _.extend( { shortcode: data.shortcode, attribute: attributeKey, templates: data.templates }, attributeData );
|
253 |
-
|
|
|
|
|
|
|
|
|
254 |
}
|
255 |
}); #>
|
256 |
</div>
|
|
|
257 |
<# }); #>
|
258 |
</div>
|
259 |
<div class="toolset-shortcode-gui-messages js-toolset-shortcode-gui-messages"></div>
|
@@ -267,6 +282,9 @@ abstract class Toolset_Shortcode_Generator {
|
|
267 |
<# if ( _.has( data, 'label' ) ) { #>
|
268 |
<h3>{{{data.label}}}</h3>
|
269 |
<# } #>
|
|
|
|
|
|
|
270 |
<# if (
|
271 |
_.has( data.templates, 'attributes' )
|
272 |
&& _.has( data.templates.attributes, data.type )
|
@@ -278,8 +296,35 @@ abstract class Toolset_Shortcode_Generator {
|
|
278 |
<# } #>
|
279 |
</div>
|
280 |
</script>
|
281 |
-
<script type="text/html" id="tmpl-toolset-shortcode-attribute-
|
282 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
</script>
|
284 |
<script type="text/html" id="tmpl-toolset-shortcode-attribute-radio">
|
285 |
<ul id="{{{data.shortcode}}}-{{{data.attribute}}}">
|
@@ -327,6 +372,194 @@ abstract class Toolset_Shortcode_Generator {
|
|
327 |
>
|
328 |
</select>
|
329 |
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
<script type="text/html" id="tmpl-toolset-shortcode-attribute-post-selector">
|
331 |
<ul id="{{data.shortcode}}}-{{data.attribute}}}">
|
332 |
<li>
|
@@ -382,6 +615,196 @@ abstract class Toolset_Shortcode_Generator {
|
|
382 |
|
383 |
}
|
384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
public function toolset_select2_suggest_posts_by_title() {
|
386 |
if ( ! isset( $_POST['s'] ) ) {
|
387 |
$output = array(
|
@@ -489,5 +912,16 @@ abstract class Toolset_Shortcode_Generator {
|
|
489 |
wp_send_json_error( $output );
|
490 |
}
|
491 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
|
493 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Generic class for generating and controlling shortcodes.
|
5 |
+
*
|
6 |
+
* It manages the Toolset shortcodes admin bar entry.
|
7 |
+
* It generates templates for shortcode attributes, as well as a target dialog for creating shortcodes.
|
8 |
+
* It holds AJAX callbacks executed inside shortcode dialogs.
|
9 |
+
*
|
10 |
+
* Use the filter toolset_shortcode_generator_register_item before admin_init:99
|
11 |
+
* Register your items as follows:
|
12 |
+
* add_filter( 'toolset_shortcode_generator_register_item', 'register_my_shortcodes_in_the_shortcode_generator' );
|
13 |
+
* function register_my_shortcodes_in_the_shortcode_generator( $registered_sections ) {
|
14 |
+
* // Do your logic here to determine whether you need to add your section or not, and check if you need specific assets
|
15 |
+
* // In case you do, register as follows:
|
16 |
+
* $registered_sections['section-id'] = array(
|
17 |
+
* 'id' => 'section-id', // The ID of the item
|
18 |
+
* 'title' => __( 'My fields', 'my-textdomain' ), // The title for the item
|
19 |
+
* 'href' => '#my_anchor', // The href attribute for the link of the item
|
20 |
+
* 'parent' => 'toolset-shortcodes', // Set the parent item as the known 'toolset-shortcodes'
|
21 |
+
* 'meta' => 'js-my-classname' // Cloassname for the li container of the item
|
22 |
+
* );
|
23 |
+
* return $registered_sections;
|
24 |
+
* }
|
25 |
+
*
|
26 |
+
* Note that you will have to take care of displaying the dialog after clicking on the item, and deal with what is should do.
|
27 |
+
*
|
28 |
+
* @since 1.9
|
29 |
+
*/
|
30 |
|
31 |
abstract class Toolset_Shortcode_Generator {
|
32 |
|
35 |
private static $target_dialog_added = false;
|
36 |
|
37 |
function __construct() {
|
38 |
+
add_action( 'init', array( $this, 'register_shortcode_transformer' ) );
|
39 |
|
40 |
add_action( 'admin_init', array( $this, 'register_shortcodes_admin_bar_items' ), 99 );
|
41 |
add_action( 'admin_bar_menu', array( $this, 'display_shortcodes_admin_bar_items' ), 99 );
|
42 |
add_action( 'admin_footer', array( $this, 'display_shortcodes_target_dialog' ) );
|
43 |
|
44 |
+
add_action( 'toolset_action_require_shortcodes_templates', array( $this, 'print_shortcodes_templates' ) );
|
45 |
|
46 |
+
add_action( 'wp_ajax_toolset_select2_suggest_posts_by_title', array( $this, 'toolset_select2_suggest_posts_by_title' ) );
|
47 |
+
add_action( 'wp_ajax_nopriv_toolset_select2_suggest_posts_by_title', array( $this, 'toolset_select2_suggest_posts_by_title' ) );
|
48 |
+
add_action( 'wp_ajax_toolset_select2_suggest_users', array( $this, 'toolset_select2_suggest_users' ) );
|
49 |
+
add_action( 'wp_ajax_nopriv_toolset_select2_suggest_users', array( $this, 'toolset_select2_suggest_users' ) );
|
50 |
+
|
51 |
+
add_filter( 'toolset_filter_shortcode_script_i18n', array( $this, 'extend_script_i18n' ) );
|
52 |
}
|
53 |
|
54 |
public function register_shortcodes_admin_bar_items() {
|
93 |
|
94 |
}
|
95 |
|
96 |
+
/**
|
97 |
* Add admin bar main item for shortcodes
|
98 |
*/
|
99 |
public function display_shortcodes_admin_bar_items( $wp_admin_bar ) {
|
111 |
}
|
112 |
}
|
113 |
|
114 |
+
/**
|
115 |
* General function for creating admin bar menu items
|
|
|
116 |
*/
|
117 |
public static function create_admin_bar_item( $wp_admin_bar, $id, $name, $href, $parent, $classes = null ) {
|
118 |
$args = array(
|
126 |
}
|
127 |
|
128 |
/**
|
|
|
|
|
129 |
* Helper method to check whether we are on an admin editor page.
|
130 |
* This covers edit pages for posts, terms and users,
|
131 |
* as well as Toolset object edit pages.
|
162 |
}
|
163 |
|
164 |
/**
|
|
|
|
|
165 |
* Helper method to check whether we are on an frontend editor page.
|
166 |
* This should cover as many frontend editors as possible.
|
167 |
*
|
214 |
* Generate the shared Toolset shortcode GUI templates.
|
215 |
*
|
216 |
* @since 2.5.4
|
217 |
+
* @todo Move this to a separated dedicated set of template files.
|
218 |
+
* @todo The post and user selector templates are used exclusively by CRED: move to CRED and rename
|
219 |
*/
|
220 |
public function print_shortcodes_templates() {
|
221 |
|
229 |
<# if ( _.has( data, 'parameters' ) ) {
|
230 |
_.each( data.parameters, function( parameterValue, parameterKey ) {
|
231 |
#>
|
232 |
+
<span class="toolset-shortcode-gui-attribute-wrapper js-toolset-shortcode-gui-attribute-wrapper js-toolset-shortcode-gui-attribute-wrapper-for-{{{parameterKey}}}" data-attribute="{{{parameterKey}}}" data-type="parameter">
|
233 |
<input type="hidden" name="{{{parameterKey}}}" value="{{{parameterValue}}}" disabled="disabled" />
|
234 |
</span>
|
235 |
<#
|
239 |
<# if ( _.size( data.attributes ) > 1 ) { #>
|
240 |
<ul class="js-toolset-shortcode-gui-tabs-list">
|
241 |
<# _.each( data.attributes, function( attributesGroup, groupKey ) { #>
|
242 |
+
<# if (
|
243 |
+
_.has( attributesGroup, 'fields' )
|
244 |
+
&& _.size( attributesGroup.fields ) > 0
|
245 |
+
) { #>
|
246 |
<li>
|
247 |
<a href="#{{{data.shortcode}}}-{{{groupKey}}}">{{{attributesGroup.header}}}</a>
|
248 |
</li>
|
249 |
+
<# } #>
|
250 |
<# }); #>
|
251 |
</ul>
|
252 |
<# } #>
|
253 |
<# _.each( data.attributes, function( attributesGroup, groupKey ) { #>
|
254 |
+
<# if (
|
255 |
+
_.has( attributesGroup, 'fields' )
|
256 |
+
&& _.size( attributesGroup.fields ) > 0
|
257 |
+
) { #>
|
258 |
<div id="{{{data.shortcode}}}-{{{groupKey}}}">
|
259 |
<h2>{{{attributesGroup.header}}}</h2>
|
260 |
<# _.each( attributesGroup.fields, function( attributeData, attributeKey ) {
|
261 |
if ( _.has( data.templates, 'attributeWrapper' ) ) {
|
262 |
attributeData = _.extend( { shortcode: data.shortcode, attribute: attributeKey, templates: data.templates }, attributeData );
|
263 |
+
if ( 'group' == attributeData.type ) {
|
264 |
+
print( data.templates.attributeGroupWrapper( attributeData ) );
|
265 |
+
} else {
|
266 |
+
print( data.templates.attributeWrapper( attributeData ) );
|
267 |
+
}
|
268 |
}
|
269 |
}); #>
|
270 |
</div>
|
271 |
+
<# } #>
|
272 |
<# }); #>
|
273 |
</div>
|
274 |
<div class="toolset-shortcode-gui-messages js-toolset-shortcode-gui-messages"></div>
|
282 |
<# if ( _.has( data, 'label' ) ) { #>
|
283 |
<h3>{{{data.label}}}</h3>
|
284 |
<# } #>
|
285 |
+
<# if ( _.has( data, 'pseudolabel' ) ) { #>
|
286 |
+
<strong>{{{data.pseudolabel}}}</strong>
|
287 |
+
<# } #>
|
288 |
<# if (
|
289 |
_.has( data.templates, 'attributes' )
|
290 |
&& _.has( data.templates.attributes, data.type )
|
296 |
<# } #>
|
297 |
</div>
|
298 |
</script>
|
299 |
+
<script type="text/html" id="tmpl-toolset-shortcode-attribute-group-wrapper">
|
300 |
+
<div class="toolset-shortcode-gui-attribute-group js-toolset-shortcode-gui-attribute-group js-toolset-shortcode-gui-attribute-group-for-{{{data.attribute}}}" data-type="group" data-group="{{{data.attribute}}}"<# if ( data.hidden ) { #> style="display:none"<# } #>>
|
301 |
+
<# if ( _.has( data, 'label' ) ) { #>
|
302 |
+
<h3>{{{data.label}}}</h3>
|
303 |
+
<# } #>
|
304 |
+
<#
|
305 |
+
var columns = _.size( data.fields ),
|
306 |
+
columnsWidth = parseInt( 100 / columns );
|
307 |
+
#>
|
308 |
+
<ul class="toolset-shortcode-gui-dialog-item-group js-toolset-shortcode-gui-dialog-item-group">
|
309 |
+
<# _.each( data.fields, function( fieldData, fieldAttribute ) { #>
|
310 |
+
<li style="width:<# print( columnsWidth ); #>%;float:left;">
|
311 |
+
<#
|
312 |
+
fieldData = _.defaults( fieldData, { shortcode: data.shortcode, templates: data.templates } );
|
313 |
+
fieldData = _.defaults( fieldData, { defaultValue: '', required: false, hidden: false, placeholder: '' } );
|
314 |
+
fieldData = _.defaults( fieldData, { defaultForceValue: fieldData.defaultValue } );
|
315 |
+
fieldData.attribute = fieldAttribute;
|
316 |
+
print( data.templates.attributeWrapper( fieldData ) );
|
317 |
+
#>
|
318 |
+
</li>
|
319 |
+
<# }); #>
|
320 |
+
</ul>
|
321 |
+
<# if ( _.has( data, 'description' ) ) { #>
|
322 |
+
<p class="description">{{{data.description}}}</p>
|
323 |
+
<# } #>
|
324 |
+
</div>
|
325 |
+
</script>
|
326 |
+
<script type="text/html" id="tmpl-toolset-shortcode-attribute-text">
|
327 |
+
<input id="{{{data.shortcode}}}-{{{data.attribute}}}" data-type="text" class="js-shortcode-gui-field large-text<# if ( data.required ) { #> js-toolset-shortcode-gui-required<# } #>" value="{{{data.defaultForceValue}}}" placeholder="{{{data.placeholder}}}" type="text">
|
328 |
</script>
|
329 |
<script type="text/html" id="tmpl-toolset-shortcode-attribute-radio">
|
330 |
<ul id="{{{data.shortcode}}}-{{{data.attribute}}}">
|
372 |
>
|
373 |
</select>
|
374 |
</script>
|
375 |
+
|
376 |
+
<script type="text/html" id="tmpl-toolset-shortcode-content">
|
377 |
+
<#
|
378 |
+
data = _.defaults( data, { defaultValue: '', required: false, hidden: false, placeholder: '' } );
|
379 |
+
data = _.defaults( data, { defaultForceValue: data.defaultValue } );
|
380 |
+
#>
|
381 |
+
<div class="toolset-shortcode-gui-attribute-wrapper js-toolset-shortcode-gui-content-wrapper" <# if ( data.hidden ) { #> style="display:none"<# } #>>
|
382 |
+
<# if ( _.has( data, 'label' ) ) { #>
|
383 |
+
<h3>{{{data.label}}}</h3>
|
384 |
+
<# } #>
|
385 |
+
<textarea id="toolset-shortcode-gui-content-{{{data.shortcode}}}" type="text" class="large-text js-toolset-shortcode-gui-content"><# {{{data.defaultValue}}} #></textarea>
|
386 |
+
<# if ( _.has( data, 'description' ) ) { #>
|
387 |
+
<p class="description">{{{data.description}}}</p>
|
388 |
+
<# } #>
|
389 |
+
</div>
|
390 |
+
</script>
|
391 |
+
|
392 |
+
<script type="text/html" id="tmpl-toolset-shortcode-attribute-postSelector">
|
393 |
+
<ul id="{{{data.shortcode}}}-{{{data.attribute}}}">
|
394 |
+
<li class="toolset-shortcode-gui-item-selector-option">
|
395 |
+
<label for="toolset-shortcode-gui-item-selector-post-id-current">
|
396 |
+
<input type="radio" class="js-toolset-shortcode-gui-item-selector" id="toolset-shortcode-gui-item-selector-post-id-current" name="toolset_shortcode_gui_object_id" value="current" checked="checked" />
|
397 |
+
<?php _e( 'The current post being displayed either directly or in a View loop', 'wpv-views' ); ?>
|
398 |
+
</label>
|
399 |
+
</li>
|
400 |
+
|
401 |
+
<?php
|
402 |
+
|
403 |
+
global $pagenow, $post;
|
404 |
+
$current_post_type = null;
|
405 |
+
if (
|
406 |
+
in_array( $pagenow, array( 'post.php' ) )
|
407 |
+
&& isset( $_GET["post"] )
|
408 |
+
) {
|
409 |
+
$current_post_id = (int) $_GET["post"];
|
410 |
+
$current_post_type_slug = get_post_type( $current_post_id );
|
411 |
+
$current_post_type = get_post_type_object( $current_post_type_slug );
|
412 |
+
} elseif (
|
413 |
+
isset( $post )
|
414 |
+
&& is_object( $post )
|
415 |
+
&& isset( $post->ID )
|
416 |
+
&& ( ! in_array( $post->post_type, array( 'view', 'view-template', 'cred-form', 'cred-user-form', 'dd_layouts' ) ) )
|
417 |
+
) {
|
418 |
+
$current_post_type = get_post_type_object( $post->post_type );
|
419 |
+
}
|
420 |
+
|
421 |
+
// Poost hierarchical relations
|
422 |
+
if (
|
423 |
+
is_null( $current_post_type )
|
424 |
+
|| (
|
425 |
+
is_object( $current_post_type )
|
426 |
+
&& isset( $current_post_type->hierarchical )
|
427 |
+
&& $current_post_type->hierarchical
|
428 |
+
)
|
429 |
+
) {
|
430 |
+
?>
|
431 |
+
<li class="toolset-shortcode-gui-item-selector-option">
|
432 |
+
<label for="toolset-shortcode-gui-item-selector-post-id-parent">
|
433 |
+
<input type="radio" class="js-toolset-shortcode-gui-item-selector" id="toolset-shortcode-gui-item-selector-post-id-parent" name="toolset_shortcode_gui_object_id" value="$parent" />
|
434 |
+
<?php echo __( 'The parent of the current post in the same post type, set by WordPress hierarchical relationship', 'wpv-views' ); ?>
|
435 |
+
</label>
|
436 |
+
</li>
|
437 |
+
<?php
|
438 |
+
}
|
439 |
+
|
440 |
+
|
441 |
+
// Types relations
|
442 |
+
if ( ! apply_filters( 'toolset_is_m2m_enabled', false ) ) {
|
443 |
+
// Legacy relationships
|
444 |
+
$current_post_type_parents = $this->get_legacy_current_post_type_relationships( $current_post_type );
|
445 |
+
$custom_post_types_relations = get_option( 'wpcf-custom-types', array() );
|
446 |
+
|
447 |
+
if ( ! empty( $current_post_type_parents ) ) {
|
448 |
+
?>
|
449 |
+
<li class="toolset-shortcode-gui-item-selector-option toolset-shortcode-gui-item-selector-has-related js-toolset-shortcode-gui-item-selector-has-related">
|
450 |
+
<label for="toolset-shortcode-gui-item-selector-post-id-related">
|
451 |
+
<input type="radio" class="js-toolset-shortcode-gui-item-selector" id="toolset-shortcode-gui-item-selector-post-id-related" name="toolset_shortcode_gui_object_id" value="related" />
|
452 |
+
<?php echo __( 'The parent of the current post in another post type, set by Types relationship', 'wpv-views' ); ?>
|
453 |
+
</label>
|
454 |
+
<div class="toolset-shortcode-gui-item-selector-is-related js-toolset-shortcode-gui-item-selector-is-related" style="display:none">
|
455 |
+
<ul class="toolset-advanced-setting tolset-mightlong-list" style="padding-top:15px;margin:5px 0 10px;">
|
456 |
+
<?php
|
457 |
+
$first = true;
|
458 |
+
foreach ( $current_post_type_parents as $slug ) {
|
459 |
+
?>
|
460 |
+
<li>
|
461 |
+
<?php echo sprintf( '<label for="toolset-shortcode-gui-item-selector-post-relationship-id-%s">', $slug ); ?>
|
462 |
+
<?php echo sprintf(
|
463 |
+
'<input type="radio" name="related_object" id="toolset-shortcode-gui-item-selector-post-relationship-id-%s" value="$%s" %s />',
|
464 |
+
$slug,
|
465 |
+
$slug,
|
466 |
+
$first ? 'checked="checked"' : ''
|
467 |
+
); ?>
|
468 |
+
<?php echo $custom_post_types_relations[ $slug ]['labels']['singular_name']; ?>
|
469 |
+
</label>
|
470 |
+
</li>
|
471 |
+
<?php
|
472 |
+
$first = false;
|
473 |
+
}
|
474 |
+
?>
|
475 |
+
</ul>
|
476 |
+
</div>
|
477 |
+
</li>
|
478 |
+
<?php
|
479 |
+
}
|
480 |
+
|
481 |
+
} else {
|
482 |
+
// m2m relationships
|
483 |
+
// Make sure m2m classes are registered in the autoloader
|
484 |
+
$current_post_type_relationships = $this->get_m2m_current_post_type_relationships( $current_post_type );
|
485 |
+
|
486 |
+
if ( ! empty( $current_post_type_relationships ) ) {
|
487 |
+
?>
|
488 |
+
<li class="toolset-shortcode-gui-item-selector-option toolset-shortcode-gui-item-selector-has-related js-toolset-shortcode-gui-item-selector-has-related">
|
489 |
+
<label for="toolset-shortcode-gui-item-selector-post-id-related">
|
490 |
+
<input type="radio" class="js-toolset-shortcode-gui-item-selector" id="toolset-shortcode-gui-item-selector-post-id-related" name="toolset_shortcode_gui_object_id" value="related" />
|
491 |
+
<?php echo __( 'The parent of the current post in another post type, set by Types relationship', 'wpv-views' ); ?>
|
492 |
+
</label>
|
493 |
+
<div class="toolset-shortcode-gui-item-selector-is-related js-toolset-shortcode-gui-item-selector-is-related" style="display:none">
|
494 |
+
<ul class="toolset-advanced-setting toolset-mightlong-list" style="padding-top:15px;margin:5px 0 10px;">
|
495 |
+
<?php
|
496 |
+
$first = true;
|
497 |
+
foreach ( $current_post_type_relationships as $relationship_data ) {
|
498 |
+
?>
|
499 |
+
<li>
|
500 |
+
<?php echo sprintf( '<label for="toolset-shortcode-gui-item-selector-post-relationship-id-%s">', $relationship_data['id'] ); ?>
|
501 |
+
<?php echo sprintf(
|
502 |
+
'<input type="radio" name="related_object" id="toolset-shortcode-gui-item-selector-post-relationship-id-%s" value="%s" %s />',
|
503 |
+
$relationship_data['id'],
|
504 |
+
$relationship_data['value'],
|
505 |
+
$first ? 'checked="checked"' : ''
|
506 |
+
); ?>
|
507 |
+
<?php echo $relationship_data['name']; ?>
|
508 |
+
</label>
|
509 |
+
</li>
|
510 |
+
<?php
|
511 |
+
$first = false;
|
512 |
+
}
|
513 |
+
?>
|
514 |
+
</ul>
|
515 |
+
</div>
|
516 |
+
</li>
|
517 |
+
<?php
|
518 |
+
}
|
519 |
+
|
520 |
+
}
|
521 |
+
|
522 |
+
?>
|
523 |
+
<li class="toolset-shortcode-gui-item-selector-option toolset-shortcode-gui-item-selector-has-related js-toolset-shortcode-gui-item-selector-has-related">
|
524 |
+
<label for="toolset-shortcode-gui-item-selector-post-id">
|
525 |
+
<input type="radio" class="js-toolset-shortcode-gui-item-selector" id="toolset-shortcode-gui-item-selector-post-id" name="toolset_shortcode_gui_object_id" value="object_id" />
|
526 |
+
<?php _e( 'A specific post', 'wpv-views' ); ?>
|
527 |
+
</label>
|
528 |
+
<div class="toolset-shortcode-gui-item-selector-is-related js-toolset-shortcode-gui-item-selector-is-related" style="display:none">
|
529 |
+
<input type="text" id="toolset-shortcode-gui-item-selector-post-id-object_id" class="js-toolset-shortcode-gui-item-selector_object_id js-toolset-shortcode-gui-attribute-has-placeholder" name="specific_object_id" placeholder="<?php echo esc_attr( __( 'Enter a post ID, eg 15', 'wpv-views' ) ); ?>" />
|
530 |
+
</div>
|
531 |
+
</li>
|
532 |
+
</ul>
|
533 |
+
<p class="description">
|
534 |
+
<?php echo sprintf(
|
535 |
+
__( 'Learn about displaying content from parent and other posts in the %sdocumentation page%s.', 'wpv-views' ),
|
536 |
+
'<a href="http://wp-types.com/documentation/user-guides/displaying-fields-of-parent-pages/" target="_blank">',
|
537 |
+
'</a>'
|
538 |
+
); ?>
|
539 |
+
</p>
|
540 |
+
</script>
|
541 |
+
|
542 |
+
<script type="text/html" id="tmpl-toolset-shortcode-attribute-userSelector">
|
543 |
+
<ul id="{{{data.shortcode}}}-{{{data.attribute}}}">
|
544 |
+
<li class="toolset-shortcode-gui-item-selector-option">
|
545 |
+
<label for="toolset-shortcode-gui-item-selector-user-id-current">
|
546 |
+
<input type="radio" class="js-toolset-shortcode-gui-item-selector" id="toolset-shortcode-gui-item-selector-user-id-current" name="toolset_shortcode_gui_object_id" value="current" checked="checked" />
|
547 |
+
<?php _e( 'The current user or the one being displayed in a View loop', 'wpv-views' ); ?>
|
548 |
+
</label>
|
549 |
+
</li>
|
550 |
+
|
551 |
+
<li class="toolset-shortcode-gui-item-selector-option toolset-shortcode-gui-item-selector-has-related js-toolset-shortcode-gui-item-selector-has-related">
|
552 |
+
<label for="toolset-shortcode-gui-item-selector-user-id">
|
553 |
+
<input type="radio" class="js-toolset-shortcode-gui-item-selector" id="toolset-shortcode-gui-item-selector-user-id" name="toolset_shortcode_gui_object_id" value="object_id" />
|
554 |
+
<?php _e( 'A specific user', 'wpv-views' ); ?>
|
555 |
+
</label>
|
556 |
+
<div class="toolset-shortcode-gui-item-selector-is-related js-toolset-shortcode-gui-item-selector-is-related" style="display:none">
|
557 |
+
<input type="text" id="toolset-shortcode-gui-item-selector-user-id-object_id" class="js-toolset-shortcode-gui-item-selector_object_id js-toolset-shortcode-gui-attribute-has-placeholder" name="specific_object_id" placeholder="<?php echo esc_attr( __( 'Enter an user ID, eg 2', 'wpv-views' ) ); ?>" />
|
558 |
+
</div>
|
559 |
+
</li>
|
560 |
+
</ul>
|
561 |
+
</script>
|
562 |
+
|
563 |
<script type="text/html" id="tmpl-toolset-shortcode-attribute-post-selector">
|
564 |
<ul id="{{data.shortcode}}}-{{data.attribute}}}">
|
565 |
<li>
|
615 |
|
616 |
}
|
617 |
|
618 |
+
public function extend_script_i18n( $toolset_shortcode_i18n ) {
|
619 |
+
$post_selector_attribute = 'id';
|
620 |
+
if ( apply_filters( 'toolset_is_m2m_enabled', false ) ) {
|
621 |
+
$post_selector_attribute = 'item';
|
622 |
+
}
|
623 |
+
$toolset_shortcode_i18n['selectorGroups'] = array(
|
624 |
+
'postSelector' => array(
|
625 |
+
'header' => __( 'Post selection', 'wpv-views' ),
|
626 |
+
'fields' => array(
|
627 |
+
$post_selector_attribute => array(
|
628 |
+
'label' => __( 'Display data for:', 'wpv-views' ),
|
629 |
+
'type' => 'postSelector',
|
630 |
+
'defaultValue' => 'current'
|
631 |
+
)
|
632 |
+
)
|
633 |
+
),
|
634 |
+
'termSelector' => array(
|
635 |
+
'header' => __( 'Taxonomy term selection', 'wpv-views' ),
|
636 |
+
'fields' => array(
|
637 |
+
'item' => array(
|
638 |
+
'label' => __( 'Display data for:', 'wpv-views' ),
|
639 |
+
'type' => 'termSelector',
|
640 |
+
'defaultValue' => 'current'
|
641 |
+
)
|
642 |
+
)
|
643 |
+
),
|
644 |
+
'userSelector' => array(
|
645 |
+
'header' => __( 'User selection', 'wpv-views' ),
|
646 |
+
'fields' => array(
|
647 |
+
'item' => array(
|
648 |
+
'label' => __( 'Display data for:', 'wpv-views' ),
|
649 |
+
'type' => 'userSelector',
|
650 |
+
'defaultValue' => 'current'
|
651 |
+
)
|
652 |
+
)
|
653 |
+
)
|
654 |
+
);
|
655 |
+
|
656 |
+
return $toolset_shortcode_i18n;
|
657 |
+
}
|
658 |
+
|
659 |
+
/**
|
660 |
+
* Get Types legacy parent relationships for a given post type, or all the existing parents otherwise.
|
661 |
+
*
|
662 |
+
* @paran $current_post_type string|null
|
663 |
+
*
|
664 |
+
* @return array
|
665 |
+
*
|
666 |
+
* @since m2m
|
667 |
+
*/
|
668 |
+
public function get_legacy_current_post_type_relationships( $current_post_type ) {
|
669 |
+
$current_post_type_parents = array();
|
670 |
+
|
671 |
+
if ( apply_filters( 'toolset_is_m2m_enabled', false ) ) {
|
672 |
+
return $current_post_type_parents;
|
673 |
+
}
|
674 |
+
|
675 |
+
$current_post_type_parents = array();
|
676 |
+
$custom_post_types_relations = get_option( 'wpcf-custom-types', array() );
|
677 |
+
|
678 |
+
if ( is_null( $current_post_type ) ) {
|
679 |
+
foreach ( $custom_post_types_relations as $cptr_key => $cptr_data ) {
|
680 |
+
if ( isset( $cptr_data['post_relationship']['has'] ) ) {
|
681 |
+
$current_post_type_parents[] = $cptr_key;
|
682 |
+
}
|
683 |
+
if (
|
684 |
+
isset( $cptr_data['post_relationship']['belongs'] )
|
685 |
+
&& is_array( $cptr_data['post_relationship']['belongs'] )
|
686 |
+
) {
|
687 |
+
$this_belongs = array_keys( $cptr_data['post_relationship']['belongs'] );
|
688 |
+
$current_post_type_parents = array_merge( $current_post_type_parents, $this_belongs );
|
689 |
+
}
|
690 |
+
}
|
691 |
+
} else if (
|
692 |
+
is_object( $current_post_type )
|
693 |
+
&& isset( $current_post_type->slug )
|
694 |
+
) {
|
695 |
+
// Fix legacy problem, when child CPT has no parents itself, but parent CPT has children
|
696 |
+
foreach ( $custom_post_types_relations as $cptr_key => $cptr_data ) {
|
697 |
+
if (
|
698 |
+
isset( $cptr_data['post_relationship']['has'] )
|
699 |
+
&& in_array( $current_post_type->slug, array_keys( $cptr_data['post_relationship']['has'] ) )
|
700 |
+
) {
|
701 |
+
$current_post_type_parents[] = $cptr_key;
|
702 |
+
}
|
703 |
+
}
|
704 |
+
if ( isset( $custom_post_types_relations[ $current_post_type->slug ] ) ) {
|
705 |
+
$current_post_type_data = $custom_post_types_relations[ $current_post_type->slug ];
|
706 |
+
if (
|
707 |
+
isset( $current_post_type_data['post_relationship'] )
|
708 |
+
&& ! empty( $current_post_type_data['post_relationship'] )
|
709 |
+
&& isset( $current_post_type_data['post_relationship']['belongs'] )
|
710 |
+
) {
|
711 |
+
foreach ( array_keys( $current_post_type_data['post_relationship']['belongs'] ) as $cpt_in_relation ) {
|
712 |
+
// Watch out! WE are not currently clearing the has and belongs entries of the relationships when deleting a post type
|
713 |
+
// So make sure the post type does exist
|
714 |
+
if ( isset( $custom_post_types_relations[ $cpt_in_relation ] ) ) {
|
715 |
+
$current_post_type_parents[] = $cpt_in_relation;
|
716 |
+
}
|
717 |
+
}
|
718 |
+
}
|
719 |
+
}
|
720 |
+
}
|
721 |
+
|
722 |
+
$current_post_type_parents = array_values( $current_post_type_parents );
|
723 |
+
$current_post_type_parents = array_unique( $current_post_type_parents );
|
724 |
+
|
725 |
+
return $current_post_type_parents;
|
726 |
+
}
|
727 |
+
|
728 |
+
/**
|
729 |
+
* Get Types one-to-many and one-to-one relationships for a given post type, or all the existing otherwise.
|
730 |
+
*
|
731 |
+
* @paran $current_post_type string|null
|
732 |
+
*
|
733 |
+
* @return array
|
734 |
+
*
|
735 |
+
* @since m2m
|
736 |
+
*/
|
737 |
+
public function get_m2m_current_post_type_relationships( $current_post_type ) {
|
738 |
+
$current_post_type_relationships = array();
|
739 |
+
|
740 |
+
if ( ! apply_filters( 'toolset_is_m2m_enabled', false ) ) {
|
741 |
+
return $current_post_type_relationships;
|
742 |
+
}
|
743 |
+
|
744 |
+
do_action( 'toolset_do_m2m_full_init' );
|
745 |
+
$query = new Toolset_Relationship_Query_V2();
|
746 |
+
|
747 |
+
// Note that we can not use $query->do_if() because it actually runs both branches
|
748 |
+
// and one of them expects $current_post_type->name to exist
|
749 |
+
if ( $current_post_type instanceof WP_Post_Type ) {
|
750 |
+
$relationship_definitions = $query
|
751 |
+
->add(
|
752 |
+
$query->do_or(
|
753 |
+
$query->do_and(
|
754 |
+
$query->has_type( $current_post_type->name, new Toolset_Relationship_Role_Child() ),
|
755 |
+
$query->has_cardinality( $query->cardinality()->one_to_many() ),
|
756 |
+
$query->origin( Toolset_Relationship_Origin_Wizard::ORIGIN_KEYWORD )
|
757 |
+
),
|
758 |
+
$query->has_cardinality( $query->cardinality()->one_to_one() )
|
759 |
+
)
|
760 |
+
)
|
761 |
+
->get_results();
|
762 |
+
} else {
|
763 |
+
$relationship_definitions = $query
|
764 |
+
->add(
|
765 |
+
$query->do_and(
|
766 |
+
$query->origin( Toolset_Relationship_Origin_Wizard::ORIGIN_KEYWORD ),
|
767 |
+
$query->do_or(
|
768 |
+
$query->has_cardinality( $query->cardinality()->one_to_many() ),
|
769 |
+
$query->has_cardinality( $query->cardinality()->one_to_one() )
|
770 |
+
)
|
771 |
+
)
|
772 |
+
)
|
773 |
+
->get_results();
|
774 |
+
}
|
775 |
+
|
776 |
+
foreach( $relationship_definitions as $relationship_definition ) {
|
777 |
+
// Note: This is only safe as long as we don't have self-join relationships enabled
|
778 |
+
if ( $current_post_type instanceof WP_Post_Type ) {
|
779 |
+
$given_post_type_role = (
|
780 |
+
in_array( $current_post_type->name, $relationship_definition->get_parent_type()->get_types() )
|
781 |
+
? Toolset_Relationship_Role::PARENT
|
782 |
+
: Toolset_Relationship_Role::CHILD
|
783 |
+
);
|
784 |
+
} else {
|
785 |
+
$given_post_type_role = Toolset_Relationship_Role::CHILD;
|
786 |
+
}
|
787 |
+
|
788 |
+
$parents = $relationship_definition->get_parent_type()->get_types();
|
789 |
+
$parent = $parents[0];
|
790 |
+
|
791 |
+
$current_post_type_relationships[] = array(
|
792 |
+
'name' => $relationship_definition->get_display_name(),
|
793 |
+
'slug' => $relationship_definition->get_slug(),
|
794 |
+
'value' => '@' . $relationship_definition->get_slug() . '.'
|
795 |
+
. $relationship_definition->get_role_name(
|
796 |
+
Toolset_Relationship_Role::other( $given_post_type_role )
|
797 |
+
),
|
798 |
+
'id' => $relationship_definition->get_slug() . '-' . $parent,
|
799 |
+
'role_name' => $relationship_definition->get_role_name(
|
800 |
+
Toolset_Relationship_Role::other( $given_post_type_role )
|
801 |
+
)
|
802 |
+
);
|
803 |
+
}
|
804 |
+
|
805 |
+
return $current_post_type_relationships;
|
806 |
+
}
|
807 |
+
|
808 |
public function toolset_select2_suggest_posts_by_title() {
|
809 |
if ( ! isset( $_POST['s'] ) ) {
|
810 |
$output = array(
|
912 |
wp_send_json_error( $output );
|
913 |
}
|
914 |
}
|
915 |
+
|
916 |
+
/**
|
917 |
+
* Register the Toolset shortcode transformer that will transform shortcode from the new format to the old one
|
918 |
+
* for proper rendering.
|
919 |
+
*
|
920 |
+
* @since 2.5.7
|
921 |
+
*/
|
922 |
+
public function register_shortcode_transformer() {
|
923 |
+
$shortcode_transformer = new Toolset_Shortcode_Transformer();
|
924 |
+
$shortcode_transformer->init_hooks();
|
925 |
+
}
|
926 |
|
927 |
}
|
vendor/toolset/toolset-common/inc/toolset.shortcode.transformer.class.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Toolset_Shortcode_Transformer
|
5 |
+
*
|
6 |
+
* Generic class to manage the Toolset shortcodes transformation to allow usage of different shortocode formats.
|
7 |
+
*
|
8 |
+
* @since 2.5.7
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Toolset_Shortcode_Transformer {
|
12 |
+
|
13 |
+
public function init_hooks() {
|
14 |
+
add_filter( 'the_content', array( $this, 'replace_shortcode_placeholders_with_brackets' ), 4 );
|
15 |
+
|
16 |
+
add_filter( 'toolset_transform_shortcode_format', array( $this, 'replace_shortcode_placeholders_with_brackets' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* In Views 2.5.0, we introduced support for shortcodes using placeholders instead of bracket. The selected placeholder
|
21 |
+
* for the left bracket "[" was chosen to be the "{!{" and the selected placeholder for the right bracket "]" was chosen
|
22 |
+
* to be the "}!}". This was done to allow the use of Toolset shortcodes inside the various page builder modules fields.
|
23 |
+
* Here, we are replacing early the instances of the placeholders with the normal brackets, in order for them to be
|
24 |
+
* treated as normal shortcodes.
|
25 |
+
*
|
26 |
+
* @param $content
|
27 |
+
*
|
28 |
+
* @return mixed
|
29 |
+
*
|
30 |
+
* @since 2.5.0
|
31 |
+
* @since 2.5.7 It was moved from Views to Toolset Common to allow shortcode transformation even if Views is disabled.
|
32 |
+
*/
|
33 |
+
public function replace_shortcode_placeholders_with_brackets( $content ) {
|
34 |
+
$content = str_replace( '{!{', '[', $content );
|
35 |
+
$content = str_replace( '}!}', ']', $content );
|
36 |
+
return $content;
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
vendor/toolset/toolset-common/loader.php
CHANGED
@@ -27,7 +27,7 @@
|
|
27 |
* Now that we have a unique version for all plugins
|
28 |
* we define the version here
|
29 |
*/
|
30 |
-
$toolset_common_version =
|
31 |
|
32 |
|
33 |
/* ---------------------------------------------------------------------- *\
|
27 |
* Now that we have a unique version for all plugins
|
28 |
* we define the version here
|
29 |
*/
|
30 |
+
$toolset_common_version = 258001;
|
31 |
|
32 |
|
33 |
/* ---------------------------------------------------------------------- *\
|
vendor/toolset/toolset-common/res/css/toolset-admin-notices.css
CHANGED
@@ -78,6 +78,18 @@
|
|
78 |
background-color: #e05628;
|
79 |
}
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
.toolset-button-external-link:after {
|
82 |
font-family: dashicons;
|
83 |
font-weight: normal;
|
@@ -85,17 +97,21 @@
|
|
85 |
content: "\f504";
|
86 |
display: inline-block;
|
87 |
width: 15px;
|
88 |
-
margin-right: -15px;
|
89 |
font-size: 15px;
|
90 |
line-height: 18px;
|
91 |
vertical-align: text-top;
|
92 |
margin-top: -1px;
|
93 |
-
padding-
|
94 |
-
padding-left: 3px;
|
95 |
text-decoration: none;
|
96 |
-webkit-font-smoothing: antialiased;
|
97 |
}
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
.toolset-list {
|
100 |
padding: 2px;
|
101 |
margin: 13px 0 13px 20px;
|
@@ -136,4 +152,16 @@
|
|
136 |
.toolset-dismiss:active:before,
|
137 |
.toolset-dismiss:focus:before {
|
138 |
color: #f05a29;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
78 |
background-color: #e05628;
|
79 |
}
|
80 |
|
81 |
+
.toolset-link {
|
82 |
+
color: #f05a28;
|
83 |
+
text-decoration: none;
|
84 |
+
}
|
85 |
+
|
86 |
+
.toolset-link:active,
|
87 |
+
.toolset-link:hover {
|
88 |
+
color: #e05628;
|
89 |
+
text-decoration: underline;
|
90 |
+
}
|
91 |
+
|
92 |
+
.toolset-external-link:after,
|
93 |
.toolset-button-external-link:after {
|
94 |
font-family: dashicons;
|
95 |
font-weight: normal;
|
97 |
content: "\f504";
|
98 |
display: inline-block;
|
99 |
width: 15px;
|
|
|
100 |
font-size: 15px;
|
101 |
line-height: 18px;
|
102 |
vertical-align: text-top;
|
103 |
margin-top: -1px;
|
104 |
+
padding-left: 1px;
|
|
|
105 |
text-decoration: none;
|
106 |
-webkit-font-smoothing: antialiased;
|
107 |
}
|
108 |
|
109 |
+
.toolset-button-external-link:after {
|
110 |
+
padding-left: 3px;
|
111 |
+
padding-right: 10px;
|
112 |
+
margin-right: -15px;
|
113 |
+
}
|
114 |
+
|
115 |
.toolset-list {
|
116 |
padding: 2px;
|
117 |
margin: 13px 0 13px 20px;
|
152 |
.toolset-dismiss:active:before,
|
153 |
.toolset-dismiss:focus:before {
|
154 |
color: #f05a29;
|
155 |
+
}
|
156 |
+
|
157 |
+
.toolset-dashboard-link-top-right {
|
158 |
+
position: absolute;
|
159 |
+
left: 212px;
|
160 |
+
top: 28px;
|
161 |
+
}
|
162 |
+
|
163 |
+
@media screen and (max-width: 850px) {
|
164 |
+
.toolset-dashboard-link-top-right {
|
165 |
+
display: none;
|
166 |
+
}
|
167 |
}
|
vendor/toolset/toolset-common/res/css/toolset-dialogs.css
CHANGED
@@ -189,7 +189,7 @@
|
|
189 |
float: left;
|
190 |
}
|
191 |
|
192 |
-
.toolset-shortcode-gui-dialog-container .ui-tabs-vertical .ui-tabs-nav li {
|
193 |
clear: left;
|
194 |
width: 100%;
|
195 |
border: none;
|
@@ -206,7 +206,7 @@
|
|
206 |
}
|
207 |
|
208 |
.toolset-shortcode-gui-dialog-container .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active {
|
209 |
-
padding-bottom: 0;
|
210 |
padding-right: .1em;
|
211 |
border: none;
|
212 |
background: #ededed;
|
@@ -254,13 +254,13 @@
|
|
254 |
.toolset-shortcode-gui-dialog-container h2 {
|
255 |
margin-top: 5px;
|
256 |
}
|
257 |
-
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-dialog-item-
|
258 |
overflow: hidden;
|
259 |
clear: left;
|
260 |
margin: 0;
|
261 |
padding: 0;
|
262 |
}
|
263 |
-
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-dialog-item-
|
264 |
display: block;
|
265 |
float: left;
|
266 |
margin: 0;
|
@@ -270,7 +270,7 @@
|
|
270 |
margin: 0;
|
271 |
padding: 0 10px 0 0;
|
272 |
}
|
273 |
-
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-dialog-item-
|
274 |
padding-right: 0;
|
275 |
}
|
276 |
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-attribute-wrapper h3,
|
@@ -284,7 +284,7 @@
|
|
284 |
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-attribute-wrapper label {
|
285 |
display: block;
|
286 |
}
|
287 |
-
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-attribute-wrapper span.toolset-shortcode-gui-attribute-pseudolabel,
|
288 |
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-attribute-group span.toolset-shortcode-gui-attribute-pseudolabel {
|
289 |
display: block;
|
290 |
margin: 3px 5px;
|
@@ -309,4 +309,45 @@
|
|
309 |
float: right;
|
310 |
margin-left: 10px;
|
311 |
margin-right: 0
|
312 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
float: left;
|
190 |
}
|
191 |
|
192 |
+
.toolset-shortcode-gui-dialog-container .ui-tabs-vertical .ui-tabs-nav li {
|
193 |
clear: left;
|
194 |
width: 100%;
|
195 |
border: none;
|
206 |
}
|
207 |
|
208 |
.toolset-shortcode-gui-dialog-container .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active {
|
209 |
+
padding-bottom: 0;
|
210 |
padding-right: .1em;
|
211 |
border: none;
|
212 |
background: #ededed;
|
254 |
.toolset-shortcode-gui-dialog-container h2 {
|
255 |
margin-top: 5px;
|
256 |
}
|
257 |
+
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-dialog-item-group {
|
258 |
overflow: hidden;
|
259 |
clear: left;
|
260 |
margin: 0;
|
261 |
padding: 0;
|
262 |
}
|
263 |
+
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-dialog-item-group > li {
|
264 |
display: block;
|
265 |
float: left;
|
266 |
margin: 0;
|
270 |
margin: 0;
|
271 |
padding: 0 10px 0 0;
|
272 |
}
|
273 |
+
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-dialog-item-group > li:last-child .toolset-shortcode-gui-attribute-wrapper {
|
274 |
padding-right: 0;
|
275 |
}
|
276 |
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-attribute-wrapper h3,
|
284 |
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-attribute-wrapper label {
|
285 |
display: block;
|
286 |
}
|
287 |
+
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-attribute-wrapper span.toolset-shortcode-gui-attribute-pseudolabel,
|
288 |
.toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-attribute-group span.toolset-shortcode-gui-attribute-pseudolabel {
|
289 |
display: block;
|
290 |
margin: 3px 5px;
|
309 |
float: right;
|
310 |
margin-left: 10px;
|
311 |
margin-right: 0
|
312 |
+
}
|
313 |
+
.toolset-shortcode-gui-dialog-container .toolset-advanced-setting {
|
314 |
+
background: #f6f6f6 none repeat scroll 0 0;
|
315 |
+
border-left: 3px solid #cdcdcd;
|
316 |
+
padding: 1px 10px 10px 20px;
|
317 |
+
}
|
318 |
+
.toolset-shortcode-gui-dialog-container .toolset-mightlong-list {
|
319 |
+
margin: 0;
|
320 |
+
}
|
321 |
+
.toolset-shortcode-gui-dialog-container .toolset-mightlong-list > li {
|
322 |
+
min-height: 24px;
|
323 |
+
min-width: 45%;
|
324 |
+
float: left;
|
325 |
+
padding-right: 4%;
|
326 |
+
margin: 0 0 6px;
|
327 |
+
}
|
328 |
+
/*********************************************
|
329 |
+
Toolset Confirmation Dialog
|
330 |
+
|
331 |
+
@since m2m
|
332 |
+
|
333 |
+
*********************************************/
|
334 |
+
.toolset-confirmation-dialog {
|
335 |
+
display: flex;
|
336 |
+
}
|
337 |
+
.toolset-confirmation-dialog-icon {
|
338 |
+
padding: 17px 15px 20px;
|
339 |
+
box-sizing: border-box;
|
340 |
+
}
|
341 |
+
.toolset-confirmation-dialog-content {
|
342 |
+
padding: 15px;
|
343 |
+
box-sizing: border-box;
|
344 |
+
}
|
345 |
+
@media (min-width: 768px) {
|
346 |
+
.toolset-confirmation-dialog-icon {
|
347 |
+
padding-left: 40px;
|
348 |
+
padding-right: 40px;
|
349 |
+
}
|
350 |
+
}
|
351 |
+
.toolset-confirmation-dialog-content {
|
352 |
+
|
353 |
+
}
|
vendor/toolset/toolset-common/res/images/third-party/logos/bb.svg
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
2 |
+
width="146.000000pt" height="128.000000pt" viewBox="0 0 146.000000 128.000000"
|
3 |
+
preserveAspectRatio="xMidYMid meet">
|
4 |
+
<g transform="translate(0.000000,128.000000) scale(0.050000,-0.050000)"
|
5 |
+
fill="#222222" stroke="none">
|
6 |
+
<path d="M1529 2519 c-232 -64 -360 -158 -381 -278 -7 -39 -40 -100 -74 -136
|
7 |
+
l-62 -65 47 -62 46 -63 -56 -118 c-61 -128 -66 -130 -145 -89 -80 41 -304 112
|
8 |
+
-354 112 -104 0 -549 -531 -550 -656 -1 -219 409 -578 994 -871 l103 -52 -20
|
9 |
+
-71 c-30 -112 20 -135 348 -162 190 -15 202 -8 142 84 -48 74 -117 107 -101
|
10 |
+
49 15 -59 -27 -72 -138 -40 l-92 25 13 86 c13 85 13 85 -83 140 -263 152 -390
|
11 |
+
251 -378 295 6 24 12 59 12 78 0 28 11 33 55 24 51 -11 49 -6 -33 68 -71 64
|
12 |
+
-85 88 -75 126 35 133 102 120 119 -23 36 -301 414 -500 414 -218 0 133 -113
|
13 |
+
182 -132 58 -35 -220 -167 -45 -172 227 -3 190 38 327 198 649 l131 266 -42
|
14 |
+
45 c-57 61 -54 80 21 143 l63 53 62 -73 61 -73 240 29 c132 17 342 29 467 27
|
15 |
+
l228 -3 76 -88 c150 -174 344 -598 299 -652 -85 -103 -303 -140 -431 -74 -155
|
16 |
+
80 -162 90 -102 150 96 95 64 134 -107 134 -169 0 -201 -35 -108 -122 46 -42
|
17 |
+
51 -43 45 -10 -4 21 4 42 18 47 35 12 31 -37 -6 -91 -98 -139 -381 -205 -551
|
18 |
+
-129 -156 70 -172 102 -119 246 56 153 42 167 -62 68 -260 -250 -245 -398 49
|
19 |
+
-499 101 -34 106 -39 159 -168 132 -323 209 -401 395 -402 192 0 368 155 520
|
20 |
+
460 53 107 41 92 93 108 136 42 -75 -413 -312 -674 -129 -140 -129 -140 49
|
21 |
+
-123 133 12 149 10 138 -18 -11 -29 -44 -40 -188 -60 -132 -19 -222 54 -155
|
22 |
+
126 21 22 18 24 -15 11 -198 -77 -483 -86 -666 -22 -47 17 -80 22 -74 12 6
|
23 |
+
-10 50 -29 96 -41 100 -27 134 -52 134 -97 0 -46 169 -81 460 -95 275 -13 349
|
24 |
+
11 519 167 136 125 131 166 -20 166 l-103 0 101 110 c118 130 230 343 265 505
|
25 |
+
14 65 45 137 71 166 88 96 43 257 -189 677 -113 203 -119 225 -74 262 45 37
|
26 |
+
37 110 -15 136 -117 60 -154 65 -180 24 -30 -49 -51 -51 -48 -5 2 27 -15 36
|
27 |
+
-81 41 -58 4 -87 17 -95 40 -18 59 -174 204 -218 204 -24 1 -106 3 -183 7 -86
|
28 |
+
3 -186 -7 -261 -28z m371 -30 c130 -36 213 -169 106 -169 -68 0 -84 11 -151
|
29 |
+
101 -54 73 -66 99 -40 92 19 -5 58 -16 85 -24z m-142 -77 c67 -97 57 -111 -79
|
30 |
+
-112 -31 0 -75 -24 -109 -60 l-58 -60 -76 74 c-67 66 -82 72 -116 51 -55 -35
|
31 |
+
-65 -31 -40 15 29 53 103 100 227 143 157 54 183 49 251 -51z m413 -181 c118
|
32 |
+
-49 79 -61 -215 -64 -292 -3 -311 7 -127 65 110 34 258 34 342 -1z m-1326
|
33 |
+
-573 c132 -28 127 -17 74 -170 -23 -65 -47 -184 -53 -264 -8 -93 -20 -143 -34
|
34 |
+
-138 -12 5 -19 24 -16 43 4 22 -2 30 -16 21 -12 -7 -44 1 -70 18 -61 40 -14
|
35 |
+
183 54 165 40 -10 47 8 15 40 -14 14 -4 53 32 125 66 131 51 155 -24 39 -30
|
36 |
+
-48 -58 -90 -61 -95 -2 -4 -28 8 -55 26 -81 53 -16 148 66 97 l53 -33 -50 58
|
37 |
+
c-27 33 -63 71 -80 85 -26 24 -25 26 10 17 22 -5 92 -20 155 -34z m-206 -17
|
38 |
+
c25 -16 24 -25 -9 -60 l-37 -42 -42 41 c-58 58 14 108 88 61z m-104 -126 c19
|
39 |
+
-15 15 -33 -17 -78 -40 -57 -44 -58 -80 -25 -47 42 -48 64 -5 111 31 35 48 33
|
40 |
+
102 -8z m130 -103 c44 -33 43 -50 -5 -112 l-38 -50 -43 43 c-70 69 9 178 86
|
41 |
+
119z m-276 -62 c34 -26 35 -35 11 -80 -49 -91 -147 -34 -103 61 25 56 38 59
|
42 |
+
92 19z m162 -122 c48 -32 48 -34 15 -90 -40 -68 -42 -68 -103 -21 -83 64 0
|
43 |
+
168 88 111z m1834 -159 l56 -39 -76 -127 c-133 -226 -323 -432 -361 -393 -5 4
|
44 |
+
24 97 63 206 58 163 133 455 133 517 0 8 29 -16 65 -55 36 -38 90 -87 120
|
45 |
+
-109z m-319 -2 c-72 -385 -117 -537 -156 -537 -81 0 -286 441 -215 462 78 22
|
46 |
+
242 113 306 168 96 81 98 79 65 -93z m-1357 42 c37 -28 37 -31 4 -102 l-35
|
47 |
+
-72 -48 45 c-80 75 -7 194 79 129z m-272 -70 c41 -34 44 -44 21 -74 -15 -19
|
48 |
+
-29 -39 -32 -43 -12 -18 -86 66 -86 98 0 68 31 75 97 19z m202 -169 c0 -11
|
49 |
+
-12 -41 -26 -66 l-25 -46 -54 42 c-79 63 -25 184 56 125 27 -19 49 -44 49 -55z
|
50 |
+
m127 -160 c-31 -64 -34 -66 -79 -36 -26 17 -43 37 -37 45 5 9 18 39 29 69 20
|
51 |
+
51 22 52 70 21 48 -31 48 -34 17 -99z"/>
|
52 |
+
<path d="M1700 1700 c-47 -88 57 -160 129 -89 44 45 39 74 -11 58 -31 -10 -40
|
53 |
+
-6 -33 14 6 15 21 25 34 22 13 -4 18 3 11 15 -22 35 -107 22 -130 -20z"/>
|
54 |
+
<path d="M2380 1709 c-55 -65 40 -162 111 -114 47 32 52 89 7 74 -31 -10 -40
|
55 |
+
-6 -33 14 6 15 21 25 34 22 13 -4 18 3 11 15 -19 30 -102 24 -130 -11z"/>
|
56 |
+
</g>
|
57 |
+
</svg>
|
vendor/toolset/toolset-common/res/images/third-party/logos/vc.svg
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2 |
+
<svg width="66px" height="50px" viewBox="0 0 66 50" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
3 |
+
<!-- Generator: Sketch 43.2 (39069) - http://www.bohemiancoding.com/sketch -->
|
4 |
+
<title>Fill 41</title>
|
5 |
+
<desc>Created with Sketch.</desc>
|
6 |
+
<defs></defs>
|
7 |
+
<g id="Page-1" stroke="none" stroke-width="1" fill="#222" fill-rule="evenodd">
|
8 |
+
<path d="M51.3446356,9.04135214 C46.8606356,8.68235214 44.9736356,9.78835214 42.8356356,10.0803521 C45.0046356,11.2153521 47.9606356,12.1793521 51.5436356,11.9703521 C48.2436356,13.2663521 42.8866356,12.8233521 39.1886356,10.5643521 C38.2256356,9.97535214 37.2136356,9.04535214 36.4556356,8.30235214 C33.4586356,5.58335214 31.2466356,0.401352144 21.6826356,0.0183521443 C9.68663559,-0.456647856 0.464635589,8.34735214 0.0156355886,19.6453521 C-0.435364411,30.9433521 8.92563559,40.4883521 20.9226356,40.9633521 C21.0806356,40.9713521 21.2386356,40.9693521 21.3946356,40.9693521 C24.5316356,40.7853521 28.6646356,39.5333521 31.7776356,37.6143521 C30.1426356,39.9343521 24.0316356,42.3893521 20.8506356,43.1673521 C21.1696356,45.6943521 22.5216356,46.8693521 23.6306356,47.6643521 C26.0896356,49.4243521 29.0086356,46.9343521 35.7406356,47.0583521 C39.4866356,47.1273521 43.3506356,48.0593521 46.4746356,49.8083521 L49.7806356,38.2683521 C58.1826356,38.3983521 65.1806356,32.2053521 65.4966356,24.2503521 C65.8176356,16.1623521 59.9106356,9.72335214 51.3446356,9.04135214 L51.3446356,9.04135214 Z" id="Fill-41" fill="#222"></path>
|
9 |
+
</g>
|
10 |
+
</svg>
|
vendor/toolset/toolset-common/res/images/third-party/logos/vc_old.svg
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
2 |
+
width="438.000000pt" height="438.000000pt" viewBox="0 0 438.000000 438.000000"
|
3 |
+
preserveAspectRatio="xMidYMid meet">
|
4 |
+
<g transform="translate(0.000000,438.000000) scale(0.100000,-0.100000)"
|
5 |
+
fill="#000000" stroke="none">
|
6 |
+
<path d="M1105 4021 c-78 -46 -574 -334 -645 -374 -19 -10 -65 -37 -103 -59
|
7 |
+
l-67 -40 2 -541 3 -541 130 -79 c72 -43 139 -82 150 -88 11 -5 27 -13 35 -19
|
8 |
+
24 -16 364 -216 380 -223 8 -4 29 -16 45 -26 17 -11 46 -28 65 -39 19 -11 50
|
9 |
+
-28 67 -38 l33 -19 0 -531 0 -531 22 -20 c13 -11 30 -23 38 -27 8 -4 24 -12
|
10 |
+
35 -19 11 -7 86 -50 165 -96 80 -46 181 -105 225 -131 244 -145 417 -240 426
|
11 |
+
-235 5 4 9 211 9 525 l0 519 22 21 c12 11 25 20 29 20 4 0 67 35 140 78 219
|
12 |
+
128 391 228 434 252 99 55 233 135 263 157 l32 24 0 523 c0 403 3 526 13 538
|
13 |
+
10 13 184 121 227 141 8 4 29 16 45 27 17 11 37 23 45 27 17 8 307 178 330
|
14 |
+
193 8 6 24 15 35 20 11 6 34 19 50 30 17 10 49 29 71 41 23 12 54 31 70 44
|
15 |
+
l28 22 -120 70 c-65 38 -195 114 -289 168 -93 54 -222 129 -285 165 -163 96
|
16 |
+
-207 120 -218 120 -6 0 -93 -48 -194 -106 -100 -58 -205 -119 -233 -134 -27
|
17 |
+
-15 -108 -62 -179 -104 -70 -42 -129 -76 -131 -76 -2 0 -41 -22 -88 -50 -47
|
18 |
+
-27 -89 -50 -94 -50 -4 0 -7 -235 -5 -522 1 -288 0 -533 -3 -546 -3 -12 -16
|
19 |
+
-27 -28 -32 -12 -6 -29 -14 -37 -20 -26 -17 -265 -156 -280 -163 -8 -4 -28
|
20 |
+
-16 -45 -27 -16 -11 -39 -24 -50 -30 -11 -6 -33 -19 -50 -30 -16 -11 -37 -23
|
21 |
+
-45 -27 -8 -4 -89 -51 -179 -105 -91 -54 -173 -98 -183 -98 -17 0 -18 24 -18
|
22 |
+
518 0 400 3 522 13 534 10 13 184 121 227 141 8 4 29 16 45 27 17 11 36 23 44
|
23 |
+
27 8 3 92 52 185 108 94 56 178 104 186 108 8 4 29 16 45 27 17 11 39 24 50
|
24 |
+
30 11 6 34 19 50 30 17 11 36 23 43 26 28 14 6 34 -115 104 -71 41 -198 114
|
25 |
+
-283 164 -85 49 -215 125 -289 168 -73 43 -137 78 -141 78 -4 0 -13 7 -20 15
|
26 |
+
-20 24 -50 16 -135 -34z"/>
|
27 |
+
</g>
|
28 |
+
</svg>
|
vendor/toolset/toolset-common/res/js/toolset-admin-notices.js
CHANGED
@@ -21,4 +21,10 @@
|
|
21 |
} );
|
22 |
} );
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
} ( jQuery ) );
|
21 |
} );
|
22 |
} );
|
23 |
|
24 |
+
|
25 |
+
$( document ).on( 'click', '[data-toolset-admin-notices-toggle-visibility]', function() {
|
26 |
+
var elementSelectorString = $( this ).data( 'toolset-admin-notices-toggle-visibility' );
|
27 |
+
$( elementSelectorString ).toggle();
|
28 |
+
} )
|
29 |
+
|
30 |
} ( jQuery ) );
|
vendor/toolset/toolset-common/res/js/toolset-shortcode.js
CHANGED
@@ -89,7 +89,7 @@ Toolset.shortcodeManager = function( $ ) {
|
|
89 |
* @since 2.5.4
|
90 |
*/
|
91 |
self.setShortcodeGuiAction = function( action ) {
|
92 |
-
if ( $.inArray( action, self.validActions )
|
93 |
self.action = action;
|
94 |
}
|
95 |
};
|
@@ -97,11 +97,13 @@ Toolset.shortcodeManager = function( $ ) {
|
|
97 |
/**
|
98 |
* Register the canonical Toolset hooks, both API filters and actions.
|
99 |
*
|
|
|
|
|
100 |
* @since 2.5.4
|
101 |
*/
|
102 |
self.initHooks = function() {
|
103 |
|
104 |
-
|
105 |
* ###############################
|
106 |
* API filters
|
107 |
* ###############################
|
@@ -135,6 +137,15 @@ Toolset.shortcodeManager = function( $ ) {
|
|
135 |
*/
|
136 |
Toolset.hooks.addFilter( 'toolset-filter-get-shortcode-gui-templates', self.getShortcodeTemplates );
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
/**
|
139 |
* Return the current crafted shortcode with the current dialog GUI attrbutes.
|
140 |
*
|
@@ -163,12 +174,19 @@ Toolset.shortcodeManager = function( $ ) {
|
|
163 |
*/
|
164 |
Toolset.hooks.addFilter( 'wpv-filter-wpv-shortcodes-transform-format', self.secureShortcodeFromSanitizationIfNeeded );
|
165 |
|
166 |
-
|
167 |
* ###############################
|
168 |
* API actions
|
169 |
* ###############################
|
170 |
*/
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
/**
|
173 |
* Set the current shortcodes GUI action: 'insert', 'create', 'save', 'append', 'edit', 'skip'.
|
174 |
*
|
@@ -180,11 +198,18 @@ Toolset.shortcodeManager = function( $ ) {
|
|
180 |
* Act upon the generated shortcode according to the current shortcodes GUI action: 'insert', 'create', 'save', 'append', 'edit', 'skip'.
|
181 |
*
|
182 |
* @since 2.5.4
|
|
|
183 |
*/
|
184 |
Toolset.hooks.addAction( 'toolset-action-do-shortcode-gui-action', self.doAction );
|
185 |
Toolset.hooks.addAction( 'toolset-action-do-shortcode-gui-action-create', self.doActionCreate, 1, 1 );
|
186 |
Toolset.hooks.addAction( 'toolset-action-do-shortcode-gui-action-insert', self.doActionInsert, 1, 1 );
|
|
|
187 |
|
|
|
|
|
|
|
|
|
|
|
188 |
Toolset.hooks.addAction( 'toolset-action-shortcode-dialog-loaded', self.initSelect2 );
|
189 |
|
190 |
return self;
|
@@ -196,27 +221,76 @@ Toolset.shortcodeManager = function( $ ) {
|
|
196 |
*
|
197 |
* @uses wp.template
|
198 |
* @since 2.5.4
|
|
|
199 |
*/
|
200 |
self.templates = {};
|
201 |
self.initTemplates = function() {
|
202 |
self.templates.dialog = wp.template( 'toolset-shortcode-gui' );
|
203 |
self.templates.attributeWrapper = wp.template( 'toolset-shortcode-attribute-wrapper' );
|
|
|
204 |
self.templates.attributes = {
|
|
|
205 |
text: wp.template( 'toolset-shortcode-attribute-text' ),
|
206 |
radio: wp.template( 'toolset-shortcode-attribute-radio' ),
|
207 |
select: wp.template( 'toolset-shortcode-attribute-select' ),
|
208 |
select2: wp.template( 'toolset-shortcode-attribute-select2' ),
|
209 |
ajaxSelect2: wp.template( 'toolset-shortcode-attribute-ajaxSelect2' ),
|
|
|
|
|
|
|
210 |
post: wp.template( 'toolset-shortcode-attribute-post-selector' ),
|
211 |
user: wp.template( 'toolset-shortcode-attribute-user-selector' )
|
212 |
};
|
213 |
return self;
|
214 |
}
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
self.getShortcodeTemplates = function( templates ) {
|
217 |
return self.templates;
|
218 |
};
|
219 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
/**
|
221 |
* Init GUI dialogs.
|
222 |
*
|
@@ -246,6 +320,7 @@ Toolset.shortcodeManager = function( $ ) {
|
|
246 |
$( 'body' ).append( '<div id="js-toolset-shortcode-generator-target-dialog" class="toolset-shortcode-gui-dialog-container js-toolset-shortcode-gui-dialog-container"></div>' );
|
247 |
}
|
248 |
self.dialogs.target = $( '#js-toolset-shortcode-generator-target-dialog' ).dialog({
|
|
|
249 |
autoOpen: false,
|
250 |
modal: true,
|
251 |
width: self.dialogMinWidth,
|
@@ -275,6 +350,11 @@ Toolset.shortcodeManager = function( $ ) {
|
|
275 |
return self;
|
276 |
};
|
277 |
|
|
|
|
|
|
|
|
|
|
|
278 |
$( document ).on( 'change', 'input.js-toolset-shortcode-gui-item-selector', function() {
|
279 |
var checkedSelector = $( this ).val();
|
280 |
$( '.js-toolset-shortcode-gui-item-selector-has-related' ).each( function() {
|
@@ -287,6 +367,11 @@ Toolset.shortcodeManager = function( $ ) {
|
|
287 |
});
|
288 |
});
|
289 |
|
|
|
|
|
|
|
|
|
|
|
290 |
self.initSelect2 = function() {
|
291 |
$( '.js-toolset-shortcode-gui-dialog-container .js-toolset-shortcode-gui-field-select2' ).each( function() {
|
292 |
var selector = $( this ),
|
@@ -362,6 +447,11 @@ Toolset.shortcodeManager = function( $ ) {
|
|
362 |
$( this ).removeClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
|
363 |
});
|
364 |
|
|
|
|
|
|
|
|
|
|
|
365 |
$( document ).on( 'change', 'input.js-shortcode-gui-field:radio', function() {
|
366 |
var checkedValue = $( this ).val(),
|
367 |
attribute = $( this ).closest( '.js-toolset-shortcode-gui-attribute-wrapper' ).data( 'attribute' ),
|
@@ -391,6 +481,16 @@ Toolset.shortcodeManager = function( $ ) {
|
|
391 |
|
392 |
};
|
393 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
self.isShortcodeAttributesContainerValid = function( status, container ) {
|
395 |
return self.validateShortcodeAttributes( container );
|
396 |
}
|
@@ -398,6 +498,10 @@ Toolset.shortcodeManager = function( $ ) {
|
|
398 |
/**
|
399 |
* Check required shortcode attributes while crafting the shortcode.
|
400 |
*
|
|
|
|
|
|
|
|
|
401 |
* @since 2.5.4
|
402 |
*/
|
403 |
self.requireShortcodeAttributes = function( evaluatedContainer ) {
|
@@ -475,7 +579,12 @@ Toolset.shortcodeManager = function( $ ) {
|
|
475 |
/**
|
476 |
* Validate shortcode attributes before crafting the final shortcode.
|
477 |
*
|
|
|
|
|
|
|
|
|
478 |
* @since 2.5.4
|
|
|
479 |
*/
|
480 |
self.validateShortcodeAttributes = function( evaluatedContainer ) {
|
481 |
var valid = true;
|
@@ -680,12 +789,29 @@ Toolset.shortcodeManager = function( $ ) {
|
|
680 |
return valid;
|
681 |
};
|
682 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
683 |
self.getCraftedShortcode = function( defaultValue ) {
|
684 |
return self.craftShortcode();
|
685 |
}
|
686 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
687 |
self.craftShortcode = function() {
|
688 |
-
var shortcodeName = $('.js-toolset-shortcode-gui-shortcode-handle').val(),
|
689 |
shortcodeAttributeString = '',
|
690 |
shortcodeAttributeValues = {},
|
691 |
shortcodeRawAttributeValues = {},
|
@@ -704,29 +830,30 @@ Toolset.shortcodeManager = function( $ ) {
|
|
704 |
shortcodeAttributeDefaultValue = attributeWrapper.data( 'default' );
|
705 |
switch ( attributeWrapper.data('type') ) {
|
706 |
case 'post':
|
|
|
707 |
case 'user':
|
|
|
|
|
|
|
|
|
708 |
shortcodeAttributeValue = $( '.js-toolset-shortcode-gui-item-selector:checked', attributeWrapper ).val();
|
709 |
switch( shortcodeAttributeValue ) {
|
710 |
case 'current':
|
711 |
shortcodeAttributeValue = false;
|
712 |
break;
|
713 |
-
case 'parent':
|
714 |
-
if ( shortcodeAttributeValue ) {
|
715 |
-
shortcodeAttributeValue = '$' + shortcodeAttributeValue;
|
716 |
-
}
|
717 |
-
break;
|
718 |
case 'related':
|
719 |
shortcodeAttributeValue = $( '[name="related_object"]:checked', attributeWrapper ).val();
|
720 |
-
if ( shortcodeAttributeValue ) {
|
721 |
-
shortcodeAttributeValue = '$' + shortcodeAttributeValue;
|
722 |
-
}
|
723 |
break;
|
724 |
case 'object_id':
|
725 |
shortcodeAttributeValue = $( '.js-toolset-shortcode-gui-item-selector_object_id', attributeWrapper ).val();
|
|
|
726 |
default:
|
|
|
727 |
}
|
728 |
break;
|
729 |
case 'select':
|
|
|
|
|
730 |
shortcodeAttributeValue = $('option:checked', attributeWrapper ).val();
|
731 |
break;
|
732 |
case 'radio':
|
@@ -740,24 +867,32 @@ Toolset.shortcodeManager = function( $ ) {
|
|
740 |
shortcodeAttributeValue = $('input', attributeWrapper ).val();
|
741 |
}
|
742 |
|
743 |
-
|
744 |
-
/**
|
745 |
-
* Fix true/false from data attribute for shortcodeAttributeDefaultValue
|
746 |
-
*/
|
747 |
if ( 'boolean' == typeof shortcodeAttributeDefaultValue ) {
|
748 |
shortcodeAttributeDefaultValue = shortcodeAttributeDefaultValue ? 'true' :'false';
|
749 |
}
|
750 |
|
|
|
751 |
shortcodeRawAttributeValues[ shortcodeAttributeKey ] = shortcodeAttributeValue;
|
|
|
752 |
/**
|
753 |
-
* Filter value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
754 |
*/
|
755 |
shortcodeAttributeValue = Toolset.hooks.applyFilters( 'toolset-filter-shortcode-gui-attribute-value', shortcodeAttributeValue, { shortcode: shortcodeName, attribute: shortcodeAttributeKey } );
|
756 |
shortcodeAttributeValue = Toolset.hooks.applyFilters( 'toolset-filter-shortcode-gui-' + shortcodeName + '-attribute-' + shortcodeAttributeKey + '-value', shortcodeAttributeValue, { shortcode: shortcodeName, attribute: shortcodeAttributeKey } );
|
757 |
|
758 |
-
|
759 |
-
* Add to the shortcodeAttributeValues object
|
760 |
-
*/
|
761 |
if (
|
762 |
shortcodeAttributeValue
|
763 |
&& shortcodeAttributeValue != shortcodeAttributeDefaultValue
|
@@ -765,7 +900,21 @@ Toolset.shortcodeManager = function( $ ) {
|
|
765 |
shortcodeAttributeValues[ shortcodeAttributeKey ] = shortcodeAttributeValue;
|
766 |
}
|
767 |
});
|
768 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
769 |
shortcodeAttributeValues = Toolset.hooks.applyFilters( 'toolset-filter-shortcode-gui-computed-attribute-values', shortcodeAttributeValues, { shortcode: shortcodeName, rawAttributes: shortcodeRawAttributeValues } );
|
770 |
shortcodeAttributeValues = Toolset.hooks.applyFilters( 'toolset-filter-shortcode-gui-' + shortcodeName + '-computed-attribute-values', shortcodeAttributeValues, { shortcode: shortcodeName, rawAttributes: shortcodeRawAttributeValues } );
|
771 |
|
@@ -775,21 +924,49 @@ Toolset.shortcodeManager = function( $ ) {
|
|
775 |
shortcodeAttributeString += " " + key + '="' + value + '"';
|
776 |
}
|
777 |
});
|
|
|
|
|
778 |
shortcodeToInsert = '[' + shortcodeName + shortcodeAttributeString + ']';
|
779 |
|
780 |
-
|
781 |
-
* Shortcodes with content
|
782 |
-
*/
|
783 |
if ( $( '.js-toolset-shortcode-gui-content' ).length > 0 ) {
|
784 |
shortcodeContent = $( '.js-toolset-shortcode-gui-content' ).val();
|
785 |
shortcodeToInsert += shortcodeContent;
|
786 |
shortcodeToInsert += '[/' + shortcodeName + ']';
|
787 |
}
|
788 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
789 |
return shortcodeToInsert;
|
790 |
|
791 |
};
|
792 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
793 |
self.resolveToolsetComboValues = function( shortcodeAttributeValues, data ) {
|
794 |
var resolvedAttributes = {};
|
795 |
_.each( shortcodeAttributeValues, function( value, key ) {
|
@@ -804,19 +981,37 @@ Toolset.shortcodeManager = function( $ ) {
|
|
804 |
return resolvedAttributes;
|
805 |
};
|
806 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
807 |
self.doAction = function( shortcode ) {
|
808 |
|
809 |
var action = self.action;
|
810 |
|
811 |
/**
|
812 |
-
* Custom action executed before performing the
|
813 |
*
|
814 |
-
* @param string shortcode
|
815 |
* @param string self.action The action to execute
|
816 |
*
|
817 |
* @since 2.5.4
|
818 |
*/
|
819 |
Toolset.hooks.doAction( 'toolset-action-before-do-shortcode-gui-action', shortcode, action );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
820 |
shortcode = Toolset.hooks.applyFilters( 'toolset-filter-before-do-shortcode-gui-action', shortcode, action );
|
821 |
|
822 |
switch ( action ) {
|
@@ -825,20 +1020,49 @@ Toolset.shortcodeManager = function( $ ) {
|
|
825 |
case 'append':
|
826 |
case 'edit':
|
827 |
case 'save':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
828 |
Toolset.hooks.doAction( 'toolset-action-do-shortcode-gui-action-' + action, shortcode );
|
829 |
break;
|
830 |
case 'insert':
|
831 |
default:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
832 |
Toolset.hooks.doAction( 'toolset-action-do-shortcode-gui-action-insert', shortcode );
|
833 |
break;
|
834 |
}
|
835 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
836 |
Toolset.hooks.doAction( 'toolset-action-after-do-shortcode-gui-action', shortcode, action );
|
837 |
|
838 |
// Set the shortcodes GUI action to its default 'insert'
|
839 |
self.setShortcodeGuiAction( 'insert' );
|
840 |
};
|
841 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
842 |
self.doActionCreate = function( shortcode ) {
|
843 |
self.dialogs.target
|
844 |
.data( 'shortcode', shortcode )
|
@@ -854,9 +1078,33 @@ Toolset.shortcodeManager = function( $ ) {
|
|
854 |
});
|
855 |
};
|
856 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
857 |
self.doActionInsert = function( shortcode ) {
|
858 |
window.icl_editor.insert( shortcode );
|
859 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
860 |
|
861 |
self.secureShortcodeFromSanitizationIfNeeded = function( shortcode_data ) {
|
862 |
var shortcode_string;
|
@@ -866,7 +1114,7 @@ Toolset.shortcodeManager = function( $ ) {
|
|
866 |
shortcode_string = shortcode_data;
|
867 |
}
|
868 |
|
869 |
-
|
870 |
* In Views 2.5.0, we introduced support for shortcodes using placeholders instead of bracket.
|
871 |
* The selected placeholder for the left bracket "[" was chosen to be the "{!{" and the selected
|
872 |
* placeholder for the right bracket "]" was chosen to be the "}!}". This was done to allow the use
|
@@ -876,7 +1124,7 @@ Toolset.shortcodeManager = function( $ ) {
|
|
876 |
* where the Visual Composer builder is used.
|
877 |
* For all the other needed pages (native post editor with each page builder enabled), this is handled
|
878 |
* elsewhere.
|
879 |
-
|
880 |
if (
|
881 |
(
|
882 |
// In the Content Template edit page with WPBakery Page Builder (former Visual Composer) enabled.
|
89 |
* @since 2.5.4
|
90 |
*/
|
91 |
self.setShortcodeGuiAction = function( action ) {
|
92 |
+
if ( -1 !== $.inArray( action, self.validActions ) ) {
|
93 |
self.action = action;
|
94 |
}
|
95 |
};
|
97 |
/**
|
98 |
* Register the canonical Toolset hooks, both API filters and actions.
|
99 |
*
|
100 |
+
* @return self;
|
101 |
+
*
|
102 |
* @since 2.5.4
|
103 |
*/
|
104 |
self.initHooks = function() {
|
105 |
|
106 |
+
/*
|
107 |
* ###############################
|
108 |
* API filters
|
109 |
* ###############################
|
137 |
*/
|
138 |
Toolset.hooks.addFilter( 'toolset-filter-get-shortcode-gui-templates', self.getShortcodeTemplates );
|
139 |
|
140 |
+
/**
|
141 |
+
* Return the postSelector/termSeletor/userSelector attributes data.
|
142 |
+
*
|
143 |
+
* @since m2m
|
144 |
+
*/
|
145 |
+
Toolset.hooks.addFilter( 'toolset-filter-get-shortcode-gui-postSelector-attributes', self.getPostSelectorAttributes );
|
146 |
+
Toolset.hooks.addFilter( 'toolset-filter-get-shortcode-gui-termSelector-attributes', self.getTermSelectorAttributes );
|
147 |
+
Toolset.hooks.addFilter( 'toolset-filter-get-shortcode-gui-userSelector-attributes', self.getUserSelectorAttributes );
|
148 |
+
|
149 |
/**
|
150 |
* Return the current crafted shortcode with the current dialog GUI attrbutes.
|
151 |
*
|
174 |
*/
|
175 |
Toolset.hooks.addFilter( 'wpv-filter-wpv-shortcodes-transform-format', self.secureShortcodeFromSanitizationIfNeeded );
|
176 |
|
177 |
+
/*
|
178 |
* ###############################
|
179 |
* API actions
|
180 |
* ###############################
|
181 |
*/
|
182 |
|
183 |
+
/**
|
184 |
+
* Register a new template.
|
185 |
+
*
|
186 |
+
* @since m2m
|
187 |
+
*/
|
188 |
+
Toolset.hooks.addAction( 'toolset-filter-register-shortcode-gui-attribute-template', self.registerShortcodeAttributeTemplate, 1, 2 );
|
189 |
+
|
190 |
/**
|
191 |
* Set the current shortcodes GUI action: 'insert', 'create', 'save', 'append', 'edit', 'skip'.
|
192 |
*
|
198 |
* Act upon the generated shortcode according to the current shortcodes GUI action: 'insert', 'create', 'save', 'append', 'edit', 'skip'.
|
199 |
*
|
200 |
* @since 2.5.4
|
201 |
+
* @since m2m Add the callback for the "save" action.
|
202 |
*/
|
203 |
Toolset.hooks.addAction( 'toolset-action-do-shortcode-gui-action', self.doAction );
|
204 |
Toolset.hooks.addAction( 'toolset-action-do-shortcode-gui-action-create', self.doActionCreate, 1, 1 );
|
205 |
Toolset.hooks.addAction( 'toolset-action-do-shortcode-gui-action-insert', self.doActionInsert, 1, 1 );
|
206 |
+
Toolset.hooks.addAction( 'toolset-action-do-shortcode-gui-action-save', self.doActionSave, 1, 1 );
|
207 |
|
208 |
+
/**
|
209 |
+
* Init select2 instances on shortcode dialogs once they are completely opened.
|
210 |
+
*
|
211 |
+
* @since 2.5.4
|
212 |
+
*/
|
213 |
Toolset.hooks.addAction( 'toolset-action-shortcode-dialog-loaded', self.initSelect2 );
|
214 |
|
215 |
return self;
|
221 |
*
|
222 |
* @uses wp.template
|
223 |
* @since 2.5.4
|
224 |
+
* @since m2m Add the attributeGroupWrapper template, and the content, postSelector and userSelector attributes templates.
|
225 |
*/
|
226 |
self.templates = {};
|
227 |
self.initTemplates = function() {
|
228 |
self.templates.dialog = wp.template( 'toolset-shortcode-gui' );
|
229 |
self.templates.attributeWrapper = wp.template( 'toolset-shortcode-attribute-wrapper' );
|
230 |
+
self.templates.attributeGroupWrapper = wp.template( 'toolset-shortcode-attribute-group-wrapper' );
|
231 |
self.templates.attributes = {
|
232 |
+
content: wp.template( 'toolset-shortcode-content' ),
|
233 |
text: wp.template( 'toolset-shortcode-attribute-text' ),
|
234 |
radio: wp.template( 'toolset-shortcode-attribute-radio' ),
|
235 |
select: wp.template( 'toolset-shortcode-attribute-select' ),
|
236 |
select2: wp.template( 'toolset-shortcode-attribute-select2' ),
|
237 |
ajaxSelect2: wp.template( 'toolset-shortcode-attribute-ajaxSelect2' ),
|
238 |
+
postSelector: wp.template( 'toolset-shortcode-attribute-postSelector' ),
|
239 |
+
userSelector: wp.template( 'toolset-shortcode-attribute-userSelector' ),
|
240 |
+
// CRED selectors templates
|
241 |
post: wp.template( 'toolset-shortcode-attribute-post-selector' ),
|
242 |
user: wp.template( 'toolset-shortcode-attribute-user-selector' )
|
243 |
};
|
244 |
return self;
|
245 |
}
|
246 |
|
247 |
+
/**
|
248 |
+
* Get all registered templates.
|
249 |
+
*
|
250 |
+
* @param templates object Initial dummy parameter si this can be used as a filter callback.
|
251 |
+
*
|
252 |
+
* @return object
|
253 |
+
*
|
254 |
+
* @since m2m
|
255 |
+
*/
|
256 |
self.getShortcodeTemplates = function( templates ) {
|
257 |
return self.templates;
|
258 |
};
|
259 |
|
260 |
+
/**
|
261 |
+
* Register a wp.template for an attribute type and make it available globally.
|
262 |
+
*
|
263 |
+
* @param templateName string
|
264 |
+
* @param template wp.template
|
265 |
+
*
|
266 |
+
* @since m2m
|
267 |
+
*/
|
268 |
+
self.registerShortcodeAttributeTemplate = function( templateName, template ) {
|
269 |
+
if ( ! _.has( self.templates.attributes, templateName ) ) {
|
270 |
+
self.templates.attributes[ templateName ] = template;
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Get the canonical post|term|user selectors attributes to append them before generating the shortcode dialog.
|
276 |
+
*
|
277 |
+
* @param attributes object Initial dummy parameter si this can be used as a filter callback.
|
278 |
+
*
|
279 |
+
* @return object
|
280 |
+
*
|
281 |
+
* @since 2.5.4
|
282 |
+
* @todo This is currently just used by CRED and probably should become CRED-only templates.
|
283 |
+
*/
|
284 |
+
self.getPostSelectorAttributes = function( $attributes ) {
|
285 |
+
return { postSelector: toolset_shortcode_i18n.selectorGroups.postSelector };
|
286 |
+
};
|
287 |
+
self.getTermSelectorAttributes = function( $attributes ) {
|
288 |
+
return { termSelector: toolset_shortcode_i18n.selectorGroups.termSelector };
|
289 |
+
};
|
290 |
+
self.getUserSelectorAttributes = function( $attributes ) {
|
291 |
+
return { userSelector: toolset_shortcode_i18n.selectorGroups.userSelector };
|
292 |
+
};
|
293 |
+
|
294 |
/**
|
295 |
* Init GUI dialogs.
|
296 |
*
|
320 |
$( 'body' ).append( '<div id="js-toolset-shortcode-generator-target-dialog" class="toolset-shortcode-gui-dialog-container js-toolset-shortcode-gui-dialog-container"></div>' );
|
321 |
}
|
322 |
self.dialogs.target = $( '#js-toolset-shortcode-generator-target-dialog' ).dialog({
|
323 |
+
dialogClass: 'toolset-ui-dialog',
|
324 |
autoOpen: false,
|
325 |
modal: true,
|
326 |
width: self.dialogMinWidth,
|
350 |
return self;
|
351 |
};
|
352 |
|
353 |
+
/**
|
354 |
+
* Control the item selector behavior for options that have further settings.
|
355 |
+
*
|
356 |
+
* @since 2.5.4
|
357 |
+
*/
|
358 |
$( document ).on( 'change', 'input.js-toolset-shortcode-gui-item-selector', function() {
|
359 |
var checkedSelector = $( this ).val();
|
360 |
$( '.js-toolset-shortcode-gui-item-selector-has-related' ).each( function() {
|
367 |
});
|
368 |
});
|
369 |
|
370 |
+
/**
|
371 |
+
* Init select2 and ajaxSelect2 attribute controls.
|
372 |
+
*
|
373 |
+
* @since 2.5.4
|
374 |
+
*/
|
375 |
self.initSelect2 = function() {
|
376 |
$( '.js-toolset-shortcode-gui-dialog-container .js-toolset-shortcode-gui-field-select2' ).each( function() {
|
377 |
var selector = $( this ),
|
447 |
$( this ).removeClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
|
448 |
});
|
449 |
|
450 |
+
/**
|
451 |
+
* Control the toolsetCombo attribute value behavior for options that combine a set of valus plus free input.
|
452 |
+
*
|
453 |
+
* @since 2.5.4
|
454 |
+
*/
|
455 |
$( document ).on( 'change', 'input.js-shortcode-gui-field:radio', function() {
|
456 |
var checkedValue = $( this ).val(),
|
457 |
attribute = $( this ).closest( '.js-toolset-shortcode-gui-attribute-wrapper' ).data( 'attribute' ),
|
481 |
|
482 |
};
|
483 |
|
484 |
+
/**
|
485 |
+
* Check whether a container for attributes is valid, including required and validation tests.
|
486 |
+
*
|
487 |
+
* @param status bool Initial dummy parameter si this can be used as a filter callback.
|
488 |
+
* @param container object jQuery object matching the container to evaluate.
|
489 |
+
*
|
490 |
+
* @return bool
|
491 |
+
*
|
492 |
+
* @since 2.5.4
|
493 |
+
*/
|
494 |
self.isShortcodeAttributesContainerValid = function( status, container ) {
|
495 |
return self.validateShortcodeAttributes( container );
|
496 |
}
|
498 |
/**
|
499 |
* Check required shortcode attributes while crafting the shortcode.
|
500 |
*
|
501 |
+
* @param evaluatedContainer object jQuery object matching the container to evaluate.
|
502 |
+
*
|
503 |
+
* @return bool
|
504 |
+
*
|
505 |
* @since 2.5.4
|
506 |
*/
|
507 |
self.requireShortcodeAttributes = function( evaluatedContainer ) {
|
579 |
/**
|
580 |
* Validate shortcode attributes before crafting the final shortcode.
|
581 |
*
|
582 |
+
* @param evaluatedContainer object jQuery object matching the container to evaluate.
|
583 |
+
*
|
584 |
+
* @return bool
|
585 |
+
*
|
586 |
* @since 2.5.4
|
587 |
+
* @todo Implement actual validation
|
588 |
*/
|
589 |
self.validateShortcodeAttributes = function( evaluatedContainer ) {
|
590 |
var valid = true;
|
789 |
return valid;
|
790 |
};
|
791 |
|
792 |
+
/**
|
793 |
+
* Get the shortcode crafted with the current dialog shortcode attributes.
|
794 |
+
*
|
795 |
+
* @param defaultValue string Initial dummy parameter si this can be used as a filter callback.
|
796 |
+
*
|
797 |
+
* @return string
|
798 |
+
*
|
799 |
+
* @since m2m
|
800 |
+
*/
|
801 |
self.getCraftedShortcode = function( defaultValue ) {
|
802 |
return self.craftShortcode();
|
803 |
}
|
804 |
|
805 |
+
/**
|
806 |
+
* Craft a shortcode given the attributes in the currently open dialog.
|
807 |
+
*
|
808 |
+
* @return string
|
809 |
+
*
|
810 |
+
* @since 2.5.4
|
811 |
+
* @since m2m Add support for postSelector, userSelector, typesViewsTermSelector, typesUserSelector and typesViewsUserSelector attribute types.
|
812 |
+
*/
|
813 |
self.craftShortcode = function() {
|
814 |
+
var shortcodeName = $( '.js-toolset-shortcode-gui-shortcode-handle' ).val(),
|
815 |
shortcodeAttributeString = '',
|
816 |
shortcodeAttributeValues = {},
|
817 |
shortcodeRawAttributeValues = {},
|
830 |
shortcodeAttributeDefaultValue = attributeWrapper.data( 'default' );
|
831 |
switch ( attributeWrapper.data('type') ) {
|
832 |
case 'post':
|
833 |
+
case 'postSelector':
|
834 |
case 'user':
|
835 |
+
case 'userSelector':
|
836 |
+
case 'typesViewsTermSelector':
|
837 |
+
case 'typesUserSelector':
|
838 |
+
case 'typesViewsUserSelector':
|
839 |
shortcodeAttributeValue = $( '.js-toolset-shortcode-gui-item-selector:checked', attributeWrapper ).val();
|
840 |
switch( shortcodeAttributeValue ) {
|
841 |
case 'current':
|
842 |
shortcodeAttributeValue = false;
|
843 |
break;
|
|
|
|
|
|
|
|
|
|
|
844 |
case 'related':
|
845 |
shortcodeAttributeValue = $( '[name="related_object"]:checked', attributeWrapper ).val();
|
|
|
|
|
|
|
846 |
break;
|
847 |
case 'object_id':
|
848 |
shortcodeAttributeValue = $( '.js-toolset-shortcode-gui-item-selector_object_id', attributeWrapper ).val();
|
849 |
+
case 'parent': // The value is correct out of the box
|
850 |
default:
|
851 |
+
break;
|
852 |
}
|
853 |
break;
|
854 |
case 'select':
|
855 |
+
case 'select2':
|
856 |
+
case 'ajaxSelect2':
|
857 |
shortcodeAttributeValue = $('option:checked', attributeWrapper ).val();
|
858 |
break;
|
859 |
case 'radio':
|
867 |
shortcodeAttributeValue = $('input', attributeWrapper ).val();
|
868 |
}
|
869 |
|
870 |
+
// Fix true/false from data attribute for shortcodeAttributeDefaultValue
|
|
|
|
|
|
|
871 |
if ( 'boolean' == typeof shortcodeAttributeDefaultValue ) {
|
872 |
shortcodeAttributeDefaultValue = shortcodeAttributeDefaultValue ? 'true' :'false';
|
873 |
}
|
874 |
|
875 |
+
// Add to the shortcodeRawAttributeValues collection
|
876 |
shortcodeRawAttributeValues[ shortcodeAttributeKey ] = shortcodeAttributeValue;
|
877 |
+
|
878 |
/**
|
879 |
+
* Filter each shortcode attribute value separatedly, using two different filters:
|
880 |
+
* - toolset-filter-shortcode-gui-attribute-value
|
881 |
+
* - toolset-filter-shortcode-gui-{shortcodeName}-attribute-{shortcodeAttributeKey}-value
|
882 |
+
*
|
883 |
+
* @param shortcodeAttributeValue string
|
884 |
+
* @param object
|
885 |
+
* {
|
886 |
+
* shortcode: shortcodeName,
|
887 |
+
* attribute: shortcodeAttributeKey
|
888 |
+
* }
|
889 |
+
*
|
890 |
+
* @since 2.5.4
|
891 |
*/
|
892 |
shortcodeAttributeValue = Toolset.hooks.applyFilters( 'toolset-filter-shortcode-gui-attribute-value', shortcodeAttributeValue, { shortcode: shortcodeName, attribute: shortcodeAttributeKey } );
|
893 |
shortcodeAttributeValue = Toolset.hooks.applyFilters( 'toolset-filter-shortcode-gui-' + shortcodeName + '-attribute-' + shortcodeAttributeKey + '-value', shortcodeAttributeValue, { shortcode: shortcodeName, attribute: shortcodeAttributeKey } );
|
894 |
|
895 |
+
// Add to the shortcodeAttributeValues collection
|
|
|
|
|
896 |
if (
|
897 |
shortcodeAttributeValue
|
898 |
&& shortcodeAttributeValue != shortcodeAttributeDefaultValue
|
900 |
shortcodeAttributeValues[ shortcodeAttributeKey ] = shortcodeAttributeValue;
|
901 |
}
|
902 |
});
|
903 |
+
|
904 |
+
/**
|
905 |
+
* Filter all shortcode attribute values, using two different filters:
|
906 |
+
* - toolset-filter-shortcode-gui-computed-attribute-values
|
907 |
+
* - toolset-filter-shortcode-gui-{shortcodeName}-computed-attribute-values
|
908 |
+
*
|
909 |
+
* @param shortcodeAttributeValues object
|
910 |
+
* @param object
|
911 |
+
* {
|
912 |
+
* shortcode: shortcodeName,
|
913 |
+
* rawAttributes: shortcodeRawAttributeValues
|
914 |
+
* }
|
915 |
+
*
|
916 |
+
* @since 2.5.4
|
917 |
+
*/
|
918 |
shortcodeAttributeValues = Toolset.hooks.applyFilters( 'toolset-filter-shortcode-gui-computed-attribute-values', shortcodeAttributeValues, { shortcode: shortcodeName, rawAttributes: shortcodeRawAttributeValues } );
|
919 |
shortcodeAttributeValues = Toolset.hooks.applyFilters( 'toolset-filter-shortcode-gui-' + shortcodeName + '-computed-attribute-values', shortcodeAttributeValues, { shortcode: shortcodeName, rawAttributes: shortcodeRawAttributeValues } );
|
920 |
|
924 |
shortcodeAttributeString += " " + key + '="' + value + '"';
|
925 |
}
|
926 |
});
|
927 |
+
|
928 |
+
// Compose the shortcodeToInsert string
|
929 |
shortcodeToInsert = '[' + shortcodeName + shortcodeAttributeString + ']';
|
930 |
|
931 |
+
// Shortcodes with content: add it plus the closing shortode tag
|
|
|
|
|
932 |
if ( $( '.js-toolset-shortcode-gui-content' ).length > 0 ) {
|
933 |
shortcodeContent = $( '.js-toolset-shortcode-gui-content' ).val();
|
934 |
shortcodeToInsert += shortcodeContent;
|
935 |
shortcodeToInsert += '[/' + shortcodeName + ']';
|
936 |
}
|
937 |
|
938 |
+
/**
|
939 |
+
* Filter the crafted shortcode string, using two different filters:
|
940 |
+
* - toolset-filter-shortcode-gui-crafted-shortcode
|
941 |
+
* - toolset-filter-shortcode-gui-{shortcodeName}-crafted-shortcode
|
942 |
+
*
|
943 |
+
* @param shortcodeToInsert string
|
944 |
+
* @param object
|
945 |
+
* {
|
946 |
+
* shortcode: shortcodeName,
|
947 |
+
* attributes: shortcodeAttributeValues
|
948 |
+
* rawAttributes: shortcodeRawAttributeValues
|
949 |
+
* }
|
950 |
+
*
|
951 |
+
* @since m2m
|
952 |
+
*/
|
953 |
+
shortcodeToInsert = Toolset.hooks.applyFilters( 'toolset-filter-shortcode-gui-crafted-shortcode', shortcodeToInsert, { shortcode: shortcodeName, attributs: shortcodeAttributeValues, rawAttributes: shortcodeRawAttributeValues } );
|
954 |
+
shortcodeToInsert = Toolset.hooks.applyFilters( 'toolset-filter-shortcode-gui-' + shortcodeName + '-crafted-shortcode', shortcodeToInsert, { shortcode: shortcodeName, attributes: shortcodeAttributeValues, rawAttributes: shortcodeRawAttributeValues } );
|
955 |
+
|
956 |
return shortcodeToInsert;
|
957 |
|
958 |
};
|
959 |
|
960 |
+
/**
|
961 |
+
* Resolve toolsetCombo attribute values, getting the actual value from the combo attribute.
|
962 |
+
*
|
963 |
+
* @param shortcodeAttributeValues object
|
964 |
+
* @param data object
|
965 |
+
*
|
966 |
+
* @return object
|
967 |
+
*
|
968 |
+
* @since 2.5.4
|
969 |
+
*/
|
970 |
self.resolveToolsetComboValues = function( shortcodeAttributeValues, data ) {
|
971 |
var resolvedAttributes = {};
|
972 |
_.each( shortcodeAttributeValues, function( value, key ) {
|
981 |
return resolvedAttributes;
|
982 |
};
|
983 |
|
984 |
+
/**
|
985 |
+
* Do the final action upon the crafted shortcode.
|
986 |
+
*
|
987 |
+
* Valid actions are 'skip', 'create', 'append', 'edit', 'save', 'insert'.
|
988 |
+
*
|
989 |
+
* @param shortcode string
|
990 |
+
*
|
991 |
+
* @since 2.5.4
|
992 |
+
*/
|
993 |
self.doAction = function( shortcode ) {
|
994 |
|
995 |
var action = self.action;
|
996 |
|
997 |
/**
|
998 |
+
* Custom action executed before performing the GUI action.
|
999 |
*
|
1000 |
+
* @param string shortcode The shortcode to action upon
|
1001 |
* @param string self.action The action to execute
|
1002 |
*
|
1003 |
* @since 2.5.4
|
1004 |
*/
|
1005 |
Toolset.hooks.doAction( 'toolset-action-before-do-shortcode-gui-action', shortcode, action );
|
1006 |
+
|
1007 |
+
/**
|
1008 |
+
* Final filter over the shortcode string before executing the GUI action.
|
1009 |
+
*
|
1010 |
+
* @param shortcode string
|
1011 |
+
* @param action string
|
1012 |
+
*
|
1013 |
+
* @since 2.5.4
|
1014 |
+
*/
|
1015 |
shortcode = Toolset.hooks.applyFilters( 'toolset-filter-before-do-shortcode-gui-action', shortcode, action );
|
1016 |
|
1017 |
switch ( action ) {
|
1020 |
case 'append':
|
1021 |
case 'edit':
|
1022 |
case 'save':
|
1023 |
+
/**
|
1024 |
+
* Do the GUI skip|create|append|edit|save action, if there is a callback for that.
|
1025 |
+
*
|
1026 |
+
* @param shortcode string
|
1027 |
+
*
|
1028 |
+
* @since 2.5.4
|
1029 |
+
*/
|
1030 |
Toolset.hooks.doAction( 'toolset-action-do-shortcode-gui-action-' + action, shortcode );
|
1031 |
break;
|
1032 |
case 'insert':
|
1033 |
default:
|
1034 |
+
/**
|
1035 |
+
* Do the GUI insert action.
|
1036 |
+
*
|
1037 |
+
* @param shortcode string
|
1038 |
+
*
|
1039 |
+
* @since 2.5.4
|
1040 |
+
*/
|
1041 |
Toolset.hooks.doAction( 'toolset-action-do-shortcode-gui-action-insert', shortcode );
|
1042 |
break;
|
1043 |
}
|
1044 |
|
1045 |
+
/**
|
1046 |
+
* Custom action executed after performing the GUI action.
|
1047 |
+
*
|
1048 |
+
* @param string shortcode The shortcode to action upon
|
1049 |
+
* @param string self.action The action executed
|
1050 |
+
*
|
1051 |
+
* @since 2.5.4
|
1052 |
+
*/
|
1053 |
Toolset.hooks.doAction( 'toolset-action-after-do-shortcode-gui-action', shortcode, action );
|
1054 |
|
1055 |
// Set the shortcodes GUI action to its default 'insert'
|
1056 |
self.setShortcodeGuiAction( 'insert' );
|
1057 |
};
|
1058 |
|
1059 |
+
/**
|
1060 |
+
* Do the GUI create action. Opens the target dialog and inserts the shortcode into it.
|
1061 |
+
*
|
1062 |
+
* @param shortcode string
|
1063 |
+
*
|
1064 |
+
* @since 2.5.4
|
1065 |
+
*/
|
1066 |
self.doActionCreate = function( shortcode ) {
|
1067 |
self.dialogs.target
|
1068 |
.data( 'shortcode', shortcode )
|
1078 |
});
|
1079 |
};
|
1080 |
|
1081 |
+
/**
|
1082 |
+
* Do the GUI insert action.
|
1083 |
+
*
|
1084 |
+
* @param shortcode string
|
1085 |
+
*
|
1086 |
+
* @uses icl_editor
|
1087 |
+
*
|
1088 |
+
* @since 2.5.4
|
1089 |
+
*/
|
1090 |
self.doActionInsert = function( shortcode ) {
|
1091 |
window.icl_editor.insert( shortcode );
|
1092 |
};
|
1093 |
+
|
1094 |
+
/**
|
1095 |
+
* Do the GUI save action. Base64-encode the shortcode and adds it as the value of an option in the Views loop wizard dialog.
|
1096 |
+
*
|
1097 |
+
* @param shortcode string
|
1098 |
+
*
|
1099 |
+
* @since m2m
|
1100 |
+
*/
|
1101 |
+
self.doActionSave = function( shortcode ) {
|
1102 |
+
$( '.js-wpv-loop-wizard-save-shortcode-ui-active' )
|
1103 |
+
.find( 'option:selected' )
|
1104 |
+
.val( Base64.encode( shortcode ) );
|
1105 |
+
$( '.js-wpv-loop-wizard-save-shortcode-ui-active' )
|
1106 |
+
.removeClass( 'js-wpv-loop-wizard-save-shortcode-ui-active' );
|
1107 |
+
};
|
1108 |
|
1109 |
self.secureShortcodeFromSanitizationIfNeeded = function( shortcode_data ) {
|
1110 |
var shortcode_string;
|
1114 |
shortcode_string = shortcode_data;
|
1115 |
}
|
1116 |
|
1117 |
+
/*
|
1118 |
* In Views 2.5.0, we introduced support for shortcodes using placeholders instead of bracket.
|
1119 |
* The selected placeholder for the left bracket "[" was chosen to be the "{!{" and the selected
|
1120 |
* placeholder for the right bracket "]" was chosen to be the "}!}". This was done to allow the use
|
1124 |
* where the Visual Composer builder is used.
|
1125 |
* For all the other needed pages (native post editor with each page builder enabled), this is handled
|
1126 |
* elsewhere.
|
1127 |
+
*/
|
1128 |
if (
|
1129 |
(
|
1130 |
// In the Content Template edit page with WPBakery Page Builder (former Visual Composer) enabled.
|
vendor/toolset/toolset-common/templates/admin/notice/types-free-version-ends.phtml
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template File
|
4 |
+
* This file is only build for classes which implements Toolset_Admin_Notice_Interface
|
5 |
+
*
|
6 |
+
* @var Toolset_Admin_Notice_Interface $this
|
7 |
+
*
|
8 |
+
* @since Types 2.2.21
|
9 |
+
*/
|
10 |
+
?>
|
11 |
+
|
12 |
+
<p>
|
13 |
+
<b>
|
14 |
+
<?php printf( __( 'Development of Toolset Types is moving into the complete %sToolset%s package.', 'wpcf' ),
|
15 |
+
'<a class="toolset-link" target="_blank" href="https://wp-types.com/?utm_source=typesplugin&utm_campaign=moving-types-to-toolset&utm_medium=admin-message&utm_term=toolset">',
|
16 |
+
'</a>' ); ?>
|
17 |
+
</b>
|
18 |
+
</p>
|
19 |
+
|
20 |
+
<p>
|
21 |
+
<?php _e( 'You will get the most advanced features in WordPress for custom post types, taxonomies and fields, but it’s going to be a paid plugin.',
|
22 |
+
'wpcf' ) ?>
|
23 |
+
</p>
|
24 |
+
|
25 |
+
<p class="toolset-list-title">
|
26 |
+
<?php _e( 'New versions will include:', 'wpcf' ); ?>
|
27 |
+
</p>
|
28 |
+
|
29 |
+
<ul class="toolset-list">
|
30 |
+
<li><?php _e( 'Repeating and nested field groups', 'wpcf' ) ?></li>
|
31 |
+
<li><?php _e( 'Post reference fields', 'wpcf' ); ?></li>
|
32 |
+
<li><?php _e( 'Many-to-many post relationships', 'wpcf' ); ?></li>
|
33 |
+
<li><?php _e( 'And more...', 'wpcf' ); ?></li>
|
34 |
+
</ul>
|
35 |
+
|
36 |
+
<p>
|
37 |
+
<?php _e( 'This free version of Types will continue to receive bug fixes, security updates and compatibility updates through 2018.',
|
38 |
+
'wpcf' ); ?>
|
39 |
+
</p>
|
40 |
+
|
41 |
+
<?php
|
42 |
+
// Button "See details and leave your feedback"
|
43 |
+
echo Toolset_Admin_Notices_Manager::tpl_button_primary(
|
44 |
+
__( 'See details and leave your feedback', 'wpcf' ),
|
45 |
+
'https://wp-types.com/2017/11/types-plugin-is-moving-to-be-a-part-of-the-complete-toolset-package/' .
|
46 |
+
'?utm_source=typesplugin' .
|
47 |
+
'&utm_campaign=moving-types-to-toolset' .
|
48 |
+
'&utm_medium=admin-message' .
|
49 |
+
'&utm_term=details-about-moving-types-to-toolset'
|
50 |
+
);
|
51 |
+
|
52 |
+
// Button "Pricing"
|
53 |
+
echo Toolset_Admin_Notices_Manager::tpl_button_primary(
|
54 |
+
__( 'Pricing', 'wpcf' ),
|
55 |
+
'https://wp-types.com/buy/' .
|
56 |
+
'?utm_source=typesplugin' .
|
57 |
+
'&utm_campaign=moving-types-to-toolset' .
|
58 |
+
'&utm_medium=admin-message' .
|
59 |
+
'&utm_term=pricing'
|
60 |
+
);
|
61 |
+
?>
|
vendor/toolset/toolset-common/templates/admin/notice/types-move-to-toolset.phtml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template File
|
4 |
+
* This file is only build for classes which implements Toolset_Admin_Notice_Interface
|
5 |
+
*
|
6 |
+
* @var Toolset_Admin_Notice_Interface $this
|
7 |
+
*
|
8 |
+
* @since 2.3.0 First release
|
9 |
+
*/
|
10 |
+
?>
|
11 |
+
|
12 |
+
<a data-toolset-admin-notices-toggle-visibility=".js-toolset-toggle-types-free-version-ends" href="javascript:void(0)" class="js-toolset-toggle-types-free-version-ends toolset-link toolset-dashboard-link-top-right"><?php _e( 'Important information about Types updates »', 'wpcf' ); ?></a>
|
13 |
+
|
14 |
+
<div class="toolset-notice-wp notice toolset-notice js-toolset-toggle-types-free-version-ends" style="display: none">
|
15 |
+
<?php $this->render_content() ?>
|
16 |
+
|
17 |
+
<?php @include( dirname( __FILE__ ) . '/presets/btn-dismiss.phtml' ); ?>
|
18 |
+
</div>
|
vendor/toolset/toolset-common/toolset-common-loader.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
if( !defined('TOOLSET_VERSION') ){
|
4 |
-
define('TOOLSET_VERSION', '2.5.
|
5 |
}
|
6 |
|
7 |
if ( ! defined('TOOLSET_COMMON_VERSION' ) ) {
|
8 |
-
define( 'TOOLSET_COMMON_VERSION', '2.5.
|
9 |
}
|
10 |
|
11 |
if ( ! defined('TOOLSET_COMMON_PATH' ) ) {
|
@@ -16,6 +16,16 @@ if ( ! defined('TOOLSET_COMMON_DIR' ) ) {
|
|
16 |
define( 'TOOLSET_COMMON_DIR', basename( TOOLSET_COMMON_PATH ) );
|
17 |
}
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
require_once( TOOLSET_COMMON_PATH . '/bootstrap.php' );
|
20 |
|
21 |
if ( ! function_exists( 'toolset_common_boostrap' ) ) {
|
1 |
<?php
|
2 |
|
3 |
if( !defined('TOOLSET_VERSION') ){
|
4 |
+
define('TOOLSET_VERSION', '2.5.8');
|
5 |
}
|
6 |
|
7 |
if ( ! defined('TOOLSET_COMMON_VERSION' ) ) {
|
8 |
+
define( 'TOOLSET_COMMON_VERSION', '2.5.8' );
|
9 |
}
|
10 |
|
11 |
if ( ! defined('TOOLSET_COMMON_PATH' ) ) {
|
16 |
define( 'TOOLSET_COMMON_DIR', basename( TOOLSET_COMMON_PATH ) );
|
17 |
}
|
18 |
|
19 |
+
/**
|
20 |
+
* Last edit flag shared among Toolset plugins.
|
21 |
+
*
|
22 |
+
* @since 2.5.7 defined in Toolset Common (this is also redundantly defined in some plugins).
|
23 |
+
*/
|
24 |
+
if ( ! defined( 'TOOLSET_EDIT_LAST' ) ) {
|
25 |
+
define( 'TOOLSET_EDIT_LAST', '_toolset_edit_last' );
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
require_once( TOOLSET_COMMON_PATH . '/bootstrap.php' );
|
30 |
|
31 |
if ( ! function_exists( 'toolset_common_boostrap' ) ) {
|
vendor/toolset/toolset-common/toolset-forms/autoload_classmap.php
CHANGED
@@ -24,6 +24,7 @@ return array(
|
|
24 |
'WPToolset_Field_Numeric' => dirname( __FILE__ ) . '/classes/class.numeric.php',
|
25 |
'WPToolset_Field_Password' => dirname( __FILE__ ) . '/classes/class.password.php',
|
26 |
'WPToolset_Field_Phone' => dirname( __FILE__ ) . '/classes/class.phone.php',
|
|
|
27 |
'WPToolset_Field_Radios' => dirname( __FILE__ ) . '/classes/class.radios.php',
|
28 |
'WPToolset_Field_Recaptcha' => dirname( __FILE__ ) . '/classes/class.recaptcha.php',
|
29 |
'WPToolset_Field_Recaptcha_v1' => dirname( __FILE__ ) . '/classes/class.recaptcha-v1.php',
|
24 |
'WPToolset_Field_Numeric' => dirname( __FILE__ ) . '/classes/class.numeric.php',
|
25 |
'WPToolset_Field_Password' => dirname( __FILE__ ) . '/classes/class.password.php',
|
26 |
'WPToolset_Field_Phone' => dirname( __FILE__ ) . '/classes/class.phone.php',
|
27 |
+
'WPToolset_Field_Post' => dirname( __FILE__ ) . '/classes/class.post.php',
|
28 |
'WPToolset_Field_Radios' => dirname( __FILE__ ) . '/classes/class.radios.php',
|
29 |
'WPToolset_Field_Recaptcha' => dirname( __FILE__ ) . '/classes/class.recaptcha.php',
|
30 |
'WPToolset_Field_Recaptcha_v1' => dirname( __FILE__ ) . '/classes/class.recaptcha-v1.php',
|
vendor/toolset/toolset-common/toolset-forms/classes/class.checkboxes.php
CHANGED
@@ -70,7 +70,7 @@ class WPToolset_Field_Checkboxes extends FieldFactory {
|
|
70 |
$_options[ $option_key ]['#before'] = sprintf(
|
71 |
'<li class="%s"><label class="wpt-form-label wpt-form-checkbox-label">', implode( ' ', $classes )
|
72 |
);
|
73 |
-
$_options[ $option_key ]['#after'] = $option['title'] . '</label></li>';
|
74 |
$_options[ $option_key ]['#pattern'] = '<BEFORE><PREFIX><ELEMENT><ERROR><SUFFIX><DESCRIPTION><AFTER>';
|
75 |
} else {
|
76 |
$_options[ $option_key ]['#before'] = sprintf(
|
70 |
$_options[ $option_key ]['#before'] = sprintf(
|
71 |
'<li class="%s"><label class="wpt-form-label wpt-form-checkbox-label">', implode( ' ', $classes )
|
72 |
);
|
73 |
+
$_options[ $option_key ]['#after'] = stripslashes( $option['title'] ) . '</label></li>';
|
74 |
$_options[ $option_key ]['#pattern'] = '<BEFORE><PREFIX><ELEMENT><ERROR><SUFFIX><DESCRIPTION><AFTER>';
|
75 |
} else {
|
76 |
$_options[ $option_key ]['#before'] = sprintf(
|
vendor/toolset/toolset-common/toolset-forms/classes/class.field_factory.php
CHANGED
@@ -132,6 +132,11 @@ abstract class FieldFactory extends FieldAbstract
|
|
132 |
*/
|
133 |
public function getTitle($_title = false)
|
134 |
{
|
|
|
|
|
|
|
|
|
|
|
135 |
$title = isset( $this->_data['title'] ) && ! empty( $this->_data['title'] )
|
136 |
? $this->_data['title']
|
137 |
: false;
|
132 |
*/
|
133 |
public function getTitle($_title = false)
|
134 |
{
|
135 |
+
if( isset( $this->_data['hide_field_title'] ) && $this->_data['hide_field_title'] ) {
|
136 |
+
// option to hide the title is used
|
137 |
+
return '';
|
138 |
+
}
|
139 |
+
|
140 |
$title = isset( $this->_data['title'] ) && ! empty( $this->_data['title'] )
|
141 |
? $this->_data['title']
|
142 |
: false;
|
vendor/toolset/toolset-common/user-editors/editor/abstract.php
CHANGED
@@ -13,6 +13,9 @@ abstract class Toolset_User_Editors_Editor_Abstract
|
|
13 |
protected $name;
|
14 |
protected $option_name = '_toolset_user_editors_editor_default';
|
15 |
|
|
|
|
|
|
|
16 |
/**
|
17 |
* All possible screens.
|
18 |
* @var Toolset_User_Editors_Editor_Screen_Interface[]
|
@@ -41,6 +44,14 @@ abstract class Toolset_User_Editors_Editor_Abstract
|
|
41 |
return $this->name;
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
public function set_name( $name ) {
|
45 |
return $this->name = $name;
|
46 |
}
|
13 |
protected $name;
|
14 |
protected $option_name = '_toolset_user_editors_editor_default';
|
15 |
|
16 |
+
protected $logo_class;
|
17 |
+
protected $logo_image_svg;
|
18 |
+
|
19 |
/**
|
20 |
* All possible screens.
|
21 |
* @var Toolset_User_Editors_Editor_Screen_Interface[]
|
44 |
return $this->name;
|
45 |
}
|
46 |
|
47 |
+
public function get_logo_class() {
|
48 |
+
return $this->logo_class;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function get_logo_image_svg() {
|
52 |
+
return $this->logo_image_svg;
|
53 |
+
}
|
54 |
+
|
55 |
public function set_name( $name ) {
|
56 |
return $this->name = $name;
|
57 |
}
|
vendor/toolset/toolset-common/user-editors/editor/avada.php
CHANGED
@@ -18,6 +18,8 @@ class Toolset_User_Editors_Editor_Avada
|
|
18 |
protected $name = 'Fusion Builder';
|
19 |
protected $option_name = '_toolset_user_editors_avada_template';
|
20 |
|
|
|
|
|
21 |
public function initialize() {
|
22 |
if ( apply_filters( 'wpv_filter_is_native_editor_for_cts', false ) ) {
|
23 |
add_action( 'edit_form_after_editor', array( $this, 'register_assets_for_backend_editor' ) );
|
18 |
protected $name = 'Fusion Builder';
|
19 |
protected $option_name = '_toolset_user_editors_avada_template';
|
20 |
|
21 |
+
protected $logo_class = 'dashicons-fusiona-logo';
|
22 |
+
|
23 |
public function initialize() {
|
24 |
if ( apply_filters( 'wpv_filter_is_native_editor_for_cts', false ) ) {
|
25 |
add_action( 'edit_form_after_editor', array( $this, 'register_assets_for_backend_editor' ) );
|
vendor/toolset/toolset-common/user-editors/editor/beaver.php
CHANGED
@@ -15,6 +15,8 @@ class Toolset_User_Editors_Editor_Beaver
|
|
15 |
protected $name = '';
|
16 |
protected $option_name = '_toolset_user_editors_beaver_template';
|
17 |
|
|
|
|
|
18 |
/**
|
19 |
* Toolset_User_Editors_Editor_Beaver constructor.
|
20 |
*
|
15 |
protected $name = '';
|
16 |
protected $option_name = '_toolset_user_editors_beaver_template';
|
17 |
|
18 |
+
protected $logo_image_svg = 'bb.svg';
|
19 |
+
|
20 |
/**
|
21 |
* Toolset_User_Editors_Editor_Beaver constructor.
|
22 |
*
|
vendor/toolset/toolset-common/user-editors/editor/divi.php
CHANGED
@@ -17,6 +17,8 @@ class Toolset_User_Editors_Editor_Divi
|
|
17 |
protected $name = 'Divi Builder';
|
18 |
protected $option_name = '_toolset_user_editors_divi_template';
|
19 |
|
|
|
|
|
20 |
public function initialize() {
|
21 |
if ( apply_filters( 'wpv_filter_is_native_editor_for_cts', false ) ) {
|
22 |
add_action( 'edit_form_after_editor', array( $this, 'register_assets_for_backend_editor' ) );
|
17 |
protected $name = 'Divi Builder';
|
18 |
protected $option_name = '_toolset_user_editors_divi_template';
|
19 |
|
20 |
+
protected $logo_class = 'toolset-divi-logo-for-ct-button';
|
21 |
+
|
22 |
public function initialize() {
|
23 |
if ( apply_filters( 'wpv_filter_is_native_editor_for_cts', false ) ) {
|
24 |
add_action( 'edit_form_after_editor', array( $this, 'register_assets_for_backend_editor' ) );
|
vendor/toolset/toolset-common/user-editors/editor/interface.php
CHANGED
@@ -19,5 +19,6 @@ interface Toolset_User_Editors_Editor_Interface {
|
|
19 |
public function get_id();
|
20 |
public function get_name();
|
21 |
public function get_option_name();
|
|
|
22 |
}
|
23 |
|
19 |
public function get_id();
|
20 |
public function get_name();
|
21 |
public function get_option_name();
|
22 |
+
public function get_logo_class();
|
23 |
}
|
24 |
|
vendor/toolset/toolset-common/user-editors/editor/screen/avada/backend.php
CHANGED
@@ -174,8 +174,9 @@ class Toolset_User_Editors_Editor_Screen_Avada_Backend
|
|
174 |
$content_template_has_avada = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'AVADA_SCREEN_ID' ) );
|
175 |
?>
|
176 |
<button
|
177 |
-
class="button button-secondary js-wpv-ct-apply-user-editor js-wpv-ct-apply-user-editor-<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
178 |
data-editor="<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
|
|
179 |
<?php disabled( $content_template_has_avada ); ?>
|
180 |
>
|
181 |
<?php echo esc_html( $this->editor->get_name() ); ?>
|
174 |
$content_template_has_avada = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'AVADA_SCREEN_ID' ) );
|
175 |
?>
|
176 |
<button
|
177 |
+
class="button button-secondary toolset-ct-button-logo js-wpv-ct-apply-user-editor js-wpv-ct-apply-user-editor-<?php echo esc_attr( $this->editor->get_id() ); ?> <?php echo $this->editor->get_logo_class(); ?>"
|
178 |
data-editor="<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
179 |
+
title="<?php echo __( 'Edit with', 'wpv-views' ) . ' ' . $this->editor->get_name() ?>"
|
180 |
<?php disabled( $content_template_has_avada ); ?>
|
181 |
>
|
182 |
<?php echo esc_html( $this->editor->get_name() ); ?>
|
vendor/toolset/toolset-common/user-editors/editor/screen/avada/backend_editor.css
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
z-index: 99998 !important;
|
3 |
}
|
4 |
|
1 |
+
/*
|
2 |
+
* We are pushing the Fusion Builder modals ("normal" and "nested columns" ones)
|
3 |
+
* one z-index level lower in order to have the "Toolset Shortcodes" admin bar button
|
4 |
+
* modal appear above them.
|
5 |
+
*/
|
6 |
+
.fusion-builder-modal-settings-container,
|
7 |
+
.fusion_builder_row_inner .fusion-builder-row-content {
|
8 |
z-index: 99998 !important;
|
9 |
}
|
10 |
|
vendor/toolset/toolset-common/user-editors/editor/screen/basic/backend.css
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.toolset-ct-button-logo img {
|
2 |
+
height: 15px;
|
3 |
+
}
|
4 |
+
.toolset-ct-button-logo:before {
|
5 |
+
font-size: 15px !important;
|
6 |
+
}
|
7 |
+
|
8 |
+
.toolset-divi-logo-for-ct-button:before {
|
9 |
+
font-family: 'ETmodules';
|
10 |
+
content: '\e626';
|
11 |
+
}
|
vendor/toolset/toolset-common/user-editors/editor/screen/basic/backend.php
CHANGED
@@ -64,6 +64,13 @@ class Toolset_User_Editors_Editor_Screen_Basic_Backend
|
|
64 |
public function register_assets() {
|
65 |
|
66 |
$toolset_assets_manager = Toolset_Assets_Manager::getInstance();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
$toolset_assets_manager->register_script(
|
69 |
'toolset-user-editors-basic-script',
|
@@ -100,12 +107,14 @@ class Toolset_User_Editors_Editor_Screen_Basic_Backend
|
|
100 |
public function admin_enqueue_assets() {
|
101 |
if ( $this->is_views_or_wpa_edit_page() ) {
|
102 |
do_action( 'toolset_enqueue_scripts', array( 'toolset-user-editors-basic-layout-template-script' ) );
|
|
|
103 |
}
|
104 |
}
|
105 |
|
106 |
public function action_assets() {
|
107 |
|
108 |
do_action( 'toolset_enqueue_scripts', array( 'toolset-user-editors-basic-script' ) );
|
|
|
109 |
|
110 |
}
|
111 |
|
64 |
public function register_assets() {
|
65 |
|
66 |
$toolset_assets_manager = Toolset_Assets_Manager::getInstance();
|
67 |
+
|
68 |
+
$toolset_assets_manager->register_style(
|
69 |
+
'toolset-user-editors-basic-style',
|
70 |
+
TOOLSET_COMMON_URL . '/user-editors/editor/screen/basic/backend.css',
|
71 |
+
array(),
|
72 |
+
TOOLSET_COMMON_VERSION
|
73 |
+
);
|
74 |
|
75 |
$toolset_assets_manager->register_script(
|
76 |
'toolset-user-editors-basic-script',
|
107 |
public function admin_enqueue_assets() {
|
108 |
if ( $this->is_views_or_wpa_edit_page() ) {
|
109 |
do_action( 'toolset_enqueue_scripts', array( 'toolset-user-editors-basic-layout-template-script' ) );
|
110 |
+
do_action( 'toolset_enqueue_styles', array( 'toolset-user-editors-basic-style' ) );
|
111 |
}
|
112 |
}
|
113 |
|
114 |
public function action_assets() {
|
115 |
|
116 |
do_action( 'toolset_enqueue_scripts', array( 'toolset-user-editors-basic-script' ) );
|
117 |
+
do_action( 'toolset_enqueue_styles', array( 'toolset-user-editors-basic-style' ) );
|
118 |
|
119 |
}
|
120 |
|
vendor/toolset/toolset-common/user-editors/editor/screen/beaver/backend.php
CHANGED
@@ -294,10 +294,12 @@ class Toolset_User_Editors_Editor_Screen_Beaver_Backend
|
|
294 |
$content_template_has_beaver = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'BEAVER_SCREEN_ID' ) );
|
295 |
?>
|
296 |
<button
|
297 |
-
class="button button-secondary js-wpv-ct-apply-user-editor js-wpv-ct-apply-user-editor-<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
298 |
data-editor="<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
|
|
299 |
<?php disabled( $content_template_has_beaver );?>
|
300 |
>
|
|
|
301 |
<?php echo esc_html( $this->editor->get_name() ); ?>
|
302 |
</button>
|
303 |
<?php
|
294 |
$content_template_has_beaver = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'BEAVER_SCREEN_ID' ) );
|
295 |
?>
|
296 |
<button
|
297 |
+
class="button button-secondary toolset-ct-button-logo js-wpv-ct-apply-user-editor js-wpv-ct-apply-user-editor-<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
298 |
data-editor="<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
299 |
+
title="<?php echo __( 'Edit with', 'wpv-views' ) . ' ' . $this->editor->get_name() ?>"
|
300 |
<?php disabled( $content_template_has_beaver );?>
|
301 |
>
|
302 |
+
<img src="<?php echo $this->constants->constant( 'TOOLSET_COMMON_URL' ) . '/res/images/third-party/logos/' . $this->editor->get_logo_image_svg(); ?>" />
|
303 |
<?php echo esc_html( $this->editor->get_name() ); ?>
|
304 |
</button>
|
305 |
<?php
|
vendor/toolset/toolset-common/user-editors/editor/screen/beaver/frontend.php
CHANGED
@@ -127,9 +127,28 @@ class Toolset_User_Editors_Editor_Screen_Beaver_Frontend
|
|
127 |
// Fake being in the loop.
|
128 |
$wp_query->in_the_loop = true;
|
129 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
$content = FLBuilder::render_content( $content );
|
132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
if ( $revert_in_the_loop ) {
|
134 |
$wp_query->in_the_loop = false;
|
135 |
}
|
127 |
// Fake being in the loop.
|
128 |
$wp_query->in_the_loop = true;
|
129 |
}
|
130 |
+
|
131 |
+
// In Beaver Builder 2.0, when the FLBuilder::render_content method is used, Beaver Builder is getting the
|
132 |
+
// post ID by forcing globals, which means that they force the use of WP globals instead of checking their
|
133 |
+
// internal post ID.
|
134 |
+
// The WP globals contains the post currently rendered and not the Content Template, so we need to temporarily
|
135 |
+
// set the Content Template in the $wp_the_query (which they use) and then put the old post in its place
|
136 |
+
// after the content is rendered.
|
137 |
+
global $wp_the_query;
|
138 |
+
$wp_the_query_post = $wp_the_query->post;
|
139 |
+
if ( (int) $template_selected !== $wp_the_query_post->ID ) {
|
140 |
+
$ct_post = get_post( $template_selected );
|
141 |
+
$wp_the_query->post = $ct_post;
|
142 |
+
}
|
143 |
|
144 |
$content = FLBuilder::render_content( $content );
|
145 |
|
146 |
+
// If the post inside the $wp_the_query global has been substituted by the Content Template, we are putting
|
147 |
+
// it back.
|
148 |
+
if ( $wp_the_query->post->ID !== $wp_the_query_post->ID ) {
|
149 |
+
$wp_the_query->post = $wp_the_query_post;
|
150 |
+
}
|
151 |
+
|
152 |
if ( $revert_in_the_loop ) {
|
153 |
$wp_query->in_the_loop = false;
|
154 |
}
|
vendor/toolset/toolset-common/user-editors/editor/screen/divi/backend.php
CHANGED
@@ -171,8 +171,9 @@ class Toolset_User_Editors_Editor_Screen_Divi_Backend
|
|
171 |
$content_template_has_divi = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'DIVI_SCREEN_ID' ) );
|
172 |
?>
|
173 |
<button
|
174 |
-
class="button button-secondary js-wpv-ct-apply-user-editor js-wpv-ct-apply-user-editor-<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
175 |
data-editor="<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
|
|
176 |
<?php disabled( $content_template_has_divi ); ?>
|
177 |
>
|
178 |
<?php echo esc_html( $this->editor->get_name() ); ?>
|
171 |
$content_template_has_divi = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'DIVI_SCREEN_ID' ) );
|
172 |
?>
|
173 |
<button
|
174 |
+
class="button button-secondary toolset-ct-button-logo js-wpv-ct-apply-user-editor js-wpv-ct-apply-user-editor-<?php echo esc_attr( $this->editor->get_id() ); ?> <?php echo $this->editor->get_logo_class(); ?>"
|
175 |
data-editor="<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
176 |
+
title="<?php echo __( 'Edit with', 'wpv-views' ) . ' ' . $this->editor->get_name() ?>"
|
177 |
<?php disabled( $content_template_has_divi ); ?>
|
178 |
>
|
179 |
<?php echo esc_html( $this->editor->get_name() ); ?>
|
vendor/toolset/toolset-common/user-editors/editor/screen/native/backend.php
CHANGED
@@ -171,8 +171,9 @@ class Toolset_User_Editors_Editor_Screen_Native_Backend
|
|
171 |
$content_template_has_native = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'NATIVE_SCREEN_ID' ) );
|
172 |
?>
|
173 |
<button
|
174 |
-
class="button button-secondary js-wpv-ct-apply-user-editor js-wpv-ct-apply-user-editor-<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
175 |
data-editor="<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
|
|
176 |
<?php disabled( $content_template_has_native ); ?>
|
177 |
>
|
178 |
<?php echo esc_html( $this->editor->get_name() ); ?>
|
171 |
$content_template_has_native = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'NATIVE_SCREEN_ID' ) );
|
172 |
?>
|
173 |
<button
|
174 |
+
class="button button-secondary toolset-ct-button-logo js-wpv-ct-apply-user-editor js-wpv-ct-apply-user-editor-<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
175 |
data-editor="<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
176 |
+
title="<?php echo __( 'Edit with', 'wpv-views' ) . ' ' . $this->editor->get_name() ?>"
|
177 |
<?php disabled( $content_template_has_native ); ?>
|
178 |
>
|
179 |
<?php echo esc_html( $this->editor->get_name() ); ?>
|
vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/backend.php
CHANGED
@@ -25,6 +25,8 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
|
|
25 |
}
|
26 |
|
27 |
public function initialize() {
|
|
|
|
|
28 |
add_action( 'init', array( $this, 'register_assets' ), 50 );
|
29 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ), 50 );
|
30 |
|
@@ -36,13 +38,13 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
|
|
36 |
|
37 |
add_action( 'wpv_action_wpv_save_item', array( $this, 'save_vc_custom_css' ) );
|
38 |
|
39 |
-
add_filter( 'vc_btn_a_href', array(
|
40 |
add_filter( 'vc_btn_a_href', 'do_shortcode' );
|
41 |
|
42 |
-
add_filter( 'vc_btn_a_title', array(
|
43 |
add_filter( 'vc_btn_a_title', 'do_shortcode' );
|
44 |
|
45 |
-
add_filter( 'vc_raw_html_module_content', array(
|
46 |
|
47 |
// Post edit page integration
|
48 |
//add_action( 'edit_form_after_title', array( $this, 'preventNested' ) );
|
@@ -86,7 +88,7 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
|
|
86 |
* called on action 'admin_init'
|
87 |
*/
|
88 |
public function setup() {
|
89 |
-
// Disable Visual
|
90 |
vc_disable_frontend();
|
91 |
|
92 |
// Get backend editor object through VC_Manager (vc di container)
|
@@ -172,7 +174,7 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
|
|
172 |
&& $ct_edit_page_screen_id === $screen_id
|
173 |
) {
|
174 |
// We need to enqueue the following style and script on the Content Template edit page but only when the
|
175 |
-
// template is built with Visual Composer.
|
176 |
do_action( 'toolset_enqueue_scripts', array( 'toolset-user-editors-vc-script' ) );
|
177 |
do_action( 'toolset_enqueue_styles', array( 'toolset-user-editors-vc-editor-style' ) );
|
178 |
}
|
@@ -194,7 +196,7 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
|
|
194 |
. sprintf(
|
195 |
__( '%1$sStop using %2$s for this Content Template%3$s', 'wpv-views' ),
|
196 |
'<a href="' . esc_url( $admin_url ) . '&ct_editor_choice=basic">',
|
197 |
-
|
198 |
'</a>'
|
199 |
)
|
200 |
. '</p>';
|
@@ -283,11 +285,13 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
|
|
283 |
$content_template_has_vc = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'VC_SCREEN_ID' ) );
|
284 |
?>
|
285 |
<button
|
286 |
-
class="button button-secondary js-wpv-ct-apply-user-editor js-wpv-ct-apply-user-editor-<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
287 |
data-editor="<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
|
|
288 |
<?php disabled( $content_template_has_vc );?>
|
289 |
>
|
290 |
-
|
|
|
291 |
</button>
|
292 |
<?php
|
293 |
}
|
@@ -316,7 +320,7 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
|
|
316 |
}
|
317 |
|
318 |
/**
|
319 |
-
* Save Visual Composer Custom CSS upon content template save.
|
320 |
*
|
321 |
* @param $content_template_id The ID of the content template to save the custom CSS for.
|
322 |
*
|
25 |
}
|
26 |
|
27 |
public function initialize() {
|
28 |
+
$shortcode_transformer = new Toolset_Shortcode_Transformer();
|
29 |
+
|
30 |
add_action( 'init', array( $this, 'register_assets' ), 50 );
|
31 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ), 50 );
|
32 |
|
38 |
|
39 |
add_action( 'wpv_action_wpv_save_item', array( $this, 'save_vc_custom_css' ) );
|
40 |
|
41 |
+
add_filter( 'vc_btn_a_href', array( $shortcode_transformer, 'replace_shortcode_placeholders_with_brackets' ) );
|
42 |
add_filter( 'vc_btn_a_href', 'do_shortcode' );
|
43 |
|
44 |
+
add_filter( 'vc_btn_a_title', array( $shortcode_transformer, 'replace_shortcode_placeholders_with_brackets' ) );
|
45 |
add_filter( 'vc_btn_a_title', 'do_shortcode' );
|
46 |
|
47 |
+
add_filter( 'vc_raw_html_module_content', array( $shortcode_transformer, 'replace_shortcode_placeholders_with_brackets' ) );
|
48 |
|
49 |
// Post edit page integration
|
50 |
//add_action( 'edit_form_after_title', array( $this, 'preventNested' ) );
|
88 |
* called on action 'admin_init'
|
89 |
*/
|
90 |
public function setup() {
|
91 |
+
// Disable WPBakery Page Builder (former Visual Composer) Frontend Editor
|
92 |
vc_disable_frontend();
|
93 |
|
94 |
// Get backend editor object through VC_Manager (vc di container)
|
174 |
&& $ct_edit_page_screen_id === $screen_id
|
175 |
) {
|
176 |
// We need to enqueue the following style and script on the Content Template edit page but only when the
|
177 |
+
// template is built with WPBakery Page Builder (former Visual Composer).
|
178 |
do_action( 'toolset_enqueue_scripts', array( 'toolset-user-editors-vc-script' ) );
|
179 |
do_action( 'toolset_enqueue_styles', array( 'toolset-user-editors-vc-editor-style' ) );
|
180 |
}
|
196 |
. sprintf(
|
197 |
__( '%1$sStop using %2$s for this Content Template%3$s', 'wpv-views' ),
|
198 |
'<a href="' . esc_url( $admin_url ) . '&ct_editor_choice=basic">',
|
199 |
+
$this->medium->get_manager()->get_active_editor()->get_name(),
|
200 |
'</a>'
|
201 |
)
|
202 |
. '</p>';
|
285 |
$content_template_has_vc = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'VC_SCREEN_ID' ) );
|
286 |
?>
|
287 |
<button
|
288 |
+
class="button button-secondary toolset-ct-button-logo js-wpv-ct-apply-user-editor js-wpv-ct-apply-user-editor-<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
289 |
data-editor="<?php echo esc_attr( $this->editor->get_id() ); ?>"
|
290 |
+
title="<?php echo __( 'Edit with', 'wpv-views' ) . ' ' . $this->editor->get_name() ?>"
|
291 |
<?php disabled( $content_template_has_vc );?>
|
292 |
>
|
293 |
+
<img src="<?php echo $this->constants->constant( 'TOOLSET_COMMON_URL' ) . '/res/images/third-party/logos/' . $this->editor->get_logo_image_svg(); ?>" />
|
294 |
+
<?php echo esc_html( $this->editor->get_name() ); ?>
|
295 |
</button>
|
296 |
<?php
|
297 |
}
|
320 |
}
|
321 |
|
322 |
/**
|
323 |
+
* Save WPBakery Page Builder (former Visual Composer) Custom CSS upon content template save.
|
324 |
*
|
325 |
* @param $content_template_id The ID of the content template to save the custom CSS for.
|
326 |
*
|
vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/frontend.php
CHANGED
@@ -7,15 +7,17 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Frontend
|
|
7 |
add_action( 'init', array( $this, 'map_all_vc_shortcodes' ) );
|
8 |
|
9 |
add_action( 'the_content', array( $this, 'render_custom_css' ) );
|
|
|
|
|
10 |
|
11 |
-
// this adds the [Fields and Views] to editor of
|
12 |
if( array_key_exists( 'action', $_POST ) && $_POST['action'] == 'vc_edit_form' ) {
|
13 |
add_filter( 'wpv_filter_dialog_for_editors_requires_post', '__return_false' );
|
14 |
}
|
15 |
}
|
16 |
|
17 |
/**
|
18 |
-
* We need to force the registration of all the Visual Composer shortcodes in order to be rendered properly upon CT
|
19 |
* rendering.
|
20 |
*/
|
21 |
public function map_all_vc_shortcodes() {
|
@@ -26,7 +28,7 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Frontend
|
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
-
* Visual Composer stores custom css as postmeta.
|
30 |
* We need to check if current post has content_template and if so apply the custom css.
|
31 |
* Hooked to the_content
|
32 |
*
|
@@ -50,4 +52,45 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Frontend
|
|
50 |
return $content;
|
51 |
}
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
add_action( 'init', array( $this, 'map_all_vc_shortcodes' ) );
|
8 |
|
9 |
add_action( 'the_content', array( $this, 'render_custom_css' ) );
|
10 |
+
|
11 |
+
add_filter( 'vc_basic_grid_find_post_shortcode', array( $this, 'maybe_get_shortcode_from_assigned_ct_id' ), 10, 3 );
|
12 |
|
13 |
+
// this adds the [Fields and Views] to editor of WPBakery Page Builder (former Visual Composer) text element
|
14 |
if( array_key_exists( 'action', $_POST ) && $_POST['action'] == 'vc_edit_form' ) {
|
15 |
add_filter( 'wpv_filter_dialog_for_editors_requires_post', '__return_false' );
|
16 |
}
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
+
* We need to force the registration of all the WPBakery Page Builder (former Visual Composer) shortcodes in order to be rendered properly upon CT
|
21 |
* rendering.
|
22 |
*/
|
23 |
public function map_all_vc_shortcodes() {
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
+
* WPBakery Page Builder (former Visual Composer) stores custom css as postmeta.
|
32 |
* We need to check if current post has content_template and if so apply the custom css.
|
33 |
* Hooked to the_content
|
34 |
*
|
52 |
return $content;
|
53 |
}
|
54 |
|
55 |
+
/**
|
56 |
+
* Some of the WPBakery Page Builder (former Visual Composer) shortcodes are accessing the post meta of the post
|
57 |
+
* currently displayed to get the setting of the shortcodes settings. For the case where a Content Template is built
|
58 |
+
* with WPBakery Page Builder (former Visual Composer), in order for the shortcode settings to be retrieved correctly
|
59 |
+
* we need to access the Content Template post.
|
60 |
+
*
|
61 |
+
* @note Part of the method's code is copied by "findPostShortcodeById" method of WPBakery Page Builder.
|
62 |
+
*
|
63 |
+
* @param $shortcode The shortcode currently being rendered.
|
64 |
+
* @param $page_id The page ID currently displayed.
|
65 |
+
* @param $grid_id The grid ID saved inside the post meta.
|
66 |
+
*
|
67 |
+
* @return array The new shortcode fetched from the Content Template
|
68 |
+
*
|
69 |
+
* @since 2.5.7
|
70 |
+
*/
|
71 |
+
public function maybe_get_shortcode_from_assigned_ct_id( $shortcode, $page_id, $grid_id ) {
|
72 |
+
$page_id = intval( $page_id );
|
73 |
+
$template_selected = get_post_meta( $page_id, '_views_template', true );
|
74 |
+
if (
|
75 |
+
! empty( $template_selected )
|
76 |
+
&& intval( $template_selected ) > 0
|
77 |
+
) {
|
78 |
+
$page_id = $template_selected;
|
79 |
+
}
|
80 |
+
|
81 |
+
$post_meta = get_post_meta( (int) $page_id, '_vc_post_settings' );
|
82 |
+
|
83 |
+
$shortcode = '';
|
84 |
+
|
85 |
+
if ( is_array( $post_meta ) ) {
|
86 |
+
foreach ( $post_meta as $meta ) {
|
87 |
+
if ( isset( $meta['vc_grid_id'] ) && ! empty( $meta['vc_grid_id']['shortcodes'] ) && isset( $meta['vc_grid_id']['shortcodes'][ $grid_id ] ) ) {
|
88 |
+
$shortcode = $meta['vc_grid_id']['shortcodes'][ $grid_id ];
|
89 |
+
break;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
return $shortcode;
|
95 |
+
}
|
96 |
+
}
|
vendor/toolset/toolset-common/user-editors/editor/visual-composer.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Editor class for the Visual Composer.
|
4 |
*
|
5 |
-
* Handles all the functionality needed to allow the Visual Composer to work with Content Template editing.
|
6 |
*
|
7 |
* @since 2.5.0
|
8 |
*/
|
@@ -11,15 +11,23 @@ class Toolset_User_Editors_Editor_Visual_Composer
|
|
11 |
extends Toolset_User_Editors_Editor_Abstract {
|
12 |
|
13 |
protected $id = 'vc';
|
14 |
-
protected $name = '
|
15 |
protected $option_name = '_toolset_user_editors_vc';
|
16 |
|
|
|
|
|
17 |
/**
|
18 |
* Minimum Version
|
19 |
* @var string version number
|
20 |
*/
|
21 |
protected $minimum_version = '4.11';
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
public function required_plugin_active() {
|
24 |
|
25 |
if ( ! apply_filters( 'toolset_is_views_available', false ) ) {
|
@@ -36,6 +44,11 @@ class Toolset_User_Editors_Editor_Visual_Composer
|
|
36 |
return false;
|
37 |
}
|
38 |
|
|
|
|
|
|
|
|
|
|
|
39 |
return true;
|
40 |
}
|
41 |
|
@@ -58,7 +71,7 @@ class Toolset_User_Editors_Editor_Visual_Composer
|
|
58 |
|
59 |
/**
|
60 |
* We need to add Views type of content templates
|
61 |
-
* to the allowed types of Visual Composer
|
62 |
*
|
63 |
*
|
64 |
* @param $default
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Editor class for the WPBakery Page Builder (former Visual Composer).
|
4 |
*
|
5 |
+
* Handles all the functionality needed to allow the WPBakery Page Builder (former Visual Composer) to work with Content Template editing.
|
6 |
*
|
7 |
* @since 2.5.0
|
8 |
*/
|
11 |
extends Toolset_User_Editors_Editor_Abstract {
|
12 |
|
13 |
protected $id = 'vc';
|
14 |
+
protected $name = 'WPBakery Page Builder';
|
15 |
protected $option_name = '_toolset_user_editors_vc';
|
16 |
|
17 |
+
protected $logo_image_svg = 'vc.svg';
|
18 |
+
|
19 |
/**
|
20 |
* Minimum Version
|
21 |
* @var string version number
|
22 |
*/
|
23 |
protected $minimum_version = '4.11';
|
24 |
|
25 |
+
/**
|
26 |
+
* Minimum WP Bakery page builder Version (new branding)
|
27 |
+
* @var string version number
|
28 |
+
*/
|
29 |
+
protected $minimum_wp_bakery_pb_version = '5.4';
|
30 |
+
|
31 |
public function required_plugin_active() {
|
32 |
|
33 |
if ( ! apply_filters( 'toolset_is_views_available', false ) ) {
|
44 |
return false;
|
45 |
}
|
46 |
|
47 |
+
if( version_compare( WPB_VC_VERSION, $this->minimum_wp_bakery_pb_version ) < 0 ) {
|
48 |
+
$this->name = 'Visual Composer';
|
49 |
+
$this->logo_image_svg = 'vc_old.svg';
|
50 |
+
}
|
51 |
+
|
52 |
return true;
|
53 |
}
|
54 |
|
71 |
|
72 |
/**
|
73 |
* We need to add Views type of content templates
|
74 |
+
* to the allowed types of WPBakery Page Builder (former Visual Composer).
|
75 |
*
|
76 |
*
|
77 |
* @param $default
|
vendor/toolset/toolset-common/user-editors/medium/content-template.php
CHANGED
@@ -299,7 +299,14 @@ class Toolset_User_Editors_Medium_Content_Template
|
|
299 |
) {
|
300 |
continue;
|
301 |
}
|
302 |
-
$editor_switch_buttons[] =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
}
|
304 |
}
|
305 |
|
299 |
) {
|
300 |
continue;
|
301 |
}
|
302 |
+
$editor_switch_buttons[] = sprintf(
|
303 |
+
'<a class="button button-secondary js-wpv-ct-apply-user-editor toolset-ct-button-logo %s" href="%s" title="%s">%s %s</a>',
|
304 |
+
sanitize_html_class( $editor->get_logo_class() ),
|
305 |
+
esc_url($admin_url . '&ct_editor_choice=' . $editor->get_id() ),
|
306 |
+
esc_attr( __( 'Edit with', 'wpv-views' ) . ' ' . $editor->get_name() ),
|
307 |
+
$editor->get_logo_image_svg() ? '<img src="' . esc_url( $this->constants->constant( 'TOOLSET_COMMON_URL' ) . '/res/images/third-party/logos/' . $editor->get_logo_image_svg() ) . '" />' : '',
|
308 |
+
esc_html( $editor->get_name() )
|
309 |
+
);
|
310 |
}
|
311 |
}
|
312 |
|
vendor/toolset/toolset-common/user-editors/medium/interface.php
CHANGED
@@ -77,7 +77,7 @@ interface Toolset_User_Editors_Medium_Interface {
|
|
77 |
|
78 |
/**
|
79 |
* Used by setup, to give the medium the user selection for editors
|
80 |
-
* e.g. Setup generates editor selection 'Default | Visual Composer | Beaver'
|
81 |
* and gives it to Content Template which decides where to place
|
82 |
*
|
83 |
* @param $selection callable
|
77 |
|
78 |
/**
|
79 |
* Used by setup, to give the medium the user selection for editors
|
80 |
+
* e.g. Setup generates editor selection 'Default | WPBakery Page Builder (former Visual Composer) | Beaver'
|
81 |
* and gives it to Content Template which decides where to place
|
82 |
*
|
83 |
* @param $selection callable
|
vendor/toolset/toolset-common/user-editors/medium/screen/content-template/frontend-editor.css
CHANGED
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
1 |
#wpv-ct-preview-post {
|
2 |
width: 170px;
|
3 |
display: inline;
|
1 |
+
.fl-builder .wpv-dialog ul {
|
2 |
+
list-style-type: none;
|
3 |
+
}
|
4 |
+
|
5 |
#wpv-ct-preview-post {
|
6 |
width: 170px;
|
7 |
display: inline;
|
vendor/toolset/toolset-common/user-editors/medium/screen/content-template/frontend-editor.js
CHANGED
@@ -24,11 +24,34 @@ ToolsetCommon.UserEditor.BeaverBuilderFrontendEditor = function( $ ) {
|
|
24 |
self.setExitUrl = function() {
|
25 |
FLBuilder._exitUrl = toolset_user_editors.mediumUrl;
|
26 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
$( window ).load( self.setExitUrl );
|
29 |
$( document ).on( 'click', '.fl-builder-save-actions .fl-builder-publish-button', self.setExitUrl );
|
30 |
$( document ).on( 'click', '.fl-builder-save-actions .fl-builder-discard-button', self.setExitUrl );
|
31 |
$( document ).on( 'click', '.fl-builder-save-actions .fl-builder-cancel-button', self.setExitUrl );
|
|
|
|
|
|
|
32 |
|
33 |
self.previewPostSelector.on( 'change', function() {
|
34 |
$.ajax( {
|
24 |
self.setExitUrl = function() {
|
25 |
FLBuilder._exitUrl = toolset_user_editors.mediumUrl;
|
26 |
};
|
27 |
+
|
28 |
+
/**
|
29 |
+
* As of Beaver Builder 2.0 in order to exit the builder page and return to the Content Template edit page
|
30 |
+
* we need to force set the "shouldRefreshOnPublish" setting to true.
|
31 |
+
*/
|
32 |
+
self.setForceRefreshOnPublish = function() {
|
33 |
+
if ( !FLBuilderConfig.shouldRefreshOnPublish ) {
|
34 |
+
FLBuilderConfig.shouldRefreshOnPublish = true;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
self.forceResetAndExit = function() {
|
39 |
+
self.setExitUrl();
|
40 |
+
self.setForceRefreshOnPublish();
|
41 |
+
}
|
42 |
+
|
43 |
+
self.doneButtonClicked = function() {
|
44 |
+
self.forceResetAndExit();
|
45 |
+
FLBuilder.triggerHook('triggerDone');
|
46 |
+
}
|
47 |
|
48 |
$( window ).load( self.setExitUrl );
|
49 |
$( document ).on( 'click', '.fl-builder-save-actions .fl-builder-publish-button', self.setExitUrl );
|
50 |
$( document ).on( 'click', '.fl-builder-save-actions .fl-builder-discard-button', self.setExitUrl );
|
51 |
$( document ).on( 'click', '.fl-builder-save-actions .fl-builder-cancel-button', self.setExitUrl );
|
52 |
+
|
53 |
+
$( document ).on( 'click', '.fl-builder-done-button.fl-builder-button', self.doneButtonClicked );
|
54 |
+
$( document ).on( 'click', '.fl-builder-button.fl-builder-button-primary[data-action="publish"]', self.forceResetAndExit );
|
55 |
|
56 |
self.previewPostSelector.on( 'change', function() {
|
57 |
$.ajax( {
|
vendor/toolset/toolset-common/utility/admin/notice/abstract.php
CHANGED
@@ -301,4 +301,10 @@ abstract class Toolset_Admin_Notice_Abstract implements Toolset_Admin_Notice_Int
|
|
301 |
? false
|
302 |
: true;
|
303 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
}
|
301 |
? false
|
302 |
: true;
|
303 |
}
|
304 |
+
|
305 |
+
public function set_template_path( $template_path ) {
|
306 |
+
if( file_exists( $template_path ) ) {
|
307 |
+
$this->template_file = $template_path;
|
308 |
+
}
|
309 |
+
}
|
310 |
}
|
vendor/toolset/toolset-common/utility/admin/notices/manager.php
CHANGED
@@ -85,7 +85,7 @@ class Toolset_Admin_Notices_Manager {
|
|
85 |
|
86 |
if( array_key_exists( $notice->get_id(), self::$notices ) ) {
|
87 |
// abort, key already exists
|
88 |
-
error_log( 'Toolset_Admin_Notices_Manager Info: Notices with key "' . $notice->get_id() . '" already exists.' );
|
89 |
|
90 |
return false;
|
91 |
}
|
85 |
|
86 |
if( array_key_exists( $notice->get_id(), self::$notices ) ) {
|
87 |
// abort, key already exists
|
88 |
+
//error_log( 'Toolset_Admin_Notices_Manager Info: Notices with key "' . $notice->get_id() . '" already exists.' );
|
89 |
|
90 |
return false;
|
91 |
}
|
vendor/toolset/toolset-common/utility/condition/theme/layouts-support/native/available.php
CHANGED
@@ -25,9 +25,23 @@ class Toolset_Condition_Theme_Layouts_Support_Native_Available implements Toolse
|
|
25 |
|
26 |
// theme path (and child theme path if active)
|
27 |
$theme_paths = array_unique( array( get_template_directory(), get_stylesheet_directory() ) );
|
28 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
foreach(
|
31 |
$file_content = @file_get_contents( $file );
|
32 |
if( is_string( $file_content ) && strpos( $file_content, 'the_ddlayout' ) !== false ) {
|
33 |
// native Layouts support!
|
25 |
|
26 |
// theme path (and child theme path if active)
|
27 |
$theme_paths = array_unique( array( get_template_directory(), get_stylesheet_directory() ) );
|
28 |
+
$files_starting_with = array( 'index', 'single', 'archive' );
|
29 |
+
$search_pattern = '{' . implode( $theme_paths, ',' ) . '}/{' . implode( $files_starting_with, ',' ) . '}*.php';
|
30 |
+
|
31 |
+
if( defined( 'GLOB_BRACE' ) ) {
|
32 |
+
$template_files = glob( $search_pattern, GLOB_BRACE );
|
33 |
+
} else {
|
34 |
+
$template_files = array();
|
35 |
+
foreach( $theme_paths as $theme_path ) {
|
36 |
+
foreach( $files_starting_with as $file ) {
|
37 |
+
foreach( glob( $theme_path . '/' . $file . '*.php' ) as $found_file ) {
|
38 |
+
$template_files[] = $found_file;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
|
44 |
+
foreach( $template_files as $file ) {
|
45 |
$file_content = @file_get_contents( $file );
|
46 |
if( is_string( $file_content ) && strpos( $file_content, 'the_ddlayout' ) !== false ) {
|
47 |
// native Layouts support!
|
vendor/toolset/toolset-common/utility/dialogs/css/dd-dialogs-forms.css
CHANGED
@@ -479,8 +479,14 @@ a.ddl-duplicate-anchor{cursor:pointer;}
|
|
479 |
.ddl-setting-for-layouts-container-in-iframe .css-styling-controls{padding-top:0px;margin-top:0px;}
|
480 |
.ddl-setting-for-layouts-container-in-iframe span.desc{padding-bottom:6px;padding-top:0px;width:555px!important;}
|
481 |
input.css-id-control{width:555px!important;}
|
482 |
-
|
|
|
|
|
|
|
483 |
/*///////// OVERRIDES /////////////////*/
|
|
|
|
|
|
|
484 |
.ui-dialog-buttonpane{padding: 8px;}
|
485 |
|
486 |
.ddl-youtube-video-cell span.px_box {
|
479 |
.ddl-setting-for-layouts-container-in-iframe .css-styling-controls{padding-top:0px;margin-top:0px;}
|
480 |
.ddl-setting-for-layouts-container-in-iframe span.desc{padding-bottom:6px;padding-top:0px;width:555px!important;}
|
481 |
input.css-id-control{width:555px!important;}
|
482 |
+
/*
|
483 |
+
@todo This should not be here, cotainers with specific size limitations should have a specific classname, not the generic Toolset dialogs ones.
|
484 |
+
*/
|
485 |
+
.toolset-ui-dialog:not(.toolset-ui-dialog-responsive) .toolset-shortcode-gui-dialog-container{min-height:92px!important;max-height:370px!important;}
|
486 |
/*///////// OVERRIDES /////////////////*/
|
487 |
+
/*
|
488 |
+
@todo This should not be here, buttonpanes with specific styles should have a specific classname, not the generic Toolset dialogs ones.
|
489 |
+
*/
|
490 |
.ui-dialog-buttonpane{padding: 8px;}
|
491 |
|
492 |
.ddl-youtube-video-cell span.px_box {
|
vendor/toolset/toolset-common/utility/gui-base/js/ListingViewModel.js
CHANGED
@@ -33,7 +33,7 @@ Toolset.Gui.ListingViewModel = function(itemModels, defaults, itemSearchFunction
|
|
33 |
var newDirection = (
|
34 |
sortHelper.currentSortBy() === propertyName
|
35 |
? sortHelper.currentSortDirection() * -1
|
36 |
-
:
|
37 |
);
|
38 |
sortHelper.sortItems(propertyName, newDirection);
|
39 |
};
|
33 |
var newDirection = (
|
34 |
sortHelper.currentSortBy() === propertyName
|
35 |
? sortHelper.currentSortDirection() * -1
|
36 |
+
: 1 // If it is not the current column it starts with ascending sorting.
|
37 |
);
|
38 |
sortHelper.sortItems(propertyName, newDirection);
|
39 |
};
|
vendor/toolset/toolset-common/utility/gui-base/main.php
CHANGED
@@ -161,7 +161,6 @@ class Toolset_Gui_Base {
|
|
161 |
$gui_base_classmap = array(
|
162 |
'Toolset_Twig_Dialog_Box_Factory' => "$base_path/twig_dialog_box_factory.php",
|
163 |
'Toolset_Twig_Dialog_Box' => "$base_path/twig_dialog_box.php",
|
164 |
-
'Toolset_Twig_Dialog_Box_Factory' => "$base_path/twig_dialog_box_factory.php",
|
165 |
'Toolset_Twig_Autoloader' => "$base_path/twig_autoloader.php",
|
166 |
'Toolset_Twig_Extensions' => "$base_path/twig_extensions.php"
|
167 |
);
|
161 |
$gui_base_classmap = array(
|
162 |
'Toolset_Twig_Dialog_Box_Factory' => "$base_path/twig_dialog_box_factory.php",
|
163 |
'Toolset_Twig_Dialog_Box' => "$base_path/twig_dialog_box.php",
|
|
|
164 |
'Toolset_Twig_Autoloader' => "$base_path/twig_autoloader.php",
|
165 |
'Toolset_Twig_Extensions' => "$base_path/twig_extensions.php"
|
166 |
);
|
vendor/toolset/toolset-common/utility/gui-base/toolset-gui-base.css
CHANGED
@@ -63,6 +63,10 @@
|
|
63 |
text-shadow: 0 -1px 1px red, 1px 0 1px red, 0 1px 1px red, -1px 0 1px red !important;
|
64 |
}
|
65 |
|
|
|
|
|
|
|
|
|
66 |
|
67 |
/* Override styling from basic.css in Types back to default. */
|
68 |
body.wp-admin button.ui-corner-all.toolset-button-in-dialog {
|
63 |
text-shadow: 0 -1px 1px red, 1px 0 1px red, 0 1px 1px red, -1px 0 1px red !important;
|
64 |
}
|
65 |
|
66 |
+
/* Button in a row */
|
67 |
+
.toolset-button-in-row + .toolset-button-in-row {
|
68 |
+
margin-left: 8px;
|
69 |
+
}
|
70 |
|
71 |
/* Override styling from basic.css in Types back to default. */
|
72 |
body.wp-admin button.ui-corner-all.toolset-button-in-dialog {
|
vendor/toolset/toolset-common/utility/gui-base/twig_autoloader.php
CHANGED
@@ -27,6 +27,7 @@
|
|
27 |
* @author Fabien Potencier <fabien@symfony.com>
|
28 |
*
|
29 |
* @since 2.2
|
|
|
30 |
*/
|
31 |
class Toolset_Twig_Autoloader {
|
32 |
|
@@ -51,6 +52,12 @@ class Toolset_Twig_Autoloader {
|
|
51 |
}
|
52 |
}
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
if ( PHP_VERSION_ID < 50300 ) {
|
55 |
spl_autoload_register( array( __CLASS__, 'autoload' ) );
|
56 |
} else {
|
27 |
* @author Fabien Potencier <fabien@symfony.com>
|
28 |
*
|
29 |
* @since 2.2
|
30 |
+
* @since 2.5.6 Autoloader bails out when it's possible to load the Twig_Environment class.
|
31 |
*/
|
32 |
class Toolset_Twig_Autoloader {
|
33 |
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
// Also resign if it's simply possible to load a Twig Environment class already.
|
56 |
+
// That probably means a composer autoloader is managing this.
|
57 |
+
if( class_exists( 'Twig_Environment', true ) ) {
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
|
61 |
if ( PHP_VERSION_ID < 50300 ) {
|
62 |
spl_autoload_register( array( __CLASS__, 'autoload' ) );
|
63 |
} else {
|
vendor/toolset/toolset-common/utility/js/utils.js
CHANGED
@@ -1480,6 +1480,12 @@ WPV_Toolset.Utils._template = function (template, data, settings) {
|
|
1480 |
};
|
1481 |
|
1482 |
// override dialog whenever toolset is active and take possession
|
|
|
|
|
|
|
|
|
|
|
|
|
1483 |
if (jQuery && jQuery.ui && jQuery.ui.dialog) {
|
1484 |
jQuery.extend(jQuery.ui.dialog.prototype.options, {
|
1485 |
dialogClass: 'toolset-ui-dialog'
|
1480 |
};
|
1481 |
|
1482 |
// override dialog whenever toolset is active and take possession
|
1483 |
+
/**
|
1484 |
+
* @todo This should not be here:
|
1485 |
+
* dialogs with specific classnames should get it directly.
|
1486 |
+
* We should not be pre-setting all jQuery UI dialogs dialogClass setting,
|
1487 |
+
* we are not good players here.
|
1488 |
+
*/
|
1489 |
if (jQuery && jQuery.ui && jQuery.ui.dialog) {
|
1490 |
jQuery.extend(jQuery.ui.dialog.prototype.options, {
|
1491 |
dialogClass: 'toolset-ui-dialog'
|
vendor/toolset/toolset-common/utility/utils.php
CHANGED
@@ -162,7 +162,7 @@ if ( ! class_exists( 'Toolset_Utils', false ) ) {
|
|
162 |
*/
|
163 |
public static function is_integer( $value ) {
|
164 |
// http://stackoverflow.com/questions/2559923/shortest-way-to-check-if-a-variable-contains-positive-integer-using-php
|
165 |
-
return ( (int) $value == $value );
|
166 |
}
|
167 |
|
168 |
|
162 |
*/
|
163 |
public static function is_integer( $value ) {
|
164 |
// http://stackoverflow.com/questions/2559923/shortest-way-to-check-if-a-variable-contains-positive-integer-using-php
|
165 |
+
return ( (int) $value == $value && is_numeric( $value ) );
|
166 |
}
|
167 |
|
168 |
|
vendor/toolset/toolset-common/visual-editor/editor-addon.class.php
CHANGED
@@ -266,6 +266,8 @@ if ( file_exists( dirname(__FILE__) . '/editor-addon-generic.class.php') && !cla
|
|
266 |
$fields = wpcf_admin_fields_get_fields_by_group( $group['id'],
|
267 |
'slug', true, false, true, 'wp-types-user-group',
|
268 |
'wpcf-usermeta' );
|
|
|
|
|
269 |
|
270 |
if ( !empty( $fields ) ) {
|
271 |
foreach ( $fields as $field_id => $field ) {
|
266 |
$fields = wpcf_admin_fields_get_fields_by_group( $group['id'],
|
267 |
'slug', true, false, true, 'wp-types-user-group',
|
268 |
'wpcf-usermeta' );
|
269 |
+
// @since m2m wpcf_admin_fields_get_fields_by_group returns strings for repeatng fields groups
|
270 |
+
$fields = array_filter( $fields, 'is_array' );
|
271 |
|
272 |
if ( !empty( $fields ) ) {
|
273 |
foreach ( $fields as $field_id => $field ) {
|
vendor/toolset/types/embedded/classes/field/definition_abstract.php
CHANGED
@@ -89,7 +89,7 @@ abstract class WPCF_Field_Definition_Abstract {
|
|
89 |
'isUnderTypesControl' => $this->is_under_types_control(),
|
90 |
'slug' => $this->get_slug(),
|
91 |
'metaKey' => $this->get_slug(),
|
92 |
-
'displayName' => $this->get_name(),
|
93 |
'groups' => $this->get_group_slugs()
|
94 |
);
|
95 |
|
89 |
'isUnderTypesControl' => $this->is_under_types_control(),
|
90 |
'slug' => $this->get_slug(),
|
91 |
'metaKey' => $this->get_slug(),
|
92 |
+
'displayName' => stripslashes( $this->get_name() ),
|
93 |
'groups' => $this->get_group_slugs()
|
94 |
);
|
95 |
|
vendor/toolset/types/embedded/includes/conditional-display.php
CHANGED
@@ -82,7 +82,7 @@ function wpcf_cd_post_groups_filter( $groups, $post, $context ) {
|
|
82 |
*/
|
83 |
if ( is_array( $v) ) {
|
84 |
$v = array_shift($v);
|
85 |
-
if ( is_array($v) ) {
|
86 |
continue;
|
87 |
}
|
88 |
$v = strval( $v);
|
82 |
*/
|
83 |
if ( is_array( $v) ) {
|
84 |
$v = array_shift($v);
|
85 |
+
if ( is_array($v) || ( is_object( $v ) && ! method_exists( $v, '__toString' ) ) ) {
|
86 |
continue;
|
87 |
}
|
88 |
$v = strval( $v);
|
vendor/toolset/types/embedded/resources/js/basic.js
CHANGED
@@ -579,7 +579,7 @@ if( typeof typesStatusBasicJsScript === 'undefined' ) {
|
|
579 |
|
580 |
// Do not add the spinner if it's already present.
|
581 |
if( 0 == currentElement.parent().find( '#' + spinnerId ).length ) {
|
582 |
-
currentElement.
|
583 |
}
|
584 |
}
|
585 |
} );
|
@@ -590,7 +590,7 @@ if( typeof typesStatusBasicJsScript === 'undefined' ) {
|
|
590 |
*/
|
591 |
function wpcfLoadingButtonStop() {
|
592 |
jQuery( '.wpcf-disabled-on-submit' ).removeAttr( 'disabled' );
|
593 |
-
jQuery( '.wpcf-
|
594 |
//Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/194177056/comments
|
595 |
//type modal didnt disappeared
|
596 |
// jQuery('.types_modal_box').remove();
|
579 |
|
580 |
// Do not add the spinner if it's already present.
|
581 |
if( 0 == currentElement.parent().find( '#' + spinnerId ).length ) {
|
582 |
+
currentElement.before( '<div id="' + spinnerId + '" class="js-wpcf-spinner spinner is-active"> </div>' );
|
583 |
}
|
584 |
}
|
585 |
} );
|
590 |
*/
|
591 |
function wpcfLoadingButtonStop() {
|
592 |
jQuery( '.wpcf-disabled-on-submit' ).removeAttr( 'disabled' );
|
593 |
+
jQuery( '.js-wpcf-spinner' ).fadeOut();
|
594 |
//Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/194177056/comments
|
595 |
//type modal didnt disappeared
|
596 |
// jQuery('.types_modal_box').remove();
|
vendor/toolset/types/embedded/resources/js/modal.js
DELETED
@@ -1,280 +0,0 @@
|
|
1 |
-
(function($){
|
2 |
-
|
3 |
-
$.fn.types_modal_box = function(prop){
|
4 |
-
|
5 |
-
// Default parameters
|
6 |
-
|
7 |
-
var options = $.extend({
|
8 |
-
height : 364,
|
9 |
-
width : 525
|
10 |
-
},prop);
|
11 |
-
|
12 |
-
return this.submit(function(e){
|
13 |
-
if ( $(this).hasClass('js-types-do-not-show-modal')) {
|
14 |
-
return;
|
15 |
-
}
|
16 |
-
add_block_page();
|
17 |
-
pop_up = add_popup_box();
|
18 |
-
add_styles(pop_up);
|
19 |
-
$.colorbox({
|
20 |
-
html: pop_up.html(),
|
21 |
-
fixed: true,
|
22 |
-
closeButton: false
|
23 |
-
});
|
24 |
-
});
|
25 |
-
|
26 |
-
function add_styles(pop_up){
|
27 |
-
$('.types_modal_box', pop_up).css({
|
28 |
-
background: "#fff none no-repeat 0 0",
|
29 |
-
border: "1px solid #888",
|
30 |
-
boxShadow: "7px 7px 20px 0px rgba(50, 50, 50, 0.75)",
|
31 |
-
});
|
32 |
-
|
33 |
-
$('.types_modal_box .message', pop_up).css({
|
34 |
-
color: "#f05a28",
|
35 |
-
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', 'Open Sans', sans-serif",
|
36 |
-
fontSize: "25px",
|
37 |
-
padding: "0 10px",
|
38 |
-
textAlign: "center"
|
39 |
-
});
|
40 |
-
$('.types_modal_box .message span', pop_up).css({
|
41 |
-
background: "transparent url("+types_modal.spinner+") no-repeat 0 50%",
|
42 |
-
paddingLeft: "30px",
|
43 |
-
lineHeight: "105px"
|
44 |
-
});
|
45 |
-
}
|
46 |
-
|
47 |
-
function add_block_page(){
|
48 |
-
var block_page = $('<div class="types_block_page"></div>');
|
49 |
-
$(block_page).appendTo('body');
|
50 |
-
}
|
51 |
-
|
52 |
-
function add_popup_box(){
|
53 |
-
var marginLeft, height, paddingTop, width;
|
54 |
-
var header = types_modal.header;
|
55 |
-
|
56 |
-
if ( !header ) {
|
57 |
-
return;
|
58 |
-
}
|
59 |
-
|
60 |
-
var html = '<div class="types_block_page">';
|
61 |
-
html += '<div class="types_modal_box '+types_modal.class+'">';
|
62 |
-
html += '<div class="message"><span>'+types_modal.message+'</span></div>';
|
63 |
-
if ( 'endabled' == types_modal.state ) {
|
64 |
-
html += '<div class="header"><div>';
|
65 |
-
if ( types_modal.question ) {
|
66 |
-
html += '<span class="question">';
|
67 |
-
html += types_modal.question;
|
68 |
-
html += '</span>';
|
69 |
-
}
|
70 |
-
html += '<p>'+header+'</p></div></div>';
|
71 |
-
} else {
|
72 |
-
options.height = 106;
|
73 |
-
}
|
74 |
-
html += '</div>';
|
75 |
-
html += '</div>';
|
76 |
-
|
77 |
-
var pop_up = $(html);
|
78 |
-
|
79 |
-
$('.header', pop_up).css({
|
80 |
-
height: "259px",
|
81 |
-
textAlign: "center",
|
82 |
-
color: "#fff",
|
83 |
-
fontSize:"15px",
|
84 |
-
backgroundImage: 'url('+types_modal.image+'?v=2)',
|
85 |
-
backgroundRepeat: "no-repeat",
|
86 |
-
});
|
87 |
-
/**
|
88 |
-
* header div
|
89 |
-
*/
|
90 |
-
marginLeft = "290px";
|
91 |
-
width = "220px";
|
92 |
-
paddingTop = "50px";
|
93 |
-
height = "150px";
|
94 |
-
switch(types_modal.class) {
|
95 |
-
case 'cred':
|
96 |
-
paddingTop = "77px";
|
97 |
-
marginLeft = "260px";
|
98 |
-
width = "250px";
|
99 |
-
height = "100px";
|
100 |
-
break;
|
101 |
-
case 'access':
|
102 |
-
marginLeft = "270px";
|
103 |
-
width = "250px";
|
104 |
-
paddingTop = "25px";
|
105 |
-
height = "120px";
|
106 |
-
break;
|
107 |
-
}
|
108 |
-
$('.header div', pop_up).css({
|
109 |
-
float: "left",
|
110 |
-
height: height,
|
111 |
-
marginLeft: marginLeft,
|
112 |
-
paddingTop: paddingTop,
|
113 |
-
textAlign: "left",
|
114 |
-
width: width
|
115 |
-
|
116 |
-
});
|
117 |
-
/**
|
118 |
-
* header p
|
119 |
-
*/
|
120 |
-
$('.header p', pop_up).css({
|
121 |
-
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', 'Open Sans', sans-serif",
|
122 |
-
fontSize: "18px",
|
123 |
-
lineHeight: "1.2em",
|
124 |
-
margin: 0
|
125 |
-
});
|
126 |
-
$('.header .question', pop_up).css({
|
127 |
-
display: "block",
|
128 |
-
fontSize: "14px",
|
129 |
-
marginBottom: "5px"
|
130 |
-
});
|
131 |
-
return pop_up;
|
132 |
-
}
|
133 |
-
|
134 |
-
return this;
|
135 |
-
};
|
136 |
-
|
137 |
-
})(jQuery);
|
138 |
-
|
139 |
-
var WPCF_Script = WPCF_Script || {};
|
140 |
-
|
141 |
-
WPCF_Script.Modal_Script = function( $ ) {
|
142 |
-
|
143 |
-
var self = this;
|
144 |
-
|
145 |
-
self.add_styles = function( pop_up ) {
|
146 |
-
$('.types_modal_box', pop_up).css({
|
147 |
-
background: "#fff none no-repeat 0 0",
|
148 |
-
border: "1px solid #888",
|
149 |
-
boxShadow: "7px 7px 20px 0px rgba(50, 50, 50, 0.75)",
|
150 |
-
});
|
151 |
-
|
152 |
-
$('.types_modal_box .message', pop_up).css({
|
153 |
-
color: "#f05a28",
|
154 |
-
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', 'Open Sans', sans-serif",
|
155 |
-
fontSize: "25px",
|
156 |
-
padding: "0 10px",
|
157 |
-
textAlign: "center"
|
158 |
-
});
|
159 |
-
$('.types_modal_box .message span', pop_up).css({
|
160 |
-
background: "transparent url("+types_modal.spinner+") no-repeat 0 50%",
|
161 |
-
paddingLeft: "30px",
|
162 |
-
lineHeight: "105px"
|
163 |
-
});
|
164 |
-
}
|
165 |
-
|
166 |
-
self.add_block_page = function() {
|
167 |
-
var block_page = $('<div class="types_block_page"></div>');
|
168 |
-
$(block_page).appendTo('body');
|
169 |
-
}
|
170 |
-
|
171 |
-
self.add_popup_box = function() {
|
172 |
-
var marginLeft, height, paddingTop, width;
|
173 |
-
var header = types_modal.header;
|
174 |
-
|
175 |
-
if ( !header ) {
|
176 |
-
return;
|
177 |
-
}
|
178 |
-
|
179 |
-
var html = '<div class="types_block_page">';
|
180 |
-
html += '<div class="types_modal_box '+types_modal.class+'">';
|
181 |
-
html += '<div class="message"><span>'+types_modal.message+'</span></div>';
|
182 |
-
if ( 'endabled' == types_modal.state ) {
|
183 |
-
html += '<div class="header"><div>';
|
184 |
-
if ( types_modal.question ) {
|
185 |
-
html += '<span class="question">';
|
186 |
-
html += types_modal.question;
|
187 |
-
html += '</span>';
|
188 |
-
}
|
189 |
-
html += '<p>'+header+'</p></div></div>';
|
190 |
-
}
|
191 |
-
html += '</div>';
|
192 |
-
html += '</div>';
|
193 |
-
|
194 |
-
var pop_up = $(html);
|
195 |
-
|
196 |
-
$('.header', pop_up).css({
|
197 |
-
height: "259px",
|
198 |
-
textAlign: "center",
|
199 |
-
color: "#fff",
|
200 |
-
fontSize:"15px",
|
201 |
-
backgroundImage: 'url('+types_modal.image+'?v=2)',
|
202 |
-
backgroundRepeat: "no-repeat",
|
203 |
-
});
|
204 |
-
/**
|
205 |
-
* header div
|
206 |
-
*/
|
207 |
-
marginLeft = "290px";
|
208 |
-
width = "220px";
|
209 |
-
paddingTop = "50px";
|
210 |
-
height = "150px";
|
211 |
-
switch(types_modal.class) {
|
212 |
-
case 'cred':
|
213 |
-
paddingTop = "77px";
|
214 |
-
marginLeft = "260px";
|
215 |
-
width = "250px";
|
216 |
-
height = "100px";
|
217 |
-
break;
|
218 |
-
case 'access':
|
219 |
-
marginLeft = "270px";
|
220 |
-
width = "250px";
|
221 |
-
paddingTop = "25px";
|
222 |
-
height = "120px";
|
223 |
-
break;
|
224 |
-
}
|
225 |
-
$('.header div', pop_up).css({
|
226 |
-
float: "left",
|
227 |
-
height: height,
|
228 |
-
marginLeft: marginLeft,
|
229 |
-
paddingTop: paddingTop,
|
230 |
-
textAlign: "left",
|
231 |
-
width: width
|
232 |
-
|
233 |
-
});
|
234 |
-
/**
|
235 |
-
* header p
|
236 |
-
*/
|
237 |
-
$('.header p', pop_up).css({
|
238 |
-
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', 'Open Sans', sans-serif",
|
239 |
-
fontSize: "18px",
|
240 |
-
lineHeight: "1.2em",
|
241 |
-
margin: 0
|
242 |
-
});
|
243 |
-
$('.header .question', pop_up).css({
|
244 |
-
display: "block",
|
245 |
-
fontSize: "14px",
|
246 |
-
marginBottom: "5px"
|
247 |
-
});
|
248 |
-
return pop_up;
|
249 |
-
}
|
250 |
-
|
251 |
-
self.init = function() {
|
252 |
-
|
253 |
-
};
|
254 |
-
|
255 |
-
$( document ).on( 'js-wpcf-event-types-show-modal', function( event ) {
|
256 |
-
/*
|
257 |
-
if ( $(this).hasClass('js-types-do-not-show-modal')) {
|
258 |
-
return;
|
259 |
-
}
|
260 |
-
*/
|
261 |
-
self.add_block_page();
|
262 |
-
var pop_up = self.add_popup_box();
|
263 |
-
|
264 |
-
if( pop_up ) {
|
265 |
-
self.add_styles( pop_up );
|
266 |
-
$.colorbox( {
|
267 |
-
html: pop_up.html(),
|
268 |
-
fixed: true,
|
269 |
-
closeButton: false
|
270 |
-
} );
|
271 |
-
}
|
272 |
-
});
|
273 |
-
|
274 |
-
self.init();
|
275 |
-
|
276 |
-
};
|
277 |
-
|
278 |
-
jQuery( document ).ready( function( $ ) {
|
279 |
-
WPCF_Script.wpcf_modal_script = new WPCF_Script.Modal_Script( $ );
|
280 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/toolset/types/includes/classes/class.types.admin.edit.fields.php
CHANGED
@@ -158,7 +158,7 @@ abstract class Types_Admin_Edit_Fields extends Types_Admin_Page
|
|
158 |
$title = !empty( $form_data['name'] ) ? $form_data['name'] : __( 'Untitled', 'wpcf' );
|
159 |
$title = sprintf(
|
160 |
'<span class="wpcf-legend-update">%s</span> <span class="description">(%s)</span> <span class="wpcf_required_data">%s</span>',
|
161 |
-
$title,
|
162 |
$field_data['title'],
|
163 |
$required
|
164 |
);
|
158 |
$title = !empty( $form_data['name'] ) ? $form_data['name'] : __( 'Untitled', 'wpcf' );
|
159 |
$title = sprintf(
|
160 |
'<span class="wpcf-legend-update">%s</span> <span class="description">(%s)</span> <span class="wpcf_required_data">%s</span>',
|
161 |
+
stripslashes( $title ),
|
162 |
$field_data['title'],
|
163 |
$required
|
164 |
);
|
vendor/toolset/types/includes/classes/class.wpcf.marketing.messages.php
CHANGED
@@ -209,9 +209,6 @@ class WPCF_Types_Marketing_Messages extends WPCF_Types_Marketing
|
|
209 |
$data[$key] = apply_filters('wpcf_marketing_message', $value, $data, $key );
|
210 |
$data['state'] = $this->state;
|
211 |
}
|
212 |
-
wp_register_script( 'types-modal', WPCF_EMBEDDED_RES_RELPATH.'/js/modal.js', array('toolset-colorbox'), WPCF_VERSION, true);
|
213 |
-
wp_localize_script( 'types-modal', 'types_modal', $data);
|
214 |
-
wp_enqueue_script('types-modal');
|
215 |
}
|
216 |
|
217 |
public function update_message($message = false)
|
209 |
$data[$key] = apply_filters('wpcf_marketing_message', $value, $data, $key );
|
210 |
$data['state'] = $this->state;
|
211 |
}
|
|
|
|
|
|
|
212 |
}
|
213 |
|
214 |
public function update_message($message = false)
|
vendor/toolset/types/includes/conditional-display.php
CHANGED
@@ -236,7 +236,7 @@ function wpcf_cd_admin_form_filter( $form, $data, $group = false )
|
|
236 |
'#type' => 'button',
|
237 |
'#before' => sprintf(
|
238 |
'<span class="js-wpcf-condition-preview">%s</span><span class="js-wpcf-condition-data"></span>',
|
239 |
-
$current
|
240 |
),
|
241 |
'#value' => empty( $current ) ? __( 'Set condition(s)', 'wpcf' ) : __( 'Edit condition(s)', 'wpcf' ),
|
242 |
'#attributes' => array(
|
@@ -666,7 +666,7 @@ function wpcf_conditional_get_curent($data)
|
|
666 |
|
667 |
$current .= sprintf(
|
668 |
'<li><span>%s %s %s</span></li>',
|
669 |
-
esc_html($all_types_fields[$condition['field']]['name']),
|
670 |
esc_html($operation),
|
671 |
esc_html($value)
|
672 |
);
|
236 |
'#type' => 'button',
|
237 |
'#before' => sprintf(
|
238 |
'<span class="js-wpcf-condition-preview">%s</span><span class="js-wpcf-condition-data"></span>',
|
239 |
+
stripslashes( $current )
|
240 |
),
|
241 |
'#value' => empty( $current ) ? __( 'Set condition(s)', 'wpcf' ) : __( 'Edit condition(s)', 'wpcf' ),
|
242 |
'#attributes' => array(
|
666 |
|
667 |
$current .= sprintf(
|
668 |
'<li><span>%s %s %s</span></li>',
|
669 |
+
esc_html(stripslashes($all_types_fields[$condition['field']]['name'])),
|
670 |
esc_html($operation),
|
671 |
esc_html($value)
|
672 |
);
|
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
|
@@ -29,7 +29,7 @@ if ( ! function_exists( 'add_action' ) ) {
|
|
29 |
|
30 |
// version
|
31 |
if ( ! defined( 'TYPES_VERSION' ) ) {
|
32 |
-
define( 'TYPES_VERSION', '2.2.
|
33 |
}
|
34 |
|
35 |
// backward compatibility
|
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.21
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
Types is free software: you can redistribute it and/or modify
|
29 |
|
30 |
// version
|
31 |
if ( ! defined( 'TYPES_VERSION' ) ) {
|
32 |
+
define( 'TYPES_VERSION', '2.2.21' );
|
33 |
}
|
34 |
|
35 |
// backward compatibility
|