@@ -16,47 +16,47 @@ |
||
16 | 16 | */ |
17 | 17 | class AddonRoutes |
18 | 18 | { |
19 | - protected RouteHandler $route_handler; |
|
20 | - |
|
21 | - /** |
|
22 | - * array of fully qualified class names for routes where keys are add-on slugs |
|
23 | - * @var string[][] |
|
24 | - */ |
|
25 | - private array $routes = []; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * @param RouteHandler $route_handler |
|
30 | - */ |
|
31 | - public function __construct(RouteHandler $route_handler) |
|
32 | - { |
|
33 | - $this->route_handler = $route_handler; |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @param string $route_fqcn |
|
39 | - * @param string $addon_slug The class name of the add-on that the route belongs to |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function addRouteFor(string $route_fqcn, string $addon_slug) |
|
43 | - { |
|
44 | - if (! isset($this->routes[ $addon_slug ])) { |
|
45 | - $this->routes[ $addon_slug ] = []; |
|
46 | - } |
|
47 | - $this->routes[ $addon_slug ][] = $route_fqcn; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * @throws Exception|DomainException|Throwable |
|
53 | - */ |
|
54 | - public function loadRoutesFor(string $addon_slug) |
|
55 | - { |
|
56 | - if (isset($this->routes[ $addon_slug ])) { |
|
57 | - foreach ($this->routes[ $addon_slug ] as $route_fqcn) { |
|
58 | - $this->route_handler->addRoute($route_fqcn); |
|
59 | - } |
|
60 | - } |
|
61 | - } |
|
19 | + protected RouteHandler $route_handler; |
|
20 | + |
|
21 | + /** |
|
22 | + * array of fully qualified class names for routes where keys are add-on slugs |
|
23 | + * @var string[][] |
|
24 | + */ |
|
25 | + private array $routes = []; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * @param RouteHandler $route_handler |
|
30 | + */ |
|
31 | + public function __construct(RouteHandler $route_handler) |
|
32 | + { |
|
33 | + $this->route_handler = $route_handler; |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @param string $route_fqcn |
|
39 | + * @param string $addon_slug The class name of the add-on that the route belongs to |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function addRouteFor(string $route_fqcn, string $addon_slug) |
|
43 | + { |
|
44 | + if (! isset($this->routes[ $addon_slug ])) { |
|
45 | + $this->routes[ $addon_slug ] = []; |
|
46 | + } |
|
47 | + $this->routes[ $addon_slug ][] = $route_fqcn; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * @throws Exception|DomainException|Throwable |
|
53 | + */ |
|
54 | + public function loadRoutesFor(string $addon_slug) |
|
55 | + { |
|
56 | + if (isset($this->routes[ $addon_slug ])) { |
|
57 | + foreach ($this->routes[ $addon_slug ] as $route_fqcn) { |
|
58 | + $this->route_handler->addRoute($route_fqcn); |
|
59 | + } |
|
60 | + } |
|
61 | + } |
|
62 | 62 | } |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function addRouteFor(string $route_fqcn, string $addon_slug) |
43 | 43 | { |
44 | - if (! isset($this->routes[ $addon_slug ])) { |
|
45 | - $this->routes[ $addon_slug ] = []; |
|
44 | + if ( ! isset($this->routes[$addon_slug])) { |
|
45 | + $this->routes[$addon_slug] = []; |
|
46 | 46 | } |
47 | - $this->routes[ $addon_slug ][] = $route_fqcn; |
|
47 | + $this->routes[$addon_slug][] = $route_fqcn; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function loadRoutesFor(string $addon_slug) |
55 | 55 | { |
56 | - if (isset($this->routes[ $addon_slug ])) { |
|
57 | - foreach ($this->routes[ $addon_slug ] as $route_fqcn) { |
|
56 | + if (isset($this->routes[$addon_slug])) { |
|
57 | + foreach ($this->routes[$addon_slug] as $route_fqcn) { |
|
58 | 58 | $this->route_handler->addRoute($route_fqcn); |
59 | 59 | } |
60 | 60 | } |
@@ -6,77 +6,77 @@ |
||
6 | 6 | |
7 | 7 | class IncompatibleAddonHandler |
8 | 8 | { |
9 | - public function deactivateIncompatibleAddons(): void |
|
10 | - { |
|
11 | - static $done = false; |
|
12 | - if ($done) { |
|
13 | - return; |
|
14 | - } |
|
15 | - $this->deactivateIncompatibleAddon( |
|
16 | - 'Wait Lists', |
|
17 | - 'EE_WAIT_LISTS_VERSION', |
|
18 | - '1.0.0.beta.074', |
|
19 | - 'load_espresso_wait_lists', |
|
20 | - 'EE_WAIT_LISTS_PLUGIN_FILE' |
|
21 | - ); |
|
22 | - $this->deactivateIncompatibleAddon( |
|
23 | - 'Automated Upcoming Event Notifications', |
|
24 | - 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION', |
|
25 | - '1.0.0.beta.091', |
|
26 | - 'load_espresso_automated_upcoming_event_notification', |
|
27 | - 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE' |
|
28 | - ); |
|
29 | - // $this->deactivateIncompatibleAddon( |
|
30 | - // 'WP Users Integration', |
|
31 | - // 'EE_WPUSERS_VERSION', |
|
32 | - // '2.1.0.rc.003', |
|
33 | - // 'load_ee_core_wpusers', |
|
34 | - // 'EE_WPUSERS_PLUGIN_FILE' |
|
35 | - // ); |
|
36 | - $done = true; |
|
37 | - } |
|
9 | + public function deactivateIncompatibleAddons(): void |
|
10 | + { |
|
11 | + static $done = false; |
|
12 | + if ($done) { |
|
13 | + return; |
|
14 | + } |
|
15 | + $this->deactivateIncompatibleAddon( |
|
16 | + 'Wait Lists', |
|
17 | + 'EE_WAIT_LISTS_VERSION', |
|
18 | + '1.0.0.beta.074', |
|
19 | + 'load_espresso_wait_lists', |
|
20 | + 'EE_WAIT_LISTS_PLUGIN_FILE' |
|
21 | + ); |
|
22 | + $this->deactivateIncompatibleAddon( |
|
23 | + 'Automated Upcoming Event Notifications', |
|
24 | + 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION', |
|
25 | + '1.0.0.beta.091', |
|
26 | + 'load_espresso_automated_upcoming_event_notification', |
|
27 | + 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE' |
|
28 | + ); |
|
29 | + // $this->deactivateIncompatibleAddon( |
|
30 | + // 'WP Users Integration', |
|
31 | + // 'EE_WPUSERS_VERSION', |
|
32 | + // '2.1.0.rc.003', |
|
33 | + // 'load_ee_core_wpusers', |
|
34 | + // 'EE_WPUSERS_PLUGIN_FILE' |
|
35 | + // ); |
|
36 | + $done = true; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @param string $addon_name |
|
42 | - * @param string $version_constant |
|
43 | - * @param string $min_version_required |
|
44 | - * @param string $load_callback |
|
45 | - * @param string $plugin_file_constant |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - private function deactivateIncompatibleAddon( |
|
49 | - string $addon_name, |
|
50 | - string $version_constant, |
|
51 | - string $min_version_required, |
|
52 | - string $load_callback, |
|
53 | - string $plugin_file_constant |
|
54 | - ): void { |
|
55 | - if (! defined($version_constant)) { |
|
56 | - return; |
|
57 | - } |
|
58 | - $addon_version = constant($version_constant); |
|
59 | - if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
|
60 | - remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
|
61 | - if (! function_exists('deactivate_plugins')) { |
|
62 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
63 | - } |
|
64 | - deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
|
65 | - unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']); |
|
66 | - EE_Error::add_error( |
|
67 | - sprintf( |
|
68 | - esc_html__( |
|
69 | - 'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.', |
|
70 | - 'event_espresso' |
|
71 | - ), |
|
72 | - $addon_name, |
|
73 | - $min_version_required |
|
74 | - ), |
|
75 | - __FILE__, |
|
76 | - __FUNCTION__ . "($addon_name)", |
|
77 | - __LINE__ |
|
78 | - ); |
|
79 | - EE_Error::get_notices(false, true); |
|
80 | - } |
|
81 | - } |
|
40 | + /** |
|
41 | + * @param string $addon_name |
|
42 | + * @param string $version_constant |
|
43 | + * @param string $min_version_required |
|
44 | + * @param string $load_callback |
|
45 | + * @param string $plugin_file_constant |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + private function deactivateIncompatibleAddon( |
|
49 | + string $addon_name, |
|
50 | + string $version_constant, |
|
51 | + string $min_version_required, |
|
52 | + string $load_callback, |
|
53 | + string $plugin_file_constant |
|
54 | + ): void { |
|
55 | + if (! defined($version_constant)) { |
|
56 | + return; |
|
57 | + } |
|
58 | + $addon_version = constant($version_constant); |
|
59 | + if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
|
60 | + remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
|
61 | + if (! function_exists('deactivate_plugins')) { |
|
62 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
63 | + } |
|
64 | + deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
|
65 | + unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']); |
|
66 | + EE_Error::add_error( |
|
67 | + sprintf( |
|
68 | + esc_html__( |
|
69 | + 'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.', |
|
70 | + 'event_espresso' |
|
71 | + ), |
|
72 | + $addon_name, |
|
73 | + $min_version_required |
|
74 | + ), |
|
75 | + __FILE__, |
|
76 | + __FUNCTION__ . "($addon_name)", |
|
77 | + __LINE__ |
|
78 | + ); |
|
79 | + EE_Error::get_notices(false, true); |
|
80 | + } |
|
81 | + } |
|
82 | 82 | } |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | string $load_callback, |
53 | 53 | string $plugin_file_constant |
54 | 54 | ): void { |
55 | - if (! defined($version_constant)) { |
|
55 | + if ( ! defined($version_constant)) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | $addon_version = constant($version_constant); |
59 | 59 | if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
60 | 60 | remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
61 | - if (! function_exists('deactivate_plugins')) { |
|
62 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
61 | + if ( ! function_exists('deactivate_plugins')) { |
|
62 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
63 | 63 | } |
64 | 64 | deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
65 | 65 | unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $min_version_required |
74 | 74 | ), |
75 | 75 | __FILE__, |
76 | - __FUNCTION__ . "($addon_name)", |
|
76 | + __FUNCTION__."($addon_name)", |
|
77 | 77 | __LINE__ |
78 | 78 | ); |
79 | 79 | EE_Error::get_notices(false, true); |
@@ -9,119 +9,119 @@ |
||
9 | 9 | |
10 | 10 | class AddonApi extends AddonApiVersion |
11 | 11 | { |
12 | - private DataMigrationApi $data_migration_api; |
|
13 | - |
|
14 | - private LegacyModelApi $legacy_model_api; |
|
15 | - |
|
16 | - |
|
17 | - /** |
|
18 | - * Bootstrap constructor. |
|
19 | - * |
|
20 | - * @param AddonRoutes $addon_routes |
|
21 | - * @param DependencyHandlers $dependency_handlers |
|
22 | - * @param Psr4Autoloader $psr4_loader |
|
23 | - * @param DataMigrationApi $data_migration_api |
|
24 | - * @param LegacyModelApi $legacy_model_api |
|
25 | - */ |
|
26 | - public function __construct( |
|
27 | - AddonRoutes $addon_routes, |
|
28 | - DependencyHandlers $dependency_handlers, |
|
29 | - Psr4Autoloader $psr4_loader, |
|
30 | - DataMigrationApi $data_migration_api, |
|
31 | - LegacyModelApi $legacy_model_api |
|
32 | - ) { |
|
33 | - $this->data_migration_api = $data_migration_api; |
|
34 | - $this->legacy_model_api = $legacy_model_api; |
|
35 | - parent::__construct($addon_routes, $dependency_handlers, $psr4_loader, AddonApiVersion::V1); |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function dataMigrationScripts(): string |
|
43 | - { |
|
44 | - return $this->data_migration_api->dataMigrationScripts(); |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @param string $data_migration_scripts |
|
50 | - */ |
|
51 | - public function addDataMigrationScripts(string $data_migration_scripts): void |
|
52 | - { |
|
53 | - $this->data_migration_api->addDataMigrationScripts($data_migration_scripts); |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function entityClasses(): string |
|
61 | - { |
|
62 | - return $this->legacy_model_api->entityClasses(); |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @param string $entity_classes |
|
68 | - */ |
|
69 | - public function addEntityClasses(string $entity_classes): void |
|
70 | - { |
|
71 | - $this->legacy_model_api->addEntityClasses($entity_classes); |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function entityModels(): string |
|
79 | - { |
|
80 | - return $this->legacy_model_api->entityModels(); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @param string $entity_models |
|
86 | - */ |
|
87 | - public function addEntityModels(string $entity_models): void |
|
88 | - { |
|
89 | - $this->legacy_model_api->addEntityModels($entity_models); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function entityClassExtensions(): string |
|
97 | - { |
|
98 | - return $this->legacy_model_api->entityClassExtensions(); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @param string $entity_class_extensions |
|
104 | - */ |
|
105 | - public function addEntityClassExtensions(string $entity_class_extensions): void |
|
106 | - { |
|
107 | - $this->legacy_model_api->addEntityClassExtensions($entity_class_extensions); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function entityModelExtensions(): string |
|
115 | - { |
|
116 | - return $this->legacy_model_api->entityModelExtensions(); |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * @param string $entity_model_extensions |
|
122 | - */ |
|
123 | - public function addEntityModelExtensions(string $entity_model_extensions): void |
|
124 | - { |
|
125 | - $this->legacy_model_api->addEntityModelExtensions($entity_model_extensions); |
|
126 | - } |
|
12 | + private DataMigrationApi $data_migration_api; |
|
13 | + |
|
14 | + private LegacyModelApi $legacy_model_api; |
|
15 | + |
|
16 | + |
|
17 | + /** |
|
18 | + * Bootstrap constructor. |
|
19 | + * |
|
20 | + * @param AddonRoutes $addon_routes |
|
21 | + * @param DependencyHandlers $dependency_handlers |
|
22 | + * @param Psr4Autoloader $psr4_loader |
|
23 | + * @param DataMigrationApi $data_migration_api |
|
24 | + * @param LegacyModelApi $legacy_model_api |
|
25 | + */ |
|
26 | + public function __construct( |
|
27 | + AddonRoutes $addon_routes, |
|
28 | + DependencyHandlers $dependency_handlers, |
|
29 | + Psr4Autoloader $psr4_loader, |
|
30 | + DataMigrationApi $data_migration_api, |
|
31 | + LegacyModelApi $legacy_model_api |
|
32 | + ) { |
|
33 | + $this->data_migration_api = $data_migration_api; |
|
34 | + $this->legacy_model_api = $legacy_model_api; |
|
35 | + parent::__construct($addon_routes, $dependency_handlers, $psr4_loader, AddonApiVersion::V1); |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function dataMigrationScripts(): string |
|
43 | + { |
|
44 | + return $this->data_migration_api->dataMigrationScripts(); |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @param string $data_migration_scripts |
|
50 | + */ |
|
51 | + public function addDataMigrationScripts(string $data_migration_scripts): void |
|
52 | + { |
|
53 | + $this->data_migration_api->addDataMigrationScripts($data_migration_scripts); |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function entityClasses(): string |
|
61 | + { |
|
62 | + return $this->legacy_model_api->entityClasses(); |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @param string $entity_classes |
|
68 | + */ |
|
69 | + public function addEntityClasses(string $entity_classes): void |
|
70 | + { |
|
71 | + $this->legacy_model_api->addEntityClasses($entity_classes); |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function entityModels(): string |
|
79 | + { |
|
80 | + return $this->legacy_model_api->entityModels(); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @param string $entity_models |
|
86 | + */ |
|
87 | + public function addEntityModels(string $entity_models): void |
|
88 | + { |
|
89 | + $this->legacy_model_api->addEntityModels($entity_models); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * @return string |
|
95 | + */ |
|
96 | + public function entityClassExtensions(): string |
|
97 | + { |
|
98 | + return $this->legacy_model_api->entityClassExtensions(); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @param string $entity_class_extensions |
|
104 | + */ |
|
105 | + public function addEntityClassExtensions(string $entity_class_extensions): void |
|
106 | + { |
|
107 | + $this->legacy_model_api->addEntityClassExtensions($entity_class_extensions); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function entityModelExtensions(): string |
|
115 | + { |
|
116 | + return $this->legacy_model_api->entityModelExtensions(); |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * @param string $entity_model_extensions |
|
122 | + */ |
|
123 | + public function addEntityModelExtensions(string $entity_model_extensions): void |
|
124 | + { |
|
125 | + $this->legacy_model_api->addEntityModelExtensions($entity_model_extensions); |
|
126 | + } |
|
127 | 127 | } |
@@ -9,44 +9,44 @@ |
||
9 | 9 | |
10 | 10 | class RegisterAddon extends EE_Addon |
11 | 11 | { |
12 | - /** |
|
13 | - * @param AddonApiV1 $addon |
|
14 | - * @throws EE_Error |
|
15 | - */ |
|
16 | - public function register(AddonApiV1 $addon): void |
|
17 | - { |
|
18 | - EE_Register_Addon::register( |
|
19 | - $addon->fqcn(), |
|
20 | - [ |
|
21 | - 'class_name' => $addon->fqcn(), |
|
22 | - 'version' => $addon->version(), |
|
23 | - 'plugin_slug' => $addon->slug(), |
|
24 | - 'min_core_version' => $addon->minCoreVersion(), |
|
25 | - 'min_wp_version' => $addon->minWpVersion(), |
|
26 | - 'main_file_path' => $addon->mainFile(), |
|
27 | - 'dms_paths' => [$addon->dataMigrationScripts()], |
|
28 | - 'class_paths' => [$addon->entityClasses()], |
|
29 | - 'model_paths' => [$addon->entityModels()], |
|
30 | - 'class_extension_paths' => [$addon->entityClassExtensions()], |
|
31 | - 'model_extension_paths' => [$addon->entityModelExtensions()], |
|
32 | - 'license' => [ |
|
33 | - 'beta' => false, |
|
34 | - 'main_file_path' => $addon->mainFile(), |
|
35 | - 'min_core_version' => $addon->minCoreVersion(), |
|
36 | - 'plugin_id' => $addon->ID(), |
|
37 | - 'plugin_name' => $addon->displayName(), |
|
38 | - 'plugin_slug' => $addon->slug(), |
|
39 | - 'version' => $addon->version(), |
|
40 | - 'wp_override' => false, |
|
41 | - ], |
|
42 | - // if plugin update engine is being used for auto-updates. not needed if PUE is not being used. |
|
43 | - 'pue_options' => [ |
|
44 | - 'pue_plugin_slug' => $addon->slug(), |
|
45 | - 'plugin_basename' => $addon->domain()->pluginBasename(), |
|
46 | - 'checkPeriod' => '24', |
|
47 | - 'use_wp_update' => false, |
|
48 | - ] |
|
49 | - ] |
|
50 | - ); |
|
51 | - } |
|
12 | + /** |
|
13 | + * @param AddonApiV1 $addon |
|
14 | + * @throws EE_Error |
|
15 | + */ |
|
16 | + public function register(AddonApiV1 $addon): void |
|
17 | + { |
|
18 | + EE_Register_Addon::register( |
|
19 | + $addon->fqcn(), |
|
20 | + [ |
|
21 | + 'class_name' => $addon->fqcn(), |
|
22 | + 'version' => $addon->version(), |
|
23 | + 'plugin_slug' => $addon->slug(), |
|
24 | + 'min_core_version' => $addon->minCoreVersion(), |
|
25 | + 'min_wp_version' => $addon->minWpVersion(), |
|
26 | + 'main_file_path' => $addon->mainFile(), |
|
27 | + 'dms_paths' => [$addon->dataMigrationScripts()], |
|
28 | + 'class_paths' => [$addon->entityClasses()], |
|
29 | + 'model_paths' => [$addon->entityModels()], |
|
30 | + 'class_extension_paths' => [$addon->entityClassExtensions()], |
|
31 | + 'model_extension_paths' => [$addon->entityModelExtensions()], |
|
32 | + 'license' => [ |
|
33 | + 'beta' => false, |
|
34 | + 'main_file_path' => $addon->mainFile(), |
|
35 | + 'min_core_version' => $addon->minCoreVersion(), |
|
36 | + 'plugin_id' => $addon->ID(), |
|
37 | + 'plugin_name' => $addon->displayName(), |
|
38 | + 'plugin_slug' => $addon->slug(), |
|
39 | + 'version' => $addon->version(), |
|
40 | + 'wp_override' => false, |
|
41 | + ], |
|
42 | + // if plugin update engine is being used for auto-updates. not needed if PUE is not being used. |
|
43 | + 'pue_options' => [ |
|
44 | + 'pue_plugin_slug' => $addon->slug(), |
|
45 | + 'plugin_basename' => $addon->domain()->pluginBasename(), |
|
46 | + 'checkPeriod' => '24', |
|
47 | + 'use_wp_update' => false, |
|
48 | + ] |
|
49 | + ] |
|
50 | + ); |
|
51 | + } |
|
52 | 52 | } |
@@ -4,71 +4,71 @@ |
||
4 | 4 | |
5 | 5 | class LegacyModelApi |
6 | 6 | { |
7 | - /** |
|
8 | - * path to EE_* entity classes |
|
9 | - */ |
|
10 | - private string $entity_classes = ''; |
|
7 | + /** |
|
8 | + * path to EE_* entity classes |
|
9 | + */ |
|
10 | + private string $entity_classes = ''; |
|
11 | 11 | |
12 | - /** |
|
13 | - * path to EEM_* entity model classes |
|
14 | - */ |
|
15 | - private string $entity_models = ''; |
|
12 | + /** |
|
13 | + * path to EEM_* entity model classes |
|
14 | + */ |
|
15 | + private string $entity_models = ''; |
|
16 | 16 | |
17 | - /** |
|
18 | - * path to EEE_* entity class extensions |
|
19 | - */ |
|
20 | - private string $entity_class_extensions = ''; |
|
17 | + /** |
|
18 | + * path to EEE_* entity class extensions |
|
19 | + */ |
|
20 | + private string $entity_class_extensions = ''; |
|
21 | 21 | |
22 | - /** |
|
23 | - * path to EEME_* entity model class extensions |
|
24 | - */ |
|
25 | - private string $entity_model_extensions = ''; |
|
22 | + /** |
|
23 | + * path to EEME_* entity model class extensions |
|
24 | + */ |
|
25 | + private string $entity_model_extensions = ''; |
|
26 | 26 | |
27 | 27 | |
28 | - public function entityClasses(): string |
|
29 | - { |
|
30 | - return $this->entity_classes; |
|
31 | - } |
|
28 | + public function entityClasses(): string |
|
29 | + { |
|
30 | + return $this->entity_classes; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - public function addEntityClasses(string $entity_classes): void |
|
35 | - { |
|
36 | - $this->entity_classes = $entity_classes; |
|
37 | - } |
|
34 | + public function addEntityClasses(string $entity_classes): void |
|
35 | + { |
|
36 | + $this->entity_classes = $entity_classes; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - public function entityModels(): string |
|
41 | - { |
|
42 | - return $this->entity_models; |
|
43 | - } |
|
40 | + public function entityModels(): string |
|
41 | + { |
|
42 | + return $this->entity_models; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - public function addEntityModels(string $entity_models): void |
|
47 | - { |
|
48 | - $this->entity_models = $entity_models; |
|
49 | - } |
|
46 | + public function addEntityModels(string $entity_models): void |
|
47 | + { |
|
48 | + $this->entity_models = $entity_models; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - public function entityClassExtensions(): string |
|
53 | - { |
|
54 | - return $this->entity_class_extensions; |
|
55 | - } |
|
52 | + public function entityClassExtensions(): string |
|
53 | + { |
|
54 | + return $this->entity_class_extensions; |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - public function addEntityClassExtensions(string $entity_class_extensions): void |
|
59 | - { |
|
60 | - $this->entity_class_extensions = $entity_class_extensions; |
|
61 | - } |
|
58 | + public function addEntityClassExtensions(string $entity_class_extensions): void |
|
59 | + { |
|
60 | + $this->entity_class_extensions = $entity_class_extensions; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - public function entityModelExtensions(): string |
|
65 | - { |
|
66 | - return $this->entity_model_extensions; |
|
67 | - } |
|
64 | + public function entityModelExtensions(): string |
|
65 | + { |
|
66 | + return $this->entity_model_extensions; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | - public function addEntityModelExtensions(string $entity_model_extensions): void |
|
71 | - { |
|
72 | - $this->entity_model_extensions = $entity_model_extensions; |
|
73 | - } |
|
70 | + public function addEntityModelExtensions(string $entity_model_extensions): void |
|
71 | + { |
|
72 | + $this->entity_model_extensions = $entity_model_extensions; |
|
73 | + } |
|
74 | 74 | } |
@@ -12,138 +12,138 @@ |
||
12 | 12 | */ |
13 | 13 | class States |
14 | 14 | { |
15 | - /** |
|
16 | - * indicates that ALL states should be retrieved from the db |
|
17 | - */ |
|
18 | - public const GET_ALL = 'all'; |
|
19 | - |
|
20 | - /** |
|
21 | - * indicates that only ACTIVE states should be retrieved from the db |
|
22 | - */ |
|
23 | - public const GET_ACTIVE = 'active'; |
|
24 | - |
|
25 | - public const INDEX_TYPE_ID = 'id'; |
|
26 | - |
|
27 | - public const INDEX_TYPE_ABBREV = 'abbrev'; |
|
28 | - |
|
29 | - public const LIST_TYPE_NAME = 'name'; |
|
30 | - |
|
31 | - public const LIST_TYPE_ABBREV = 'abbrev'; |
|
32 | - |
|
33 | - |
|
34 | - private static function validGetOption(string $get_all_or_active): string |
|
35 | - { |
|
36 | - return in_array($get_all_or_active, [States::GET_ALL, States::GET_ACTIVE], true) |
|
37 | - ? $get_all_or_active |
|
38 | - : States::GET_ACTIVE; |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - private static function validIndexType(string $index_type): string |
|
43 | - { |
|
44 | - return in_array($index_type, [States::INDEX_TYPE_ID, States::INDEX_TYPE_ABBREV], true) |
|
45 | - ? $index_type |
|
46 | - : States::INDEX_TYPE_ID; |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - private static function validListType(string $list_type): string |
|
51 | - { |
|
52 | - return in_array($list_type, [States::LIST_TYPE_NAME, States::LIST_TYPE_ABBREV], true) |
|
53 | - ? $list_type |
|
54 | - : States::LIST_TYPE_NAME; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @param string $get_all_or_active |
|
60 | - * @return array |
|
61 | - * @throws EE_Error |
|
62 | - * @throws ReflectionException |
|
63 | - */ |
|
64 | - private static function getStates(string $get_all_or_active = States::GET_ACTIVE): array |
|
65 | - { |
|
66 | - $get_all_or_active = States::validGetOption($get_all_or_active); |
|
67 | - // get possibly cached list of states |
|
68 | - return $get_all_or_active === States::GET_ALL |
|
69 | - ? EEM_State::instance()->get_all_states() |
|
70 | - : EEM_State::instance()->get_all_active_states(); |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @param string $index_type what to use as keys for the array, one of the States::INDEX_TYPE_* constants |
|
76 | - * @param bool $group_by_country whether to group the states by country |
|
77 | - * @param string $get_all_or_active whether to get all states or just active states, |
|
78 | - * one of the States::GET_* constants |
|
79 | - * @return array |
|
80 | - * @throws EE_Error |
|
81 | - * @throws ReflectionException |
|
82 | - */ |
|
83 | - public static function arrayOfNames( |
|
84 | - string $index_type = States::INDEX_TYPE_ID, |
|
85 | - bool $group_by_country = true, |
|
86 | - string $get_all_or_active = States::GET_ACTIVE |
|
87 | - ): array { |
|
88 | - return States::arrayOfStates($index_type, $group_by_country, $get_all_or_active, States::LIST_TYPE_NAME); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @param string $index_type what to use as keys for the array, one of the States::INDEX_TYPE_* constants |
|
94 | - * @param bool $group_by_country whether to group the states by country |
|
95 | - * @param string $get_all_or_active whether to get all states or just active states, |
|
96 | - * one of the States::GET_* constants |
|
97 | - * @return array |
|
98 | - * @throws EE_Error |
|
99 | - * @throws ReflectionException |
|
100 | - */ |
|
101 | - public static function arrayOfAbbreviations( |
|
102 | - string $index_type = States::INDEX_TYPE_ID, |
|
103 | - bool $group_by_country = true, |
|
104 | - string $get_all_or_active = States::GET_ACTIVE |
|
105 | - ): array { |
|
106 | - return States::arrayOfStates($index_type, $group_by_country, $get_all_or_active, States::LIST_TYPE_ABBREV); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * generate list of state names or ISO codes |
|
112 | - * |
|
113 | - * @param string $index_type what to use as keys for the array, one of the States::INDEX_TYPE_* constants |
|
114 | - * @param bool $group_by_country whether to group the states by country |
|
115 | - * @param string $get_all_or_active whether to get all states or just active states, |
|
116 | - * one of the States::GET_* constants |
|
117 | - * @param string $list_type whether to use state names or abbreviations as values for the array, |
|
118 | - * one of the States::LIST_TYPE_* constants |
|
119 | - * @return array |
|
120 | - * @throws EE_Error |
|
121 | - * @throws ReflectionException |
|
122 | - */ |
|
123 | - private static function arrayOfStates( |
|
124 | - string $index_type, |
|
125 | - bool $group_by_country, |
|
126 | - string $get_all_or_active, |
|
127 | - string $list_type |
|
128 | - ): array { |
|
129 | - $list = [0 => '']; |
|
130 | - $group_list = ['' => [0 => '']]; |
|
131 | - $states = States::getStates($get_all_or_active); |
|
132 | - $list_type = States::validListType($list_type); |
|
133 | - $index_type = States::validIndexType($index_type); |
|
134 | - if (! empty($states)) { |
|
135 | - foreach ($states as $state) { |
|
136 | - if ($state instanceof EE_State) { |
|
137 | - $index = $index_type === States::INDEX_TYPE_ID ? $state->ID() : $state->abbrev(); |
|
138 | - $value = $list_type === States::LIST_TYPE_NAME ? $state->name() : $state->abbrev(); |
|
139 | - if ($group_by_country) { |
|
140 | - $group_list[ $state->country()->name() ][ $index ] = $value; |
|
141 | - } else { |
|
142 | - $list[ $index ] = $value; |
|
143 | - } |
|
144 | - } |
|
145 | - } |
|
146 | - } |
|
147 | - return $group_by_country ? $group_list : $list; |
|
148 | - } |
|
15 | + /** |
|
16 | + * indicates that ALL states should be retrieved from the db |
|
17 | + */ |
|
18 | + public const GET_ALL = 'all'; |
|
19 | + |
|
20 | + /** |
|
21 | + * indicates that only ACTIVE states should be retrieved from the db |
|
22 | + */ |
|
23 | + public const GET_ACTIVE = 'active'; |
|
24 | + |
|
25 | + public const INDEX_TYPE_ID = 'id'; |
|
26 | + |
|
27 | + public const INDEX_TYPE_ABBREV = 'abbrev'; |
|
28 | + |
|
29 | + public const LIST_TYPE_NAME = 'name'; |
|
30 | + |
|
31 | + public const LIST_TYPE_ABBREV = 'abbrev'; |
|
32 | + |
|
33 | + |
|
34 | + private static function validGetOption(string $get_all_or_active): string |
|
35 | + { |
|
36 | + return in_array($get_all_or_active, [States::GET_ALL, States::GET_ACTIVE], true) |
|
37 | + ? $get_all_or_active |
|
38 | + : States::GET_ACTIVE; |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + private static function validIndexType(string $index_type): string |
|
43 | + { |
|
44 | + return in_array($index_type, [States::INDEX_TYPE_ID, States::INDEX_TYPE_ABBREV], true) |
|
45 | + ? $index_type |
|
46 | + : States::INDEX_TYPE_ID; |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + private static function validListType(string $list_type): string |
|
51 | + { |
|
52 | + return in_array($list_type, [States::LIST_TYPE_NAME, States::LIST_TYPE_ABBREV], true) |
|
53 | + ? $list_type |
|
54 | + : States::LIST_TYPE_NAME; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @param string $get_all_or_active |
|
60 | + * @return array |
|
61 | + * @throws EE_Error |
|
62 | + * @throws ReflectionException |
|
63 | + */ |
|
64 | + private static function getStates(string $get_all_or_active = States::GET_ACTIVE): array |
|
65 | + { |
|
66 | + $get_all_or_active = States::validGetOption($get_all_or_active); |
|
67 | + // get possibly cached list of states |
|
68 | + return $get_all_or_active === States::GET_ALL |
|
69 | + ? EEM_State::instance()->get_all_states() |
|
70 | + : EEM_State::instance()->get_all_active_states(); |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @param string $index_type what to use as keys for the array, one of the States::INDEX_TYPE_* constants |
|
76 | + * @param bool $group_by_country whether to group the states by country |
|
77 | + * @param string $get_all_or_active whether to get all states or just active states, |
|
78 | + * one of the States::GET_* constants |
|
79 | + * @return array |
|
80 | + * @throws EE_Error |
|
81 | + * @throws ReflectionException |
|
82 | + */ |
|
83 | + public static function arrayOfNames( |
|
84 | + string $index_type = States::INDEX_TYPE_ID, |
|
85 | + bool $group_by_country = true, |
|
86 | + string $get_all_or_active = States::GET_ACTIVE |
|
87 | + ): array { |
|
88 | + return States::arrayOfStates($index_type, $group_by_country, $get_all_or_active, States::LIST_TYPE_NAME); |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @param string $index_type what to use as keys for the array, one of the States::INDEX_TYPE_* constants |
|
94 | + * @param bool $group_by_country whether to group the states by country |
|
95 | + * @param string $get_all_or_active whether to get all states or just active states, |
|
96 | + * one of the States::GET_* constants |
|
97 | + * @return array |
|
98 | + * @throws EE_Error |
|
99 | + * @throws ReflectionException |
|
100 | + */ |
|
101 | + public static function arrayOfAbbreviations( |
|
102 | + string $index_type = States::INDEX_TYPE_ID, |
|
103 | + bool $group_by_country = true, |
|
104 | + string $get_all_or_active = States::GET_ACTIVE |
|
105 | + ): array { |
|
106 | + return States::arrayOfStates($index_type, $group_by_country, $get_all_or_active, States::LIST_TYPE_ABBREV); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * generate list of state names or ISO codes |
|
112 | + * |
|
113 | + * @param string $index_type what to use as keys for the array, one of the States::INDEX_TYPE_* constants |
|
114 | + * @param bool $group_by_country whether to group the states by country |
|
115 | + * @param string $get_all_or_active whether to get all states or just active states, |
|
116 | + * one of the States::GET_* constants |
|
117 | + * @param string $list_type whether to use state names or abbreviations as values for the array, |
|
118 | + * one of the States::LIST_TYPE_* constants |
|
119 | + * @return array |
|
120 | + * @throws EE_Error |
|
121 | + * @throws ReflectionException |
|
122 | + */ |
|
123 | + private static function arrayOfStates( |
|
124 | + string $index_type, |
|
125 | + bool $group_by_country, |
|
126 | + string $get_all_or_active, |
|
127 | + string $list_type |
|
128 | + ): array { |
|
129 | + $list = [0 => '']; |
|
130 | + $group_list = ['' => [0 => '']]; |
|
131 | + $states = States::getStates($get_all_or_active); |
|
132 | + $list_type = States::validListType($list_type); |
|
133 | + $index_type = States::validIndexType($index_type); |
|
134 | + if (! empty($states)) { |
|
135 | + foreach ($states as $state) { |
|
136 | + if ($state instanceof EE_State) { |
|
137 | + $index = $index_type === States::INDEX_TYPE_ID ? $state->ID() : $state->abbrev(); |
|
138 | + $value = $list_type === States::LIST_TYPE_NAME ? $state->name() : $state->abbrev(); |
|
139 | + if ($group_by_country) { |
|
140 | + $group_list[ $state->country()->name() ][ $index ] = $value; |
|
141 | + } else { |
|
142 | + $list[ $index ] = $value; |
|
143 | + } |
|
144 | + } |
|
145 | + } |
|
146 | + } |
|
147 | + return $group_by_country ? $group_list : $list; |
|
148 | + } |
|
149 | 149 | } |
@@ -131,15 +131,15 @@ |
||
131 | 131 | $states = States::getStates($get_all_or_active); |
132 | 132 | $list_type = States::validListType($list_type); |
133 | 133 | $index_type = States::validIndexType($index_type); |
134 | - if (! empty($states)) { |
|
134 | + if ( ! empty($states)) { |
|
135 | 135 | foreach ($states as $state) { |
136 | 136 | if ($state instanceof EE_State) { |
137 | 137 | $index = $index_type === States::INDEX_TYPE_ID ? $state->ID() : $state->abbrev(); |
138 | 138 | $value = $list_type === States::LIST_TYPE_NAME ? $state->name() : $state->abbrev(); |
139 | 139 | if ($group_by_country) { |
140 | - $group_list[ $state->country()->name() ][ $index ] = $value; |
|
140 | + $group_list[$state->country()->name()][$index] = $value; |
|
141 | 141 | } else { |
142 | - $list[ $index ] = $value; |
|
142 | + $list[$index] = $value; |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | } |
@@ -12,126 +12,126 @@ |
||
12 | 12 | */ |
13 | 13 | class Countries |
14 | 14 | { |
15 | - /** |
|
16 | - * indicates that ALL countries should be retrieved from the db |
|
17 | - */ |
|
18 | - public const GET_ALL = 'all'; |
|
19 | - |
|
20 | - /** |
|
21 | - * indicates that only ACTIVE countries should be retrieved from the db |
|
22 | - */ |
|
23 | - public const GET_ACTIVE = 'active'; |
|
24 | - |
|
25 | - public const INDEX_TYPE_ID = 'id'; |
|
26 | - |
|
27 | - public const INDEX_TYPE_ISO = 'iso'; |
|
28 | - |
|
29 | - public const LIST_TYPE_NAME = 'name'; |
|
30 | - |
|
31 | - public const LIST_TYPE_ISO = 'iso'; |
|
32 | - |
|
33 | - |
|
34 | - private static function validGetOption(string $get_all_or_active): string |
|
35 | - { |
|
36 | - return in_array($get_all_or_active, [Countries::GET_ALL, Countries::GET_ACTIVE], true) |
|
37 | - ? $get_all_or_active |
|
38 | - : Countries::GET_ACTIVE; |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - private static function validIndexType(string $index_type): string |
|
43 | - { |
|
44 | - return in_array($index_type, [Countries::INDEX_TYPE_ID, Countries::INDEX_TYPE_ISO], true) |
|
45 | - ? $index_type |
|
46 | - : Countries::INDEX_TYPE_ID; |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - private static function validListType(string $list_type): string |
|
51 | - { |
|
52 | - return in_array($list_type, [Countries::LIST_TYPE_NAME, Countries::LIST_TYPE_ISO], true) |
|
53 | - ? $list_type |
|
54 | - : Countries::LIST_TYPE_NAME; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @param string $get_all_or_active whether to get all countries or just active countries, |
|
60 | - * @return array |
|
61 | - * @throws EE_Error |
|
62 | - * @throws ReflectionException |
|
63 | - */ |
|
64 | - private static function getCountries(string $get_all_or_active = Countries::GET_ACTIVE): array |
|
65 | - { |
|
66 | - $get_all_or_active = Countries::validGetOption($get_all_or_active); |
|
67 | - // get possibly cached list of countries |
|
68 | - return $get_all_or_active === Countries::GET_ALL |
|
69 | - ? EEM_Country::instance()->get_all_countries() |
|
70 | - : EEM_Country::instance()->get_all_active_countries(); |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @param string $index_type what to use as keys for the array, one of the Countries::INDEX_TYPE_* constants |
|
76 | - * @param string $get_all_or_active whether to get all countries or just active countries, |
|
77 | - * one of the Countries::GET_* constants |
|
78 | - * @return array |
|
79 | - * @throws EE_Error |
|
80 | - * @throws ReflectionException |
|
81 | - */ |
|
82 | - public static function arrayOfNames( |
|
83 | - string $index_type = Countries::INDEX_TYPE_ID, |
|
84 | - string $get_all_or_active = Countries::GET_ACTIVE |
|
85 | - ): array { |
|
86 | - return Countries::arrayOfCountries($index_type, $get_all_or_active, Countries::LIST_TYPE_NAME); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @param string $index_type what to use as keys for the array, one of the Countries::INDEX_TYPE_* constants |
|
92 | - * @param string $get_all_or_active whether to get all countries or just active countries, |
|
93 | - * one of the Countries::GET_* constants |
|
94 | - * @return array |
|
95 | - * @throws EE_Error |
|
96 | - * @throws ReflectionException |
|
97 | - */ |
|
98 | - public static function arrayOfISOs( |
|
99 | - string $index_type = Countries::INDEX_TYPE_ID, |
|
100 | - string $get_all_or_active = Countries::GET_ACTIVE |
|
101 | - ): array { |
|
102 | - return Countries::arrayOfCountries($index_type, $get_all_or_active, Countries::LIST_TYPE_ISO); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * generate list of country names or ISO codes |
|
108 | - * |
|
109 | - * @param string $index_type what to use as keys for the array, one of the Countries::INDEX_TYPE_* constants |
|
110 | - * @param string $get_all_or_active whether to get all countries or just active countries, |
|
111 | - * one of the Countries::GET_* constants |
|
112 | - * @param string $list_type whether to use country names or ISO codes as values for the array, |
|
113 | - * one of the Countries::LIST_TYPE_* constants |
|
114 | - * @return array |
|
115 | - * @throws EE_Error |
|
116 | - * @throws ReflectionException |
|
117 | - */ |
|
118 | - private static function arrayOfCountries( |
|
119 | - string $index_type, |
|
120 | - string $get_all_or_active, |
|
121 | - string $list_type |
|
122 | - ): array { |
|
123 | - $list = ['' => '']; |
|
124 | - $countries = Countries::getCountries($get_all_or_active); |
|
125 | - $list_type = Countries::validListType($list_type); |
|
126 | - $index_type = Countries::validIndexType($index_type); |
|
127 | - if (! empty($countries)) { |
|
128 | - foreach ($countries as $country) { |
|
129 | - if ($country instanceof EE_Country) { |
|
130 | - $index = $index_type === Countries::INDEX_TYPE_ID ? $country->ID() : $country->ISO(); |
|
131 | - $list[ $index ] = $list_type === Countries::LIST_TYPE_NAME ? $country->name() : $country->ISO(); |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - return $list; |
|
136 | - } |
|
15 | + /** |
|
16 | + * indicates that ALL countries should be retrieved from the db |
|
17 | + */ |
|
18 | + public const GET_ALL = 'all'; |
|
19 | + |
|
20 | + /** |
|
21 | + * indicates that only ACTIVE countries should be retrieved from the db |
|
22 | + */ |
|
23 | + public const GET_ACTIVE = 'active'; |
|
24 | + |
|
25 | + public const INDEX_TYPE_ID = 'id'; |
|
26 | + |
|
27 | + public const INDEX_TYPE_ISO = 'iso'; |
|
28 | + |
|
29 | + public const LIST_TYPE_NAME = 'name'; |
|
30 | + |
|
31 | + public const LIST_TYPE_ISO = 'iso'; |
|
32 | + |
|
33 | + |
|
34 | + private static function validGetOption(string $get_all_or_active): string |
|
35 | + { |
|
36 | + return in_array($get_all_or_active, [Countries::GET_ALL, Countries::GET_ACTIVE], true) |
|
37 | + ? $get_all_or_active |
|
38 | + : Countries::GET_ACTIVE; |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + private static function validIndexType(string $index_type): string |
|
43 | + { |
|
44 | + return in_array($index_type, [Countries::INDEX_TYPE_ID, Countries::INDEX_TYPE_ISO], true) |
|
45 | + ? $index_type |
|
46 | + : Countries::INDEX_TYPE_ID; |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + private static function validListType(string $list_type): string |
|
51 | + { |
|
52 | + return in_array($list_type, [Countries::LIST_TYPE_NAME, Countries::LIST_TYPE_ISO], true) |
|
53 | + ? $list_type |
|
54 | + : Countries::LIST_TYPE_NAME; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @param string $get_all_or_active whether to get all countries or just active countries, |
|
60 | + * @return array |
|
61 | + * @throws EE_Error |
|
62 | + * @throws ReflectionException |
|
63 | + */ |
|
64 | + private static function getCountries(string $get_all_or_active = Countries::GET_ACTIVE): array |
|
65 | + { |
|
66 | + $get_all_or_active = Countries::validGetOption($get_all_or_active); |
|
67 | + // get possibly cached list of countries |
|
68 | + return $get_all_or_active === Countries::GET_ALL |
|
69 | + ? EEM_Country::instance()->get_all_countries() |
|
70 | + : EEM_Country::instance()->get_all_active_countries(); |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @param string $index_type what to use as keys for the array, one of the Countries::INDEX_TYPE_* constants |
|
76 | + * @param string $get_all_or_active whether to get all countries or just active countries, |
|
77 | + * one of the Countries::GET_* constants |
|
78 | + * @return array |
|
79 | + * @throws EE_Error |
|
80 | + * @throws ReflectionException |
|
81 | + */ |
|
82 | + public static function arrayOfNames( |
|
83 | + string $index_type = Countries::INDEX_TYPE_ID, |
|
84 | + string $get_all_or_active = Countries::GET_ACTIVE |
|
85 | + ): array { |
|
86 | + return Countries::arrayOfCountries($index_type, $get_all_or_active, Countries::LIST_TYPE_NAME); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @param string $index_type what to use as keys for the array, one of the Countries::INDEX_TYPE_* constants |
|
92 | + * @param string $get_all_or_active whether to get all countries or just active countries, |
|
93 | + * one of the Countries::GET_* constants |
|
94 | + * @return array |
|
95 | + * @throws EE_Error |
|
96 | + * @throws ReflectionException |
|
97 | + */ |
|
98 | + public static function arrayOfISOs( |
|
99 | + string $index_type = Countries::INDEX_TYPE_ID, |
|
100 | + string $get_all_or_active = Countries::GET_ACTIVE |
|
101 | + ): array { |
|
102 | + return Countries::arrayOfCountries($index_type, $get_all_or_active, Countries::LIST_TYPE_ISO); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * generate list of country names or ISO codes |
|
108 | + * |
|
109 | + * @param string $index_type what to use as keys for the array, one of the Countries::INDEX_TYPE_* constants |
|
110 | + * @param string $get_all_or_active whether to get all countries or just active countries, |
|
111 | + * one of the Countries::GET_* constants |
|
112 | + * @param string $list_type whether to use country names or ISO codes as values for the array, |
|
113 | + * one of the Countries::LIST_TYPE_* constants |
|
114 | + * @return array |
|
115 | + * @throws EE_Error |
|
116 | + * @throws ReflectionException |
|
117 | + */ |
|
118 | + private static function arrayOfCountries( |
|
119 | + string $index_type, |
|
120 | + string $get_all_or_active, |
|
121 | + string $list_type |
|
122 | + ): array { |
|
123 | + $list = ['' => '']; |
|
124 | + $countries = Countries::getCountries($get_all_or_active); |
|
125 | + $list_type = Countries::validListType($list_type); |
|
126 | + $index_type = Countries::validIndexType($index_type); |
|
127 | + if (! empty($countries)) { |
|
128 | + foreach ($countries as $country) { |
|
129 | + if ($country instanceof EE_Country) { |
|
130 | + $index = $index_type === Countries::INDEX_TYPE_ID ? $country->ID() : $country->ISO(); |
|
131 | + $list[ $index ] = $list_type === Countries::LIST_TYPE_NAME ? $country->name() : $country->ISO(); |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + return $list; |
|
136 | + } |
|
137 | 137 | } |
@@ -124,11 +124,11 @@ |
||
124 | 124 | $countries = Countries::getCountries($get_all_or_active); |
125 | 125 | $list_type = Countries::validListType($list_type); |
126 | 126 | $index_type = Countries::validIndexType($index_type); |
127 | - if (! empty($countries)) { |
|
127 | + if ( ! empty($countries)) { |
|
128 | 128 | foreach ($countries as $country) { |
129 | 129 | if ($country instanceof EE_Country) { |
130 | 130 | $index = $index_type === Countries::INDEX_TYPE_ID ? $country->ID() : $country->ISO(); |
131 | - $list[ $index ] = $list_type === Countries::LIST_TYPE_NAME ? $country->name() : $country->ISO(); |
|
131 | + $list[$index] = $list_type === Countries::LIST_TYPE_NAME ? $country->name() : $country->ISO(); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
@@ -17,281 +17,281 @@ |
||
17 | 17 | */ |
18 | 18 | abstract class IframeEmbedButton |
19 | 19 | { |
20 | - /** |
|
21 | - * @var string $iframe_name |
|
22 | - */ |
|
23 | - private $iframe_name; |
|
20 | + /** |
|
21 | + * @var string $iframe_name |
|
22 | + */ |
|
23 | + private $iframe_name; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var string $route_name |
|
27 | - */ |
|
28 | - private $route_name; |
|
25 | + /** |
|
26 | + * @var string $route_name |
|
27 | + */ |
|
28 | + private $route_name; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var string $slug |
|
32 | - */ |
|
33 | - private $slug; |
|
30 | + /** |
|
31 | + * @var string $slug |
|
32 | + */ |
|
33 | + private $slug; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @var boolean $append_filterable_content |
|
37 | - */ |
|
38 | - private $append_filterable_content; |
|
35 | + /** |
|
36 | + * @var boolean $append_filterable_content |
|
37 | + */ |
|
38 | + private $append_filterable_content; |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * IframeEmbedButton constructor. |
|
43 | - * |
|
44 | - * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
45 | - * @param string $route_name the name of the registered route |
|
46 | - * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
47 | - * will most likely be "event" since that's the only usage atm |
|
48 | - */ |
|
49 | - public function __construct($iframe_name, $route_name, $slug = 'event') |
|
50 | - { |
|
51 | - $this->iframe_name = $iframe_name; |
|
52 | - $this->route_name = $route_name; |
|
53 | - $this->slug = $slug; |
|
54 | - } |
|
41 | + /** |
|
42 | + * IframeEmbedButton constructor. |
|
43 | + * |
|
44 | + * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
45 | + * @param string $route_name the name of the registered route |
|
46 | + * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
47 | + * will most likely be "event" since that's the only usage atm |
|
48 | + */ |
|
49 | + public function __construct($iframe_name, $route_name, $slug = 'event') |
|
50 | + { |
|
51 | + $this->iframe_name = $iframe_name; |
|
52 | + $this->route_name = $route_name; |
|
53 | + $this->slug = $slug; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Adds an iframe embed code button to the Event editor. |
|
59 | - */ |
|
60 | - public function addEventEditorIframeEmbedButtonFilter() |
|
61 | - { |
|
62 | - add_filter( |
|
63 | - 'get_sample_permalink_html', |
|
64 | - array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'), |
|
65 | - 15, |
|
66 | - 2 |
|
67 | - ); |
|
68 | - } |
|
57 | + /** |
|
58 | + * Adds an iframe embed code button to the Event editor. |
|
59 | + */ |
|
60 | + public function addEventEditorIframeEmbedButtonFilter() |
|
61 | + { |
|
62 | + add_filter( |
|
63 | + 'get_sample_permalink_html', |
|
64 | + array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'), |
|
65 | + 15, |
|
66 | + 2 |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Adds assets of iframe embed code button. |
|
72 | - */ |
|
73 | - public function addEventEditorIframeEmbedButtonAssets() |
|
74 | - { |
|
75 | - add_action( |
|
76 | - 'admin_enqueue_scripts', |
|
77 | - array($this, 'embedButtonAssets'), |
|
78 | - 10 |
|
79 | - ); |
|
80 | - } |
|
70 | + /** |
|
71 | + * Adds assets of iframe embed code button. |
|
72 | + */ |
|
73 | + public function addEventEditorIframeEmbedButtonAssets() |
|
74 | + { |
|
75 | + add_action( |
|
76 | + 'admin_enqueue_scripts', |
|
77 | + array($this, 'embedButtonAssets'), |
|
78 | + 10 |
|
79 | + ); |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * @param $permalink_string |
|
85 | - * @param $id |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id) |
|
89 | - { |
|
90 | - return $this->eventEditorIframeEmbedButton( |
|
91 | - $permalink_string, |
|
92 | - $id |
|
93 | - ); |
|
94 | - } |
|
83 | + /** |
|
84 | + * @param $permalink_string |
|
85 | + * @param $id |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id) |
|
89 | + { |
|
90 | + return $this->eventEditorIframeEmbedButton( |
|
91 | + $permalink_string, |
|
92 | + $id |
|
93 | + ); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | - /** |
|
98 | - * iframe embed code button to the Event editor. |
|
99 | - * |
|
100 | - * @param string $permalink_string |
|
101 | - * @param int $id |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - public function eventEditorIframeEmbedButton( |
|
105 | - $permalink_string, |
|
106 | - $id |
|
107 | - ) { |
|
108 | - // make sure this is ONLY when editing and the event id has been set. |
|
109 | - if (! empty($id)) { |
|
110 | - $post = get_post($id); |
|
111 | - // if NOT event then let's get out. |
|
112 | - if ($post->post_type !== EspressoPostType::EVENTS) { |
|
113 | - return $permalink_string; |
|
114 | - } |
|
115 | - $permalink_string .= $this->embedButtonHtml([$this->slug => $id]); |
|
116 | - } |
|
117 | - return $permalink_string; |
|
118 | - } |
|
97 | + /** |
|
98 | + * iframe embed code button to the Event editor. |
|
99 | + * |
|
100 | + * @param string $permalink_string |
|
101 | + * @param int $id |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + public function eventEditorIframeEmbedButton( |
|
105 | + $permalink_string, |
|
106 | + $id |
|
107 | + ) { |
|
108 | + // make sure this is ONLY when editing and the event id has been set. |
|
109 | + if (! empty($id)) { |
|
110 | + $post = get_post($id); |
|
111 | + // if NOT event then let's get out. |
|
112 | + if ($post->post_type !== EspressoPostType::EVENTS) { |
|
113 | + return $permalink_string; |
|
114 | + } |
|
115 | + $permalink_string .= $this->embedButtonHtml([$this->slug => $id]); |
|
116 | + } |
|
117 | + return $permalink_string; |
|
118 | + } |
|
119 | 119 | |
120 | 120 | |
121 | - /** |
|
122 | - * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
123 | - * |
|
124 | - * @param string $action name of the WP do_action() to hook into |
|
125 | - */ |
|
126 | - public function addActionIframeEmbedButton($action) |
|
127 | - { |
|
128 | - // add button for iframe code to event editor. |
|
129 | - add_action( |
|
130 | - $action, |
|
131 | - array($this, 'addActionIframeEmbedButtonCallback'), |
|
132 | - 10, |
|
133 | - 2 |
|
134 | - ); |
|
135 | - } |
|
121 | + /** |
|
122 | + * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
123 | + * |
|
124 | + * @param string $action name of the WP do_action() to hook into |
|
125 | + */ |
|
126 | + public function addActionIframeEmbedButton($action) |
|
127 | + { |
|
128 | + // add button for iframe code to event editor. |
|
129 | + add_action( |
|
130 | + $action, |
|
131 | + array($this, 'addActionIframeEmbedButtonCallback'), |
|
132 | + 10, |
|
133 | + 2 |
|
134 | + ); |
|
135 | + } |
|
136 | 136 | |
137 | 137 | |
138 | - /** |
|
139 | - * @return void |
|
140 | - */ |
|
141 | - public function addActionIframeEmbedButtonCallback() |
|
142 | - { |
|
143 | - echo wp_kses($this->embedButtonHtml(), AllowedTags::getWithFullTags()); |
|
144 | - } |
|
138 | + /** |
|
139 | + * @return void |
|
140 | + */ |
|
141 | + public function addActionIframeEmbedButtonCallback() |
|
142 | + { |
|
143 | + echo wp_kses($this->embedButtonHtml(), AllowedTags::getWithFullTags()); |
|
144 | + } |
|
145 | 145 | |
146 | 146 | |
147 | - /** |
|
148 | - * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
149 | - * |
|
150 | - * @param string $filter name of the WP apply_filters() to hook into |
|
151 | - * @param bool $append if true, will add iframe embed button to end of content, |
|
152 | - * else if false, will add to the beginning of the content |
|
153 | - */ |
|
154 | - public function addFilterIframeEmbedButton($filter, $append = true) |
|
155 | - { |
|
156 | - $this->append_filterable_content = $append; |
|
157 | - // add button for iframe code to event editor. |
|
158 | - add_filter( |
|
159 | - $filter, |
|
160 | - array($this, 'addFilterIframeEmbedButtonCallback'), |
|
161 | - 10 |
|
162 | - ); |
|
163 | - } |
|
147 | + /** |
|
148 | + * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
149 | + * |
|
150 | + * @param string $filter name of the WP apply_filters() to hook into |
|
151 | + * @param bool $append if true, will add iframe embed button to end of content, |
|
152 | + * else if false, will add to the beginning of the content |
|
153 | + */ |
|
154 | + public function addFilterIframeEmbedButton($filter, $append = true) |
|
155 | + { |
|
156 | + $this->append_filterable_content = $append; |
|
157 | + // add button for iframe code to event editor. |
|
158 | + add_filter( |
|
159 | + $filter, |
|
160 | + array($this, 'addFilterIframeEmbedButtonCallback'), |
|
161 | + 10 |
|
162 | + ); |
|
163 | + } |
|
164 | 164 | |
165 | 165 | |
166 | - /** |
|
167 | - * @param array|string $filterable_content |
|
168 | - * @return array|string |
|
169 | - */ |
|
170 | - public function addFilterIframeEmbedButtonCallback($filterable_content) |
|
171 | - { |
|
172 | - $embedButtonHtml = $this->embedButtonHtml(); |
|
173 | - if (is_array($filterable_content)) { |
|
174 | - $filterable_content = $this->append_filterable_content |
|
175 | - ? $filterable_content + array($this->route_name => $embedButtonHtml) |
|
176 | - : array($this->route_name => $embedButtonHtml) + $filterable_content; |
|
177 | - } else { |
|
178 | - $filterable_content = $this->append_filterable_content |
|
179 | - ? $filterable_content . $embedButtonHtml |
|
180 | - : $embedButtonHtml . $filterable_content; |
|
181 | - } |
|
182 | - return $filterable_content; |
|
183 | - } |
|
166 | + /** |
|
167 | + * @param array|string $filterable_content |
|
168 | + * @return array|string |
|
169 | + */ |
|
170 | + public function addFilterIframeEmbedButtonCallback($filterable_content) |
|
171 | + { |
|
172 | + $embedButtonHtml = $this->embedButtonHtml(); |
|
173 | + if (is_array($filterable_content)) { |
|
174 | + $filterable_content = $this->append_filterable_content |
|
175 | + ? $filterable_content + array($this->route_name => $embedButtonHtml) |
|
176 | + : array($this->route_name => $embedButtonHtml) + $filterable_content; |
|
177 | + } else { |
|
178 | + $filterable_content = $this->append_filterable_content |
|
179 | + ? $filterable_content . $embedButtonHtml |
|
180 | + : $embedButtonHtml . $filterable_content; |
|
181 | + } |
|
182 | + return $filterable_content; |
|
183 | + } |
|
184 | 184 | |
185 | 185 | |
186 | - /** |
|
187 | - * iframe_embed_html |
|
188 | - * |
|
189 | - * @param array $query_args |
|
190 | - * @param string $button_class |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public function embedButtonHtml($query_args = array(), $button_class = '') |
|
194 | - { |
|
195 | - // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
196 | - $query_args = (array) $query_args + array($this->route_name => 'iframe'); |
|
197 | - $query_args = (array) apply_filters( |
|
198 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
199 | - $query_args |
|
200 | - ); |
|
201 | - // add this route to our localized vars |
|
202 | - $iframe_module_routes = EE_Registry::$i18n_js_strings['iframe_module_routes'] ?? []; |
|
203 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
204 | - EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes; |
|
205 | - $route_name = esc_attr($this->route_name); |
|
206 | - $iframe_url = esc_url_raw(add_query_arg($query_args, site_url())); |
|
186 | + /** |
|
187 | + * iframe_embed_html |
|
188 | + * |
|
189 | + * @param array $query_args |
|
190 | + * @param string $button_class |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public function embedButtonHtml($query_args = array(), $button_class = '') |
|
194 | + { |
|
195 | + // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
196 | + $query_args = (array) $query_args + array($this->route_name => 'iframe'); |
|
197 | + $query_args = (array) apply_filters( |
|
198 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
199 | + $query_args |
|
200 | + ); |
|
201 | + // add this route to our localized vars |
|
202 | + $iframe_module_routes = EE_Registry::$i18n_js_strings['iframe_module_routes'] ?? []; |
|
203 | + $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
204 | + EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes; |
|
205 | + $route_name = esc_attr($this->route_name); |
|
206 | + $iframe_url = esc_url_raw(add_query_arg($query_args, site_url())); |
|
207 | 207 | |
208 | - return EEH_HTML::div( |
|
209 | - EEH_HTML::link( |
|
210 | - '#', |
|
211 | - sprintf( |
|
212 | - esc_html__('%1$s Embed %2$s iFrame', 'event_espresso'), |
|
213 | - '<span class="dashicons dashicons-embed-post"></span>', |
|
214 | - $this->iframe_name |
|
215 | - ), |
|
216 | - sprintf( |
|
217 | - esc_html__( |
|
218 | - 'click here to generate code for embedding %1$s iframe into another site.', |
|
219 | - 'event_espresso' |
|
220 | - ), |
|
221 | - EEH_Inflector::add_indefinite_article($this->iframe_name) |
|
222 | - ), |
|
223 | - $route_name . '-iframe-embed-trigger-js', |
|
224 | - 'iframe-embed-trigger-js button button--small button--secondary ' . esc_attr($button_class), |
|
225 | - '', |
|
226 | - ' data-iframe_embed_button="#' . $route_name . '-iframe-js" tabindex="-1"' |
|
227 | - ), |
|
228 | - '', |
|
229 | - 'ee-admin-button-row ee-admin-button-row--align-start' |
|
230 | - ) |
|
231 | - . EEH_HTML::div( |
|
232 | - EEH_HTML::div( |
|
233 | - esc_html('<iframe src="' . $iframe_url . '" allow="' . home_url() . '" width="100%" height="100%"></iframe>'), |
|
234 | - '', |
|
235 | - '', |
|
236 | - 'width:100%; height: 500px;' |
|
237 | - ), |
|
238 | - $route_name . '-iframe-js', |
|
239 | - 'iframe-embed-wrapper-js', |
|
240 | - 'display:none;' |
|
241 | - ); |
|
242 | - } |
|
208 | + return EEH_HTML::div( |
|
209 | + EEH_HTML::link( |
|
210 | + '#', |
|
211 | + sprintf( |
|
212 | + esc_html__('%1$s Embed %2$s iFrame', 'event_espresso'), |
|
213 | + '<span class="dashicons dashicons-embed-post"></span>', |
|
214 | + $this->iframe_name |
|
215 | + ), |
|
216 | + sprintf( |
|
217 | + esc_html__( |
|
218 | + 'click here to generate code for embedding %1$s iframe into another site.', |
|
219 | + 'event_espresso' |
|
220 | + ), |
|
221 | + EEH_Inflector::add_indefinite_article($this->iframe_name) |
|
222 | + ), |
|
223 | + $route_name . '-iframe-embed-trigger-js', |
|
224 | + 'iframe-embed-trigger-js button button--small button--secondary ' . esc_attr($button_class), |
|
225 | + '', |
|
226 | + ' data-iframe_embed_button="#' . $route_name . '-iframe-js" tabindex="-1"' |
|
227 | + ), |
|
228 | + '', |
|
229 | + 'ee-admin-button-row ee-admin-button-row--align-start' |
|
230 | + ) |
|
231 | + . EEH_HTML::div( |
|
232 | + EEH_HTML::div( |
|
233 | + esc_html('<iframe src="' . $iframe_url . '" allow="' . home_url() . '" width="100%" height="100%"></iframe>'), |
|
234 | + '', |
|
235 | + '', |
|
236 | + 'width:100%; height: 500px;' |
|
237 | + ), |
|
238 | + $route_name . '-iframe-js', |
|
239 | + 'iframe-embed-wrapper-js', |
|
240 | + 'display:none;' |
|
241 | + ); |
|
242 | + } |
|
243 | 243 | |
244 | 244 | |
245 | - /** |
|
246 | - * enqueue iframe button js |
|
247 | - */ |
|
248 | - public function embedButtonAssets() |
|
249 | - { |
|
250 | - EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__( |
|
251 | - 'copy and paste the following into any other site\'s content to display this event:', |
|
252 | - 'event_espresso' |
|
253 | - ); |
|
254 | - EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__( |
|
255 | - 'click anywhere outside of this window to close it.', |
|
256 | - 'event_espresso' |
|
257 | - ); |
|
258 | - wp_register_script( |
|
259 | - 'iframe_embed_button', |
|
260 | - plugin_dir_url(__FILE__) . 'iframe-embed-button.js', |
|
261 | - array('ee-dialog'), |
|
262 | - EVENT_ESPRESSO_VERSION, |
|
263 | - true |
|
264 | - ); |
|
265 | - wp_enqueue_script('iframe_embed_button'); |
|
266 | - } |
|
245 | + /** |
|
246 | + * enqueue iframe button js |
|
247 | + */ |
|
248 | + public function embedButtonAssets() |
|
249 | + { |
|
250 | + EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__( |
|
251 | + 'copy and paste the following into any other site\'s content to display this event:', |
|
252 | + 'event_espresso' |
|
253 | + ); |
|
254 | + EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__( |
|
255 | + 'click anywhere outside of this window to close it.', |
|
256 | + 'event_espresso' |
|
257 | + ); |
|
258 | + wp_register_script( |
|
259 | + 'iframe_embed_button', |
|
260 | + plugin_dir_url(__FILE__) . 'iframe-embed-button.js', |
|
261 | + array('ee-dialog'), |
|
262 | + EVENT_ESPRESSO_VERSION, |
|
263 | + true |
|
264 | + ); |
|
265 | + wp_enqueue_script('iframe_embed_button'); |
|
266 | + } |
|
267 | 267 | |
268 | 268 | |
269 | - /** |
|
270 | - * generates embed button sections for admin pages |
|
271 | - * |
|
272 | - * @param array $embed_buttons |
|
273 | - * @return string |
|
274 | - */ |
|
275 | - public function addIframeEmbedButtonsSection(array $embed_buttons) |
|
276 | - { |
|
277 | - $embed_buttons = (array) apply_filters( |
|
278 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
279 | - $embed_buttons |
|
280 | - ); |
|
281 | - if (empty($embed_buttons)) { |
|
282 | - return ''; |
|
283 | - } |
|
284 | - // add button for iframe code to event editor. |
|
285 | - $html = EEH_HTML::div('', '', 'ee-admin-section ee-iframe-embed-buttons'); |
|
286 | - $html .= EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso')); |
|
287 | - $html .= EEH_HTML::p( |
|
288 | - esc_html__( |
|
289 | - 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
290 | - 'event_espresso' |
|
291 | - ) |
|
292 | - ); |
|
293 | - $html .= ' ' . implode(' ', $embed_buttons) . ' '; |
|
294 | - $html .= EEH_HTML::divx(); |
|
295 | - return $html; |
|
296 | - } |
|
269 | + /** |
|
270 | + * generates embed button sections for admin pages |
|
271 | + * |
|
272 | + * @param array $embed_buttons |
|
273 | + * @return string |
|
274 | + */ |
|
275 | + public function addIframeEmbedButtonsSection(array $embed_buttons) |
|
276 | + { |
|
277 | + $embed_buttons = (array) apply_filters( |
|
278 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
279 | + $embed_buttons |
|
280 | + ); |
|
281 | + if (empty($embed_buttons)) { |
|
282 | + return ''; |
|
283 | + } |
|
284 | + // add button for iframe code to event editor. |
|
285 | + $html = EEH_HTML::div('', '', 'ee-admin-section ee-iframe-embed-buttons'); |
|
286 | + $html .= EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso')); |
|
287 | + $html .= EEH_HTML::p( |
|
288 | + esc_html__( |
|
289 | + 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
290 | + 'event_espresso' |
|
291 | + ) |
|
292 | + ); |
|
293 | + $html .= ' ' . implode(' ', $embed_buttons) . ' '; |
|
294 | + $html .= EEH_HTML::divx(); |
|
295 | + return $html; |
|
296 | + } |
|
297 | 297 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $id |
107 | 107 | ) { |
108 | 108 | // make sure this is ONLY when editing and the event id has been set. |
109 | - if (! empty($id)) { |
|
109 | + if ( ! empty($id)) { |
|
110 | 110 | $post = get_post($id); |
111 | 111 | // if NOT event then let's get out. |
112 | 112 | if ($post->post_type !== EspressoPostType::EVENTS) { |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | : array($this->route_name => $embedButtonHtml) + $filterable_content; |
177 | 177 | } else { |
178 | 178 | $filterable_content = $this->append_filterable_content |
179 | - ? $filterable_content . $embedButtonHtml |
|
180 | - : $embedButtonHtml . $filterable_content; |
|
179 | + ? $filterable_content.$embedButtonHtml |
|
180 | + : $embedButtonHtml.$filterable_content; |
|
181 | 181 | } |
182 | 182 | return $filterable_content; |
183 | 183 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | ); |
201 | 201 | // add this route to our localized vars |
202 | 202 | $iframe_module_routes = EE_Registry::$i18n_js_strings['iframe_module_routes'] ?? []; |
203 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
203 | + $iframe_module_routes[$this->route_name] = $this->route_name; |
|
204 | 204 | EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes; |
205 | 205 | $route_name = esc_attr($this->route_name); |
206 | 206 | $iframe_url = esc_url_raw(add_query_arg($query_args, site_url())); |
@@ -220,22 +220,22 @@ discard block |
||
220 | 220 | ), |
221 | 221 | EEH_Inflector::add_indefinite_article($this->iframe_name) |
222 | 222 | ), |
223 | - $route_name . '-iframe-embed-trigger-js', |
|
224 | - 'iframe-embed-trigger-js button button--small button--secondary ' . esc_attr($button_class), |
|
223 | + $route_name.'-iframe-embed-trigger-js', |
|
224 | + 'iframe-embed-trigger-js button button--small button--secondary '.esc_attr($button_class), |
|
225 | 225 | '', |
226 | - ' data-iframe_embed_button="#' . $route_name . '-iframe-js" tabindex="-1"' |
|
226 | + ' data-iframe_embed_button="#'.$route_name.'-iframe-js" tabindex="-1"' |
|
227 | 227 | ), |
228 | 228 | '', |
229 | 229 | 'ee-admin-button-row ee-admin-button-row--align-start' |
230 | 230 | ) |
231 | 231 | . EEH_HTML::div( |
232 | 232 | EEH_HTML::div( |
233 | - esc_html('<iframe src="' . $iframe_url . '" allow="' . home_url() . '" width="100%" height="100%"></iframe>'), |
|
233 | + esc_html('<iframe src="'.$iframe_url.'" allow="'.home_url().'" width="100%" height="100%"></iframe>'), |
|
234 | 234 | '', |
235 | 235 | '', |
236 | 236 | 'width:100%; height: 500px;' |
237 | 237 | ), |
238 | - $route_name . '-iframe-js', |
|
238 | + $route_name.'-iframe-js', |
|
239 | 239 | 'iframe-embed-wrapper-js', |
240 | 240 | 'display:none;' |
241 | 241 | ); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | ); |
258 | 258 | wp_register_script( |
259 | 259 | 'iframe_embed_button', |
260 | - plugin_dir_url(__FILE__) . 'iframe-embed-button.js', |
|
260 | + plugin_dir_url(__FILE__).'iframe-embed-button.js', |
|
261 | 261 | array('ee-dialog'), |
262 | 262 | EVENT_ESPRESSO_VERSION, |
263 | 263 | true |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | 'event_espresso' |
291 | 291 | ) |
292 | 292 | ); |
293 | - $html .= ' ' . implode(' ', $embed_buttons) . ' '; |
|
293 | + $html .= ' '.implode(' ', $embed_buttons).' '; |
|
294 | 294 | $html .= EEH_HTML::divx(); |
295 | 295 | return $html; |
296 | 296 | } |
@@ -31,11 +31,14 @@ |
||
31 | 31 | <meta name="robots" content="noindex,nofollow"> |
32 | 32 | <?php if ($enqueue_wp_assets) : ?> |
33 | 33 | <?php wp_head(); ?> |
34 | - <?php else : ?> |
|
34 | + <?php else { |
|
35 | + : ?> |
|
35 | 36 | <?php foreach ($css as $handle => $url) : ?> |
36 | 37 | <?php if (isset($inline_styles["{$handle}_before"])) :?> |
37 | 38 | <style> |
38 | - <?php echo wp_kses($inline_styles["{$handle}_before"], AllowedTags::getWithFullTags()); ?> |
|
39 | + <?php echo wp_kses($inline_styles["{$handle}_before"], AllowedTags::getWithFullTags()); |
|
40 | +} |
|
41 | +?> |
|
39 | 42 | </style> |
40 | 43 | <?php endif; ?> |
41 | 44 | <link rel="stylesheet" type="text/css" id="<?php esc_attr_e($handle); ?>-css" href="<?php echo esc_url_raw($url); ?>"> |