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

Version Description

  • Fixed an issue that field title was not available on filter "wpt_field_options"
  • Fixed an issue with the background when resizing transparent indexed colored PNGs
  • Fixed an issue with special character entities import
Download this release

Release Info

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

Code changes from version 2.2.19 to 2.2.20

Files changed (112) hide show
  1. readme.txt +6 -1
  2. vendor/autoload.php +1 -1
  3. vendor/composer/autoload_classmap.php +51 -14
  4. vendor/composer/autoload_real.php +7 -7
  5. vendor/composer/autoload_static.php +56 -19
  6. vendor/composer/installed.json +5 -4
  7. vendor/toolset/toolset-common/autoload_classmap.php +18 -10
  8. vendor/toolset/toolset-common/bootstrap.php +15 -20
  9. vendor/toolset/toolset-common/changelog.md +12 -0
  10. vendor/toolset/toolset-common/inc/autoloaded/element/domain.php +19 -0
  11. vendor/toolset/toolset-common/inc/autoloaded/{element.php → element/element.php} +0 -0
  12. vendor/toolset/toolset-common/inc/autoloaded/{element_factory.php → element/element_factory.php} +0 -0
  13. vendor/toolset/toolset-common/inc/autoloaded/{i_element.php → element/i_element.php} +8 -2
  14. vendor/toolset/toolset-common/inc/autoloaded/{i_post.php → element/i_post.php} +0 -0
  15. vendor/toolset/toolset-common/inc/autoloaded/{post.php → element/post.php} +6 -9
  16. vendor/toolset/toolset-common/inc/autoloaded/{post_translation_set.php → element/post_translation_set.php} +10 -9
  17. vendor/toolset/toolset-common/inc/autoloaded/field/group.php +12 -0
  18. vendor/toolset/toolset-common/inc/autoloaded/field/group/post.php +1 -0
  19. vendor/toolset/toolset-common/inc/autoloaded/field/group/post_factory.php +4 -2
  20. vendor/toolset/toolset-common/inc/autoloaded/field/utils.php +7 -0
  21. vendor/toolset/toolset-common/inc/autoloaded/i_query.php +16 -0
  22. vendor/toolset/toolset-common/inc/autoloaded/post_type/query.php +5 -0
  23. vendor/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/id.php +0 -2
  24. vendor/toolset/toolset-common/inc/autoloaded/upgrade/command/m2m_v1_database_structure_upgrade.php +284 -0
  25. vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_definition.php +80 -0
  26. vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_definition_repository.php +24 -0
  27. vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_factory.php +31 -0
  28. vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_interface.php +22 -0
  29. vendor/toolset/toolset-common/inc/autoloaded/upgrade/controller.php +186 -0
  30. vendor/toolset/toolset-common/inc/controller/constants.php +3 -1
  31. vendor/toolset/toolset-common/inc/m2m/association.php +1 -1
  32. vendor/toolset/toolset-common/inc/m2m/association_base.php +1 -1
  33. vendor/toolset/toolset-common/inc/m2m/association_query.php +24 -13
  34. vendor/toolset/toolset-common/inc/m2m/association_repository.php +1 -1
  35. vendor/toolset/toolset-common/inc/m2m/association_translation_set.php +1 -1
  36. vendor/toolset/toolset-common/inc/m2m/autoload_classmap.php +39 -10
  37. vendor/toolset/toolset-common/inc/m2m/controller.php +0 -2
  38. vendor/toolset/toolset-common/inc/m2m/{database_operations.php → database/operations.php} +197 -46
  39. vendor/toolset/toolset-common/inc/m2m/database/table_name.php +93 -0
  40. vendor/toolset/toolset-common/inc/m2m/database/unique_table_alias.php +42 -0
  41. vendor/toolset/toolset-common/inc/m2m/{definition.php → definition/definition.php} +81 -17
  42. vendor/toolset/toolset-common/inc/m2m/{definition_factory.php → definition/factory.php} +0 -0
  43. vendor/toolset/toolset-common/inc/m2m/definition/persistence.php +209 -0
  44. vendor/toolset/toolset-common/inc/m2m/{definition_repository.php → definition/repository.php} +72 -141
  45. vendor/toolset/toolset-common/inc/m2m/definition/translator.php +177 -0
  46. vendor/toolset/toolset-common/inc/m2m/driver.php +2 -2
  47. vendor/toolset/toolset-common/inc/m2m/element_type.php +5 -0
  48. vendor/toolset/toolset-common/inc/m2m/i_definition.php +6 -6
  49. vendor/toolset/toolset-common/inc/m2m/potential_association/distinct_post_query.php +159 -0
  50. vendor/toolset/toolset-common/inc/m2m/potential_association/query_factory.php +38 -0
  51. vendor/toolset/toolset-common/inc/m2m/potential_association/query_interface.php +42 -0
  52. vendor/toolset/toolset-common/inc/m2m/potential_association/query_posts.php +207 -0
  53. vendor/toolset/toolset-common/inc/m2m/query_factory.php +61 -0
  54. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/abstract.php +44 -0
  55. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/and.php +43 -0
  56. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/has_active_types.php +110 -0
  57. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/has_domain.php +65 -0
  58. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/i_condition.php +28 -0
  59. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/is_active.php +15 -0
  60. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/is_boolean_flag.php +55 -0
  61. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/is_legacy.php +15 -0
  62. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/operator.php +74 -0
  63. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/or.php +42 -0
  64. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/origin.php +41 -0
  65. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/type.php +50 -0
  66. vendor/toolset/toolset-common/inc/m2m/relationship_query/condition_factory.php +111 -0
  67. vendor/toolset/toolset-common/inc/m2m/{relationship_query.php → relationship_query/relationship_query.php} +13 -3
  68. vendor/toolset/toolset-common/inc/m2m/relationship_query/relationship_query_v2.php +342 -0
  69. vendor/toolset/toolset-common/inc/m2m/relationship_query/sql_expression_builder.php +68 -0
  70. vendor/toolset/toolset-common/inc/m2m/relationship_role/abstract.php +9 -0
  71. vendor/toolset/toolset-common/inc/m2m/relationship_role/child.php +39 -0
  72. vendor/toolset/toolset-common/inc/m2m/relationship_role/interface.php +32 -0
  73. vendor/toolset/toolset-common/inc/m2m/relationship_role/intermediary.php +28 -0
  74. vendor/toolset/toolset-common/inc/m2m/relationship_role/parent.php +40 -0
  75. vendor/toolset/toolset-common/inc/m2m/relationship_role/parent_child_interface.php +15 -0
  76. vendor/toolset/toolset-common/inc/m2m/{role.php → relationship_role/role.php} +55 -8
  77. vendor/toolset/toolset-common/inc/m2m/table_name.php +0 -41
  78. vendor/toolset/toolset-common/inc/m2m/utils.php +10 -7
  79. vendor/toolset/toolset-common/inc/m2m/wpml_interoperability.php +1 -1
  80. vendor/toolset/toolset-common/inc/toolset.assets.manager.class.php +43 -0
  81. vendor/toolset/toolset-common/inc/toolset.shortcode.generator.class.php +297 -10
  82. vendor/toolset/toolset-common/inc/toolset.upgrade.class.php +0 -137
  83. vendor/toolset/toolset-common/loader.php +1 -1
  84. vendor/toolset/toolset-common/res/css/toolset-dialogs.css +147 -3
  85. vendor/toolset/toolset-common/res/js/toolset-shortcode.js +950 -0
  86. vendor/toolset/toolset-common/toolset-common-loader.php +6 -4
  87. vendor/toolset/toolset-common/toolset-forms/classes/class.field_factory.php +28 -3
  88. vendor/toolset/toolset-common/toolset-forms/classes/class.post.php +12 -0
  89. vendor/toolset/toolset-common/user-editors/editor/avada.php +8 -0
  90. vendor/toolset/toolset-common/user-editors/editor/basic.php +45 -0
  91. vendor/toolset/toolset-common/user-editors/editor/divi.php +4 -1
  92. vendor/toolset/toolset-common/user-editors/editor/screen/avada/backend_editor.css +12 -0
  93. vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/backend.php +109 -51
  94. vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/backend.phtml +16 -0
  95. vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/backend_editor.css +3 -0
  96. vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/backend_editor.js +37 -0
  97. vendor/toolset/toolset-common/utility/condition/plugin/types/ready_for_m2m.php +1 -1
  98. vendor/toolset/toolset-common/utility/help-videos/res/css/toolset-help-videos-retro.css +138 -0
  99. vendor/toolset/toolset-common/utility/help-videos/res/css/toolset-help-videos.css +1 -0
  100. vendor/toolset/toolset-common/utility/help-videos/res/js/toolset-help-videos-retro.js +374 -0
  101. vendor/toolset/toolset-common/utility/help-videos/res/js/toolset-help-videos.js +8 -8
  102. vendor/toolset/toolset-common/utility/help-videos/toolset-help-videos.php +21 -6
  103. vendor/toolset/types/admin.php +0 -3
  104. vendor/toolset/types/embedded/classes/editor.php +2 -0
  105. vendor/toolset/types/embedded/classes/loader.php +0 -8
  106. vendor/toolset/types/embedded/includes/import-export.php +11 -4
  107. vendor/toolset/types/embedded/resources/css/basic.css +9 -0
  108. vendor/toolset/types/embedded/resources/css/dashicons.css +0 -829
  109. vendor/toolset/types/embedded/resources/js/editor.js +10 -0
  110. vendor/toolset/types/embedded/views/image.php +5 -0
  111. vendor/toolset/types/includes/import-export.php +4 -1
  112. wpcf.php +2 -2
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.19
11
 
12
  The complete and reliable plugin for managing custom post types, custom taxonomies and custom fields.
13
 
@@ -158,6 +158,11 @@ Additionally, Types is the only plugin that lets you define parent/child relatio
158
 
159
  == Changelog ==
160
 
 
 
 
 
 
161
  = 2.2.19 =
162
  * Fixed an issue when using 3rd party shortcodes on the WYSIWYG field
163
 
7
  License: GPLv2
8
  Requires at least: 3.7
9
  Tested up to: 4.9
10
+ Stable tag: 2.2.20
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.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
164
+ * Fixed an issue with special character entities import
165
+
166
  = 2.2.19 =
167
  * Fixed an issue when using 3rd party shortcodes on the WYSIWYG field
168
 
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit9dc3a75d9bf0dcdec570d52c4943bef9::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit98453dc040b2a0c9d9e4e0ebe2a806a4::getLoader();
vendor/composer/autoload_classmap.php CHANGED
@@ -97,13 +97,19 @@ return array(
97
  'FormAbstract' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/abstract.form.php',
98
  'FormFactory' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.form_factory.php',
99
  'IToolset_Association' => $vendorDir . '/toolset/toolset-common/inc/m2m/i_association.php',
100
- 'IToolset_Element' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/i_element.php',
101
- 'IToolset_Post' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/i_post.php',
102
  'IToolset_Post_Type' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type.php',
103
  'IToolset_Post_Type_From_Types' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type_from_types.php',
104
  'IToolset_Post_Type_Registered' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type_registered.php',
 
 
105
  'IToolset_Relationship_Definition' => $vendorDir . '/toolset/toolset-common/inc/m2m/i_definition.php',
106
  'IToolset_Relationship_Origin' => $vendorDir . '/toolset/toolset-common/inc/m2m/origin/interface.php',
 
 
 
 
107
  'ReCaptchaResponse' => $vendorDir . '/toolset/toolset-common/toolset-forms/js/recaptcha-php-1.11/recaptchalib.php',
108
  'Toolset_Admin_Bar_Menu' => $vendorDir . '/toolset/toolset-common/inc/toolset.admin.bar.menu.class.php',
109
  'Toolset_Admin_Notice_Abstract' => $vendorDir . '/toolset/toolset-common/utility/admin/notice/abstract.php',
@@ -168,8 +174,9 @@ return array(
168
  'Toolset_DateParser' => $vendorDir . '/toolset/toolset-common/expression-parser/parser.php',
169
  'Toolset_Date_Utils' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/date_utils.php',
170
  'Toolset_DialogBoxes' => $vendorDir . '/toolset/toolset-common/utility/dialogs/toolset.dialog-boxes.class.php',
171
- 'Toolset_Element' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element.php',
172
- 'Toolset_Element_Factory' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element_factory.php',
 
173
  'Toolset_ErrorHandler' => $vendorDir . '/toolset/toolset-common/utility/utils.php',
174
  'Toolset_Export_Import_Screen' => $vendorDir . '/toolset/toolset-common/inc/toolset.export.import.screen.class.php',
175
  'Toolset_Field_Accessor_Abstract' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/field/accessor/abstract.php',
@@ -245,8 +252,8 @@ return array(
245
  'Toolset_Naming_Helper' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/naming_helper.php',
246
  'Toolset_Object_Relationship' => $vendorDir . '/toolset/toolset-common/inc/toolset.object.relationship.class.php',
247
  'Toolset_Parser' => $vendorDir . '/toolset/toolset-common/expression-parser/parser.php',
248
- 'Toolset_Post' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post.php',
249
- 'Toolset_Post_Translation_Set' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_translation_set.php',
250
  'Toolset_Post_Type_Exclude_List' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/excluded_list.php',
251
  'Toolset_Post_Type_Factory' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/factory.php',
252
  'Toolset_Post_Type_From_Types' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/from_types.php',
@@ -255,14 +262,20 @@ return array(
255
  'Toolset_Post_Type_Query_Factory' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/query_factory.php',
256
  'Toolset_Post_Type_Registered' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/registered.php',
257
  'Toolset_Post_Type_Repository' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/repository.php',
 
 
258
  'Toolset_Promotion' => $vendorDir . '/toolset/toolset-common/inc/toolset.promotion.class.php',
259
  'Toolset_Regex' => $vendorDir . '/toolset/toolset-common/expression-parser/parser.php',
260
  'Toolset_Relationship_Cardinality' => $vendorDir . '/toolset/toolset-common/inc/m2m/cardinality.php',
261
  'Toolset_Relationship_Controller' => $vendorDir . '/toolset/toolset-common/inc/m2m/controller.php',
262
- 'Toolset_Relationship_Database_Operations' => $vendorDir . '/toolset/toolset-common/inc/m2m/database_operations.php',
263
- 'Toolset_Relationship_Definition' => $vendorDir . '/toolset/toolset-common/inc/m2m/definition.php',
264
- 'Toolset_Relationship_Definition_Factory' => $vendorDir . '/toolset/toolset-common/inc/m2m/definition_factory.php',
265
- 'Toolset_Relationship_Definition_Repository' => $vendorDir . '/toolset/toolset-common/inc/m2m/definition_repository.php',
 
 
 
 
266
  'Toolset_Relationship_Driver' => $vendorDir . '/toolset/toolset-common/inc/m2m/driver.php',
267
  'Toolset_Relationship_Driver_Base' => $vendorDir . '/toolset/toolset-common/inc/m2m/driver_base.php',
268
  'Toolset_Relationship_Element_Type' => $vendorDir . '/toolset/toolset-common/inc/m2m/element_type.php',
@@ -272,14 +285,33 @@ return array(
272
  'Toolset_Relationship_Origin_Post_Reference_Field' => $vendorDir . '/toolset/toolset-common/inc/m2m/origin/post_reference_field.php',
273
  'Toolset_Relationship_Origin_Repeatable_Group' => $vendorDir . '/toolset/toolset-common/inc/m2m/origin/repeatable_group.php',
274
  'Toolset_Relationship_Origin_Wizard' => $vendorDir . '/toolset/toolset-common/inc/m2m/origin/wizard.php',
275
- 'Toolset_Relationship_Query' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query.php',
276
  'Toolset_Relationship_Query_Base' => $vendorDir . '/toolset/toolset-common/inc/m2m/query_base.php',
277
  'Toolset_Relationship_Query_Cache' => $vendorDir . '/toolset/toolset-common/inc/m2m/query_cache.php',
278
- 'Toolset_Relationship_Role' => $vendorDir . '/toolset/toolset-common/inc/m2m/role.php',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  'Toolset_Relationship_Scope' => $vendorDir . '/toolset/toolset-common/inc/m2m/scope.php',
280
  'Toolset_Relationship_Service' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/relationship_service.php',
281
  'Toolset_Relationship_Slug_Validator' => $vendorDir . '/toolset/toolset-common/inc/m2m/slug_validator.php',
282
- 'Toolset_Relationship_Table_Name' => $vendorDir . '/toolset/toolset-common/inc/m2m/table_name.php',
283
  'Toolset_Relationship_Utils' => $vendorDir . '/toolset/toolset-common/inc/m2m/utils.php',
284
  'Toolset_Relationship_WPML_Interoperability' => $vendorDir . '/toolset/toolset-common/inc/m2m/wpml_interoperability.php',
285
  'Toolset_Relevanssi_Compatibility' => $vendorDir . '/toolset/toolset-common/inc/toolset.relevanssi.compatibility.class.php',
@@ -302,7 +334,11 @@ return array(
302
  'Toolset_Twig_Dialog_Box' => $vendorDir . '/toolset/toolset-common/utility/gui-base/twig_dialog_box.php',
303
  'Toolset_Twig_Dialog_Box_Factory' => $vendorDir . '/toolset/toolset-common/utility/gui-base/twig_dialog_box_factory.php',
304
  'Toolset_Twig_Extensions' => $vendorDir . '/toolset/toolset-common/utility/gui-base/twig_extensions.php',
305
- 'Toolset_Upgrade' => $vendorDir . '/toolset/toolset-common/inc/toolset.upgrade.class.php',
 
 
 
 
306
  'Toolset_User_Editors_Editor_Abstract' => $vendorDir . '/toolset/toolset-common/user-editors/editor/abstract.php',
307
  'Toolset_User_Editors_Editor_Avada' => $vendorDir . '/toolset/toolset-common/user-editors/editor/avada.php',
308
  'Toolset_User_Editors_Editor_Basic' => $vendorDir . '/toolset/toolset-common/user-editors/editor/basic.php',
@@ -673,6 +709,7 @@ return array(
673
  'WPToolset_Field_Numeric' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.numeric.php',
674
  'WPToolset_Field_Password' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.password.php',
675
  'WPToolset_Field_Phone' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.phone.php',
 
676
  'WPToolset_Field_Radios' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.radios.php',
677
  'WPToolset_Field_Recaptcha' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.recaptcha.php',
678
  'WPToolset_Field_Recaptcha_v1' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.recaptcha-v1.php',
97
  'FormAbstract' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/abstract.form.php',
98
  'FormFactory' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.form_factory.php',
99
  'IToolset_Association' => $vendorDir . '/toolset/toolset-common/inc/m2m/i_association.php',
100
+ 'IToolset_Element' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element/i_element.php',
101
+ 'IToolset_Post' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element/i_post.php',
102
  'IToolset_Post_Type' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type.php',
103
  'IToolset_Post_Type_From_Types' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type_from_types.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_Definition' => $vendorDir . '/toolset/toolset-common/inc/m2m/i_definition.php',
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',
112
+ 'IToolset_Upgrade_Command' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/upgrade/command_interface.php',
113
  'ReCaptchaResponse' => $vendorDir . '/toolset/toolset-common/toolset-forms/js/recaptcha-php-1.11/recaptchalib.php',
114
  'Toolset_Admin_Bar_Menu' => $vendorDir . '/toolset/toolset-common/inc/toolset.admin.bar.menu.class.php',
115
  'Toolset_Admin_Notice_Abstract' => $vendorDir . '/toolset/toolset-common/utility/admin/notice/abstract.php',
174
  'Toolset_DateParser' => $vendorDir . '/toolset/toolset-common/expression-parser/parser.php',
175
  'Toolset_Date_Utils' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/date_utils.php',
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',
182
  'Toolset_Field_Accessor_Abstract' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/field/accessor/abstract.php',
252
  'Toolset_Naming_Helper' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/naming_helper.php',
253
  'Toolset_Object_Relationship' => $vendorDir . '/toolset/toolset-common/inc/toolset.object.relationship.class.php',
254
  'Toolset_Parser' => $vendorDir . '/toolset/toolset-common/expression-parser/parser.php',
255
+ 'Toolset_Post' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element/post.php',
256
+ 'Toolset_Post_Translation_Set' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/element/post_translation_set.php',
257
  'Toolset_Post_Type_Exclude_List' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/excluded_list.php',
258
  'Toolset_Post_Type_Factory' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/factory.php',
259
  'Toolset_Post_Type_From_Types' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/from_types.php',
262
  'Toolset_Post_Type_Query_Factory' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/query_factory.php',
263
  'Toolset_Post_Type_Registered' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/registered.php',
264
  'Toolset_Post_Type_Repository' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/post_type/repository.php',
265
+ 'Toolset_Potential_Association_Query_Factory' => $vendorDir . '/toolset/toolset-common/inc/m2m/potential_association/query_factory.php',
266
+ 'Toolset_Potential_Association_Query_Posts' => $vendorDir . '/toolset/toolset-common/inc/m2m/potential_association/query_posts.php',
267
  'Toolset_Promotion' => $vendorDir . '/toolset/toolset-common/inc/toolset.promotion.class.php',
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',
274
+ 'Toolset_Relationship_Definition_Factory' => $vendorDir . '/toolset/toolset-common/inc/m2m/definition/factory.php',
275
+ 'Toolset_Relationship_Definition_Persistence' => $vendorDir . '/toolset/toolset-common/inc/m2m/definition/persistence.php',
276
+ 'Toolset_Relationship_Definition_Repository' => $vendorDir . '/toolset/toolset-common/inc/m2m/definition/repository.php',
277
+ 'Toolset_Relationship_Definition_Translator' => $vendorDir . '/toolset/toolset-common/inc/m2m/definition/translator.php',
278
+ 'Toolset_Relationship_Distinct_Post_Query' => $vendorDir . '/toolset/toolset-common/inc/m2m/potential_association/distinct_post_query.php',
279
  'Toolset_Relationship_Driver' => $vendorDir . '/toolset/toolset-common/inc/m2m/driver.php',
280
  'Toolset_Relationship_Driver_Base' => $vendorDir . '/toolset/toolset-common/inc/m2m/driver_base.php',
281
  'Toolset_Relationship_Element_Type' => $vendorDir . '/toolset/toolset-common/inc/m2m/element_type.php',
285
  'Toolset_Relationship_Origin_Post_Reference_Field' => $vendorDir . '/toolset/toolset-common/inc/m2m/origin/post_reference_field.php',
286
  'Toolset_Relationship_Origin_Repeatable_Group' => $vendorDir . '/toolset/toolset-common/inc/m2m/origin/repeatable_group.php',
287
  'Toolset_Relationship_Origin_Wizard' => $vendorDir . '/toolset/toolset-common/inc/m2m/origin/wizard.php',
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',
298
+ 'Toolset_Relationship_Query_Condition_Is_Legacy' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/condition/is_legacy.php',
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',
305
+ 'Toolset_Relationship_Query_V2' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_query/relationship_query_v2.php',
306
+ 'Toolset_Relationship_Role' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_role/role.php',
307
+ 'Toolset_Relationship_Role_Abstract' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_role/abstract.php',
308
+ 'Toolset_Relationship_Role_Child' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_role/child.php',
309
+ 'Toolset_Relationship_Role_Intermediary' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_role/intermediary.php',
310
+ 'Toolset_Relationship_Role_Parent' => $vendorDir . '/toolset/toolset-common/inc/m2m/relationship_role/parent.php',
311
  'Toolset_Relationship_Scope' => $vendorDir . '/toolset/toolset-common/inc/m2m/scope.php',
312
  'Toolset_Relationship_Service' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/relationship_service.php',
313
  'Toolset_Relationship_Slug_Validator' => $vendorDir . '/toolset/toolset-common/inc/m2m/slug_validator.php',
314
+ 'Toolset_Relationship_Table_Name' => $vendorDir . '/toolset/toolset-common/inc/m2m/database/table_name.php',
315
  'Toolset_Relationship_Utils' => $vendorDir . '/toolset/toolset-common/inc/m2m/utils.php',
316
  'Toolset_Relationship_WPML_Interoperability' => $vendorDir . '/toolset/toolset-common/inc/m2m/wpml_interoperability.php',
317
  'Toolset_Relevanssi_Compatibility' => $vendorDir . '/toolset/toolset-common/inc/toolset.relevanssi.compatibility.class.php',
334
  'Toolset_Twig_Dialog_Box' => $vendorDir . '/toolset/toolset-common/utility/gui-base/twig_dialog_box.php',
335
  'Toolset_Twig_Dialog_Box_Factory' => $vendorDir . '/toolset/toolset-common/utility/gui-base/twig_dialog_box_factory.php',
336
  'Toolset_Twig_Extensions' => $vendorDir . '/toolset/toolset-common/utility/gui-base/twig_extensions.php',
337
+ 'Toolset_Upgrade_Command_Definition' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/upgrade/command_definition.php',
338
+ 'Toolset_Upgrade_Command_Definition_Repository' => $vendorDir . '/toolset/toolset-common/inc/autoloaded/upgrade/command_definition_repository.php',
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',
709
  'WPToolset_Field_Numeric' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.numeric.php',
710
  'WPToolset_Field_Password' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.password.php',
711
  'WPToolset_Field_Phone' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.phone.php',
712
+ 'WPToolset_Field_Post' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.post.php',
713
  'WPToolset_Field_Radios' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.radios.php',
714
  'WPToolset_Field_Recaptcha' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.recaptcha.php',
715
  'WPToolset_Field_Recaptcha_v1' => $vendorDir . '/toolset/toolset-common/toolset-forms/classes/class.recaptcha-v1.php',
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit9dc3a75d9bf0dcdec570d52c4943bef9
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit9dc3a75d9bf0dcdec570d52c4943bef9
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit9dc3a75d9bf0dcdec570d52c4943bef9', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit9dc3a75d9bf0dcdec570d52c4943bef9', '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\ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit9dc3a75d9bf0dcdec570d52c4943bef9
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequire9dc3a75d9bf0dcdec570d52c4943bef9($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequire9dc3a75d9bf0dcdec570d52c4943bef9($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit98453dc040b2a0c9d9e4e0ebe2a806a4
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit98453dc040b2a0c9d9e4e0ebe2a806a4', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit98453dc040b2a0c9d9e4e0ebe2a806a4', '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\ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4::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\ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire98453dc040b2a0c9d9e4e0ebe2a806a4($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequire98453dc040b2a0c9d9e4e0ebe2a806a4($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 ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9
8
  {
9
  public static $files = array (
10
  'a52c1eba913b4ecdd3571194b37baea9' => __DIR__ . '/../..' . '/application/functions.php',
@@ -126,13 +126,19 @@ class ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9
126
  'FormAbstract' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/abstract.form.php',
127
  'FormFactory' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.form_factory.php',
128
  'IToolset_Association' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/i_association.php',
129
- 'IToolset_Element' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/i_element.php',
130
- 'IToolset_Post' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/i_post.php',
131
  'IToolset_Post_Type' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type.php',
132
  'IToolset_Post_Type_From_Types' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type_from_types.php',
133
  'IToolset_Post_Type_Registered' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type_registered.php',
 
 
134
  'IToolset_Relationship_Definition' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/i_definition.php',
135
  'IToolset_Relationship_Origin' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/origin/interface.php',
 
 
 
 
136
  'ReCaptchaResponse' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/js/recaptcha-php-1.11/recaptchalib.php',
137
  'Toolset_Admin_Bar_Menu' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.admin.bar.menu.class.php',
138
  'Toolset_Admin_Notice_Abstract' => __DIR__ . '/..' . '/toolset/toolset-common/utility/admin/notice/abstract.php',
@@ -197,8 +203,9 @@ class ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9
197
  'Toolset_DateParser' => __DIR__ . '/..' . '/toolset/toolset-common/expression-parser/parser.php',
198
  'Toolset_Date_Utils' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/date_utils.php',
199
  'Toolset_DialogBoxes' => __DIR__ . '/..' . '/toolset/toolset-common/utility/dialogs/toolset.dialog-boxes.class.php',
200
- 'Toolset_Element' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element.php',
201
- 'Toolset_Element_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element_factory.php',
 
202
  'Toolset_ErrorHandler' => __DIR__ . '/..' . '/toolset/toolset-common/utility/utils.php',
203
  'Toolset_Export_Import_Screen' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.export.import.screen.class.php',
204
  'Toolset_Field_Accessor_Abstract' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/field/accessor/abstract.php',
@@ -274,8 +281,8 @@ class ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9
274
  'Toolset_Naming_Helper' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/naming_helper.php',
275
  'Toolset_Object_Relationship' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.object.relationship.class.php',
276
  'Toolset_Parser' => __DIR__ . '/..' . '/toolset/toolset-common/expression-parser/parser.php',
277
- 'Toolset_Post' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post.php',
278
- 'Toolset_Post_Translation_Set' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_translation_set.php',
279
  'Toolset_Post_Type_Exclude_List' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/excluded_list.php',
280
  'Toolset_Post_Type_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/factory.php',
281
  'Toolset_Post_Type_From_Types' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/from_types.php',
@@ -284,14 +291,20 @@ class ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9
284
  'Toolset_Post_Type_Query_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/query_factory.php',
285
  'Toolset_Post_Type_Registered' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/registered.php',
286
  'Toolset_Post_Type_Repository' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/repository.php',
 
 
287
  'Toolset_Promotion' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.promotion.class.php',
288
  'Toolset_Regex' => __DIR__ . '/..' . '/toolset/toolset-common/expression-parser/parser.php',
289
  'Toolset_Relationship_Cardinality' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/cardinality.php',
290
  'Toolset_Relationship_Controller' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/controller.php',
291
- 'Toolset_Relationship_Database_Operations' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/database_operations.php',
292
- 'Toolset_Relationship_Definition' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/definition.php',
293
- 'Toolset_Relationship_Definition_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/definition_factory.php',
294
- 'Toolset_Relationship_Definition_Repository' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/definition_repository.php',
 
 
 
 
295
  'Toolset_Relationship_Driver' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/driver.php',
296
  'Toolset_Relationship_Driver_Base' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/driver_base.php',
297
  'Toolset_Relationship_Element_Type' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/element_type.php',
@@ -301,14 +314,33 @@ class ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9
301
  'Toolset_Relationship_Origin_Post_Reference_Field' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/origin/post_reference_field.php',
302
  'Toolset_Relationship_Origin_Repeatable_Group' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/origin/repeatable_group.php',
303
  'Toolset_Relationship_Origin_Wizard' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/origin/wizard.php',
304
- 'Toolset_Relationship_Query' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query.php',
305
  'Toolset_Relationship_Query_Base' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/query_base.php',
306
  'Toolset_Relationship_Query_Cache' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/query_cache.php',
307
- 'Toolset_Relationship_Role' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/role.php',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  'Toolset_Relationship_Scope' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/scope.php',
309
  'Toolset_Relationship_Service' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/relationship_service.php',
310
  'Toolset_Relationship_Slug_Validator' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/slug_validator.php',
311
- 'Toolset_Relationship_Table_Name' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/table_name.php',
312
  'Toolset_Relationship_Utils' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/utils.php',
313
  'Toolset_Relationship_WPML_Interoperability' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/wpml_interoperability.php',
314
  'Toolset_Relevanssi_Compatibility' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.relevanssi.compatibility.class.php',
@@ -331,7 +363,11 @@ class ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9
331
  'Toolset_Twig_Dialog_Box' => __DIR__ . '/..' . '/toolset/toolset-common/utility/gui-base/twig_dialog_box.php',
332
  'Toolset_Twig_Dialog_Box_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/utility/gui-base/twig_dialog_box_factory.php',
333
  'Toolset_Twig_Extensions' => __DIR__ . '/..' . '/toolset/toolset-common/utility/gui-base/twig_extensions.php',
334
- 'Toolset_Upgrade' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.upgrade.class.php',
 
 
 
 
335
  'Toolset_User_Editors_Editor_Abstract' => __DIR__ . '/..' . '/toolset/toolset-common/user-editors/editor/abstract.php',
336
  'Toolset_User_Editors_Editor_Avada' => __DIR__ . '/..' . '/toolset/toolset-common/user-editors/editor/avada.php',
337
  'Toolset_User_Editors_Editor_Basic' => __DIR__ . '/..' . '/toolset/toolset-common/user-editors/editor/basic.php',
@@ -702,6 +738,7 @@ class ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9
702
  'WPToolset_Field_Numeric' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.numeric.php',
703
  'WPToolset_Field_Password' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.password.php',
704
  'WPToolset_Field_Phone' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.phone.php',
 
705
  'WPToolset_Field_Radios' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.radios.php',
706
  'WPToolset_Field_Recaptcha' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.recaptcha.php',
707
  'WPToolset_Field_Recaptcha_v1' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.recaptcha-v1.php',
@@ -727,10 +764,10 @@ class ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9
727
  public static function getInitializer(ClassLoader $loader)
728
  {
729
  return \Closure::bind(function () use ($loader) {
730
- $loader->prefixLengthsPsr4 = ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9::$prefixLengthsPsr4;
731
- $loader->prefixDirsPsr4 = ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9::$prefixDirsPsr4;
732
- $loader->prefixesPsr0 = ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9::$prefixesPsr0;
733
- $loader->classMap = ComposerStaticInit9dc3a75d9bf0dcdec570d52c4943bef9::$classMap;
734
 
735
  }, null, ClassLoader::class);
736
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4
8
  {
9
  public static $files = array (
10
  'a52c1eba913b4ecdd3571194b37baea9' => __DIR__ . '/../..' . '/application/functions.php',
126
  'FormAbstract' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/abstract.form.php',
127
  'FormFactory' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.form_factory.php',
128
  'IToolset_Association' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/i_association.php',
129
+ 'IToolset_Element' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element/i_element.php',
130
+ 'IToolset_Post' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element/i_post.php',
131
  'IToolset_Post_Type' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type.php',
132
  'IToolset_Post_Type_From_Types' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/i_post_type_from_types.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_Definition' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/i_definition.php',
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',
141
+ 'IToolset_Upgrade_Command' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/upgrade/command_interface.php',
142
  'ReCaptchaResponse' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/js/recaptcha-php-1.11/recaptchalib.php',
143
  'Toolset_Admin_Bar_Menu' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.admin.bar.menu.class.php',
144
  'Toolset_Admin_Notice_Abstract' => __DIR__ . '/..' . '/toolset/toolset-common/utility/admin/notice/abstract.php',
203
  'Toolset_DateParser' => __DIR__ . '/..' . '/toolset/toolset-common/expression-parser/parser.php',
204
  'Toolset_Date_Utils' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/date_utils.php',
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',
211
  'Toolset_Field_Accessor_Abstract' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/field/accessor/abstract.php',
281
  'Toolset_Naming_Helper' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/naming_helper.php',
282
  'Toolset_Object_Relationship' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.object.relationship.class.php',
283
  'Toolset_Parser' => __DIR__ . '/..' . '/toolset/toolset-common/expression-parser/parser.php',
284
+ 'Toolset_Post' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element/post.php',
285
+ 'Toolset_Post_Translation_Set' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/element/post_translation_set.php',
286
  'Toolset_Post_Type_Exclude_List' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/excluded_list.php',
287
  'Toolset_Post_Type_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/factory.php',
288
  'Toolset_Post_Type_From_Types' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/from_types.php',
291
  'Toolset_Post_Type_Query_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/query_factory.php',
292
  'Toolset_Post_Type_Registered' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/registered.php',
293
  'Toolset_Post_Type_Repository' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/post_type/repository.php',
294
+ 'Toolset_Potential_Association_Query_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/potential_association/query_factory.php',
295
+ 'Toolset_Potential_Association_Query_Posts' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/potential_association/query_posts.php',
296
  'Toolset_Promotion' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.promotion.class.php',
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',
303
+ 'Toolset_Relationship_Definition_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/definition/factory.php',
304
+ 'Toolset_Relationship_Definition_Persistence' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/definition/persistence.php',
305
+ 'Toolset_Relationship_Definition_Repository' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/definition/repository.php',
306
+ 'Toolset_Relationship_Definition_Translator' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/definition/translator.php',
307
+ 'Toolset_Relationship_Distinct_Post_Query' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/potential_association/distinct_post_query.php',
308
  'Toolset_Relationship_Driver' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/driver.php',
309
  'Toolset_Relationship_Driver_Base' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/driver_base.php',
310
  'Toolset_Relationship_Element_Type' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/element_type.php',
314
  'Toolset_Relationship_Origin_Post_Reference_Field' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/origin/post_reference_field.php',
315
  'Toolset_Relationship_Origin_Repeatable_Group' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/origin/repeatable_group.php',
316
  'Toolset_Relationship_Origin_Wizard' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/origin/wizard.php',
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',
327
+ 'Toolset_Relationship_Query_Condition_Is_Legacy' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/condition/is_legacy.php',
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',
334
+ 'Toolset_Relationship_Query_V2' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_query/relationship_query_v2.php',
335
+ 'Toolset_Relationship_Role' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_role/role.php',
336
+ 'Toolset_Relationship_Role_Abstract' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_role/abstract.php',
337
+ 'Toolset_Relationship_Role_Child' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_role/child.php',
338
+ 'Toolset_Relationship_Role_Intermediary' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_role/intermediary.php',
339
+ 'Toolset_Relationship_Role_Parent' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/relationship_role/parent.php',
340
  'Toolset_Relationship_Scope' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/scope.php',
341
  'Toolset_Relationship_Service' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/relationship_service.php',
342
  'Toolset_Relationship_Slug_Validator' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/slug_validator.php',
343
+ 'Toolset_Relationship_Table_Name' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/database/table_name.php',
344
  'Toolset_Relationship_Utils' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/utils.php',
345
  'Toolset_Relationship_WPML_Interoperability' => __DIR__ . '/..' . '/toolset/toolset-common/inc/m2m/wpml_interoperability.php',
346
  'Toolset_Relevanssi_Compatibility' => __DIR__ . '/..' . '/toolset/toolset-common/inc/toolset.relevanssi.compatibility.class.php',
363
  'Toolset_Twig_Dialog_Box' => __DIR__ . '/..' . '/toolset/toolset-common/utility/gui-base/twig_dialog_box.php',
364
  'Toolset_Twig_Dialog_Box_Factory' => __DIR__ . '/..' . '/toolset/toolset-common/utility/gui-base/twig_dialog_box_factory.php',
365
  'Toolset_Twig_Extensions' => __DIR__ . '/..' . '/toolset/toolset-common/utility/gui-base/twig_extensions.php',
366
+ 'Toolset_Upgrade_Command_Definition' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/upgrade/command_definition.php',
367
+ 'Toolset_Upgrade_Command_Definition_Repository' => __DIR__ . '/..' . '/toolset/toolset-common/inc/autoloaded/upgrade/command_definition_repository.php',
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',
738
  'WPToolset_Field_Numeric' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.numeric.php',
739
  'WPToolset_Field_Password' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.password.php',
740
  'WPToolset_Field_Phone' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.phone.php',
741
+ 'WPToolset_Field_Post' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.post.php',
742
  'WPToolset_Field_Radios' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.radios.php',
743
  'WPToolset_Field_Recaptcha' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.recaptcha.php',
744
  'WPToolset_Field_Recaptcha_v1' => __DIR__ . '/..' . '/toolset/toolset-common/toolset-forms/classes/class.recaptcha-v1.php',
764
  public static function getInitializer(ClassLoader $loader)
765
  {
766
  return \Closure::bind(function () use ($loader) {
767
+ $loader->prefixLengthsPsr4 = ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4::$prefixLengthsPsr4;
768
+ $loader->prefixDirsPsr4 = ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4::$prefixDirsPsr4;
769
+ $loader->prefixesPsr0 = ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4::$prefixesPsr0;
770
+ $loader->classMap = ComposerStaticInit98453dc040b2a0c9d9e4e0ebe2a806a4::$classMap;
771
 
772
  }, null, ClassLoader::class);
773
  }
vendor/composer/installed.json CHANGED
@@ -217,22 +217,23 @@
217
  },
218
  {
219
  "name": "toolset/toolset-common",
220
- "version": "2.5.3",
221
- "version_normalized": "2.5.3.0",
222
  "source": {
223
  "type": "git",
224
  "url": "ssh://git@git.onthegosystems.com:10022/toolset/toolset-common.git",
225
- "reference": "4e0c6e06de7e3db6a73a28e73e8c0d4b8432db6f"
226
  },
227
  "require": {
228
  "php": ">=5.2.0"
229
  },
230
  "require-dev": {
 
231
  "otgs/build-tools-ci": "~0.7.0",
232
  "otgs/unit-tests-framework": "~1.2.0",
233
  "phpunit/php-token-stream": "<2.0"
234
  },
235
- "time": "2017-10-31T08:29:00+00:00",
236
  "type": "library",
237
  "extra": {
238
  "branch-alias": {
217
  },
218
  {
219
  "name": "toolset/toolset-common",
220
+ "version": "2.5.5",
221
+ "version_normalized": "2.5.5.0",
222
  "source": {
223
  "type": "git",
224
  "url": "ssh://git@git.onthegosystems.com:10022/toolset/toolset-common.git",
225
+ "reference": "d4643145e2ab1e30c26b9f3ec1842d5f644e7c4e"
226
  },
227
  "require": {
228
  "php": ">=5.2.0"
229
  },
230
  "require-dev": {
231
+ "10up/wp_mock": "~0.2.0",
232
  "otgs/build-tools-ci": "~0.7.0",
233
  "otgs/unit-tests-framework": "~1.2.0",
234
  "phpunit/php-token-stream": "<2.0"
235
  },
236
+ "time": "2017-11-14T09:28:59+00:00",
237
  "type": "library",
238
  "extra": {
239
  "branch-alias": {
vendor/toolset/toolset-common/autoload_classmap.php CHANGED
@@ -1,21 +1,23 @@
1
  <?php
2
  // Generated by ZF2's ./bin/classmap_generator.php
3
  return array(
4
- 'IToolset_Element' => dirname( __FILE__ ) . '/inc/autoloaded/i_element.php',
5
- 'IToolset_Post' => dirname( __FILE__ ) . '/inc/autoloaded/i_post.php',
6
  'IToolset_Post_Type' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/i_post_type.php',
7
  'IToolset_Post_Type_From_Types' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/i_post_type_from_types.php',
8
  'IToolset_Post_Type_Registered' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/i_post_type_registered.php',
 
 
9
  'Toolset_Admin_Notice_Abstract' => dirname( __FILE__ ) . '/utility/admin/notice/abstract.php',
10
  'Toolset_Admin_Notice_Dismissible' => dirname( __FILE__ ) . '/utility/admin/notice/dismissible.php',
11
  'Toolset_Admin_Notice_Error' => dirname( __FILE__ ) . '/utility/admin/notice/error.php',
12
  'Toolset_Admin_Notice_Interface' => dirname( __FILE__ ) . '/utility/admin/notice/interface.php',
13
  'Toolset_Admin_Notice_Layouts_Help' => dirname( __FILE__ ) . '/utility/admin/notice/layouts/help.php',
14
  'Toolset_Admin_Notice_Required_Action' => dirname( __FILE__ ) . '/utility/admin/notice/required/action.php',
 
15
  'Toolset_Admin_Notice_Success' => dirname( __FILE__ ) . '/utility/admin/notice/success.php',
16
  'Toolset_Admin_Notice_Undismissible' => dirname( __FILE__ ) . '/utility/admin/notice/undismissible.php',
17
  'Toolset_Admin_Notice_Warning' => dirname( __FILE__ ) . '/utility/admin/notice/warning.php',
18
- 'Toolset_Admin_Notices_Manager' => dirname( __FILE__ ) . '/utility/admin/notices/manager.php',
19
  'Toolset_Ajax_Handler_Abstract' => dirname( __FILE__ ) . '/inc/autoloaded/ajax_handler/abstract.php',
20
  'Toolset_Ajax_Handler_Interface' => dirname( __FILE__ ) . '/inc/autoloaded/ajax_handler/interface.php',
21
  'Toolset_Ajax_Handler_Migrate_To_M2M' => dirname( __FILE__ ) . '/inc/autoloaded/ajax_handler/migrate_to_m2m.php',
@@ -54,8 +56,9 @@ return array(
54
  'Toolset_Date' => dirname( __FILE__ ) . '/expression-parser/parser.php',
55
  'Toolset_DateParser' => dirname( __FILE__ ) . '/expression-parser/parser.php',
56
  'Toolset_Date_Utils' => dirname( __FILE__ ) . '/inc/autoloaded/date_utils.php',
57
- 'Toolset_Element' => dirname( __FILE__ ) . '/inc/autoloaded/element.php',
58
- 'Toolset_Element_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/element_factory.php',
 
59
  'Toolset_Field_Accessor_Abstract' => dirname( __FILE__ ) . '/inc/autoloaded/field/accessor/abstract.php',
60
  'Toolset_Field_Accessor_Dummy' => dirname( __FILE__ ) . '/inc/autoloaded/field/accessor/dummy.php',
61
  'Toolset_Field_Accessor_Postmeta' => dirname( __FILE__ ) . '/inc/autoloaded/field/accessor/postmeta.php',
@@ -67,8 +70,8 @@ return array(
67
  'Toolset_Field_Data_Mapper_Checkboxes' => dirname( __FILE__ ) . '/inc/autoloaded/field/data_mapper/checkboxes.php',
68
  'Toolset_Field_Data_Mapper_Identity' => dirname( __FILE__ ) . '/inc/autoloaded/field/data_mapper/identity.php',
69
  'Toolset_Field_Data_Saver' => dirname( __FILE__ ) . '/inc/autoloaded/field/data_saver.php',
70
- 'Toolset_Field_Definition' => dirname( __FILE__ ) . '/inc/autoloaded/field/definition.php',
71
  'Toolset_Field_Definition_Abstract' => dirname( __FILE__ ) . '/inc/autoloaded/field/definition_abstract.php',
 
72
  'Toolset_Field_Definition_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/field/definition_factory.php',
73
  'Toolset_Field_Definition_Factory_Post' => dirname( __FILE__ ) . '/inc/autoloaded/field/definition_factory_post.php',
74
  'Toolset_Field_Definition_Factory_Term' => dirname( __FILE__ ) . '/inc/autoloaded/field/definition_factory_term.php',
@@ -85,8 +88,8 @@ return array(
85
  'Toolset_Field_Group_Term_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/field/group/term_factory.php',
86
  'Toolset_Field_Group_User' => dirname( __FILE__ ) . '/inc/autoloaded/field/group/user.php',
87
  'Toolset_Field_Group_User_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/field/group/user_factory.php',
88
- 'Toolset_Field_Instance' => dirname( __FILE__ ) . '/inc/autoloaded/field/instance.php',
89
  'Toolset_Field_Instance_Abstract' => dirname( __FILE__ ) . '/inc/autoloaded/field/instance_abstract.php',
 
90
  'Toolset_Field_Instance_Post' => dirname( __FILE__ ) . '/inc/autoloaded/field/instance_post.php',
91
  'Toolset_Field_Instance_Term' => dirname( __FILE__ ) . '/inc/autoloaded/field/instance_term.php',
92
  'Toolset_Field_Instance_Unsaved' => dirname( __FILE__ ) . '/inc/autoloaded/field/instance_unsaved.php',
@@ -109,10 +112,10 @@ return array(
109
  'Toolset_Field_Renderer_Purpose' => dirname( __FILE__ ) . '/inc/autoloaded/field/renderer/purpose.php',
110
  'Toolset_Field_Renderer_Toolset_Forms' => dirname( __FILE__ ) . '/inc/autoloaded/field/renderer/toolset_forms.php',
111
  'Toolset_Field_Renderer_Toolset_Forms_Repeatable_Group' => dirname( __FILE__ ) . '/inc/autoloaded/field/renderer/toolset_forms_repeatable_group.php',
112
- 'Toolset_Field_Type_Definition' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition.php',
113
  'Toolset_Field_Type_Definition_Checkbox' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition/checkbox.php',
114
  'Toolset_Field_Type_Definition_Checkboxes' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition/checkboxes.php',
115
  'Toolset_Field_Type_Definition_Date' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition/date.php',
 
116
  'Toolset_Field_Type_Definition_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition_factory.php',
117
  'Toolset_Field_Type_Definition_Numeric' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition/numeric.php',
118
  'Toolset_Field_Type_Definition_Radio' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition/radio.php',
@@ -122,8 +125,8 @@ return array(
122
  'Toolset_Functions' => dirname( __FILE__ ) . '/expression-parser/parser.php',
123
  'Toolset_Naming_Helper' => dirname( __FILE__ ) . '/inc/autoloaded/naming_helper.php',
124
  'Toolset_Parser' => dirname( __FILE__ ) . '/expression-parser/parser.php',
125
- 'Toolset_Post' => dirname( __FILE__ ) . '/inc/autoloaded/post.php',
126
- 'Toolset_Post_Translation_Set' => dirname( __FILE__ ) . '/inc/autoloaded/post_translation_set.php',
127
  'Toolset_Post_Type_Exclude_List' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/excluded_list.php',
128
  'Toolset_Post_Type_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/factory.php',
129
  'Toolset_Post_Type_From_Types' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/from_types.php',
@@ -144,6 +147,11 @@ return array(
144
  'Toolset_Shortcode_Attr_Item_M2M' => dirname( __FILE__ ) . '/inc/autoloaded/shortcode/attr/item/m2m.php',
145
  'Toolset_Stack' => dirname( __FILE__ ) . '/expression-parser/parser.php',
146
  'Toolset_Tokenizer' => dirname( __FILE__ ) . '/expression-parser/parser.php',
 
 
 
 
 
147
  'Toolset_User_Editors_Editor_Abstract' => dirname( __FILE__ ) . '/user-editors/editor/abstract.php',
148
  'Toolset_User_Editors_Editor_Avada' => dirname( __FILE__ ) . '/user-editors/editor/avada.php',
149
  'Toolset_User_Editors_Editor_Basic' => dirname( __FILE__ ) . '/user-editors/editor/basic.php',
1
  <?php
2
  // Generated by ZF2's ./bin/classmap_generator.php
3
  return array(
4
+ 'IToolset_Element' => dirname( __FILE__ ) . '/inc/autoloaded/element/i_element.php',
5
+ 'IToolset_Post' => dirname( __FILE__ ) . '/inc/autoloaded/element/i_post.php',
6
  'IToolset_Post_Type' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/i_post_type.php',
7
  'IToolset_Post_Type_From_Types' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/i_post_type_from_types.php',
8
  'IToolset_Post_Type_Registered' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/i_post_type_registered.php',
9
+ 'IToolset_Query' => dirname( __FILE__ ) . '/inc/autoloaded/i_query.php',
10
+ 'IToolset_Upgrade_Command' => dirname( __FILE__ ) . '/inc/autoloaded/upgrade/command_interface.php',
11
  'Toolset_Admin_Notice_Abstract' => dirname( __FILE__ ) . '/utility/admin/notice/abstract.php',
12
  'Toolset_Admin_Notice_Dismissible' => dirname( __FILE__ ) . '/utility/admin/notice/dismissible.php',
13
  'Toolset_Admin_Notice_Error' => dirname( __FILE__ ) . '/utility/admin/notice/error.php',
14
  'Toolset_Admin_Notice_Interface' => dirname( __FILE__ ) . '/utility/admin/notice/interface.php',
15
  'Toolset_Admin_Notice_Layouts_Help' => dirname( __FILE__ ) . '/utility/admin/notice/layouts/help.php',
16
  'Toolset_Admin_Notice_Required_Action' => dirname( __FILE__ ) . '/utility/admin/notice/required/action.php',
17
+ 'Toolset_Admin_Notices_Manager' => dirname( __FILE__ ) . '/utility/admin/notices/manager.php',
18
  'Toolset_Admin_Notice_Success' => dirname( __FILE__ ) . '/utility/admin/notice/success.php',
19
  'Toolset_Admin_Notice_Undismissible' => dirname( __FILE__ ) . '/utility/admin/notice/undismissible.php',
20
  'Toolset_Admin_Notice_Warning' => dirname( __FILE__ ) . '/utility/admin/notice/warning.php',
 
21
  'Toolset_Ajax_Handler_Abstract' => dirname( __FILE__ ) . '/inc/autoloaded/ajax_handler/abstract.php',
22
  'Toolset_Ajax_Handler_Interface' => dirname( __FILE__ ) . '/inc/autoloaded/ajax_handler/interface.php',
23
  'Toolset_Ajax_Handler_Migrate_To_M2M' => dirname( __FILE__ ) . '/inc/autoloaded/ajax_handler/migrate_to_m2m.php',
56
  'Toolset_Date' => dirname( __FILE__ ) . '/expression-parser/parser.php',
57
  'Toolset_DateParser' => dirname( __FILE__ ) . '/expression-parser/parser.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_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',
64
  'Toolset_Field_Accessor_Postmeta' => dirname( __FILE__ ) . '/inc/autoloaded/field/accessor/postmeta.php',
70
  'Toolset_Field_Data_Mapper_Checkboxes' => dirname( __FILE__ ) . '/inc/autoloaded/field/data_mapper/checkboxes.php',
71
  'Toolset_Field_Data_Mapper_Identity' => dirname( __FILE__ ) . '/inc/autoloaded/field/data_mapper/identity.php',
72
  'Toolset_Field_Data_Saver' => dirname( __FILE__ ) . '/inc/autoloaded/field/data_saver.php',
 
73
  'Toolset_Field_Definition_Abstract' => dirname( __FILE__ ) . '/inc/autoloaded/field/definition_abstract.php',
74
+ 'Toolset_Field_Definition' => dirname( __FILE__ ) . '/inc/autoloaded/field/definition.php',
75
  'Toolset_Field_Definition_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/field/definition_factory.php',
76
  'Toolset_Field_Definition_Factory_Post' => dirname( __FILE__ ) . '/inc/autoloaded/field/definition_factory_post.php',
77
  'Toolset_Field_Definition_Factory_Term' => dirname( __FILE__ ) . '/inc/autoloaded/field/definition_factory_term.php',
88
  'Toolset_Field_Group_Term_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/field/group/term_factory.php',
89
  'Toolset_Field_Group_User' => dirname( __FILE__ ) . '/inc/autoloaded/field/group/user.php',
90
  'Toolset_Field_Group_User_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/field/group/user_factory.php',
 
91
  'Toolset_Field_Instance_Abstract' => dirname( __FILE__ ) . '/inc/autoloaded/field/instance_abstract.php',
92
+ 'Toolset_Field_Instance' => dirname( __FILE__ ) . '/inc/autoloaded/field/instance.php',
93
  'Toolset_Field_Instance_Post' => dirname( __FILE__ ) . '/inc/autoloaded/field/instance_post.php',
94
  'Toolset_Field_Instance_Term' => dirname( __FILE__ ) . '/inc/autoloaded/field/instance_term.php',
95
  'Toolset_Field_Instance_Unsaved' => dirname( __FILE__ ) . '/inc/autoloaded/field/instance_unsaved.php',
112
  'Toolset_Field_Renderer_Purpose' => dirname( __FILE__ ) . '/inc/autoloaded/field/renderer/purpose.php',
113
  'Toolset_Field_Renderer_Toolset_Forms' => dirname( __FILE__ ) . '/inc/autoloaded/field/renderer/toolset_forms.php',
114
  'Toolset_Field_Renderer_Toolset_Forms_Repeatable_Group' => dirname( __FILE__ ) . '/inc/autoloaded/field/renderer/toolset_forms_repeatable_group.php',
 
115
  'Toolset_Field_Type_Definition_Checkbox' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition/checkbox.php',
116
  'Toolset_Field_Type_Definition_Checkboxes' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition/checkboxes.php',
117
  'Toolset_Field_Type_Definition_Date' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition/date.php',
118
+ 'Toolset_Field_Type_Definition' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition.php',
119
  'Toolset_Field_Type_Definition_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition_factory.php',
120
  'Toolset_Field_Type_Definition_Numeric' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition/numeric.php',
121
  'Toolset_Field_Type_Definition_Radio' => dirname( __FILE__ ) . '/inc/autoloaded/field/type/definition/radio.php',
125
  'Toolset_Functions' => dirname( __FILE__ ) . '/expression-parser/parser.php',
126
  'Toolset_Naming_Helper' => dirname( __FILE__ ) . '/inc/autoloaded/naming_helper.php',
127
  'Toolset_Parser' => dirname( __FILE__ ) . '/expression-parser/parser.php',
128
+ 'Toolset_Post' => dirname( __FILE__ ) . '/inc/autoloaded/element/post.php',
129
+ 'Toolset_Post_Translation_Set' => dirname( __FILE__ ) . '/inc/autoloaded/element/post_translation_set.php',
130
  'Toolset_Post_Type_Exclude_List' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/excluded_list.php',
131
  'Toolset_Post_Type_Factory' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/factory.php',
132
  'Toolset_Post_Type_From_Types' => dirname( __FILE__ ) . '/inc/autoloaded/post_type/from_types.php',
147
  'Toolset_Shortcode_Attr_Item_M2M' => dirname( __FILE__ ) . '/inc/autoloaded/shortcode/attr/item/m2m.php',
148
  'Toolset_Stack' => dirname( __FILE__ ) . '/expression-parser/parser.php',
149
  'Toolset_Tokenizer' => dirname( __FILE__ ) . '/expression-parser/parser.php',
150
+ 'Toolset_Upgrade_Command_Definition' => dirname( __FILE__ ) . '/inc/autoloaded/upgrade/command_definition.php',
151
+ 'Toolset_Upgrade_Command_Definition_Repository' => dirname( __FILE__ ) . '/inc/autoloaded/upgrade/command_definition_repository.php',
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',
vendor/toolset/toolset-common/bootstrap.php CHANGED
@@ -33,7 +33,7 @@ class Toolset_Common_Bootstrap {
33
 
34
  private static $instance;
35
  private static $sections_loaded;
36
-
37
  public $assets_manager;
38
  public $object_relationship;
39
  public $menu;
@@ -82,9 +82,9 @@ class Toolset_Common_Bootstrap {
82
  $this->register_res();
83
  $this->register_libs();
84
  $this->register_inc();
85
-
86
  add_filter( 'toolset_is_toolset_common_available', '__return_true' );
87
-
88
  add_action( 'switch_blog', array( $this, 'clear_settings_instance' ) );
89
 
90
  /**
@@ -130,7 +130,7 @@ class Toolset_Common_Bootstrap {
130
  return in_array( $section_name, self::$sections_loaded );
131
  }
132
 
133
-
134
  /**
135
  * Add a section name to the list of the loaded ones.
136
  *
@@ -207,7 +207,7 @@ class Toolset_Common_Bootstrap {
207
  }
208
 
209
  }
210
-
211
  public function register_res() {
212
 
213
  if ( ! $this->is_section_loaded( self::TOOLSET_RESOURCES ) ) {
@@ -218,7 +218,7 @@ class Toolset_Common_Bootstrap {
218
  $this->apply_filters_on_sections_loaded( 'toolset_register_assets_section' );
219
  }
220
  }
221
-
222
  public function register_libs() {
223
 
224
  if ( ! $this->is_section_loaded( self::TOOLSET_LIBRARIES ) ) {
@@ -247,7 +247,7 @@ class Toolset_Common_Bootstrap {
247
  $this->apply_filters_on_sections_loaded( 'toolset_register_library_section' );
248
  }
249
  }
250
-
251
  public function register_inc() {
252
 
253
  if ( ! $this->is_section_loaded( self::TOOLSET_INCLUDES ) ) {
@@ -256,6 +256,10 @@ class Toolset_Common_Bootstrap {
256
 
257
  $this->register_autoloaded_classes();
258
 
 
 
 
 
259
  // Manually load the more sensitive code.
260
  if ( ! class_exists( 'Toolset_Settings', false ) ) {
261
  require_once TOOLSET_COMMON_PATH . '/inc/toolset.settings.class.php';
@@ -310,16 +314,7 @@ class Toolset_Common_Bootstrap {
310
  $this->relevanssi_compatibility = new Toolset_Relevanssi_Compatibility();
311
  }
312
 
313
- // If we're in admin mode, check for the need of database upgrade. It is safe to expect that
314
- // an admin page will be visited during plugin upgrade, or shortly after (e.g. if wp-cli is used).
315
- if( ( self::MODE_ADMIN == $this->get_request_mode() )
316
- && ! class_exists( 'Toolset_Upgrade', false ) )
317
- {
318
- require_once TOOLSET_COMMON_PATH . '/inc/toolset.upgrade.class.php';
319
- Toolset_Upgrade::initialize();
320
- }
321
-
322
- if ( ! class_exists( 'Toolset_CssComponent' ) ) {
323
  require_once( TOOLSET_COMMON_PATH . '/inc/toolset.css.component.class.php' );
324
  Toolset_CssComponent::getInstance();
325
  }
@@ -365,7 +360,7 @@ class Toolset_Common_Bootstrap {
365
  $this->apply_filters_on_sections_loaded( 'toolset_register_include_section' );
366
  }
367
  }
368
-
369
  public function register_utils() {
370
 
371
  if( ! $this->is_section_loaded( self::TOOLSET_AUTOLOADER ) ) {
@@ -425,7 +420,7 @@ class Toolset_Common_Bootstrap {
425
  $this->apply_filters_on_sections_loaded( 'toolset_register_forms_section' );
426
  }
427
  }
428
-
429
  public function register_visual_editor() {
430
 
431
  if ( ! $this->is_section_loaded( self::TOOLSET_VISUAL_EDITOR ) ) {
@@ -436,7 +431,7 @@ class Toolset_Common_Bootstrap {
436
  $this->apply_filters_on_sections_loaded( 'toolset_register_visual_editor_section' );
437
  }
438
  }
439
-
440
  public function register_parser() {
441
 
442
  if ( ! $this->is_section_loaded( self::TOOLSET_PARSER ) ) {
33
 
34
  private static $instance;
35
  private static $sections_loaded;
36
+
37
  public $assets_manager;
38
  public $object_relationship;
39
  public $menu;
82
  $this->register_res();
83
  $this->register_libs();
84
  $this->register_inc();
85
+
86
  add_filter( 'toolset_is_toolset_common_available', '__return_true' );
87
+
88
  add_action( 'switch_blog', array( $this, 'clear_settings_instance' ) );
89
 
90
  /**
130
  return in_array( $section_name, self::$sections_loaded );
131
  }
132
 
133
+
134
  /**
135
  * Add a section name to the list of the loaded ones.
136
  *
207
  }
208
 
209
  }
210
+
211
  public function register_res() {
212
 
213
  if ( ! $this->is_section_loaded( self::TOOLSET_RESOURCES ) ) {
218
  $this->apply_filters_on_sections_loaded( 'toolset_register_assets_section' );
219
  }
220
  }
221
+
222
  public function register_libs() {
223
 
224
  if ( ! $this->is_section_loaded( self::TOOLSET_LIBRARIES ) ) {
247
  $this->apply_filters_on_sections_loaded( 'toolset_register_library_section' );
248
  }
249
  }
250
+
251
  public function register_inc() {
252
 
253
  if ( ! $this->is_section_loaded( self::TOOLSET_INCLUDES ) ) {
256
 
257
  $this->register_autoloaded_classes();
258
 
259
+ // Make sure we check for upgrades after the Toolset Common library is fully loaded.
260
+ $upgrade_controller = Toolset_Upgrade_Controller::get_instance();
261
+ $upgrade_controller->initialize();
262
+
263
  // Manually load the more sensitive code.
264
  if ( ! class_exists( 'Toolset_Settings', false ) ) {
265
  require_once TOOLSET_COMMON_PATH . '/inc/toolset.settings.class.php';
314
  $this->relevanssi_compatibility = new Toolset_Relevanssi_Compatibility();
315
  }
316
 
317
+ if ( ! class_exists( 'Toolset_CssComponent', false ) ) {
 
 
 
 
 
 
 
 
 
318
  require_once( TOOLSET_COMMON_PATH . '/inc/toolset.css.component.class.php' );
319
  Toolset_CssComponent::getInstance();
320
  }
360
  $this->apply_filters_on_sections_loaded( 'toolset_register_include_section' );
361
  }
362
  }
363
+
364
  public function register_utils() {
365
 
366
  if( ! $this->is_section_loaded( self::TOOLSET_AUTOLOADER ) ) {
420
  $this->apply_filters_on_sections_loaded( 'toolset_register_forms_section' );
421
  }
422
  }
423
+
424
  public function register_visual_editor() {
425
 
426
  if ( ! $this->is_section_loaded( self::TOOLSET_VISUAL_EDITOR ) ) {
431
  $this->apply_filters_on_sections_loaded( 'toolset_register_visual_editor_section' );
432
  }
433
  }
434
+
435
  public function register_parser() {
436
 
437
  if ( ! $this->is_section_loaded( self::TOOLSET_PARSER ) ) {
vendor/toolset/toolset-common/changelog.md CHANGED
@@ -1,5 +1,17 @@
1
  # Toolset Common Library
2
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ## 2.5.3
4
  * Released with Types 2.2.17
5
 
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).
6
+ * Fix several compatibility issues with Visual Composer.
7
+ * Fix a problem when gathering the title of some Types fields.
8
+
9
+ ## 2.5.4
10
+ * Released with CRED 1.9.3
11
+ * Include a shared Toolset JS shortcodes library.
12
+ * Fixed a problem with loading the latest Bootstrap CSS Components from Toolset Common.
13
+ * Fixed some notices caused by slightly different array structures on fields.
14
+
15
  ## 2.5.3
16
  * Released with Types 2.2.17
17
 
vendor/toolset/toolset-common/inc/autoloaded/element/domain.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Enum class that holds the names of element domains.
5
+ *
6
+ * @since 2.5.4
7
+ */
8
+ abstract class Toolset_Element_Domain {
9
+
10
+ const POSTS = 'posts';
11
+ const USERS = 'users';
12
+ const TERMS = 'terms';
13
+
14
+
15
+ public static function all() {
16
+ return array( self::POSTS, self::USERS, self::TERMS );
17
+ }
18
+
19
+ }
vendor/toolset/toolset-common/inc/autoloaded/{element.php → element/element.php} RENAMED
File without changes
vendor/toolset/toolset-common/inc/autoloaded/{element_factory.php → element/element_factory.php} RENAMED
File without changes
vendor/toolset/toolset-common/inc/autoloaded/{i_element.php → element/i_element.php} RENAMED
@@ -24,6 +24,12 @@ interface IToolset_Element {
24
  function get_id();
25
 
26
 
 
 
 
 
 
 
27
  /**
28
  * Load custom fields of the element if they're not loaded yet.
29
  *
@@ -56,7 +62,7 @@ interface IToolset_Element {
56
  *
57
  * @param string|Toolset_Field_Definition $field_source Field definition or a field slug.
58
  * @return bool True if a field with given slug exists.
59
- * @throws InvalidArgumentException
60
  * @since m2m
61
  */
62
  function has_field( $field_source );
@@ -69,7 +75,7 @@ interface IToolset_Element {
69
  *
70
  * @param string|Toolset_Field_Definition $field_source Field definition or a field slug.
71
  * @return Toolset_Field_Instance
72
- * @throws InvalidArgumentException
73
  */
74
  function get_field( $field_source );
75
 
24
  function get_id();
25
 
26
 
27
+ /**
28
+ * @return string Element title.
29
+ */
30
+ function get_title();
31
+
32
+
33
  /**
34
  * Load custom fields of the element if they're not loaded yet.
35
  *
62
  *
63
  * @param string|Toolset_Field_Definition $field_source Field definition or a field slug.
64
  * @return bool True if a field with given slug exists.
65
+ * @throws InvalidArgumentException When the field source has a wrong type.
66
  * @since m2m
67
  */
68
  function has_field( $field_source );
75
  *
76
  * @param string|Toolset_Field_Definition $field_source Field definition or a field slug.
77
  * @return Toolset_Field_Instance
78
+ * @throws InvalidArgumentException When the field source has a wrong type.
79
  */
80
  function get_field( $field_source );
81
 
vendor/toolset/toolset-common/inc/autoloaded/{i_post.php → element/i_post.php} RENAMED
File without changes
vendor/toolset/toolset-common/inc/autoloaded/{post.php → element/post.php} RENAMED
@@ -86,6 +86,12 @@ class Toolset_Post extends Toolset_Element implements IToolset_Post {
86
  public function get_id() { return $this->post->ID; }
87
 
88
 
 
 
 
 
 
 
89
  /**
90
  * @inheritdoc
91
  * @return Toolset_Field_Group_Post[]
@@ -131,15 +137,6 @@ class Toolset_Post extends Toolset_Element implements IToolset_Post {
131
  }
132
 
133
 
134
- /**
135
- * @inheritdoc
136
- * @return string
137
- */
138
- public function get_title() {
139
- return $this->post->post_title;
140
- }
141
-
142
-
143
  /**
144
  * @param string $title New post title
145
  *
86
  public function get_id() { return $this->post->ID; }
87
 
88
 
89
+ /**
90
+ * @return string Post title.
91
+ */
92
+ public function get_title() { return $this->post->post_title; }
93
+
94
+
95
  /**
96
  * @inheritdoc
97
  * @return Toolset_Field_Group_Post[]
137
  }
138
 
139
 
 
 
 
 
 
 
 
 
 
140
  /**
141
  * @param string $title New post title
142
  *
vendor/toolset/toolset-common/inc/autoloaded/{post_translation_set.php → element/post_translation_set.php} RENAMED
@@ -196,6 +196,16 @@ class Toolset_Post_Translation_Set implements IToolset_Post {
196
  /**
197
  * @param null|string $language_code If null, the best translation will be selected automatically.
198
  *
 
 
 
 
 
 
 
 
 
 
199
  * @return string Post type slug.
200
  * @since m2m
201
  */
@@ -316,15 +326,6 @@ class Toolset_Post_Translation_Set implements IToolset_Post {
316
  return $this->get_best_translation( $language_code )->get_language();
317
  }
318
 
319
- /**
320
- * @param null|string $language_code
321
- *
322
- * @return string Post title
323
- * @since m2m
324
- */
325
- public function get_title( $language_code = null ) {
326
- return $this->get_best_translation( $language_code )->get_title();
327
- }
328
 
329
  /**
330
  * @param null|string $language_code
196
  /**
197
  * @param null|string $language_code If null, the best translation will be selected automatically.
198
  *
199
+ * @return string Post title.
200
+ */
201
+ public function get_title( $language_code = null ) {
202
+ return $this->get_best_translation( $language_code )->get_title();
203
+ }
204
+
205
+
206
+ /**
207
+ * @param null|string $language_code If null, the best translation will be selected automatically.
208
+ *
209
  * @return string Post type slug.
210
  * @since m2m
211
  */
326
  return $this->get_best_translation( $language_code )->get_language();
327
  }
328
 
 
 
 
 
 
 
 
 
 
329
 
330
  /**
331
  * @param null|string $language_code
vendor/toolset/toolset-common/inc/autoloaded/field/group.php CHANGED
@@ -482,6 +482,18 @@ abstract class Toolset_Field_Group {
482
  }
483
 
484
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  private $assigned_to_items = null;
486
 
487
 
482
  }
483
 
484
 
485
+ /**
486
+ * Updates the assinged types
487
+ *
488
+ * After assigned a new assined type, this method must be called in order to update the cached property `assigned_to_types`
489
+ *
490
+ * @param String[] $types List of types
491
+ */
492
+ protected function update_assigned_types( $types ) {
493
+ $this->assigned_to_types = $types;
494
+ }
495
+
496
+
497
  private $assigned_to_items = null;
498
 
499
 
vendor/toolset/toolset-common/inc/autoloaded/field/group/post.php CHANGED
@@ -80,6 +80,7 @@ class Toolset_Field_Group_Post extends Toolset_Field_Group {
80
  }
81
  }
82
 
 
83
  $post_types = empty( $post_types )
84
  ? ''
85
  : implode( ',', $post_types );
80
  }
81
  }
82
 
83
+ $this->update_assigned_types( $post_types );
84
  $post_types = empty( $post_types )
85
  ? ''
86
  : implode( ',', $post_types );
vendor/toolset/toolset-common/inc/autoloaded/field/group/post_factory.php CHANGED
@@ -46,15 +46,17 @@ class Toolset_Field_Group_Post_Factory extends Toolset_Field_Group_Factory {
46
  *
47
  * @param string $name Sanitized field group name. Note that the final name may change when new post is inserted.
48
  * @param string $title Field group title.
 
 
49
  *
50
  * @return null|Toolset_Field_Group The new field group or null on error.
51
  */
52
- public static function create( $name, $title = '', $status = 'draft' ) {
53
  // we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
54
  // we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
55
  // instead of Toolset_Field_Group_Term_Factory like the original get_called_class() function does
56
  // ends in an error because of parents (abstract) $var = new self();
57
- return Toolset_Field_Group_Post_Factory::get_instance()->create_field_group( $name, $title, $status );
58
  }
59
 
60
 
46
  *
47
  * @param string $name Sanitized field group name. Note that the final name may change when new post is inserted.
48
  * @param string $title Field group title.
49
+ * @param String $status Post status
50
+ * @param String $purpose Purpose.
51
  *
52
  * @return null|Toolset_Field_Group The new field group or null on error.
53
  */
54
+ public static function create( $name, $title = '', $status = 'draft', $purpose = Toolset_Field_Group_Post::PURPOSE_GENERIC ) {
55
  // we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
56
  // we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
57
  // instead of Toolset_Field_Group_Term_Factory like the original get_called_class() function does
58
  // ends in an error because of parents (abstract) $var = new self();
59
+ return Toolset_Field_Group_Post_Factory::get_instance()->create_field_group( $name, $title, $status, $purpose );
60
  }
61
 
62
 
vendor/toolset/toolset-common/inc/autoloaded/field/utils.php CHANGED
@@ -10,8 +10,14 @@ final class Toolset_Field_Utils {
10
 
11
 
12
  // Field domains supported by the page.
 
 
13
  const DOMAIN_POSTS = 'posts';
 
 
14
  const DOMAIN_USERS = 'users';
 
 
15
  const DOMAIN_TERMS = 'terms';
16
 
17
  // Since PHP 5.6, noooo!
@@ -25,6 +31,7 @@ final class Toolset_Field_Utils {
25
  *
26
  * @return array
27
  * @since 2.0
 
28
  */
29
  public static function get_domains() {
30
  return array( self::DOMAIN_POSTS, self::DOMAIN_USERS, self::DOMAIN_TERMS );
10
 
11
 
12
  // Field domains supported by the page.
13
+
14
+ /** @deprecated Use Toolset_Element_Domain::POSTS instead. */
15
  const DOMAIN_POSTS = 'posts';
16
+
17
+ /** @deprecated Use Toolset_Element_Domain::USERS instead. */
18
  const DOMAIN_USERS = 'users';
19
+
20
+ /** @deprecated Use Toolset_Element_Domain::TERMS instead. */
21
  const DOMAIN_TERMS = 'terms';
22
 
23
  // Since PHP 5.6, noooo!
31
  *
32
  * @return array
33
  * @since 2.0
34
+ * @deprecated Use Toolset_Element_Domain::all() instead.
35
  */
36
  public static function get_domains() {
37
  return array( self::DOMAIN_POSTS, self::DOMAIN_USERS, self::DOMAIN_TERMS );
vendor/toolset/toolset-common/inc/autoloaded/i_query.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Generic interface for queries.
5
+ *
6
+ * @since m2m
7
+ */
8
+ interface IToolset_Query {
9
+
10
+
11
+ /**
12
+ * @return array
13
+ */
14
+ public function get_results();
15
+
16
+ }
vendor/toolset/toolset-common/inc/autoloaded/post_type/query.php CHANGED
@@ -29,6 +29,7 @@ class Toolset_Post_Type_Query {
29
  const HAS_SPECIAL_PURPOSE = 'has_special_purpose';
30
  const IS_EXCLUDED = 'is_excluded';
31
  const IS_PUBLIC = 'is_public';
 
32
 
33
  const RETURN_TYPE = 'return';
34
 
@@ -91,6 +92,10 @@ class Toolset_Post_Type_Query {
91
  self::IS_PUBLIC => array(
92
  'callback' => array( $this, 'filter_bool_property' ),
93
  'filter_args' => 'is_public'
 
 
 
 
94
  )
95
  );
96
 
29
  const HAS_SPECIAL_PURPOSE = 'has_special_purpose';
30
  const IS_EXCLUDED = 'is_excluded';
31
  const IS_PUBLIC = 'is_public';
32
+ const IS_REGISTERED = 'is_registered';
33
 
34
  const RETURN_TYPE = 'return';
35
 
92
  self::IS_PUBLIC => array(
93
  'callback' => array( $this, 'filter_bool_property' ),
94
  'filter_args' => 'is_public'
95
+ ),
96
+ self::IS_REGISTERED => array(
97
+ 'callback' => array( $this, 'filter_bool_property' ),
98
+ 'filter_args' => 'is_registered'
99
  )
100
  );
101
 
vendor/toolset/toolset-common/inc/autoloaded/shortcode/attr/item/id.php CHANGED
@@ -24,8 +24,6 @@ class Toolset_Shortcode_Attr_Item_Id implements Toolset_Shortcode_Attr_Interface
24
  }
25
 
26
  return $this->return_single_id( $role_id );
27
-
28
- return false;
29
  }
30
 
31
  /**
24
  }
25
 
26
  return $this->return_single_id( $role_id );
 
 
27
  }
28
 
29
  /**
vendor/toolset/toolset-common/inc/autoloaded/upgrade/command/m2m_v1_database_structure_upgrade.php ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Transform the m2m table structures and data from the m2m-v1 beta release to be up-to-date with changes
5
+ * implemented in toolsetcommon-305 (aimed for the m2m-v2 beta release).
6
+ *
7
+ * Obviously, the upgrade will run only if m2m is enabled at the time of the upgrade.
8
+ *
9
+ * Note: We're hardcoding a bunch of things here and the code is not really DRY. That's on purpose: This upgrade
10
+ * command aims at a specific database structure and by using hardcoded values (e.g. for table names)
11
+ * we're becoming immune even to unlikely changes like future renaming of tables or columns.
12
+ *
13
+ * Note: This will fail terribly if executed for the second time.
14
+ *
15
+ * @since 2.5.4
16
+ */
17
+ class Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade implements IToolset_Upgrade_Command {
18
+
19
+
20
+ /** @var wpdb */
21
+ private $wpdb;
22
+
23
+
24
+ /** @var Toolset_Relationship_Database_Operations|null */
25
+ private $_database_operations;
26
+
27
+
28
+ /**
29
+ * @var int Next free set_id value for the type set table. We know it starts at 1 because when this command
30
+ * runs, the table doesn't exist yet.
31
+ */
32
+ private $next_type_set_id = 1;
33
+
34
+
35
+ /**
36
+ * Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade constructor.
37
+ *
38
+ * @param wpdb|null $wpdb_di
39
+ * @param Toolset_Relationship_Database_Operations|null $relationship_database_operations_di
40
+ */
41
+ public function __construct(
42
+ wpdb $wpdb_di = null,
43
+ Toolset_Relationship_Database_Operations $relationship_database_operations_di = null
44
+ ) {
45
+ if( null === $wpdb_di ) {
46
+ global $wpdb;
47
+ $this->wpdb = $wpdb;
48
+ } else {
49
+ $this->wpdb = $wpdb_di;
50
+ }
51
+
52
+ $this->_database_operations = $relationship_database_operations_di;
53
+ }
54
+
55
+ /**
56
+ * Run the command.
57
+ *
58
+ * @return Toolset_Result|Toolset_Result_Set
59
+ */
60
+ public function run() {
61
+
62
+ if( ! apply_filters( 'toolset_is_m2m_enabled', false ) ) {
63
+ // Nothing to do here: The tables will be created as soon as m2m is activated for the first time.
64
+ return new Toolset_Result( true );
65
+ }
66
+
67
+ $results = new Toolset_Result_Set();
68
+
69
+ $this->create_post_type_set_table();
70
+ $this->transform_post_type_sets();
71
+ $this->change_relationship_type_column_datatypes();
72
+
73
+ $this->add_extra_relationship_columns();
74
+ $this->transform_extra_relationship_data();
75
+ $this->drop_relationship_extra_column();
76
+
77
+ $this->add_indexes_for_relationships_table();
78
+
79
+ $this->add_relationship_id_column_for_associations();
80
+ $this->transform_relationship_references_for_associations();
81
+ $this->remove_relationship_slug_column_for_associations();
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.
91
+ $query = "CREATE TABLE {$this->get_type_set_table_name()} (
92
+ id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
93
+ set_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
94
+ type VARCHAR(20) NOT NULL DEFAULT '',
95
+ PRIMARY KEY id (id),
96
+ KEY set_id (set_id),
97
+ KEY type (type)
98
+ ) {$this->wpdb->get_charset_collate()};";
99
+
100
+ self::dbdelta( $query );
101
+ }
102
+
103
+
104
+ private function transform_post_type_sets() {
105
+ $relationships = $this->wpdb->get_results(
106
+ "SELECT id, parent_types, child_types FROM {$this->get_relationships_table_name()}"
107
+ );
108
+
109
+ foreach( $relationships as $relationship ) {
110
+ $parent_types = $this->save_post_type_set( maybe_unserialize( $relationship->parent_types ) );
111
+ $child_types = $this->save_post_type_set( maybe_unserialize( $relationship->child_types ) );
112
+
113
+ $this->wpdb->update(
114
+ $this->get_relationships_table_name(),
115
+ array(
116
+ 'parent_types' => $parent_types,
117
+ 'child_types' => $child_types,
118
+ ),
119
+ array(
120
+ 'id' => (int) $relationship->id,
121
+ ),
122
+ '%s',
123
+ '%d'
124
+ );
125
+ }
126
+ }
127
+
128
+
129
+ private function change_relationship_type_column_datatypes() {
130
+ $this->wpdb->query(
131
+ "ALTER TABLE {$this->get_relationships_table_name()}
132
+ MODIFY parent_types bigint(20) UNSIGNED NOT NULL DEFAULT 0,
133
+ MODIFY child_types bigint(20) UNSIGNED NOT NULL DEFAULT 0"
134
+ );
135
+ }
136
+
137
+
138
+ /**
139
+ * Execute a dbDelta() query, ensuring that the function is available.
140
+ *
141
+ * @param string $query MySQL query.
142
+ *
143
+ * @return array dbDelta return value.
144
+ */
145
+ private static function dbdelta( $query ) {
146
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
147
+ return dbDelta( $query );
148
+ }
149
+
150
+
151
+ private function get_type_set_table_name() {
152
+ return $this->wpdb->prefix . 'toolset_type_sets';
153
+ }
154
+
155
+
156
+ private function get_relationships_table_name() {
157
+ return $this->wpdb->prefix . 'toolset_relationships';
158
+ }
159
+
160
+
161
+ private function get_associations_table_name() {
162
+ return $this->wpdb->prefix . 'toolset_associations';
163
+ }
164
+
165
+
166
+ private function save_post_type_set( $post_types ) {
167
+ $set_id = $this->next_type_set_id++;
168
+
169
+ foreach( $post_types as $post_type ) {
170
+ $this->wpdb->insert(
171
+ $this->get_type_set_table_name(),
172
+ array(
173
+ 'set_id' => $set_id,
174
+ 'type' => $post_type,
175
+ ),
176
+ array( '%d', '%s' )
177
+ );
178
+ }
179
+
180
+ return $set_id;
181
+ }
182
+
183
+
184
+ private function add_extra_relationship_columns() {
185
+ $this->wpdb->query(
186
+ "ALTER TABLE {$this->get_relationships_table_name()}
187
+ CHANGE COLUMN display_name display_name_plural varchar(255) NOT NULL DEFAULT '',
188
+ ADD COLUMN display_name_singular varchar(255) NOT NULL DEFAULT '',
189
+ ADD COLUMN role_name_parent varchar(255) NOT NULL DEFAULT '',
190
+ ADD COLUMN role_name_child varchar(255) NOT NULL DEFAULT '',
191
+ ADD COLUMN role_name_intermediary varchar(255) NOT NULL DEFAULT '',
192
+ ADD COLUMN needs_legacy_support tinyint(1) NOT NULL DEFAULT 0,
193
+ ADD COLUMN is_active tinyint(1) NOT NULL DEFAULT 0"
194
+ );
195
+ }
196
+
197
+
198
+ private function transform_extra_relationship_data() {
199
+ $relationships = $this->wpdb->get_results(
200
+ "SELECT id, extra FROM {$this->get_relationships_table_name()}"
201
+ );
202
+
203
+ foreach( $relationships as $relationship ) {
204
+ $extra_data = maybe_unserialize( $relationship->extra );
205
+
206
+ $this->wpdb->update(
207
+ $this->get_relationships_table_name(),
208
+ array(
209
+ 'role_name_parent' => 'parent',
210
+ 'role_name_child' => 'child',
211
+ 'role_name_intermediary' => 'association',
212
+ 'needs_legacy_support' => ( toolset_getarr( $extra_data, 'needs_legacy_support', 0 ) ? 1 : 0 ),
213
+ 'is_active' => ( toolset_getarr( $extra_data, 'is_active', 1 ) ? 1 : 0 ),
214
+ 'display_name_singular' => toolset_getarr( $extra_data, 'display_name_singular', '' ),
215
+ ),
216
+ array( 'id' => (int) $relationship->id ),
217
+ array( '%s', '%s', '%s', '%d', '%d', '%s' ),
218
+ '%d'
219
+ );
220
+ }
221
+ }
222
+
223
+
224
+ private function drop_relationship_extra_column() {
225
+ $this->wpdb->query(
226
+ "ALTER TABLE {$this->get_relationships_table_name()}
227
+ DROP COLUMN extra"
228
+ );
229
+ }
230
+
231
+
232
+ private function add_indexes_for_relationships_table() {
233
+ $this->wpdb->query(
234
+ "ALTER TABLE {$this->get_relationships_table_name()}
235
+ ADD INDEX is_active (is_active),
236
+ ADD INDEX needs_legacy_support (needs_legacy_support),
237
+ ADD INDEX parent_type (parent_domain, parent_types),
238
+ ADD INDEX child_type (child_domain, child_types)"
239
+ );
240
+ }
241
+
242
+
243
+ private function add_relationship_id_column_for_associations() {
244
+ $this->wpdb->query(
245
+ "ALTER TABLE {$this->get_associations_table_name()}
246
+ ADD COLUMN relationship_id bigint(20) UNSIGNED NOT NULL"
247
+ );
248
+ }
249
+
250
+
251
+ private function transform_relationship_references_for_associations() {
252
+ $relationships = $this->wpdb->get_results(
253
+ "SELECT id, slug FROM {$this->get_relationships_table_name()}"
254
+ );
255
+
256
+ foreach( $relationships as $relationship ) {
257
+ $this->wpdb->update(
258
+ $this->get_associations_table_name(),
259
+ array( 'relationship_id' => $relationship->id ),
260
+ array( 'relationship' => $relationship->slug ),
261
+ '%d',
262
+ '%s'
263
+ );
264
+ }
265
+ }
266
+
267
+
268
+ private function remove_relationship_slug_column_for_associations() {
269
+ $this->wpdb->query(
270
+ "ALTER TABLE {$this->get_associations_table_name()}
271
+ DROP COLUMN relationship"
272
+ );
273
+ }
274
+
275
+
276
+ private function add_indexes_for_associations_table() {
277
+ $this->wpdb->query(
278
+ "ALTER TABLE {$this->get_associations_table_name()}
279
+ ADD INDEX relationship_id (relationship_id),
280
+ ADD INDEX parent_id (parent_id, relationship_id),
281
+ ADD INDEX child_id (child_id, relationship_id)"
282
+ );
283
+ }
284
+ }
vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_definition.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Defines an upgrade command and determines whether it should be executed or not.
5
+ *
6
+ * @since 2.5.3
7
+ */
8
+ class Toolset_Upgrade_Command_Definition {
9
+
10
+ /** @var string */
11
+ private $command_class_name;
12
+
13
+ /** @var int */
14
+ private $upgrade_version;
15
+
16
+ /** @var Toolset_Upgrade_Command_Factory */
17
+ private $_command_factory;
18
+
19
+
20
+ /**
21
+ * Toolset_Upgrade_Command_Definition constructor.
22
+ *
23
+ * @param string $command_class_name
24
+ * @param int $upgrade_version If we have Toolset Common at this version or higher and the command hasn't run yet,
25
+ * it should be executed.
26
+ * @param Toolset_Upgrade_Command_Factory|null $command_factory_di
27
+ * @throws InvalidArgumentException On invalid input.
28
+ */
29
+ public function __construct(
30
+ $command_class_name, $upgrade_version,
31
+ Toolset_Upgrade_Command_Factory $command_factory_di = null
32
+ ) {
33
+ if(
34
+ empty( $command_class_name ) || ! is_string( $command_class_name )
35
+ || ! is_int( $upgrade_version ) || 0 > $upgrade_version
36
+ ) {
37
+ throw new InvalidArgumentException();
38
+ }
39
+
40
+ $this->command_class_name = $command_class_name;
41
+ $this->upgrade_version = $upgrade_version;
42
+ $this->_command_factory = $command_factory_di;
43
+ }
44
+
45
+
46
+ /**
47
+ * Determine whether the command should be executed.
48
+ *
49
+ * @param int $from_version Current (database) version.
50
+ * @param int $to_version Version we're upgrading to.
51
+ *
52
+ * @return bool
53
+ */
54
+ public function should_run( $from_version, $to_version ) {
55
+ return ( $from_version < $this->upgrade_version && $this->upgrade_version <= $to_version );
56
+ }
57
+
58
+
59
+ /**
60
+ * Create the command instance.
61
+ *
62
+ * @return IToolset_Upgrade_Command
63
+ */
64
+ public function get_command() {
65
+ return $this->get_command_factory()->create( $this->command_class_name );
66
+ }
67
+
68
+
69
+ /**
70
+ * @return Toolset_Upgrade_Command_Factory
71
+ */
72
+ private function get_command_factory() {
73
+ if( null === $this->_command_factory ) {
74
+ $this->_command_factory = new Toolset_Upgrade_Command_Factory();
75
+ }
76
+
77
+ return $this->_command_factory;
78
+ }
79
+
80
+ }
vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_definition_repository.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Stores upgrade command definitions.
5
+ *
6
+ * Had to be extracted from Toolset_Upgrade_Controller for testability reasons.
7
+ *
8
+ * @since 2.5.4
9
+ */
10
+ class Toolset_Upgrade_Command_Definition_Repository {
11
+
12
+ public function get_commands() {
13
+
14
+ $upgrade_commands = array(
15
+ new Toolset_Upgrade_Command_Definition(
16
+ 'Toolset_Upgrade_Command_M2M_V1_Database_Structure_Upgrade',
17
+ 0
18
+ )
19
+ );
20
+
21
+ return $upgrade_commands;
22
+ }
23
+
24
+ }
vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_factory.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Factory for the IToolset_Upgrade_Command classes.
5
+ *
6
+ * @since 2.5.3
7
+ */
8
+ class Toolset_Upgrade_Command_Factory {
9
+
10
+ /**
11
+ * @param string $command_class_name
12
+ *
13
+ * @return IToolset_Upgrade_Command
14
+ * @throws InvalidArgumentException If the class doesn't exist
15
+ * or doesn't implement the IToolset_Upgrade_Command interface.
16
+ */
17
+ public function create( $command_class_name ) {
18
+ if( ! class_exists( $command_class_name, true ) ) {
19
+ throw new InvalidArgumentException( 'Upgrade command not found.' );
20
+ }
21
+
22
+ $command_class = new $command_class_name();
23
+
24
+ if( ! $command_class instanceof IToolset_Upgrade_Command ) {
25
+ throw new InvalidArgumentException( 'Invalid upgrade command.' );
26
+ }
27
+
28
+ return $command_class;
29
+ }
30
+
31
+ }
vendor/toolset/toolset-common/inc/autoloaded/upgrade/command_interface.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Interface IToolset_Upgrade_Command
5
+ *
6
+ * Command that upgrades the database when a Toolset Common library is upgraded.
7
+ *
8
+ * WARNING: Since it's very difficult to recover from any errors that occur during the upgrade, it is extremely
9
+ * important to have the commands thoroughly covered by unit tests and well-tested.
10
+ *
11
+ * @since 2.5.3
12
+ */
13
+ interface IToolset_Upgrade_Command {
14
+
15
+ /**
16
+ * Run the command.
17
+ *
18
+ * @return Toolset_Result|Toolset_Result_Set
19
+ */
20
+ public function run();
21
+
22
+ }
vendor/toolset/toolset-common/inc/autoloaded/upgrade/controller.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Toolset Common Library upgrade mechanism.
5
+ *
6
+ * Compares a number of the library version in database with the current one. If the current version is lower,
7
+ * it executes all the commands defined in get_upgrade_commands() and updates the database.
8
+ *
9
+ * Performance cost on every server request:
10
+ * - one add_action hook
11
+ * - one autoloaded option
12
+ *
13
+ * @since 2.5.1
14
+ */
15
+ class Toolset_Upgrade_Controller {
16
+
17
+
18
+ /** Name of the option used to store version number. */
19
+ const DATABASE_VERSION_OPTION = 'toolset_database_version';
20
+
21
+
22
+ /** @var Toolset_Upgrade_Controller */
23
+ private static $instance;
24
+
25
+
26
+ /** @var bool */
27
+ private $is_initialized = false;
28
+
29
+
30
+ /** @var Toolset_Constants */
31
+ private $constants;
32
+
33
+
34
+ /** @var Toolset_Upgrade_Command_Definition_Repository|null */
35
+ private $_command_definition_repository;
36
+
37
+
38
+ public static function get_instance() {
39
+ if( null == self::$instance ) {
40
+ self::$instance = new self();
41
+ }
42
+
43
+ return self::$instance;
44
+ }
45
+
46
+
47
+ public function initialize() {
48
+ if( $this->is_initialized ) {
49
+ return;
50
+ }
51
+
52
+ // When everything is loaded and possibly hooked in the upgrade action, we can proceed.
53
+ add_action( 'toolset_common_loaded', array( $this, 'check_upgrade' ) );
54
+
55
+ $this->is_initialized = true;
56
+ }
57
+
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
+
68
+ /**
69
+ * Check if an upgrade is needed.
70
+ *
71
+ * Do not call this manually, there's no need to.
72
+ *
73
+ * @since m2m
74
+ */
75
+ public function check_upgrade() {
76
+
77
+ $database_version = $this->get_database_version();
78
+ $library_version = $this->get_library_version();
79
+ $is_upgrade_needed = ( 0 !== $library_version && $database_version < $library_version );
80
+
81
+ if( $is_upgrade_needed ) {
82
+
83
+ // Safety measure - Abort if the library isn't fully loaded.
84
+ if( false === apply_filters( 'toolset_is_toolset_common_available', false ) ) {
85
+ return;
86
+ }
87
+
88
+ // This is required by the tcl-status plugin.
89
+ if( apply_filters( 'toolset_disable_upgrade_routine', false ) ) {
90
+ return;
91
+ }
92
+
93
+ $this->do_upgrade( $database_version, $library_version );
94
+ }
95
+ }
96
+
97
+
98
+ /**
99
+ * Get current version number.
100
+ *
101
+ * @return int
102
+ * @since m2m
103
+ */
104
+ private function get_library_version() {
105
+ $version = (
106
+ $this->constants->defined( 'TOOLSET_COMMON_VERSION_NUMBER' )
107
+ ? (int) $this->constants->constant( 'TOOLSET_COMMON_VERSION_NUMBER' )
108
+ : 0
109
+ );
110
+
111
+ return $version;
112
+ }
113
+
114
+
115
+ /**
116
+ * Get number of the version stored in the database.
117
+ *
118
+ * @return int
119
+ * @since m2m
120
+ */
121
+ private function get_database_version() {
122
+ $version = (int) get_option( self::DATABASE_VERSION_OPTION, 0 );
123
+
124
+ return $version;
125
+ }
126
+
127
+
128
+ /**
129
+ * Update the version number stored in the database.
130
+ *
131
+ * @param int $version_number
132
+ * @since m2m
133
+ */
134
+ private function update_database_version( $version_number ) {
135
+ if( is_numeric( $version_number ) ) {
136
+ update_option( self::DATABASE_VERSION_OPTION, (int) $version_number, true );
137
+ }
138
+ }
139
+
140
+
141
+ /**
142
+ * Perform the actual upgrade.
143
+ *
144
+ * @param int $from_version
145
+ * @param int $to_version
146
+ */
147
+ private function do_upgrade( $from_version, $to_version ) {
148
+
149
+ $this->update_database_version( $to_version );
150
+
151
+ $command_definitions = $this->get_upgrade_commands();
152
+
153
+ foreach( $command_definitions as $command_definition ) {
154
+ if( $command_definition->should_run( $from_version, $to_version ) ) {
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
+
168
+
169
+ /**
170
+ * Get the upgrade commands to consider.
171
+ *
172
+ * The commands will be executed in the order in which they are returned.
173
+ *
174
+ * @return Toolset_Upgrade_Command_Definition[]
175
+ * @since 2.5.4
176
+ */
177
+ private function get_upgrade_commands() {
178
+ if( null === $this->_command_definition_repository ) {
179
+ $this->_command_definition_repository = new Toolset_Upgrade_Command_Definition_Repository();
180
+ }
181
+
182
+ return $this->_command_definition_repository->get_commands();
183
+ }
184
+
185
+
186
+ }
vendor/toolset/toolset-common/inc/controller/constants.php CHANGED
@@ -5,7 +5,9 @@
5
  *
6
  * Motivation: http://www.theaveragedev.com/mocking-constants-in-tests/
7
  *
8
- * @since m2m
 
 
9
  */
10
  class Toolset_Constants {
11
 
5
  *
6
  * Motivation: http://www.theaveragedev.com/mocking-constants-in-tests/
7
  *
8
+ * Note: Use this *only* if you need it in unit tests!
9
+ *
10
+ * @since 2.5.1
11
  */
12
  class Toolset_Constants {
13
 
vendor/toolset/toolset-common/inc/m2m/association.php CHANGED
@@ -41,7 +41,7 @@ class Toolset_Association extends Toolset_Association_Base {
41
 
42
  parent::__construct( $trid, $relationship_definition );
43
 
44
- foreach( Toolset_Relationship_Role::parent_child() as $element_role ) {
45
  $element_source = toolset_getarr( $element_sources, $element_role, null );
46
 
47
  if( is_array( $element_source ) && 1 === count( $element_source ) ) {
41
 
42
  parent::__construct( $trid, $relationship_definition );
43
 
44
+ foreach( Toolset_Relationship_Role::parent_child_role_names() as $element_role ) {
45
  $element_source = toolset_getarr( $element_sources, $element_role, null );
46
 
47
  if( is_array( $element_source ) && 1 === count( $element_source ) ) {
vendor/toolset/toolset-common/inc/m2m/association_base.php CHANGED
@@ -96,7 +96,7 @@ abstract class Toolset_Association_Base implements IToolset_Association {
96
  * todo get rid of this, move to the enum
97
  */
98
  public static function validate_element_role( $element_role ) {
99
- if( ! in_array( $element_role, Toolset_Relationship_Role::parent_child() ) ) {
100
  throw new InvalidArgumentException( 'Invalid element key.' );
101
  }
102
  }
96
  * todo get rid of this, move to the enum
97
  */
98
  public static function validate_element_role( $element_role ) {
99
+ if( ! in_array( $element_role, Toolset_Relationship_Role::parent_child_role_names() ) ) {
100
  throw new InvalidArgumentException( 'Invalid element key.' );
101
  }
102
  }
vendor/toolset/toolset-common/inc/m2m/association_query.php CHANGED
@@ -151,9 +151,20 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
151
  //
152
  //
153
  if( $this->has_query_var( self::QUERY_RELATIONSHIP_SLUG ) ) {
 
 
 
 
 
 
 
 
 
 
 
154
  $where_clauses[] = $wpdb->prepare(
155
- "association.relationship LIKE %s",
156
- $this->get_query_var( self::QUERY_RELATIONSHIP_SLUG )
157
  );
158
  }
159
 
@@ -322,7 +333,7 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
322
  $sep = self::GROUP_CONCAT_SEPARATOR;
323
  $select_fields = array(
324
  'trid' => "$groupby_table.trid",
325
- 'relationship' => "GROUP_CONCAT($groupby_table.relationship SEPARATOR '$sep')",
326
  'association_id' => "GROUP_CONCAT($groupby_table.id SEPARATOR '$sep')",
327
  'lang' => "GROUP_CONCAT($groupby_table.lang SEPARATOR '$sep')",
328
  'parent_id' => "GROUP_CONCAT($groupby_table.parent_id SEPARATOR '$sep')",
@@ -335,7 +346,7 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
335
  // The simplest case, there's no need to deal with translations at all.
336
  $select_fields = array(
337
  'trid' => 'association.trid',
338
- 'relationship' => 'association.relationship',
339
  'association_id' => 'association.id',
340
  'parent_id' => 'association.parent_id',
341
  'child_id' => 'association.child_id',
@@ -363,7 +374,7 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
363
  $sql_join = '';
364
  if( $join_relationships ) {
365
  $sql_join .= ' JOIN ' . Toolset_Relationship_Table_Name::relationships() . ' AS relationship
366
- ON ( association.relationship LIKE relationship.slug ) ';
367
  }
368
  if( ! empty( $join_wp_posts_on ) ) {
369
  $sql_join .= " JOIN {$wpdb->posts} ON ( association.{$join_wp_posts_on} = {$wpdb->posts}.ID ) ";
@@ -542,7 +553,7 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
542
  */
543
  private function postprocess_element_ids( $rows, $role ) {
544
 
545
- $column_name = Toolset_Relationship_Database_Operations::role_to_column( $role );
546
 
547
  if( Toolset_Relationship_Multilingual_Mode::is_on() ) {
548
  $results = array();
@@ -574,7 +585,7 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
574
  */
575
  private function postprocess_elements( $rows, $role ) {
576
 
577
- $column_name = Toolset_Relationship_Database_Operations::role_to_column( $role );
578
 
579
  $results = array();
580
  foreach( $rows as $row ) {
@@ -641,8 +652,8 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
641
  }
642
 
643
  // All relationship slugs should be the same, we just grab one of them.
644
- $relationship_slugs = $this->get_field_by_language( $row, 'relationship', $language_codes, true );
645
- $relationship_slug = array_pop( $relationship_slugs );
646
 
647
  } else {
648
 
@@ -650,7 +661,7 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
650
  $parent_source = (int) toolset_getarr( $row, 'parent_id' );
651
  $child_source = (int) toolset_getarr( $row, 'child_id' );
652
  $intermediary_source = (int) toolset_getarr( $row, 'intermediary_id' );
653
- $relationship_slug = toolset_getarr( $row, 'relationship' );
654
 
655
  }
656
 
@@ -660,7 +671,7 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
660
  // Add the association to results.
661
  try {
662
  $association = $association_repository->instantiate(
663
- $relationship_slug,
664
  $association_trid,
665
  array(
666
  Toolset_Relationship_Role::PARENT => $parent_source,
@@ -864,8 +875,8 @@ class Toolset_Association_Query extends Toolset_Relationship_Query_Base {
864
  * @return array Main row, updated.
865
  */
866
  private function merge_rows( $main, $completion ) {
867
- foreach( Toolset_Relationship_Role::all() as $role ) {
868
- $column_name = Toolset_Relationship_Database_Operations::role_to_column( $role );
869
  $main_value = (int) toolset_getarr( $main, $column_name );
870
  if( 0 === $main_value ) {
871
  $main[ $column_name ] = (int) toolset_getarr( $completion, $column_name );
151
  //
152
  //
153
  if( $this->has_query_var( self::QUERY_RELATIONSHIP_SLUG ) ) {
154
+ $relationship_slug = $this->get_query_var( self::QUERY_RELATIONSHIP_SLUG );
155
+ $relationship = Toolset_Relationship_Utils::get_relationship_definition( $relationship_slug );
156
+
157
+ if( null === $relationship ) {
158
+ // This will cause the query to return no results, as there can be no associations
159
+ // for a non-existent relationship.
160
+ $relationship_id = 0;
161
+ } else {
162
+ $relationship_id = $relationship->get_row_id();
163
+ }
164
+
165
  $where_clauses[] = $wpdb->prepare(
166
+ "association.relationship_id = %d",
167
+ $relationship_id
168
  );
169
  }
170
 
333
  $sep = self::GROUP_CONCAT_SEPARATOR;
334
  $select_fields = array(
335
  'trid' => "$groupby_table.trid",
336
+ 'relationship_id' => "GROUP_CONCAT($groupby_table.relationship_id SEPARATOR '$sep')",
337
  'association_id' => "GROUP_CONCAT($groupby_table.id SEPARATOR '$sep')",
338
  'lang' => "GROUP_CONCAT($groupby_table.lang SEPARATOR '$sep')",
339
  'parent_id' => "GROUP_CONCAT($groupby_table.parent_id SEPARATOR '$sep')",
346
  // The simplest case, there's no need to deal with translations at all.
347
  $select_fields = array(
348
  'trid' => 'association.trid',
349
+ 'relationship_id' => 'association.relationship_id',
350
  'association_id' => 'association.id',
351
  'parent_id' => 'association.parent_id',
352
  'child_id' => 'association.child_id',
374
  $sql_join = '';
375
  if( $join_relationships ) {
376
  $sql_join .= ' JOIN ' . Toolset_Relationship_Table_Name::relationships() . ' AS relationship
377
+ ON ( association.relationship_id LIKE relationship.id ) ';
378
  }
379
  if( ! empty( $join_wp_posts_on ) ) {
380
  $sql_join .= " JOIN {$wpdb->posts} ON ( association.{$join_wp_posts_on} = {$wpdb->posts}.ID ) ";
553
  */
554
  private function postprocess_element_ids( $rows, $role ) {
555
 
556
+ $column_name = Toolset_Relationship_Database_Operations::get_instance()->role_to_column( $role );
557
 
558
  if( Toolset_Relationship_Multilingual_Mode::is_on() ) {
559
  $results = array();
585
  */
586
  private function postprocess_elements( $rows, $role ) {
587
 
588
+ $column_name = Toolset_Relationship_Database_Operations::get_instance()->role_to_column( $role );
589
 
590
  $results = array();
591
  foreach( $rows as $row ) {
652
  }
653
 
654
  // All relationship slugs should be the same, we just grab one of them.
655
+ $relationship_ids = $this->get_field_by_language( $row, 'relationship_id', $language_codes, true );
656
+ $relationship_id = (int) array_pop( $relationship_ids );
657
 
658
  } else {
659
 
661
  $parent_source = (int) toolset_getarr( $row, 'parent_id' );
662
  $child_source = (int) toolset_getarr( $row, 'child_id' );
663
  $intermediary_source = (int) toolset_getarr( $row, 'intermediary_id' );
664
+ $relationship_id = (int) toolset_getarr( $row, 'relationship_id' );
665
 
666
  }
667
 
671
  // Add the association to results.
672
  try {
673
  $association = $association_repository->instantiate(
674
+ $relationship_id,
675
  $association_trid,
676
  array(
677
  Toolset_Relationship_Role::PARENT => $parent_source,
875
  * @return array Main row, updated.
876
  */
877
  private function merge_rows( $main, $completion ) {
878
+ foreach( Toolset_Relationship_Role::all_role_names() as $role ) {
879
+ $column_name = Toolset_Relationship_Database_Operations::get_instance()->role_to_column( $role );
880
  $main_value = (int) toolset_getarr( $main, $column_name );
881
  if( 0 === $main_value ) {
882
  $main[ $column_name ] = (int) toolset_getarr( $completion, $column_name );
vendor/toolset/toolset-common/inc/m2m/association_repository.php CHANGED
@@ -137,7 +137,7 @@ class Toolset_Association_Repository {
137
  /**
138
  * Create an association instance from provided values.
139
  *
140
- * @param string|Toolset_Relationship_Definition $relationship_definition_source
141
  * @param int|string $association_trid
142
  * @param array $element_sources Elements indexed by role names - either Toolset_Element instances or ids (can be mixed).
143
  *
137
  /**
138
  * Create an association instance from provided values.
139
  *
140
+ * @param int|string|IToolset_Relationship_Definition $relationship_definition_source
141
  * @param int|string $association_trid
142
  * @param array $element_sources Elements indexed by role names - either Toolset_Element instances or ids (can be mixed).
143
  *
vendor/toolset/toolset-common/inc/m2m/association_translation_set.php CHANGED
@@ -39,7 +39,7 @@ class Toolset_Association_Translation_Set extends Toolset_Association_Base {
39
 
40
  parent::__construct( $trid, $relationship_definition );
41
 
42
- foreach( Toolset_Relationship_Role::all() as $role ) {
43
  $this->element_sources[ $role ] = toolset_getarr( $element_sources, $role, null );
44
  }
45
  }
39
 
40
  parent::__construct( $trid, $relationship_definition );
41
 
42
+ foreach( Toolset_Relationship_Role::all_role_names() as $role ) {
43
  $this->element_sources[ $role ] = toolset_getarr( $element_sources, $role, null );
44
  }
45
  }
vendor/toolset/toolset-common/inc/m2m/autoload_classmap.php CHANGED
@@ -2,36 +2,65 @@
2
  // Generated by ZF2's ./bin/classmap_generator.php
3
  return array(
4
  'IToolset_Association' => dirname( __FILE__ ) . '/i_association.php',
 
5
  'IToolset_Relationship_Definition' => dirname( __FILE__ ) . '/i_definition.php',
6
  'IToolset_Relationship_Origin' => dirname( __FILE__ ) . '/origin/interface.php',
7
- 'Toolset_Association' => dirname( __FILE__ ) . '/association.php',
 
 
8
  'Toolset_Association_Base' => dirname( __FILE__ ) . '/association_base.php',
 
9
  'Toolset_Association_Query' => dirname( __FILE__ ) . '/association_query.php',
10
  'Toolset_Association_Repository' => dirname( __FILE__ ) . '/association_repository.php',
11
  'Toolset_Association_Transitional' => dirname( __FILE__ ) . '/association_transitional.php',
12
  'Toolset_Association_Translation_Set' => dirname( __FILE__ ) . '/association_translation_set.php',
 
 
13
  'Toolset_Relationship_Cardinality' => dirname( __FILE__ ) . '/cardinality.php',
14
  'Toolset_Relationship_Controller' => dirname( __FILE__ ) . '/controller.php',
15
- 'Toolset_Relationship_Database_Operations' => dirname( __FILE__ ) . '/database_operations.php',
16
- 'Toolset_Relationship_Definition' => dirname( __FILE__ ) . '/definition.php',
17
- 'Toolset_Relationship_Definition_Factory' => dirname( __FILE__ ) . '/definition_factory.php',
18
- 'Toolset_Relationship_Definition_Repository' => dirname( __FILE__ ) . '/definition_repository.php',
19
- 'Toolset_Relationship_Driver' => dirname( __FILE__ ) . '/driver.php',
 
 
 
20
  'Toolset_Relationship_Driver_Base' => dirname( __FILE__ ) . '/driver_base.php',
 
21
  'Toolset_Relationship_Element_Type' => dirname( __FILE__ ) . '/element_type.php',
22
- 'Toolset_Relationship_Migration' => dirname( __FILE__ ) . '/migration.php',
23
  'Toolset_Relationship_Migration_Associations' => dirname( __FILE__ ) . '/migration_associations.php',
 
24
  'Toolset_Relationship_Multilingual_Mode' => dirname( __FILE__ ) . '/multilingual_mode.php',
25
  'Toolset_Relationship_Origin_Post_Reference_Field' => dirname( __FILE__ ) . '/origin/post_reference_field.php',
26
  'Toolset_Relationship_Origin_Repeatable_Group' => dirname( __FILE__ ) . '/origin/repeatable_group.php',
27
  'Toolset_Relationship_Origin_Wizard' => dirname( __FILE__ ) . '/origin/wizard.php',
28
- 'Toolset_Relationship_Query' => dirname( __FILE__ ) . '/relationship_query.php',
29
  'Toolset_Relationship_Query_Base' => dirname( __FILE__ ) . '/query_base.php',
30
  'Toolset_Relationship_Query_Cache' => dirname( __FILE__ ) . '/query_cache.php',
31
- 'Toolset_Relationship_Role' => dirname( __FILE__ ) . '/role.php',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  'Toolset_Relationship_Scope' => dirname( __FILE__ ) . '/scope.php',
33
  'Toolset_Relationship_Slug_Validator' => dirname( __FILE__ ) . '/slug_validator.php',
34
- 'Toolset_Relationship_Table_Name' => dirname( __FILE__ ) . '/table_name.php',
35
  'Toolset_Relationship_Utils' => dirname( __FILE__ ) . '/utils.php',
36
  'Toolset_Relationship_WPML_Interoperability' => dirname( __FILE__ ) . '/wpml_interoperability.php',
37
  );
2
  // Generated by ZF2's ./bin/classmap_generator.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_Definition' => dirname( __FILE__ ) . '/i_definition.php',
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',
11
  'Toolset_Association_Base' => dirname( __FILE__ ) . '/association_base.php',
12
+ 'Toolset_Association' => dirname( __FILE__ ) . '/association.php',
13
  'Toolset_Association_Query' => dirname( __FILE__ ) . '/association_query.php',
14
  'Toolset_Association_Repository' => dirname( __FILE__ ) . '/association_repository.php',
15
  'Toolset_Association_Transitional' => dirname( __FILE__ ) . '/association_transitional.php',
16
  'Toolset_Association_Translation_Set' => dirname( __FILE__ ) . '/association_translation_set.php',
17
+ 'Toolset_Potential_Association_Query_Factory' => dirname( __FILE__ ) . '/potential_association/query_factory.php',
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',
24
+ 'Toolset_Relationship_Definition_Factory' => dirname( __FILE__ ) . '/definition/factory.php',
25
+ 'Toolset_Relationship_Definition_Persistence' => dirname( __FILE__ ) . '/definition/persistence.php',
26
+ 'Toolset_Relationship_Definition_Repository' => dirname( __FILE__ ) . '/definition/repository.php',
27
+ 'Toolset_Relationship_Definition_Translator' => dirname( __FILE__ ) . '/definition/translator.php',
28
+ 'Toolset_Relationship_Distinct_Post_Query' => dirname( __FILE__ ) . '/potential_association/distinct_post_query.php',
29
  'Toolset_Relationship_Driver_Base' => dirname( __FILE__ ) . '/driver_base.php',
30
+ 'Toolset_Relationship_Driver' => dirname( __FILE__ ) . '/driver.php',
31
  'Toolset_Relationship_Element_Type' => dirname( __FILE__ ) . '/element_type.php',
 
32
  'Toolset_Relationship_Migration_Associations' => dirname( __FILE__ ) . '/migration_associations.php',
33
+ 'Toolset_Relationship_Migration' => dirname( __FILE__ ) . '/migration.php',
34
  'Toolset_Relationship_Multilingual_Mode' => dirname( __FILE__ ) . '/multilingual_mode.php',
35
  'Toolset_Relationship_Origin_Post_Reference_Field' => dirname( __FILE__ ) . '/origin/post_reference_field.php',
36
  'Toolset_Relationship_Origin_Repeatable_Group' => dirname( __FILE__ ) . '/origin/repeatable_group.php',
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',
47
+ 'Toolset_Relationship_Query_Condition_Is_Legacy' => dirname( __FILE__ ) . '/relationship_query/condition/is_legacy.php',
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',
54
+ 'Toolset_Relationship_Query_Sql_Expression_Builder' => dirname( __FILE__ ) . '/relationship_query/sql_expression_builder.php',
55
+ 'Toolset_Relationship_Query_V2' => dirname( __FILE__ ) . '/relationship_query/relationship_query_v2.php',
56
+ 'Toolset_Relationship_Role_Abstract' => dirname( __FILE__ ) . '/relationship_role/abstract.php',
57
+ 'Toolset_Relationship_Role_Child' => dirname( __FILE__ ) . '/relationship_role/child.php',
58
+ 'Toolset_Relationship_Role' => dirname( __FILE__ ) . '/relationship_role/role.php',
59
+ 'Toolset_Relationship_Role_Intermediary' => dirname( __FILE__ ) . '/relationship_role/intermediary.php',
60
+ 'Toolset_Relationship_Role_Parent' => dirname( __FILE__ ) . '/relationship_role/parent.php',
61
  'Toolset_Relationship_Scope' => dirname( __FILE__ ) . '/scope.php',
62
  'Toolset_Relationship_Slug_Validator' => dirname( __FILE__ ) . '/slug_validator.php',
63
+ 'Toolset_Relationship_Table_Name' => dirname( __FILE__ ) . '/database/table_name.php',
64
  'Toolset_Relationship_Utils' => dirname( __FILE__ ) . '/utils.php',
65
  'Toolset_Relationship_WPML_Interoperability' => dirname( __FILE__ ) . '/wpml_interoperability.php',
66
  );
vendor/toolset/toolset-common/inc/m2m/controller.php CHANGED
@@ -162,8 +162,6 @@ class Toolset_Relationship_Controller {
162
  */
163
  private function add_hooks() {
164
 
165
- add_filter( 'toolset_is_m2m_ready', '__return_true' );
166
-
167
  /**
168
  * toolset_is_m2m_enabled
169
  *
162
  */
163
  private function add_hooks() {
164
 
 
 
165
  /**
166
  * toolset_is_m2m_enabled
167
  *
vendor/toolset/toolset-common/inc/m2m/{database_operations.php → database/operations.php} RENAMED
@@ -23,11 +23,26 @@ class Toolset_Relationship_Database_Operations {
23
  const MAXIMUM_RELATIONSHIP_SLUG_LENGTH = 255;
24
 
25
 
 
 
 
 
 
 
 
 
 
26
  /** @var wpdb */
27
  private $wpdb;
28
 
29
 
30
- public function __construct( wpdb $wpdb_di = null ) {
 
 
 
 
 
 
31
 
32
  if( null === $wpdb_di ) {
33
  global $wpdb;
@@ -35,10 +50,26 @@ class Toolset_Relationship_Database_Operations {
35
  } else {
36
  $this->wpdb = $wpdb_di;
37
  }
 
38
 
39
  }
40
 
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  /**
43
  * Create new association and persist it.
44
  *
@@ -83,26 +114,32 @@ class Toolset_Relationship_Database_Operations {
83
  }
84
 
85
 
86
- private static $role_to_column_map = array(
87
- Toolset_Relationship_Role::PARENT => 'parent_id',
88
- Toolset_Relationship_Role::CHILD => 'child_id',
89
- Toolset_Relationship_Role::INTERMEDIARY => 'intermediary_id',
90
- );
 
91
 
92
 
93
  /**
94
  * For a given role name, return the corresponding column in the associations table.
95
  *
96
- * @param string $role
 
 
97
  * @return string
98
  * @since m2m
99
  */
100
- public static function role_to_column( $role ) {
101
- if ( ! array_key_exists( $role, self::$role_to_column_map ) ) {
102
- throw new InvalidArgumentException();
 
 
 
103
  }
104
 
105
- return self::$role_to_column_map[ $role ];
106
  }
107
 
108
 
@@ -116,11 +153,9 @@ class Toolset_Relationship_Database_Operations {
116
  * TODO is it possible to reliably detect dbDelta failure?
117
  */
118
  public function do_native_dbdelta() {
119
-
120
  $this->create_associations_table();
121
-
122
  $this->create_relationship_table();
123
-
124
  return true;
125
  }
126
 
@@ -133,11 +168,8 @@ class Toolset_Relationship_Database_Operations {
133
  * @return array dbDelta return value.
134
  */
135
  private static function dbdelta( $query ) {
136
-
137
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
138
-
139
  return dbDelta( $query );
140
-
141
  }
142
 
143
 
@@ -152,14 +184,12 @@ class Toolset_Relationship_Database_Operations {
152
  public function table_exists( $table_name ) {
153
  global $wpdb;
154
  $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name );
155
-
156
  return ( $wpdb->get_var( $query ) == $table_name );
157
  }
158
 
159
 
160
- private static function get_charset_collate() {
161
  global $wpdb;
162
-
163
  return $wpdb->get_charset_collate();
164
  }
165
 
@@ -182,19 +212,19 @@ class Toolset_Relationship_Database_Operations {
182
  // Note that dbDelta is very sensitive about details, almost nothing here is arbitrary.
183
  $query = "CREATE TABLE {$association_table_name} (
184
  id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
185
- relationship varchar(" . self::MAXIMUM_RELATIONSHIP_SLUG_LENGTH . ") NOT NULL DEFAULT '',
186
  parent_id bigint(20) UNSIGNED NOT NULL,
187
  child_id bigint(20) UNSIGNED NOT NULL,
188
  intermediary_id bigint(20) UNSIGNED NOT NULL,
189
  trid bigint(20) UNSIGNED NOT NULL,
190
  lang varchar(7) NOT NULL DEFAULT '',
191
  translation_type enum('original','translation','none') NOT NULL DEFAULT 'none',
192
- PRIMARY KEY id (id)
193
- ) " . self::get_charset_collate() . ";";
 
 
 
194
 
195
- // fixme: consider adding keys, but beware max length
196
- // KEY parent (parent_id, relationship),
197
- // KEY child (child_id, relationship)
198
  self::dbdelta( $query );
199
  }
200
 
@@ -208,7 +238,7 @@ class Toolset_Relationship_Database_Operations {
208
  */
209
  private function create_relationship_table() {
210
 
211
- $table_name = Toolset_Relationship_Table_Name::relationships();
212
 
213
  if ( $this->table_exists( $table_name ) ) {
214
  return;
@@ -218,12 +248,13 @@ class Toolset_Relationship_Database_Operations {
218
  $query = "CREATE TABLE {$table_name} (
219
  id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
220
  slug varchar(" . self::MAXIMUM_RELATIONSHIP_SLUG_LENGTH . ") NOT NULL DEFAULT '',
221
- display_name varchar(255) NOT NULL DEFAULT '',
 
222
  driver varchar(50) NOT NULL DEFAULT '',
223
  parent_domain varchar(20) NOT NULL DEFAULT '',
224
- parent_types text NOT NULL DEFAULT '',
225
  child_domain varchar(20) NOT NULL DEFAULT '',
226
- child_types text NOT NULL DEFAULT '',
227
  intermediary_type varchar(20) NOT NULL DEFAULT '',
228
  ownership enum('parent', 'child', 'none') NOT NULL DEFAULT 'none',
229
  cardinality_parent_max int(10) NOT NULL DEFAULT -1,
@@ -233,16 +264,44 @@ class Toolset_Relationship_Database_Operations {
233
  is_distinct tinyint(1) NOT NULL DEFAULT 0,
234
  scope longtext NOT NULL DEFAULT '',
235
  origin varchar(50) NOT NULL DEFAULT '',
236
- extra longtext NOT NULL DEFAULT '',
 
 
 
 
237
  PRIMARY KEY id (id),
238
- KEY slug (slug)
239
- ) " . self::get_charset_collate() . ";";
 
 
 
 
240
 
241
  self::dbdelta( $query );
242
 
243
  }
244
 
245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  /**
247
  * Get the next unused value for trid (translation ID, grouping different translations of
248
  * one association together).
@@ -299,16 +358,16 @@ class Toolset_Relationship_Database_Operations {
299
  $is_success = ( false !== $rows_updated );
300
 
301
  $message = (
302
- $is_success
303
- ? sprintf(
304
- __( 'The association table has been updated with the new relationship slug "%s". %d rows have been updated.', 'wpcf' ),
305
- $new_slug,
306
- $rows_updated
307
- )
308
- : sprintf(
309
- __( 'There has been an error when updating the assocation table with the new relationship slug: %s', 'wpcf' ),
310
- $wpdb->last_error
311
- )
312
  );
313
 
314
  return new Toolset_Result( $is_success, $message );
@@ -324,7 +383,7 @@ class Toolset_Relationship_Database_Operations {
324
  */
325
  public function delete_associations_by_relationship( $relationship_slug ) {
326
 
327
- $associations_table = Toolset_Relationship_Table_Name::associations();
328
 
329
  $result = $this->wpdb->delete(
330
  $associations_table,
@@ -346,9 +405,101 @@ class Toolset_Relationship_Database_Operations {
346
  }
347
 
348
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  public function load_all_relationships() {
350
- $table_name = Toolset_Relationship_Table_Name::relationships();
351
- $rows = toolset_ensarr( $this->wpdb->get_results( "SELECT * FROM $table_name" ) );
 
 
 
 
 
 
 
 
 
 
352
  return $rows;
353
  }
354
 
23
  const MAXIMUM_RELATIONSHIP_SLUG_LENGTH = 255;
24
 
25
 
26
+ /**
27
+ * Delimiter used in GROUP_CONCAT MySQL function.
28
+ */
29
+ const GROUP_CONCAT_DELIMITER = ',';
30
+
31
+
32
+ private static $instance;
33
+
34
+
35
  /** @var wpdb */
36
  private $wpdb;
37
 
38
 
39
+ private $table_name;
40
+
41
+
42
+ public function __construct(
43
+ wpdb $wpdb_di = null,
44
+ Toolset_Relationship_Table_Name $table_name_di = null
45
+ ) {
46
 
47
  if( null === $wpdb_di ) {
48
  global $wpdb;
50
  } else {
51
  $this->wpdb = $wpdb_di;
52
  }
53
+ $this->table_name = ( null === $table_name_di ? new Toolset_Relationship_Table_Name() : $table_name_di );
54
 
55
  }
56
 
57
 
58
+ /**
59
+ * Careful. This class is NOT meant to be a singleton. This is a temporary solution for easier transition
60
+ * from using static methods.
61
+ *
62
+ * @return Toolset_Relationship_Database_Operations
63
+ */
64
+ public static function get_instance() {
65
+ if( null === self::$instance ) {
66
+ self::$instance = new self();
67
+ }
68
+
69
+ return self::$instance;
70
+ }
71
+
72
+
73
  /**
74
  * Create new association and persist it.
75
  *
114
  }
115
 
116
 
117
+ // The _id columns in the associations table
118
+ const COLUMN_ID = '_id';
119
+
120
+ // Columns in the relationships table
121
+ const COLUMN_DOMAIN = '_domain';
122
+ const COLUMN_TYPES = '_types';
123
 
124
 
125
  /**
126
  * For a given role name, return the corresponding column in the associations table.
127
  *
128
+ * @param string|IToolset_Relationship_Role $role
129
+ * @param string $column
130
+ *
131
  * @return string
132
  * @since m2m
133
  */
134
+ public function role_to_column( $role, $column = self::COLUMN_ID ) {
135
+
136
+ if( $role instanceof IToolset_Relationship_Role ) {
137
+ $role_name = $role->get_name();
138
+ } else {
139
+ $role_name = $role;
140
  }
141
 
142
+ return $role_name . $column;
143
  }
144
 
145
 
153
  * TODO is it possible to reliably detect dbDelta failure?
154
  */
155
  public function do_native_dbdelta() {
 
156
  $this->create_associations_table();
 
157
  $this->create_relationship_table();
158
+ $this->create_type_set_table();
159
  return true;
160
  }
161
 
168
  * @return array dbDelta return value.
169
  */
170
  private static function dbdelta( $query ) {
 
171
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
 
172
  return dbDelta( $query );
 
173
  }
174
 
175
 
184
  public function table_exists( $table_name ) {
185
  global $wpdb;
186
  $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name );
 
187
  return ( $wpdb->get_var( $query ) == $table_name );
188
  }
189
 
190
 
191
+ private function get_charset_collate() {
192
  global $wpdb;
 
193
  return $wpdb->get_charset_collate();
194
  }
195
 
212
  // Note that dbDelta is very sensitive about details, almost nothing here is arbitrary.
213
  $query = "CREATE TABLE {$association_table_name} (
214
  id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
215
+ relationship_id bigint(20) UNSIGNED NOT NULL,
216
  parent_id bigint(20) UNSIGNED NOT NULL,
217
  child_id bigint(20) UNSIGNED NOT NULL,
218
  intermediary_id bigint(20) UNSIGNED NOT NULL,
219
  trid bigint(20) UNSIGNED NOT NULL,
220
  lang varchar(7) NOT NULL DEFAULT '',
221
  translation_type enum('original','translation','none') NOT NULL DEFAULT 'none',
222
+ PRIMARY KEY id (id),
223
+ KEY relationship_id (relationship_id),
224
+ KEY parent_id (parent_id, relationship_id),
225
+ KEY child_id (child_id, relationship_id)
226
+ ) " . $this->get_charset_collate() . ";";
227
 
 
 
 
228
  self::dbdelta( $query );
229
  }
230
 
238
  */
239
  private function create_relationship_table() {
240
 
241
+ $table_name = $this->table_name->relationship_table();
242
 
243
  if ( $this->table_exists( $table_name ) ) {
244
  return;
248
  $query = "CREATE TABLE {$table_name} (
249
  id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
250
  slug varchar(" . self::MAXIMUM_RELATIONSHIP_SLUG_LENGTH . ") NOT NULL DEFAULT '',
251
+ display_name_plural varchar(255) NOT NULL DEFAULT '',
252
+ display_name_singular varchar(255) NOT NULL DEFAULT '',
253
  driver varchar(50) NOT NULL DEFAULT '',
254
  parent_domain varchar(20) NOT NULL DEFAULT '',
255
+ parent_types bigint(20) UNSIGNED NOT NULL DEFAULT 0,
256
  child_domain varchar(20) NOT NULL DEFAULT '',
257
+ child_types bigint(20) UNSIGNED NOT NULL DEFAULT 0,
258
  intermediary_type varchar(20) NOT NULL DEFAULT '',
259
  ownership enum('parent', 'child', 'none') NOT NULL DEFAULT 'none',
260
  cardinality_parent_max int(10) NOT NULL DEFAULT -1,
264
  is_distinct tinyint(1) NOT NULL DEFAULT 0,
265
  scope longtext NOT NULL DEFAULT '',
266
  origin varchar(50) NOT NULL DEFAULT '',
267
+ role_name_parent varchar(255) NOT NULL DEFAULT '',
268
+ role_name_child varchar(255) NOT NULL DEFAULT '',
269
+ role_name_intermediary varchar(255) NOT NULL DEFAULT '',
270
+ needs_legacy_support tinyint(1) NOT NULL DEFAULT 0,
271
+ is_active tinyint(1) NOT NULL DEFAULT 0,
272
  PRIMARY KEY id (id),
273
+ KEY slug (slug),
274
+ KEY is_active (is_active),
275
+ KEY needs_legacy_support (needs_legacy_support),
276
+ KEY parent_type (parent_domain, parent_types),
277
+ KEY child_type (child_domain, child_types)
278
+ ) " . $this->get_charset_collate() . ";";
279
 
280
  self::dbdelta( $query );
281
 
282
  }
283
 
284
 
285
+ private function create_type_set_table() {
286
+ $table_name = $this->table_name->type_set_table();
287
+ if ( $this->table_exists( $table_name ) ) {
288
+ return;
289
+ }
290
+
291
+ // Note that dbDelta is very sensitive about details, almost nothing here is arbitrary.
292
+ $query = "CREATE TABLE {$table_name} (
293
+ id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
294
+ set_id bigint(20) UNSIGNED NOT NULL DEFAULT 0,
295
+ type varchar(20) NOT NULL DEFAULT '',
296
+ PRIMARY KEY id (id),
297
+ KEY set_id (set_id),
298
+ KEY type (type)
299
+ ) " . $this->get_charset_collate() . ";";
300
+
301
+ self::dbdelta( $query );
302
+ }
303
+
304
+
305
  /**
306
  * Get the next unused value for trid (translation ID, grouping different translations of
307
  * one association together).
358
  $is_success = ( false !== $rows_updated );
359
 
360
  $message = (
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
+ $new_slug,
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
 
373
  return new Toolset_Result( $is_success, $message );
383
  */
384
  public function delete_associations_by_relationship( $relationship_slug ) {
385
 
386
+ $associations_table = $this->table_name->association_table();
387
 
388
  $result = $this->wpdb->delete(
389
  $associations_table,
405
  }
406
 
407
 
408
+ /**
409
+ * Build the part of the SELECT clause that is required for proper loading of a relationship definition.
410
+ *
411
+ * @param string $relationships_table_alias
412
+ * @param string $parent_types_table_alias
413
+ * @param string $child_types_table_alias
414
+ *
415
+ * @return string
416
+ * @since 2.5.4
417
+ */
418
+ public function get_standard_relationships_select_clause(
419
+ $relationships_table_alias = 'relationships',
420
+ $parent_types_table_alias = 'parent_types_table',
421
+ $child_types_table_alias = 'child_types_table'
422
+ ) {
423
+ return "
424
+ $relationships_table_alias.id AS id,
425
+ $relationships_table_alias.slug AS slug,
426
+ $relationships_table_alias.display_name_plural AS display_name_plural,
427
+ $relationships_table_alias.display_name_singular AS display_name_singular,
428
+ $relationships_table_alias.driver AS driver,
429
+ $relationships_table_alias.parent_domain AS parent_domain,
430
+ $relationships_table_alias.child_domain AS child_domain,
431
+ $relationships_table_alias.intermediary_type AS intermediary_type,
432
+ $relationships_table_alias.ownership AS ownership,
433
+ $relationships_table_alias.cardinality_parent_max AS cardinality_parent_max,
434
+ $relationships_table_alias.cardinality_parent_min AS cardinality_parent_min,
435
+ $relationships_table_alias.cardinality_child_max AS cardinality_child_max,
436
+ $relationships_table_alias.cardinality_child_min AS cardinality_child_min,
437
+ $relationships_table_alias.is_distinct AS is_distinct,
438
+ $relationships_table_alias.scope AS scope,
439
+ $relationships_table_alias.origin AS origin,
440
+ $relationships_table_alias.role_name_parent AS role_name_parent,
441
+ $relationships_table_alias.role_name_child AS role_name_child,
442
+ $relationships_table_alias.role_name_intermediary AS role_name_intermediary,
443
+ $relationships_table_alias.needs_legacy_support AS needs_legacy_support,
444
+ $relationships_table_alias.is_active AS is_active,
445
+ $relationships_table_alias.parent_types AS parent_types_set_id,
446
+ $relationships_table_alias.child_types AS child_types_set_id,
447
+ GROUP_CONCAT(DISTINCT $parent_types_table_alias.type) AS parent_types,
448
+ GROUP_CONCAT(DISTINCT $child_types_table_alias.type) AS child_types";
449
+ }
450
+
451
+
452
+ /**
453
+ * Build the part of the JOIN clause that is required for proper loading of a relationship definition.
454
+ *
455
+ * @param $type_set_table_name
456
+ * @param string $relationships_table_alias
457
+ * @param string $parent_types_table_alias
458
+ * @param string $child_types_table_alias
459
+ *
460
+ * @return string
461
+ * @since 2.5.4
462
+ */
463
+ public function get_standard_relationships_join_clause(
464
+ $type_set_table_name,
465
+ $relationships_table_alias = 'relationships',
466
+ $parent_types_table_alias = 'parent_types_table',
467
+ $child_types_table_alias = 'child_types_table'
468
+ ) {
469
+ return "
470
+ JOIN {$type_set_table_name} AS {$parent_types_table_alias}
471
+ ON ({$relationships_table_alias}.parent_types = {$parent_types_table_alias}.set_id )
472
+ JOIN {$type_set_table_name} AS {$child_types_table_alias}
473
+ ON ({$relationships_table_alias}.child_types = {$child_types_table_alias}.set_id )";
474
+ }
475
+
476
+
477
+ /**
478
+ * Build the part of the GROUP BY clause that is required for proper loading of a relationship definition.
479
+ *
480
+ * @param string $relationships_table_alias
481
+ *
482
+ * @return string
483
+ * @since 2.5.4
484
+ */
485
+ public function get_standards_relationship_group_by_clause( $relationships_table_alias = 'relationships' ) {
486
+ return "{$relationships_table_alias}.id";
487
+ }
488
+
489
+
490
  public function load_all_relationships() {
491
+ $relationship_table = $this->table_name->relationship_table();
492
+ $type_set_table = $this->table_name->type_set_table();
493
+
494
+ // The query is so complex because it needs to bring in data from the type set tables. But
495
+ // those two joins are very cheap because we don't expect many records here.
496
+ $query = "
497
+ SELECT {$this->get_standard_relationships_select_clause()}
498
+ FROM {$relationship_table} AS relationships
499
+ {$this->get_standard_relationships_join_clause( $type_set_table )}
500
+ GROUP BY {$this->get_standards_relationship_group_by_clause()}";
501
+
502
+ $rows = toolset_ensarr( $this->wpdb->get_results( $query ) );
503
  return $rows;
504
  }
505
 
vendor/toolset/toolset-common/inc/m2m/database/table_name.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Enum class. Holds names of m2m tables and provides methods that return full table names
5
+ * with correct $wpdb prefixes.
6
+ *
7
+ * NOT to be used outside the m2m API under any circumstances.
8
+ *
9
+ * @since m2m
10
+ */
11
+ class Toolset_Relationship_Table_Name {
12
+
13
+
14
+ /** @var wpdb */
15
+ private $wpdb;
16
+
17
+
18
+ /**
19
+ * Toolset_Relationship_Table_Name constructor.
20
+ *
21
+ * @param wpdb|null $wpdb_di
22
+ */
23
+ public function __construct( wpdb $wpdb_di = null ) {
24
+ if( null === $wpdb_di ) {
25
+ global $wpdb;
26
+ $this->wpdb = $wpdb;
27
+ } else {
28
+ $this->wpdb = $wpdb_di;
29
+ }
30
+ }
31
+
32
+
33
+ private static $instance;
34
+
35
+ /**
36
+ * This is only a temporary solution to avoid refactoring of all usages of static methods
37
+ * on this class.
38
+ *
39
+ * @return Toolset_Relationship_Table_Name
40
+ */
41
+ private static function get_instance() {
42
+ if( null === self::$instance ) {
43
+ self::$instance = new self();
44
+ }
45
+
46
+ return self::$instance;
47
+ }
48
+
49
+
50
+ private function get_full_table_name( $table_name ) {
51
+ return $this->wpdb->prefix . $table_name;
52
+ }
53
+
54
+
55
+ public function association_table() {
56
+ return $this->get_full_table_name( 'toolset_associations' );
57
+ }
58
+
59
+
60
+ public function relationship_table() {
61
+ return $this->get_full_table_name( 'toolset_relationships' );
62
+ }
63
+
64
+
65
+ public function type_set_table() {
66
+ return $this->get_full_table_name( 'toolset_type_sets' );
67
+ }
68
+
69
+
70
+ /**
71
+ * @deprecated Instantiate the class before using it.
72
+ * @return string
73
+ */
74
+ public static function associations() {
75
+ return self::get_instance()->association_table();
76
+ }
77
+
78
+
79
+ // fixme check all usages and update to the new table structure
80
+ public static function association_translations() {
81
+ throw new RuntimeException( 'The translations table was removed.');
82
+ }
83
+
84
+
85
+ /**
86
+ * @deprecated Instantiate the class before using it.
87
+ * @return string
88
+ */
89
+ public static function relationships() {
90
+ return self::get_instance()->relationship_table();
91
+ }
92
+
93
+ }
vendor/toolset/toolset-common/inc/m2m/database/unique_table_alias.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Generates unique alias values for a given table name.
5
+ *
6
+ * Works under the assumption that there are no tables with similar names different only by a numeric suffix "_$n". :)
7
+ * The generated values are unique within one class instance.
8
+ *
9
+ * @since 2.5.4
10
+ */
11
+ class Toolset_Relationship_Database_Unique_Table_Alias {
12
+
13
+ /**
14
+ * @var string[] Maps a table name to last used numeric suffix.
15
+ */
16
+ private $last_ids = array();
17
+
18
+
19
+ /**
20
+ * Generate a new unique value
21
+ * @param string $table_name
22
+ * @param bool $always_suffix Add a suffix even if using the table alias for the first time.
23
+ *
24
+ * @return string
25
+ */
26
+ public function generate( $table_name, $always_suffix = false ) {
27
+
28
+ if( ! array_key_exists( $table_name, $this->last_ids ) ) {
29
+ $this->last_ids[ $table_name ] = 1;
30
+ }
31
+
32
+ $last_id = $this->last_ids[ $table_name ];
33
+ $this->last_ids[ $table_name ]++;
34
+
35
+ if( $last_id === 0 && ! $always_suffix ) {
36
+ return $table_name;
37
+ }
38
+
39
+ return "{$table_name}_{$last_id}";
40
+ }
41
+
42
+ }
vendor/toolset/toolset-common/inc/m2m/{definition.php → definition/definition.php} RENAMED
@@ -23,6 +23,9 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
23
  // Even private methods should use getters instead of accessing properties directly.
24
  // Read getters' description for more detailed information.
25
 
 
 
 
26
  /** @var string */
27
  private $slug;
28
 
@@ -41,6 +44,12 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
41
  /** @var Toolset_Relationship_Element_Type */
42
  private $child_type;
43
 
 
 
 
 
 
 
44
  /** @var Toolset_Relationship_Cardinality */
45
  private $cardinality;
46
 
@@ -84,6 +93,8 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
84
  const DA_DRIVER = 'driver';
85
  const DA_PARENT_TYPE = 'parent';
86
  const DA_CHILD_TYPE = 'child';
 
 
87
  const DA_CARDINALITY = 'cardinality';
88
  const DA_DRIVER_SETUP = 'driver_setup';
89
  const DA_OWNERSHIP = 'ownership';
@@ -93,6 +104,7 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
93
  const DA_NEEDS_LEGACY_SUPPORT = 'needs_legacy_support';
94
  const DA_IS_ACTIVE = 'is_active';
95
  const DA_ORIGIN = 'origin';
 
96
 
97
  // Supported relationship driver names.
98
  // At the moment, only the native Toolset relationships are supported.
@@ -124,7 +136,9 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
124
  private function read_definition_array( $definition_array ) {
125
 
126
  $this->slug = sanitize_title( toolset_getarr( $definition_array, self::DA_SLUG ) );
127
-
 
 
128
  if( empty( $this->slug ) ) {
129
  throw new InvalidArgumentException( 'Invalid or missing slug.' );
130
  }
@@ -186,7 +200,7 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
186
 
187
  $role_names_definition = toolset_getarr( $definition_array, self::DA_ROLE_NAMES );
188
  $this->role_names = array();
189
- foreach( Toolset_Relationship_Role::all() as $role ) {
190
  // For each existing role, we will have a key with a custom name slug that should be recognized
191
  // in shortcodes, etc. Default value is also the role name.
192
  $this->role_names[ $role ] = sanitize_title(
@@ -199,6 +213,9 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
199
  $this->is_active( toolset_getarr( $definition_array, self::DA_IS_ACTIVE, true ) );
200
 
201
  $this->set_origin( toolset_getarr( $definition_array, self::DA_ORIGIN, Toolset_Relationship_Origin_Wizard::ORIGIN_KEYWORD ) );
 
 
 
202
  }
203
 
204
 
@@ -318,6 +335,11 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
318
  }
319
 
320
 
 
 
 
 
 
321
  public function get_domain( $element_role ) {
322
  return $this->get_element_type( $element_role )->get_domain();
323
  }
@@ -327,13 +349,13 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
327
  /**
328
  * Get a relationship entity type.
329
  *
330
- * @param string $element_role
331
  *
332
  * @return Toolset_Relationship_Element_Type
333
  * @since m2m
334
  */
335
  public function get_element_type( $element_role ) {
336
- switch( $element_role ) {
337
  case Toolset_Relationship_Role::CHILD:
338
  return $this->get_child_type();
339
  case Toolset_Relationship_Role::PARENT:
@@ -344,17 +366,37 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
344
  }
345
 
346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  /**
348
  * Set type of a relationship role (parent or child).
349
  *
350
  * Must not be used outside m2m API.
351
  *
352
- * @param string $element_role
353
  * @param Toolset_Relationship_Element_Type $type
354
  * @since m2m
355
  */
356
  public function set_element_type( $element_role, Toolset_Relationship_Element_Type $type ) {
357
- switch( $element_role ) {
358
  case Toolset_Relationship_Role::PARENT:
359
  $this->parent_type = $type;
360
  break;
@@ -370,7 +412,7 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
370
  /**
371
  * Determine if there are posts on the given side of the relationship.
372
  *
373
- * @param string $element_role
374
  * @return bool
375
  * @since m2m
376
  */
@@ -609,7 +651,7 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
609
  * @since m2m
610
  */
611
  private function elements_match_relationship_types( $elements ) {
612
- foreach( Toolset_Relationship_Role::parent_child() as $element_role ) {
613
  $element = toolset_getarr( $elements, $element_role, null );
614
  if( ! $element instanceof Toolset_Element ) {
615
  throw new InvalidArgumentException( 'Missing or invalid element instance.' );
@@ -689,16 +731,17 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
689
  /**
690
  * Get a custom role name that should be recognized in shortcodes instead of parent, child, etc.
691
  *
692
- * @param string $role One of the Toolset_Relationship_Role values.
693
  * @return string Custom role name.
694
  * @since m2m
695
  */
696
- public function get_role_name( $role ) {
697
- if( ! Toolset_Relationship_Role::is_valid( $role ) ) {
 
698
  throw new InvalidArgumentException();
699
  }
700
 
701
- return $this->role_names[ $role ];
702
  }
703
 
704
 
@@ -723,7 +766,7 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
723
  * @since m2m
724
  */
725
  private function get_default_role_name( $role ) {
726
- if( in_array( $role, Toolset_Relationship_Role::parent_child() ) ) {
727
  return $role;
728
  } elseif( Toolset_Relationship_Role::INTERMEDIARY === $role ) {
729
  return 'association';
@@ -738,19 +781,20 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
738
  *
739
  * The name will be sanitized and the value actually saved will be returned.
740
  *
741
- * @param string $role One of the Toolset_Relationship_Role values.
742
  * @param string $custom_name Custom name for the role.
743
  *
744
  * @return string Sanitized custom name
745
  * @since m2m
746
  */
747
- public function set_role_name( $role, $custom_name ) {
748
- if( ! Toolset_Relationship_Role::is_valid( $role ) ) {
 
749
  throw new InvalidArgumentException();
750
  }
751
 
752
  $sanitized_custom_name = sanitize_title( $custom_name );
753
- $this->role_names[ $role ] = $sanitized_custom_name;
754
 
755
  return $sanitized_custom_name;
756
  }
@@ -795,6 +839,15 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
795
  return $this->is_active;
796
  }
797
 
 
 
 
 
 
 
 
 
 
798
  /**
799
  * @return IToolset_Relationship_Origin
800
  * @since m2m
@@ -828,4 +881,15 @@ class Toolset_Relationship_Definition implements IToolset_Relationship_Definitio
828
 
829
  $this->origin = $origin;
830
  }
 
 
 
 
 
 
 
 
 
 
 
831
  }
23
  // Even private methods should use getters instead of accessing properties directly.
24
  // Read getters' description for more detailed information.
25
 
26
+ /** @var int */
27
+ private $row_id;
28
+
29
  /** @var string */
30
  private $slug;
31
 
44
  /** @var Toolset_Relationship_Element_Type */
45
  private $child_type;
46
 
47
+ /** @var int */
48
+ private $parent_type_set_id;
49
+
50
+ /** @var int */
51
+ private $child_type_set_id;
52
+
53
  /** @var Toolset_Relationship_Cardinality */
54
  private $cardinality;
55
 
93
  const DA_DRIVER = 'driver';
94
  const DA_PARENT_TYPE = 'parent';
95
  const DA_CHILD_TYPE = 'child';
96
+ const DA_PARENT_TYPE_SET_ID = 'parent_type_set_id';
97
+ const DA_CHILD_TYPE_SET_ID = 'child_type_set_id';
98
  const DA_CARDINALITY = 'cardinality';
99
  const DA_DRIVER_SETUP = 'driver_setup';
100
  const DA_OWNERSHIP = 'ownership';
104
  const DA_NEEDS_LEGACY_SUPPORT = 'needs_legacy_support';
105
  const DA_IS_ACTIVE = 'is_active';
106
  const DA_ORIGIN = 'origin';
107
+ const DA_ROW_ID = 'row_id';
108
 
109
  // Supported relationship driver names.
110
  // At the moment, only the native Toolset relationships are supported.
136
  private function read_definition_array( $definition_array ) {
137
 
138
  $this->slug = sanitize_title( toolset_getarr( $definition_array, self::DA_SLUG ) );
139
+
140
+ $this->row_id = (int) toolset_getarr( $definition_array, self::DA_ROW_ID );
141
+
142
  if( empty( $this->slug ) ) {
143
  throw new InvalidArgumentException( 'Invalid or missing slug.' );
144
  }
200
 
201
  $role_names_definition = toolset_getarr( $definition_array, self::DA_ROLE_NAMES );
202
  $this->role_names = array();
203
+ foreach( Toolset_Relationship_Role::all_role_names() as $role ) {
204
  // For each existing role, we will have a key with a custom name slug that should be recognized
205
  // in shortcodes, etc. Default value is also the role name.
206
  $this->role_names[ $role ] = sanitize_title(
213
  $this->is_active( toolset_getarr( $definition_array, self::DA_IS_ACTIVE, true ) );
214
 
215
  $this->set_origin( toolset_getarr( $definition_array, self::DA_ORIGIN, Toolset_Relationship_Origin_Wizard::ORIGIN_KEYWORD ) );
216
+
217
+ $this->parent_type_set_id = (int) toolset_getarr( $definition_array, self::DA_PARENT_TYPE_SET_ID );
218
+ $this->child_type_set_id = (int) toolset_getarr( $definition_array, self::DA_CHILD_TYPE_SET_ID );
219
  }
220
 
221
 
335
  }
336
 
337
 
338
+ /**
339
+ * @param string|IToolset_Relationship_Role $element_role
340
+ *
341
+ * @return string
342
+ */
343
  public function get_domain( $element_role ) {
344
  return $this->get_element_type( $element_role )->get_domain();
345
  }
349
  /**
350
  * Get a relationship entity type.
351
  *
352
+ * @param string|IToolset_Relationship_Role $element_role
353
  *
354
  * @return Toolset_Relationship_Element_Type
355
  * @since m2m
356
  */
357
  public function get_element_type( $element_role ) {
358
+ switch( $this->role_to_role_name( $element_role ) ) {
359
  case Toolset_Relationship_Role::CHILD:
360
  return $this->get_child_type();
361
  case Toolset_Relationship_Role::PARENT:
366
  }
367
 
368
 
369
+ /**
370
+ * Get an set_id that references type slugs in the toolset_type_sets table for a given role.
371
+ * Obviously, never use this outside of m2m API.
372
+ *
373
+ * @param IToolset_Relationship_Role_Parent_Child|string $element_role
374
+ *
375
+ * @return int Set ID or zero if the type set is not persisted yet.
376
+ */
377
+ public function get_element_type_set_id( $element_role ) {
378
+ switch( $this->role_to_role_name( $element_role ) ) {
379
+ case Toolset_Relationship_Role::PARENT:
380
+ return $this->parent_type_set_id;
381
+ case Toolset_Relationship_Role::CHILD:
382
+ return $this->child_type_set_id;
383
+ default:
384
+ throw new InvalidArgumentException();
385
+ }
386
+ }
387
+
388
+
389
  /**
390
  * Set type of a relationship role (parent or child).
391
  *
392
  * Must not be used outside m2m API.
393
  *
394
+ * @param string|IToolset_Relationship_Role $element_role
395
  * @param Toolset_Relationship_Element_Type $type
396
  * @since m2m
397
  */
398
  public function set_element_type( $element_role, Toolset_Relationship_Element_Type $type ) {
399
+ switch( $this->role_to_role_name( $element_role ) ) {
400
  case Toolset_Relationship_Role::PARENT:
401
  $this->parent_type = $type;
402
  break;
412
  /**
413
  * Determine if there are posts on the given side of the relationship.
414
  *
415
+ * @param string|IToolset_Relationship_Role $element_role
416
  * @return bool
417
  * @since m2m
418
  */
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.' );
731
  /**
732
  * Get a custom role name that should be recognized in shortcodes instead of parent, child, etc.
733
  *
734
+ * @param string|IToolset_Relationship_Role $element_role One of the Toolset_Relationship_Role values.
735
  * @return string Custom role name.
736
  * @since m2m
737
  */
738
+ public function get_role_name( $element_role ) {
739
+ $element_role = $this->role_to_role_name( $element_role );
740
+ if( ! Toolset_Relationship_Role::is_valid( $element_role ) ) {
741
  throw new InvalidArgumentException();
742
  }
743
 
744
+ return $this->role_names[ $element_role ];
745
  }
746
 
747
 
766
  * @since m2m
767
  */
768
  private function get_default_role_name( $role ) {
769
+ if( in_array( $role, Toolset_Relationship_Role::parent_child_role_names() ) ) {
770
  return $role;
771
  } elseif( Toolset_Relationship_Role::INTERMEDIARY === $role ) {
772
  return 'association';
781
  *
782
  * The name will be sanitized and the value actually saved will be returned.
783
  *
784
+ * @param string|IToolset_Relationship_Role $element_role One of the Toolset_Relationship_Role values.
785
  * @param string $custom_name Custom name for the role.
786
  *
787
  * @return string Sanitized custom name
788
  * @since m2m
789
  */
790
+ public function set_role_name( $element_role, $custom_name ) {
791
+ $role_name = $this->role_to_role_name( $element_role );
792
+ if( ! Toolset_Relationship_Role::is_valid( $role_name ) ) {
793
  throw new InvalidArgumentException();
794
  }
795
 
796
  $sanitized_custom_name = sanitize_title( $custom_name );
797
+ $this->role_names[ $role_name ] = $sanitized_custom_name;
798
 
799
  return $sanitized_custom_name;
800
  }
839
  return $this->is_active;
840
  }
841
 
842
+
843
+ private function role_to_role_name( $role ) {
844
+ if( $role instanceof IToolset_Relationship_Role ) {
845
+ return $role->get_name();
846
+ }
847
+
848
+ return $role;
849
+ }
850
+
851
  /**
852
  * @return IToolset_Relationship_Origin
853
  * @since m2m
881
 
882
  $this->origin = $origin;
883
  }
884
+
885
+
886
+ /**
887
+ * Get an ID of the database row where this relationship definition is stored.
888
+ *
889
+ * @return int Careful: This can be zero if no ID is available (relationship is not saved yet).
890
+ */
891
+ public function get_row_id() {
892
+ return $this->row_id;
893
+ }
894
+
895
  }
vendor/toolset/toolset-common/inc/m2m/{definition_factory.php → definition/factory.php} RENAMED
File without changes
vendor/toolset/toolset-common/inc/m2m/definition/persistence.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Handles the persistence of relationship definitions, from IToolset_Relationship_Definition object to a wpdb call.
5
+ *
6
+ * For internal purposes of the m2m API only. Use Toolset_Relationship_Definition_Repository().
7
+ *
8
+ * @since 2.5.2
9
+ */
10
+ class Toolset_Relationship_Definition_Persistence {
11
+
12
+
13
+ /** @var wpdb */
14
+ private $wpdb;
15
+
16
+
17
+ /** @var Toolset_Relationship_Definition_Translator */
18
+ private $definition_translator;
19
+
20
+
21
+ /** @var Toolset_Relationship_Table_Name */
22
+ private $table_name;
23
+
24
+
25
+ public function __construct(
26
+ wpdb $wpdb_di = null,
27
+ Toolset_Relationship_Definition_Translator $definition_translator_di = null,
28
+ Toolset_Relationship_Table_Name $table_name_di = null
29
+ ) {
30
+
31
+ if( null === $wpdb_di ) {
32
+ global $wpdb;
33
+ $this->wpdb = $wpdb;
34
+ } else {
35
+ $this->wpdb = $wpdb_di;
36
+ }
37
+
38
+ $this->definition_translator = (
39
+ null === $definition_translator_di
40
+ ? new Toolset_Relationship_Definition_Translator()
41
+ : $definition_translator_di
42
+ );
43
+
44
+ $this->table_name = (
45
+ null === $table_name_di
46
+ ? new Toolset_Relationship_Table_Name()
47
+ : $table_name_di
48
+ );
49
+
50
+ }
51
+
52
+
53
+
54
+ /**
55
+ * Update a single relationship definition.
56
+ *
57
+ * @param Toolset_Relationship_Definition $relationship_definition
58
+ */
59
+ public function persist_definition( Toolset_Relationship_Definition $relationship_definition ) {
60
+ $row = $this->definition_translator->to_database_row( $relationship_definition );
61
+ $row = $this->update_definition_type_sets( $relationship_definition, $row );
62
+ $this->wpdb->update(
63
+ $this->table_name->relationship_table(),
64
+ $row,
65
+ array( 'slug' => $relationship_definition->get_slug() ),
66
+ $this->definition_translator->get_database_row_formats(),
67
+ '%s'
68
+ );
69
+ }
70
+
71
+
72
+ /**
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
+
88
+ /**
89
+ * Delete a relationship definition record from the database.
90
+ *
91
+ * @param Toolset_Relationship_Definition $relationship_definition
92
+ */
93
+ public function delete_definition( Toolset_Relationship_Definition $relationship_definition ) {
94
+
95
+ foreach( Toolset_Relationship_Role::parent_child_role_names() as $role_name ) {
96
+ $set_id = $relationship_definition->get_element_type_set_id( $role_name );
97
+
98
+ if( 0 === $set_id ) {
99
+ continue;
100
+ }
101
+
102
+ $this->wpdb->delete(
103
+ $this->table_name->type_set_table(),
104
+ array( 'set_id' => $set_id ),
105
+ '%d'
106
+ );
107
+ }
108
+
109
+ $this->wpdb->delete(
110
+ $this->table_name->relationship_table(),
111
+ array( 'slug' => $relationship_definition->get_slug() ),
112
+ '%s'
113
+ );
114
+ }
115
+
116
+
117
+ /**
118
+ * Persist type sets for parent and child roles and update the to-be-saved database row with
119
+ * a new set_id if it changed.
120
+ *
121
+ * @param Toolset_Relationship_Definition $definition
122
+ * @param array $definition_row
123
+ *
124
+ * @return array Updated definition row.
125
+ */
126
+ private function update_definition_type_sets( $definition, $definition_row ) {
127
+ $definition_row['child_types'] = $this->update_type_set(
128
+ $definition->get_child_type()->get_types(),
129
+ $definition->get_element_type_set_id( Toolset_Relationship_Role::CHILD )
130
+ );
131
+
132
+ $definition_row['parent_types'] = $this->update_type_set(
133
+ $definition->get_parent_type()->get_types(),
134
+ $definition->get_element_type_set_id( Toolset_Relationship_Role::PARENT )
135
+ );
136
+
137
+ return $definition_row;
138
+ }
139
+
140
+
141
+ /**
142
+ * Update a type set in the database.
143
+ *
144
+ * @param string[] $types
145
+ * @param int $set_id Previously used set_id or 0.
146
+ *
147
+ * @return int set_id that was used in the end.
148
+ */
149
+ private function update_type_set( $types, $set_id ) {
150
+ if( 0 === $set_id ) {
151
+ $set_id = $this->get_next_free_set_id();
152
+ } else {
153
+ // set_id doesn't change but we need to overwrite the whole set
154
+ $this->delete_type_set( $set_id );
155
+ }
156
+
157
+ foreach( $types as $type ) {
158
+ $this->insert_type( $type, $set_id );
159
+ }
160
+
161
+ return $set_id;
162
+ }
163
+
164
+
165
+ /**
166
+ * Determine a next free set_id in the type set table.
167
+ *
168
+ * @return int
169
+ */
170
+ private function get_next_free_set_id() {
171
+ $type_set_table = $this->table_name->type_set_table();
172
+ $last_set_id = (int) $this->wpdb->get_var( "SELECT MAX(set_id) FROM {$type_set_table}" );
173
+ return ( $last_set_id + 1 );
174
+ }
175
+
176
+
177
+ /**
178
+ * Insert a single type record into the type set table.
179
+ *
180
+ * @param string $type
181
+ * @param int $set_id
182
+ */
183
+ private function insert_type( $type, $set_id ) {
184
+ $this->wpdb->insert(
185
+ $this->table_name->type_set_table(),
186
+ array(
187
+ 'set_id' => $set_id,
188
+ 'type' => $type
189
+ ),
190
+ array( '%d', '%s' )
191
+ );
192
+ }
193
+
194
+
195
+ /**
196
+ * Delete a whole type set from the type set table.
197
+ *
198
+ * @param int $set_id
199
+ */
200
+ private function delete_type_set( $set_id ) {
201
+ $this->wpdb->delete(
202
+ $this->table_name->type_set_table(),
203
+ array( 'set_id' => $set_id ),
204
+ '%d'
205
+ );
206
+ }
207
+
208
+
209
+ }
vendor/toolset/toolset-common/inc/m2m/{definition_repository.php → definition/repository.php} RENAMED
@@ -16,8 +16,12 @@
16
  */
17
  class Toolset_Relationship_Definition_Repository {
18
 
 
19
  private static $instance = null;
20
 
 
 
 
21
  public static function get_instance() {
22
  if( null == self::$instance ) {
23
  self::$instance = new self();
@@ -36,15 +40,29 @@ class Toolset_Relationship_Definition_Repository {
36
  /** @var Toolset_Relationship_Definition_Factory|null */
37
  private $_definition_factory;
38
 
 
 
 
 
 
39
 
40
  public function __construct(
41
  Toolset_Association_Repository $association_repository_di = null,
42
  Toolset_Relationship_Database_Operations $database_operations_di = null,
43
- Toolset_Relationship_Definition_Factory $definition_factory_di = null
 
 
44
  ) {
45
  $this->_association_repository = $association_repository_di;
46
  $this->_database_operations = $database_operations_di;
47
  $this->_definition_factory = $definition_factory_di;
 
 
 
 
 
 
 
48
  }
49
 
50
 
@@ -66,93 +84,22 @@ class Toolset_Relationship_Definition_Repository {
66
  $this->definitions = array();
67
  foreach( $rows as $row ) {
68
 
69
- $definition_array = $this->database_row_to_definition_array( $row );
70
- $definition = $this->load_definition_from_array( $definition_array );
71
 
72
  if( null != $definition ) {
73
- $this->insert_definition( $definition );
74
  }
75
  }
76
  }
77
 
78
 
79
- /**
80
- * Convert a row from the relationships table into a relationship definition array.
81
- *
82
- * @param $row
83
- * @return array
84
- * @since m2m
85
- */
86
- private function database_row_to_definition_array( $row ) {
87
-
88
- $extra_data = toolset_ensarr( maybe_unserialize( $row->extra ) );
89
-
90
- $definition_array = array(
91
- Toolset_Relationship_Definition::DA_SLUG => $row->slug,
92
- Toolset_Relationship_Definition::DA_DISPLAY_NAME_PLURAL => $row->display_name,
93
- Toolset_Relationship_Definition::DA_DISPLAY_NAME_SINGULAR => toolset_getarr( $extra_data, 'display_name_singular', $row->slug ),
94
- Toolset_Relationship_Definition::DA_DRIVER => $row->driver,
95
- Toolset_Relationship_Definition::DA_PARENT_TYPE => array(
96
- Toolset_Relationship_Element_Type::DA_DOMAIN => $row->parent_domain,
97
- Toolset_Relationship_Element_Type::DA_TYPES => maybe_unserialize( $row->parent_types )
98
- ),
99
- Toolset_Relationship_Definition::DA_CHILD_TYPE => array(
100
- Toolset_Relationship_Element_Type::DA_DOMAIN => $row->child_domain,
101
- Toolset_Relationship_Element_Type::DA_TYPES => maybe_unserialize( $row->child_types )
102
- ),
103
- Toolset_Relationship_Definition::DA_CARDINALITY => array(
104
- Toolset_Relationship_Role::PARENT => array(
105
- Toolset_Relationship_Cardinality::MAX => (int) $row->cardinality_parent_max,
106
- Toolset_Relationship_Cardinality::MIN => (int) $row->cardinality_parent_min
107
- ),
108
- Toolset_Relationship_Role::CHILD => array(
109
- Toolset_Relationship_Cardinality::MAX => (int) $row->cardinality_child_max,
110
- Toolset_Relationship_Cardinality::MIN => (int) $row->cardinality_child_min
111
- )
112
- ),
113
- Toolset_Relationship_Definition::DA_DRIVER_SETUP => array(
114
- Toolset_Relationship_Driver::DA_INTERMEDIARY_POST_TYPE => $row->intermediary_type
115
- ),
116
- Toolset_Relationship_Definition::DA_OWNERSHIP => $row->ownership,
117
- Toolset_Relationship_Definition::DA_IS_DISTINCT => (bool) $row->is_distinct,
118
- Toolset_Relationship_Definition::DA_SCOPE => maybe_unserialize( $row->scope ),
119
- Toolset_Relationship_Definition::DA_ORIGIN => maybe_unserialize( $row->origin ),
120
- Toolset_Relationship_Definition::DA_ROLE_NAMES => toolset_ensarr( toolset_getarr( $extra_data, 'role_names' ) ),
121
- Toolset_Relationship_Definition::DA_NEEDS_LEGACY_SUPPORT => (bool) toolset_getarr( $extra_data, 'needs_legacy_support', false ),
122
- Toolset_Relationship_Definition::DA_IS_ACTIVE => (bool) toolset_getarr( $extra_data, 'is_active', true )
123
- );
124
-
125
- return $definition_array;
126
- }
127
-
128
-
129
- /**
130
- * Load a single relationship definition from a definition array.
131
- *
132
- * @param array $definition_array
133
- * @return null|Toolset_Relationship_Definition The relationship definition or null if it was not
134
- * possible to load it (which means that the definition array was invalid).
135
- * @since m2m
136
- */
137
- private function load_definition_from_array( $definition_array ) {
138
-
139
- try {
140
- return $this->get_definition_factory()->create( $definition_array );
141
- } catch( Exception $e ) {
142
- // todo log the error somehow
143
- return null;
144
- }
145
-
146
- }
147
-
148
-
149
  /**
150
  * Insert a definition into the array of managed ones.
151
- *
152
  * @param $definition Toolset_Relationship_Definition
153
  * @since m2m
154
  */
155
- private function insert_definition( $definition ) {
156
  // We can rely on this, the slug never changes.
157
  $this->definitions[ $definition->get_slug() ] = $definition;
158
  }
@@ -174,7 +121,6 @@ class Toolset_Relationship_Definition_Repository {
174
  public function remove_definition( $definition, $do_cleanup = true ) {
175
  /**@var Toolset_Result */
176
  $toolset_results = array();
177
-
178
  if( ! $definition instanceof Toolset_Relationship_Definition ) {
179
  if( ! is_string( $definition ) || ! $this->definition_exists( $definition ) ) {
180
  throw new InvalidArgumentException( 'Relationship definition doesn\'t exist.' );
@@ -207,8 +153,9 @@ class Toolset_Relationship_Definition_Repository {
207
  }
208
  }
209
  }
210
-
211
  unset( $this->definitions[ $slug ] );
 
 
212
  $toolset_results[] = new Toolset_Result( true, sprintf( __( 'Relationship "%s" has been deleted.', 'wpcf' ), $slug ) );
213
 
214
  // No "after_delete_relationship" action as long as we have to save_relationships() manually. This can change in the future.
@@ -219,7 +166,7 @@ class Toolset_Relationship_Definition_Repository {
219
 
220
  /**
221
  * Get all relationship definitions.
222
- *
223
  * @return IToolset_Relationship_Definition[]
224
  */
225
  public function get_definitions() {
@@ -229,7 +176,7 @@ class Toolset_Relationship_Definition_Repository {
229
 
230
  /**
231
  * Determine if a relationship definition with a given slug exists.
232
- *
233
  * @param string $slug
234
  * @return bool
235
  * @since m2m
@@ -241,16 +188,34 @@ class Toolset_Relationship_Definition_Repository {
241
 
242
  /**
243
  * Get a relationship definition with given slug.
244
- *
245
  * @param string $slug
246
  * @return null|IToolset_Relationship_Definition
247
- * @since m2m
248
  */
249
  public function get_definition( $slug ) {
250
  return ( $this->definition_exists( $slug ) ? $this->definitions[ $slug ] : null );
251
  }
252
 
253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  /**
255
  * Create a new definition and start managing it.
256
  *
@@ -292,13 +257,13 @@ class Toolset_Relationship_Definition_Repository {
292
  Toolset_Relationship_Definition::DA_CHILD_TYPE => $child->get_definition_array(),
293
  Toolset_Relationship_Definition::DA_IS_ACTIVE => true
294
  );
295
-
296
  $new_definition = new Toolset_Relationship_Definition( $definition_array );
297
-
298
- $this->insert_definition( $new_definition );
299
 
300
- Toolset_Relationship_Multilingual_Mode::flush_cache();
301
-
 
 
302
  return $new_definition;
303
  }
304
 
@@ -326,66 +291,24 @@ class Toolset_Relationship_Definition_Repository {
326
 
327
  /**
328
  * Persist all relationship definitions in the database.
329
- *
 
330
  * @since m2m
331
  */
332
  public function save_definitions() {
333
-
334
- global $wpdb;
335
-
336
- $table_name = Toolset_Relationship_Table_Name::relationships();
337
- $format = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s' );
338
-
339
- $wpdb->query( "TRUNCATE $table_name" );
340
-
341
  foreach( $this->definitions as $definition ) {
342
-
343
- $row = $this->definition_to_database_row( $definition );
344
-
345
- $wpdb->insert( $table_name, $row, $format );
346
  }
347
  }
348
 
349
-
350
  /**
351
- * Convert a relationship definition into a database row
352
  *
353
- * @param Toolset_Relationship_Definition $definition
354
- * @return array
355
- * @since m2m
356
  */
357
- private function definition_to_database_row( $definition ) {
358
-
359
- $defintion_array = $definition->get_definition_array();
360
-
361
- $row = array(
362
- 'slug' => $definition->get_slug(),
363
- 'display_name' => $definition->get_display_name(),
364
- 'driver' => $defintion_array[ Toolset_Relationship_Definition::DA_DRIVER ],
365
- 'parent_domain' => $definition->get_parent_type()->get_domain(),
366
- 'parent_types' => maybe_serialize( $definition->get_parent_type()->get_types() ),
367
- 'child_domain' => $definition->get_child_type()->get_domain(),
368
- 'child_types' => maybe_serialize( $definition->get_child_type()->get_types() ),
369
- 'intermediary_type' => $definition->get_driver()->get_setup( Toolset_Relationship_Driver::DA_INTERMEDIARY_POST_TYPE, '' ),
370
- 'ownership' => ( null == $definition->get_owner() ? 'none' : $definition->get_owner() ),
371
- 'cardinality_parent_max' => $definition->get_cardinality()->get_parent( Toolset_Relationship_Cardinality::MAX ),
372
- 'cardinality_parent_min' => $definition->get_cardinality()->get_parent( Toolset_Relationship_Cardinality::MIN ),
373
- 'cardinality_child_max' => $definition->get_cardinality()->get_child( Toolset_Relationship_Cardinality::MAX ),
374
- 'cardinality_child_min' => $definition->get_cardinality()->get_child( Toolset_Relationship_Cardinality::MIN ),
375
- 'is_distinct' => ( $definition->is_distinct() ? 1 : 0 ),
376
- 'scope' => maybe_serialize( $definition->has_scope() ? $definition->get_scope()->get_scope_data() : '' ),
377
- 'origin' => $definition->get_origin()->get_origin_keyword(),
378
- 'extra' => maybe_serialize(
379
- array(
380
- 'role_names' => $definition->get_role_names(),
381
- 'needs_legacy_support' => ( $definition->needs_legacy_support() ? 1 : 0 ),
382
- 'is_active' => ( $definition->is_active() ? 1 : 0 ),
383
- 'display_name_singular' => $definition->get_display_name_singular()
384
- )
385
- )
386
- );
387
-
388
- return $row;
389
  }
390
 
391
 
@@ -462,10 +385,9 @@ class Toolset_Relationship_Definition_Repository {
462
  $relationship_definition->set_slug( $new_slug );
463
 
464
  // Update the storage
465
- $this->remove_definition( $previous_slug );
466
- $this->insert_definition( $relationship_definition );
467
-
468
- $this->save_definitions();
469
 
470
  // The association table needs an update as well
471
  $association_update_result = Toolset_Relationship_Database_Operations::update_associations_on_definition_renaming(
@@ -512,4 +434,13 @@ class Toolset_Relationship_Definition_Repository {
512
  return $this->_definition_factory;
513
  }
514
 
 
 
 
 
 
 
 
 
 
515
  }
16
  */
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 == self::$instance ) {
27
  self::$instance = new self();
40
  /** @var Toolset_Relationship_Definition_Factory|null */
41
  private $_definition_factory;
42
 
43
+ /** @var Toolset_Relationship_Definition_Persistence */
44
+ private $_definition_persistence;
45
+
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,
52
+ Toolset_Relationship_Definition_Factory $definition_factory_di = null,
53
+ Toolset_Relationship_Definition_Persistence $definition_persistence_di = null,
54
+ Toolset_Relationship_Definition_Translator $definition_translator_di = null
55
  ) {
56
  $this->_association_repository = $association_repository_di;
57
  $this->_database_operations = $database_operations_di;
58
  $this->_definition_factory = $definition_factory_di;
59
+ $this->_definition_persistence = $definition_persistence_di;
60
+
61
+ $this->definition_translator = (
62
+ null === $definition_translator_di
63
+ ? new Toolset_Relationship_Definition_Translator()
64
+ : $definition_translator_di
65
+ );
66
  }
67
 
68
 
84
  $this->definitions = array();
85
  foreach( $rows as $row ) {
86
 
87
+ $definition = $this->definition_translator->from_database_row( $row );
 
88
 
89
  if( null != $definition ) {
90
+ $this->add_to_cache( $definition );
91
  }
92
  }
93
  }
94
 
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  /**
97
  * Insert a definition into the array of managed ones.
98
+ *
99
  * @param $definition Toolset_Relationship_Definition
100
  * @since m2m
101
  */
102
+ private function add_to_cache( $definition ) {
103
  // We can rely on this, the slug never changes.
104
  $this->definitions[ $definition->get_slug() ] = $definition;
105
  }
121
  public function remove_definition( $definition, $do_cleanup = true ) {
122
  /**@var Toolset_Result */
123
  $toolset_results = array();
 
124
  if( ! $definition instanceof Toolset_Relationship_Definition ) {
125
  if( ! is_string( $definition ) || ! $this->definition_exists( $definition ) ) {
126
  throw new InvalidArgumentException( 'Relationship definition doesn\'t exist.' );
153
  }
154
  }
155
  }
 
156
  unset( $this->definitions[ $slug ] );
157
+ $this->get_definition_persistence()->delete_definition( $definition );
158
+
159
  $toolset_results[] = new Toolset_Result( true, sprintf( __( 'Relationship "%s" has been deleted.', 'wpcf' ), $slug ) );
160
 
161
  // No "after_delete_relationship" action as long as we have to save_relationships() manually. This can change in the future.
166
 
167
  /**
168
  * Get all relationship definitions.
169
+ *
170
  * @return IToolset_Relationship_Definition[]
171
  */
172
  public function get_definitions() {
176
 
177
  /**
178
  * Determine if a relationship definition with a given slug exists.
179
+ *
180
  * @param string $slug
181
  * @return bool
182
  * @since m2m
188
 
189
  /**
190
  * Get a relationship definition with given slug.
191
+ *
192
  * @param string $slug
193
  * @return null|IToolset_Relationship_Definition
194
+ * @since m2m
195
  */
196
  public function get_definition( $slug ) {
197
  return ( $this->definition_exists( $slug ) ? $this->definitions[ $slug ] : null );
198
  }
199
 
200
 
201
+ /**
202
+ * Get a relationship definition with a given row ID.
203
+ *
204
+ * @param int $row_id
205
+ *
206
+ * @return null|Toolset_Relationship_Definition
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
+ }
214
+
215
+ return null;
216
+ }
217
+
218
+
219
  /**
220
  * Create a new definition and start managing it.
221
  *
257
  Toolset_Relationship_Definition::DA_CHILD_TYPE => $child->get_definition_array(),
258
  Toolset_Relationship_Definition::DA_IS_ACTIVE => true
259
  );
260
+
261
  $new_definition = new Toolset_Relationship_Definition( $definition_array );
 
 
262
 
263
+ $this->get_definition_persistence()->insert_definition( $new_definition );
264
+
265
+ $this->add_to_cache( $new_definition );
266
+
267
  return $new_definition;
268
  }
269
 
291
 
292
  /**
293
  * Persist all relationship definitions in the database.
294
+ *
295
+ * @deprecated Use persist_definition() only on the relationship that has been changed.
296
  * @since m2m
297
  */
298
  public function save_definitions() {
 
 
 
 
 
 
 
 
299
  foreach( $this->definitions as $definition ) {
300
+ $this->persist_definition( $definition );
 
 
 
301
  }
302
  }
303
 
 
304
  /**
305
+ * Update a single relationship definition.
306
  *
307
+ * @param Toolset_Relationship_Definition $relationship_definition
308
+ * @since 2.5.2
 
309
  */
310
+ public function persist_definition( Toolset_Relationship_Definition $relationship_definition ) {
311
+ $this->get_definition_persistence()->persist_definition( $relationship_definition );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  }
313
 
314
 
385
  $relationship_definition->set_slug( $new_slug );
386
 
387
  // Update the storage
388
+ $this->remove_definition( $previous_slug, false );
389
+ $this->add_to_cache( $relationship_definition );
390
+ $this->persist_definition( $relationship_definition );
 
391
 
392
  // The association table needs an update as well
393
  $association_update_result = Toolset_Relationship_Database_Operations::update_associations_on_definition_renaming(
434
  return $this->_definition_factory;
435
  }
436
 
437
+
438
+ private function get_definition_persistence() {
439
+ if( null === $this->_definition_persistence ) {
440
+ $this->_definition_persistence = new Toolset_Relationship_Definition_Persistence();
441
+ }
442
+
443
+ return $this->_definition_persistence;
444
+ }
445
+
446
  }
vendor/toolset/toolset-common/inc/m2m/definition/translator.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Translates between a database row from the toolset_relationships table and a relationship definition.
5
+ *
6
+ * This is the only place when such process is supposed to take place.
7
+ *
8
+ * Never use this class outside of the m2m API.
9
+ *
10
+ * @since 2.5.2
11
+ */
12
+ class Toolset_Relationship_Definition_Translator {
13
+
14
+
15
+ private $definition_factory;
16
+
17
+
18
+ public function __construct( Toolset_Relationship_Definition_Factory $definition_factory_di = null ) {
19
+ $this->definition_factory = (
20
+ null === $definition_factory_di
21
+ ? new Toolset_Relationship_Definition_Factory()
22
+ : $definition_factory_di
23
+ );
24
+ }
25
+
26
+
27
+ /**
28
+ * Convert a relationship definition into a database row
29
+ *
30
+ * @param Toolset_Relationship_Definition $definition
31
+ * @return array
32
+ * @since m2m
33
+ */
34
+ public function to_database_row( $definition ) {
35
+
36
+ $defintion_array = $definition->get_definition_array();
37
+
38
+ $row = array(
39
+ 'slug' => $definition->get_slug(),
40
+ 'display_name_plural' => $definition->get_display_name(),
41
+ 'display_name_singular' => $definition->get_display_name_singular(),
42
+ 'driver' => $defintion_array[ Toolset_Relationship_Definition::DA_DRIVER ],
43
+ 'parent_domain' => $definition->get_parent_type()->get_domain(),
44
+ 'parent_types' => $definition->get_element_type_set_id( Toolset_Relationship_Role::PARENT ),
45
+ 'child_domain' => $definition->get_child_type()->get_domain(),
46
+ 'child_types' => $definition->get_element_type_set_id( Toolset_Relationship_Role::CHILD ),
47
+ 'intermediary_type' => $definition->get_driver()->get_setup( Toolset_Relationship_Driver::DA_INTERMEDIARY_POST_TYPE, '' ),
48
+ 'ownership' => ( null == $definition->get_owner() ? 'none' : $definition->get_owner() ),
49
+ 'cardinality_parent_max' => $definition->get_cardinality()->get_parent( Toolset_Relationship_Cardinality::MAX ),
50
+ 'cardinality_parent_min' => $definition->get_cardinality()->get_parent( Toolset_Relationship_Cardinality::MIN ),
51
+ 'cardinality_child_max' => $definition->get_cardinality()->get_child( Toolset_Relationship_Cardinality::MAX ),
52
+ 'cardinality_child_min' => $definition->get_cardinality()->get_child( Toolset_Relationship_Cardinality::MIN ),
53
+ 'is_distinct' => ( $definition->is_distinct() ? 1 : 0 ),
54
+ 'scope' => maybe_serialize( $definition->has_scope() ? $definition->get_scope()->get_scope_data() : '' ),
55
+ 'origin' => $definition->get_origin()->get_origin_keyword(),
56
+ 'role_name_parent' => $definition->get_role_name( Toolset_Relationship_Role::PARENT ),
57
+ 'role_name_child' => $definition->get_role_name( Toolset_Relationship_Role::CHILD ),
58
+ 'role_name_intermediary' => $definition->get_role_name( Toolset_Relationship_Role::INTERMEDIARY ),
59
+ 'needs_legacy_support' => ( $definition->needs_legacy_support() ? 1 : 0 ),
60
+ 'is_active' => ( $definition->is_active() ? 1 : 0 ),
61
+ );
62
+
63
+ return $row;
64
+ }
65
+
66
+
67
+ /**
68
+ * Convert a row from the relationships table into a relationship definition array.
69
+ *
70
+ * @param $row
71
+ * @return array
72
+ * @since m2m
73
+ */
74
+ private function from_database_row_to_definition_array( $row ) {
75
+
76
+ $definition_array = array(
77
+ Toolset_Relationship_Definition::DA_ROW_ID => $row->id,
78
+ Toolset_Relationship_Definition::DA_SLUG => $row->slug,
79
+ Toolset_Relationship_Definition::DA_DISPLAY_NAME_PLURAL => $row->display_name_plural,
80
+ Toolset_Relationship_Definition::DA_DISPLAY_NAME_SINGULAR => $row->display_name_singular,
81
+ Toolset_Relationship_Definition::DA_DRIVER => $row->driver,
82
+ Toolset_Relationship_Definition::DA_PARENT_TYPE => array(
83
+ Toolset_Relationship_Element_Type::DA_DOMAIN => $row->parent_domain,
84
+ Toolset_Relationship_Element_Type::DA_TYPES => explode( Toolset_Relationship_Database_Operations::GROUP_CONCAT_DELIMITER, $row->parent_types ),
85
+ ),
86
+ Toolset_Relationship_Definition::DA_CHILD_TYPE => array(
87
+ Toolset_Relationship_Element_Type::DA_DOMAIN => $row->child_domain,
88
+ Toolset_Relationship_Element_Type::DA_TYPES => explode( Toolset_Relationship_Database_Operations::GROUP_CONCAT_DELIMITER, $row->child_types ),
89
+ ),
90
+ Toolset_Relationship_Definition::DA_PARENT_TYPE_SET_ID => (int) $row->parent_types_set_id,
91
+ Toolset_Relationship_Definition::DA_CHILD_TYPE_SET_ID => (int) $row->child_types_set_id,
92
+ Toolset_Relationship_Definition::DA_CARDINALITY => array(
93
+ Toolset_Relationship_Role::PARENT => array(
94
+ Toolset_Relationship_Cardinality::MAX => (int) $row->cardinality_parent_max,
95
+ Toolset_Relationship_Cardinality::MIN => (int) $row->cardinality_parent_min
96
+ ),
97
+ Toolset_Relationship_Role::CHILD => array(
98
+ Toolset_Relationship_Cardinality::MAX => (int) $row->cardinality_child_max,
99
+ Toolset_Relationship_Cardinality::MIN => (int) $row->cardinality_child_min
100
+ )
101
+ ),
102
+ Toolset_Relationship_Definition::DA_DRIVER_SETUP => array(
103
+ Toolset_Relationship_Driver::DA_INTERMEDIARY_POST_TYPE => $row->intermediary_type
104
+ ),
105
+ Toolset_Relationship_Definition::DA_OWNERSHIP => $row->ownership,
106
+ Toolset_Relationship_Definition::DA_IS_DISTINCT => (bool) $row->is_distinct,
107
+ Toolset_Relationship_Definition::DA_SCOPE => maybe_unserialize( $row->scope ),
108
+ Toolset_Relationship_Definition::DA_ROLE_NAMES => array(
109
+ Toolset_Relationship_Role::PARENT => $row->role_name_parent,
110
+ Toolset_Relationship_Role::CHILD => $row->role_name_child,
111
+ Toolset_Relationship_Role::INTERMEDIARY => $row->role_name_intermediary,
112
+ ),
113
+ Toolset_Relationship_Definition::DA_NEEDS_LEGACY_SUPPORT => (bool) $row->needs_legacy_support,
114
+ Toolset_Relationship_Definition::DA_IS_ACTIVE => (bool) $row->is_active,
115
+ Toolset_Relationship_Definition::DA_ORIGIN => maybe_unserialize( $row->origin ),
116
+ );
117
+
118
+ return $definition_array;
119
+ }
120
+
121
+
122
+ /**
123
+ * Load a single relationship definition from a definition array.
124
+ *
125
+ * @param array $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
+
132
+ //try {
133
+ $definition_array = $this->from_database_row_to_definition_array( $database_row );
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
+
144
+ /**
145
+ * Get an array of formats for $wpdb when working with the database row generated by this class.
146
+ *
147
+ * @return string[]
148
+ */
149
+ public function get_database_row_formats() {
150
+ return array(
151
+ '%s', // slug
152
+ '%s', // display_name_plural
153
+ '%s', // display_name_singular
154
+ '%s', // driver
155
+ '%s', // parent_domain
156
+ '%d', // parent_types
157
+ '%s', // child_domain
158
+ '%d', // child_types
159
+ '%s', // intermediary_type
160
+ '%d', // ownership
161
+ '%d', // cardinality_parent_max
162
+ '%d', // cardinality_parent_min
163
+ '%d', // cardinality_child_max
164
+ '%d', // cardinality_child_min
165
+ '%d', // is_distinct
166
+ '%s', // scope
167
+ '%s', // origin
168
+ '%s', // role_name_parent
169
+ '%s', // role_name_child
170
+ '%s', // role_name_intermediary
171
+ '%d', // needs_legacy_support
172
+ '%d', // is_active
173
+ );
174
+ }
175
+
176
+
177
+ }
vendor/toolset/toolset-common/inc/m2m/driver.php CHANGED
@@ -94,7 +94,7 @@ class Toolset_Relationship_Driver extends Toolset_Relationship_Driver_Base {
94
  );
95
 
96
  foreach ( $insert_results as $language_code => $insert_result ) {
97
- foreach ( Toolset_Relationship_Role::all() as $role_name ) {
98
  $element_sources[ $role_name ][ $language_code ] = $insert_result['elements'][ $role_name ];
99
  }
100
  }
@@ -230,7 +230,7 @@ class Toolset_Relationship_Driver extends Toolset_Relationship_Driver_Base {
230
  $affected_rows = $wpdb->insert(
231
  Toolset_Relationship_Table_Name::associations(),
232
  array(
233
- 'relationship' => $this->get_relationship_slug(),
234
  'parent_id' => $elements[ Toolset_Relationship_Role::PARENT ],
235
  'child_id' => $elements[ Toolset_Relationship_Role::CHILD ],
236
  'intermediary_id' => $elements[ Toolset_Relationship_Role::INTERMEDIARY ],
94
  );
95
 
96
  foreach ( $insert_results as $language_code => $insert_result ) {
97
+ foreach ( Toolset_Relationship_Role::all_role_names() as $role_name ) {
98
  $element_sources[ $role_name ][ $language_code ] = $insert_result['elements'][ $role_name ];
99
  }
100
  }
230
  $affected_rows = $wpdb->insert(
231
  Toolset_Relationship_Table_Name::associations(),
232
  array(
233
+ 'relationship_id' => $this->get_relationship_definition()->get_row_id(),
234
  'parent_id' => $elements[ Toolset_Relationship_Role::PARENT ],
235
  'child_id' => $elements[ Toolset_Relationship_Role::CHILD ],
236
  'intermediary_id' => $elements[ Toolset_Relationship_Role::INTERMEDIARY ],
vendor/toolset/toolset-common/inc/m2m/element_type.php CHANGED
@@ -18,7 +18,12 @@ class Toolset_Relationship_Element_Type {
18
  /** @var string[] Possible element types within the domain. */
19
  private $types;
20
 
 
21
  // Currently, only posts are supported.
 
 
 
 
22
  const DOMAIN_POSTS = 'posts';
23
 
24
 
18
  /** @var string[] Possible element types within the domain. */
19
  private $types;
20
 
21
+
22
  // Currently, only posts are supported.
23
+
24
+ /**
25
+ * @deprecated Use Toolset_Element_Domain::POSTS instead.
26
+ */
27
  const DOMAIN_POSTS = 'posts';
28
 
29
 
vendor/toolset/toolset-common/inc/m2m/i_definition.php CHANGED
@@ -95,7 +95,7 @@ interface IToolset_Relationship_Definition {
95
  /**
96
  * Get a relationship entity type.
97
  *
98
- * @param string $element_role
99
  *
100
  * @return Toolset_Relationship_Element_Type
101
  * @since m2m
@@ -106,7 +106,7 @@ interface IToolset_Relationship_Definition {
106
  /**
107
  * Determine if there are posts on the given side of the relationship.
108
  *
109
- * @param string $element_role
110
  *
111
  * @return bool
112
  * @since m2m
@@ -155,8 +155,8 @@ interface IToolset_Relationship_Definition {
155
  * So far, only native relationships are supported. In their case, an intermediary post is created automatically,
156
  * if the relationship requires it.
157
  *
158
- * @param int|WP_Post|Toolset_Element $parent Parent element (of matching domain, type and other conditions)
159
- * @param int|WP_Post|Toolset_Element $child Child element (of matching domain, type and other conditions)
160
  *
161
  * @return Toolset_Result|Toolset_Association_Base The newly created association or a negative Toolset_Result when it could not have been created.
162
  * @throws RuntimeException when the association cannot be created because of a known reason. The exception would
@@ -196,7 +196,7 @@ interface IToolset_Relationship_Definition {
196
  /**
197
  * Get a custom role name that should be recognized in shortcodes instead of parent, child, etc.
198
  *
199
- * @param string $role One of the Toolset_Relationship_Role values.
200
  *
201
  * @return string Custom role name.
202
  * @since m2m
@@ -218,7 +218,7 @@ interface IToolset_Relationship_Definition {
218
  *
219
  * The name will be sanitized and the value actually saved will be returned.
220
  *
221
- * @param string $role One of the Toolset_Relationship_Role values.
222
  * @param string $custom_name Custom name for the role.
223
  *
224
  * @return string Sanitized custom name
95
  /**
96
  * Get a relationship entity type.
97
  *
98
+ * @param string|IToolset_Relationship_Role $element_role
99
  *
100
  * @return Toolset_Relationship_Element_Type
101
  * @since m2m
106
  /**
107
  * Determine if there are posts on the given side of the relationship.
108
  *
109
+ * @param string|IToolset_Relationship_Role $element_role
110
  *
111
  * @return bool
112
  * @since m2m
155
  * So far, only native relationships are supported. In their case, an intermediary post is created automatically,
156
  * if the relationship requires it.
157
  *
158
+ * @param int|WP_Post|IToolset_Element $parent Parent element (of matching domain, type and other conditions)
159
+ * @param int|WP_Post|IToolset_Element $child Child element (of matching domain, type and other conditions)
160
  *
161
  * @return Toolset_Result|Toolset_Association_Base The newly created association or a negative Toolset_Result when it could not have been created.
162
  * @throws RuntimeException when the association cannot be created because of a known reason. The exception would
196
  /**
197
  * Get a custom role name that should be recognized in shortcodes instead of parent, child, etc.
198
  *
199
+ * @param string|IToolset_Relationship_Role $role One of the Toolset_Relationship_Role values.
200
  *
201
  * @return string Custom role name.
202
  * @since m2m
218
  *
219
  * The name will be sanitized and the value actually saved will be returned.
220
  *
221
+ * @param string|IToolset_Relationship_Role $role One of the Toolset_Relationship_Role values.
222
  * @param string $custom_name Custom name for the role.
223
  *
224
  * @return string Sanitized custom name
vendor/toolset/toolset-common/inc/m2m/potential_association/distinct_post_query.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Augments WP_Query to check whether posts are associated with a particular other element ID,
5
+ * and dismisses those posts.
6
+ *
7
+ * This is used in Toolset_Potential_Association_Query_Posts to handle distinct relationships.
8
+ *
9
+ * Both before_query() and after_query() methods need to be called as close to the actual
10
+ * querying as possible, otherwise things will get broken.
11
+ *
12
+ * @since m2m
13
+ */
14
+ class Toolset_Relationship_Distinct_Post_Query {
15
+
16
+ /** @var Toolset_Relationship_Definition */
17
+ private $relationship;
18
+
19
+ /** @var int */
20
+ private $for_element_id;
21
+
22
+ /** @var IToolset_Relationship_Role_Parent_Child */
23
+ private $target_role;
24
+
25
+ /** @var null|Toolset_Relationship_Table_Name */
26
+ private $_table_names;
27
+
28
+ /** @var null|wpdb */
29
+ private $_wpdb;
30
+
31
+
32
+ /**
33
+ * Toolset_Relationship_Distinct_Post_Query constructor.
34
+ *
35
+ * @param Toolset_Relationship_Definition $relationship
36
+ * @param IToolset_Relationship_Role_Parent_Child $target_role Target role of the relationships (future role of
37
+ * the posts that are being queried)
38
+ * @param int $for_element_id ID of the element to check against.
39
+ * @param Toolset_Relationship_Table_Name|null $table_names_di
40
+ * @param wpdb|null $wpdb_di
41
+ */
42
+ public function __construct(
43
+ Toolset_Relationship_Definition $relationship,
44
+ IToolset_Relationship_Role_Parent_Child $target_role,
45
+ $for_element_id,
46
+ Toolset_Relationship_Table_Name $table_names_di = null,
47
+ wpdb $wpdb_di = null
48
+ ) {
49
+ $this->relationship = $relationship;
50
+ $this->for_element_id = $for_element_id;
51
+ $this->target_role = $target_role;
52
+
53
+ $this->_table_names = $table_names_di;
54
+ $this->_wpdb = $wpdb_di;
55
+ }
56
+
57
+
58
+ private function is_actionable() {
59
+ return $this->relationship->is_distinct();
60
+ }
61
+
62
+
63
+ /**
64
+ * Hooks to filters in order to add extra clauses to the MySQL query.
65
+ */
66
+ public function before_query() {
67
+ if( ! $this->is_actionable() ) {
68
+ return;
69
+ }
70
+
71
+ add_filter( 'posts_join', array( $this, 'add_join_clauses' ) );
72
+
73
+ add_filter( 'posts_where', array( $this, 'add_where_clauses' ) );
74
+ }
75
+
76
+
77
+ /**
78
+ * Cleanup - unhooks the filters added in before_query().
79
+ */
80
+ public function after_query() {
81
+ if( ! $this->is_actionable() ) {
82
+ return;
83
+ }
84
+
85
+ remove_filter( 'posts_join', array( $this, 'add_join_clauses' ) );
86
+
87
+ remove_filter( 'posts_where', array( $this, 'add_where_clauses' ) );
88
+ }
89
+
90
+
91
+ private function get_table_names() {
92
+ if( null === $this->_table_names ) {
93
+ $this->_table_names = new Toolset_Relationship_Table_Name();
94
+ }
95
+
96
+ return $this->_table_names;
97
+ }
98
+
99
+
100
+ private function get_wpdb() {
101
+ if( null === $this->_wpdb ) {
102
+ global $wpdb;
103
+ $this->_wpdb = $wpdb;
104
+ }
105
+
106
+ return $this->_wpdb;
107
+ }
108
+
109
+
110
+ /**
111
+ * Add a JOIN clause to the WP_Query's MySQL query string.
112
+ *
113
+ * That will connect the row from the associations table, if there is an association
114
+ * with the correct relationship and the $for_element.
115
+ *
116
+ * Otherwise, those columns will be NULL, because we're doing a LEFT JOIN here.
117
+ *
118
+ * @param string $join
119
+ *
120
+ * @return string
121
+ */
122
+ public function add_join_clauses( $join ) {
123
+ $association_table = $this->get_table_names()->association_table();
124
+ $posts_table_name = $this->get_wpdb()->posts;
125
+ $target_element_column = $this->target_role->get_name() . '_id';
126
+ $for_element_column = $this->target_role->other() . '_id';
127
+
128
+ $join .= $this->get_wpdb()->prepare(
129
+ " LEFT JOIN {$association_table} AS toolset_associations ON (
130
+ toolset_associations.relationship_id = %d
131
+ AND toolset_associations.{$target_element_column} = {$posts_table_name}.ID
132
+ AND toolset_associations.{$for_element_column} = %d
133
+ ) ",
134
+ $this->relationship->get_row_id(),
135
+ $this->for_element_id
136
+ );
137
+
138
+ return $join;
139
+ }
140
+
141
+
142
+ /**
143
+ * Add a WHERE clause to the WP_Query's MySQL query string.
144
+ *
145
+ * After adding the JOIN, we only need to check that there's not an ID of the
146
+ * column with $for_element: That means there's no association between the queried
147
+ * post and $for_element, and we can offer the post as a result.
148
+ *
149
+ * @param string $where
150
+ *
151
+ * @return string
152
+ */
153
+ public function add_where_clauses( $where ) {
154
+ $for_element_column = $this->target_role->other() . '_id';
155
+ $where .= " AND ( toolset_associations.{$for_element_column} IS NULL ) ";
156
+ return $where;
157
+ }
158
+
159
+ }
vendor/toolset/toolset-common/inc/m2m/potential_association/query_factory.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Factory for IToolset_Potentional_Association_Query.
5
+ *
6
+ * Detects the target domain and returns the proper factory instance.
7
+ *
8
+ * @since m2m
9
+ */
10
+ class Toolset_Potential_Association_Query_Factory {
11
+
12
+ /**
13
+ * @param IToolset_Relationship_Definition $for_relationship
14
+ * @param IToolset_Relationship_Role $for_role
15
+ * @param IToolset_Element $for_element
16
+ * @param array $args
17
+ *
18
+ * @return IToolset_Potential_Association_Query
19
+ * @throws RuntimeException
20
+ */
21
+ public function create(
22
+ IToolset_Relationship_Definition $for_relationship,
23
+ IToolset_Relationship_Role $for_role,
24
+ IToolset_Element $for_element,
25
+ $args = array()
26
+ ) {
27
+ $target_domain = $for_relationship->get_element_type( $for_role->get_name() )->get_domain();
28
+
29
+ switch( $target_domain ) {
30
+ case Toolset_Relationship_Element_Type::DOMAIN_POSTS:
31
+ return new Toolset_Potential_Association_Query_Posts( $for_relationship, $for_role, $for_element, $args );
32
+ break;
33
+ default:
34
+ throw new RuntimeException( 'Not implemented.' );
35
+ }
36
+ }
37
+
38
+ }
vendor/toolset/toolset-common/inc/m2m/potential_association/query_interface.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * When you have a relationship and a specific element in one role, this
5
+ * query class will help you to find elements that can be associated with it.
6
+ *
7
+ * It takes into account all the aspects, like whether the relationship is distinct or not.
8
+ *
9
+ * @since m2m
10
+ */
11
+ interface IToolset_Potential_Association_Query extends IToolset_Query {
12
+
13
+ /**
14
+ * IToolset_Potential_Association_Query constructor.
15
+ *
16
+ * @param IToolset_Relationship_Definition $relationship
17
+ * @param IToolset_Relationship_Role_Parent_Child $target_role
18
+ * @param IToolset_Element $for_element
19
+ * @param array $args
20
+ * @param Toolset_Relationship_Query_Factory|null $query_factory_di
21
+ */
22
+ public function __construct(
23
+ IToolset_Relationship_Definition $relationship,
24
+ IToolset_Relationship_Role_Parent_Child $target_role,
25
+ IToolset_Element $for_element,
26
+ $args,
27
+ Toolset_Relationship_Query_Factory $query_factory_di = null
28
+ );
29
+
30
+
31
+ /**
32
+ * @return IToolset_Element[]
33
+ */
34
+ public function get_results();
35
+
36
+
37
+ /**
38
+ * @return int
39
+ */
40
+ public function get_found_elements();
41
+
42
+ }
vendor/toolset/toolset-common/inc/m2m/potential_association/query_posts.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * When you have a relationship and a specific element in one role, this
5
+ * query class will help you to find elements that can be associated with it.
6
+ *
7
+ * It takes into account all the aspects, like whether the relationship is distinct or not.
8
+ *
9
+ * This class works for querying posts (disregarding the domain of the element to connect to).
10
+ *
11
+ * Note that relationship cardinality limitation is not checked in get_results(). It is assumed that
12
+ * they've been checked before even querying for posts to associate.
13
+ *
14
+ * @since m2m
15
+ */
16
+ class Toolset_Potential_Association_Query_Posts implements IToolset_Potential_Association_Query {
17
+
18
+ /** @var IToolset_Relationship_Definition */
19
+ private $relationship;
20
+
21
+ /** @var IToolset_Relationship_Role */
22
+ private $target_role;
23
+
24
+ /** @var IToolset_Element */
25
+ private $for_element;
26
+
27
+ /** @var array */
28
+ private $args;
29
+
30
+ /** @var int|null */
31
+ private $found_results;
32
+
33
+ /** @var Toolset_Relationship_Query_Factory */
34
+ private $query_factory;
35
+
36
+
37
+ /**
38
+ * Toolset_Potential_Association_Query constructor.
39
+ *
40
+ * @param IToolset_Relationship_Definition $relationship Relationship to query for.
41
+ * @param IToolset_Relationship_Role_Parent_Child $target_role Element role. Only parent or child are accepted.
42
+ * @param IToolset_Element $for_element Element that may be corrected with the result of the query.
43
+ * @param array $args Additional query arguments:
44
+ * - search_string: string
45
+ * - count_results: bool
46
+ * - items_per_page: int
47
+ * - page: int
48
+ * - wp_query_override: array
49
+ * @param Toolset_Relationship_Query_Factory|null $query_factory_di
50
+ */
51
+ public function __construct(
52
+ IToolset_Relationship_Definition $relationship,
53
+ IToolset_Relationship_Role_Parent_Child $target_role,
54
+ IToolset_Element $for_element,
55
+ $args,
56
+ Toolset_Relationship_Query_Factory $query_factory_di = null
57
+ ) {
58
+ $this->relationship = $relationship;
59
+ $this->for_element = $for_element;
60
+ $this->target_role = $target_role;
61
+ $this->args = $args;
62
+
63
+ if( $relationship->get_element_type( $target_role->get_name() )->get_domain() !== Toolset_Relationship_Element_Type::DOMAIN_POSTS ) {
64
+ throw new InvalidArgumentException( 'Target role has a wrong domain.' );
65
+ }
66
+
67
+ $this->query_factory = ( null === $query_factory_di ? new Toolset_Relationship_Query_Factory() : $query_factory_di );
68
+ }
69
+
70
+
71
+ /**
72
+ * @return IToolset_Post[]
73
+ */
74
+ public function get_results() {
75
+
76
+ $query_args = array(
77
+
78
+ // Performance ptimizations
79
+ //
80
+ //
81
+ 'ignore_sticky_posts' => true,
82
+ 'cache_results' => false,
83
+ 'update_post_meta_cache' => false,
84
+ 'update_post_term_cache' => false,
85
+ 'no_found_rows' => ! $this->needs_found_rows(),
86
+
87
+ // Relevant query args
88
+ //
89
+ //
90
+ 'post_type' => $this->get_target_post_types(),
91
+ 'post_status' => 'publish',
92
+ // just to make sure in case we mess with post_status in the future
93
+ 'perm' => 'readable',
94
+ // the common use case is to get post titles and IDs
95
+ 'fields' => 'all',
96
+
97
+ 'posts_per_page' => $this->get_items_per_page(),
98
+ 'paged' => $this->get_page()
99
+ );
100
+
101
+ $search_string = $this->get_search_string();
102
+ if( ! empty( $search_string ) ) {
103
+ $query_args['s'] = $search_string;
104
+ }
105
+
106
+ $query_args = array_merge( $query_args, $this->get_additional_wp_query_args() );
107
+
108
+ // For distinct relationships, we need to make sure that the returned posts
109
+ // aren't already associated with $for_element.
110
+ $augment_query_for_distinct_relationships = $this->query_factory->distinct_relationship_posts(
111
+ $this->relationship,
112
+ $this->target_role,
113
+ $this->for_element->get_id()
114
+ );
115
+
116
+ $augment_query_for_distinct_relationships->before_query();
117
+
118
+ $query = $this->query_factory->wp_query( $query_args );
119
+ $results = $query->get_posts();
120
+
121
+ $augment_query_for_distinct_relationships->after_query();
122
+
123
+ $this->found_results = (int) $query->found_posts;
124
+
125
+ return $this->transform_results( $results );
126
+ }
127
+
128
+
129
+ private function get_additional_wp_query_args() {
130
+ return toolset_ensarr( toolset_getarr( $this->args, 'wp_query_override' ) );
131
+ }
132
+
133
+
134
+ private function get_target_post_types() {
135
+ return $this->relationship->get_element_type( $this->target_role )->get_types();
136
+ }
137
+
138
+ private function needs_found_rows() {
139
+ return (bool) toolset_getarr( $this->args, 'count_results', false );
140
+ }
141
+
142
+
143
+ private function get_search_string() {
144
+ return toolset_getarr( $this->args, 'search_string' );
145
+ }
146
+
147
+
148
+ private function get_page() {
149
+ return (int) toolset_getarr( $this->args, 'page' );
150
+ }
151
+
152
+
153
+ private function get_items_per_page() {
154
+ $limit = (int) toolset_getarr( $this->args, 'items_per_page' );
155
+ if( $limit < 1 ) {
156
+ $limit = 10;
157
+ }
158
+
159
+ return $limit;
160
+ }
161
+
162
+
163
+ /**
164
+ * @param WP_Post[] $wp_posts
165
+ *
166
+ * @return IToolset_Post[]
167
+ */
168
+ private function transform_results( $wp_posts ) {
169
+ $results = array();
170
+ foreach( $wp_posts as $wp_post ) {
171
+ $results[] = Toolset_Element::get_instance(
172
+ Toolset_Field_Utils::DOMAIN_POSTS,
173
+ $wp_post
174
+ );
175
+ }
176
+
177
+ return $results;
178
+ }
179
+
180
+
181
+ /**
182
+ * @return int
183
+ */
184
+ public function get_found_elements() {
185
+ if( ! $this->needs_found_rows() ) {
186
+ throw new RuntimeException( 'The number of found elements is not available.' );
187
+ }
188
+ return $this->found_results;
189
+ }
190
+
191
+
192
+ /**
193
+ * Check whether a specific single element can be associated.
194
+ *
195
+ * The relationship, target role and the other element are those provided in the constructor.
196
+ *
197
+ * WIP
198
+ */
199
+ public function check_single_element() {
200
+ // todo move the logic from Toolset_Relationship_Definition here
201
+
202
+ throw new RuntimeException( 'Not implemented.' );
203
+ }
204
+
205
+
206
+
207
+ }
vendor/toolset/toolset-common/inc/m2m/query_factory.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Factory for instantiating query classes.
5
+ *
6
+ * Should be extendended for association query and all others within the m2m project.
7
+ *
8
+ * @since m2m
9
+ */
10
+ class Toolset_Relationship_Query_Factory {
11
+
12
+ /**
13
+ * @param $args
14
+ *
15
+ * @return Toolset_Relationship_Query
16
+ * @deprecated
17
+ */
18
+ public function relationships( $args ) {
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
25
+ * the posts that are being queried)
26
+ * @param int $for_element_id ID of the element to check against.
27
+ * @param Toolset_Relationship_Table_Name|null $table_names_di
28
+ * @param wpdb|null $wpdb_di
29
+ *
30
+ * @return Toolset_Relationship_Distinct_Post_Query
31
+ */
32
+ public function distinct_relationship_posts(
33
+ IToolset_Relationship_Definition $relationship,
34
+ IToolset_Relationship_Role_Parent_Child $target_role,
35
+ $for_element_id,
36
+ Toolset_Relationship_Table_Name $table_names_di = null,
37
+ wpdb $wpdb_di = null
38
+ ) {
39
+ return new Toolset_Relationship_Distinct_Post_Query(
40
+ $relationship,
41
+ $target_role,
42
+ $for_element_id,
43
+ $table_names_di,
44
+ $wpdb_di
45
+ );
46
+ }
47
+
48
+
49
+ /**
50
+ * @param array $args Query arguments.
51
+ *
52
+ * @return WP_Query
53
+ */
54
+ public function wp_query( $args ) {
55
+ return new WP_Query( $args );
56
+ }
57
+
58
+
59
+
60
+
61
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/abstract.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Condition for the Toolset_Relationship_Query_V2.
5
+ *
6
+ * Provides a wpdb instance to all its subclasses.
7
+ *
8
+ * @since m2m
9
+ */
10
+ abstract class Toolset_Relationship_Query_Condition implements IToolset_Relationship_Query_Condition {
11
+
12
+
13
+ /**
14
+ * By default, there is nothing to join.
15
+ *
16
+ * @return string
17
+ */
18
+ public function get_join_clause() {
19
+ return '';
20
+ }
21
+
22
+
23
+ /**
24
+ * Get the alias of the post type set table that's joined to the query for a given role.
25
+ *
26
+ * @param IToolset_Relationship_Role_Parent_Child $role
27
+ *
28
+ * @return string
29
+ */
30
+ protected function get_type_set_table_alias( $role ) {
31
+ // We're using the standard aliases that are always joined in by default.
32
+ switch( $role->get_name() ) {
33
+ case Toolset_Relationship_Role::PARENT:
34
+ return 'parent_types_table';
35
+ case Toolset_Relationship_Role::CHILD:
36
+ return 'child_types_table';
37
+ }
38
+
39
+ // This should never happen.
40
+ throw new RuntimeException();
41
+ }
42
+
43
+
44
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/and.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Chains multiple IToolset_Relationship_Query_Condition with AND.
5
+ *
6
+ * @since m2m
7
+ */
8
+ class Toolset_Relationship_Query_Condition_And extends Toolset_Relationship_Query_Condition_Operator {
9
+
10
+
11
+ /**
12
+ * @inheritdoc
13
+ *
14
+ * @return string
15
+ */
16
+ public function get_where_clause() {
17
+
18
+ if( empty( $this->conditions ) ) {
19
+ return '1 = 1';
20
+ }
21
+
22
+ $where_clauses = array();
23
+
24
+ foreach( $this->conditions as $condition ) {
25
+ $where_clauses[] = $condition->get_where_clause();
26
+ }
27
+
28
+ return ' ( ' . implode( ' ) AND ( ', $where_clauses ) . ' ) ';
29
+
30
+ }
31
+
32
+
33
+ /**
34
+ * @inheritdoc
35
+ *
36
+ * @param IToolset_Relationship_Query_Condition[] $conditions
37
+ *
38
+ * @return Toolset_Relationship_Query_Condition_And
39
+ */
40
+ protected function instantiate_self( $conditions ) {
41
+ return new self( $conditions );
42
+ }
43
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/has_active_types.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Condition that the relationship has at least one active post type in a given role (or another domain than posts).
5
+ *
6
+ * Note that if polymorphic relationships are introduced, a relationship with a mix of inactive and active post types
7
+ * in one role will pass the condition but it will not have the information about the inactive types. That may become
8
+ * an issue when editing relationships (however, there a query is not used, but relationships are loaded directly).
9
+ *
10
+ * @since 2.5.4
11
+ */
12
+ class Toolset_Relationship_Query_Condition_Has_Active_Types extends Toolset_Relationship_Query_Condition {
13
+
14
+
15
+ /** @var bool */
16
+ private $only_active_types;
17
+
18
+
19
+ /** @var IToolset_Relationship_Role_Parent_Child */
20
+ protected $for_role;
21
+
22
+
23
+ /** @var Toolset_Relationship_Database_Operations */
24
+ private $database_operations;
25
+
26
+
27
+ /** @var Toolset_Post_Type_Query_Factory */
28
+ private $post_type_query_factory;
29
+
30
+
31
+ /**
32
+ * Toolset_Relationship_Query_Condition_Has_Active_Types constructor.
33
+ *
34
+ * @param bool $only_active_types
35
+ * @param IToolset_Relationship_Role_Parent_Child $for_role
36
+ * @param Toolset_Relationship_Database_Operations|null $database_operations_di
37
+ * @param Toolset_Post_Type_Query_Factory|null $post_type_query_factory_di
38
+ */
39
+ public function __construct(
40
+ $only_active_types,
41
+ IToolset_Relationship_Role_Parent_Child $for_role,
42
+ Toolset_Relationship_Database_Operations $database_operations_di = null,
43
+ Toolset_Post_Type_Query_Factory $post_type_query_factory_di = null
44
+ ) {
45
+ if( ! is_bool( $only_active_types ) ) {
46
+ throw new InvalidArgumentException();
47
+ }
48
+
49
+ $this->only_active_types = $only_active_types;
50
+ $this->for_role = $for_role;
51
+
52
+ $this->database_operations = (
53
+ null === $database_operations_di
54
+ ? new Toolset_Relationship_Database_Operations()
55
+ : $database_operations_di
56
+ );
57
+
58
+ $this->post_type_query_factory = (
59
+ null === $post_type_query_factory_di
60
+ ? new Toolset_Post_Type_Query_Factory()
61
+ : $post_type_query_factory_di
62
+ );
63
+ }
64
+
65
+ /**
66
+ * Get a part of the WHERE clause that applies the condition.
67
+ *
68
+ * @return string Valid part of a MySQL query, so that it can be
69
+ * used in WHERE ( $condition1 ) AND ( $condition2 ) AND ( $condition3 ) ...
70
+ */
71
+ public function get_where_clause() {
72
+
73
+ if( ! $this->only_active_types ) {
74
+ return '1 = 1';
75
+ }
76
+
77
+ $active_post_types = $this->get_active_post_type_slugs();
78
+ $type_set_table_alias = $this->get_type_set_table_alias( $this->for_role );
79
+ $domain_column_name = $this->database_operations->role_to_column(
80
+ $this->for_role,
81
+ Toolset_Relationship_Database_Operations::COLUMN_DOMAIN
82
+ );
83
+
84
+ $query = sprintf(
85
+ "(
86
+ relationships.{$domain_column_name} != '%s'
87
+ OR {$type_set_table_alias}.type IN ( '" . implode( "', '", esc_sql( $active_post_types ) ) . "' )
88
+ )",
89
+ Toolset_Element_Domain::POSTS
90
+ );
91
+
92
+ return $query;
93
+ }
94
+
95
+
96
+ /**
97
+ * @return string[] Slugs of active post types.
98
+ */
99
+ private function get_active_post_type_slugs() {
100
+
101
+ $post_type_query = $this->post_type_query_factory->create( array(
102
+ Toolset_Post_Type_Query::IS_REGISTERED => true,
103
+ Toolset_Post_Type_Query::RETURN_TYPE => 'slug'
104
+ ) );
105
+
106
+ $active_post_types = $post_type_query->get_results();
107
+
108
+ return $active_post_types;
109
+ }
110
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/has_domain.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Condition that a relationship involves a certain element domain.
5
+ *
6
+ * @since m2m
7
+ */
8
+ class Toolset_Relationship_Query_Condition_Has_Domain extends Toolset_Relationship_Query_Condition {
9
+
10
+
11
+ /** @var string */
12
+ private $domain_name;
13
+
14
+
15
+ /** @var IToolset_Relationship_Role_Parent_Child */
16
+ private $role;
17
+
18
+
19
+ /** @var Toolset_Relationship_Database_Operations */
20
+ private $database_operations;
21
+
22
+
23
+ /**
24
+ * Toolset_Relationship_Query_Condition_Has_Domain constructor.
25
+ *
26
+ * @param string $domain_name One of the Toolset_Field_Utils::DOMAIN_* values.
27
+ * @param IToolset_Relationship_Role_Parent_Child $role
28
+ * @param Toolset_Relationship_Database_Operations|null $database_operations_di
29
+ */
30
+ public function __construct(
31
+ $domain_name, IToolset_Relationship_Role_Parent_Child $role,
32
+ Toolset_Relationship_Database_Operations $database_operations_di = null
33
+ ) {
34
+ if( ! is_string( $domain_name ) || ! in_array( $domain_name, Toolset_Element_Domain::all() ) ) {
35
+ throw new InvalidArgumentException();
36
+ }
37
+
38
+ $this->domain_name = $domain_name;
39
+
40
+ $this->role = $role;
41
+
42
+ $this->database_operations = (
43
+ null === $database_operations_di
44
+ ? new Toolset_Relationship_Database_Operations()
45
+ : $database_operations_di
46
+ );
47
+ }
48
+
49
+
50
+ /**
51
+ * @inheritdoc
52
+ *
53
+ * @return string
54
+ */
55
+ public function get_where_clause() {
56
+ $column_name = $this->database_operations->role_to_column(
57
+ $this->role, Toolset_Relationship_Database_Operations::COLUMN_DOMAIN
58
+ );
59
+
60
+ return sprintf(
61
+ "relationships.{$column_name} = '%s'",
62
+ esc_sql( $this->domain_name )
63
+ );
64
+ }
65
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/i_condition.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Represents a single condition for the Tooset_Relationship_Query_V2.
5
+ *
6
+ * @since m2m
7
+ */
8
+ interface IToolset_Relationship_Query_Condition {
9
+
10
+ /**
11
+ * Get a part of the WHERE clause that applies the condition.
12
+ *
13
+ * @return string Valid part of a MySQL query, so that it can be
14
+ * used in WHERE ( $condition1 ) AND ( $condition2 ) AND ( $condition3 ) ...
15
+ */
16
+ public function get_where_clause();
17
+
18
+
19
+ /**
20
+ * Get a part of the JOIN clause that is required by the condition.
21
+ *
22
+ * @return string Valid part of a MySQL query, so that it can be
23
+ * used as: $table_as_unique_alias_on_condition_1 $table_as_unique_alias_on_condition_2 ...
24
+ * (meaning that every clause should start with its own "JOIN"
25
+ */
26
+ public function get_join_clause();
27
+
28
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/is_active.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Condition that a relationship is active.
5
+ *
6
+ * @since m2m
7
+ */
8
+ class Toolset_Relationship_Query_Condition_Is_Active extends Toolset_Relationship_Query_Condition_Is_Boolean_Flag {
9
+
10
+
11
+ protected function get_flag_column_name() {
12
+ return 'is_active';
13
+ }
14
+
15
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/is_boolean_flag.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abstract condition for querying by a boolean flag stored as 1/0.
5
+ *
6
+ * @since 2.5.4
7
+ */
8
+ abstract class Toolset_Relationship_Query_Condition_Is_Boolean_Flag extends Toolset_Relationship_Query_Condition {
9
+
10
+
11
+ private $flag_value;
12
+
13
+
14
+ /**
15
+ * Toolset_Relationship_Query_Condition_Is_Active constructor.
16
+ *
17
+ * @param bool|string $flag_value '*' will match anything.
18
+ */
19
+ public function __construct( $flag_value ) {
20
+
21
+ if( ! is_bool( $flag_value ) && '*' !== $flag_value ) {
22
+ throw new InvalidArgumentException();
23
+ }
24
+
25
+ $this->flag_value = $flag_value;
26
+ }
27
+
28
+
29
+ /**
30
+ * @inheritdoc
31
+ * @return string
32
+ */
33
+ public function get_where_clause() {
34
+
35
+ if( '*' === $this->flag_value ) {
36
+ return '1 = 1';
37
+ }
38
+
39
+ $required_value = ( $this->flag_value ? 1 : 0 );
40
+
41
+ $condition = sprintf(
42
+ "relationships.{$this->get_flag_column_name()} = %d",
43
+ $required_value
44
+ );
45
+
46
+ return $condition;
47
+ }
48
+
49
+
50
+ /**
51
+ * @return string Name of the database column to query by.
52
+ */
53
+ protected abstract function get_flag_column_name();
54
+
55
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/is_legacy.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Condition that a relationship needs legacy support (because it was migrated
5
+ * from the legacy implementation).
6
+ *
7
+ * @since m2m
8
+ */
9
+ class Toolset_Relationship_Query_Condition_Is_Legacy extends Toolset_Relationship_Query_Condition_Is_Boolean_Flag {
10
+
11
+
12
+ protected function get_flag_column_name() {
13
+ return 'needs_legacy_support';
14
+ }
15
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/operator.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abstract condition for implementing operators in the MySQL query.
5
+ *
6
+ * @since 2.5.4
7
+ */
8
+ abstract class Toolset_Relationship_Query_Condition_Operator implements IToolset_Relationship_Query_Condition {
9
+
10
+
11
+ /** @var IToolset_Relationship_Query_Condition[] */
12
+ protected $conditions = array();
13
+
14
+
15
+ /**
16
+ * Toolset_Relationship_Query_Condition_Operator constructor.
17
+ *
18
+ * @param IToolset_Relationship_Query_Condition[]|array $conditions If a nested array of conditions
19
+ * is provided, it will be handled as a nested $op ($op is the operation):
20
+ * ( $condition1 ) $op ( ( $condition2_1 ) $op ( $condition2_2 ) ) $op ...etc.
21
+ */
22
+ public function __construct( $conditions ) {
23
+ $this->add_conditions( $conditions );
24
+ }
25
+
26
+
27
+ /**
28
+ * @param IToolset_Relationship_Query_Condition[]|array $conditions
29
+ */
30
+ private function add_conditions( $conditions ) {
31
+ foreach( $conditions as $condition ) {
32
+ if( $condition instanceof IToolset_Relationship_Query_Condition ) {
33
+ $this->conditions[] = $condition;
34
+ } elseif( is_array( $condition ) ) {
35
+ if( count( $condition ) === 1 ) {
36
+ // single condition inside an array - it doesn't have to be nested in another condition
37
+ $this->add_conditions( $condition );
38
+ } else {
39
+ $this->conditions[] = $this->instantiate_self( $condition );
40
+ }
41
+ } else {
42
+ throw new InvalidArgumentException();
43
+ }
44
+ }
45
+ }
46
+
47
+
48
+ /**
49
+ * Just joins the join clauses from nested conditions
50
+ * @return string
51
+ */
52
+ public function get_join_clause() {
53
+ $join_clauses = '';
54
+
55
+ foreach( $this->conditions as $condition ) {
56
+ $join_clauses .= ' ' . $condition->get_join_clause() . ' ';
57
+ }
58
+
59
+ return $join_clauses;
60
+ }
61
+
62
+
63
+ /**
64
+ * Return an instance of self with provided conditions.
65
+ *
66
+ * Used for nesting when a nested array of conditions is passed to the constructor.
67
+ *
68
+ * @param IToolset_Relationship_Query_Condition[] $conditions
69
+ *
70
+ * @return IToolset_Relationship_Query_Condition
71
+ */
72
+ abstract protected function instantiate_self( $conditions );
73
+
74
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/or.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Chains multiple IToolset_Relationship_Query_Condition with OR.
5
+ *
6
+ * @since m2m
7
+ */
8
+ class Toolset_Relationship_Query_Condition_Or extends Toolset_Relationship_Query_Condition_Operator {
9
+
10
+
11
+ /**
12
+ * @inheritdoc
13
+ *
14
+ * @return string
15
+ */
16
+ public function get_where_clause() {
17
+
18
+ if( empty( $this->conditions ) ) {
19
+ return '1 = 1';
20
+ }
21
+
22
+ $clauses = array();
23
+ foreach( $this->conditions as $condition ) {
24
+ $clauses[] = $condition->get_where_clause();
25
+ }
26
+
27
+ $or_clause = ' ( ' . implode( ' ) OR ( ', $clauses ) . ' ) ';
28
+
29
+ return $or_clause;
30
+ }
31
+
32
+
33
+ /**
34
+ * @inheritdoc
35
+ * @param IToolset_Relationship_Query_Condition[] $conditions
36
+ *
37
+ * @return Toolset_Relationship_Query_Condition_Or
38
+ */
39
+ protected function instantiate_self( $conditions ) {
40
+ return new self( $conditions );
41
+ }
42
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/origin.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Condition that a relationship has a certain origin (was created through a wizard or as a
5
+ * post reference field or a repeatable field group).
6
+ *
7
+ * @since m2m
8
+ */
9
+ class Toolset_Relationship_Query_Condition_Origin extends Toolset_Relationship_Query_Condition {
10
+
11
+
12
+ /** @var string */
13
+ private $origin;
14
+
15
+
16
+ /**
17
+ * Toolset_Relationship_Query_Condition_Origin constructor.
18
+ *
19
+ * @param string $origin
20
+ * @throws InvalidArgumentException
21
+ */
22
+ public function __construct( $origin ) {
23
+ if( ! is_string( $origin ) || empty( $origin ) ) {
24
+ throw new InvalidArgumentException();
25
+ }
26
+
27
+ $this->origin = $origin;
28
+ }
29
+
30
+
31
+ /**
32
+ * @inheritdoc
33
+ * @return string
34
+ */
35
+ public function get_where_clause() {
36
+ return sprintf(
37
+ "relationship.origin = '%s'",
38
+ esc_sql( $this->origin )
39
+ );
40
+ }
41
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition/type.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Condition that a relationship involves a certain type in a certain relationship role.
5
+ *
6
+ * @since m2m
7
+ */
8
+ class Toolset_Relationship_Query_Condition_Type extends Toolset_Relationship_Query_Condition {
9
+
10
+
11
+ /** @var IToolset_Relationship_Role_Parent_Child */
12
+ private $role;
13
+
14
+ /** @var string */
15
+ private $type;
16
+
17
+
18
+ /**
19
+ * Toolset_Relationship_Query_Condition_Type constructor.
20
+ *
21
+ * @param string $type
22
+ * @param IToolset_Relationship_Role_Parent_Child $role What relationship role to query for
23
+ */
24
+ public function __construct(
25
+ $type, IToolset_Relationship_Role_Parent_Child $role
26
+ ) {
27
+ if( ! is_string( $type ) || empty( $type ) || sanitize_text_field( $type ) !== $type ) {
28
+ throw new InvalidArgumentException();
29
+ }
30
+
31
+ $this->type = $type;
32
+ $this->role = $role;
33
+ }
34
+
35
+
36
+ /**
37
+ * @inheritdoc
38
+ *
39
+ * @return string
40
+ */
41
+ public function get_where_clause() {
42
+ $where = sprintf(
43
+ "{$this->get_type_set_table_alias( $this->role )}.type = '%s'",
44
+ esc_sql( $this->type )
45
+ );
46
+
47
+ return $where;
48
+ }
49
+
50
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/condition_factory.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Factory of IToolset_Relationship_Query_Condition classes.
5
+ *
6
+ * @since 2.5.4
7
+ */
8
+ class Toolset_Relationship_Query_Condition_Factory {
9
+
10
+ /**
11
+ * Chain multiple conditions with OR.
12
+ *
13
+ * The whole statement will evaluate to true if at least one of provided conditions is true.
14
+ *
15
+ * @param IToolset_Relationship_Query_Condition[] $operands
16
+ * @return IToolset_Relationship_Query_Condition
17
+ */
18
+ public function do_or( $operands ) {
19
+ return new Toolset_Relationship_Query_Condition_Or( $operands );
20
+ }
21
+
22
+
23
+ /**
24
+ * Chain multiple conditions with AN.
25
+ *
26
+ * The whole statement will evaluate to true if all provided conditions are true.
27
+ *
28
+ * @param IToolset_Relationship_Query_Condition[] $operands
29
+ * @return IToolset_Relationship_Query_Condition
30
+ */
31
+ public function do_and( $operands ) {
32
+ return new Toolset_Relationship_Query_Condition_And( $operands );
33
+ }
34
+
35
+
36
+ /**
37
+ * Condition that the relationship involves a certain domain.
38
+ *
39
+ * @param string $domain_name 'posts'|'users'|'terms'
40
+ * @param IToolset_Relationship_Role_Parent_Child $in_role
41
+ *
42
+ * @return IToolset_Relationship_Query_Condition
43
+ */
44
+ public function has_domain( $domain_name, IToolset_Relationship_Role_Parent_Child $in_role ) {
45
+ return new Toolset_Relationship_Query_Condition_Has_Domain( $domain_name, $in_role );
46
+ }
47
+
48
+
49
+ /**
50
+ * Condition that the relationship comes from a certain source
51
+ *
52
+ * @param string $origin
53
+ *
54
+ * @return Toolset_Relationship_Query_Condition_Origin
55
+ */
56
+ public function origin( $origin ) {
57
+ return new Toolset_Relationship_Query_Condition_Origin( $origin );
58
+ }
59
+
60
+
61
+ /**
62
+ * Condition that the relationship has a certain type in a given role.
63
+ *
64
+ * @param string $type
65
+ * @param IToolset_Relationship_Role_Parent_Child $in_role
66
+ *
67
+ * @return IToolset_Relationship_Query_Condition
68
+ */
69
+ public function has_type( $type, IToolset_Relationship_Role_Parent_Child $in_role ) {
70
+ return new Toolset_Relationship_Query_Condition_Type( $type, $in_role );
71
+ }
72
+
73
+
74
+ /**
75
+ * Condition that the relationship was migrated from the legacy implementation.
76
+ *
77
+ * @param bool $should_be_legacy
78
+ *
79
+ * @return IToolset_Relationship_Query_Condition
80
+ */
81
+ public function is_legacy( $should_be_legacy = true ) {
82
+ return new Toolset_Relationship_Query_Condition_Is_Legacy( $should_be_legacy );
83
+ }
84
+
85
+
86
+ /**
87
+ * Condition that the relationship is active.
88
+ *
89
+ * @param bool $should_be_active
90
+ *
91
+ * @return IToolset_Relationship_Query_Condition
92
+ */
93
+ public function is_active( $should_be_active = true ) {
94
+ return new Toolset_Relationship_Query_Condition_Is_Active( $should_be_active );
95
+ }
96
+
97
+
98
+ /**
99
+ * Condition that the relationship has at least one active post type in a given role (or another domain than posts).
100
+ *
101
+ * @param bool $has_active_post_types
102
+ * @param IToolset_Relationship_Role_Parent_Child $in_role
103
+ *
104
+ * @return IToolset_Relationship_Query_Condition|Toolset_Relationship_Query_Condition_Has_Active_Types
105
+ */
106
+ public function has_active_post_types( $has_active_post_types, IToolset_Relationship_Role_Parent_Child $in_role ) {
107
+ return new Toolset_Relationship_Query_Condition_Has_Active_Types( $has_active_post_types, $in_role );
108
+ }
109
+
110
+
111
+ }
vendor/toolset/toolset-common/inc/m2m/{relationship_query.php → relationship_query/relationship_query.php} RENAMED
@@ -19,6 +19,8 @@
19
  * submit a merge request rather than going around the query and touching the database directly.
20
  *
21
  * @since m2m
 
 
22
  */
23
  class Toolset_Relationship_Query extends Toolset_Relationship_Query_Base {
24
 
@@ -84,9 +86,16 @@ class Toolset_Relationship_Query extends Toolset_Relationship_Query_Base {
84
  /**
85
  * @inheritdoc
86
  * @return Toolset_Relationship_Definition[]
 
87
  */
88
  public function get_results() {
89
 
 
 
 
 
 
 
90
  if ( $this->use_cached_results ) {
91
  $cache = Toolset_Relationship_Query_Cache::get_instance();
92
  $value = $cache->get( $this->query, $this->get_subject_name_for_cache() );
@@ -107,6 +116,7 @@ class Toolset_Relationship_Query extends Toolset_Relationship_Query_Base {
107
  }
108
 
109
  return $results;
 
110
  }
111
 
112
 
@@ -145,7 +155,7 @@ class Toolset_Relationship_Query extends Toolset_Relationship_Query_Base {
145
 
146
  $domain_query = $this->get_query_var( self::QUERY_HAS_DOMAIN );
147
 
148
- foreach ( Toolset_Relationship_Role::parent_child() as $element_role ) {
149
  $domain = $relationship_definition->get_element_type( $element_role )->get_domain();
150
  if ( $domain_query == $domain ) {
151
  return true;
@@ -172,7 +182,7 @@ class Toolset_Relationship_Query extends Toolset_Relationship_Query_Base {
172
  $target_types[0] = toolset_wraparr( $target_types[0] );
173
  $target_types['comparison'] = isset( $target_types['comparison'] ) ? $target_types['comparison'] : 'OR';
174
 
175
- foreach ( Toolset_Relationship_Role::parent_child() as $role ) {
176
  $element_type = $relationship_definition->get_element_type( $role );
177
  $types = $element_type->get_types();
178
 
@@ -207,7 +217,7 @@ class Toolset_Relationship_Query extends Toolset_Relationship_Query_Base {
207
  $target_domain = toolset_getarr( $type_query, 'domain' );
208
  $target_type = toolset_getarr( $type_query, 'type' );
209
 
210
- foreach ( Toolset_Relationship_Role::parent_child() as $role ) {
211
  $element_type = $relationship_definition->get_element_type( $role );
212
  $types = $element_type->get_types();
213
 
19
  * submit a merge request rather than going around the query and touching the database directly.
20
  *
21
  * @since m2m
22
+ *
23
+ * @deprecated Use Toolset_Relationship_Query_V2 instead.
24
  */
25
  class Toolset_Relationship_Query extends Toolset_Relationship_Query_Base {
26
 
86
  /**
87
  * @inheritdoc
88
  * @return Toolset_Relationship_Definition[]
89
+ * @deprecated Use Toolset_Relationship_Query_V2 instead.
90
  */
91
  public function get_results() {
92
 
93
+ /* _doing_it_wrong(
94
+ 'Toolset_Relationship_Query::get_results',
95
+ 'Toolset_Relationship_Query is deprecated in favor of Toolset_Relationship_Query_V2',
96
+ ''
97
+ ); */
98
+
99
  if ( $this->use_cached_results ) {
100
  $cache = Toolset_Relationship_Query_Cache::get_instance();
101
  $value = $cache->get( $this->query, $this->get_subject_name_for_cache() );
116
  }
117
 
118
  return $results;
119
+
120
  }
121
 
122
 
155
 
156
  $domain_query = $this->get_query_var( self::QUERY_HAS_DOMAIN );
157
 
158
+ foreach ( Toolset_Relationship_Role::parent_child_role_names() as $element_role ) {
159
  $domain = $relationship_definition->get_element_type( $element_role )->get_domain();
160
  if ( $domain_query == $domain ) {
161
  return true;
182
  $target_types[0] = toolset_wraparr( $target_types[0] );
183
  $target_types['comparison'] = isset( $target_types['comparison'] ) ? $target_types['comparison'] : 'OR';
184
 
185
+ foreach ( Toolset_Relationship_Role::parent_child_role_names() as $role ) {
186
  $element_type = $relationship_definition->get_element_type( $role );
187
  $types = $element_type->get_types();
188
 
217
  $target_domain = toolset_getarr( $type_query, 'domain' );
218
  $target_type = toolset_getarr( $type_query, 'type' );
219
 
220
+ foreach ( Toolset_Relationship_Role::parent_child_role_names() as $role ) {
221
  $element_type = $relationship_definition->get_element_type( $role );
222
  $types = $element_type->get_types();
223
 
vendor/toolset/toolset-common/inc/m2m/relationship_query/relationship_query_v2.php ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Relationship query class with a more OOP/functional approach.
5
+ *
6
+ * Replaces Toolset_Relationship_Query.
7
+ *
8
+ * Allows for chaining query conditions and avoiding passing query arguments as associative arrays.
9
+ * It makes it also possible to build queries with nested AND & OR statements in an arbitrary way.
10
+ * The object model may be complex but all the complexity is hidden from the user, they need to know
11
+ * only the methods on this class.
12
+ *
13
+ * Example usage:
14
+ *
15
+ * $query = new Toolset_Relationship_Query_V2();
16
+ *
17
+ * $results = $query
18
+ * ->add(
19
+ * $query->has_domain( 'posts' )
20
+ * )
21
+ * ->add(
22
+ * $query->do_or(
23
+ * $query->has_type( 'attachment', new Toolset_Relationship_Role_Parent() ),
24
+ * $query->do_and(
25
+ * $query->has_type( 'page', new Toolset_Relationship_Role_Parent() ),
26
+ * $query->is_legacy( false )
27
+ * )
28
+ * )
29
+ * )
30
+ * ->add( $query->is_active( '*' ) )
31
+ * ->get_results();
32
+ *
33
+ * Note:
34
+ * - If no is_active() condition is provided on the top level, 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 provided on the top level, has_active_post_types(true) is used
37
+ * for both parent and child role.
38
+ *
39
+ * @since m2m
40
+ */
41
+ class Toolset_Relationship_Query_V2 implements IToolset_Query {
42
+
43
+
44
+ /** @var IToolset_Relationship_Query_Condition[] */
45
+ private $conditions = array();
46
+
47
+ /** @var wpdb */
48
+ private $wpdb;
49
+
50
+ /** @var Toolset_Relationship_Definition_Translator */
51
+ private $definition_translator;
52
+
53
+
54
+ private $should_add_default_conditions = true;
55
+ private $has_is_active_condition = false;
56
+ private $has_is_post_type_active_condition = false;
57
+
58
+
59
+ /** @var Toolset_Relationship_Database_Unique_Table_Alias */
60
+ private $unique_table_alias;
61
+
62
+
63
+ /** @var Toolset_Relationship_Query_Sql_Expression_Builder */
64
+ private $expression_builder;
65
+
66
+
67
+ /** @var Toolset_Relationship_Query_Condition_Factory */
68
+ private $condition_factory;
69
+
70
+
71
+ /**
72
+ * Toolset_Relationship_Query_V2 constructor.
73
+ *
74
+ * @param wpdb|null $wpdb_di
75
+ * @param Toolset_Relationship_Definition_Translator|null $definition_translator_di
76
+ * @param Toolset_Relationship_Database_Unique_Table_Alias|null $unique_table_alias_di
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,
83
+ Toolset_Relationship_Definition_Translator $definition_translator_di = null,
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 ) {
91
+ global $wpdb;
92
+ $this->wpdb = $wpdb;
93
+ } else {
94
+ $this->wpdb = $wpdb_di;
95
+ }
96
+
97
+ $this->definition_translator = (
98
+ null === $definition_translator_di
99
+ ? new Toolset_Relationship_Definition_Translator()
100
+ : $definition_translator_di
101
+ );
102
+
103
+ $this->unique_table_alias = (
104
+ null === $unique_table_alias_di
105
+ ? new Toolset_Relationship_Database_Unique_Table_Alias()
106
+ : $unique_table_alias_di
107
+ );
108
+
109
+ $this->expression_builder = (
110
+ null === $expression_builder_di
111
+ ? new Toolset_Relationship_Query_Sql_Expression_Builder()
112
+ : $expression_builder_di
113
+ );
114
+
115
+ $this->condition_factory = (
116
+ null === $condition_factory_di
117
+ ? new Toolset_Relationship_Query_Condition_Factory()
118
+ : $condition_factory_di
119
+ );
120
+ }
121
+
122
+
123
+ /**
124
+ * Add another condition to the query.
125
+ *
126
+ * @param IToolset_Relationship_Query_Condition $condition
127
+ *
128
+ * @return $this
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
+
144
+
145
+ /**
146
+ * Basically, this sets default query parameters.
147
+ *
148
+ * The method needs to stay idempotent.
149
+ */
150
+ private function add_default_conditions() {
151
+ if( ! $this->should_add_default_conditions ) {
152
+ return;
153
+ }
154
+
155
+ if( ! $this->has_is_active_condition ) {
156
+ $this->add( $this->is_active() );
157
+ }
158
+
159
+ if( ! $this->has_is_post_type_active_condition ) {
160
+ $this->add( $this->has_active_post_types() );
161
+ }
162
+ }
163
+
164
+
165
+ /**
166
+ * @return IToolset_Relationship_Query_Condition MySQL WHERE clause for the query.
167
+ */
168
+ private function build_root_condition() {
169
+ $this->add_default_conditions();
170
+ return $this->condition_factory->do_and( $this->conditions );
171
+ }
172
+
173
+
174
+ /**
175
+ * @return $this
176
+ */
177
+ public function do_not_add_default_conditions() {
178
+ $this->should_add_default_conditions = false;
179
+ return $this;
180
+ }
181
+
182
+
183
+ /**
184
+ * Apply stored conditions and perform the query.
185
+ *
186
+ * todo: Add the results to the relationship repository.
187
+ *
188
+ * @return IToolset_Relationship_Definition[]
189
+ */
190
+ public function get_results() {
191
+
192
+ $query = $this->build_sql_query();
193
+ $rows = toolset_ensarr( $this->wpdb->get_results( $query ) );
194
+
195
+ $results = array();
196
+ foreach( $rows as $row ) {
197
+ $definition = $this->definition_translator->from_database_row( $row );
198
+ $results[] = $definition;
199
+ /*if( null != $definition ) {
200
+ $this->insert_definition( $definition );
201
+ }*/
202
+ }
203
+
204
+ return $results;
205
+ }
206
+
207
+
208
+ /**
209
+ * Build a complete MySQL query from the conditions.
210
+ *
211
+ * @return string
212
+ */
213
+ private function build_sql_query() {
214
+ $root_condition = $this->build_root_condition();
215
+ return $this->expression_builder->build( $root_condition );
216
+ }
217
+
218
+
219
+ /**
220
+ * Chain multiple conditions with OR.
221
+ *
222
+ * The whole statement will evaluate to true if at least one of provided conditions is true.
223
+ *
224
+ * @param IToolset_Relationship_Query_Condition[] [$condition1, $condition2, ...]
225
+ * @return IToolset_Relationship_Query_Condition
226
+ */
227
+ public function do_or() {
228
+ return $this->condition_factory->do_or( func_get_args() );
229
+ }
230
+
231
+
232
+ /**
233
+ * Chain multiple conditions with AN.
234
+ *
235
+ * The whole statement will evaluate to true if all provided conditions are true.
236
+ *
237
+ * @param IToolset_Relationship_Query_Condition[] [$condition1, $condition2, ...]
238
+ * @return IToolset_Relationship_Query_Condition
239
+ */
240
+ public function do_and() {
241
+ return $this->condition_factory->do_and( func_get_args() );
242
+ }
243
+
244
+
245
+ /**
246
+ * Condition that the relationship involves a certain domain.
247
+ *
248
+ * @param string $domain_name 'posts'|'users'|'terms'
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
+ *
252
+ * @return IToolset_Relationship_Query_Condition
253
+ */
254
+ public function has_domain( $domain_name, $in_role = null ) {
255
+ if( null === $in_role ) {
256
+ return $this->do_or(
257
+ $this->has_domain( $domain_name, new Toolset_Relationship_Role_Parent() ),
258
+ $this->has_domain( $domain_name, new Toolset_Relationship_Role_Child() )
259
+ );
260
+ }
261
+
262
+ return $this->condition_factory->has_domain( $domain_name, $in_role );
263
+ }
264
+
265
+
266
+ /**
267
+ * Condition that the relationship comes from a certain source
268
+ *
269
+ * @param string $origin
270
+ *
271
+ * @return Toolset_Relationship_Query_Condition_Origin
272
+ */
273
+ public function origin( $origin ) {
274
+ return $this->condition_factory->origin( $origin );
275
+ }
276
+
277
+
278
+ /**
279
+ * Condition that the relationship has a certain type in a given role.
280
+ *
281
+ * @param string $type
282
+ * @param IToolset_Relationship_Role_Parent_Child|null $in_role If null is provided, the type
283
+ * can be in both parent or child role for the condition to be true.
284
+ *
285
+ * @return IToolset_Relationship_Query_Condition
286
+ */
287
+ public function has_type( $type, $in_role = null ) {
288
+ if( null === $in_role ) {
289
+ return $this->do_or(
290
+ $this->has_type( $type, new Toolset_Relationship_Role_Parent() ),
291
+ $this->has_type( $type, new Toolset_Relationship_Role_Child() )
292
+ );
293
+ }
294
+
295
+ return $this->condition_factory->has_type( $type, $in_role );
296
+ }
297
+
298
+
299
+ /**
300
+ * Condition that the relationship was migrated from the legacy implementation.
301
+ *
302
+ * @param bool $should_be_legacy
303
+ *
304
+ * @return IToolset_Relationship_Query_Condition
305
+ */
306
+ public function is_legacy( $should_be_legacy = true ) {
307
+ return $this->condition_factory->is_legacy( $should_be_legacy );
308
+ }
309
+
310
+
311
+ /**
312
+ * Condition that the relationship is active.
313
+ *
314
+ * @param bool $should_be_active
315
+ *
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
+
322
+
323
+ /**
324
+ * Condition that the relationship has at least one active post type in a given role (or another domain than posts).
325
+ *
326
+ * @param bool $has_active_post_types
327
+ * @param IToolset_Relationship_Role_Parent_Child|null $in_role
328
+ *
329
+ * @return IToolset_Relationship_Query_Condition|Toolset_Relationship_Query_Condition_Has_Active_Types
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->do_or(
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
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_query/sql_expression_builder.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Builds the MySQL for the relationship query out of IToolset_Relationship_Query_Condition instances.
5
+ *
6
+ * @since 2.5.4
7
+ */
8
+ class Toolset_Relationship_Query_Sql_Expression_Builder {
9
+
10
+
11
+ /** @var Toolset_Relationship_Database_Operations */
12
+ private $database_operations;
13
+
14
+
15
+ /** @var Toolset_Relationship_Table_Name */
16
+ private $table_name;
17
+
18
+
19
+ /**
20
+ * Toolset_Relationship_Query_Sql_Expression_Builder constructor.
21
+ *
22
+ * @param Toolset_Relationship_Table_Name|null $table_name_di
23
+ * @param Toolset_Relationship_Database_Operations|null $database_operations_di
24
+ */
25
+ public function __construct(
26
+ Toolset_Relationship_Table_Name $table_name_di = null,
27
+ Toolset_Relationship_Database_Operations $database_operations_di = null
28
+ ) {
29
+ $this->table_name = ( null === $table_name_di ? new Toolset_Relationship_Table_Name() : $table_name_di );
30
+
31
+ $this->database_operations = (
32
+ null === $database_operations_di
33
+ ? new Toolset_Relationship_Database_Operations()
34
+ : $database_operations_di
35
+ );
36
+ }
37
+
38
+
39
+ /**
40
+ * Build a complete MySQL query from the conditions.
41
+ *
42
+ * Also make sure that the query results will be easily recognizable by Toolset_Relationship_Definition_Translator.
43
+ *
44
+ * @param IToolset_Relationship_Query_Condition $root_condition
45
+ *
46
+ * @return string
47
+ */
48
+ public function build( IToolset_Relationship_Query_Condition $root_condition ) {
49
+
50
+ $relationship_table = $this->table_name->relationship_table();
51
+ $type_set_table = $this->table_name->type_set_table();
52
+
53
+ // This is a bit more complex because we need to get results in a format that the
54
+ // definition translator will accept.
55
+ $select_clause = $this->database_operations->get_standard_relationships_select_clause();
56
+ $where_clause = $root_condition->get_where_clause();
57
+ $join_clause = implode( ' ', array(
58
+ $this->database_operations->get_standard_relationships_join_clause( $type_set_table ),
59
+ $root_condition->get_join_clause()
60
+ ) );
61
+ $group_by_clause = $this->database_operations->get_standards_relationship_group_by_clause();
62
+
63
+ return "SELECT {$select_clause} FROM {$relationship_table} AS relationships {$join_clause}
64
+ WHERE {$where_clause} GROUP BY {$group_by_clause}";
65
+
66
+ }
67
+
68
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_role/abstract.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Toolset_Relationship_Role_Abstract implements IToolset_Relationship_Role {
4
+
5
+ public function __toString() {
6
+ return $this->get_name();
7
+ }
8
+
9
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_role/child.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Represents a child role of an element in a relationship.
5
+ *
6
+ * @since m2m
7
+ */
8
+ class Toolset_Relationship_Role_Child
9
+ extends Toolset_Relationship_Role_Abstract
10
+ implements IToolset_Relationship_Role_Parent_Child
11
+ {
12
+
13
+ /**
14
+ * Role name.
15
+ *
16
+ * @return string
17
+ */
18
+ public function get_name() {
19
+ return Toolset_Relationship_Role::CHILD;
20
+ }
21
+
22
+ /**
23
+ * @inheritdoc
24
+ * @return bool
25
+ */
26
+ public function is_parent_child() {
27
+ return true;
28
+ }
29
+
30
+
31
+ /**
32
+ * @inheritdoc
33
+ *
34
+ * @return IToolset_Relationship_Role_Parent_Child
35
+ */
36
+ public function other() {
37
+ return new Toolset_Relationship_Role_Parent();
38
+ }
39
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_role/interface.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Represents a role that one element can take in a relationship.
5
+ *
6
+ * @since m2m
7
+ */
8
+ interface IToolset_Relationship_Role {
9
+
10
+ /**
11
+ * Role name.
12
+ *
13
+ * @return string
14
+ */
15
+ public function get_name();
16
+
17
+
18
+ /**
19
+ * Preferably check instanceof IToolset_Relationship_Role_Parent_Child.
20
+ * @return bool
21
+ */
22
+ public function is_parent_child();
23
+
24
+
25
+ /**
26
+ * Convert this to a role name string.
27
+ *
28
+ * @return string
29
+ */
30
+ public function __toString();
31
+
32
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_role/intermediary.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Represents an intermediary post role in a relationship.
5
+ *
6
+ * @since m2m
7
+ */
8
+ class Toolset_Relationship_Role_Intermediary extends Toolset_Relationship_Role_Abstract {
9
+
10
+ /**
11
+ * Role name.
12
+ *
13
+ * @return string
14
+ */
15
+ public function get_name() {
16
+ return Toolset_Relationship_Role::INTERMEDIARY;
17
+ }
18
+
19
+
20
+ /**
21
+ * @inheritdoc
22
+ * @return bool
23
+ */
24
+ public function is_parent_child() {
25
+ return false;
26
+ }
27
+
28
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_role/parent.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Represents a parent role of an element in a relationship.
5
+ *
6
+ * @since m2m
7
+ */
8
+ class Toolset_Relationship_Role_Parent
9
+ extends Toolset_Relationship_Role_Abstract
10
+ implements IToolset_Relationship_Role_Parent_Child
11
+ {
12
+
13
+ /**
14
+ * Role name.
15
+ *
16
+ * @return string
17
+ */
18
+ public function get_name() {
19
+ return Toolset_Relationship_Role::PARENT;
20
+ }
21
+
22
+
23
+ /**
24
+ * @inheritdoc
25
+ * @return bool
26
+ */
27
+ public function is_parent_child() {
28
+ return true;
29
+ }
30
+
31
+
32
+ /**
33
+ * @inheritdoc
34
+ *
35
+ * @return IToolset_Relationship_Role_Parent_Child
36
+ */
37
+ public function other() {
38
+ return new Toolset_Relationship_Role_Child();
39
+ }
40
+ }
vendor/toolset/toolset-common/inc/m2m/relationship_role/parent_child_interface.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Represents a parent or a child (not intermediary) role of an element in a relationship.
5
+ *
6
+ * @since m2m
7
+ */
8
+ interface IToolset_Relationship_Role_Parent_Child extends IToolset_Relationship_Role {
9
+
10
+ /**
11
+ * @return IToolset_Relationship_Role_Parent_Child The opposite role.
12
+ */
13
+ public function other();
14
+
15
+ }
vendor/toolset/toolset-common/inc/m2m/{role.php → relationship_role/role.php} RENAMED
@@ -3,42 +3,88 @@
3
  /**
4
  * Enum class. Defines names of roles that elements can take in a relationship.
5
  *
6
- * The values also match the 'role' column of the association translations table, so they must not be changed.
 
 
7
  *
8
  * @since m2m
9
  */
10
  abstract class Toolset_Relationship_Role {
11
 
 
12
  const PARENT = 'parent';
13
  const CHILD = 'child';
14
  const INTERMEDIARY = 'intermediary';
15
 
16
 
 
 
 
 
 
17
  public static function parent_child() {
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  return array( self::PARENT, self::CHILD );
19
  }
20
 
21
 
 
 
 
 
 
22
  public static function all() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  return array( self::PARENT, self::CHILD, self::INTERMEDIARY );
24
  }
25
 
26
 
27
  public static function is_valid( $role_name ) {
28
- return in_array( $role_name, self::all() );
29
  }
30
 
31
  /**
32
  * Throw an exception if a given role name isn't valid.
33
  *
34
- * @param $role_name
35
  * @param null|string[] $valid_roles Array of roles to accept, defaults to all() roles.
36
  * @since m2m
37
  */
38
- public static function validate( $role_name, $valid_roles = null ) {
 
 
 
 
 
 
39
 
40
  if( null === $valid_roles ) {
41
- $valid_roles = Toolset_Relationship_Role::all();
42
  }
43
 
44
  if( !in_array( $role_name, $valid_roles ) ) {
@@ -69,11 +115,11 @@ abstract class Toolset_Relationship_Role {
69
  /**
70
  * Organize two elements into an array of parent and child.
71
  *
72
- * @param IToolset_Element $first_element
73
- * @param IToolset_Element $second_element
74
  * @param string $first_role Role of the first element (parent or child expected)
75
  *
76
- * @return IToolset_Element[] Two provided elements orderd as parent and child.
77
  */
78
  public static function sort_elements( $first_element, $second_element, $first_role ) {
79
 
@@ -86,4 +132,5 @@ abstract class Toolset_Relationship_Role {
86
  throw new InvalidArgumentException( 'Invalid role name. Parent or child expected.' );
87
  }
88
 
 
89
  }
3
  /**
4
  * Enum class. Defines names of roles that elements can take in a relationship.
5
  *
6
+ * Note that this enum also supports the strongly-typed approach with objects implementing
7
+ * the IToolset_Relationship_Role interface. It is recommended to use this instead of
8
+ * encouraging more stringly-typed code.
9
  *
10
  * @since m2m
11
  */
12
  abstract class Toolset_Relationship_Role {
13
 
14
+ // Don't change these values. They're used also in the database context.
15
  const PARENT = 'parent';
16
  const CHILD = 'child';
17
  const INTERMEDIARY = 'intermediary';
18
 
19
 
20
+ /**
21
+ * Get the array of parent and child roles for easy looping.
22
+ *
23
+ * @return IToolset_Relationship_Role_Parent_Child[]
24
+ */
25
  public static function parent_child() {
26
+ return array(
27
+ new Toolset_Relationship_Role_Parent(),
28
+ new Toolset_Relationship_Role_Child()
29
+ );
30
+ }
31
+
32
+
33
+ /**
34
+ * Get the array of parent and child role names for easy looping.
35
+ *
36
+ * @return string[]
37
+ */
38
+ public static function parent_child_role_names() {
39
  return array( self::PARENT, self::CHILD );
40
  }
41
 
42
 
43
+ /**
44
+ * Get the array of parent, child and intermediary roles for easy looping.
45
+ *
46
+ * @return IToolset_Relationship_Role[]
47
+ */
48
  public static function all() {
49
+ return array(
50
+ new Toolset_Relationship_Role_Parent(),
51
+ new Toolset_Relationship_Role_Child(),
52
+ new Toolset_Relationship_Role_Intermediary()
53
+ );
54
+ }
55
+
56
+
57
+ /**
58
+ * Get the array of parent, child and intermediary role names for easy looping.
59
+ *
60
+ * @return string[]
61
+ */
62
+ public static function all_role_names() {
63
  return array( self::PARENT, self::CHILD, self::INTERMEDIARY );
64
  }
65
 
66
 
67
  public static function is_valid( $role_name ) {
68
+ return in_array( $role_name, self::all_role_names() );
69
  }
70
 
71
  /**
72
  * Throw an exception if a given role name isn't valid.
73
  *
74
+ * @param string|IToolset_Relationship_Role $role
75
  * @param null|string[] $valid_roles Array of roles to accept, defaults to all() roles.
76
  * @since m2m
77
  */
78
+ public static function validate( $role, $valid_roles = null ) {
79
+
80
+ if( $role instanceof IToolset_Relationship_Role ) {
81
+ $role_name = $role->get_name();
82
+ } else {
83
+ $role_name = $role;
84
+ }
85
 
86
  if( null === $valid_roles ) {
87
+ $valid_roles = Toolset_Relationship_Role::all_role_names();
88
  }
89
 
90
  if( !in_array( $role_name, $valid_roles ) ) {
115
  /**
116
  * Organize two elements into an array of parent and child.
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
 
132
  throw new InvalidArgumentException( 'Invalid role name. Parent or child expected.' );
133
  }
134
 
135
+
136
  }
vendor/toolset/toolset-common/inc/m2m/table_name.php DELETED
@@ -1,41 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Enum class. Holds names of m2m tables and provides methods that return full table names
5
- * with correct $wpdb prefixes.
6
- *
7
- * NOT to be used outside the m2m API under any circumstances.
8
- *
9
- * @since m2m
10
- */
11
- abstract class Toolset_Relationship_Table_Name {
12
-
13
-
14
- /**
15
- * Get the associations table name.
16
- *
17
- * @param string $table_name
18
- * @return string
19
- */
20
- public static function get_full_table_name( $table_name ) {
21
- global $wpdb;
22
- return $wpdb->prefix . $table_name;
23
- }
24
-
25
-
26
- public static function associations() {
27
- return self::get_full_table_name( 'toolset_associations' );
28
- }
29
-
30
-
31
- // fixme check all usages and update to the new table structure
32
- public static function association_translations() {
33
- throw new RuntimeException( 'The translations table was removed.');
34
- }
35
-
36
-
37
- public static function relationships() {
38
- return self::get_full_table_name( 'toolset_relationships' );
39
- }
40
-
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/toolset/toolset-common/inc/m2m/utils.php CHANGED
@@ -12,17 +12,20 @@ class Toolset_Relationship_Utils {
12
  /**
13
  * @param string|Toolset_Relationship_Definition $relationship_definition_source
14
  *
15
- * @return null|Toolset_Relationship_Definition
16
  */
17
  public static function get_relationship_definition( $relationship_definition_source ) {
18
- if( is_string( $relationship_definition_source ) ) {
19
- $rd_factory = Toolset_Relationship_Definition_Repository::get_instance();
20
- $relationship_definition = $rd_factory->get_definition( $relationship_definition_source );
21
- } else {
22
- $relationship_definition = $relationship_definition_source;
 
 
 
23
  }
24
 
25
- return $relationship_definition;
26
  }
27
 
28
  }
12
  /**
13
  * @param string|Toolset_Relationship_Definition $relationship_definition_source
14
  *
15
+ * @return null|IToolset_Relationship_Definition
16
  */
17
  public static function get_relationship_definition( $relationship_definition_source ) {
18
+ $rd_factory = Toolset_Relationship_Definition_Repository::get_instance();
19
+
20
+ if( $relationship_definition_source instanceof IToolset_Relationship_Definition ) {
21
+ return $relationship_definition_source;
22
+ } elseif( is_string( $relationship_definition_source ) ) {
23
+ return $rd_factory->get_definition( $relationship_definition_source );
24
+ } elseif( is_int( $relationship_definition_source ) ) {
25
+ return $rd_factory->get_definition_by_row_id( $relationship_definition_source );
26
  }
27
 
28
+ return null;
29
  }
30
 
31
  }
vendor/toolset/toolset-common/inc/m2m/wpml_interoperability.php CHANGED
@@ -263,7 +263,7 @@ class Toolset_Relationship_WPML_Interoperability {
263
 
264
  // Refresh the view for all posts that take part in the association.
265
  $results = new Toolset_Result_Set();
266
- foreach ( Toolset_Relationship_Role::parent_child() as $element_role ) {
267
  if ( $relationship_definition->is_post( $element_role ) ) {
268
  $result = $this->refresh_view_for_post_in_association(
269
  $element_ids[ $element_role ], $element_role, $relationship_definition->get_slug(), $association_id
263
 
264
  // Refresh the view for all posts that take part in the association.
265
  $results = new Toolset_Result_Set();
266
+ foreach ( Toolset_Relationship_Role::parent_child_role_names() as $element_role ) {
267
  if ( $relationship_definition->is_post( $element_role ) ) {
268
  $result = $this->refresh_view_for_post_in_association(
269
  $element_ids[ $element_role ], $element_role, $relationship_definition->get_slug(), $association_id
vendor/toolset/toolset-common/inc/toolset.assets.manager.class.php CHANGED
@@ -198,6 +198,8 @@ class Toolset_Assets_Manager {
198
  * we are using ACF handle to prevent unwanted overrides of window.wp.hooks namespace (******!)
199
  */
200
  const SCRIPT_WP_EVENT_MANAGER = 'acf-input';
 
 
201
 
202
  // Styles
203
  //
@@ -794,6 +796,47 @@ class Toolset_Assets_Manager {
794
  'toolset_theme_loads_own_bs' => __( 'This theme loads its own version of Bootstrap. You should select this option to avoid loading Bootstrap twice and causing display problems on the site\'s front-end', 'wpv-views' )
795
  )
796
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
797
 
798
  return apply_filters( 'toolset_add_registered_script', $this->scripts );
799
  }
198
  * we are using ACF handle to prevent unwanted overrides of window.wp.hooks namespace (******!)
199
  */
200
  const SCRIPT_WP_EVENT_MANAGER = 'acf-input';
201
+
202
+ const SCRIPT_TOOLSET_SHORTCODE = 'toolset-shortcode';
203
 
204
  // Styles
205
  //
796
  'toolset_theme_loads_own_bs' => __( 'This theme loads its own version of Bootstrap. You should select this option to avoid loading Bootstrap twice and causing display problems on the site\'s front-end', 'wpv-views' )
797
  )
798
  );
799
+
800
+ $this->register_script(
801
+ self::SCRIPT_TOOLSET_SHORTCODE,
802
+ $this->assets_url . "/res/js/toolset-shortcode.js",
803
+ array(
804
+ 'jquery', 'jquery-ui-dialog', 'jquery-ui-tabs', 'suggest', 'shortcode', 'underscore', 'wp-util',
805
+ self::SCRIPT_SELECT2, self::SCRIPT_ICL_EDITOR, self::SCRIPT_UTILS, self::SCRIPT_TOOLSET_EVENT_MANAGER ),
806
+ TOOLSET_COMMON_VERSION,
807
+ true
808
+ );
809
+
810
+ global $pagenow;
811
+
812
+ $this->localize_script(
813
+ self::SCRIPT_TOOLSET_SHORTCODE,
814
+ 'toolset_shortcode_i18n',
815
+ array(
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 );
842
  }
vendor/toolset/toolset-common/inc/toolset.shortcode.generator.class.php CHANGED
@@ -25,10 +25,8 @@
25
  *
26
  * @since 1.9
27
  */
28
-
29
- if ( ! class_exists( 'Toolset_Shortcode_Generator' ) ) {
30
 
31
- abstract class Toolset_Shortcode_Generator {
32
 
33
  private static $registered_admin_bar_items = array();
34
  private static $can_show_admin_bar_item = false;
@@ -39,6 +37,13 @@ if ( ! class_exists( 'Toolset_Shortcode_Generator' ) ) {
39
  add_action( 'admin_init', array( $this, 'register_shortcodes_admin_bar_items' ), 99 );
40
  add_action( 'admin_bar_menu', array( $this, 'display_shortcodes_admin_bar_items' ), 99 );
41
  add_action( 'admin_footer', array( $this, 'display_shortcodes_target_dialog' ) );
 
 
 
 
 
 
 
42
  }
43
 
44
  public function register_shortcodes_admin_bar_items() {
@@ -183,14 +188,20 @@ if ( ! class_exists( 'Toolset_Shortcode_Generator' ) ) {
183
  * Dialog Template HTML code
184
  */
185
  public function display_shortcodes_target_dialog() {
186
- if (
187
  self::$can_show_admin_bar_item
188
  && self::$target_dialog_added === false
189
  ) {
190
  ?>
191
  <div class="toolset-dialog-container" style="display:none">
192
- <div id="toolset-shortcode-generator-target-dialog" class="toolset-shortcode-gui-dialog-container js-toolset-shortcode-generator-target-dialog">
193
- <textarea id="toolset-shortcode-generator-target" class="textarea" rows="4" style="width:100%;"></textarea>
 
 
 
 
 
 
194
  </div>
195
  </div>
196
  <?php
@@ -198,9 +209,285 @@ if ( ! class_exists( 'Toolset_Shortcode_Generator' ) ) {
198
  }
199
 
200
  }
201
-
202
-
203
-
204
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
 
206
  }
25
  *
26
  * @since 1.9
27
  */
 
 
28
 
29
+ abstract class Toolset_Shortcode_Generator {
30
 
31
  private static $registered_admin_bar_items = array();
32
  private static $can_show_admin_bar_item = false;
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', array( $this, 'print_shortcodes_templates' ) );
42
+
43
+ add_action( 'wp_ajax_toolset_select2_suggest_posts_by_title', array( $this, 'toolset_select2_suggest_posts_by_title' ) );
44
+ add_action( 'wp_ajax_nopriv_toolset_select2_suggest_posts_by_title', array( $this, 'toolset_select2_suggest_posts_by_title' ) );
45
+ add_action( 'wp_ajax_toolset_select2_suggest_users', array( $this, 'toolset_select2_suggest_users' ) );
46
+ add_action( 'wp_ajax_nopriv_toolset_select2_suggest_users', array( $this, 'toolset_select2_suggest_users' ) );
47
  }
48
 
49
  public function register_shortcodes_admin_bar_items() {
188
  * Dialog Template HTML code
189
  */
190
  public function display_shortcodes_target_dialog() {
191
+ if (
192
  self::$can_show_admin_bar_item
193
  && self::$target_dialog_added === false
194
  ) {
195
  ?>
196
  <div class="toolset-dialog-container" style="display:none">
197
+ <div id="js-toolset-shortcode-generator-target-dialog" class="toolset-shortcode-gui-dialog-container js-toolset-shortcode-generator-target-dialog">
198
+ <p>
199
+ <?php echo __( 'This is the generated shortcode, based on the settings that you have selected:', 'wpv-views' ); ?>
200
+ </p>
201
+ <textarea id="js-toolset-shortcode-generator-target" readonly="readonly" style="width:100%;resize:none;box-sizing:border-box;font-family:monospace;display:block;padding:5px;background-color:#ededed;border: 1px solid #ccc !important;box-shadow: none !important;"></textarea>
202
+ <p>
203
+ <?php echo __( 'You can now copy and paste this shortcode anywhere you want.', 'wpv-views' ); ?>
204
+ </p>
205
  </div>
206
  </div>
207
  <?php
209
  }
210
 
211
  }
212
+
213
+ /**
214
+ * Generate the shared Toolset shortcode GUI templates.
215
+ *
216
+ * @since 2.5.4
217
+ * @note Move this to a separated dedicated set of template files.
218
+ */
219
+ public function print_shortcodes_templates() {
220
+
221
+ if ( did_action( 'toolset_action_require_shortcodes_templates_done' ) ) {
222
+ return;
223
+ }
224
+
225
+ ?>
226
+ <script type="text/html" id="tmpl-toolset-shortcode-gui">
227
+ <input value="{{{data.shortcode}}}" class="toolset-shortcode-gui-shortcode-handle js-toolset-shortcode-gui-shortcode-handle" type="hidden" />
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-form" data-attribute="{{{parameterKey}}}" data-type="parameter">
232
+ <input type="hidden" name="{{{parameterKey}}}" value="{{{parameterValue}}}" disabled="disabled" />
233
+ </span>
234
+ <#
235
+ });
236
+ } #>
237
+ <div id="js-toolset-shortcode-gui-dialog-tabs" class="toolset-shortcode-gui-tabs js-toolset-shortcode-gui-tabs">
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
+ print( data.templates.attributeWrapper( attributeData ) );
254
+ }
255
+ }); #>
256
+ </div>
257
+ <# }); #>
258
+ </div>
259
+ <div class="toolset-shortcode-gui-messages js-toolset-shortcode-gui-messages"></div>
260
+ </script>
261
+ <script type="text/html" id="tmpl-toolset-shortcode-attribute-wrapper">
262
+ <#
263
+ data = _.defaults( data, { defaultValue: '', required: false, hidden: false, placeholder: '' } );
264
+ data = _.defaults( data, { defaultForceValue: data.defaultValue } );
265
+ #>
266
+ <div class="toolset-shortcode-gui-attribute-wrapper js-toolset-shortcode-gui-attribute-wrapper js-toolset-shortcode-gui-attribute-wrapper-for-{{{data.attribute}}}" data-attribute="{{{data.attribute}}}" data-type="{{{data.type}}}" data-default="{{{data.defaultValue}}}"<# if ( data.hidden ) { #> style="display:none"<# } #>>
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 )
273
+ ) {
274
+ print( data.templates.attributes[ data.type ]( data ) );
275
+ } #>
276
+ <# if ( _.has( data, 'description' ) ) { #>
277
+ <p class="description">{{{data.description}}}</p>
278
+ <# } #>
279
+ </div>
280
+ </script>
281
+ <script type="text/html" id="tmpl-toolset-shortcode-attribute-text"><# //alert(data.toSource()); #>
282
+ <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}}}" type="text">
283
+ </script>
284
+ <script type="text/html" id="tmpl-toolset-shortcode-attribute-radio">
285
+ <ul id="{{{data.shortcode}}}-{{{data.attribute}}}">
286
+ <# _.each( data.options, function( optionLabel, optionKey ) { #>
287
+ <li>
288
+ <label>
289
+ <input name="{{{data.shortcode}}}-{{{data.attribute}}}" value="{{{optionKey}}}" class="js-shortcode-gui-field" type="radio"<# if ( optionKey == data.defaultForceValue ) { #> checked="checked"<# } #>>
290
+ {{{optionLabel}}}
291
+ </lanel>
292
+ </li>
293
+ <# }); #>
294
+ </ul>
295
+ </script>
296
+ <script type="text/html" id="tmpl-toolset-shortcode-attribute-select">
297
+ <select id="{{{data.shortcode}}}-{{{data.attribute}}}" class="js-shortcode-gui-field">
298
+ <# _.each( data.options, function( optionLabel, optionKey ) { #>
299
+ <option value="{{{optionKey}}}"<# if ( optionKey == data.defaultForceValue ) { #> selected="selected"<# } #>>
300
+ {{{optionLabel}}}
301
+ </option>
302
+ <# }); #>
303
+ </select>
304
+ </script>
305
+ <script type="text/html" id="tmpl-toolset-shortcode-attribute-select2">
306
+ <select id="{{{data.shortcode}}}-{{{data.attribute}}}" class="js-shortcode-gui-field js-toolset-shortcode-gui-field-select2<# if ( data.required ) { #> js-toolset-shortcode-gui-required<# } #>">
307
+ <#
308
+ if ( _.has( data, 'options' ) ) {
309
+ _.each( data.options, function( optionLabel, optionKey ) {
310
+ #>
311
+ <option value="{{{optionKey}}}"<# if ( optionKey == data.defaultForceValue ) { #> selected="selected"<# } #>>
312
+ {{{optionLabel}}}
313
+ </option>
314
+ <#
315
+ });
316
+ }
317
+ #>
318
+ </select>
319
+ </script>
320
+ <script type="text/html" id="tmpl-toolset-shortcode-attribute-ajaxSelect2">
321
+ <select
322
+ id="{{{data.shortcode}}}-{{{data.attribute}}}"
323
+ class="js-shortcode-gui-field js-toolset-shortcode-gui-field-ajax-select2<# if ( data.required ) { #> js-toolset-shortcode-gui-required<# } #>"
324
+ data-action="{{{data.action}}}"
325
+ data-nonce="{{{data.nonce}}}"
326
+ data-placeholder="{{{data.placeholder}}}"
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>
333
+ <label>
334
+ <input type="radio" name="{{{data.shortcode}}}-select-target-post" class="toolset-shortcode-gui-item-selector js-toolset-shortcode-gui-item-selector" value="current" checked="checked" />
335
+ <?php
336
+ if (
337
+ isset( $_GET['page'] )
338
+ && in_array( $_GET['page'], array( 'views-editor', 'view-archives-editor' ) )
339
+ ) {
340
+ _e( 'Edit current post in the loop', 'wp-cred' );
341
+ } else {
342
+ _e( 'Edit current post', 'wp-cred' );
343
+ }
344
+ ?>
345
+ </label>
346
+ </li>
347
+ <li class="js-toolset-shortcode-gui-item-selector-has-related">
348
+ <label>
349
+ <input type="radio" name="{{{data.shortcode}}}-select-target-post" class="toolset-shortcode-gui-item-selector js-toolset-shortcode-gui-item-selector" value="object_id" />
350
+ <?php _e( 'Edit another post', 'wp-cred' ); ?>
351
+ <div class="toolset-shortcode-gui-item-selector-is-related js-toolset-shortcode-gui-item-selector-is-related" style="display:none">
352
+ <select id="toolset-shortcode-gui-item-selector-object_id" class="js-toolset-shortcode-gui-item-selector_object_id js-toolset-shortcode-gui-field-ajax-select2" data-action="toolset_select2_suggest_posts_by_title" data-nonce="" data-placeholder="<?php echo esc_attr( 'Search for posts by title', 'wpv-views' ); ?>">
353
+ </select>
354
+ </div>
355
+ </label>
356
+ </li>
357
+ </ul>
358
+ </script>
359
+ <script type="text/html" id="tmpl-toolset-shortcode-attribute-user-selector">
360
+ <ul id="{{data.shortcode}}}-{{data.attribute}}}">
361
+ <li>
362
+ <label>
363
+ <input type="radio" name="{{{data.shortcode}}}-select-target-user" class="toolset-shortcode-gui-item-selector js-toolset-shortcode-gui-item-selector" value="current" checked="checked" />
364
+ <?php _e( 'Edit current logged in user', 'wp-cred' ); ?>
365
+ </label>
366
+ </li>
367
+ <li class="js-toolset-shortcode-gui-item-selector-has-related">
368
+ <label>
369
+ <input type="radio" name="{{{data.shortcode}}}-select-target-user" class="toolset-shortcode-gui-item-selector js-toolset-shortcode-gui-item-selector" value="object_id" />
370
+ <?php _e( 'Edit another user', 'wp-cred' ); ?>
371
+ <div class="toolset-shortcode-gui-item-selector-is-related js-toolset-shortcode-gui-item-selector-is-related" style="display:none">
372
+ <select id="toolset-shortcode-gui-item-selector-object_id" class="js-toolset-shortcode-gui-item-selector_object_id js-toolset-shortcode-gui-field-ajax-select2" data-action="toolset_select2_suggest_users" data-nonce="" data-placeholder="<?php echo esc_attr( 'Search for users', 'wpv-views' ); ?>">
373
+ </select>
374
+ </div>
375
+ </label>
376
+ </li>
377
+ </ul>
378
+ </script>
379
+ <?php
380
+
381
+ do_action( 'toolset_action_require_shortcodes_templates_done' );
382
+
383
+ }
384
+
385
+ public function toolset_select2_suggest_posts_by_title() {
386
+ if ( ! isset( $_POST['s'] ) ) {
387
+ $output = array(
388
+ 'message' => __( 'Wrong or missing query.', 'wpv-views' ),
389
+ );
390
+ wp_send_json_error( $output );
391
+ }
392
+
393
+ global $wpdb;
394
+
395
+ if ( method_exists( $wpdb, 'esc_like' ) ) {
396
+ $s = '%' . $wpdb->esc_like( $_POST['s'] ) . '%';
397
+ } else {
398
+ $s = '%' . like_escape( esc_sql( $_POST['s'] ) ) . '%';
399
+ }
400
+
401
+ $toolset_post_type_exclude = new Toolset_Post_Type_Exclude_List();
402
+ $toolset_post_type_exclude_list = $toolset_post_type_exclude->get();
403
+ $toolset_post_type_exclude_list_string = "'" . implode( "', '", $toolset_post_type_exclude_list ) . "'";
404
+
405
+ $results = $wpdb->get_results(
406
+ $wpdb->prepare(
407
+ "SELECT ID, post_type, post_title
408
+ FROM {$wpdb->posts}
409
+ WHERE post_title LIKE %s
410
+ AND post_status = %s
411
+ AND post_type NOT IN ( {$toolset_post_type_exclude_list_string} )
412
+ LIMIT 0, 15",
413
+ $s,
414
+ 'publish'
415
+ )
416
+ );
417
+
418
+ if (
419
+ isset( $results )
420
+ && ! empty( $results )
421
+ ) {
422
+ $output = array();
423
+ if ( is_array( $results ) ) {
424
+ foreach ( $results as $result ) {
425
+ $output[] = array(
426
+ 'text' => $result->post_title . ' (' . $result->post_type . ')',
427
+ 'id' => $result->ID,
428
+ );
429
+ }
430
+ wp_send_json_success( $output );
431
+ }
432
+ } else {
433
+ $output = array(
434
+ 'message' => __( 'Error while retrieving result.', 'wpv-views' ),
435
+ );
436
+ wp_send_json_error( $output );
437
+ }
438
+ }
439
+
440
+ public function toolset_select2_suggest_users() {
441
+ if ( ! isset( $_POST['s'] ) ) {
442
+ $output = array(
443
+ 'message' => __( 'Wrong or missing query.', 'wpv-views' ),
444
+ );
445
+ wp_send_json_error( $output );
446
+ }
447
+
448
+ global $wpdb;
449
+
450
+
451
+ if ( method_exists( $wpdb, 'esc_like' ) ) {
452
+ $s = '%' . $wpdb->esc_like( $_POST['s'] ) . '%';
453
+ } else {
454
+ $s = '%' . like_escape( esc_sql( $_POST['s'] ) ) . '%';
455
+ }
456
+
457
+ $results = $wpdb->get_results(
458
+ $wpdb->prepare(
459
+ "SELECT ID, display_name
460
+ FROM {$wpdb->users}
461
+ WHERE display_name LIKE %s
462
+ OR user_login LIKE %s
463
+ OR user_nicename LIKE %s
464
+ LIMIT 0, 15",
465
+ $s,
466
+ $s,
467
+ $s
468
+ )
469
+ );
470
+
471
+ if (
472
+ isset( $results )
473
+ && ! empty( $results )
474
+ ) {
475
+ $output = array();
476
+ if ( is_array( $results ) ) {
477
+ foreach ( $results as $result ) {
478
+ $output[] = array(
479
+ 'text' => $result->display_name,
480
+ 'id' => $result->ID,
481
+ );
482
+ }
483
+ wp_send_json_success( $output );
484
+ }
485
+ } else {
486
+ $output = array(
487
+ 'message' => __( 'Error while retrieving result.', 'wpv-views' ),
488
+ );
489
+ wp_send_json_error( $output );
490
+ }
491
+ }
492
 
493
  }
vendor/toolset/toolset-common/inc/toolset.upgrade.class.php DELETED
@@ -1,137 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Toolset Common Library upgrade mechanism.
5
- *
6
- * Compares a number of the library version in database with the current one. If the current version is lower,
7
- * it does the toolset_do_upgrade action and updates the database.
8
- *
9
- * Note: For performance reasons, this is loaded only during admin page requests. As a consequence, everything running
10
- * on front-end that relies on certain state of the database must survive a TCL upgrade without an immediate database
11
- * upgrade.
12
- *
13
- * @since m2m
14
- */
15
- class Toolset_Upgrade {
16
-
17
- private static $instance;
18
-
19
- public static function get_instance() {
20
- if( null == self::$instance ) {
21
- self::$instance = new self();
22
- }
23
-
24
- return self::$instance;
25
- }
26
-
27
- private function __construct() { }
28
-
29
- private function __clone() { }
30
-
31
-
32
- private $is_initialized = false;
33
-
34
-
35
- public static function initialize() {
36
- $instance = self::get_instance();
37
- if( $instance->is_initialized ) {
38
- return;
39
- }
40
-
41
- // When everything is loaded and possibly hooked in the upgrade action, we can proceed.
42
- add_action( 'toolset_common_loaded', array( $instance, 'check_upgrade' ) );
43
-
44
- $instance->is_initialized = true;
45
- }
46
-
47
-
48
- /** Name of the option used to store version number. */
49
- const DATABASE_VERSION_OPTION = 'toolset_database_version';
50
-
51
-
52
- /**
53
- * Check if an upgrade is needed.
54
- *
55
- * Do not call this manually, there's no need to.
56
- *
57
- * @since m2m
58
- */
59
- public function check_upgrade() {
60
-
61
- $database_version = $this->get_database_version();
62
- $library_version = $this->get_library_version();
63
- $is_upgrade_needed = ( $database_version < $library_version );
64
-
65
- if( $is_upgrade_needed ) {
66
-
67
- // Safety measure - Abort if the library isn't fully loaded.
68
- if( false == apply_filters( 'toolset_is_toolset_common_available', false ) ) {
69
- return;
70
- }
71
-
72
- $this->do_upgrade( $database_version, $library_version );
73
- }
74
- }
75
-
76
-
77
- /**
78
- * Get current version number.
79
- *
80
- * @return int
81
- * @since m2m
82
- */
83
- private function get_library_version() {
84
- return ( defined( 'TOOLSET_COMMON_VERSION_NUMBER' ) ? (int) TOOLSET_COMMON_VERSION_NUMBER : 0 );
85
- }
86
-
87
-
88
- /**
89
- * Get number of the version stored in the database.
90
- *
91
- * @return int
92
- * @since m2m
93
- */
94
- private function get_database_version() {
95
- $version = (int) get_option( self::DATABASE_VERSION_OPTION, 0 );
96
- return $version;
97
- }
98
-
99
-
100
- /**
101
- * Update the version number stored in the database.
102
- *
103
- * @param int $version_number
104
- * @since m2m
105
- */
106
- private function update_database_version( $version_number ) {
107
- if( is_numeric( $version_number ) ) {
108
- update_option( self::DATABASE_VERSION_OPTION, (int) $version_number, true );
109
- }
110
- }
111
-
112
-
113
- /**
114
- * Perform the actual upgrade.
115
- *
116
- * @param int $from_version
117
- * @param int $to_version
118
- * @since m2m
119
- */
120
- private function do_upgrade( $from_version, $to_version ) {
121
-
122
- /**
123
- * This is fired when library version increase is detected.
124
- *
125
- * It happens only once per each increase and only after the whole library has been loaded.
126
- *
127
- * @param int $from_version
128
- * @param int $to_version
129
- * @since m2m
130
- */
131
- do_action( 'toolset_do_upgrade', $from_version, $to_version );
132
-
133
- $this->update_database_version( $to_version );
134
- }
135
-
136
-
137
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = 253002;
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 = 255000;
31
 
32
 
33
  /* ---------------------------------------------------------------------- *\
vendor/toolset/toolset-common/res/css/toolset-dialogs.css CHANGED
@@ -1,6 +1,6 @@
1
- /*
2
- * Css with rules that will prevent other plugins to make changes on our dialogs
3
- */
4
 
5
  .toolset-ui-dialog.ui-dialog {
6
  z-index: 100102 !important;
@@ -166,3 +166,147 @@
166
  font-size: 11px !important;
167
  letter-spacing: normal;
168
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * CSS with rules that will prevent other plugins to make changes on our dialogs
3
+ */
4
 
5
  .toolset-ui-dialog.ui-dialog {
6
  z-index: 100102 !important;
166
  font-size: 11px !important;
167
  letter-spacing: normal;
168
  }
169
+ /**
170
+ * Shortcodes dialogs styles: listing dialog.
171
+ */
172
+ .toolset-shortcode-gui-group-list .item {
173
+ margin: 0 5px 5px 0;
174
+ white-space: nowrap;
175
+ display: inline-block;
176
+ cursor: pointer;
177
+ }
178
+ /**
179
+ * Shortcodes dialogs styles: shortcodes dialog.
180
+ */
181
+ .toolset-shortcode-gui-dialog-container .ui-tabs-nav {
182
+ padding: .2em .1em .2em .2em;
183
+ border: none;
184
+ background: none;
185
+ box-shadow: none;
186
+ width: 30%;
187
+ max-width: 250px;
188
+ display: block;
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;
196
+ margin: 0 -1px .2em 0;
197
+ -webkit-transition: all 0.05s linear;
198
+ -moz-transition: all 0.05s linear;
199
+ -o-transition: all 0.05s linear;
200
+ -ms-transition: all 0.05s linear;
201
+ transition: all 0.05s linear;
202
+ }
203
+
204
+ .toolset-shortcode-gui-dialog-container .ui-tabs-vertical .ui-tabs-nav li a {
205
+ display:block;
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;
213
+ }
214
+
215
+ .toolset-shortcode-gui-dialog-container .ui-tabs-vertical .ui-tabs-nav li.toolset-shortcode-gui-tabs-incomplete {
216
+ background: #b94a48 !important;
217
+ }
218
+
219
+ .toolset-shortcode-gui-dialog-container .ui-tabs-vertical .ui-tabs-panel {
220
+ display: block;
221
+ float: left;
222
+ width: 60%;
223
+ padding-left: 5%;
224
+ border-left: 1px solid #ccc;
225
+ }
226
+
227
+ .toolset-shortcode-gui-dialog-container .ui-tabs-vertical label {
228
+ display: block;
229
+ }
230
+ .toolset-shortcode-gui-dialog-container .ui-tabs-vertical .ui-tabs-nav .ui-tabs-active a {
231
+ color: #333;
232
+ font-weight: 700;
233
+ }
234
+ .toolset-shortcode-gui-dialog-container .ui-tabs-vertical .ui-tabs-nav .toolset-shortcode-gui-tabs-incomplete a {
235
+ color: #f9f9f9;
236
+ }
237
+ .toolset-shortcode-gui-dialog-container .ui-tabs-vertical .ui-tabs-nav a {
238
+ display: block;
239
+ padding: 4px 20px;
240
+ line-height: 18px;
241
+ font-size: 14px;
242
+ text-shadow: none;
243
+ text-decoration: none;
244
+ color: grey;
245
+ }
246
+ .toolset-shortcode-gui-dialog-container .ui-tabs-vertical [class*=" icon-"] {
247
+ padding-left: 2em;
248
+ }
249
+ .toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-attribute-wrapper,
250
+ .toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-content-wrapper {
251
+ position: relative;
252
+ /*padding-bottom: 1em;*/
253
+ }
254
+ .toolset-shortcode-gui-dialog-container h2 {
255
+ margin-top: 5px;
256
+ }
257
+ .toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-dialog-item-grouped {
258
+ overflow: hidden;
259
+ clear: left;
260
+ margin: 0;
261
+ padding: 0;
262
+ }
263
+ .toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-dialog-item-grouped > li {
264
+ display: block;
265
+ float: left;
266
+ margin: 0;
267
+ padding: 0;
268
+ }
269
+ .toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-attribute-group .toolset-shortcode-gui-attribute-wrapper {
270
+ margin: 0;
271
+ padding: 0 10px 0 0;
272
+ }
273
+ .toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-dialog-item-grouped > 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,
277
+ .toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-attribute-group h3,
278
+ .toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-content-wrapper h3 {
279
+ color: #333;
280
+ background: #ededed;
281
+ padding: 1px 5px;
282
+ font-size: 13px;
283
+ }
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;
291
+ }
292
+ .toolset-shortcode-gui-dialog-container .toolset-shortcode-gui-invalid-attr {
293
+ border-color: #B94A48;
294
+ background-color: #F2DEDE;
295
+ color: #B94A48;
296
+ }
297
+ .toolset-shortcode-gui-dialog-container + .ui-dialog-buttonpane .ui-dialog-buttonset {
298
+ float: none;
299
+ overflow: hidden;
300
+ padding: 2px 0;
301
+ }
302
+
303
+ .toolset-shortcode-gui-dialog-container + .ui-dialog-buttonpane button {
304
+ float: left;
305
+ margin-right: 10px;
306
+ }
307
+
308
+ .toolset-shortcode-gui-dialog-container + .ui-dialog-buttonpane .toolset-shortcode-gui-dialog-button-align-right {
309
+ float: right;
310
+ margin-left: 10px;
311
+ margin-right: 0
312
+ }
vendor/toolset/toolset-common/res/js/toolset-shortcode.js ADDED
@@ -0,0 +1,950 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * API and helper functions for the GUI on Toolset shortcodes.
3
+ *
4
+ * @since 2.5.4
5
+ * @package Toolset
6
+ */
7
+
8
+ var Toolset = Toolset || {};
9
+
10
+ /**
11
+ * -------------------------------------
12
+ * Shortcode GUI
13
+ * -------------------------------------
14
+ */
15
+
16
+ Toolset.shortcodeManager = function( $ ) {
17
+
18
+ var self = this;
19
+
20
+ /**
21
+ * Shortcodes GUI API version.
22
+ *
23
+ * Access to it using the API methods, from inside this object:
24
+ * - self.getShortcodeGuiApiVersion
25
+ *
26
+ * Access to it using the API hooks, from the outside world:
27
+ * - toolset-filter-get-shortcode-gui-api-version
28
+ *
29
+ * @since 2.5.4
30
+ */
31
+ self.apiVersion = 254000;
32
+
33
+ /**
34
+ * Get the current shortcodes GUI API version.
35
+ *
36
+ * @see toolset-filter-get-shortcode-gui-api-version
37
+ *
38
+ * @since 2.5.4
39
+ */
40
+ self.getShortcodeGuiApiVersion = function( version ) {
41
+ return self.apiVersion;
42
+ };
43
+
44
+ /**
45
+ * Dialog rendering helpers, mainly size calculators.
46
+ *
47
+ * @since 2.5.4
48
+ */
49
+ self.dialogMinWidth = 870;
50
+ self.calculateDialogMaxWidth = function() {
51
+ return ( $( window ).width() - 200 );
52
+ };
53
+ self.calculateDialogMaxHeight = function() {
54
+ return ( $( window ).height() - 100 );
55
+ };
56
+
57
+ /**
58
+ * The current GUI API action to be performed. Can be 'insert', 'create', 'save', 'append', 'edit', 'skip'.
59
+ *
60
+ * Access to it using the API methods, from inside this object:
61
+ * - self.getShortcodeGuiAction
62
+ * - self.setShortcodeGuiAction
63
+ *
64
+ * Access to it using the API hooks, from the outside world:
65
+ * - toolset-filter-get-shortcode-gui-action
66
+ * - toolset-action-set-shortcode-gui-action
67
+ *
68
+ * @since 2.5.4
69
+ */
70
+ self.action = 'insert';
71
+ self.validActions = [ 'insert', 'create', 'save', 'append', 'edit', 'skip' ];
72
+
73
+ /**
74
+ * Get the current shortcodes GUI action.
75
+ *
76
+ * @see wpv-filter-wpv-shortcodes-gui-get-gui-action
77
+ *
78
+ * @since 2.5.4
79
+ */
80
+ self.getShortcodeGuiAction = function( action ) {
81
+ return self.action;
82
+ };
83
+
84
+ /**
85
+ * Set the current shortcodes GUI action.
86
+ *
87
+ * @see wpv-action-wpv-shortcodes-gui-set-gui-action
88
+ *
89
+ * @since 2.5.4
90
+ */
91
+ self.setShortcodeGuiAction = function( action ) {
92
+ if ( $.inArray( action, self.validActions ) !== -1 ) {
93
+ self.action = action;
94
+ }
95
+ };
96
+
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
+ * ###############################
108
+ */
109
+
110
+ /**
111
+ * Return the current shortcodes GUI API version.
112
+ *
113
+ * @since 2.5.4
114
+ */
115
+ Toolset.hooks.addFilter( 'toolset-filter-get-shortcode-gui-api-version', self.getShortcodeGuiApiVersion );
116
+
117
+ /**
118
+ * Return the current shortcode GUI action: 'insert', 'create', 'save', 'append', 'edit', 'skip'.
119
+ *
120
+ * @since 2.5.4
121
+ */
122
+ Toolset.hooks.addFilter( 'toolset-filter-get-shortcode-gui-action', self.getShortcodeGuiAction );
123
+
124
+ /**
125
+ * Validate a shortcode attributes container.
126
+ *
127
+ * @since 2.5.4
128
+ */
129
+ Toolset.hooks.addFilter( 'toolset-filter-is-shortcode-attributes-container-valid', self.isShortcodeAttributesContainerValid, 10, 2 );
130
+
131
+ /**
132
+ * Return the shortcode GUI templates.
133
+ *
134
+ * @since 2.5.4
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
+ *
141
+ * @since 2.5.4
142
+ */
143
+ Toolset.hooks.addFilter( 'toolset-filter-get-crafted-shortcode', self.getCraftedShortcode );
144
+
145
+ /**
146
+ * Return the current crafted shortcode with the current dialog GUI attrbutes.
147
+ *
148
+ * @since 2.5.4
149
+ */
150
+ Toolset.hooks.addFilter( 'toolset-filter-shortcode-gui-computed-attribute-values', self.resolveToolsetComboValues, 1, 2 );
151
+
152
+ /**
153
+ * Filter the generated shortcode to support shortcodes with different format.
154
+ *
155
+ * @since 2.5.4
156
+ */
157
+ Toolset.hooks.addFilter( 'wpv-filter-wpv-shortcodes-gui-before-do-action', self.secureShortcodeFromSanitizationIfNeeded );
158
+
159
+ /**
160
+ * Filter the generated shortcode to support shortcodes with different format.
161
+ *
162
+ * @since 2.5.4
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
+ *
175
+ * @since 2.5.4
176
+ */
177
+ Toolset.hooks.addAction( 'toolset-action-set-shortcode-gui-action', self.setShortcodeGuiAction );
178
+
179
+ /**
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;
191
+
192
+ };
193
+
194
+ /**
195
+ * Init GUI templates.
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
+ *
223
+ * @uses jQuery.dialog
224
+ * @since 2.5.4
225
+ */
226
+ self.dialogs = {};
227
+ self.dialogs.target = null;
228
+
229
+ self.shortcodeDialogSpinnerContent = $(
230
+ '<div style="min-height: 150px;">' +
231
+ '<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; ">' +
232
+ '<div class="ajax-loader"></div>' +
233
+ '<p>' + toolset_shortcode_i18n.action.loading + '</p>' +
234
+ '</div>' +
235
+ '</div>'
236
+ );
237
+
238
+ self.initDialogs = function() {
239
+
240
+ /**
241
+ * Canonical dialog to generate Toolset shortcodes.
242
+ *
243
+ * @since 2.5.4
244
+ */
245
+ if ( ! $( '#js-toolset-shortcode-generator-target-dialog' ).length ) {
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,
252
+ title: toolset_shortcode_i18n.title.generated,
253
+ resizable: false,
254
+ draggable: false,
255
+ show: {
256
+ effect: "blind",
257
+ duration: 800
258
+ },
259
+ create: function( event, ui ) {
260
+ $( event.target ).parent().css( 'position', 'fixed' );
261
+ },
262
+ open: function( event, ui ) {
263
+ $( '#js-toolset-shortcode-generator-target' )
264
+ .html( $( this ).data( 'shortcode' ) )
265
+ .focus();
266
+ $('body').addClass('modal-open');
267
+ },
268
+ close: function( event, ui ) {
269
+ $( 'body' ).removeClass( 'modal-open' );
270
+ self.setShortcodeGuiAction( 'insert' );
271
+ $( this ).dialog( 'close' );
272
+ }
273
+ });
274
+
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() {
281
+ var hasRelatedContainer = $( this );
282
+ if ( $( 'input.js-toolset-shortcode-gui-item-selector:checked', hasRelatedContainer ).val() == checkedSelector ) {
283
+ $( '.js-toolset-shortcode-gui-item-selector-is-related', hasRelatedContainer ).slideDown( 'fast' );
284
+ } else {
285
+ $( '.js-toolset-shortcode-gui-item-selector-is-related', hasRelatedContainer ).slideUp( 'fast' );
286
+ }
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 ),
293
+ selectorParent = selector.closest( '.js-toolset-shortcode-gui-dialog-container' );
294
+
295
+ selector
296
+ .addClass( 'js-toolset-shortcode-gui-field-select2-inited' )
297
+ .css( { width: '100%' } )
298
+ .toolset_select2(
299
+ {
300
+ width: 'resolve',
301
+ dropdownAutoWidth: true,
302
+ dropdownParent: selectorParent,
303
+ placeholder: selector.data( 'placeholder' )
304
+ }
305
+ )
306
+ .data( 'toolset_select2' )
307
+ .$dropdown
308
+ .addClass( 'toolset_select2-dropdown-in-dialog' );
309
+ });
310
+
311
+ $( '.js-toolset-shortcode-gui-dialog-container .js-toolset-shortcode-gui-field-ajax-select2' ).each( function() {
312
+ var selector = $( this ),
313
+ selectorParent = selector.closest( '.js-toolset-shortcode-gui-dialog-container' );
314
+
315
+ selector
316
+ .addClass( 'js-toolset-shortcode-gui-field-select2-inited' )
317
+ .css( { width: '100%' } )
318
+ .toolset_select2(
319
+ {
320
+ width: 'resolve',
321
+ dropdownAutoWidth: true,
322
+ dropdownParent: selectorParent,
323
+ placeholder: selector.data( 'placeholder' ),
324
+ ajax: {
325
+ url: toolset_shortcode_i18n.ajaxurl + '?action=' + selector.data( 'action' ) + '&nonce=' + selector.data( 'nonce' ),
326
+ dataType: 'json',
327
+ delay: 250,
328
+ type: 'post',
329
+ data: function( params ) {
330
+ return {
331
+ s: params.term,
332
+ page: params.page,
333
+ };
334
+ },
335
+ processResults: function( response, params ) {
336
+ params.page = params.page || 1;
337
+ if ( response.success ) {
338
+ return {
339
+ results: response.data,
340
+ };
341
+ }
342
+ return {
343
+ results: [],
344
+ };
345
+ },
346
+ cache: false
347
+ }
348
+ }
349
+ )
350
+ .data( 'toolset_select2' )
351
+ .$dropdown
352
+ .addClass( 'toolset_select2-dropdown-in-dialog' );
353
+ });
354
+ };
355
+
356
+ /**
357
+ * Clean validation errors on input change.
358
+ *
359
+ * @since 2.5.4
360
+ */
361
+ $( document ).on( 'change keyup input cut paste', '.js-toolset-shortcode-gui-dialog-container input, .js-toolset-shortcode-gui-dialog-container select', 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' ),
368
+ comboAttributeWrapper = $( '.js-toolset-shortcode-gui-attribute-wrapper-for-toolsetCombo\\:' + attribute );
369
+
370
+ if ( comboAttributeWrapper.length == 0 ) {
371
+ return;
372
+ }
373
+
374
+ if ( 'toolsetCombo' == checkedValue ) {
375
+ comboAttributeWrapper.slideDown( 'fast' );
376
+ } else {
377
+ comboAttributeWrapper.slideUp( 'fast' );
378
+ }
379
+ });
380
+
381
+ /**
382
+ * Validation patterns.
383
+ *
384
+ * @since 2.5.4
385
+ */
386
+ self.validationPatterns = {
387
+ number: /^[0-9]+$/,
388
+ numberList: /^\d+(?:,\d+)*$/,
389
+ numberExtended: /^(-1|[0-9]+)$/,
390
+ url: /^(https?):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,
391
+
392
+ };
393
+
394
+ self.isShortcodeAttributesContainerValid = function( status, container ) {
395
+ return self.validateShortcodeAttributes( container );
396
+ }
397
+
398
+ /**
399
+ * Check required shortcode attributes while crafting the shortcode.
400
+ *
401
+ * @since 2.5.4
402
+ */
403
+ self.requireShortcodeAttributes = function( evaluatedContainer ) {
404
+ var valid = true;
405
+
406
+ evaluatedContainer.find( '.js-shortcode-gui-field.js-toolset-shortcode-gui-required' ).each( function() {
407
+ var requiredAttribute = $( this ),
408
+ requiredAttributeIsValid = true;
409
+
410
+ // Here we are checking for empty text inputs and selects with the default empty option selected.
411
+ if (
412
+ null === requiredAttribute.val()
413
+ || '' == requiredAttribute.val()
414
+ ) {
415
+ requiredAttribute.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
416
+ requiredAttributeIsValid = false;
417
+
418
+ if ( requiredAttribute.hasClass( 'toolset_select2-hidden-accessible' ) ) {
419
+ requiredAttribute
420
+ .toolset_select2()
421
+ .data( 'toolset_select2' )
422
+ .$selection
423
+ .addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
424
+ }
425
+
426
+ }
427
+ if ( ! requiredAttributeIsValid ) {
428
+ valid = false;
429
+ /*
430
+ error_container
431
+ .wpvToolsetMessage({
432
+ text: wpv_shortcodes_gui_texts.attr_empty,
433
+ type: 'error',
434
+ inline: false,
435
+ stay: true
436
+ });
437
+ // Hack to allow more than one error message per filter
438
+ error_container
439
+ .data( 'message-box', null )
440
+ .data( 'has_message', false );
441
+ */
442
+ }
443
+ });
444
+
445
+ evaluatedContainer.find( 'input.js-shortcode-gui-field:radio:checked' ).each( function() {
446
+ var checkedValue = $( this ).val(),
447
+ attribute = $( this ).closest( '.js-toolset-shortcode-gui-attribute-wrapper' ).data( 'attribute' ),
448
+ comboAttributeWrapper = $( '.js-toolset-shortcode-gui-attribute-wrapper-for-toolsetCombo\\:' + attribute );
449
+
450
+ if (
451
+ 'toolsetCombo' == checkedValue
452
+ && comboAttributeWrapper.length > 0
453
+ ) {
454
+ var comboAttributeActualSelector = comboAttributeWrapper.find( '.js-shortcode-gui-field' );
455
+ if (
456
+ null == comboAttributeActualSelector.val()
457
+ || '' == comboAttributeActualSelector.val()
458
+ ) {
459
+ comboAttributeActualSelector.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
460
+ if ( comboAttributeActualSelector.hasClass( 'toolset_select2-hidden-accessible' ) ) {
461
+ comboAttributeActualSelector
462
+ .toolset_select2()
463
+ .data( 'toolset_select2' )
464
+ .$selection
465
+ .addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
466
+ }
467
+ valid = false;
468
+ }
469
+ }
470
+ });
471
+
472
+ return valid;
473
+ };
474
+
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;
482
+
483
+ valid = self.requireShortcodeAttributes( evaluatedContainer );
484
+ if ( ! valid ) {
485
+ return false;
486
+ }
487
+ /*
488
+ $evaluatedContainer.find( 'input:text' ).each( function() {
489
+ var thiz = $( this ),
490
+ thiz_val = thiz.val(),
491
+ thiz_type = thiz.data( 'type' ),
492
+ thiz_message = '',
493
+ thiz_valid = true;
494
+ if ( ! thiz.hasClass( 'js-toolset-shortcode-gui-invalid-attr' ) ) {
495
+ switch ( thiz_type ) {
496
+ case 'number':
497
+ if (
498
+ self.numeric_natural_pattern.test( thiz_val ) == false
499
+ && thiz_val != ''
500
+ ) {
501
+ thiz_valid = false;
502
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
503
+ thiz_message = wpv_shortcodes_gui_texts.attr_number_invalid;
504
+ }
505
+ break;
506
+ case 'numberextended':
507
+ if (
508
+ self.numeric_natural_extended_pattern.test( thiz_val ) == false
509
+ && thiz_val != ''
510
+ ) {
511
+ thiz_valid = false;
512
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
513
+ thiz_message = wpv_shortcodes_gui_texts.attr_number_invalid;
514
+ }
515
+ break;
516
+ case 'numberlist':
517
+ if (
518
+ self.numeric_natural_list_pattern.test( thiz_val.replace(/\s+/g, '') ) == false
519
+ && thiz_val != ''
520
+ ) {
521
+ thiz_valid = false;
522
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
523
+ thiz_message = wpv_shortcodes_gui_texts.attr_numberlist_invalid;
524
+ }
525
+ break;
526
+ case 'year':
527
+ if (
528
+ self.year_pattern.test( thiz_val ) == false
529
+ && thiz_val != ''
530
+ ) {
531
+ thiz_valid = false;
532
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
533
+ thiz_message = wpv_shortcodes_gui_texts.attr_year_invalid;
534
+ }
535
+ break;
536
+ case 'month':
537
+ if (
538
+ self.month_pattern.test( thiz_val ) == false
539
+ && thiz_val != ''
540
+ ) {
541
+ thiz_valid = false;
542
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
543
+ thiz_message = wpv_shortcodes_gui_texts.attr_month_invalid;
544
+ }
545
+ break;
546
+ case 'week':
547
+ if (
548
+ self.week_pattern.test( thiz_val ) == false
549
+ && thiz_val != ''
550
+ ) {
551
+ thiz_valid = false;
552
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
553
+ thiz_message = wpv_shortcodes_gui_texts.attr_week_invalid;
554
+ }
555
+ break;
556
+ case 'day':
557
+ if (
558
+ self.day_pattern.test( thiz_val ) == false
559
+ && thiz_val != ''
560
+ ) {
561
+ thiz_valid = false;
562
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
563
+ thiz_message = wpv_shortcodes_gui_texts.attr_day_invalid;
564
+ }
565
+ break;
566
+ case 'hour':
567
+ if (
568
+ self.hour_pattern.test( thiz_val ) == false
569
+ && thiz_val != ''
570
+ ) {
571
+ thiz_valid = false;
572
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
573
+ thiz_message = wpv_shortcodes_gui_texts.attr_hour_invalid;
574
+ }
575
+ break;
576
+ case 'minute':
577
+ if (
578
+ self.minute_pattern.test( thiz_val ) == false
579
+ && thiz_val != ''
580
+ ) {
581
+ thiz_valid = false;
582
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
583
+ thiz_message = wpv_shortcodes_gui_texts.attr_minute_invalid;
584
+ }
585
+ break;
586
+ case 'second':
587
+ if (
588
+ self.second_pattern.test( thiz_val ) == false
589
+ && thiz_val != ''
590
+ ) {
591
+ thiz_valid = false;
592
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
593
+ thiz_message = wpv_shortcodes_gui_texts.attr_second_invalid;
594
+ }
595
+ break;
596
+ case 'dayofyear':
597
+ if (
598
+ self.dayofyear_pattern.test( thiz_val ) == false
599
+ && thiz_val != ''
600
+ ) {
601
+ thiz_valid = false;
602
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
603
+ thiz_message = wpv_shortcodes_gui_texts.attr_dayofyear_invalid;
604
+ }
605
+ break;
606
+ case 'dayofweek':
607
+ if (
608
+ self.dayofweek_pattern.test( thiz_val ) == false
609
+ && thiz_val != ''
610
+ ) {
611
+ thiz_valid = false;
612
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
613
+ thiz_message = wpv_shortcodes_gui_texts.attr_dayofweek_invalid;
614
+ }
615
+ break;
616
+ case 'url':
617
+ if (
618
+ self.url_patern.test( thiz_val ) == false
619
+ && thiz_val != ''
620
+ ) {
621
+ thiz_valid = false;
622
+ thiz.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
623
+ thiz_message = wpv_shortcodes_gui_texts.attr_url_invalid;
624
+ }
625
+ break;
626
+ }
627
+ if ( ! thiz_valid ) {
628
+ valid = false;
629
+ error_container
630
+ .wpvToolsetMessage({
631
+ text: thiz_message,
632
+ type: 'error',
633
+ inline: false,
634
+ stay: true
635
+ });
636
+ // Hack to allow more than one error message per filter
637
+ error_container
638
+ .data( 'message-box', null )
639
+ .data( 'has_message', false );
640
+ }
641
+ }
642
+ });
643
+ */
644
+ // Special case: item selector tab
645
+ if (
646
+ $( '.js-toolset-shortcode-gui-item-selector:checked', evaluatedContainer ).length > 0
647
+ && 'object_id' == $( '.js-toolset-shortcode-gui-item-selector:checked', evaluatedContainer ).val()
648
+ ) {
649
+ var itemSelection = $( '.js-toolset-shortcode-gui-item-selector_object_id', evaluatedContainer ),
650
+ itemSelectionId = itemSelection.val(),
651
+ itemSelectionValid = true;
652
+ //$itemSelectionMessage = '';
653
+ if ( '' == itemSelectionId ) {
654
+ itemSelectionValid = false;
655
+ itemSelection.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
656
+ if ( itemSelection.hasClass( 'toolset_select2-hidden-accessible' ) ) {
657
+ itemSelection
658
+ .toolset_select2()
659
+ .data( 'toolset_select2' )
660
+ .$selection
661
+ .addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
662
+ }
663
+ //$itemSelectionMessage = cred_shortcode_i18n.validation.mandatory;
664
+ } else if ( self.validationPatterns.number.test( itemSelectionId ) == false ) {
665
+ itemSelectionValid = false;
666
+ itemSelection.addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
667
+ if ( itemSelection.hasClass( 'toolset_select2-hidden-accessible' ) ) {
668
+ itemSelection
669
+ .toolset_select2()
670
+ .data( 'toolset_select2' )
671
+ .$selection
672
+ .addClass( 'toolset-shortcode-gui-invalid-attr js-toolset-shortcode-gui-invalid-attr' );
673
+ }
674
+ //$itemSelectionMessage = cred_shortcode_i18n.validation.number;
675
+ }
676
+ if ( ! itemSelectionValid ) {
677
+ valid = false;
678
+ }
679
+ }
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 = {},
692
+ shortcodeContent = '',
693
+ shortcodeToInsert = '',
694
+ shortcodeIsValid = self.validateShortcodeAttributes( $( '.js-toolset-shortcode-gui-dialog-container' ) );
695
+
696
+ if ( ! shortcodeIsValid ) {
697
+ return;
698
+ }
699
+
700
+ $( '.js-toolset-shortcode-gui-attribute-wrapper', '.js-toolset-shortcode-gui-dialog-container' ).each( function() {
701
+ var attributeWrapper = $( this ),
702
+ shortcodeAttributeKey = attributeWrapper.data( 'attribute' ),
703
+ shortcodeAttributeValue = '',
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':
733
+ case 'radiohtml':
734
+ shortcodeAttributeValue = $('input:checked', attributeWrapper ).val();
735
+ break;
736
+ case 'checkbox':
737
+ shortcodeAttributeValue = $('input:checked', attributeWrapper ).val();
738
+ break;
739
+ default:
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
764
+ ) {
765
+ shortcodeAttributeValues[ shortcodeAttributeKey ] = shortcodeAttributeValue;
766
+ }
767
+ });
768
+ // Filter pairs key => value
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
+
772
+ // Compose the shortcodeAttributeString string
773
+ _.each( shortcodeAttributeValues, function( value, key ) {
774
+ if ( value ) {
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 ) {
796
+ if ( 'toolsetCombo' == value ) {
797
+ resolvedAttributes[ key ] = data.rawAttributes[ 'toolsetCombo:' + key ];
798
+ } else if ( /^toolsetCombo/.test( key ) ) {
799
+ resolvedAttributes[ key ] = false;
800
+ } else {
801
+ resolvedAttributes[ key ] = value;
802
+ }
803
+ });
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 shortcodes GUI action.
813
+ *
814
+ * @param string shortcode The shortcode to action upon
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 ) {
823
+ case 'skip':
824
+ case 'create':
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 )
845
+ .dialog( 'open' ).dialog({
846
+ maxHeight: self.calculateDialogMaxHeight(),
847
+ maxWidth: self.calculateDialogMaxWidth(),
848
+ position: {
849
+ my: "center top+50",
850
+ at: "center top",
851
+ of: window,
852
+ collision: "none"
853
+ }
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;
863
+ if ( typeof( shortcode_data ) === 'object' ) {
864
+ shortcode_string = shortcode_data.shortcode;
865
+ } else {
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
873
+ * of Toolset shortcodes inside the various page builder modules fields.
874
+ * Here, we are offering the shortcodes created by the Toolset Shortcodes admin bar menu, in their
875
+ * new format, with the brackets replaced with placeholders but only on the Content Template edit page.
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.
883
+ 'toolset_page_ct-editor' === window.pagenow
884
+ && 'undefined' !== typeof window.vc
885
+ )
886
+ || (
887
+ $.inArray( window.adminpage, [ 'post-php', 'post-new-php' ] ) !== -1
888
+ && (
889
+ (
890
+ // Divi builder is enabled.
891
+ 'undefined' !== typeof window.et_builder
892
+ && $( '#et_pb_toggle_builder.et_pb_builder_is_used' ).length > 0
893
+ )
894
+ || (
895
+ // WPBakery Page Builder (former Visual Composer) is enabled.
896
+ 'undefined' !== typeof window.vc
897
+ && $( '.composer-switch.vc_backend-status' ).length > 0
898
+ )
899
+ || (
900
+ // Frontend WPBakery Page Builder (former Visual Composer) is enabled.
901
+ 'undefined' !== typeof window.vc
902
+ && (
903
+ $( '#vc_navbar.vc_navgar-frontend' ).length > 0
904
+ // Adding a second condition to catch the case that they will fix the typo in the class name.
905
+ || $( '#vc_navbar.vc_navbar-frontend' ).length > 0
906
+ )
907
+ )
908
+ || (
909
+ // Fusion Builder is enabled.
910
+ 'undefined' !== typeof window.FusionPageBuilder
911
+ && $( '#fusion_toggle_builder.fusion_builder_is_active' ).length > 0
912
+ )
913
+ )
914
+ )
915
+ ) {
916
+ shortcode_string = shortcode_string.replace( /\[/g, '{!{' ).replace( /]/g, '}!}' ).replace( /"/g, '\'' );
917
+ }
918
+
919
+ if ( typeof( shortcode_data ) === 'object' ) {
920
+ shortcode_data.shortcode = shortcode_string;
921
+ } else {
922
+ shortcode_data = shortcode_string;
923
+ }
924
+
925
+ return shortcode_data;
926
+ }
927
+
928
+ /**
929
+ * Init main method:
930
+ * - Init templates
931
+ * - Init dialogs.
932
+ * - Init API hooks.
933
+ *
934
+ * @since 2.5.4
935
+ */
936
+ self.init = function() {
937
+
938
+ self.initTemplates()
939
+ .initDialogs()
940
+ .initHooks()
941
+
942
+ };
943
+
944
+ self.init();
945
+
946
+ }
947
+
948
+ jQuery( document ).ready( function( $ ) {
949
+ Toolset.shortcodeGUI = new Toolset.shortcodeManager( $ );
950
+ });
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.3');
5
  }
6
 
7
  if ( ! defined('TOOLSET_COMMON_VERSION' ) ) {
8
- define( 'TOOLSET_COMMON_VERSION', '2.5.3' );
9
  }
10
 
11
  if ( ! defined('TOOLSET_COMMON_PATH' ) ) {
@@ -76,14 +76,16 @@ if ( ! function_exists( 'toolset_common_boostrap' ) ) {
76
  define( 'TOOLSET_COMMON_FRONTEND_PROTOCOL', 'http' ); // DEPRECATED
77
  }
78
 
79
- if( 0 != (int) $version_number ) {
 
 
80
 
81
  /**
82
  * If defined, this is an integer version number of the common library.
83
  *
84
  * It can be used for simple version comparison.
85
  *
86
- * @since m2m
87
  */
88
  define( 'TOOLSET_COMMON_VERSION_NUMBER', $version_number );
89
  }
1
  <?php
2
 
3
  if( !defined('TOOLSET_VERSION') ){
4
+ define('TOOLSET_VERSION', '2.5.5');
5
  }
6
 
7
  if ( ! defined('TOOLSET_COMMON_VERSION' ) ) {
8
+ define( 'TOOLSET_COMMON_VERSION', '2.5.5' );
9
  }
10
 
11
  if ( ! defined('TOOLSET_COMMON_PATH' ) ) {
76
  define( 'TOOLSET_COMMON_FRONTEND_PROTOCOL', 'http' ); // DEPRECATED
77
  }
78
 
79
+ // By preventing a re-definition we're easily allowing helper plugins like tcl-override to function.
80
+ // If nothing fancy is happening on the site, this will have zero impact.
81
+ if( 0 !== (int) $version_number && ! defined( 'TOOLSET_COMMON_VERSION_NUMBER' ) ) {
82
 
83
  /**
84
  * If defined, this is an integer version number of the common library.
85
  *
86
  * It can be used for simple version comparison.
87
  *
88
+ * @since 2.5.1
89
  */
90
  define( 'TOOLSET_COMMON_VERSION_NUMBER', $version_number );
91
  }
vendor/toolset/toolset-common/toolset-forms/classes/class.field_factory.php CHANGED
@@ -121,15 +121,40 @@ abstract class FieldFactory extends FieldAbstract
121
  return $actual_value;
122
  }
123
 
 
 
 
 
 
 
 
 
 
124
  public function getTitle($_title = false)
125
  {
126
- if( isset( $this->_data['title'] ) ) {
127
- return $this->_data['title'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  }
129
 
 
130
  if( isset( $this->_data['name'] ) && strpos( $this->_data['name'], 'wpcf' ) !== 0 ) {
131
  // legacy format
132
- $this->_data['name'];
133
  }
134
 
135
  return '';
121
  return $actual_value;
122
  }
123
 
124
+ /**
125
+ * Get the title of a field
126
+ *
127
+ * ATTENTION: Function uses $this->_data['title'] and $this->_data['_title']
128
+ *
129
+ * @param bool $_title
130
+ *
131
+ * @return bool|string
132
+ */
133
  public function getTitle($_title = false)
134
  {
135
+ $title = isset( $this->_data['title'] ) && ! empty( $this->_data['title'] )
136
+ ? $this->_data['title']
137
+ : false;
138
+
139
+ $_title = $_title && isset( $this->_data['_title'] )
140
+ ? $this->_data['_title']
141
+ : false;
142
+
143
+ // highest priority: '_title' should be used and 'title' is not set or empty
144
+ // note: '_title' just needs to be set, but it CAN BE empty
145
+ if ( $_title && ! $title ) {
146
+ return $_title;
147
+ }
148
+
149
+ // second priority: $this->_data['title'] is not empty
150
+ if( $title ) {
151
+ return $title;
152
  }
153
 
154
+ // last priority: $this->_data['name'] isset and not starting with 'wpcf'
155
  if( isset( $this->_data['name'] ) && strpos( $this->_data['name'], 'wpcf' ) !== 0 ) {
156
  // legacy format
157
+ return $this->_data['name'];
158
  }
159
 
160
  return '';
vendor/toolset/toolset-common/toolset-forms/classes/class.post.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This class is only needed for validation purposes.
5
+ *
6
+ * When a Post field is marked as mandatory, this class is neccesary for checking.
7
+ *
8
+ * @since m2m
9
+ */
10
+ class WPToolset_Field_Post extends FieldFactory {
11
+
12
+ }
vendor/toolset/toolset-common/user-editors/editor/avada.php CHANGED
@@ -24,8 +24,11 @@ class Toolset_User_Editors_Editor_Avada
24
 
25
  // register medium slug
26
  add_filter( 'fusion_builder_default_post_types', array( $this, 'support_medium' ) );
 
27
  }
28
 
 
 
29
  add_action( 'toolset_update_fusion_builder_post_meta', array( $this, 'update_fusion_builder_post_meta' ), 10, 2 );
30
 
31
  if (
@@ -63,6 +66,11 @@ class Toolset_User_Editors_Editor_Avada
63
 
64
  public function register_assets_for_backend_editor() {
65
  do_action( 'toolset_enqueue_scripts', array( 'toolset-user-editors-avada-script' ) );
 
 
 
 
 
66
  do_action( 'toolset_enqueue_styles', array( 'toolset-user-editors-avada-editor-style' ) );
67
  }
68
 
24
 
25
  // register medium slug
26
  add_filter( 'fusion_builder_default_post_types', array( $this, 'support_medium' ) );
27
+ add_filter( 'fusion_builder_allowed_post_types', array( $this, 'support_medium' ) );
28
  }
29
 
30
+ add_action( 'edit_form_after_editor', array( $this, 'register_assets_for_avada_compatibility' ) );
31
+
32
  add_action( 'toolset_update_fusion_builder_post_meta', array( $this, 'update_fusion_builder_post_meta' ), 10, 2 );
33
 
34
  if (
66
 
67
  public function register_assets_for_backend_editor() {
68
  do_action( 'toolset_enqueue_scripts', array( 'toolset-user-editors-avada-script' ) );
69
+ }
70
+
71
+ public function register_assets_for_avada_compatibility() {
72
+ // The enqueueing of the style for Fusion Builder was moved outside the "CT editing" condition to also support
73
+ // compatibility to the native post/page editor when Fusion Builder is used there too.
74
  do_action( 'toolset_enqueue_styles', array( 'toolset-user-editors-avada-editor-style' ) );
75
  }
76
 
vendor/toolset/toolset-common/user-editors/editor/basic.php CHANGED
@@ -14,6 +14,16 @@ class Toolset_User_Editors_Editor_Basic
14
  protected $id = 'basic';
15
  protected $name = 'HTML';
16
 
 
 
 
 
 
 
 
 
 
 
17
  public function required_plugin_active() {
18
  return true;
19
  }
@@ -21,4 +31,39 @@ class Toolset_User_Editors_Editor_Basic
21
  public function run() {
22
 
23
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  }
14
  protected $id = 'basic';
15
  protected $name = 'HTML';
16
 
17
+ const DIVI_SCREEN_ID = 'divi';
18
+ const AVADA_SCREEN_ID = 'avada';
19
+ const VC_SCREEN_ID = 'vc';
20
+ const NATIVE_SCREEN_ID = 'native';
21
+ const BEAVER_SCREEN_ID = 'beaver';
22
+
23
+ public function initialize() {
24
+ add_filter( 'wpv_filter_wpv_shortcodes_transform_format', array( $this, 'secure_shortcode_from_sanitization' ), 10, 2 );
25
+ }
26
+
27
  public function required_plugin_active() {
28
  return true;
29
  }
31
  public function run() {
32
 
33
  }
34
+
35
+ /**
36
+ * Transform all the shortcodes to the new format, using placeholders instead of brackets, whenever they are used
37
+ * for a Content Template that is built using a page builder.
38
+ *
39
+ * @param string $shortcode The shortcode string.
40
+ * @param int $content_template The current currently edited Content Template.
41
+ *
42
+ * @return string The transformed shortcode.
43
+ *
44
+ * @since 2.5.1
45
+ */
46
+ public function secure_shortcode_from_sanitization( $shortcode, $content_template ) {
47
+ if (
48
+ null !== $content_template
49
+ && 'view-template' === $content_template->post_type
50
+ && in_array(
51
+ get_post_meta(
52
+ $content_template->ID,
53
+ '_toolset_user_editors_editor_choice', true
54
+ ),
55
+ array(
56
+ self::DIVI_SCREEN_ID,
57
+ self::AVADA_SCREEN_ID,
58
+ self::VC_SCREEN_ID,
59
+ self::NATIVE_SCREEN_ID,
60
+ self::BEAVER_SCREEN_ID,
61
+ )
62
+ )
63
+ ) {
64
+ $shortcode = str_replace( '[', '{!{', $shortcode );
65
+ $shortcode = str_replace( ']', '}!}', $shortcode );
66
+ }
67
+ return $shortcode;
68
+ }
69
  }
vendor/toolset/toolset-common/user-editors/editor/divi.php CHANGED
@@ -57,7 +57,10 @@ class Toolset_User_Editors_Editor_Divi
57
  return false;
58
  }
59
 
60
- if ( defined( 'ET_BUILDER_THEME' ) ) {
 
 
 
61
  $this->name = __( 'Divi Builder', 'wpv-views' );
62
  return true;
63
  }
57
  return false;
58
  }
59
 
60
+ if (
61
+ defined( 'ET_BUILDER_THEME' )
62
+ || defined( 'ET_BUILDER_PLUGIN_VERSION' )
63
+ ) {
64
  $this->name = __( 'Divi Builder', 'wpv-views' );
65
  return true;
66
  }
vendor/toolset/toolset-common/user-editors/editor/screen/avada/backend_editor.css CHANGED
@@ -1,3 +1,15 @@
1
  .fusion-builder-modal-settings-container {
2
  z-index: 99998 !important;
 
 
 
 
 
 
 
 
 
 
 
 
3
  }
1
  .fusion-builder-modal-settings-container {
2
  z-index: 99998 !important;
3
+ }
4
+
5
+ .post-new-php #colorbox,
6
+ .post-new-php #cboxOverlay,
7
+ .post-new-php #cboxWrapper,
8
+ .post-php #colorbox,
9
+ .post-php #cboxOverlay,
10
+ .post-php #cboxWrapper,
11
+ .post-type-view-template #colorbox,
12
+ .post-type-view-template #cboxOverlay,
13
+ .post-type-view-template #cboxWrapper {
14
+ z-index: 99999 !important
15
  }
vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/backend.php CHANGED
@@ -6,6 +6,24 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
6
  private $post;
7
  public $editor;
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  public function initialize() {
10
  add_action( 'init', array( $this, 'register_assets' ), 50 );
11
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ), 50 );
@@ -13,7 +31,19 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
13
  add_filter( 'toolset_filter_toolset_registered_user_editors', array( $this, 'register_user_editor' ) );
14
  add_filter( 'wpv_filter_wpv_layout_template_extra_attributes', array( $this, 'layout_template_attribute' ), 10, 3 );
15
  add_action( 'wpv_action_wpv_ct_inline_user_editor_buttons', array( $this, 'register_inline_editor_action_buttons' ) );
16
-
 
 
 
 
 
 
 
 
 
 
 
 
17
  // Post edit page integration
18
  //add_action( 'edit_form_after_title', array( $this, 'preventNested' ) );
19
  }
@@ -105,9 +135,16 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
105
  TOOLSET_COMMON_VERSION,
106
  true
107
  );
108
-
 
 
 
 
 
 
 
109
  $vc_layout_template_i18n = array(
110
- 'template_editor_url' => admin_url( 'admin.php?page=ct-editor' ),
111
  'template_overlay' => array(
112
  'title' => sprintf( __( 'You created this template using %1$s', 'wpv-views' ), $this->editor->get_name() ),
113
  'button' => sprintf( __( 'Edit with %1$s', 'wpv-views' ), $this->editor->get_name() ),
@@ -122,61 +159,45 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
122
 
123
  }
124
 
125
- public function admin_enqueue_assets() {
 
 
 
126
  if ( $this->is_views_or_wpa_edit_page() ) {
127
  do_action( 'toolset_enqueue_scripts', array( 'toolset-user-editors-vc-layout-template-script' ) );
128
  }
129
 
130
- do_action( 'toolset_enqueue_scripts', array( 'toolset-user-editors-vc-script' ) );
 
 
 
 
 
 
 
 
 
131
  }
132
 
133
  public function html_output() {
134
-
135
- ob_start(); ?>
136
- <div style="display: none;">
137
- <input type="hidden" id="post_ID" name="post_ID" value="<?php echo $this->post->ID; ?>">
138
- <textarea cols="30" rows="10" id="wpv_content" name="wpv_content" data-bind="textInput: postContentAccepted"></textarea>
139
- <?php wp_editor( $this->post->post_content, 'content', array( 'media_buttons' => true ) ); ?>
140
- </div>
141
-
142
- <div id="wpb_visual_composer" style="padding-bottom: 5px; background: #fff;"><?php $this->editor->renderEditor( $this->post ); ?></div>
143
- <?php
144
- $script = "<script>
145
- jQuery( window ).load( function( ) {
146
- /* no fullscreen, no vc save button */
147
- jQuery( '#vc_navbar .vc_save-backend, #vc_fullscreen-button' ).remove();
148
-
149
- /* show vc editor */
150
- vc.app.show();
151
- vc.app.status = 'shown';
152
-
153
- var viewsBasicTextarea = jQuery( '#wpv_content' );
154
- var wordpressDefaultTextarea = jQuery( '#content' );
155
-
156
- /* Visual Composer fires the 'sync' event everytime something is changed */
157
- /* we use this to enable button 'Save all sections at once' if content has changed */
158
- vc.shortcodes.on( 'sync', function() {
159
- if( wordpressDefaultTextarea.val() != viewsBasicTextarea.val() ) {
160
- viewsBasicTextarea.val( wordpressDefaultTextarea.val() );
161
-
162
- WPViews.ct_edit_screen.vm.postContentAccepted = function(){ return wordpressDefaultTextarea.val() };
163
- WPViews.ct_edit_screen.vm.propertyChangeByComparator( 'postContent', _.isEqual );
164
- }
165
- } );
166
- } );</script>";
167
- echo preg_replace('/\v(?:[\v\h]+)/', '', $script);
168
  $output = ob_get_contents();
 
169
  ob_end_clean();
170
-
171
  $admin_url = admin_url( 'admin.php?page=ct-editor&ct_id=' . esc_attr( $_GET['ct_id'] ) );
172
- $output .= '<p>'
173
- . sprintf(
174
- __( '%1$sStop using %2$s for this Content Template%3$s', 'wpv-views' ),
175
- '<a href="' . esc_url( $admin_url ) . '&ct_editor_choice=basic">',
176
- 'Visual Composer',
177
- '</a>'
178
- )
179
- . '</p>';
180
 
181
  return $output;
182
  }
@@ -251,7 +272,7 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
251
  */
252
 
253
  public function layout_template_attribute( $attributes, $content_template, $view_id ) {
254
- $content_template_has_vc = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == 'vc' );
255
  if ( $content_template_has_vc ) {
256
  $attributes['builder'] = $this->editor->get_id();
257
  }
@@ -259,7 +280,7 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
259
  }
260
 
261
  public function register_inline_editor_action_buttons( $content_template ) {
262
- $content_template_has_vc = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == 'vc' );
263
  ?>
264
  <button
265
  class="button button-secondary js-wpv-ct-apply-user-editor js-wpv-ct-apply-user-editor-<?php echo esc_attr( $this->editor->get_id() ); ?>"
@@ -274,4 +295,41 @@ class Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend
274
  public function force_shortcode_generator_display( $register_section ) {
275
  return true;
276
  }
277
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  private $post;
7
  public $editor;
8
 
9
+ /**
10
+ * @var Toolset_Constants
11
+ */
12
+ protected $constants;
13
+
14
+ /**
15
+ * Toolset_User_Editors_Editor_Screen_Visual_Composer_Backend constructor.
16
+ *
17
+ * @param Toolset_Constants|null $constants
18
+ */
19
+ public function __construct( Toolset_Constants $constants = null ) {
20
+ $this->constants = $constants
21
+ ? $constants
22
+ : new Toolset_Constants();
23
+
24
+ $this->constants->define( 'VC_SCREEN_ID', 'vc' );
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 );
31
  add_filter( 'toolset_filter_toolset_registered_user_editors', array( $this, 'register_user_editor' ) );
32
  add_filter( 'wpv_filter_wpv_layout_template_extra_attributes', array( $this, 'layout_template_attribute' ), 10, 3 );
33
  add_action( 'wpv_action_wpv_ct_inline_user_editor_buttons', array( $this, 'register_inline_editor_action_buttons' ) );
34
+
35
+ add_filter( 'wpcf_filter_wpcf_admin_get_current_edited_post', array( $this, 'get_current_ct_id_for_wpcf_admin' ), 11, 1 );
36
+
37
+ add_action( 'wpv_action_wpv_save_item', array( $this, 'save_vc_custom_css' ) );
38
+
39
+ add_filter( 'vc_btn_a_href', array( 'WPV_Frontend_Render_Filters', 'replace_shortcode_placeholders_with_brackets' ) );
40
+ add_filter( 'vc_btn_a_href', 'do_shortcode' );
41
+
42
+ add_filter( 'vc_btn_a_title', array( 'WPV_Frontend_Render_Filters', 'replace_shortcode_placeholders_with_brackets' ) );
43
+ add_filter( 'vc_btn_a_title', 'do_shortcode' );
44
+
45
+ add_filter( 'vc_raw_html_module_content', array( 'WPV_Frontend_Render_Filters', 'replace_shortcode_placeholders_with_brackets' ) );
46
+
47
  // Post edit page integration
48
  //add_action( 'edit_form_after_title', array( $this, 'preventNested' ) );
49
  }
135
  TOOLSET_COMMON_VERSION,
136
  true
137
  );
138
+
139
+ $toolset_assets_manager->register_style(
140
+ 'toolset-user-editors-vc-editor-style',
141
+ TOOLSET_COMMON_URL . '/user-editors/editor/screen/visual-composer/backend_editor.css',
142
+ array(),
143
+ TOOLSET_COMMON_VERSION
144
+ );
145
+
146
  $vc_layout_template_i18n = array(
147
+ 'template_editor_url' => admin_url( 'admin.php?page=ct-editor' ),
148
  'template_overlay' => array(
149
  'title' => sprintf( __( 'You created this template using %1$s', 'wpv-views' ), $this->editor->get_name() ),
150
  'button' => sprintf( __( 'Edit with %1$s', 'wpv-views' ), $this->editor->get_name() ),
159
 
160
  }
161
 
162
+ public function admin_enqueue_assets( $screen_id ) {
163
+ $content_template_has_vc = ( get_post_meta( wpv_getget( 'ct_id' ), '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'VC_SCREEN_ID' ) );
164
+ $ct_edit_page_screen_id = class_exists( 'WPV_Page_Slug' ) ? WPV_Page_Slug::CONTENT_TEMPLATES_EDIT_PAGE : 'toolset_page_ct-editor';
165
+
166
  if ( $this->is_views_or_wpa_edit_page() ) {
167
  do_action( 'toolset_enqueue_scripts', array( 'toolset-user-editors-vc-layout-template-script' ) );
168
  }
169
 
170
+ if (
171
+ $content_template_has_vc
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
+ }
179
+
180
  }
181
 
182
  public function html_output() {
183
+
184
+ ob_start();
185
+
186
+ include_once( dirname( __FILE__ ) . '/backend.phtml' );
187
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  $output = ob_get_contents();
189
+
190
  ob_end_clean();
191
+
192
  $admin_url = admin_url( 'admin.php?page=ct-editor&ct_id=' . esc_attr( $_GET['ct_id'] ) );
193
+ $output .= '<p>'
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
+ 'Visual Composer',
198
+ '</a>'
199
+ )
200
+ . '</p>';
201
 
202
  return $output;
203
  }
272
  */
273
 
274
  public function layout_template_attribute( $attributes, $content_template, $view_id ) {
275
+ $content_template_has_vc = ( get_post_meta( $content_template->ID, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'VC_SCREEN_ID' ) );
276
  if ( $content_template_has_vc ) {
277
  $attributes['builder'] = $this->editor->get_id();
278
  }
280
  }
281
 
282
  public function register_inline_editor_action_buttons( $content_template ) {
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() ); ?>"
295
  public function force_shortcode_generator_display( $register_section ) {
296
  return true;
297
  }
298
+
299
+ /**
300
+ * Get the current content template ID to append to the third-party shortcodes added in the Fields and Views dialog.
301
+ *
302
+ * @param WP_POST $current_post The current post.
303
+ *
304
+ * @return WP_Post The filtered post.
305
+ *
306
+ * @since 2.5.1
307
+ */
308
+ public function get_current_ct_id_for_wpcf_admin( $current_post ) {
309
+ $ct_id = wpv_getget( 'ct_id' );
310
+
311
+ if ( ! empty( $ct_id ) ) {
312
+ $current_post = get_post( $ct_id );
313
+ }
314
+
315
+ return $current_post;
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
+ *
323
+ * @since 2.5.1
324
+ */
325
+ public function save_vc_custom_css( $content_template_id ) {
326
+ $content_template_has_vc = ( get_post_meta( $content_template_id, '_toolset_user_editors_editor_choice', true ) == $this->constants->constant( 'VC_SCREEN_ID' ) );
327
+ if ( $content_template_has_vc ) {
328
+ foreach ( $_POST['properties'] as $property ) {
329
+ if ( 'template_extra_css' === $property['name'] ) {
330
+ update_post_meta( $content_template_id, '_wpb_post_custom_css', $property['value'] );
331
+ }
332
+ }
333
+ }
334
+ }
335
+ }
vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/backend.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div style="display: none;">
2
+ <input type="hidden" id="post_ID" name="post_ID" value="<?php echo $this->post->ID; ?>">
3
+ <textarea cols="30" rows="10" id="wpv_content" name="wpv_content" data-bind="textInput: postContentAccepted"></textarea>
4
+ <textarea cols="30" rows="10" id="wpv_template_extra_css" name="name" data-bind="textInput: templateCssAccepted"></textarea>
5
+ <?php
6
+ wp_editor(
7
+ $this->post->post_content,
8
+ 'content',
9
+ array(
10
+ 'media_buttons' => true,
11
+ )
12
+ );
13
+ ?>
14
+ </div>
15
+
16
+ <div id="wpb_visual_composer" style="padding-bottom: 5px; background: #fff;"><?php $this->editor->renderEditor( $this->post ); ?></div>
vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/backend_editor.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ .toolset_page_ct-editor .vc_ui-panel.vc_ui-panel-window {
2
+ z-index: 20000;
3
+ }
vendor/toolset/toolset-common/user-editors/editor/screen/visual-composer/backend_editor.js CHANGED
@@ -58,10 +58,47 @@ ToolsetCommon.UserEditor.VisualComposerEditor = function( $ ) {
58
  }
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  self.init = function() {
62
  Toolset.hooks.addFilter( 'wpv-filter-wpv-shortcodes-gui-before-do-action', self.secureShortcodeFromSanitization );
63
 
64
  Toolset.hooks.addFilter( 'wpv-filter-wpv-shortcodes-transform-format', self.secureShortcodeFromSanitization );
 
 
65
  };
66
 
67
  self.init();
58
  }
59
  }
60
 
61
+ self.initializeVisualComposerBackendEditor = function() {
62
+ $( window ).load( function() {
63
+ /* no fullscreen, no vc save button */
64
+ jQuery( '#vc_navbar .vc_save-backend, #vc_fullscreen-button' ).remove();
65
+
66
+ /* show vc editor */
67
+ vc.app.show();
68
+ vc.app.status = 'shown';
69
+
70
+ var viewsBasicTextarea = jQuery( '#wpv_content' );
71
+ var wordpressDefaultTextarea = jQuery( '#content' );
72
+
73
+ var viewsCSSArea = jQuery( '#wpv_template_extra_css' );
74
+ vc.post_settings_view.on( 'save', function() {
75
+ if( this.saved_css_data != vc.$custom_css.val() ) {
76
+ viewsCSSArea.val( vc.$custom_css.val() );
77
+
78
+ WPViews.ct_edit_screen.vm.templateCssAccepted = function(){ return vc.$custom_css.val(); };
79
+ WPViews.ct_edit_screen.vm.propertyChangeByComparator( 'templateCss', _.isEqual );
80
+ }
81
+ } );
82
+
83
+ /* Visual Composer fires the 'sync' event everytime something is changed */
84
+ /* we use this to enable button 'Save all sections at once' if content has changed */
85
+ vc.shortcodes.on( 'sync', function() {
86
+ if( wordpressDefaultTextarea.val() != viewsBasicTextarea.val() ) {
87
+ viewsBasicTextarea.val( wordpressDefaultTextarea.val() );
88
+
89
+ WPViews.ct_edit_screen.vm.postContentAccepted = function(){ return wordpressDefaultTextarea.val() };
90
+ WPViews.ct_edit_screen.vm.propertyChangeByComparator( 'postContent', _.isEqual );
91
+ }
92
+ } );
93
+ });
94
+ }
95
+
96
  self.init = function() {
97
  Toolset.hooks.addFilter( 'wpv-filter-wpv-shortcodes-gui-before-do-action', self.secureShortcodeFromSanitization );
98
 
99
  Toolset.hooks.addFilter( 'wpv-filter-wpv-shortcodes-transform-format', self.secureShortcodeFromSanitization );
100
+
101
+ self.initializeVisualComposerBackendEditor();
102
  };
103
 
104
  self.init();
vendor/toolset/toolset-common/utility/condition/plugin/types/ready_for_m2m.php CHANGED
@@ -8,7 +8,7 @@
8
  class Toolset_Condition_Plugin_Types_Ready_For_M2M extends Toolset_Condition_Plugin_Types_Active {
9
 
10
  public function is_met() {
11
- return ( parent::is_met() && true === apply_filters( 'types_is_ready_for_m2m', false ) );
12
  }
13
 
14
  }
8
  class Toolset_Condition_Plugin_Types_Ready_For_M2M extends Toolset_Condition_Plugin_Types_Active {
9
 
10
  public function is_met() {
11
+ return ( parent::is_met() && true === apply_filters( 'toolset_is_m2m_ready', false ) );
12
  }
13
 
14
  }
vendor/toolset/toolset-common/utility/help-videos/res/css/toolset-help-videos-retro.css ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .toolset-wrap{
2
+ position:relative;
3
+ }
4
+ .toolset-videos-wrapper{
5
+ clear: both;
6
+ margin: 10px 0 0 0;
7
+ width: 820px;
8
+ float:left;
9
+ }
10
+ .toolset-video-box-wrap{
11
+ position: relative;
12
+ display:block;
13
+ /*width:100%;*/
14
+ height:100%;
15
+ float:left;
16
+ clear:both;
17
+ overflow:hidden;
18
+ margin-top:20px;
19
+ margin-bottom:20px;
20
+ }
21
+ .toolset-wrap .toolset-video-box-wrap{overflow:visible;}
22
+
23
+ .toolset-box-video {
24
+ position: relative;
25
+ top: 10px;
26
+ overflow: hidden;
27
+ }
28
+
29
+ .toolset-box-container {
30
+ margin-bottom: 0px;
31
+ }
32
+
33
+ .toolset-box-container:empty {
34
+ margin: 0;
35
+ }
36
+ .toolset-box-content{margin-bottom:2px;}
37
+ .remove-video{float:right;}
38
+ .remove-video-icon{font-size:16px;margin-right:2px;}
39
+ .remove-video-icon:hover{color:#0073aa;}
40
+ .toolset-box-footer{
41
+ position: relative;
42
+ width:100%;
43
+ display: block;
44
+ overflow: hidden;
45
+ padding:4px 0px 0px 0px;
46
+ }
47
+ .toolset-box-header{
48
+ position: relative;
49
+ width:100%;
50
+ display: block;
51
+ overflow: hidden;
52
+ padding:0px 0px 4px 0px;
53
+ }
54
+ .remove-video{cursor:pointer;}
55
+ .button.remove-video{margin:0px 0px 0px 4px;}
56
+ .remove-video-icon{position:relative;bottom:-1px;font-size:16px;}
57
+ .video-box-title{
58
+ margin-bottom:0px;
59
+ padding-bottom:0px;
60
+ margin-top:0px;
61
+ padding-top:0px;
62
+ font-weight:normal;
63
+ font-size:13px;
64
+ }
65
+ .video-box-title-open{
66
+ margin-bottom:0px;
67
+ padding-bottom:0px;
68
+ margin-top:0px;
69
+ padding-top:0px;
70
+ position:relative;
71
+ top:30px;
72
+ color:white;
73
+ z-index:8888;
74
+ font-family: 'FontAwesome'!important;
75
+ font-style: normal!important;
76
+ float:left;
77
+ margin-left:30px;
78
+ font-size:24px;
79
+ display:block;
80
+ }
81
+ .video-box-title-open i{
82
+ font-family: 'FontAwesome'!important;
83
+ font-style: normal!important;
84
+ }
85
+ span.mejs-offscreen{display:none!important;}
86
+ .video-title-alone{cursor:pointer;}
87
+ /**** LIST *****/
88
+ .js-video-list{
89
+ color:#0073aa;
90
+ cursor:pointer;
91
+ }
92
+ .toolset-video-icon{
93
+ font-size:14px;
94
+ margin-left:6px;
95
+ }
96
+ /*** OVERLAY ****/
97
+ /*OVERLAY*/
98
+ /* ------- */
99
+ /* Overlay */
100
+ /* ------- */
101
+ .toolset-box-container .loader-overlay {
102
+ position: absolute;
103
+ top: 0;
104
+ right: 0;
105
+ bottom: 0;
106
+ left: 0;
107
+ z-index: 3;
108
+ background: #000;
109
+ text-align: center;
110
+ opacity: .4;
111
+ width:100%;
112
+ height:100%;
113
+ float:left;
114
+ }
115
+ .toolset-box-container .loader-overlay-high-z {
116
+ z-index: 8888;
117
+ }
118
+
119
+ .toolset-box-container .preloader {
120
+ position:absolute;
121
+ z-index: 100;
122
+ top:50%;
123
+ left:48%;
124
+ /*display: inline-block;*/
125
+ margin: -32px 0 0 -32px;
126
+ width: 64px;
127
+ height: 64px;
128
+ background: url('../images/ajax-loader-overlay2.gif') center center no-repeat;
129
+ font-family: 'FontAwesome'!important;
130
+ font-style: normal!important;
131
+ }
132
+ .toolset-box-container .preloader i.fa.fa-play-circle{
133
+ font-family: 'FontAwesome'!important;
134
+ font-style: normal!important;
135
+ font-size:7em;
136
+ cursor:pointer;
137
+ }
138
+ .toolset-box-container .preloader i.fa.fa-play-circle:hover{color:white;opacity: 1;}
vendor/toolset/toolset-common/utility/help-videos/res/css/toolset-help-videos.css CHANGED
@@ -25,6 +25,7 @@
25
  top: 10px;
26
  overflow: hidden;
27
  }
 
28
 
29
  .toolset-box-container {
30
  margin-bottom: 0px;
25
  top: 10px;
26
  overflow: hidden;
27
  }
28
+ .toolset-box-video div.mejs-overlay-play{display:none!important;} /** let's make sure that the overlay is hidden even if original JS has $overlay.show(); **/
29
 
30
  .toolset-box-container {
31
  margin-bottom: 0px;
vendor/toolset/toolset-common/utility/help-videos/res/js/toolset-help-videos-retro.js ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var WP_Toolset = WPV_Toolset || {};
2
+
3
+ WP_Toolset.HelpVideos = {};
4
+
5
+ if( typeof _ !== 'undefined' && _.templateSettings )
6
+ {
7
+ _.templateSettings = {
8
+ escape: /\{\{([^\}]+?)\}\}(?!\})/g,
9
+ evaluate: /<#([\s\S]+?)#>/g,
10
+ interpolate: /\{\{\{([\s\S]+?)\}\}\}/g
11
+ };
12
+ }
13
+
14
+ WP_Toolset.HelpVideosFactory = function ($) {
15
+ var self = this,
16
+ videos = WP_ToolsetVideoSettings.video_instances,
17
+ current = WP_ToolsetVideoSettings.current,
18
+ seen = WP_ToolsetVideoSettings.seen,
19
+ collection,
20
+ append_done = false,
21
+ triggered_manually = false,
22
+ collection_view = null;
23
+
24
+ self.init = function () {
25
+ return self.show_video(current);
26
+ };
27
+
28
+ self.get_seen = function(){
29
+ return seen;
30
+ }
31
+
32
+ self.populate_collection = function(){
33
+ collection = new WP_Toolset.HelpVideosCollection();
34
+ _.each(videos, function(v){
35
+ collection.add( new WP_Toolset.HelpVideo( v ) );
36
+ });
37
+ return collection;
38
+ };
39
+
40
+ self.get_videos = function(){
41
+ return collection;
42
+ };
43
+
44
+ self.create_on_the_fly = function(element,append_to){
45
+ if( append_done === false ){
46
+ var el = self.create_element(element);
47
+ jQuery(append_to).append(el);
48
+ append_done = true;
49
+ }
50
+ };
51
+
52
+ self.handle_list = function(){
53
+ var models = self.populate_collection();
54
+ collection_view = new WP_Toolset.HelpVideosListView({model:models});
55
+ jQuery( '.js-toolset-videos-wrapper' ).append( jQuery(WP_ToolsetVideoSettings.VIDEOS_LIST_TITLE), collection_view.$el );
56
+ };
57
+
58
+ self.show_video = function( video ){
59
+ if ( videos.hasOwnProperty(video) ) {
60
+
61
+ if( adminpage !== WP_ToolsetVideoSettings.detached_page && videos[video].hasOwnProperty('append_to') && videos[video].append_to !== '' ){
62
+ self.create_on_the_fly( videos[video].element ? videos[video].element : WP_ToolsetVideoSettings.GENERIC_ELEMENT, videos[video].append_to );
63
+ }
64
+
65
+ var model = WP_Toolset.HelpVideos.hasOwnProperty(video) ? WP_Toolset.HelpVideos[video] : new WP_Toolset.HelpVideo(videos[video]),
66
+ view = new WP_Toolset.HelpVideoView({
67
+ el: videos[video].element ? videos[video].element : WP_ToolsetVideoSettings.GENERIC_ELEMENT,
68
+ model: model
69
+ });
70
+
71
+ if( adminpage !== WP_ToolsetVideoSettings.detached_page && self.get_seen() === 'seen' && triggered_manually === false ){
72
+ view.$el.hide();
73
+ view.manual_trigger();
74
+ triggered_manually = true;
75
+ }
76
+
77
+ jQuery('.js-toolset-videos-wrapper').width( model.get('width') ).height( model.get('height') );
78
+
79
+ WP_Toolset.HelpVideos[video] = model;
80
+
81
+ return WP_Toolset.HelpVideos[video];
82
+ }
83
+
84
+ return null;
85
+ };
86
+
87
+ self.show_new_video = function( model ){
88
+ self.remove_list();
89
+ jQuery('.js-toolset-videos-wrapper').append( self.create_element( model.get('element') ) );
90
+ self.show_video( model.get('name') );
91
+ };
92
+
93
+ self.create_element = function( selector ){
94
+ var sel = selector.substring(1);
95
+ return jQuery('<div class="'+sel+'" id="'+sel+'"></div>')
96
+ };
97
+
98
+ self.remove_list = function(){
99
+ jQuery('.js-videos-list-title').remove();
100
+ collection_view.remove();
101
+ };
102
+
103
+ self.init();
104
+ };
105
+
106
+ WP_Toolset.HelpVideo = Backbone.Model.extend({
107
+ defaults: {
108
+ title:'',
109
+ name: '',
110
+ url: '',
111
+ element: '',
112
+ screens: [],
113
+ width:'600px',
114
+ height:'400px'
115
+ }
116
+ });
117
+
118
+ WP_Toolset.HelpVideosCollection = Backbone.Collection.extend({
119
+ model:WP_Toolset.HelpVideo,
120
+ current:null
121
+ });
122
+
123
+
124
+ WP_Toolset.HelpVideoView = Backbone.View.extend({
125
+ DELAY:200,
126
+ initialize: function (options) {
127
+ var self = this;
128
+ self.template_selector = '#toolset-video-template';
129
+ self.template = _.template(jQuery(self.template_selector).html());
130
+ self.deatch_url = WP_ToolsetVideoSettings.detach_url;
131
+ self.render(options).el;
132
+ },
133
+ render: function (options) {
134
+ var self = this;
135
+ self.$el.html(self.template(self.model.toJSON()));
136
+ self.wrap = jQuery('.js-toolset-box-container', self.$el);
137
+ self.handle_detach();
138
+ self.wrap.loaderOverlay('show', {
139
+ class:'loader-overlay-high-z',
140
+ css : {
141
+ "opacity" : "0.65",
142
+ height : self.model.get('height')
143
+ }
144
+ }
145
+ );
146
+ self.hidden_wrap = jQuery('.js-video-player-box', self.$el);
147
+ self.remove_button = jQuery('.js-remove-video', self.$el);
148
+ self.handle_video();
149
+ self.remove_video();
150
+ return self;
151
+ },
152
+ handle_detach:function(){
153
+ var self = this, $button = jQuery('.js-detach-video', self.$el);
154
+ if( adminpage === WP_ToolsetVideoSettings.detached_page ){
155
+ $button.hide();
156
+ } else {
157
+ $button.on('click', function(event){
158
+ event.stopImmediatePropagation();
159
+ event.preventDefault();
160
+ self.remove_button.trigger('click');
161
+ window.open( self.deatch_url );
162
+ });
163
+ }
164
+ },
165
+ handle_video:function(){
166
+ var self = this;
167
+ var video = jQuery('.js-video-player');
168
+ if( video.length === 0 ) return; // if no player instances in DOM then do nothing
169
+ self.player = new MediaElementPlayer( video, {
170
+ alwaysShowHours: false,
171
+ width:self.model.get('width'),
172
+ height:self.model.get('height'),
173
+ success: function (mediaElement, domObject) {
174
+ mediaElement.addEventListener('loadeddata', function(e) {
175
+ mediaElement.pause();
176
+ self.hidden_wrap.fadeIn(self.DELAY, function(event){
177
+ self.setPlay( mediaElement );
178
+
179
+ });
180
+ }, false);
181
+
182
+ mediaElement.addEventListener('ended', function(e) {
183
+ self.setPlay( mediaElement, true );
184
+ }, false);
185
+ mediaElement.addEventListener('play', function(e) {
186
+ jQuery('.mejs-mediaelement').loaderOverlay('hide');
187
+ }, false);
188
+ },
189
+ // fires when a problem is detected
190
+ error: function () {
191
+
192
+ }
193
+ } );
194
+ },
195
+ setPlay:function( mediaElement, after_ended ){
196
+ var play = jQuery('<i class="fa fa-play-circle js-toolset-play-video"></i>'),
197
+ $title = jQuery('.js-video-box-title-open').eq(0).detach().clone();
198
+
199
+ jQuery('.mejs-mediaelement').loaderOverlay('show', {
200
+ class:'loader-overlay-high-z',
201
+ css : {
202
+ "opacity" : "0.7",
203
+ 'height': jQuery('.mejs-mediaelement').height() - 30 + 'px'
204
+ }
205
+ });
206
+
207
+
208
+ jQuery('.js-video-box-title-open').remove();
209
+ jQuery('.toolset-box-container .loader-overlay').append($title);
210
+
211
+ jQuery('.toolset-box-container .preloader').css({
212
+ 'background':'none'
213
+ }).append(play);
214
+
215
+ jQuery('.js-toolset-play-video').on('click', function(event){
216
+ event.stopImmediatePropagation();
217
+ event.preventDefault();
218
+ jQuery('.mejs-mediaelement').loaderOverlay('hide',{onRemove:function(){
219
+
220
+ mediaElement.play();
221
+
222
+ }});
223
+ });
224
+
225
+ this.wrap.loaderOverlay('hide',{onRemove:function(){
226
+ }, fadeOutSpeed:200});
227
+ },
228
+ remove_video:function(){
229
+ var self = this;
230
+ self.remove_button.on('click', function(event){
231
+ event.stopImmediatePropagation();
232
+ event.preventDefault();
233
+ self.$el.hide(400, function(){
234
+ if( adminpage === WP_ToolsetVideoSettings.detached_page ){
235
+ WP_Toolset.HelpVideos.main.handle_list();
236
+ } else {
237
+ self.insert_title_view();
238
+ }
239
+ self.remove();
240
+ });
241
+ });
242
+ },
243
+ manual_trigger:function(){
244
+ var self = this;
245
+ self.remove_button.trigger('click');
246
+ },
247
+ insert_title_view:function(){
248
+ var self = this,
249
+ index = self.$el.index(),
250
+ parent = self.$el.parent(),
251
+ element = self.model.get('element') ? self.model.get('element').substring(1) : WP_ToolsetVideoSettings.GENERIC_ELEMENT,
252
+ new_me = new WP_Toolset.HelpVideoListView({
253
+ model:self.model,
254
+ template_selector:'#toolset-video-header-template',
255
+ tagName:'div',
256
+ classes:element,
257
+ id:element
258
+ });
259
+
260
+ parent.insertAtIndex(index, new_me.$el);
261
+ return new_me;
262
+ }
263
+ });
264
+
265
+ WP_Toolset.HelpVideoListView = Backbone.View.extend({
266
+ initialize:function(options){
267
+ var self = this;
268
+ self.tagName = options.tagName;
269
+ self.$el.addClass(options.classes + ' video-title-alone');
270
+ if( options.hasOwnProperty('id') ){
271
+ self.$el.prop('id', options.id);
272
+ }
273
+ self.template_selector = options.template_selector;
274
+ self.template = _.template(jQuery(self.template_selector).html());
275
+ self.render( options ).el
276
+ return self;
277
+ },
278
+ render:function( options ){
279
+ var self = this;
280
+ self.$el.html(self.template(self.model.toJSON()));
281
+ self.show();
282
+ return self;
283
+ },
284
+ show:function(){
285
+ var self = this;
286
+ self.$el.on('click', function(event){
287
+ event.stopImmediatePropagation();
288
+ event.preventDefault();
289
+ if( adminpage === WP_ToolsetVideoSettings.detached_page ) {
290
+ WP_Toolset.HelpVideos.main.show_new_video(self.model);
291
+ } else {
292
+ self.insert_video_view();
293
+ }
294
+ });
295
+ },
296
+ insert_video_view:function(){
297
+ var self = this,
298
+ index = self.$el.index(),
299
+ parent = self.$el.parent();
300
+
301
+ self.$el.empty();
302
+ parent.insertAtIndex( index, self.$el.clone() );
303
+ self.remove();
304
+ WP_Toolset.HelpVideos.main.show_video( self.model.get('name') );
305
+ }
306
+ });
307
+
308
+ WP_Toolset.HelpVideosListView = Backbone.View.extend({
309
+ el:'.js-videos-list',
310
+ tagName: 'ul',
311
+ initialize:function(options){
312
+ var self = this;
313
+ self.$el = self.create_element();
314
+ self.el = self.$el[0];
315
+ self.render(options).el;
316
+ return self;
317
+ },
318
+ render:function( option ){
319
+
320
+ var self = this,
321
+ options = _.extend({}, option);
322
+
323
+ self.$el.empty();
324
+
325
+ self.fragment = document.createDocumentFragment();
326
+
327
+ self.appendModelElement( options );
328
+
329
+ self.$el.append( self.fragment );
330
+
331
+ return self;
332
+ },
333
+ appendModelElement:function( option ){
334
+ var self = this, view, el, options = option;
335
+
336
+ self.model.each(function(model){
337
+
338
+ try{
339
+
340
+ options = {
341
+ model:model
342
+ }
343
+
344
+ view = new WP_Toolset.HelpVideoListView({
345
+ model:model,
346
+ template_selector:'#toolset-video-list-template',
347
+ tagName:'li',
348
+ classes:'js-video-list toolset-video-list'
349
+ });
350
+
351
+ el = view.el;
352
+
353
+ self.fragment.appendChild( el );
354
+
355
+ }
356
+ catch( e )
357
+ {
358
+ console.error( e.message );
359
+ }
360
+ }, self)
361
+
362
+ return this;
363
+ },
364
+ create_element:function(){
365
+ return jQuery('<ul class="js-videos-list toolset-videos-list"></ul>');
366
+ }
367
+ });
368
+
369
+ (function ($) {
370
+ $(function () {
371
+ WP_Toolset.HelpVideos.main = {};
372
+ WP_Toolset.HelpVideosFactory.call(WP_Toolset.HelpVideos.main, $);
373
+ });
374
+ }(jQuery));
vendor/toolset/toolset-common/utility/help-videos/res/js/toolset-help-videos.js CHANGED
@@ -166,18 +166,20 @@ WP_Toolset.HelpVideoView = Backbone.View.extend({
166
  var self = this;
167
  var video = jQuery('.js-video-player');
168
  if( video.length === 0 ) return; // if no player instances in DOM then do nothing
169
- self.player = new MediaElementPlayer( video, {
170
  alwaysShowHours: false,
171
  width:self.model.get('width'),
172
  height:self.model.get('height'),
173
- success: function (mediaElement, domObject) {
174
- mediaElement.addEventListener('loadeddata', function(e) {
 
175
  mediaElement.pause();
176
  self.hidden_wrap.fadeIn(self.DELAY, function(event){
177
  self.setPlay( mediaElement );
178
-
179
  });
180
- }, false);
 
181
 
182
  mediaElement.addEventListener('ended', function(e) {
183
  self.setPlay( mediaElement, true );
@@ -188,7 +190,7 @@ WP_Toolset.HelpVideoView = Backbone.View.extend({
188
  },
189
  // fires when a problem is detected
190
  error: function () {
191
-
192
  }
193
  } );
194
  },
@@ -216,9 +218,7 @@ WP_Toolset.HelpVideoView = Backbone.View.extend({
216
  event.stopImmediatePropagation();
217
  event.preventDefault();
218
  jQuery('.mejs-mediaelement').loaderOverlay('hide',{onRemove:function(){
219
-
220
  mediaElement.play();
221
-
222
  }});
223
  });
224
 
166
  var self = this;
167
  var video = jQuery('.js-video-player');
168
  if( video.length === 0 ) return; // if no player instances in DOM then do nothing
169
+ self.player = new MediaElementPlayer( video[0], {
170
  alwaysShowHours: false,
171
  width:self.model.get('width'),
172
  height:self.model.get('height'),
173
+ success: function (mediaElement, domObject, instance) {
174
+ var playerContainer = instance.getElement(instance.container);
175
+ var startPlayer = function(e) {
176
  mediaElement.pause();
177
  self.hidden_wrap.fadeIn(self.DELAY, function(event){
178
  self.setPlay( mediaElement );
179
+ e.target.removeEventListener( 'controlsshown', startPlayer, false );
180
  });
181
+ };
182
+ playerContainer.addEventListener('controlsshown', startPlayer, false);
183
 
184
  mediaElement.addEventListener('ended', function(e) {
185
  self.setPlay( mediaElement, true );
190
  },
191
  // fires when a problem is detected
192
  error: function () {
193
+ console.log( 'error', arguments );
194
  }
195
  } );
196
  },
218
  event.stopImmediatePropagation();
219
  event.preventDefault();
220
  jQuery('.mejs-mediaelement').loaderOverlay('hide',{onRemove:function(){
 
221
  mediaElement.play();
 
222
  }});
223
  });
224
 
vendor/toolset/toolset-common/utility/help-videos/toolset-help-videos.php CHANGED
@@ -52,17 +52,32 @@ if( ! class_exists( 'Toolset_HelpVideo', false ) ) {
52
  return $user_id;
53
  }
54
 
 
 
 
 
 
55
  public function add_register_scripts($scripts)
56
  {
57
- $scripts['toolset-help-video'] = new Toolset_Script('toolset-help-video', TOOLSET_COMMON_URL . '/utility/help-videos/res/js/toolset-help-videos.js', array('jquery', 'underscore', 'backbone', 'wp-mediaelement', 'toolset-utils'), '1.0', true);
 
 
 
 
 
58
  return $scripts;
59
  }
60
 
61
- public function add_register_styles($styles)
62
- {
63
- $styles['toolset-help-video'] = new Toolset_Style('toolset-help-video', TOOLSET_COMMON_URL . '/utility/help-videos/res/css/toolset-help-videos.css');
64
- return $styles;
65
- }
 
 
 
 
 
66
 
67
  public function admin_enqueue_scripts()
68
  {
52
  return $user_id;
53
  }
54
 
55
+ private function is_wp_older_than_4_dot_9(){
56
+ $current = get_bloginfo('version');
57
+ return version_compare( $current, '4.9-RC1' ) === -1;
58
+ }
59
+
60
  public function add_register_scripts($scripts)
61
  {
62
+ if( $this->is_wp_older_than_4_dot_9() ){
63
+ $scripts['toolset-help-video'] = new Toolset_Script('toolset-help-video', TOOLSET_COMMON_URL . '/utility/help-videos/res/js/toolset-help-videos-retro.js', array('jquery', 'underscore', 'backbone', 'wp-mediaelement', 'toolset-utils'), '1.0', true);
64
+ } else {
65
+ $scripts['toolset-help-video'] = new Toolset_Script('toolset-help-video', TOOLSET_COMMON_URL . '/utility/help-videos/res/js/toolset-help-videos.js', array('jquery', 'underscore', 'backbone', 'wp-mediaelement', 'toolset-utils'), '1.0', true);
66
+ }
67
+
68
  return $scripts;
69
  }
70
 
71
+ public function add_register_styles($styles)
72
+ {
73
+ if( $this->is_wp_older_than_4_dot_9() ) {
74
+ $styles['toolset-help-video'] = new Toolset_Style( 'toolset-help-video', TOOLSET_COMMON_URL . '/utility/help-videos/res/css/toolset-help-videos-retro.css' );
75
+ } else {
76
+ $styles['toolset-help-video'] = new Toolset_Style( 'toolset-help-video', TOOLSET_COMMON_URL . '/utility/help-videos/res/css/toolset-help-videos.css' );
77
+ }
78
+
79
+ return $styles;
80
+ }
81
 
82
  public function admin_enqueue_scripts()
83
  {
vendor/toolset/types/admin.php CHANGED
@@ -96,9 +96,6 @@ if ( !defined('WPCF_AUTHOR' )){
96
  function wpcf_admin_init_hook()
97
  {
98
  wp_register_style('wpcf-css-embedded', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION );
99
-
100
- wp_enqueue_style('toolset-dashicons');
101
-
102
  }
103
 
104
 
96
  function wpcf_admin_init_hook()
97
  {
98
  wp_register_style('wpcf-css-embedded', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION );
 
 
 
99
  }
100
 
101
 
vendor/toolset/types/embedded/classes/editor.php CHANGED
@@ -334,6 +334,8 @@ class WPCF_Editor
334
  $shortcode = preg_replace( '@</?script[^>]*>@im', '', wp_kses_post($shortcode) );
335
  // Add additional parameters if required
336
  $shortcode = $this->_add_parameters_to_shortcode( $shortcode, $_POST );
 
 
337
  // Insert shortcode
338
  echo '<script type="text/javascript">jQuery(function(){tedFrame.close("'
339
  . $shortcode . '", "' . esc_js( $shortcode ) . '");});</script>';
334
  $shortcode = preg_replace( '@</?script[^>]*>@im', '', wp_kses_post($shortcode) );
335
  // Add additional parameters if required
336
  $shortcode = $this->_add_parameters_to_shortcode( $shortcode, $_POST );
337
+ // Perform a filtering of the shortcode to support different shortcode formats.
338
+ $shortcode = apply_filters( 'wpv_filter_wpv_shortcodes_transform_format', $shortcode, $this->_post );
339
  // Insert shortcode
340
  echo '<script type="text/javascript">jQuery(function(){tedFrame.close("'
341
  . $shortcode . '", "' . esc_js( $shortcode ) . '");});</script>';
vendor/toolset/types/embedded/classes/loader.php CHANGED
@@ -179,14 +179,6 @@ class WPCF_Loader
179
  WPCF_EMBEDDED_RES_RELPATH . '/css/colorbox.css', array(),
180
  WPCF_VERSION );
181
  }
182
- if ( !wp_style_is( 'toolset-dashicons', 'registered' ) ) {
183
- wp_register_style(
184
- 'toolset-dashicons',
185
- WPCF_EMBEDDED_RES_RELPATH . '/css/dashicons.css',
186
- array(),
187
- WPCF_VERSION
188
- );
189
- }
190
  }
191
 
192
  /**
179
  WPCF_EMBEDDED_RES_RELPATH . '/css/colorbox.css', array(),
180
  WPCF_VERSION );
181
  }
 
 
 
 
 
 
 
 
182
  }
183
 
184
  /**
vendor/toolset/types/embedded/includes/import-export.php CHANGED
@@ -22,12 +22,19 @@ function wpcf_admin_import_data( $data = '', $redirect = true, $context = 'types
22
  $return = array();
23
 
24
  libxml_use_internal_errors( true );
 
 
 
25
  $data = simplexml_load_string( $data );
26
  if ( ! $data ) {
27
- $return[] = array(
28
- 'type' => 'error',
29
- 'content' => __( 'Error parsing XML: ', 'wpcf' ) . $error->message
30
- );
 
 
 
 
31
  libxml_clear_errors();
32
 
33
  return $return;
22
  $return = array();
23
 
24
  libxml_use_internal_errors( true );
25
+
26
+ // remove any non UTF-8 characters
27
+ $data = preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', '', $data);
28
  $data = simplexml_load_string( $data );
29
  if ( ! $data ) {
30
+
31
+ foreach ( libxml_get_errors() as $error ) {
32
+ $return[] = array(
33
+ 'type' => 'error',
34
+ 'content' => sprintf( __( 'Error on line %s', 'wpcf' ), $error->line ) . ': '. $error->message
35
+ );
36
+ }
37
+
38
  libxml_clear_errors();
39
 
40
  return $return;
vendor/toolset/types/embedded/resources/css/basic.css CHANGED
@@ -1450,4 +1450,13 @@ input#slug+p.wpcf-form-description {
1450
  }
1451
  .ui-sortable-handle .description{
1452
  font-weight: normal;
 
 
 
 
 
 
 
 
 
1453
  }
1450
  }
1451
  .ui-sortable-handle .description{
1452
  font-weight: normal;
1453
+ }
1454
+
1455
+ /* Part of removed file: ./dashicons.css */
1456
+ div.wpcf-types-menu-image {
1457
+ float: left;
1458
+ width: 36px;
1459
+ height: 34px;
1460
+ margin: 0;
1461
+ text-align: center;
1462
  }
vendor/toolset/types/embedded/resources/css/dashicons.css DELETED
@@ -1,829 +0,0 @@
1
- /**
2
- *
3
- *
4
- */
5
-
6
- div.wpcf-types-menu-image {
7
- float: left;
8
- width: 36px;
9
- height: 34px;
10
- margin: 0;
11
- text-align: center;
12
- }
13
-
14
- .dashicons-menu:before
15
- {
16
- content: "\f333";
17
- }
18
- .dashicons-admin-site:before
19
- {
20
- content: "\f319";
21
- }
22
- .dashicons-dashboard:before
23
- {
24
- content: "\f226";
25
- }
26
- .dashicons-admin-post:before
27
- {
28
- content: "\f109";
29
- }
30
- .dashicons-admin-media:before
31
- {
32
- content: "\f104";
33
- }
34
- .dashicons-admin-links:before
35
- {
36
- content: "\f103";
37
- }
38
- .dashicons-admin-page:before
39
- {
40
- content: "\f105";
41
- }
42
- .dashicons-admin-comments:before
43
- {
44
- content: "\f101";
45
- }
46
- .dashicons-admin-appearance:before
47
- {
48
- content: "\f100";
49
- }
50
- .dashicons-admin-plugins:before
51
- {
52
- content: "\f106";
53
- }
54
- .dashicons-admin-users:before
55
- {
56
- content: "\f110";
57
- }
58
- .dashicons-admin-tools:before
59
- {
60
- content: "\f107";
61
- }
62
- .dashicons-admin-settings:before
63
- {
64
- content: "\f108";
65
- }
66
- .dashicons-admin-network:before
67
- {
68
- content: "\f112";
69
- }
70
- .dashicons-admin-home:before
71
- {
72
- content: "\f102";
73
- }
74
- .dashicons-admin-generic:before
75
- {
76
- content: "\f111";
77
- }
78
- .dashicons-admin-collapse:before
79
- {
80
- content: "\f148";
81
- }
82
-
83
- <!-- welcome screen -->
84
- .dashicons-welcome-write-blog:before
85
- {
86
- content: "\f119";
87
- }
88
- .dashicons-welcome-add-page:before
89
- {
90
- content: "\f133";
91
- }
92
- .dashicons-welcome-view-site:before
93
- {
94
- content: "\f115";
95
- }
96
- .dashicons-welcome-widgets-menus:before
97
- {
98
- content: "\f116";
99
- }
100
- .dashicons-welcome-comments:before
101
- {
102
- content: "\f117";
103
- }
104
- .dashicons-welcome-learn-more:before
105
- {
106
- content: "\f118";
107
- }
108
-
109
- <!-- post formats -->
110
- .dashicons-format-aside:before
111
- {
112
- content: "\f123";
113
- }
114
- .dashicons-format-image:before
115
- {
116
- content: "\f128";
117
- }
118
- .dashicons-format-gallery:before
119
- {
120
- content: "\f161";
121
- }
122
- .dashicons-format-video:before
123
- {
124
- content: "\f126";
125
- }
126
- .dashicons-format-status:before
127
- {
128
- content: "\f130";
129
- }
130
- .dashicons-format-quote:before
131
- {
132
- content: "\f122";
133
- }
134
- .dashicons-format-chat:before
135
- {
136
- content: "\f125";
137
- }
138
- .dashicons-format-audio:before
139
- {
140
- content: "\f127";
141
- }
142
- .dashicons-camera:before
143
- {
144
- content: "\f306";
145
- }
146
- .dashicons-images-alt:before
147
- {
148
- content: "\f232";
149
- }
150
- .dashicons-images-alt2:before
151
- {
152
- content: "\f233";
153
- }
154
- .dashicons-video-alt:before
155
- {
156
- content: "\f234";
157
- }
158
- .dashicons-video-alt2:before
159
- {
160
- content: "\f235";
161
- }
162
- .dashicons-video-alt3:before
163
- {
164
- content: "\f236";
165
- }
166
-
167
- <!-- media -->
168
- .dashicons-media-archive:before
169
- {
170
- content: "\f501";
171
- }
172
- .dashicons-media-audio:before
173
- {
174
- content: "\f500";
175
- }
176
- .dashicons-media-code:before
177
- {
178
- content: "\f499";
179
- }
180
- .dashicons-media-default:before
181
- {
182
- content: "\f498";
183
- }
184
- .dashicons-media-document:before
185
- {
186
- content: "\f497";
187
- }
188
- .dashicons-media-interactive:before
189
- {
190
- content: "\f496";
191
- }
192
- .dashicons-media-spreadsheet:before
193
- {
194
- content: "\f495";
195
- }
196
- .dashicons-media-text:before
197
- {
198
- content: "\f491";
199
- }
200
- .dashicons-media-video:before
201
- {
202
- content: "\f490";
203
- }
204
- .dashicons-playlist-audio:before
205
- {
206
- content: "\f492";
207
- }
208
- .dashicons-playlist-video:before
209
- {
210
- content: "\f493";
211
- }
212
-
213
- <!-- image editing -->
214
- .dashicons-image-crop:before
215
- {
216
- content: "\f165";
217
- }
218
- .dashicons-image-rotate-left:before
219
- {
220
- content: "\f166";
221
- }
222
- .dashicons-image-rotate-right:before
223
- {
224
- content: "\f167";
225
- }
226
- .dashicons-image-flip-vertical:before
227
- {
228
- content: "\f168";
229
- }
230
- .dashicons-image-flip-horizontal:before
231
- {
232
- content: "\f169";
233
- }
234
- .dashicons-undo:before
235
- {
236
- content: "\f171";
237
- }
238
- .dashicons-redo:before
239
- {
240
- content: "\f172";
241
- }
242
-
243
- <!-- tinymce -->
244
- .dashicons-editor-bold:before
245
- {
246
- content: "\f200";
247
- }
248
- .dashicons-editor-italic:before
249
- {
250
- content: "\f201";
251
- }
252
- .dashicons-editor-ul:before
253
- {
254
- content: "\f203";
255
- }
256
- .dashicons-editor-ol:before
257
- {
258
- content: "\f204";
259
- }
260
- .dashicons-editor-quote:before
261
- {
262
- content: "\f205";
263
- }
264
- .dashicons-editor-alignleft:before
265
- {
266
- content: "\f206";
267
- }
268
- .dashicons-editor-aligncenter:before
269
- {
270
- content: "\f207";
271
- }
272
- .dashicons-editor-alignright:before
273
- {
274
- content: "\f208";
275
- }
276
- .dashicons-editor-insertmore:before
277
- {
278
- content: "\f209";
279
- }
280
- .dashicons-editor-spellcheck:before
281
- {
282
- content: "\f210";
283
- }
284
- .dashicons-editor-expand:before
285
- {
286
- content: "\f211";
287
- }
288
- .dashicons-editor-contract:before
289
- {
290
- content: "\f506";
291
- }
292
- .dashicons-editor-kitchensink:before
293
- {
294
- content: "\f212";
295
- }
296
- .dashicons-editor-underline:before
297
- {
298
- content: "\f213";
299
- }
300
- .dashicons-editor-justify:before
301
- {
302
- content: "\f214";
303
- }
304
- .dashicons-editor-textcolor:before
305
- {
306
- content: "\f215";
307
- }
308
- .dashicons-editor-paste-word:before
309
- {
310
- content: "\f216";
311
- }
312
- .dashicons-editor-paste-text:before
313
- {
314
- content: "\f217";
315
- }
316
- .dashicons-editor-removeformatting:before
317
- {
318
- content: "\f218";
319
- }
320
- .dashicons-editor-video:before
321
- {
322
- content: "\f219";
323
- }
324
- .dashicons-editor-customchar:before
325
- {
326
- content: "\f220";
327
- }
328
- .dashicons-editor-outdent:before
329
- {
330
- content: "\f221";
331
- }
332
- .dashicons-editor-indent:before
333
- {
334
- content: "\f222";
335
- }
336
- .dashicons-editor-help:before
337
- {
338
- content: "\f223";
339
- }
340
- .dashicons-editor-strikethrough:before
341
- {
342
- content: "\f224";
343
- }
344
- .dashicons-editor-unlink:before
345
- {
346
- content: "\f225";
347
- }
348
- .dashicons-editor-rtl:before
349
- {
350
- content: "\f320";
351
- }
352
- .dashicons-editor-break:before
353
- {
354
- content: "\f464";
355
- }
356
- .dashicons-editor-code:before
357
- {
358
- content: "\f475";
359
- }
360
- .dashicons-editor-paragraph:before
361
- {
362
- content: "\f476";
363
- }
364
-
365
- <!-- posts -->
366
- .dashicons-align-left:before
367
- {
368
- content: "\f135";
369
- }
370
- .dashicons-align-right:before
371
- {
372
- content: "\f136";
373
- }
374
- .dashicons-align-center:before
375
- {
376
- content: "\f134";
377
- }
378
- .dashicons-align-none:before
379
- {
380
- content: "\f138";
381
- }
382
- .dashicons-lock:before
383
- {
384
- content: "\f160";
385
- }
386
- .dashicons-calendar:before
387
- {
388
- content: "\f145";
389
- }
390
- .dashicons-visibility:before
391
- {
392
- content: "\f177";
393
- }
394
- .dashicons-post-status:before
395
- {
396
- content: "\f173";
397
- }
398
- .dashicons-edit:before
399
- {
400
- content: "\f464";
401
- }
402
- .dashicons-trash:before
403
- {
404
- content: "\f182";
405
- }
406
-
407
- <!-- sorting -->
408
- .dashicons-external:before
409
- {
410
- content: "\f504";
411
- }
412
- .dashicons-arrow-up:before
413
- {
414
- content: "\f142";
415
- }
416
- .dashicons-arrow-down:before
417
- {
418
- content: "\f140";
419
- }
420
- .dashicons-arrow-right:before
421
- {
422
- content: "\f139";
423
- }
424
- .dashicons-arrow-left:before
425
- {
426
- content: "\f141";
427
- }
428
- .dashicons-arrow-up-alt:before
429
- {
430
- content: "\f342";
431
- }
432
- .dashicons-arrow-down-alt:before
433
- {
434
- content: "\f346";
435
- }
436
- .dashicons-arrow-right-alt:before
437
- {
438
- content: "\f344";
439
- }
440
- .dashicons-arrow-left-alt:before
441
- {
442
- content: "\f340";
443
- }
444
- .dashicons-arrow-up-alt2:before
445
- {
446
- content: "\f343";
447
- }
448
- .dashicons-arrow-down-alt2:before
449
- {
450
- content: "\f347";
451
- }
452
- .dashicons-arrow-right-alt2:before
453
- {
454
- content: "\f345";
455
- }
456
- .dashicons-arrow-left-alt2:before
457
- {
458
- content: "\f341";
459
- }
460
- .dashicons-sort:before
461
- {
462
- content: "\f156";
463
- }
464
- .dashicons-leftright:before
465
- {
466
- content: "\f229";
467
- }
468
- .dashicons-randomize:before
469
- {
470
- content: "\f503";
471
- }
472
- .dashicons-list-view:before
473
- {
474
- content: "\f163";
475
- }
476
- .dashicons-exerpt-view:before
477
- {
478
- content: "\f164";
479
- }
480
-
481
- <!-- social -->
482
- .dashicons-share:before
483
- {
484
- content: "\f237";
485
- }
486
- .dashicons-share-alt:before
487
- {
488
- content: "\f240";
489
- }
490
- .dashicons-share-alt2:before
491
- {
492
- content: "\f242";
493
- }
494
- .dashicons-twitter:before
495
- {
496
- content: "\f301";
497
- }
498
- .dashicons-rss:before
499
- {
500
- content: "\f303";
501
- }
502
- .dashicons-email:before
503
- {
504
- content: "\f465";
505
- }
506
- .dashicons-email-alt:before
507
- {
508
- content: "\f466";
509
- }
510
- .dashicons-facebook:before
511
- {
512
- content: "\f304";
513
- }
514
- .dashicons-facebook-alt:before
515
- {
516
- content: "\f305";
517
- }
518
- .dashicons-googleplus:before
519
- {
520
- content: "\f462";
521
- }
522
- .dashicons-networking:before
523
- {
524
- content: "\f325";
525
- }
526
-
527
- <!-- WPorg specific icons: Jobs, Profiles, WordCamps -->
528
- .dashicons-hammer:before
529
- {
530
- content: "\f308";
531
- }
532
- .dashicons-art:before
533
- {
534
- content: "\f309";
535
- }
536
- .dashicons-migrate:before
537
- {
538
- content: "\f310";
539
- }
540
- .dashicons-performance:before
541
- {
542
- content: "\f311";
543
- }
544
- .dashicons-universal-access:before
545
- {
546
- content: "\f483";
547
- }
548
- .dashicons-universal-access-alt:before
549
- {
550
- content: "\f507";
551
- }
552
- .dashicons-tickets:before
553
- {
554
- content: "\f486";
555
- }
556
- .dashicons-nametag:before
557
- {
558
- content: "\f484";
559
- }
560
- .dashicons-clipboard:before
561
- {
562
- content: "\f481";
563
- }
564
- .dashicons-heart:before
565
- {
566
- content: "\f487";
567
- }
568
- .dashicons-megaphone:before
569
- {
570
- content: "\f488";
571
- }
572
- .dashicons-schedule:before
573
- {
574
- content: "\f489";
575
- }
576
-
577
- <!-- internal/products -->
578
- .dashicons-wordpress:before
579
- {
580
- content: "\f120";
581
- }
582
- .dashicons-wordpress-alt:before
583
- {
584
- content: "\f324";
585
- }
586
- .dashicons-pressthis:before
587
- {
588
- content: "\f157";
589
- }
590
- .dashicons-update:before
591
- {
592
- content: "\f463";
593
- }
594
- .dashicons-screenoptions:before
595
- {
596
- content: "\f180";
597
- }
598
- .dashicons-info:before
599
- {
600
- content: "\f348";
601
- }
602
- .dashicons-cart:before
603
- {
604
- content: "\f174";
605
- }
606
- .dashicons-feedback:before
607
- {
608
- content: "\f175";
609
- }
610
- .dashicons-cloud:before
611
- {
612
- content: "\f176";
613
- }
614
- .dashicons-translation:before
615
- {
616
- content: "\f326";
617
- }
618
-
619
- <!-- taxonomies -->
620
- .dashicons-tag:before
621
- {
622
- content: "\f323";
623
- }
624
- .dashicons-category:before
625
- {
626
- content: "\f318";
627
- }
628
-
629
- <!-- widgets -->
630
- .dashicons-archive:before
631
- {
632
- content: "\f478";
633
- }
634
- .dashicons-tagcloud:before
635
- {
636
- content: "\f479";
637
- }
638
- .dashicons-text:before
639
- {
640
- content: "\f480";
641
- }
642
-
643
- <!-- alerts/notifications/flags -->
644
- .dashicons-yes:before
645
- {
646
- content: "\f147";
647
- }
648
- .dashicons-no:before
649
- {
650
- content: "\f158";
651
- }
652
- .dashicons-no-alt:before
653
- {
654
- content: "\f335";
655
- }
656
- .dashicons-plus:before
657
- {
658
- content: "\f132";
659
- }
660
- .dashicons-plus-alt:before
661
- {
662
- content: "\f502";
663
- }
664
- .dashicons-minus:before
665
- {
666
- content: "\f460";
667
- }
668
- .dashicons-dismiss:before
669
- {
670
- content: "\f153";
671
- }
672
- .dashicons-marker:before
673
- {
674
- content: "\f159";
675
- }
676
- .dashicons-star-filled:before
677
- {
678
- content: "\f155";
679
- }
680
- .dashicons-star-half:before
681
- {
682
- content: "\f459";
683
- }
684
- .dashicons-star-empty:before
685
- {
686
- content: "\f154";
687
- }
688
- .dashicons-flag:before
689
- {
690
- content: "\f227";
691
- }
692
-
693
- <!-- misc/cpt -->
694
- .dashicons-location:before
695
- {
696
- content: "\f230";
697
- }
698
- .dashicons-location-alt:before
699
- {
700
- content: "\f231";
701
- }
702
- .dashicons-vault:before
703
- {
704
- content: "\f178";
705
- }
706
- .dashicons-shield:before
707
- {
708
- content: "\f332";
709
- }
710
- .dashicons-shield-alt:before
711
- {
712
- content: "\f334";
713
- }
714
- .dashicons-sos:before
715
- {
716
- content: "\f468";
717
- }
718
- .dashicons-search:before
719
- {
720
- content: "\f179";
721
- }
722
- .dashicons-slides:before
723
- {
724
- content: "\f181";
725
- }
726
- .dashicons-analytics:before
727
- {
728
- content: "\f183";
729
- }
730
- .dashicons-chart-pie:before
731
- {
732
- content: "\f184";
733
- }
734
- .dashicons-chart-bar:before
735
- {
736
- content: "\f185";
737
- }
738
- .dashicons-chart-line:before
739
- {
740
- content: "\f238";
741
- }
742
- .dashicons-chart-area:before
743
- {
744
- content: "\f239";
745
- }
746
- .dashicons-groups:before
747
- {
748
- content: "\f307";
749
- }
750
- .dashicons-businessman:before
751
- {
752
- content: "\f338";
753
- }
754
- .dashicons-id:before
755
- {
756
- content: "\f336";
757
- }
758
- .dashicons-id-alt:before
759
- {
760
- content: "\f337";
761
- }
762
- .dashicons-products:before
763
- {
764
- content: "\f312";
765
- }
766
- .dashicons-awards:before
767
- {
768
- content: "\f313";
769
- }
770
- .dashicons-forms:before
771
- {
772
- content: "\f314";
773
- }
774
- .dashicons-testimonial:before
775
- {
776
- content: "\f473";
777
- }
778
- .dashicons-portfolio:before
779
- {
780
- content: "\f322";
781
- }
782
- .dashicons-book:before
783
- {
784
- content: "\f330";
785
- }
786
- .dashicons-book-alt:before
787
- {
788
- content: "\f331";
789
- }
790
- .dashicons-download:before
791
- {
792
- content: "\f316";
793
- }
794
- .dashicons-upload:before
795
- {
796
- content: "\f317";
797
- }
798
- .dashicons-backup:before
799
- {
800
- content: "\f321";
801
- }
802
- .dashicons-clock:before
803
- {
804
- content: "\f469";
805
- }
806
- .dashicons-lightbulb:before
807
- {
808
- content: "\f339";
809
- }
810
- .dashicons-microphone:before
811
- {
812
- content: "\f482";
813
- }
814
- .dashicons-desktop:before
815
- {
816
- content: "\f472";
817
- }
818
- .dashicons-tablet:before
819
- {
820
- content: "\f471";
821
- }
822
- .dashicons-smartphone:before
823
- {
824
- content: "\f470";
825
- }
826
- .dashicons-smiley:before
827
- {
828
- content: "\f328";
829
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/toolset/types/embedded/resources/js/editor.js CHANGED
@@ -152,6 +152,16 @@ var tedFrame = (function(window, $){
152
 
153
  function insertShortcode( shortcode, esc_shortcode )
154
  {
 
 
 
 
 
 
 
 
 
 
155
  if ( ted.callback == 'views_wizard' ) {
156
  window.parent.typesWPViews.wizardSendShortcode( shortcode );
157
  return true;
152
 
153
  function insertShortcode( shortcode, esc_shortcode )
154
  {
155
+ /**
156
+ * Perform a filtering of the shortcode to support different shortcode formats.
157
+ *
158
+ * @param string shortcode The shortcode to be filtered.
159
+ *
160
+ * @since 2.2.20
161
+ */
162
+ shortcode = window.parent.Toolset.hooks.applyFilters( 'wpv-filter-wpv-shortcodes-transform-format', shortcode );
163
+ esc_shortcode = window.parent.Toolset.hooks.applyFilters( 'wpv-filter-wpv-shortcodes-transform-format', esc_shortcode );
164
+
165
  if ( ted.callback == 'views_wizard' ) {
166
  window.parent.typesWPViews.wizardSendShortcode( shortcode );
167
  return true;
vendor/toolset/types/embedded/views/image.php CHANGED
@@ -260,11 +260,16 @@ class Types_Image_View
260
  "Error resampling image {$img}", $dims );
261
  }
262
 
 
 
 
263
  // convert from full colors to index colors, like original PNG.
264
  if ( IMAGETYPE_PNG == $imgData->imagetype && function_exists( 'imageistruecolor' ) && !imageistruecolor( $imgRes ) ) {
265
  imagetruecolortopalette( $new_image, false,
266
  imagecolorstotal( $imgRes ) );
267
  }
 
 
268
  // we don't need the original in memory anymore
269
  imagedestroy( $imgRes );
270
 
260
  "Error resampling image {$img}", $dims );
261
  }
262
 
263
+ /* COMMENTED OUT TO NOT USE INDEXED COLORS FOR RESIZED PNGs, EVEN IF THE SOURCE HAS INDEXED COLORS.
264
+ * REASON: TRANSPARENT SUPPORT NOT WORKING 100% AFTER RESIZING USING INDEXED COLORS
265
+ *
266
  // convert from full colors to index colors, like original PNG.
267
  if ( IMAGETYPE_PNG == $imgData->imagetype && function_exists( 'imageistruecolor' ) && !imageistruecolor( $imgRes ) ) {
268
  imagetruecolortopalette( $new_image, false,
269
  imagecolorstotal( $imgRes ) );
270
  }
271
+ */
272
+
273
  // we don't need the original in memory anymore
274
  imagedestroy( $imgRes );
275
 
vendor/toolset/types/includes/import-export.php CHANGED
@@ -649,11 +649,14 @@ function wpcf_admin_import_export_settings($data)
649
  '#after' => '<br />',
650
  );
651
  libxml_use_internal_errors( true );
 
 
 
652
  $data = simplexml_load_string( $data );
653
  if ( !$data ) {
654
  echo '<div class="message error"><p>' . __( 'Error parsing XML', 'wpcf' ) . '</p></div>';
655
  foreach ( libxml_get_errors() as $error ) {
656
- echo '<div class="message error"><p>' . $error->message . '</p></div>';
657
  }
658
  libxml_clear_errors();
659
  return false;
649
  '#after' => '<br />',
650
  );
651
  libxml_use_internal_errors( true );
652
+
653
+ // remove any non UTF-8 characters (see types-596)
654
+ $data = preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', '', $data);
655
  $data = simplexml_load_string( $data );
656
  if ( !$data ) {
657
  echo '<div class="message error"><p>' . __( 'Error parsing XML', 'wpcf' ) . '</p></div>';
658
  foreach ( libxml_get_errors() as $error ) {
659
+ echo '<div class="message error"><p> ' . sprintf( __( 'Error on line %s', 'wpcf' ), $error->line ) . ': '. $error->message . '</p></div>';
660
  }
661
  libxml_clear_errors();
662
  return false;
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.19
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.19' );
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.20
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.20' );
33
  }
34
 
35
  // backward compatibility