@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | |
64 | 64 | } else { |
65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | - /** |
|
68 | - * espresso_minimum_php_version_error |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | + /** |
|
68 | + * espresso_minimum_php_version_error |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.62.rc.017'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.62.rc.017'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
@@ -16,55 +16,55 @@ |
||
16 | 16 | interface DomainInterface extends InterminableInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @return string |
|
21 | - * @throws DomainException |
|
22 | - */ |
|
23 | - public function pluginFile(); |
|
19 | + /** |
|
20 | + * @return string |
|
21 | + * @throws DomainException |
|
22 | + */ |
|
23 | + public function pluginFile(); |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @return string |
|
28 | - * @throws DomainException |
|
29 | - */ |
|
30 | - public function pluginBasename(); |
|
26 | + /** |
|
27 | + * @return string |
|
28 | + * @throws DomainException |
|
29 | + */ |
|
30 | + public function pluginBasename(); |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public function pluginPath(); |
|
33 | + /** |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public function pluginPath(); |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return string |
|
41 | - * @throws DomainException |
|
42 | - */ |
|
43 | - public function pluginUrl(); |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + * @throws DomainException |
|
42 | + */ |
|
43 | + public function pluginUrl(); |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @return string |
|
48 | - * @throws DomainException |
|
49 | - */ |
|
50 | - public function version(); |
|
46 | + /** |
|
47 | + * @return string |
|
48 | + * @throws DomainException |
|
49 | + */ |
|
50 | + public function version(); |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function distributionAssetsPath(); |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function distributionAssetsPath(); |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function distributionAssetsUrl(); |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function distributionAssetsUrl(); |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function assetNamespace(); |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function assetNamespace(); |
|
69 | 69 | |
70 | 70 | } |
@@ -20,157 +20,157 @@ |
||
20 | 20 | abstract class DomainBase implements DomainInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Equivalent to `__FILE__` for main plugin file. |
|
25 | - * |
|
26 | - * @var FilePath |
|
27 | - */ |
|
28 | - private $plugin_file; |
|
29 | - |
|
30 | - /** |
|
31 | - * String indicating version for plugin |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - private $version; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string $plugin_basename |
|
39 | - */ |
|
40 | - private $plugin_basename; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string $plugin_path |
|
44 | - */ |
|
45 | - private $plugin_path; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var string $plugin_url |
|
49 | - */ |
|
50 | - private $plugin_url; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var string $asset_namespace |
|
54 | - */ |
|
55 | - private $asset_namespace; |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Initializes internal properties. |
|
61 | - * |
|
62 | - * @param FilePath $plugin_file |
|
63 | - * @param Version $version |
|
64 | - */ |
|
65 | - public function __construct(FilePath $plugin_file, Version $version) |
|
66 | - { |
|
67 | - $this->plugin_file = $plugin_file; |
|
68 | - $this->version = $version; |
|
69 | - $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
70 | - $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
71 | - $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
72 | - $this->setAssetNamespace(); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public function pluginFile() |
|
80 | - { |
|
81 | - return (string) $this->plugin_file; |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function pluginBasename() |
|
90 | - { |
|
91 | - return $this->plugin_basename; |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @return string |
|
98 | - */ |
|
99 | - public function pluginPath() |
|
100 | - { |
|
101 | - return $this->plugin_path; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - public function pluginUrl() |
|
110 | - { |
|
111 | - return $this->plugin_url; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @return string |
|
118 | - */ |
|
119 | - public function version() |
|
120 | - { |
|
121 | - return (string) $this->version; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @return Version |
|
128 | - */ |
|
129 | - public function versionValueObject() |
|
130 | - { |
|
131 | - return $this->version; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @return string |
|
137 | - */ |
|
138 | - public function distributionAssetsPath() |
|
139 | - { |
|
140 | - return $this->pluginPath() . 'assets/dist/'; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public function distributionAssetsUrl() |
|
148 | - { |
|
149 | - return $this->pluginUrl() . 'assets/dist/'; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @return string |
|
155 | - */ |
|
156 | - public function assetNamespace() |
|
157 | - { |
|
158 | - return $this->asset_namespace; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @return void |
|
164 | - */ |
|
165 | - private function setAssetNamespace() |
|
166 | - { |
|
167 | - $asset_namespace = explode('/', $this->plugin_basename); |
|
168 | - $asset_namespace = reset($asset_namespace); |
|
169 | - $asset_namespace = $asset_namespace === 'event-espresso-core' |
|
170 | - ? Registry::ASSET_NAMESPACE_CORE |
|
171 | - : $asset_namespace; |
|
172 | - $this->asset_namespace = $asset_namespace; |
|
173 | - } |
|
23 | + /** |
|
24 | + * Equivalent to `__FILE__` for main plugin file. |
|
25 | + * |
|
26 | + * @var FilePath |
|
27 | + */ |
|
28 | + private $plugin_file; |
|
29 | + |
|
30 | + /** |
|
31 | + * String indicating version for plugin |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + private $version; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string $plugin_basename |
|
39 | + */ |
|
40 | + private $plugin_basename; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string $plugin_path |
|
44 | + */ |
|
45 | + private $plugin_path; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var string $plugin_url |
|
49 | + */ |
|
50 | + private $plugin_url; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var string $asset_namespace |
|
54 | + */ |
|
55 | + private $asset_namespace; |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Initializes internal properties. |
|
61 | + * |
|
62 | + * @param FilePath $plugin_file |
|
63 | + * @param Version $version |
|
64 | + */ |
|
65 | + public function __construct(FilePath $plugin_file, Version $version) |
|
66 | + { |
|
67 | + $this->plugin_file = $plugin_file; |
|
68 | + $this->version = $version; |
|
69 | + $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
70 | + $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
71 | + $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
72 | + $this->setAssetNamespace(); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public function pluginFile() |
|
80 | + { |
|
81 | + return (string) $this->plugin_file; |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function pluginBasename() |
|
90 | + { |
|
91 | + return $this->plugin_basename; |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @return string |
|
98 | + */ |
|
99 | + public function pluginPath() |
|
100 | + { |
|
101 | + return $this->plugin_path; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + public function pluginUrl() |
|
110 | + { |
|
111 | + return $this->plugin_url; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @return string |
|
118 | + */ |
|
119 | + public function version() |
|
120 | + { |
|
121 | + return (string) $this->version; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @return Version |
|
128 | + */ |
|
129 | + public function versionValueObject() |
|
130 | + { |
|
131 | + return $this->version; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @return string |
|
137 | + */ |
|
138 | + public function distributionAssetsPath() |
|
139 | + { |
|
140 | + return $this->pluginPath() . 'assets/dist/'; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public function distributionAssetsUrl() |
|
148 | + { |
|
149 | + return $this->pluginUrl() . 'assets/dist/'; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @return string |
|
155 | + */ |
|
156 | + public function assetNamespace() |
|
157 | + { |
|
158 | + return $this->asset_namespace; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @return void |
|
164 | + */ |
|
165 | + private function setAssetNamespace() |
|
166 | + { |
|
167 | + $asset_namespace = explode('/', $this->plugin_basename); |
|
168 | + $asset_namespace = reset($asset_namespace); |
|
169 | + $asset_namespace = $asset_namespace === 'event-espresso-core' |
|
170 | + ? Registry::ASSET_NAMESPACE_CORE |
|
171 | + : $asset_namespace; |
|
172 | + $this->asset_namespace = $asset_namespace; |
|
173 | + } |
|
174 | 174 | |
175 | 175 | |
176 | 176 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public function distributionAssetsPath() |
139 | 139 | { |
140 | - return $this->pluginPath() . 'assets/dist/'; |
|
140 | + return $this->pluginPath().'assets/dist/'; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function distributionAssetsUrl() |
148 | 148 | { |
149 | - return $this->pluginUrl() . 'assets/dist/'; |
|
149 | + return $this->pluginUrl().'assets/dist/'; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | private function setAssetNamespace() |
166 | 166 | { |
167 | - $asset_namespace = explode('/', $this->plugin_basename); |
|
167 | + $asset_namespace = explode('/', $this->plugin_basename); |
|
168 | 168 | $asset_namespace = reset($asset_namespace); |
169 | 169 | $asset_namespace = $asset_namespace === 'event-espresso-core' |
170 | 170 | ? Registry::ASSET_NAMESPACE_CORE |
@@ -26,68 +26,68 @@ |
||
26 | 26 | interface BlockInterface |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * Perform any early setup required by the block |
|
31 | - * including setting the block type and supported post types |
|
32 | - * |
|
33 | - * @return void |
|
34 | - */ |
|
35 | - public function initialize(); |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function blockType(); |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * AssetRegister that this editor block uses for asset registration |
|
46 | - * |
|
47 | - * @return AssetRegisterInterface |
|
48 | - */ |
|
49 | - public function assetRegister(); |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Registers the Editor Block with WP core; |
|
54 | - * Returns the registered block type on success, or false on failure. |
|
55 | - * |
|
56 | - * @return WP_Block_Type|false |
|
57 | - */ |
|
58 | - public function registerBlock(); |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * Un-registers the Editor Block with WP core; |
|
63 | - * Returns the registered block type on success, or false on failure. |
|
64 | - * |
|
65 | - * @return WP_Block_Type|false |
|
66 | - */ |
|
67 | - public function unRegisterBlock(); |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * returns true if the block type applies for the supplied post type |
|
72 | - * and should be added to that post type's editor |
|
73 | - * |
|
74 | - * @param string $post_type |
|
75 | - * @return boolean |
|
76 | - */ |
|
77 | - public function appliesToPostType($post_type); |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @return array |
|
82 | - */ |
|
83 | - public function getEditorContainer(); |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * returns the rendered HTML for the block |
|
88 | - * |
|
89 | - * @param array $attributes |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public function renderBlock(array $attributes = array()); |
|
29 | + /** |
|
30 | + * Perform any early setup required by the block |
|
31 | + * including setting the block type and supported post types |
|
32 | + * |
|
33 | + * @return void |
|
34 | + */ |
|
35 | + public function initialize(); |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function blockType(); |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * AssetRegister that this editor block uses for asset registration |
|
46 | + * |
|
47 | + * @return AssetRegisterInterface |
|
48 | + */ |
|
49 | + public function assetRegister(); |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Registers the Editor Block with WP core; |
|
54 | + * Returns the registered block type on success, or false on failure. |
|
55 | + * |
|
56 | + * @return WP_Block_Type|false |
|
57 | + */ |
|
58 | + public function registerBlock(); |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * Un-registers the Editor Block with WP core; |
|
63 | + * Returns the registered block type on success, or false on failure. |
|
64 | + * |
|
65 | + * @return WP_Block_Type|false |
|
66 | + */ |
|
67 | + public function unRegisterBlock(); |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * returns true if the block type applies for the supplied post type |
|
72 | + * and should be added to that post type's editor |
|
73 | + * |
|
74 | + * @param string $post_type |
|
75 | + * @return boolean |
|
76 | + */ |
|
77 | + public function appliesToPostType($post_type); |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @return array |
|
82 | + */ |
|
83 | + public function getEditorContainer(); |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * returns the rendered HTML for the block |
|
88 | + * |
|
89 | + * @param array $attributes |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public function renderBlock(array $attributes = array()); |
|
93 | 93 | } |
@@ -20,20 +20,20 @@ |
||
20 | 20 | */ |
21 | 21 | class CoreBlocksAssetRegister extends BlockAssetRegister |
22 | 22 | { |
23 | - /** |
|
24 | - * CoreBlocksAssetRegister constructor. |
|
25 | - * |
|
26 | - * @param DomainInterface $domain |
|
27 | - * @param Registry $registry |
|
28 | - */ |
|
29 | - public function __construct(DomainInterface $domain, Registry $registry) { |
|
30 | - parent::__construct( |
|
31 | - 'core-blocks', |
|
32 | - array(), |
|
33 | - 'core-blocks', |
|
34 | - array(), |
|
35 | - $domain, |
|
36 | - $registry |
|
37 | - ); |
|
38 | - } |
|
23 | + /** |
|
24 | + * CoreBlocksAssetRegister constructor. |
|
25 | + * |
|
26 | + * @param DomainInterface $domain |
|
27 | + * @param Registry $registry |
|
28 | + */ |
|
29 | + public function __construct(DomainInterface $domain, Registry $registry) { |
|
30 | + parent::__construct( |
|
31 | + 'core-blocks', |
|
32 | + array(), |
|
33 | + 'core-blocks', |
|
34 | + array(), |
|
35 | + $domain, |
|
36 | + $registry |
|
37 | + ); |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | \ No newline at end of file |
@@ -25,29 +25,29 @@ |
||
25 | 25 | class EventAttendees extends Block |
26 | 26 | { |
27 | 27 | |
28 | - const BLOCK_TYPE = 'widgets-event-attendees'; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * EventAttendees constructor. |
|
33 | - * |
|
34 | - * @param CoreBlocksAssetRegister $asset_register |
|
35 | - */ |
|
36 | - public function __construct(CoreBlocksAssetRegister $asset_register) { |
|
37 | - parent::__construct($asset_register); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Perform any early setup required by the block |
|
43 | - * including setting the block type and supported post types |
|
44 | - * |
|
45 | - * @return void |
|
46 | - */ |
|
47 | - public function initialize() |
|
48 | - { |
|
49 | - $this->setBlockType(EventAttendees::BLOCK_TYPE); |
|
50 | - $this->setSupportedPostTypes(array('espresso_events', 'post', 'page')); |
|
51 | - $this->setAttributes(array()); |
|
52 | - } |
|
28 | + const BLOCK_TYPE = 'widgets-event-attendees'; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * EventAttendees constructor. |
|
33 | + * |
|
34 | + * @param CoreBlocksAssetRegister $asset_register |
|
35 | + */ |
|
36 | + public function __construct(CoreBlocksAssetRegister $asset_register) { |
|
37 | + parent::__construct($asset_register); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Perform any early setup required by the block |
|
43 | + * including setting the block type and supported post types |
|
44 | + * |
|
45 | + * @return void |
|
46 | + */ |
|
47 | + public function initialize() |
|
48 | + { |
|
49 | + $this->setBlockType(EventAttendees::BLOCK_TYPE); |
|
50 | + $this->setSupportedPostTypes(array('espresso_events', 'post', 'page')); |
|
51 | + $this->setAttributes(array()); |
|
52 | + } |
|
53 | 53 | } |
@@ -20,55 +20,55 @@ |
||
20 | 20 | class BlockCollection extends Collection |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Collection constructor |
|
25 | - * |
|
26 | - * @throws InvalidInterfaceException |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - parent::__construct('EventEspresso\core\domain\entities\editor\BlockInterface'); |
|
31 | - } |
|
23 | + /** |
|
24 | + * Collection constructor |
|
25 | + * |
|
26 | + * @throws InvalidInterfaceException |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + parent::__construct('EventEspresso\core\domain\entities\editor\BlockInterface'); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * unRegisterBlock |
|
36 | - * finds block in the Collection based on the identifier that was set using addObject() |
|
37 | - * and calls unRegisterBlock() on it. Returns block if successful and false if block was not found. |
|
38 | - * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
39 | - * |
|
40 | - * @param mixed $identifier |
|
41 | - * @return boolean |
|
42 | - */ |
|
43 | - public function unRegisterBlock($identifier) |
|
44 | - { |
|
45 | - $this->rewind(); |
|
46 | - while ($this->valid()) { |
|
47 | - if ($identifier === $this->getInfo()) { |
|
48 | - $object = $this->current(); |
|
49 | - $this->rewind(); |
|
50 | - return $object->unRegisterBlock(); |
|
51 | - } |
|
52 | - $this->next(); |
|
53 | - } |
|
54 | - return false; |
|
55 | - } |
|
34 | + /** |
|
35 | + * unRegisterBlock |
|
36 | + * finds block in the Collection based on the identifier that was set using addObject() |
|
37 | + * and calls unRegisterBlock() on it. Returns block if successful and false if block was not found. |
|
38 | + * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
39 | + * |
|
40 | + * @param mixed $identifier |
|
41 | + * @return boolean |
|
42 | + */ |
|
43 | + public function unRegisterBlock($identifier) |
|
44 | + { |
|
45 | + $this->rewind(); |
|
46 | + while ($this->valid()) { |
|
47 | + if ($identifier === $this->getInfo()) { |
|
48 | + $object = $this->current(); |
|
49 | + $this->rewind(); |
|
50 | + return $object->unRegisterBlock(); |
|
51 | + } |
|
52 | + $this->next(); |
|
53 | + } |
|
54 | + return false; |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * unRegisterAllBlocks |
|
60 | - * calls unRegisterBlock() on all blocks in Collection. |
|
61 | - * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
62 | - * |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - public function unRegisterAllBlocks() |
|
66 | - { |
|
67 | - $this->rewind(); |
|
68 | - while ($this->valid()) { |
|
69 | - $this->current()->unRegisterBlock(); |
|
70 | - $this->next(); |
|
71 | - } |
|
72 | - $this->rewind(); |
|
73 | - } |
|
58 | + /** |
|
59 | + * unRegisterAllBlocks |
|
60 | + * calls unRegisterBlock() on all blocks in Collection. |
|
61 | + * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
62 | + * |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + public function unRegisterAllBlocks() |
|
66 | + { |
|
67 | + $this->rewind(); |
|
68 | + while ($this->valid()) { |
|
69 | + $this->current()->unRegisterBlock(); |
|
70 | + $this->next(); |
|
71 | + } |
|
72 | + $this->rewind(); |
|
73 | + } |
|
74 | 74 | } |
@@ -27,221 +27,221 @@ |
||
27 | 27 | abstract class Block implements BlockInterface |
28 | 28 | { |
29 | 29 | |
30 | - const NS = 'event-espresso/'; |
|
31 | - |
|
32 | - /** |
|
33 | - * AssetRegister that this editor block uses for asset registration |
|
34 | - * |
|
35 | - * @var AssetRegisterInterface $asset_register_fqcn |
|
36 | - */ |
|
37 | - protected $asset_register; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string $editor_block_type |
|
41 | - */ |
|
42 | - private $editor_block_type; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var WP_Block_Type $wp_block_type |
|
46 | - */ |
|
47 | - private $wp_block_type; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var array $supported_post_types |
|
51 | - */ |
|
52 | - private $supported_post_types; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var array $attributes |
|
56 | - */ |
|
57 | - private $attributes; |
|
58 | - |
|
59 | - /** |
|
60 | - * If set to true, then the block will render its content client side |
|
61 | - * If false, then the block will render its content server side using the renderBlock() method |
|
62 | - * |
|
63 | - * @var bool $dynamic |
|
64 | - */ |
|
65 | - private $dynamic = false; |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * BlockLoader constructor. |
|
70 | - * |
|
71 | - * @param AssetRegisterInterface $asset_register |
|
72 | - */ |
|
73 | - public function __construct(AssetRegisterInterface $asset_register) { |
|
74 | - $this->asset_register = $asset_register; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function blockType() |
|
82 | - { |
|
83 | - return $this->editor_block_type; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function namespacedBlockType() |
|
91 | - { |
|
92 | - return Block::NS . $this->editor_block_type; |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @param string $editor_block_type |
|
98 | - */ |
|
99 | - protected function setBlockType($editor_block_type) |
|
100 | - { |
|
101 | - $this->editor_block_type = $editor_block_type; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * AssetRegister that this editor block uses for asset registration |
|
107 | - * |
|
108 | - * @return AssetRegisterInterface |
|
109 | - */ |
|
110 | - public function assetRegister() |
|
111 | - { |
|
112 | - return $this->asset_register; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @param WP_Block_Type $wp_block_type |
|
119 | - */ |
|
120 | - protected function setWpBlockType($wp_block_type) |
|
121 | - { |
|
122 | - $this->wp_block_type = $wp_block_type; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @param array $supported_post_types |
|
128 | - */ |
|
129 | - protected function setSupportedPostTypes(array $supported_post_types) |
|
130 | - { |
|
131 | - $this->supported_post_types = $supported_post_types; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @return array |
|
137 | - */ |
|
138 | - public function attributes() |
|
139 | - { |
|
140 | - return $this->attributes; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @param array $attributes |
|
146 | - */ |
|
147 | - public function setAttributes(array $attributes) |
|
148 | - { |
|
149 | - $this->attributes = $attributes; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @return bool |
|
155 | - */ |
|
156 | - public function isDynamic() |
|
157 | - { |
|
158 | - return $this->dynamic; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @param bool $dynamic |
|
164 | - */ |
|
165 | - public function setDynamic($dynamic = true) |
|
166 | - { |
|
167 | - $this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * Registers the Editor Block with WP core; |
|
173 | - * Returns the registered block type on success, or false on failure. |
|
174 | - * |
|
175 | - * @return WP_Block_Type|false |
|
176 | - */ |
|
177 | - public function registerBlock() |
|
178 | - { |
|
179 | - $context ='core'; |
|
180 | - // todo add route detection (ie inject route) and change context based on route |
|
181 | - $args = array( |
|
182 | - 'attributes' => $this->attributes(), |
|
183 | - 'editor_script' => "{$context}-blocks", |
|
184 | - 'editor_style' => "{$context}-blocks", |
|
185 | - 'script' => "{$context}-blocks", |
|
186 | - 'style' => "{$context}-blocks", |
|
187 | - ); |
|
188 | - if(! $this->isDynamic()) { |
|
189 | - $args['render_callback'] = $this->renderBlock(); |
|
190 | - } |
|
191 | - $wp_block_type = register_block_type( |
|
192 | - new WP_Block_Type( |
|
193 | - $this->namespacedBlockType(), |
|
194 | - $args |
|
195 | - ) |
|
196 | - ); |
|
197 | - $this->setWpBlockType($wp_block_type); |
|
198 | - return $wp_block_type; |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * @return WP_Block_Type|false The registered block type on success, or false on failure. |
|
204 | - */ |
|
205 | - public function unRegisterBlock() |
|
206 | - { |
|
207 | - return unregister_block_type($this->namespacedBlockType()); |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * returns true if the block type applies for the supplied post type |
|
213 | - * and should be added to that post type's editor |
|
214 | - * |
|
215 | - * @param string $post_type |
|
216 | - * @return boolean |
|
217 | - */ |
|
218 | - public function appliesToPostType($post_type) |
|
219 | - { |
|
220 | - return in_array($post_type, $this->supported_post_types, true); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * @return array |
|
226 | - */ |
|
227 | - public function getEditorContainer() |
|
228 | - { |
|
229 | - return array( |
|
230 | - $this->namespacedBlockType(), |
|
231 | - array() |
|
232 | - ); |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * returns the rendered HTML for the block |
|
239 | - * |
|
240 | - * @param array $attributes |
|
241 | - * @return string |
|
242 | - */ |
|
243 | - public function renderBlock(array $attributes = array()) |
|
244 | - { |
|
245 | - return ''; |
|
246 | - } |
|
30 | + const NS = 'event-espresso/'; |
|
31 | + |
|
32 | + /** |
|
33 | + * AssetRegister that this editor block uses for asset registration |
|
34 | + * |
|
35 | + * @var AssetRegisterInterface $asset_register_fqcn |
|
36 | + */ |
|
37 | + protected $asset_register; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string $editor_block_type |
|
41 | + */ |
|
42 | + private $editor_block_type; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var WP_Block_Type $wp_block_type |
|
46 | + */ |
|
47 | + private $wp_block_type; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var array $supported_post_types |
|
51 | + */ |
|
52 | + private $supported_post_types; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var array $attributes |
|
56 | + */ |
|
57 | + private $attributes; |
|
58 | + |
|
59 | + /** |
|
60 | + * If set to true, then the block will render its content client side |
|
61 | + * If false, then the block will render its content server side using the renderBlock() method |
|
62 | + * |
|
63 | + * @var bool $dynamic |
|
64 | + */ |
|
65 | + private $dynamic = false; |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * BlockLoader constructor. |
|
70 | + * |
|
71 | + * @param AssetRegisterInterface $asset_register |
|
72 | + */ |
|
73 | + public function __construct(AssetRegisterInterface $asset_register) { |
|
74 | + $this->asset_register = $asset_register; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function blockType() |
|
82 | + { |
|
83 | + return $this->editor_block_type; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function namespacedBlockType() |
|
91 | + { |
|
92 | + return Block::NS . $this->editor_block_type; |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @param string $editor_block_type |
|
98 | + */ |
|
99 | + protected function setBlockType($editor_block_type) |
|
100 | + { |
|
101 | + $this->editor_block_type = $editor_block_type; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * AssetRegister that this editor block uses for asset registration |
|
107 | + * |
|
108 | + * @return AssetRegisterInterface |
|
109 | + */ |
|
110 | + public function assetRegister() |
|
111 | + { |
|
112 | + return $this->asset_register; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @param WP_Block_Type $wp_block_type |
|
119 | + */ |
|
120 | + protected function setWpBlockType($wp_block_type) |
|
121 | + { |
|
122 | + $this->wp_block_type = $wp_block_type; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @param array $supported_post_types |
|
128 | + */ |
|
129 | + protected function setSupportedPostTypes(array $supported_post_types) |
|
130 | + { |
|
131 | + $this->supported_post_types = $supported_post_types; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @return array |
|
137 | + */ |
|
138 | + public function attributes() |
|
139 | + { |
|
140 | + return $this->attributes; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @param array $attributes |
|
146 | + */ |
|
147 | + public function setAttributes(array $attributes) |
|
148 | + { |
|
149 | + $this->attributes = $attributes; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @return bool |
|
155 | + */ |
|
156 | + public function isDynamic() |
|
157 | + { |
|
158 | + return $this->dynamic; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @param bool $dynamic |
|
164 | + */ |
|
165 | + public function setDynamic($dynamic = true) |
|
166 | + { |
|
167 | + $this->dynamic = filter_var($dynamic, FILTER_VALIDATE_BOOLEAN); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Registers the Editor Block with WP core; |
|
173 | + * Returns the registered block type on success, or false on failure. |
|
174 | + * |
|
175 | + * @return WP_Block_Type|false |
|
176 | + */ |
|
177 | + public function registerBlock() |
|
178 | + { |
|
179 | + $context ='core'; |
|
180 | + // todo add route detection (ie inject route) and change context based on route |
|
181 | + $args = array( |
|
182 | + 'attributes' => $this->attributes(), |
|
183 | + 'editor_script' => "{$context}-blocks", |
|
184 | + 'editor_style' => "{$context}-blocks", |
|
185 | + 'script' => "{$context}-blocks", |
|
186 | + 'style' => "{$context}-blocks", |
|
187 | + ); |
|
188 | + if(! $this->isDynamic()) { |
|
189 | + $args['render_callback'] = $this->renderBlock(); |
|
190 | + } |
|
191 | + $wp_block_type = register_block_type( |
|
192 | + new WP_Block_Type( |
|
193 | + $this->namespacedBlockType(), |
|
194 | + $args |
|
195 | + ) |
|
196 | + ); |
|
197 | + $this->setWpBlockType($wp_block_type); |
|
198 | + return $wp_block_type; |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * @return WP_Block_Type|false The registered block type on success, or false on failure. |
|
204 | + */ |
|
205 | + public function unRegisterBlock() |
|
206 | + { |
|
207 | + return unregister_block_type($this->namespacedBlockType()); |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * returns true if the block type applies for the supplied post type |
|
213 | + * and should be added to that post type's editor |
|
214 | + * |
|
215 | + * @param string $post_type |
|
216 | + * @return boolean |
|
217 | + */ |
|
218 | + public function appliesToPostType($post_type) |
|
219 | + { |
|
220 | + return in_array($post_type, $this->supported_post_types, true); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * @return array |
|
226 | + */ |
|
227 | + public function getEditorContainer() |
|
228 | + { |
|
229 | + return array( |
|
230 | + $this->namespacedBlockType(), |
|
231 | + array() |
|
232 | + ); |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * returns the rendered HTML for the block |
|
239 | + * |
|
240 | + * @param array $attributes |
|
241 | + * @return string |
|
242 | + */ |
|
243 | + public function renderBlock(array $attributes = array()) |
|
244 | + { |
|
245 | + return ''; |
|
246 | + } |
|
247 | 247 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function namespacedBlockType() |
91 | 91 | { |
92 | - return Block::NS . $this->editor_block_type; |
|
92 | + return Block::NS.$this->editor_block_type; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -176,16 +176,16 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function registerBlock() |
178 | 178 | { |
179 | - $context ='core'; |
|
179 | + $context = 'core'; |
|
180 | 180 | // todo add route detection (ie inject route) and change context based on route |
181 | - $args = array( |
|
181 | + $args = array( |
|
182 | 182 | 'attributes' => $this->attributes(), |
183 | 183 | 'editor_script' => "{$context}-blocks", |
184 | 184 | 'editor_style' => "{$context}-blocks", |
185 | 185 | 'script' => "{$context}-blocks", |
186 | 186 | 'style' => "{$context}-blocks", |
187 | 187 | ); |
188 | - if(! $this->isDynamic()) { |
|
188 | + if ( ! $this->isDynamic()) { |
|
189 | 189 | $args['render_callback'] = $this->renderBlock(); |
190 | 190 | } |
191 | 191 | $wp_block_type = register_block_type( |
@@ -22,78 +22,78 @@ |
||
22 | 22 | abstract class BlockManager |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionInterface|BlockInterface[] $blocks |
|
27 | - */ |
|
28 | - protected $blocks; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var RequestInterface $request |
|
32 | - */ |
|
33 | - protected $request; |
|
34 | - |
|
35 | - /** |
|
36 | - * the post type that the current request applies to |
|
37 | - * |
|
38 | - * @var string $request_post_type |
|
39 | - */ |
|
40 | - protected $request_post_type; |
|
41 | - |
|
42 | - /** |
|
43 | - * value of the 'page' $_GET param |
|
44 | - * |
|
45 | - * @var string $page |
|
46 | - */ |
|
47 | - protected $page; |
|
48 | - |
|
49 | - /** |
|
50 | - * value of the 'action' $_GET param |
|
51 | - * |
|
52 | - * @var string $action |
|
53 | - */ |
|
54 | - protected $action; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * BlockManager constructor. |
|
59 | - * |
|
60 | - * @param BlockCollection $blocks |
|
61 | - * @param RequestInterface $request |
|
62 | - */ |
|
63 | - public function __construct( |
|
64 | - BlockCollection $blocks, |
|
65 | - RequestInterface $request |
|
66 | - ) { |
|
67 | - $this->blocks = $blocks; |
|
68 | - $this->request = $request; |
|
69 | - $this->request_post_type = $this->request->getRequestParam('post_type', ''); |
|
70 | - $this->page = $this->request->getRequestParam('page', ''); |
|
71 | - $this->action = $this->request->getRequestParam('action', ''); |
|
72 | - add_action($this->init_hook(), array($this, 'initialize')); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * Returns the name of a hookpoint to be used to call initialize() |
|
78 | - * |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - abstract public function init_hook(); |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * Perform any early setup required for block editors to functions |
|
86 | - * |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - abstract public function initialize(); |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function currentRequestPostType() |
|
96 | - { |
|
97 | - return $this->request_post_type; |
|
98 | - } |
|
25 | + /** |
|
26 | + * @var CollectionInterface|BlockInterface[] $blocks |
|
27 | + */ |
|
28 | + protected $blocks; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var RequestInterface $request |
|
32 | + */ |
|
33 | + protected $request; |
|
34 | + |
|
35 | + /** |
|
36 | + * the post type that the current request applies to |
|
37 | + * |
|
38 | + * @var string $request_post_type |
|
39 | + */ |
|
40 | + protected $request_post_type; |
|
41 | + |
|
42 | + /** |
|
43 | + * value of the 'page' $_GET param |
|
44 | + * |
|
45 | + * @var string $page |
|
46 | + */ |
|
47 | + protected $page; |
|
48 | + |
|
49 | + /** |
|
50 | + * value of the 'action' $_GET param |
|
51 | + * |
|
52 | + * @var string $action |
|
53 | + */ |
|
54 | + protected $action; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * BlockManager constructor. |
|
59 | + * |
|
60 | + * @param BlockCollection $blocks |
|
61 | + * @param RequestInterface $request |
|
62 | + */ |
|
63 | + public function __construct( |
|
64 | + BlockCollection $blocks, |
|
65 | + RequestInterface $request |
|
66 | + ) { |
|
67 | + $this->blocks = $blocks; |
|
68 | + $this->request = $request; |
|
69 | + $this->request_post_type = $this->request->getRequestParam('post_type', ''); |
|
70 | + $this->page = $this->request->getRequestParam('page', ''); |
|
71 | + $this->action = $this->request->getRequestParam('action', ''); |
|
72 | + add_action($this->init_hook(), array($this, 'initialize')); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * Returns the name of a hookpoint to be used to call initialize() |
|
78 | + * |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + abstract public function init_hook(); |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * Perform any early setup required for block editors to functions |
|
86 | + * |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + abstract public function initialize(); |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function currentRequestPostType() |
|
96 | + { |
|
97 | + return $this->request_post_type; |
|
98 | + } |
|
99 | 99 | } |