From fc3b96fe063715f81fd7cb566fadfae4d9c5463a Mon Sep 17 00:00:00 2001 From: Stephen Page Date: Mon, 19 Feb 2024 18:24:18 -0500 Subject: [PATCH 1/8] Update composer --- composer.lock | 185 ++++++++++++++++++++++---------------------------- 1 file changed, 82 insertions(+), 103 deletions(-) diff --git a/composer.lock b/composer.lock index 67ed3b2f17..f648faae95 100644 --- a/composer.lock +++ b/composer.lock @@ -618,16 +618,16 @@ "packages-dev": [ { "name": "antecedent/patchwork", - "version": "2.1.27", + "version": "2.1.28", "source": { "type": "git", "url": "https://github.com/antecedent/patchwork.git", - "reference": "16a1ab81559aabf14acb616141e801b32777f085" + "reference": "6b30aff81ebadf0f2feb9268d3e08385cebcc08d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/antecedent/patchwork/zipball/16a1ab81559aabf14acb616141e801b32777f085", - "reference": "16a1ab81559aabf14acb616141e801b32777f085", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/6b30aff81ebadf0f2feb9268d3e08385cebcc08d", + "reference": "6b30aff81ebadf0f2feb9268d3e08385cebcc08d", "shasum": "" }, "require": { @@ -660,9 +660,9 @@ ], "support": { "issues": "https://github.com/antecedent/patchwork/issues", - "source": "https://github.com/antecedent/patchwork/tree/2.1.27" + "source": "https://github.com/antecedent/patchwork/tree/2.1.28" }, - "time": "2023-12-03T18:46:49+00:00" + "time": "2024-02-06T09:26:11+00:00" }, { "name": "automattic/vipwpcs", @@ -1203,16 +1203,16 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", "shasum": "" }, "require": { @@ -1244,22 +1244,22 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.2" + "source": "https://github.com/doctrine/deprecations/tree/1.1.3" }, - "time": "2023-09-27T20:04:15+00:00" + "time": "2024-01-30T19:34:25+00:00" }, { "name": "doctrine/inflector", - "version": "2.0.9", + "version": "2.0.10", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "2930cd5ef353871c821d5c43ed030d39ac8cfe65" + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/2930cd5ef353871c821d5c43ed030d39ac8cfe65", - "reference": "2930cd5ef353871c821d5c43ed030d39ac8cfe65", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/5817d0659c5b50c9b950feb9af7b9668e2c436bc", + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc", "shasum": "" }, "require": { @@ -1321,7 +1321,7 @@ ], "support": { "issues": "https://github.com/doctrine/inflector/issues", - "source": "https://github.com/doctrine/inflector/tree/2.0.9" + "source": "https://github.com/doctrine/inflector/tree/2.0.10" }, "funding": [ { @@ -1337,7 +1337,7 @@ "type": "tidelift" } ], - "time": "2024-01-15T18:05:13+00:00" + "time": "2024-02-18T20:23:39+00:00" }, { "name": "doctrine/instantiator", @@ -2453,16 +2453,16 @@ }, { "name": "nesbot/carbon", - "version": "2.72.1", + "version": "2.72.3", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "2b3b3db0a2d0556a177392ff1a3bf5608fa09f78" + "reference": "0c6fd108360c562f6e4fd1dedb8233b423e91c83" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/2b3b3db0a2d0556a177392ff1a3bf5608fa09f78", - "reference": "2b3b3db0a2d0556a177392ff1a3bf5608fa09f78", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/0c6fd108360c562f6e4fd1dedb8233b423e91c83", + "reference": "0c6fd108360c562f6e4fd1dedb8233b423e91c83", "shasum": "" }, "require": { @@ -2556,7 +2556,7 @@ "type": "tidelift" } ], - "time": "2023-12-08T23:47:49+00:00" + "time": "2024-01-25T10:35:09+00:00" }, { "name": "nilportugues/sql-query-formatter", @@ -3005,16 +3005,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.8.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc" + "reference": "bc3dc91a5e9b14aa06d1d9e90647c5c5a2cc5353" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fad452781b3d774e3337b0c0b245dd8e5a4455fc", - "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/bc3dc91a5e9b14aa06d1d9e90647c5c5a2cc5353", + "reference": "bc3dc91a5e9b14aa06d1d9e90647c5c5a2cc5353", "shasum": "" }, "require": { @@ -3057,9 +3057,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.0" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.1" }, - "time": "2024-01-11T11:49:22+00:00" + "time": "2024-01-18T19:15:27+00:00" }, { "name": "phpspec/prophecy", @@ -4552,16 +4552,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.8.1", + "version": "3.9.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "14f5fff1e64118595db5408e946f3a22c75807f7" + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7", - "reference": "14f5fff1e64118595db5408e946f3a22c75807f7", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", "shasum": "" }, "require": { @@ -4628,7 +4628,7 @@ "type": "open_collective" } ], - "time": "2024-01-11T20:47:48+00:00" + "time": "2024-02-16T15:06:51+00:00" }, { "name": "stellarwp/coding-standards", @@ -5280,16 +5280,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", "shasum": "" }, "require": { @@ -5303,9 +5303,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -5342,7 +5339,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" }, "funding": [ { @@ -5358,20 +5355,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "ecaafce9f77234a6a449d29e49267ba10499116d" + "reference": "a287ed7475f85bf6f61890146edbc932c0fff919" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/ecaafce9f77234a6a449d29e49267ba10499116d", - "reference": "ecaafce9f77234a6a449d29e49267ba10499116d", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/a287ed7475f85bf6f61890146edbc932c0fff919", + "reference": "a287ed7475f85bf6f61890146edbc932c0fff919", "shasum": "" }, "require": { @@ -5384,9 +5381,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -5429,7 +5423,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.29.0" }, "funding": [ { @@ -5445,20 +5439,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:30:37+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", "shasum": "" }, "require": { @@ -5469,9 +5463,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -5513,7 +5504,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" }, "funding": [ { @@ -5529,20 +5520,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "42292d99c55abe617799667f454222c54c60e229" + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", - "reference": "42292d99c55abe617799667f454222c54c60e229", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { @@ -5556,9 +5547,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -5596,7 +5584,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" }, "funding": [ { @@ -5612,20 +5600,20 @@ "type": "tidelift" } ], - "time": "2023-07-28T09:04:16+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179" + "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/70f4aebd92afca2f865444d30a4d2151c13c3179", - "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/861391a8da9a04cbad2d232ddd9e4893220d6e25", + "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25", "shasum": "" }, "require": { @@ -5633,9 +5621,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -5672,7 +5657,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php72/tree/v1.29.0" }, "funding": [ { @@ -5688,20 +5673,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5" + "reference": "21bd091060673a1177ae842c0ef8fe30893114d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fe2f306d1d9d346a7fee353d0d5012e401e984b5", - "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/21bd091060673a1177ae842c0ef8fe30893114d2", + "reference": "21bd091060673a1177ae842c0ef8fe30893114d2", "shasum": "" }, "require": { @@ -5709,9 +5694,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -5751,7 +5733,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.29.0" }, "funding": [ { @@ -5767,20 +5749,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", "shasum": "" }, "require": { @@ -5788,9 +5770,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -5834,7 +5813,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" }, "funding": [ { @@ -5850,7 +5829,7 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/process", @@ -6701,16 +6680,16 @@ }, { "name": "wp-cli/wp-cli", - "version": "v2.9.0", + "version": "v2.10.0", "source": { "type": "git", "url": "https://github.com/wp-cli/wp-cli.git", - "reference": "8a3befba2d947fbf5cc6d1941edf2dd99da4d4b7" + "reference": "a339dca576df73c31af4b4d8054efc2dab9a0685" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/8a3befba2d947fbf5cc6d1941edf2dd99da4d4b7", - "reference": "8a3befba2d947fbf5cc6d1941edf2dd99da4d4b7", + "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/a339dca576df73c31af4b4d8054efc2dab9a0685", + "reference": "a339dca576df73c31af4b4d8054efc2dab9a0685", "shasum": "" }, "require": { @@ -6740,7 +6719,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.9.x-dev" + "dev-main": "2.10.x-dev" } }, "autoload": { @@ -6767,7 +6746,7 @@ "issues": "https://github.com/wp-cli/wp-cli/issues", "source": "https://github.com/wp-cli/wp-cli" }, - "time": "2023-10-25T09:06:37+00:00" + "time": "2024-02-08T16:52:43+00:00" }, { "name": "wp-coding-standards/wpcs", From c20d98d8f49cca1c7959f25e0a51b8a3b2aa9362 Mon Sep 17 00:00:00 2001 From: Gustavo Bordoni Date: Sun, 17 Mar 2024 12:16:18 -0400 Subject: [PATCH 2/8] Modify the interface usage cause it was making ->container->make() fail --- src/Common/Contracts/Provider/Controller.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Common/Contracts/Provider/Controller.php b/src/Common/Contracts/Provider/Controller.php index cacdd8f29c..cb6c0ba54c 100644 --- a/src/Common/Contracts/Provider/Controller.php +++ b/src/Common/Contracts/Provider/Controller.php @@ -11,7 +11,6 @@ namespace TEC\Common\Contracts\Provider; use TEC\Common\Contracts\Service_Provider; -use TEC\Common\StellarWP\ContainerContract\ContainerInterface; use Tribe__Log as Log; /** @@ -21,7 +20,6 @@ * * @package TEC\Common\Provider; * - * @property ContainerInterface $container */ abstract class Controller extends Service_Provider { /** From 72428a78caefe64c75d29aef4839de5890756928 Mon Sep 17 00:00:00 2001 From: Stephen Page Date: Fri, 5 Apr 2024 14:03:47 -0400 Subject: [PATCH 3/8] version --- package.json | 2 +- src/Tribe/Main.php | 2 +- tribe-common.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 12e8dc17ac..5adc84fa6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tribe-common", - "version": "5.2.4", + "version": "5.3.0", "repository": "git@github.com:the-events-calendar/tribe-common.git", "_resourcepath": "src/resources", "_domainPath": "lang", diff --git a/src/Tribe/Main.php b/src/Tribe/Main.php index ef1f071fc6..9b775ea1cb 100644 --- a/src/Tribe/Main.php +++ b/src/Tribe/Main.php @@ -18,7 +18,7 @@ class Tribe__Main { const OPTIONNAME = 'tribe_events_calendar_options'; const OPTIONNAMENETWORK = 'tribe_events_calendar_network_options'; const FEED_URL = 'https://theeventscalendar.com/feed/'; - const VERSION = '5.2.4'; + const VERSION = '5.3.0'; protected $plugin_context; protected $plugin_context_class; diff --git a/tribe-common.php b/tribe-common.php index fede468c50..537320e209 100644 --- a/tribe-common.php +++ b/tribe-common.php @@ -2,7 +2,7 @@ /** * Plugin Name: Tribe Common * Description: An event settings framework for managing shared options - * Version: 5.2.4 + * Version: 5.3.0 * Author: The Events Calendar * Author URI: http://evnt.is/1x * Text Domain: tribe-common From f2dd3628f9c8bfcd67c4bfb751bc122ae300ff68 Mon Sep 17 00:00:00 2001 From: Stephen Page Date: Fri, 5 Apr 2024 14:04:06 -0400 Subject: [PATCH 4/8] Initial commit --- .../Contracts/Manager_Abstract.php | 57 ++ .../Integrations/Integration_Abstract.php | 1 + .../Widgets/Contracts/Abstract_Widget.php | 667 ++++++++++++++++++ .../Elementor/Widgets/Template_Engine.php | 156 ++++ src/Common/Integrations/Provider.php | 1 + .../Traits/Plugin_Integration.php | 3 + 6 files changed, 885 insertions(+) create mode 100644 src/Common/Integrations/Contracts/Manager_Abstract.php create mode 100644 src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php create mode 100644 src/Common/Integrations/Plugins/Elementor/Widgets/Template_Engine.php diff --git a/src/Common/Integrations/Contracts/Manager_Abstract.php b/src/Common/Integrations/Contracts/Manager_Abstract.php new file mode 100644 index 0000000000..2b68818b7f --- /dev/null +++ b/src/Common/Integrations/Contracts/Manager_Abstract.php @@ -0,0 +1,57 @@ + => ]`. + */ + public function get_registered_objects() { + /** + * Filters the list of objects available and registered. + * + * Both classes and built objects can be associated with a slug; if bound in the container the classes + * will be built according to the binding rules; objects will be returned as they are. + * + * @since TBD + * + * @param array $widgets An associative array of objects in the shape `[ => ]`. + */ + return (array) apply_filters( "tec_registered_{$this->type}", $this->objects, $this ); + } + + /** + * Registers the objects. + * + * @since TBD + */ + abstract public function register(); +} diff --git a/src/Common/Integrations/Integration_Abstract.php b/src/Common/Integrations/Integration_Abstract.php index 198bc0dd87..3e4f2eb609 100644 --- a/src/Common/Integrations/Integration_Abstract.php +++ b/src/Common/Integrations/Integration_Abstract.php @@ -8,6 +8,7 @@ */ namespace TEC\Common\Integrations; + use TEC\Common\Contracts\Service_Provider; /** diff --git a/src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php b/src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php new file mode 100644 index 0000000000..bf64e40710 --- /dev/null +++ b/src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php @@ -0,0 +1,667 @@ + + */ + protected array $categories = [ 'the-events-calendar' ]; + + /** + * Widget template engine. + * + * @since TBD + * + * @var Template_Engine + */ + protected Template_Engine $template; + + /** + * Widget template prefix. + * + * This holds the base path to the widget templates. + * + * @since TBD + * + * @var string + */ + protected string $template_prefix = 'tec/integrations/elementor/widgets'; + + /** + * Template engine class. + * + * @since TBD + * + * @var string The template engine class to use. + */ + protected string $template_engine_class = Template_Engine::class; + + /** + * The hooks added by the widget. + * + * @since TBD + * + * @var array + */ + protected array $added_hooks = []; + + /** + * Get elementor widget slug. + * + * @since TBD + * + * @return string + */ + public static function get_elementor_slug(): string { + return static::$slug_prefix . static::get_slug(); + } + + /** + * Gets the name (aka slug) of the widget. + * + * @since TBD + * + * @return string + */ + public function get_name(): string { + return static::get_elementor_slug(); + } + + /** + * Get local widget slug. + * + * @since TBD + * + * @return string + */ + public static function get_slug(): string { + return static::$slug; + } + + /** + * Gets the title of the widget. + * + * @since TBD + */ + public function get_title(): string { + $title = $this->title(); + $slug = static::get_slug(); + + /** + * Filters the title of the widget. + * + * @since TBD + * + * @param string $title The widget title. + * @param Abstract_Widget $this The widget instance. + */ + $title = apply_filters( static::$slug_prefix . 'title', $title, $this ); + + /** + * Filters the title of a specific tec-elementor widget, by slug. + * + * @since TBD + * + * @param string $title The widget title. + * @param Abstract_Widget $this The widget instance. + */ + return (string) apply_filters( static::$slug_prefix . "_widget_{$slug}_title", $title, $this ); + } + + /** + * Gets/creates the title of the widget. + * This must be overridden by the child class to include translating the title string. + * + * @since TBD + */ + abstract protected function title(): string; + + /** + * Gets the icon class for the widget. + * + * @since TBD + * + * @return string + */ + public function get_icon(): string { + return $this->get_icon_class(); + } + + /** + * Gets the CSS class list for the widget. + * As a string (for use in attributes) or as an array. + * + * @since TBD + * + * @param string $format The format to return. Either 'attribute' (default) or 'array'. + * + * @return string|array + */ + public function get_element_classes( string $format = 'attribute' ) { + // If the property is empty, generate and use the widget class. + $classes = $this->get_widget_class(); + $slug = static::get_slug(); + + /** + * Filters the widget class list for all tec-elementor widgets. + * + * @since TBD + * + * @param array $classes The widget classes. + * @param string $format The format to return. Either 'attribute' (default - returns a string) or 'array'. + * @param Abstract_Widget $this The widget instance. + * + * @return array + */ + $classes = apply_filters( static::$slug_prefix . 'element_classes', (array) $classes, $format, $this ); + + /** + * Filters the widget class list for a specific tec-elementor widget, by slug. + * + * @since TBD + * + * @param array $classes The widget classes. + * @param string $format The format to return. Either 'attribute' (default - returns a string) or 'array'. + * @param Abstract_Widget $this The widget instance. + * + * @return array + */ + $classes = apply_filters( static::$slug_prefix . "{$slug}_element_classes", (array) $classes, $format, $this ); + + // If we want a string, this is where we convert. + if ( 'attribute' === $format ) { + return implode( ' ', (array) $classes ); + } + + return $classes; + } + + /** + * Provides a "trimmed" slug for usage in classes and such and converts all underscores to dashes. + * + * @since TBD + * + * @return string + */ + public static function trim_slug(): string { + return trim( str_replace( '_', '-', static::get_slug() ) ); + } + + /** + * Provides the main CSS class for the widget. + * + * @since TBD + * + * @return string + */ + public function get_widget_class(): string { + $slug = static::get_slug(); + $class = $this->asset_prefix . '__' . static::trim_slug(); + + /** + * Filters the widget class for all tec-elementor widgets. + * + * @since TBD + * + * @param string $class The widget class. + * @param Abstract_Widget $this The widget instance. + * + * @return string + */ + $class = apply_filters( static::$slug_prefix . 'class', $class, $this ); + + /** + * Filters the widget class for a specific tec-elementor widget, by slug. + * + * @since TBD + * + * @param string $class The widget class. + * @param Abstract_Widget $this The widget instance. + * + * @return string + */ + return apply_filters( static::$slug_prefix . "{$slug}_class", $class, $this ); + } + + /** + * Provides the CSS class for the widget icon. + * + * @since TBD + * + * @return string + */ + public function get_icon_class(): string { + $slug = static::get_slug(); + $class = $this->asset_prefix . '__icon-' . static::trim_slug(); + + /** + * Filters the widget icon class for all tec-elementor widgets. + * + * @since TBD + * + * @param string $class The widget class. + * @param Abstract_Widget $this The widget instance. + * + * @return string + */ + $class = apply_filters( static::$slug_prefix . 'icon_class', $class, $this ); + + /** + * Filters the widget icon class for a specific tec-elementor widget, by slug. + * + * @since TBD + * + * @param string $class The widget class. + * @param Abstract_Widget $this The widget instance. + * + * @return string + */ + return (string) apply_filters( static::$slug_prefix . "{$slug}icon_class", $class, $this ); + } + + /** + * Gets the categories of the widget. + * + * @since TBD + * + * @return array + */ + public function get_categories(): array { + return $this->categories; + } + + /** + * An internal, filterable function to get the ID of the post the widget is used in. + * + * @since TBD + * + * @return int|false The ID of the current item (parent post) the widget is in. False if not found. + */ + protected function post_id(): ?int { + $post_id = (int) get_the_ID(); + $slug = self::get_slug(); + + if ( + is_admin() && + 'elementor' === tribe_get_request_var( 'action' ) + ) { + $post_id = (int) tribe_get_request_var( 'post', false ); + } + + /** + * Filters the post ID of the post the widget is used in. + * + * @since TBD + * + * @param int $post_id The post ID. + * @param Abstract_Widget $this The widget instance. + */ + $post_id = (int) apply_filters( static::$slug_prefix . 'post_id', (int) $post_id, $this ); + + /** + * Filters the post ID of the post the widget is used in. + * + * @since TBD + * + * @param int $post_id The post ID. + * @param Abstract_Widget $this The widget instance. + */ + $post_id = (int) apply_filters( static::$slug_prefix . "{$slug}_post_id", (int) $post_id, $this ); + + if ( get_post_type( $post_id ) !== static::get_widget_post_type() ) { + return null; + } + + return $post_id > 0 ? $post_id : null; + } + + /** + * Get the post ID. + * + * @since TBD + * + * @return int|null + */ + public function get_post_id() { + return $this->post_id(); + } + + /** + * Determines if the widget has a valid post ID associated with it. + * + * @since TBD + * + * @return bool + */ + protected function has_post_id(): bool { + return $this->get_post_id() !== null; + } + + /** + * Get the post type associated with the widget. + * + * @since TBD + * + * @return string + */ + protected function get_widget_post_type(): string { + return static::$post_type; + } + + /** + * Get the template engine class. + * + * @since TBD + * + * @return string + */ + protected function get_template_engine_class(): string { + // Ensures that the class returned is a subclass of Template_Engine. + if ( ! is_subclass_of( $this->template_engine_class, Template_Engine::class ) ) { + return Template_Engine::class; + } + + return $this->template_engine_class; + } + + /** + * Get template object. + * + * @since TBD + * + * @return Template_Engine + */ + public function get_template(): Template_Engine { + if ( empty( $this->template ) ) { + /** + * @var Template_Engine $template_engine_class + */ + $template_engine_class = $this->get_template_engine_class(); + $this->template = $template_engine_class::with_widget( $this ); + + do_action( 'tec_elementor_widget_set_template', $this ); + } + + return $this->template; + } + + /** + * Set up a self-removing filter for a widget template, it should hook itself on the before and after include hooks + * of the template engine. + * + * @since TBD + * + * @param string $on The hook to add on. + * @param ?callable $callback The callback to add to the filter. + * @param int $priority The priority of the filter. + * @param int $accepted_args The number of arguments the filter accepts. + */ + protected function set_template_filter( string $on, ?callable $callback = null, int $priority = 10, int $accepted_args = 1 ): void { + $template_file = $this->trim_slug(); + $hook_name = trailingslashit( static::$template_prefix ) . $template_file; + + $add = "tribe_template_before_include:{$hook_name}"; + $remove = "tribe_template_after_include:{$hook_name}"; + + // ensure the callback is callable. + if ( ! is_callable( $callback ) ) { + return; + } + + $add_callback = static function () use ( $on, $callback, $priority, $accepted_args ) { + add_filter( $on, $callback, $priority, $accepted_args ); + }; + + $remove_callback = static function () use ( $on, $callback, $priority ) { + remove_filter( $on, $callback, $priority ); + }; + + // Include the hook. + add_action( $add, $add_callback ); + $this->added_hooks[] = [ + 'hook' => $add, + 'callback' => $add_callback, + ]; + + // Remove the hook. + add_action( $remove, $remove_callback ); + $this->added_hooks[] = [ + 'hook' => $remove, + 'callback' => $remove_callback, + ]; + } + + /** + * Unset the template filters. + * + * @since TBD + */ + protected function unset_template_filters(): void { + foreach ( $this->added_hooks as $hook ) { + remove_action( $hook['hook'], $hook['callback'] ); + } + } + + /** + * Get the template args for the widget. + * + * @since TBD + * + * @return array The template args. + */ + abstract protected function template_args(): array; + + /** + * Determine if the widget should show mock data. + * + * @since TBD + * + * @return bool + */ + public function should_show_mock_data(): bool { + return false; + } + + /** + * Get the template arguments. + * + * This calls the template_args method on the widget and then filters the data. + * + * @since TBD + * + * @return array + */ + public function get_template_args(): array { + $args = $this->template_args(); // Defined in each widget instance. + $slug = self::get_slug(); + + + /** + * Filters the template data for all Elementor widget templates. + * + * @param array $args The template data. + * @param bool $preview Whether the template is in preview mode. + * @param object $widget The widget object. + * + * @return array + */ + $args = (array) apply_filters( static::$slug_prefix . 'template_data', $args, false, $this ); + + /** + * Filters the template data for a specific (by $slug) Elementor widget templates. + * + * @param array $args The template data. + * @param bool $preview Whether the template is in preview mode. + * @param object $widget The widget object. + * + * @return array + */ + $args = (array) apply_filters( static::$slug_prefix . 'template_data', $args, false, $this ); + + // Add the widget to the data array. + $args['widget'] = $this; + + return $args; + } + + /** + * Get the asset source for the widget. + * + * @since TBD + * + * @return string + */ + abstract protected function get_asset_source(); + + /** + * Register the styles for the widget. + * + * @since TBD + */ + public function register_style(): void { + if ( ! static::$has_styles ) { + return; + } + + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { + return; + } + + $slug = static::trim_slug(); + $source = $this->get_asset_source(); + + // Register the styles for the widget. + tribe_asset( + tribe( $source ), + static::$asset_prefix . $slug . '-styles', + static::$asset_base_path . $slug . '.css', + [], + null, + [ 'groups' => [ static::$group_key ] ] + ); + } + + /** + * Enqueue the styles for the widget. + * + * @since TBD + */ + public function enqueue_style(): void { + if ( ! static::$has_styles ) { + return; + } + + $slug = static::trim_slug(); + + tribe_asset_enqueue( static::$asset_prefix . $slug . '-styles' ); + } + + /** + * Get the output of the widget. + * + * @since TBD + * + * @return string + */ + public function get_output(): string { + $output = $this->get_template()->template( 'widgets/base', $this->get_template_args(), false ); + + $this->unset_template_filters(); + + return $output; + } + + /** + * Render the Elementor widget, this method needs to be protected as it is originally defined as such in elementor. + * + * @since TBD + */ + protected function render(): void { + echo $this->get_output(); // phpcs:ignore StellarWP.XSS.EscapeOutput.OutputNotEscaped,WordPress.Security.EscapeOutput.OutputNotEscaped + } +} diff --git a/src/Common/Integrations/Plugins/Elementor/Widgets/Template_Engine.php b/src/Common/Integrations/Plugins/Elementor/Widgets/Template_Engine.php new file mode 100644 index 0000000000..69adb79eb5 --- /dev/null +++ b/src/Common/Integrations/Plugins/Elementor/Widgets/Template_Engine.php @@ -0,0 +1,156 @@ +set_template_origin( tribe( 'tec.main' ) ); + $this->set_template_folder( 'src/views/integrations/elementor' ); + $this->set_template_context_extract( true ); + $this->set_template_folder_lookup( true ); + } + + /** + * Factory method to create a new instance of the Template Engine. + * + * @param Abstract_Widget $widget The widget instance to set. + * + * @return Template_Engine + */ + public static function with_widget( Abstract_Widget $widget ): Template_Engine { + $instance = new static(); + $instance->set_widget( $widget ); + + return $instance; + } + + /** + * Set the widget internally to these templates. + * + * @since TBD + * + * @param Abstract_Widget $widget The widget instance to set. + * + * @return void + */ + protected function set_widget( Abstract_Widget $widget ): void { + $this->widget = $widget; + } + + /** + * Allows to get the widget instance. + * + * @since TBD + * + * @return Abstract_Widget + */ + public function get_widget(): Abstract_Widget { + return $this->widget; + } + + /** + * Get the post ID associated with this template. + * + * @since TBD + * + * @param int|string|WP_Post $post The post ID, post object or slug. + * + * @return void + */ + public function set_post( $post ): void { + if ( is_numeric( $post ) ) { + $post = get_post( $post ); + } + + if ( ! $post instanceof WP_Post ) { + return; + } + + $this->post = $post; + } + + /** + * Determines if the template has a post associated with it. + * + * @since TBD + * + * @return bool + */ + public function has_post(): bool { + return null !== $this->get_post(); + } + + /** + * Get the post associated with this template. + * + * @since TBD + * + * @return WP_Post|null + */ + public function get_post(): ?WP_Post { + return $this->post; + } + + /** + * Determines if Elementor is in Edit Mode. + * + * @since TBD + * + * @return bool + */ + public function is_edit_mode(): bool { + return \Elementor\Plugin::$instance->editor->is_edit_mode(); + } + + /** + * Determines if Elementor is on Preview Mode. + * + * @since TBD + * + * @return bool + */ + public function is_preview_mode(): bool { + return \Elementor\Plugin::$instance->preview->is_preview_mode(); + } +} diff --git a/src/Common/Integrations/Provider.php b/src/Common/Integrations/Provider.php index 60535e6631..47c8f69c3f 100644 --- a/src/Common/Integrations/Provider.php +++ b/src/Common/Integrations/Provider.php @@ -6,6 +6,7 @@ * * @package TEC\Common\Integrations */ + namespace TEC\Common\Integrations; /** diff --git a/src/Common/Integrations/Traits/Plugin_Integration.php b/src/Common/Integrations/Traits/Plugin_Integration.php index 17d0b5c216..8f7c290b4b 100644 --- a/src/Common/Integrations/Traits/Plugin_Integration.php +++ b/src/Common/Integrations/Traits/Plugin_Integration.php @@ -1,4 +1,7 @@ Date: Mon, 8 Apr 2024 09:44:52 -0400 Subject: [PATCH 5/8] Get namespaces and such working correctly. --- .../Contracts/Manager_Abstract.php | 2 +- .../Widgets/Contracts/Abstract_Widget.php | 33 +++++++++++++++---- .../Elementor/Widgets/Template_Engine.php | 20 +++++------ 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/Common/Integrations/Contracts/Manager_Abstract.php b/src/Common/Integrations/Contracts/Manager_Abstract.php index 2b68818b7f..6fd90b80e6 100644 --- a/src/Common/Integrations/Contracts/Manager_Abstract.php +++ b/src/Common/Integrations/Contracts/Manager_Abstract.php @@ -7,7 +7,7 @@ * @package TEC\Integrations\Contracts */ -namespace TEC\Integrations\Contracts; +namespace TEC\Common\Integrations\Contracts; /** * Class Manager_Abstract diff --git a/src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php b/src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php index bf64e40710..0f3742f2c8 100644 --- a/src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php +++ b/src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php @@ -110,7 +110,7 @@ abstract class Abstract_Widget extends Widget_Base { * * @var string */ - protected string $template_prefix = 'tec/integrations/elementor/widgets'; + protected static string $template_prefix = 'tec/integrations/elementor/widgets'; /** * Template engine class. @@ -212,6 +212,25 @@ public function get_icon(): string { return $this->get_icon_class(); } + /** + * Get the template file path, which will be used to include the correct widget template to be rendered. + * By default, it will be the combination of a folder named 'widgets' and the widget slug with _ replaced by -. + * For example: + * - if the widget slug is 'event_cost' + * - template file path will be 'widgets/event-cost'. + * + * This method can be overridden by the child class to provide a custom template file path. + * + * @since TBD + * + * @return string + */ + public function get_template_file(): string { + $file = str_replace( '_', '-', static::get_slug() ); + + return "widgets/{$file}"; + } + /** * Gets the CSS class list for the widget. * As a string (for use in attributes) or as an array. @@ -281,7 +300,7 @@ public static function trim_slug(): string { */ public function get_widget_class(): string { $slug = static::get_slug(); - $class = $this->asset_prefix . '__' . static::trim_slug(); + $class = static::$asset_prefix . '__' . static::trim_slug(); /** * Filters the widget class for all tec-elementor widgets. @@ -317,7 +336,7 @@ public function get_widget_class(): string { */ public function get_icon_class(): string { $slug = static::get_slug(); - $class = $this->asset_prefix . '__icon-' . static::trim_slug(); + $class = static::$asset_prefix . '__icon-' . static::trim_slug(); /** * Filters the widget icon class for all tec-elementor widgets. @@ -364,7 +383,7 @@ public function get_categories(): array { */ protected function post_id(): ?int { $post_id = (int) get_the_ID(); - $slug = self::get_slug(); + $slug = static::get_slug(); if ( is_admin() && @@ -429,7 +448,7 @@ protected function has_post_id(): bool { * * @return string */ - protected function get_widget_post_type(): string { + public static function get_widget_post_type(): string { return static::$post_type; } @@ -558,7 +577,7 @@ public function should_show_mock_data(): bool { */ public function get_template_args(): array { $args = $this->template_args(); // Defined in each widget instance. - $slug = self::get_slug(); + $slug = static::get_slug(); /** @@ -581,7 +600,7 @@ public function get_template_args(): array { * * @return array */ - $args = (array) apply_filters( static::$slug_prefix . 'template_data', $args, false, $this ); + $args = (array) apply_filters( static::$slug_prefix . "{$slug}_template_data", $args, false, $this ); // Add the widget to the data array. $args['widget'] = $this; diff --git a/src/Common/Integrations/Plugins/Elementor/Widgets/Template_Engine.php b/src/Common/Integrations/Plugins/Elementor/Widgets/Template_Engine.php index 69adb79eb5..341e0eb12d 100644 --- a/src/Common/Integrations/Plugins/Elementor/Widgets/Template_Engine.php +++ b/src/Common/Integrations/Plugins/Elementor/Widgets/Template_Engine.php @@ -4,12 +4,12 @@ * * @since TBD * - * @package TEC\Integrations\Plugins\Elementor\Widgets + * @package TEC\Common\Integrations\Plugins\Elementor\Widgets */ namespace TEC\Common\Integrations\Plugins\Elementor\Widgets; -use TEC\Integrations\Plugins\Elementor\Widgets\Contracts\Abstract_Widget; +use TEC\Common\Integrations\Plugins\Elementor\Widgets\Contracts\Abstract_Widget; use Tribe__Template as Base_Template_Engine; use WP_Post; @@ -18,17 +18,15 @@ * * @since TBD * - * @package TEC\Integrations\Plugins\Elementor\Widgets + * @package TEC\Common\Integrations\Plugins\Elementor\Widgets */ -class Template_Engine extends Base_Template_Engine { +abstract class Template_Engine extends Base_Template_Engine { /** * Which widget instance is being used for this template engine. * * @since TBD - * - * @var Abstract_Widget The widget instance. */ - protected Abstract_Widget $widget; + protected $widget; /** * Stores a potential Post ID associated with this template. @@ -54,11 +52,11 @@ protected function __construct() { /** * Factory method to create a new instance of the Template Engine. * - * @param Abstract_Widget $widget The widget instance to set. + * @param $widget The widget instance to set. * * @return Template_Engine */ - public static function with_widget( Abstract_Widget $widget ): Template_Engine { + public static function with_widget( $widget ): Template_Engine { $instance = new static(); $instance->set_widget( $widget ); @@ -70,11 +68,11 @@ public static function with_widget( Abstract_Widget $widget ): Template_Engine { * * @since TBD * - * @param Abstract_Widget $widget The widget instance to set. + * @param $widget The widget instance to set. * * @return void */ - protected function set_widget( Abstract_Widget $widget ): void { + protected function set_widget( $widget ): void { $this->widget = $widget; } From 1027eca219069cddc5759cc080881f99eb264c74 Mon Sep 17 00:00:00 2001 From: Stephen Page Date: Mon, 15 Apr 2024 20:18:31 -0400 Subject: [PATCH 6/8] Update caniuse --- package-lock.json | 16 ++++++++-------- package.json | 20 ++++++++++++++++---- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index e63e7eddd5..3a8e923fdb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tribe-common", - "version": "5.2.5", + "version": "5.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tribe-common", - "version": "5.2.5", + "version": "5.3.0", "dependencies": { "@babel/runtime": "^7.15.3", "@moderntribe/common": "file:src/modules", @@ -5496,9 +5496,9 @@ "license": "CC-BY-4.0" }, "node_modules/caniuse-lite": { - "version": "1.0.30001543", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001543.tgz", - "integrity": "sha512-qxdO8KPWPQ+Zk6bvNpPeQIOH47qZSYdFZd6dXQzb2KzhnSXju4Kd7H1PkSJx6NICSMgo/IhRZRhhfPTHYpJUCA==", + "version": "1.0.30001610", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001610.tgz", + "integrity": "sha512-QFutAY4NgaelojVMjY63o6XlZyORPaLfyMnsl3HgnWdJUcX6K0oaJymHjH8PT5Gk7sTm8rvC/c5COUQKXqmOMA==", "dev": true, "funding": [ { @@ -29295,9 +29295,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001543", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001543.tgz", - "integrity": "sha512-qxdO8KPWPQ+Zk6bvNpPeQIOH47qZSYdFZd6dXQzb2KzhnSXju4Kd7H1PkSJx6NICSMgo/IhRZRhhfPTHYpJUCA==", + "version": "1.0.30001610", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001610.tgz", + "integrity": "sha512-QFutAY4NgaelojVMjY63o6XlZyORPaLfyMnsl3HgnWdJUcX6K0oaJymHjH8PT5Gk7sTm8rvC/c5COUQKXqmOMA==", "dev": true }, "cardinal": { diff --git a/package.json b/package.json index 5adc84fa6c..635957c09a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,10 @@ "_glotPressUrl": "https://translations.theeventscalendar.com", "_glotPressSlug": "tribe-common", "_glotPressFileFormat": "%textdomain%-%wp_locale%.%format%", - "_glotPressFormats": ["po", "mo"], + "_glotPressFormats": [ + "po", + "mo" + ], "_glotPressFilter": { "translation_sets": false, "minimum_percentage": 30, @@ -31,9 +34,14 @@ "!src/resources/postcss/datepicker.pcss", "!src/resources/postcss/tribe-ui.pcss" ], - "jest": ["src/modules/**/__tests__/**/*.js"] + "jest": [ + "src/modules/**/__tests__/**/*.js" + ] + }, + "engines": { + "node": "18.13.0", + "npm": "8.19.3" }, - "engines": { "node": "18.13.0", "npm": "8.19.3" }, "scripts": { "analyze": "webpack-bundle-analyzer -m static stats.json", "bootstrap": "./scripts/linkDependencies", @@ -106,7 +114,11 @@ "webpack-cli": "^3.1.2", "webpack-merge": "^4.1.4" }, - "overrides": { "babel-plugin-lodash": { "@babel/types": "~7.20.0" } }, + "overrides": { + "babel-plugin-lodash": { + "@babel/types": "~7.20.0" + } + }, "browserslist": [ "last 2 Chrome versions", "last 2 Firefox versions", From f40510ed2780acd3a9bd0042cbd409517fa811a4 Mon Sep 17 00:00:00 2001 From: Camwyn Date: Wed, 24 Apr 2024 10:49:41 -0400 Subject: [PATCH 7/8] Set pcss utils to main --- src/resources/postcss/utilities | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/postcss/utilities b/src/resources/postcss/utilities index 024e7fa9ff..ecb4d65dfb 160000 --- a/src/resources/postcss/utilities +++ b/src/resources/postcss/utilities @@ -1 +1 @@ -Subproject commit 024e7fa9ffc1483ab6e7cbfed1a5883adc9ce829 +Subproject commit ecb4d65dfbb6e48704e309c2586e6950cff5f44d From 584de903e46fa1aea4e8a2357ff0f3359489b011 Mon Sep 17 00:00:00 2001 From: Camwyn Date: Mon, 6 May 2024 10:16:33 -0400 Subject: [PATCH 8/8] small tweaks --- composer.lock | 153 +++++----- .../Widgets/Contracts/Abstract_Widget.php | 269 +++++++++++++++--- 2 files changed, 314 insertions(+), 108 deletions(-) diff --git a/composer.lock b/composer.lock index 415ce03047..5bb3239066 100644 --- a/composer.lock +++ b/composer.lock @@ -70,16 +70,16 @@ }, { "name": "lucatume/di52", - "version": "3.3.5", + "version": "3.3.7", "source": { "type": "git", "url": "https://github.com/lucatume/di52.git", - "reference": "d39d1cbbc57eb41c7aa21fab106e17b6938ec6b3" + "reference": "76c0c2ad0422ce595e2e38138456f3475888e32c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lucatume/di52/zipball/d39d1cbbc57eb41c7aa21fab106e17b6938ec6b3", - "reference": "d39d1cbbc57eb41c7aa21fab106e17b6938ec6b3", + "url": "https://api.github.com/repos/lucatume/di52/zipball/76c0c2ad0422ce595e2e38138456f3475888e32c", + "reference": "76c0c2ad0422ce595e2e38138456f3475888e32c", "shasum": "" }, "require": { @@ -109,9 +109,9 @@ "description": "A PHP 5.6 compatible dependency injection container.", "support": { "issues": "https://github.com/lucatume/di52/issues", - "source": "https://github.com/lucatume/di52/tree/3.3.5" + "source": "https://github.com/lucatume/di52/tree/3.3.7" }, - "time": "2023-09-01T08:49:32+00:00" + "time": "2024-04-26T14:46:26+00:00" }, { "name": "monolog/monolog", @@ -2807,16 +2807,16 @@ }, { "name": "phpcsstandards/phpcsutils", - "version": "1.0.10", + "version": "1.0.11", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544" + "reference": "c457da9dabb60eb7106dd5e3c05132b1a6539c6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/51609a5b89f928e0c463d6df80eb38eff1eaf544", - "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/c457da9dabb60eb7106dd5e3c05132b1a6539c6a", + "reference": "c457da9dabb60eb7106dd5e3c05132b1a6539c6a", "shasum": "" }, "require": { @@ -2891,7 +2891,7 @@ "type": "open_collective" } ], - "time": "2024-03-17T23:44:50+00:00" + "time": "2024-04-24T11:47:18+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -2948,28 +2948,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", + "version": "5.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" + "reference": "298d2febfe79d03fe714eb871d5538da55205b1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/298d2febfe79d03fe714eb871d5538da55205b1a", + "reference": "298d2febfe79d03fe714eb871d5538da55205b1a", "shasum": "" }, "require": { + "doctrine/deprecations": "^1.1", "ext-filter": "*", - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", + "phpdocumentor/type-resolver": "^1.7", + "phpstan/phpdoc-parser": "^1.7", "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" + "mockery/mockery": "~1.3.5", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-webmozart-assert": "^1.2", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^5.13" }, "type": "library", "extra": { @@ -2993,15 +3000,15 @@ }, { "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" + "email": "opensource@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.0" }, - "time": "2021-10-19T17:43:47+00:00" + "time": "2024-04-09T21:13:58+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -3132,16 +3139,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.26.0", + "version": "1.28.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "231e3186624c03d7e7c890ec662b81e6b0405227" + "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/231e3186624c03d7e7c890ec662b81e6b0405227", - "reference": "231e3186624c03d7e7c890ec662b81e6b0405227", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", + "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", "shasum": "" }, "require": { @@ -3173,9 +3180,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.26.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.28.0" }, - "time": "2024-02-23T16:05:55+00:00" + "time": "2024-04-03T18:51:33+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4417,16 +4424,16 @@ }, { "name": "sirbrillig/phpcs-variable-analysis", - "version": "v2.11.17", + "version": "v2.11.18", "source": { "type": "git", "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", - "reference": "3b71162a6bf0cde2bff1752e40a1788d8273d049" + "reference": "ca242a0b7309e0f9d1f73b236e04ecf4ca3248d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3b71162a6bf0cde2bff1752e40a1788d8273d049", - "reference": "3b71162a6bf0cde2bff1752e40a1788d8273d049", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/ca242a0b7309e0f9d1f73b236e04ecf4ca3248d0", + "reference": "ca242a0b7309e0f9d1f73b236e04ecf4ca3248d0", "shasum": "" }, "require": { @@ -4471,7 +4478,7 @@ "source": "https://github.com/sirbrillig/phpcs-variable-analysis", "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" }, - "time": "2023-08-05T23:46:11+00:00" + "time": "2024-04-13T16:42:46+00:00" }, { "name": "slevomat/coding-standard", @@ -4540,16 +4547,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.0", + "version": "3.9.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/aac1f6f347a5c5ac6bc98ad395007df00990f480", + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480", "shasum": "" }, "require": { @@ -4616,7 +4623,7 @@ "type": "open_collective" } ], - "time": "2024-02-16T15:06:51+00:00" + "time": "2024-04-23T20:25:34+00:00" }, { "name": "stellarwp/coding-standards", @@ -4903,16 +4910,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" + "reference": "80d075412b557d41002320b96a096ca65aa2c98d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", + "reference": "80d075412b557d41002320b96a096ca65aa2c98d", "shasum": "" }, "require": { @@ -4950,7 +4957,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" }, "funding": [ { @@ -4966,7 +4973,7 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2023-01-24T14:02:46+00:00" }, { "name": "symfony/dom-crawler", @@ -5884,16 +5891,16 @@ }, { "name": "symfony/service-contracts", - "version": "v2.5.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c" + "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/4b426aac47d6427cc1a1d0f7e2ac724627f5966c", - "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a2329596ddc8fd568900e3fc76cba42489ecc7f3", + "reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3", "shasum": "" }, "require": { @@ -5947,7 +5954,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/service-contracts/tree/v2.5.3" }, "funding": [ { @@ -5963,7 +5970,7 @@ "type": "tidelift" } ], - "time": "2022-05-30T19:17:29+00:00" + "time": "2023-04-21T15:04:16+00:00" }, { "name": "symfony/translation", @@ -6062,16 +6069,16 @@ }, { "name": "symfony/translation-contracts", - "version": "v2.5.2", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe" + "reference": "b0073a77ac0b7ea55131020e87b1e3af540f4664" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/136b19dd05cdf0709db6537d058bcab6dd6e2dbe", - "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/b0073a77ac0b7ea55131020e87b1e3af540f4664", + "reference": "b0073a77ac0b7ea55131020e87b1e3af540f4664", "shasum": "" }, "require": { @@ -6120,7 +6127,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/translation-contracts/tree/v2.5.3" }, "funding": [ { @@ -6136,7 +6143,7 @@ "type": "tidelift" } ], - "time": "2022-06-27T16:58:25+00:00" + "time": "2024-01-23T13:51:25+00:00" }, { "name": "symfony/yaml", @@ -6215,22 +6222,22 @@ "source": { "type": "git", "url": "https://github.com/the-events-calendar/tec-testing-facilities.git", - "reference": "6c66235042c4389079a0c98ff8e70ad0ac227eb0" + "reference": "0b5909300805b8844ce4720cee72ea7389eb2e58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/the-events-calendar/tec-testing-facilities/zipball/6c66235042c4389079a0c98ff8e70ad0ac227eb0", - "reference": "6c66235042c4389079a0c98ff8e70ad0ac227eb0", + "url": "https://api.github.com/repos/the-events-calendar/tec-testing-facilities/zipball/0b5909300805b8844ce4720cee72ea7389eb2e58", + "reference": "0b5909300805b8844ce4720cee72ea7389eb2e58", "shasum": "" }, "require": { "lucatume/wp-browser": "^2.0 || ^3.0", "nilportugues/sql-query-formatter": "^1.2", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "codeception/codeception": "^3.0", - "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", "phpunit/phpunit": "^6.0", "vlucas/phpdotenv": "^3.0", "wordpress/wordpress": "dev-master", @@ -6261,7 +6268,7 @@ "issues": "https://github.com/the-events-calendar/tec-testing-facilities/issues", "source": "https://github.com/the-events-calendar/tec-testing-facilities/tree/master" }, - "time": "2022-05-20T15:21:07+00:00" + "time": "2024-04-15T14:14:23+00:00" }, { "name": "theseer/tokenizer", @@ -6739,16 +6746,16 @@ }, { "name": "wp-coding-standards/wpcs", - "version": "3.0.1", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1" + "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/b4caf9689f1a0e4a4c632679a44e638c1c67aff1", - "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/9333efcbff231f10dfd9c56bb7b65818b4733ca7", + "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7", "shasum": "" }, "require": { @@ -6757,16 +6764,16 @@ "ext-tokenizer": "*", "ext-xmlreader": "*", "php": ">=5.4", - "phpcsstandards/phpcsextra": "^1.1.0", - "phpcsstandards/phpcsutils": "^1.0.8", - "squizlabs/php_codesniffer": "^3.7.2" + "phpcsstandards/phpcsextra": "^1.2.1", + "phpcsstandards/phpcsutils": "^1.0.10", + "squizlabs/php_codesniffer": "^3.9.0" }, "require-dev": { "php-parallel-lint/php-console-highlighter": "^1.0.0", "php-parallel-lint/php-parallel-lint": "^1.3.2", "phpcompatibility/php-compatibility": "^9.0", "phpcsstandards/phpcsdevtools": "^1.2.0", - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" }, "suggest": { "ext-iconv": "For improved results", @@ -6797,11 +6804,11 @@ }, "funding": [ { - "url": "https://opencollective.com/thewpcc/contribute/wp-php-63406", + "url": "https://opencollective.com/php_codesniffer", "type": "custom" } ], - "time": "2023-09-14T07:06:09+00:00" + "time": "2024-03-25T16:39:00+00:00" }, { "name": "zordius/lightncandy", @@ -6874,5 +6881,5 @@ "platform-overrides": { "php": "7.4.0" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php b/src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php index 0f3742f2c8..49345a93fa 100644 --- a/src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php +++ b/src/Common/Integrations/Plugins/Elementor/Widgets/Contracts/Abstract_Widget.php @@ -11,6 +11,7 @@ use TEC\Common\Integrations\Plugins\Elementor\Widgets\Template_Engine; use Elementor\Widget_Base; +use WP_Post; /** * Abstract Widget class @@ -83,6 +84,15 @@ abstract class Abstract_Widget extends Widget_Base { */ protected static bool $has_styles = false; + /** + * Whether the widget has scripts to register/enqueue. + * + * @since TBD + * + * @var bool + */ + protected static bool $has_scripts = false; + /** * Widget categories. * @@ -137,8 +147,8 @@ abstract class Abstract_Widget extends Widget_Base { * * @return string */ - public static function get_elementor_slug(): string { - return static::$slug_prefix . static::get_slug(); + public function get_elementor_slug(): string { + return $this->get_slug_prefix() . static::get_slug(); } /** @@ -149,7 +159,7 @@ public static function get_elementor_slug(): string { * @return string */ public function get_name(): string { - return static::get_elementor_slug(); + return $this->get_elementor_slug(); } /** @@ -163,6 +173,65 @@ public static function get_slug(): string { return static::$slug; } + /** + * Get local widget slug. + * + * @since TBD + * + * @param bool $trim Whether to trim the last underscore from the prefix. + * + * @return string + */ + public function get_slug_prefix( $trim = false ): string { + $prefix = static::$slug_prefix; + + + if ( $trim ) { + $prefix = rtrim( $prefix, '_' ); + } else { + // Ensure our prefix ends with an underscore. + $prefix = rtrim( $prefix, '_' ) . '_'; + } + + /** + * Filters the slug prefix for all tec-elementor widgets. + * + * @since TBD + * + * @param string $prefix The widget slug prefix. + * @param bool $trim Whether to trim the last underscore from the prefix. + * @param object $this The widget instance. + * + * @return string + */ + return (string) apply_filters( 'tec_elementor_widget_slug_prefix', $prefix, $trim, $this ); + } + + public function create_slug( $slug ) { + $prefix = $this->get_slug_prefix(); + + return $prefix . $slug; + } + + /** + * Get local widget slug. + * + * @since TBD + * + * @param bool $trim Whether to trim the last slug. + * + * @return string + */ + public function get_asset_prefix( $trim = false ): string { + $prefix = str_replace( '_', '-', $this->get_slug_prefix() ); + + if ( $trim ) { + $prefix = rtrim( $prefix, '-' ); + } + + return $prefix; + } + /** * Gets the title of the widget. * @@ -180,7 +249,7 @@ public function get_title(): string { * @param string $title The widget title. * @param Abstract_Widget $this The widget instance. */ - $title = apply_filters( static::$slug_prefix . 'title', $title, $this ); + $title = apply_filters( $this->create_slug( 'title' ), $title, $this ); /** * Filters the title of a specific tec-elementor widget, by slug. @@ -190,7 +259,7 @@ public function get_title(): string { * @param string $title The widget title. * @param Abstract_Widget $this The widget instance. */ - return (string) apply_filters( static::$slug_prefix . "_widget_{$slug}_title", $title, $this ); + return (string) apply_filters( $this->get_slug_prefix() . "widget_{$slug}_title", $title, $this ); } /** @@ -257,7 +326,7 @@ public function get_element_classes( string $format = 'attribute' ) { * * @return array */ - $classes = apply_filters( static::$slug_prefix . 'element_classes', (array) $classes, $format, $this ); + $classes = apply_filters( $this->get_slug_prefix() . 'element_classes', (array) $classes, $format, $this ); /** * Filters the widget class list for a specific tec-elementor widget, by slug. @@ -270,7 +339,7 @@ public function get_element_classes( string $format = 'attribute' ) { * * @return array */ - $classes = apply_filters( static::$slug_prefix . "{$slug}_element_classes", (array) $classes, $format, $this ); + $classes = apply_filters( $this->get_slug_prefix() . "{$slug}_element_classes", (array) $classes, $format, $this ); // If we want a string, this is where we convert. if ( 'attribute' === $format ) { @@ -300,7 +369,7 @@ public static function trim_slug(): string { */ public function get_widget_class(): string { $slug = static::get_slug(); - $class = static::$asset_prefix . '__' . static::trim_slug(); + $class = static::get_asset_prefix() . '_' . static::trim_slug(); /** * Filters the widget class for all tec-elementor widgets. @@ -312,7 +381,7 @@ public function get_widget_class(): string { * * @return string */ - $class = apply_filters( static::$slug_prefix . 'class', $class, $this ); + $class = apply_filters( $this->get_slug_prefix() . 'class', $class, $this ); /** * Filters the widget class for a specific tec-elementor widget, by slug. @@ -324,7 +393,7 @@ public function get_widget_class(): string { * * @return string */ - return apply_filters( static::$slug_prefix . "{$slug}_class", $class, $this ); + return apply_filters( $this->get_slug_prefix() . "{$slug}_class", $class, $this ); } /** @@ -336,7 +405,7 @@ public function get_widget_class(): string { */ public function get_icon_class(): string { $slug = static::get_slug(); - $class = static::$asset_prefix . '__icon-' . static::trim_slug(); + $class = static::get_asset_prefix() . '__icon-' . static::trim_slug(); /** * Filters the widget icon class for all tec-elementor widgets. @@ -348,7 +417,7 @@ public function get_icon_class(): string { * * @return string */ - $class = apply_filters( static::$slug_prefix . 'icon_class', $class, $this ); + $class = apply_filters( $this->get_slug_prefix() . 'icon_class', $class, $this ); /** * Filters the widget icon class for a specific tec-elementor widget, by slug. @@ -360,7 +429,7 @@ public function get_icon_class(): string { * * @return string */ - return (string) apply_filters( static::$slug_prefix . "{$slug}icon_class", $class, $this ); + return (string) apply_filters( $this->get_slug_prefix() . "{$slug}icon_class", $class, $this ); } /** @@ -400,7 +469,7 @@ protected function post_id(): ?int { * @param int $post_id The post ID. * @param Abstract_Widget $this The widget instance. */ - $post_id = (int) apply_filters( static::$slug_prefix . 'post_id', (int) $post_id, $this ); + $post_id = (int) apply_filters( $this->get_slug_prefix() . 'post_id', (int) $post_id, $this ); /** * Filters the post ID of the post the widget is used in. @@ -410,7 +479,7 @@ protected function post_id(): ?int { * @param int $post_id The post ID. * @param Abstract_Widget $this The widget instance. */ - $post_id = (int) apply_filters( static::$slug_prefix . "{$slug}_post_id", (int) $post_id, $this ); + $post_id = (int) apply_filters( $this->get_slug_prefix() . "{$slug}_post_id", (int) $post_id, $this ); if ( get_post_type( $post_id ) !== static::get_widget_post_type() ) { return null; @@ -430,6 +499,29 @@ public function get_post_id() { return $this->post_id(); } + /** + * Get the post object for the widget. + * + * @since TBD + * + * @return WP_Post|null + */ + public function get_post() { + $post = get_post( $this->get_post_id() ); + + /** + * Filters the post object for the widget. + * + * @since TBD + * + * @param WP_Post $post The post object. + * @param Abstract_Widget $this The widget instance. + * + * @return WP_Post + */ + return apply_filters( $this->get_slug_prefix() . 'post', $post, $this ); + } + /** * Determines if the widget has a valid post ID associated with it. * @@ -482,6 +574,7 @@ public function get_template(): Template_Engine { */ $template_engine_class = $this->get_template_engine_class(); $this->template = $template_engine_class::with_widget( $this ); + $this->template->set_post( $this->get_post() ); do_action( 'tec_elementor_widget_set_template', $this ); } @@ -489,6 +582,10 @@ public function get_template(): Template_Engine { return $this->template; } + public function get_template_prefix( $file = '' ): string { + return trailingslashit( static::$template_prefix ) . ltrim( $file, '/' ); + } + /** * Set up a self-removing filter for a widget template, it should hook itself on the before and after include hooks * of the template engine. @@ -501,8 +598,7 @@ public function get_template(): Template_Engine { * @param int $accepted_args The number of arguments the filter accepts. */ protected function set_template_filter( string $on, ?callable $callback = null, int $priority = 10, int $accepted_args = 1 ): void { - $template_file = $this->trim_slug(); - $hook_name = trailingslashit( static::$template_prefix ) . $template_file; + $hook_name = $this->get_template_prefix( $this->trim_slug() ); $add = "tribe_template_before_include:{$hook_name}"; $remove = "tribe_template_after_include:{$hook_name}"; @@ -589,7 +685,7 @@ public function get_template_args(): array { * * @return array */ - $args = (array) apply_filters( static::$slug_prefix . 'template_data', $args, false, $this ); + $args = (array) apply_filters( $this->get_slug_prefix() . 'template_data', $args, false, $this ); /** * Filters the template data for a specific (by $slug) Elementor widget templates. @@ -600,7 +696,7 @@ public function get_template_args(): array { * * @return array */ - $args = (array) apply_filters( static::$slug_prefix . "{$slug}_template_data", $args, false, $this ); + $args = (array) apply_filters( $this->get_slug_prefix() . "{$slug}_template_data", $args, false, $this ); // Add the widget to the data array. $args['widget'] = $this; @@ -609,7 +705,7 @@ public function get_template_args(): array { } /** - * Get the asset source for the widget. + * Get the asset source (plugin) for the widget. * * @since TBD * @@ -617,12 +713,87 @@ public function get_template_args(): array { */ abstract protected function get_asset_source(); + /** + * Get the asset base path for the widget. + * + * @since TBD + * + * @return string + */ + public function get_asset_base_path(): string { + /** + * Filters the asset base path for all Elementor widgets. + * + * @since TBD + * + * @param string $path The asset base path. + * @param Abstract_Widget $this The widget instance. + * + * @return string + */ + return (string) apply_filters( $this->get_slug_prefix() . 'asset_base_path', static::$asset_base_path, $this ); + } + + /** + * Get the asset file name for the widget. + * + * @since TBD + * + * @param string $suffix The file suffix. 'js' for a javascript or 'css' for a stylesheet asset. Default is 'css'. + * + * @return string + */ + public function get_asset_file_name( $suffix = 'css' ) { + $file = static::get_asset_base_path() . static::trim_slug(); + $file .= ( 'js' === $suffix ) ? '.js' : '.css'; + + /** + * Filters the asset file name for all Elementor widgets. + * + * @since TBD + * + * @param string $file The asset file name. + * @param string $suffix The file suffix. Should be 'js' or 'css'. + * @param Abstract_Widget $this The widget instance. + * + * @return string + */ + return (string) apply_filters( $this->get_slug_prefix() . 'asset_file_name', $file, $suffix, $this ); + } + + /** + * Get the asset handle for the widget. + * + * @since TBD + * + * @param string $suffix The file suffix. 'js' for a javascript or 'css' for a stylesheet asset. Default is 'css'. + * + * @return string + */ + public function get_asset_handle( $suffix = 'css' ) { + $handle = static::get_asset_prefix() . static::trim_slug(); + $handle .= ( 'js' === $suffix ) ? '-scripts' : '-styles'; + + /** + * Filters the asset handle for all Elementor widgets. + * + * @since TBD + * + * @param string $handle The asset handle. + * @param string $suffix The file suffix. Should be 'js' or 'css'. + * @param Abstract_Widget $this The widget instance. + * + * @return string + */ + return (string) apply_filters( $this->get_slug_prefix() . 'asset_handle', $handle, $suffix, $this ); + } + /** * Register the styles for the widget. * * @since TBD */ - public function register_style(): void { + public function register_assets(): void { if ( ! static::$has_styles ) { return; } @@ -631,18 +802,30 @@ public function register_style(): void { return; } - $slug = static::trim_slug(); - $source = $this->get_asset_source(); - // Register the styles for the widget. - tribe_asset( - tribe( $source ), - static::$asset_prefix . $slug . '-styles', - static::$asset_base_path . $slug . '.css', - [], - null, - [ 'groups' => [ static::$group_key ] ] - ); + if ( static::$has_styles ) { + tribe_asset( + tribe( $this->get_asset_source() ), + $this->get_asset_handle(), + $this->get_asset_file_name(), + [], + null, + [ 'groups' => [ static::$group_key ] ] + ); + } + + // Register the scripts for the widget. + if ( static::$has_scripts ) { + tribe_asset( + tribe( $this->get_asset_source() ), + $this->get_asset_handle( 'js' ), + $this->get_asset_file_name( 'js' ), + [], + null, + [ 'groups' => [ static::$group_key ] ] + ); + } + } /** @@ -655,9 +838,20 @@ public function enqueue_style(): void { return; } - $slug = static::trim_slug(); + tribe_asset_enqueue( static::get_asset_handle() ); + } - tribe_asset_enqueue( static::$asset_prefix . $slug . '-styles' ); + /** + * Enqueue the styles for the widget. + * + * @since TBD + */ + public function enqueue_script(): void { + if ( ! static::$has_scripts ) { + return; + } + + tribe_asset_enqueue( static::get_asset_handle( 'js' ) ); } /** @@ -668,7 +862,12 @@ public function enqueue_style(): void { * @return string */ public function get_output(): string { - $output = $this->get_template()->template( 'widgets/base', $this->get_template_args(), false ); + $template = $this->get_template(); + $output = $template->template( 'widgets/base', $this->get_template_args(), false ); + + if ( ! $template->has_post() && ! $template->get_widget()->should_show_mock_data() ) { + return ''; + } $this->unset_template_filters();