@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __construct(EEHI_File $file_helper = null) |
39 | 39 | { |
40 | - if (! $file_helper) { |
|
40 | + if ( ! $file_helper) { |
|
41 | 41 | $this->_file_helper = new EEH_File(); |
42 | 42 | } |
43 | 43 | } |
@@ -65,23 +65,23 @@ discard block |
||
65 | 65 | try { |
66 | 66 | $base_folder = $this->get_base_folder(); |
67 | 67 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
68 | - $base_folder . JobHandlerFile::temp_folder_name |
|
68 | + $base_folder.JobHandlerFile::temp_folder_name |
|
69 | 69 | ); |
70 | 70 | if ($success) { |
71 | 71 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
72 | - $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id |
|
72 | + $base_folder.JobHandlerFile::temp_folder_name.'/'.$job_id |
|
73 | 73 | ); |
74 | 74 | } |
75 | 75 | if ($success) { |
76 | - $filepath = $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/' . $filename; |
|
76 | + $filepath = $base_folder.JobHandlerFile::temp_folder_name.'/'.$job_id.'/'.$filename; |
|
77 | 77 | $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
78 | 78 | } |
79 | 79 | // let's add the .htaccess file so safari will open the file properly |
80 | 80 | if ($success) { |
81 | 81 | $extension = EEH_File::get_file_extension($filepath); |
82 | 82 | EEH_File::write_to_file( |
83 | - $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/.htaccess', |
|
84 | - 'AddType ' . $filetype . ' ' . $extension, |
|
83 | + $base_folder.JobHandlerFile::temp_folder_name.'/'.$job_id.'/.htaccess', |
|
84 | + 'AddType '.$filetype.' '.$extension, |
|
85 | 85 | '.htaccess' |
86 | 86 | ); |
87 | 87 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | ) |
106 | 106 | ); |
107 | 107 | // those methods normally fail with an exception, but if not, let's do it |
108 | - if (! $success) { |
|
108 | + if ( ! $success) { |
|
109 | 109 | throw new EE_Error( |
110 | 110 | esc_html__('Could not create temporary file, an unknown error occurred', 'event_espresso') |
111 | 111 | ); |
@@ -19,144 +19,144 @@ |
||
19 | 19 | */ |
20 | 20 | abstract class JobHandlerFile extends JobHandler |
21 | 21 | { |
22 | - // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase |
|
23 | - const temp_folder_name = 'batch_temp_folder'; |
|
24 | - |
|
25 | - // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
26 | - |
|
27 | - /** |
|
28 | - * @var EEHI_File |
|
29 | - */ |
|
30 | - protected $_file_helper = null; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * JobHandlerFile constructor. |
|
35 | - * |
|
36 | - * @param EEHI_File|null $file_helper |
|
37 | - */ |
|
38 | - public function __construct(EEHI_File $file_helper = null) |
|
39 | - { |
|
40 | - if (! $file_helper) { |
|
41 | - $this->_file_helper = new EEH_File(); |
|
42 | - } |
|
43 | - } |
|
44 | - |
|
45 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Creates a file |
|
50 | - * |
|
51 | - * @param string $job_id |
|
52 | - * @param string $filename |
|
53 | - * @param string $filetype |
|
54 | - * @param string $bom initial content to place in the file. |
|
55 | - * @return string |
|
56 | - * @throws BatchRequestException |
|
57 | - */ |
|
58 | - public function create_file_from_job_with_name( |
|
59 | - string $job_id, |
|
60 | - string $filename, |
|
61 | - string $filetype = 'application/ms-excel', |
|
62 | - string $bom = "\xEF\xBB\xBF" |
|
63 | - ): string { |
|
64 | - $filepath = ''; |
|
65 | - try { |
|
66 | - $base_folder = $this->get_base_folder(); |
|
67 | - $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
68 | - $base_folder . JobHandlerFile::temp_folder_name |
|
69 | - ); |
|
70 | - if ($success) { |
|
71 | - $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
72 | - $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id |
|
73 | - ); |
|
74 | - } |
|
75 | - if ($success) { |
|
76 | - $filepath = $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/' . $filename; |
|
77 | - $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
|
78 | - } |
|
79 | - // let's add the .htaccess file so safari will open the file properly |
|
80 | - if ($success) { |
|
81 | - $extension = EEH_File::get_file_extension($filepath); |
|
82 | - EEH_File::write_to_file( |
|
83 | - $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/.htaccess', |
|
84 | - 'AddType ' . $filetype . ' ' . $extension, |
|
85 | - '.htaccess' |
|
86 | - ); |
|
87 | - } |
|
88 | - /** |
|
89 | - * Filters what initial content will be added to the file. |
|
90 | - * |
|
91 | - * @param string $return_value By default, it's whatever was passed into |
|
92 | - * JobHandlerFile::create_file_from_job_with_name() |
|
93 | - * @param string $filename |
|
94 | - * @param string $filetype default 'application/ms-excel' |
|
95 | - * @param string $filepath |
|
96 | - */ |
|
97 | - EEH_File::write_to_file( |
|
98 | - $filepath, |
|
99 | - apply_filters( |
|
100 | - 'FHEE__EE_CSV__begin_sending_csv__start_writing', |
|
101 | - $bom, |
|
102 | - $filename, |
|
103 | - $filetype, |
|
104 | - $filepath |
|
105 | - ) |
|
106 | - ); |
|
107 | - // those methods normally fail with an exception, but if not, let's do it |
|
108 | - if (! $success) { |
|
109 | - throw new EE_Error( |
|
110 | - esc_html__('Could not create temporary file, an unknown error occurred', 'event_espresso') |
|
111 | - ); |
|
112 | - } |
|
113 | - } catch (EE_Error $e) { |
|
114 | - throw new BatchRequestException( |
|
115 | - sprintf( |
|
116 | - // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment |
|
117 | - esc_html__('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), |
|
118 | - $job_id, |
|
119 | - $e->getMessage() |
|
120 | - ), |
|
121 | - 500, |
|
122 | - $e |
|
123 | - ); |
|
124 | - } |
|
125 | - return $filepath; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * Gets the URL to download the file |
|
131 | - * |
|
132 | - * @param string $filepath |
|
133 | - * @return string url to file |
|
134 | - */ |
|
135 | - public function get_url_to_file(string $filepath): string |
|
136 | - { |
|
137 | - return str_replace($this->get_base_folder(), $this->get_base_url(), $filepath); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * Gets the folder which will contain the "batch_temp_folder" |
|
143 | - * |
|
144 | - * @return string |
|
145 | - */ |
|
146 | - public function get_base_folder(): string |
|
147 | - { |
|
148 | - return apply_filters( |
|
149 | - 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_folder', |
|
150 | - EVENT_ESPRESSO_UPLOAD_DIR |
|
151 | - ); |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - public function get_base_url(): string |
|
156 | - { |
|
157 | - return apply_filters( |
|
158 | - 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_url', |
|
159 | - EVENT_ESPRESSO_UPLOAD_URL |
|
160 | - ); |
|
161 | - } |
|
22 | + // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase |
|
23 | + const temp_folder_name = 'batch_temp_folder'; |
|
24 | + |
|
25 | + // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
26 | + |
|
27 | + /** |
|
28 | + * @var EEHI_File |
|
29 | + */ |
|
30 | + protected $_file_helper = null; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * JobHandlerFile constructor. |
|
35 | + * |
|
36 | + * @param EEHI_File|null $file_helper |
|
37 | + */ |
|
38 | + public function __construct(EEHI_File $file_helper = null) |
|
39 | + { |
|
40 | + if (! $file_helper) { |
|
41 | + $this->_file_helper = new EEH_File(); |
|
42 | + } |
|
43 | + } |
|
44 | + |
|
45 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Creates a file |
|
50 | + * |
|
51 | + * @param string $job_id |
|
52 | + * @param string $filename |
|
53 | + * @param string $filetype |
|
54 | + * @param string $bom initial content to place in the file. |
|
55 | + * @return string |
|
56 | + * @throws BatchRequestException |
|
57 | + */ |
|
58 | + public function create_file_from_job_with_name( |
|
59 | + string $job_id, |
|
60 | + string $filename, |
|
61 | + string $filetype = 'application/ms-excel', |
|
62 | + string $bom = "\xEF\xBB\xBF" |
|
63 | + ): string { |
|
64 | + $filepath = ''; |
|
65 | + try { |
|
66 | + $base_folder = $this->get_base_folder(); |
|
67 | + $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
68 | + $base_folder . JobHandlerFile::temp_folder_name |
|
69 | + ); |
|
70 | + if ($success) { |
|
71 | + $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
72 | + $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id |
|
73 | + ); |
|
74 | + } |
|
75 | + if ($success) { |
|
76 | + $filepath = $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/' . $filename; |
|
77 | + $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
|
78 | + } |
|
79 | + // let's add the .htaccess file so safari will open the file properly |
|
80 | + if ($success) { |
|
81 | + $extension = EEH_File::get_file_extension($filepath); |
|
82 | + EEH_File::write_to_file( |
|
83 | + $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/.htaccess', |
|
84 | + 'AddType ' . $filetype . ' ' . $extension, |
|
85 | + '.htaccess' |
|
86 | + ); |
|
87 | + } |
|
88 | + /** |
|
89 | + * Filters what initial content will be added to the file. |
|
90 | + * |
|
91 | + * @param string $return_value By default, it's whatever was passed into |
|
92 | + * JobHandlerFile::create_file_from_job_with_name() |
|
93 | + * @param string $filename |
|
94 | + * @param string $filetype default 'application/ms-excel' |
|
95 | + * @param string $filepath |
|
96 | + */ |
|
97 | + EEH_File::write_to_file( |
|
98 | + $filepath, |
|
99 | + apply_filters( |
|
100 | + 'FHEE__EE_CSV__begin_sending_csv__start_writing', |
|
101 | + $bom, |
|
102 | + $filename, |
|
103 | + $filetype, |
|
104 | + $filepath |
|
105 | + ) |
|
106 | + ); |
|
107 | + // those methods normally fail with an exception, but if not, let's do it |
|
108 | + if (! $success) { |
|
109 | + throw new EE_Error( |
|
110 | + esc_html__('Could not create temporary file, an unknown error occurred', 'event_espresso') |
|
111 | + ); |
|
112 | + } |
|
113 | + } catch (EE_Error $e) { |
|
114 | + throw new BatchRequestException( |
|
115 | + sprintf( |
|
116 | + // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment |
|
117 | + esc_html__('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), |
|
118 | + $job_id, |
|
119 | + $e->getMessage() |
|
120 | + ), |
|
121 | + 500, |
|
122 | + $e |
|
123 | + ); |
|
124 | + } |
|
125 | + return $filepath; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * Gets the URL to download the file |
|
131 | + * |
|
132 | + * @param string $filepath |
|
133 | + * @return string url to file |
|
134 | + */ |
|
135 | + public function get_url_to_file(string $filepath): string |
|
136 | + { |
|
137 | + return str_replace($this->get_base_folder(), $this->get_base_url(), $filepath); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * Gets the folder which will contain the "batch_temp_folder" |
|
143 | + * |
|
144 | + * @return string |
|
145 | + */ |
|
146 | + public function get_base_folder(): string |
|
147 | + { |
|
148 | + return apply_filters( |
|
149 | + 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_folder', |
|
150 | + EVENT_ESPRESSO_UPLOAD_DIR |
|
151 | + ); |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + public function get_base_url(): string |
|
156 | + { |
|
157 | + return apply_filters( |
|
158 | + 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_url', |
|
159 | + EVENT_ESPRESSO_UPLOAD_URL |
|
160 | + ); |
|
161 | + } |
|
162 | 162 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function Request_Handler() |
100 | 100 | { |
101 | - if (! $this->Request_Handler instanceof EE_Request_Handler) { |
|
101 | + if ( ! $this->Request_Handler instanceof EE_Request_Handler) { |
|
102 | 102 | $this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler'); |
103 | 103 | } |
104 | 104 | return $this->Request_Handler; |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | print( |
334 | 334 | apply_filters( |
335 | 335 | 'FHEE__EE_Front_Controller__header_meta_tag', |
336 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
336 | + '<meta name="generator" content="Event Espresso Version '.EVENT_ESPRESSO_VERSION."\" />\n" |
|
337 | 337 | ) |
338 | 338 | ); |
339 | 339 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | print( |
351 | 351 | apply_filters( |
352 | 352 | 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
353 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
353 | + '<meta name="robots" content="noindex,follow" />'."\n" |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | public function prependNotices($the_content) |
435 | 435 | { |
436 | 436 | $notices = $this->printNotices(); |
437 | - return $notices ? $notices . $the_content : $the_content; |
|
437 | + return $notices ? $notices.$the_content : $the_content; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | { |
447 | 447 | ob_start(); |
448 | 448 | echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags()); |
449 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
449 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
450 | 450 | return ob_get_clean(); |
451 | 451 | } |
452 | 452 |
@@ -19,515 +19,515 @@ |
||
19 | 19 | */ |
20 | 20 | final class EE_Front_Controller |
21 | 21 | { |
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - private $_template_path; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - private $_template; |
|
31 | - |
|
32 | - /** |
|
33 | - * @type EE_Registry |
|
34 | - */ |
|
35 | - protected $Registry; |
|
36 | - |
|
37 | - /** |
|
38 | - * @type EE_Request_Handler |
|
39 | - */ |
|
40 | - protected $Request_Handler; |
|
41 | - |
|
42 | - /** |
|
43 | - * @type EE_Module_Request_Router |
|
44 | - */ |
|
45 | - protected $Module_Request_Router; |
|
46 | - |
|
47 | - /** |
|
48 | - * @type CurrentPage |
|
49 | - */ |
|
50 | - protected $current_page; |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * class constructor |
|
55 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
56 | - * |
|
57 | - * @access public |
|
58 | - * @param EE_Registry $Registry |
|
59 | - * @param CurrentPage $EspressoPage |
|
60 | - * @param EE_Module_Request_Router $Module_Request_Router |
|
61 | - */ |
|
62 | - public function __construct( |
|
63 | - EE_Registry $Registry, |
|
64 | - CurrentPage $EspressoPage, |
|
65 | - EE_Module_Request_Router $Module_Request_Router |
|
66 | - ) { |
|
67 | - $this->Registry = $Registry; |
|
68 | - $this->current_page = $EspressoPage; |
|
69 | - $this->Module_Request_Router = $Module_Request_Router; |
|
70 | - // load other resources and begin to actually run shortcodes and modules |
|
71 | - // analyse the incoming WP request |
|
72 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
73 | - // process request with module factory |
|
74 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
75 | - // before headers sent |
|
76 | - add_action('wp', array($this, 'wp'), 5); |
|
77 | - // primarily used to process any content shortcodes |
|
78 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
79 | - // header |
|
80 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
81 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
82 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
83 | - // display errors |
|
84 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
85 | - // the content |
|
86 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
87 | - // exclude our private cpt comments |
|
88 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
89 | - // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
90 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
91 | - // action hook EE |
|
92 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @return EE_Request_Handler |
|
98 | - * @deprecated 4.10.14.p |
|
99 | - */ |
|
100 | - public function Request_Handler() |
|
101 | - { |
|
102 | - if (! $this->Request_Handler instanceof EE_Request_Handler) { |
|
103 | - $this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler'); |
|
104 | - } |
|
105 | - return $this->Request_Handler; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @return EE_Module_Request_Router |
|
111 | - */ |
|
112 | - public function Module_Request_Router() |
|
113 | - { |
|
114 | - return $this->Module_Request_Router; |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return LegacyShortcodesManager |
|
120 | - * @deprecated 4.10.14.p |
|
121 | - */ |
|
122 | - public function getLegacyShortcodesManager() |
|
123 | - { |
|
124 | - return EE_Config::getLegacyShortcodesManager(); |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
132 | - /** |
|
133 | - * filter_wp_comments |
|
134 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
135 | - * widgets/queries done on frontend |
|
136 | - * |
|
137 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
138 | - * @return array array of comment clauses with modifications. |
|
139 | - * @throws InvalidArgumentException |
|
140 | - * @throws InvalidDataTypeException |
|
141 | - * @throws InvalidInterfaceException |
|
142 | - */ |
|
143 | - public function filter_wp_comments($clauses) |
|
144 | - { |
|
145 | - global $wpdb; |
|
146 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
147 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
148 | - $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
149 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
150 | - ); |
|
151 | - $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
152 | - foreach ($cpts as $cpt => $details) { |
|
153 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
154 | - } |
|
155 | - } |
|
156 | - return $clauses; |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
162 | - * |
|
163 | - * @param string $url incoming url |
|
164 | - * @return string final assembled url |
|
165 | - */ |
|
166 | - public function maybe_force_admin_ajax_ssl($url) |
|
167 | - { |
|
168 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
169 | - $url = str_replace('http://', 'https://', $url); |
|
170 | - } |
|
171 | - return $url; |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - |
|
178 | - |
|
179 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
184 | - * default priority init phases have run |
|
185 | - * |
|
186 | - * @access public |
|
187 | - * @return void |
|
188 | - */ |
|
189 | - public function wp_loaded() |
|
190 | - { |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - |
|
196 | - |
|
197 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
198 | - /** |
|
199 | - * _get_request |
|
200 | - * |
|
201 | - * @access public |
|
202 | - * @param WP $WP |
|
203 | - * @return void |
|
204 | - */ |
|
205 | - public function get_request(WP $WP) |
|
206 | - { |
|
207 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
208 | - $this->current_page->parseQueryVars($WP); |
|
209 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
210 | - remove_action('parse_request', [$this, 'get_request'], 1); |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
216 | - * |
|
217 | - * @access public |
|
218 | - * @param WP_Query $WP_Query |
|
219 | - * @return void |
|
220 | - * @throws EE_Error |
|
221 | - * @throws ReflectionException |
|
222 | - */ |
|
223 | - public function pre_get_posts($WP_Query) |
|
224 | - { |
|
225 | - // only load Module_Request_Router if this is the main query |
|
226 | - if ( |
|
227 | - $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
228 | - && $WP_Query->is_main_query() |
|
229 | - ) { |
|
230 | - // cycle thru module routes |
|
231 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
232 | - // determine module and method for route |
|
233 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
234 | - if ($module instanceof EED_Module) { |
|
235 | - // get registered view for route |
|
236 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
237 | - // grab module name |
|
238 | - $module_name = $module->module_name(); |
|
239 | - // map the module to the module objects |
|
240 | - $this->Registry->modules->{$module_name} = $module; |
|
241 | - } |
|
242 | - } |
|
243 | - } |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - |
|
248 | - |
|
249 | - |
|
250 | - /*********************************************** WP HOOK ***********************************************/ |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * wp - basically last chance to do stuff before headers sent |
|
255 | - * |
|
256 | - * @access public |
|
257 | - * @return void |
|
258 | - */ |
|
259 | - public function wp() |
|
260 | - { |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - |
|
265 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
266 | - |
|
267 | - |
|
268 | - /** |
|
269 | - * callback for the "template_redirect" hook point |
|
270 | - * checks sidebars for EE widgets |
|
271 | - * loads resources and assets accordingly |
|
272 | - * |
|
273 | - * @return void |
|
274 | - */ |
|
275 | - public function templateRedirect() |
|
276 | - { |
|
277 | - global $wp_query; |
|
278 | - if (empty($wp_query->posts)) { |
|
279 | - return; |
|
280 | - } |
|
281 | - // if we already know this is an espresso page, then load assets |
|
282 | - $load_assets = $this->current_page->isEspressoPage(); |
|
283 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
284 | - $load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars(); |
|
285 | - if ($load_assets) { |
|
286 | - add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
287 | - add_action('wp_enqueue_scripts', array($this, 'enqueueScripts'), 10); |
|
288 | - } |
|
289 | - |
|
290 | - if (is_singular(EspressoPostType::EVENTS)) { |
|
291 | - new FilterNextPreviousEventPostQuery(); |
|
292 | - } |
|
293 | - } |
|
294 | - |
|
295 | - |
|
296 | - /** |
|
297 | - * builds list of active widgets then scans active sidebars looking for them |
|
298 | - * returns true is an EE widget is found in an active sidebar |
|
299 | - * Please Note: this does NOT mean that the sidebar or widget |
|
300 | - * is actually in use in a given template, as that is unfortunately not known |
|
301 | - * until a sidebar and it's widgets are actually loaded |
|
302 | - * |
|
303 | - * @return boolean |
|
304 | - */ |
|
305 | - private function espresso_widgets_in_active_sidebars() |
|
306 | - { |
|
307 | - $espresso_widgets = array(); |
|
308 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
309 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
310 | - if (is_active_widget(false, false, $id_base)) { |
|
311 | - $espresso_widgets[] = $id_base; |
|
312 | - } |
|
313 | - } |
|
314 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
315 | - foreach ($all_sidebar_widgets as $sidebar_widgets) { |
|
316 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
317 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
318 | - foreach ($espresso_widgets as $espresso_widget) { |
|
319 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
320 | - return true; |
|
321 | - } |
|
322 | - } |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
326 | - return false; |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * header_meta_tag |
|
332 | - * |
|
333 | - * @access public |
|
334 | - * @return void |
|
335 | - */ |
|
336 | - public function header_meta_tag() |
|
337 | - { |
|
338 | - print( |
|
339 | - apply_filters( |
|
340 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
341 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
342 | - ) |
|
343 | - ); |
|
344 | - |
|
345 | - // let's exclude all event type taxonomy term archive pages from search engine indexing |
|
346 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
347 | - // also exclude all critical pages from indexing |
|
348 | - if ( |
|
349 | - ( |
|
350 | - is_tax('espresso_event_type') |
|
351 | - && get_option('blog_public') !== '0' |
|
352 | - ) |
|
353 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
354 | - ) { |
|
355 | - print( |
|
356 | - apply_filters( |
|
357 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
358 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
359 | - ) |
|
360 | - ); |
|
361 | - } |
|
362 | - } |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * wp_print_scripts |
|
367 | - * |
|
368 | - * @return void |
|
369 | - * @throws EE_Error |
|
370 | - */ |
|
371 | - public function wp_print_scripts() |
|
372 | - { |
|
373 | - global $post; |
|
374 | - if ( |
|
375 | - isset($post->EE_Event) |
|
376 | - && $post->EE_Event instanceof EE_Event |
|
377 | - && get_post_type() === EspressoPostType::EVENTS |
|
378 | - && is_singular() |
|
379 | - ) { |
|
380 | - EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
381 | - } |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - public function enqueueStyle() |
|
386 | - { |
|
387 | - wp_enqueue_style('espresso_default'); |
|
388 | - wp_enqueue_style('espresso_custom_css'); |
|
389 | - } |
|
390 | - |
|
391 | - |
|
392 | - |
|
393 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
394 | - |
|
395 | - |
|
396 | - public function enqueueScripts() |
|
397 | - { |
|
398 | - wp_enqueue_script('espresso_core'); |
|
399 | - } |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * display_errors |
|
404 | - * |
|
405 | - * @access public |
|
406 | - * @return void |
|
407 | - * @throws DomainException |
|
408 | - */ |
|
409 | - public function display_errors() |
|
410 | - { |
|
411 | - static $shown_already = false; |
|
412 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
413 | - if ( |
|
414 | - ! $shown_already |
|
415 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
416 | - && is_main_query() |
|
417 | - && ! is_feed() |
|
418 | - && in_the_loop() |
|
419 | - && $this->current_page->isEspressoPage() |
|
420 | - ) { |
|
421 | - $shown_already = true; |
|
422 | - if (did_action('wp_head')) { |
|
423 | - echo wp_kses($this->printNotices(), AllowedTags::getAllowedTags()); |
|
424 | - } else { |
|
425 | - // block enabled themes run their query loop before headers are sent |
|
426 | - // so we need to add our notices onto the beginning of the content |
|
427 | - add_filter('the_content', [$this, 'prependNotices'], 1, 1); |
|
428 | - } |
|
429 | - } |
|
430 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
431 | - } |
|
432 | - |
|
433 | - |
|
434 | - /** |
|
435 | - * @param string $the_content |
|
436 | - * @return string |
|
437 | - * @since 4.10.30.p |
|
438 | - */ |
|
439 | - public function prependNotices($the_content) |
|
440 | - { |
|
441 | - $notices = $this->printNotices(); |
|
442 | - return $notices ? $notices . $the_content : $the_content; |
|
443 | - } |
|
444 | - |
|
445 | - |
|
446 | - /** |
|
447 | - * @return false|string |
|
448 | - * @since 4.10.30.p |
|
449 | - */ |
|
450 | - public function printNotices() |
|
451 | - { |
|
452 | - ob_start(); |
|
453 | - echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags()); |
|
454 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
455 | - return ob_get_clean(); |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - |
|
460 | - /*********************************************** UTILITIES ***********************************************/ |
|
461 | - |
|
462 | - |
|
463 | - /** |
|
464 | - * @param bool|string $template_include_path |
|
465 | - * @return string |
|
466 | - * @throws EE_Error |
|
467 | - * @throws ReflectionException |
|
468 | - */ |
|
469 | - public function template_include($template_include_path = '') |
|
470 | - { |
|
471 | - if ($this->current_page->isEspressoPage()) { |
|
472 | - // despite all helpers having autoloaders set, we need to manually load the template loader |
|
473 | - // because there are some side effects in that class for triggering template tag functions |
|
474 | - $this->Registry->load_helper('EEH_Template'); |
|
475 | - $this->_template_path = ! empty($this->_template_path) |
|
476 | - ? basename($this->_template_path) |
|
477 | - : basename((string) $template_include_path); |
|
478 | - $template_path = EEH_Template::locate_template($this->_template_path, [], false); |
|
479 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
480 | - $this->_template = basename($this->_template_path); |
|
481 | - return $this->_template_path; |
|
482 | - } |
|
483 | - return $template_include_path; |
|
484 | - } |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
488 | - * @param bool $with_path |
|
489 | - * @return string |
|
490 | - */ |
|
491 | - public function get_selected_template($with_path = false) |
|
492 | - { |
|
493 | - return $with_path ? $this->_template_path : $this->_template; |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - /** |
|
498 | - * @param string $shortcode_class |
|
499 | - * @param WP $wp |
|
500 | - * @throws ReflectionException |
|
501 | - * @deprecated 4.9.26 |
|
502 | - */ |
|
503 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
504 | - { |
|
505 | - EE_Error::doing_it_wrong( |
|
506 | - __METHOD__, |
|
507 | - esc_html__( |
|
508 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
509 | - 'event_espresso' |
|
510 | - ), |
|
511 | - '4.9.26' |
|
512 | - ); |
|
513 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
514 | - } |
|
515 | - |
|
516 | - |
|
517 | - /** |
|
518 | - * @return void |
|
519 | - * @deprecated 4.9.57.p |
|
520 | - */ |
|
521 | - public function loadPersistentAdminNoticeManager() |
|
522 | - { |
|
523 | - } |
|
524 | - |
|
525 | - |
|
526 | - /** |
|
527 | - * @return void |
|
528 | - * @deprecated 4.9.64.p |
|
529 | - */ |
|
530 | - public function employ_CPT_Strategy() |
|
531 | - { |
|
532 | - } |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + private $_template_path; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + private $_template; |
|
31 | + |
|
32 | + /** |
|
33 | + * @type EE_Registry |
|
34 | + */ |
|
35 | + protected $Registry; |
|
36 | + |
|
37 | + /** |
|
38 | + * @type EE_Request_Handler |
|
39 | + */ |
|
40 | + protected $Request_Handler; |
|
41 | + |
|
42 | + /** |
|
43 | + * @type EE_Module_Request_Router |
|
44 | + */ |
|
45 | + protected $Module_Request_Router; |
|
46 | + |
|
47 | + /** |
|
48 | + * @type CurrentPage |
|
49 | + */ |
|
50 | + protected $current_page; |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * class constructor |
|
55 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
56 | + * |
|
57 | + * @access public |
|
58 | + * @param EE_Registry $Registry |
|
59 | + * @param CurrentPage $EspressoPage |
|
60 | + * @param EE_Module_Request_Router $Module_Request_Router |
|
61 | + */ |
|
62 | + public function __construct( |
|
63 | + EE_Registry $Registry, |
|
64 | + CurrentPage $EspressoPage, |
|
65 | + EE_Module_Request_Router $Module_Request_Router |
|
66 | + ) { |
|
67 | + $this->Registry = $Registry; |
|
68 | + $this->current_page = $EspressoPage; |
|
69 | + $this->Module_Request_Router = $Module_Request_Router; |
|
70 | + // load other resources and begin to actually run shortcodes and modules |
|
71 | + // analyse the incoming WP request |
|
72 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
73 | + // process request with module factory |
|
74 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
75 | + // before headers sent |
|
76 | + add_action('wp', array($this, 'wp'), 5); |
|
77 | + // primarily used to process any content shortcodes |
|
78 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
79 | + // header |
|
80 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
81 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
82 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
83 | + // display errors |
|
84 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
85 | + // the content |
|
86 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
87 | + // exclude our private cpt comments |
|
88 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
89 | + // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
90 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
91 | + // action hook EE |
|
92 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @return EE_Request_Handler |
|
98 | + * @deprecated 4.10.14.p |
|
99 | + */ |
|
100 | + public function Request_Handler() |
|
101 | + { |
|
102 | + if (! $this->Request_Handler instanceof EE_Request_Handler) { |
|
103 | + $this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler'); |
|
104 | + } |
|
105 | + return $this->Request_Handler; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @return EE_Module_Request_Router |
|
111 | + */ |
|
112 | + public function Module_Request_Router() |
|
113 | + { |
|
114 | + return $this->Module_Request_Router; |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return LegacyShortcodesManager |
|
120 | + * @deprecated 4.10.14.p |
|
121 | + */ |
|
122 | + public function getLegacyShortcodesManager() |
|
123 | + { |
|
124 | + return EE_Config::getLegacyShortcodesManager(); |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + |
|
131 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
132 | + /** |
|
133 | + * filter_wp_comments |
|
134 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
135 | + * widgets/queries done on frontend |
|
136 | + * |
|
137 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
138 | + * @return array array of comment clauses with modifications. |
|
139 | + * @throws InvalidArgumentException |
|
140 | + * @throws InvalidDataTypeException |
|
141 | + * @throws InvalidInterfaceException |
|
142 | + */ |
|
143 | + public function filter_wp_comments($clauses) |
|
144 | + { |
|
145 | + global $wpdb; |
|
146 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
147 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
148 | + $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
149 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
150 | + ); |
|
151 | + $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
152 | + foreach ($cpts as $cpt => $details) { |
|
153 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
154 | + } |
|
155 | + } |
|
156 | + return $clauses; |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
162 | + * |
|
163 | + * @param string $url incoming url |
|
164 | + * @return string final assembled url |
|
165 | + */ |
|
166 | + public function maybe_force_admin_ajax_ssl($url) |
|
167 | + { |
|
168 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
169 | + $url = str_replace('http://', 'https://', $url); |
|
170 | + } |
|
171 | + return $url; |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + |
|
178 | + |
|
179 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
184 | + * default priority init phases have run |
|
185 | + * |
|
186 | + * @access public |
|
187 | + * @return void |
|
188 | + */ |
|
189 | + public function wp_loaded() |
|
190 | + { |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + |
|
196 | + |
|
197 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
198 | + /** |
|
199 | + * _get_request |
|
200 | + * |
|
201 | + * @access public |
|
202 | + * @param WP $WP |
|
203 | + * @return void |
|
204 | + */ |
|
205 | + public function get_request(WP $WP) |
|
206 | + { |
|
207 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
208 | + $this->current_page->parseQueryVars($WP); |
|
209 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
210 | + remove_action('parse_request', [$this, 'get_request'], 1); |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
216 | + * |
|
217 | + * @access public |
|
218 | + * @param WP_Query $WP_Query |
|
219 | + * @return void |
|
220 | + * @throws EE_Error |
|
221 | + * @throws ReflectionException |
|
222 | + */ |
|
223 | + public function pre_get_posts($WP_Query) |
|
224 | + { |
|
225 | + // only load Module_Request_Router if this is the main query |
|
226 | + if ( |
|
227 | + $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
228 | + && $WP_Query->is_main_query() |
|
229 | + ) { |
|
230 | + // cycle thru module routes |
|
231 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
232 | + // determine module and method for route |
|
233 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
234 | + if ($module instanceof EED_Module) { |
|
235 | + // get registered view for route |
|
236 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
237 | + // grab module name |
|
238 | + $module_name = $module->module_name(); |
|
239 | + // map the module to the module objects |
|
240 | + $this->Registry->modules->{$module_name} = $module; |
|
241 | + } |
|
242 | + } |
|
243 | + } |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + |
|
248 | + |
|
249 | + |
|
250 | + /*********************************************** WP HOOK ***********************************************/ |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * wp - basically last chance to do stuff before headers sent |
|
255 | + * |
|
256 | + * @access public |
|
257 | + * @return void |
|
258 | + */ |
|
259 | + public function wp() |
|
260 | + { |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + |
|
265 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
266 | + |
|
267 | + |
|
268 | + /** |
|
269 | + * callback for the "template_redirect" hook point |
|
270 | + * checks sidebars for EE widgets |
|
271 | + * loads resources and assets accordingly |
|
272 | + * |
|
273 | + * @return void |
|
274 | + */ |
|
275 | + public function templateRedirect() |
|
276 | + { |
|
277 | + global $wp_query; |
|
278 | + if (empty($wp_query->posts)) { |
|
279 | + return; |
|
280 | + } |
|
281 | + // if we already know this is an espresso page, then load assets |
|
282 | + $load_assets = $this->current_page->isEspressoPage(); |
|
283 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
284 | + $load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars(); |
|
285 | + if ($load_assets) { |
|
286 | + add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
287 | + add_action('wp_enqueue_scripts', array($this, 'enqueueScripts'), 10); |
|
288 | + } |
|
289 | + |
|
290 | + if (is_singular(EspressoPostType::EVENTS)) { |
|
291 | + new FilterNextPreviousEventPostQuery(); |
|
292 | + } |
|
293 | + } |
|
294 | + |
|
295 | + |
|
296 | + /** |
|
297 | + * builds list of active widgets then scans active sidebars looking for them |
|
298 | + * returns true is an EE widget is found in an active sidebar |
|
299 | + * Please Note: this does NOT mean that the sidebar or widget |
|
300 | + * is actually in use in a given template, as that is unfortunately not known |
|
301 | + * until a sidebar and it's widgets are actually loaded |
|
302 | + * |
|
303 | + * @return boolean |
|
304 | + */ |
|
305 | + private function espresso_widgets_in_active_sidebars() |
|
306 | + { |
|
307 | + $espresso_widgets = array(); |
|
308 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
309 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
310 | + if (is_active_widget(false, false, $id_base)) { |
|
311 | + $espresso_widgets[] = $id_base; |
|
312 | + } |
|
313 | + } |
|
314 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
315 | + foreach ($all_sidebar_widgets as $sidebar_widgets) { |
|
316 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
317 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
318 | + foreach ($espresso_widgets as $espresso_widget) { |
|
319 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
320 | + return true; |
|
321 | + } |
|
322 | + } |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | + return false; |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * header_meta_tag |
|
332 | + * |
|
333 | + * @access public |
|
334 | + * @return void |
|
335 | + */ |
|
336 | + public function header_meta_tag() |
|
337 | + { |
|
338 | + print( |
|
339 | + apply_filters( |
|
340 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
341 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
342 | + ) |
|
343 | + ); |
|
344 | + |
|
345 | + // let's exclude all event type taxonomy term archive pages from search engine indexing |
|
346 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
347 | + // also exclude all critical pages from indexing |
|
348 | + if ( |
|
349 | + ( |
|
350 | + is_tax('espresso_event_type') |
|
351 | + && get_option('blog_public') !== '0' |
|
352 | + ) |
|
353 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
354 | + ) { |
|
355 | + print( |
|
356 | + apply_filters( |
|
357 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
358 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
359 | + ) |
|
360 | + ); |
|
361 | + } |
|
362 | + } |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * wp_print_scripts |
|
367 | + * |
|
368 | + * @return void |
|
369 | + * @throws EE_Error |
|
370 | + */ |
|
371 | + public function wp_print_scripts() |
|
372 | + { |
|
373 | + global $post; |
|
374 | + if ( |
|
375 | + isset($post->EE_Event) |
|
376 | + && $post->EE_Event instanceof EE_Event |
|
377 | + && get_post_type() === EspressoPostType::EVENTS |
|
378 | + && is_singular() |
|
379 | + ) { |
|
380 | + EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
381 | + } |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + public function enqueueStyle() |
|
386 | + { |
|
387 | + wp_enqueue_style('espresso_default'); |
|
388 | + wp_enqueue_style('espresso_custom_css'); |
|
389 | + } |
|
390 | + |
|
391 | + |
|
392 | + |
|
393 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
394 | + |
|
395 | + |
|
396 | + public function enqueueScripts() |
|
397 | + { |
|
398 | + wp_enqueue_script('espresso_core'); |
|
399 | + } |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * display_errors |
|
404 | + * |
|
405 | + * @access public |
|
406 | + * @return void |
|
407 | + * @throws DomainException |
|
408 | + */ |
|
409 | + public function display_errors() |
|
410 | + { |
|
411 | + static $shown_already = false; |
|
412 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
413 | + if ( |
|
414 | + ! $shown_already |
|
415 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
416 | + && is_main_query() |
|
417 | + && ! is_feed() |
|
418 | + && in_the_loop() |
|
419 | + && $this->current_page->isEspressoPage() |
|
420 | + ) { |
|
421 | + $shown_already = true; |
|
422 | + if (did_action('wp_head')) { |
|
423 | + echo wp_kses($this->printNotices(), AllowedTags::getAllowedTags()); |
|
424 | + } else { |
|
425 | + // block enabled themes run their query loop before headers are sent |
|
426 | + // so we need to add our notices onto the beginning of the content |
|
427 | + add_filter('the_content', [$this, 'prependNotices'], 1, 1); |
|
428 | + } |
|
429 | + } |
|
430 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
431 | + } |
|
432 | + |
|
433 | + |
|
434 | + /** |
|
435 | + * @param string $the_content |
|
436 | + * @return string |
|
437 | + * @since 4.10.30.p |
|
438 | + */ |
|
439 | + public function prependNotices($the_content) |
|
440 | + { |
|
441 | + $notices = $this->printNotices(); |
|
442 | + return $notices ? $notices . $the_content : $the_content; |
|
443 | + } |
|
444 | + |
|
445 | + |
|
446 | + /** |
|
447 | + * @return false|string |
|
448 | + * @since 4.10.30.p |
|
449 | + */ |
|
450 | + public function printNotices() |
|
451 | + { |
|
452 | + ob_start(); |
|
453 | + echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags()); |
|
454 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
455 | + return ob_get_clean(); |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + |
|
460 | + /*********************************************** UTILITIES ***********************************************/ |
|
461 | + |
|
462 | + |
|
463 | + /** |
|
464 | + * @param bool|string $template_include_path |
|
465 | + * @return string |
|
466 | + * @throws EE_Error |
|
467 | + * @throws ReflectionException |
|
468 | + */ |
|
469 | + public function template_include($template_include_path = '') |
|
470 | + { |
|
471 | + if ($this->current_page->isEspressoPage()) { |
|
472 | + // despite all helpers having autoloaders set, we need to manually load the template loader |
|
473 | + // because there are some side effects in that class for triggering template tag functions |
|
474 | + $this->Registry->load_helper('EEH_Template'); |
|
475 | + $this->_template_path = ! empty($this->_template_path) |
|
476 | + ? basename($this->_template_path) |
|
477 | + : basename((string) $template_include_path); |
|
478 | + $template_path = EEH_Template::locate_template($this->_template_path, [], false); |
|
479 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
480 | + $this->_template = basename($this->_template_path); |
|
481 | + return $this->_template_path; |
|
482 | + } |
|
483 | + return $template_include_path; |
|
484 | + } |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | + * @param bool $with_path |
|
489 | + * @return string |
|
490 | + */ |
|
491 | + public function get_selected_template($with_path = false) |
|
492 | + { |
|
493 | + return $with_path ? $this->_template_path : $this->_template; |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + /** |
|
498 | + * @param string $shortcode_class |
|
499 | + * @param WP $wp |
|
500 | + * @throws ReflectionException |
|
501 | + * @deprecated 4.9.26 |
|
502 | + */ |
|
503 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
504 | + { |
|
505 | + EE_Error::doing_it_wrong( |
|
506 | + __METHOD__, |
|
507 | + esc_html__( |
|
508 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
509 | + 'event_espresso' |
|
510 | + ), |
|
511 | + '4.9.26' |
|
512 | + ); |
|
513 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
514 | + } |
|
515 | + |
|
516 | + |
|
517 | + /** |
|
518 | + * @return void |
|
519 | + * @deprecated 4.9.57.p |
|
520 | + */ |
|
521 | + public function loadPersistentAdminNoticeManager() |
|
522 | + { |
|
523 | + } |
|
524 | + |
|
525 | + |
|
526 | + /** |
|
527 | + * @return void |
|
528 | + * @deprecated 4.9.64.p |
|
529 | + */ |
|
530 | + public function employ_CPT_Strategy() |
|
531 | + { |
|
532 | + } |
|
533 | 533 | } |
@@ -2,34 +2,34 @@ |
||
2 | 2 | |
3 | 3 | class EE_Switch_Input extends EE_Form_Input_With_Options_Base |
4 | 4 | { |
5 | - public const OPTION_ON = 'ON'; |
|
5 | + public const OPTION_ON = 'ON'; |
|
6 | 6 | |
7 | - public const OPTION_OFF = 'OFF'; |
|
7 | + public const OPTION_OFF = 'OFF'; |
|
8 | 8 | |
9 | 9 | |
10 | - /** |
|
11 | - * @param array $input_settings |
|
12 | - * @param array $answer_options |
|
13 | - */ |
|
14 | - public function __construct($input_settings = [], array $answer_options = []) |
|
15 | - { |
|
16 | - $this->_set_display_strategy(new EE_Switch_Display_Strategy()); |
|
17 | - $this->_add_validation_strategy( |
|
18 | - new EE_Many_Valued_Validation_Strategy( |
|
19 | - [ |
|
20 | - new EE_Enum_Validation_Strategy( |
|
21 | - $input_settings['validation_error_message'] ?? null |
|
22 | - ), |
|
23 | - ] |
|
24 | - ) |
|
25 | - ); |
|
26 | - if (! is_array($answer_options) || empty($answer_options)) { |
|
27 | - $answer_options = [ |
|
28 | - EE_Switch_Input::OPTION_ON => esc_html__('enabled', 'event_espresso'), |
|
29 | - EE_Switch_Input::OPTION_OFF => esc_html__('disabled', 'event_espresso'), |
|
30 | - ]; |
|
31 | - } |
|
32 | - $this->_multiple_selections = false; |
|
33 | - parent::__construct($answer_options, $input_settings); |
|
34 | - } |
|
10 | + /** |
|
11 | + * @param array $input_settings |
|
12 | + * @param array $answer_options |
|
13 | + */ |
|
14 | + public function __construct($input_settings = [], array $answer_options = []) |
|
15 | + { |
|
16 | + $this->_set_display_strategy(new EE_Switch_Display_Strategy()); |
|
17 | + $this->_add_validation_strategy( |
|
18 | + new EE_Many_Valued_Validation_Strategy( |
|
19 | + [ |
|
20 | + new EE_Enum_Validation_Strategy( |
|
21 | + $input_settings['validation_error_message'] ?? null |
|
22 | + ), |
|
23 | + ] |
|
24 | + ) |
|
25 | + ); |
|
26 | + if (! is_array($answer_options) || empty($answer_options)) { |
|
27 | + $answer_options = [ |
|
28 | + EE_Switch_Input::OPTION_ON => esc_html__('enabled', 'event_espresso'), |
|
29 | + EE_Switch_Input::OPTION_OFF => esc_html__('disabled', 'event_espresso'), |
|
30 | + ]; |
|
31 | + } |
|
32 | + $this->_multiple_selections = false; |
|
33 | + parent::__construct($answer_options, $input_settings); |
|
34 | + } |
|
35 | 35 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | ] |
24 | 24 | ) |
25 | 25 | ); |
26 | - if (! is_array($answer_options) || empty($answer_options)) { |
|
26 | + if ( ! is_array($answer_options) || empty($answer_options)) { |
|
27 | 27 | $answer_options = [ |
28 | 28 | EE_Switch_Input::OPTION_ON => esc_html__('enabled', 'event_espresso'), |
29 | 29 | EE_Switch_Input::OPTION_OFF => esc_html__('disabled', 'event_espresso'), |
@@ -14,23 +14,23 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Checkbox_Multi_Input extends EE_Form_Input_With_Options_Base |
16 | 16 | { |
17 | - /** |
|
18 | - * @param array | EE_Question_Option[] $answer_options |
|
19 | - * @param array $input_settings |
|
20 | - */ |
|
21 | - public function __construct($answer_options, $input_settings = []) |
|
22 | - { |
|
23 | - $this->_set_display_strategy(new EE_Checkbox_Display_Strategy()); |
|
24 | - $this->_add_validation_strategy( |
|
25 | - new EE_Many_Valued_Validation_Strategy( |
|
26 | - [ |
|
27 | - new EE_Enum_Validation_Strategy( |
|
28 | - $input_settings['validation_error_message'] ?? null |
|
29 | - ) |
|
30 | - ] |
|
31 | - ) |
|
32 | - ); |
|
33 | - $this->_multiple_selections = true; |
|
34 | - parent::__construct($answer_options, $input_settings); |
|
35 | - } |
|
17 | + /** |
|
18 | + * @param array | EE_Question_Option[] $answer_options |
|
19 | + * @param array $input_settings |
|
20 | + */ |
|
21 | + public function __construct($answer_options, $input_settings = []) |
|
22 | + { |
|
23 | + $this->_set_display_strategy(new EE_Checkbox_Display_Strategy()); |
|
24 | + $this->_add_validation_strategy( |
|
25 | + new EE_Many_Valued_Validation_Strategy( |
|
26 | + [ |
|
27 | + new EE_Enum_Validation_Strategy( |
|
28 | + $input_settings['validation_error_message'] ?? null |
|
29 | + ) |
|
30 | + ] |
|
31 | + ) |
|
32 | + ); |
|
33 | + $this->_multiple_selections = true; |
|
34 | + parent::__construct($answer_options, $input_settings); |
|
35 | + } |
|
36 | 36 | } |
@@ -14,107 +14,107 @@ |
||
14 | 14 | class JobStepResponse |
15 | 15 | { |
16 | 16 | // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
17 | - /** |
|
18 | - * Description fo what happened during this step |
|
19 | - * |
|
20 | - * @var array|string |
|
21 | - */ |
|
22 | - protected $_update_text; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var JobParameters |
|
26 | - */ |
|
27 | - protected $_job_parameters; |
|
28 | - |
|
29 | - /** |
|
30 | - * Extra data to include as part of the response. |
|
31 | - * |
|
32 | - * @var array |
|
33 | - */ |
|
34 | - protected $_extra_data = []; |
|
17 | + /** |
|
18 | + * Description fo what happened during this step |
|
19 | + * |
|
20 | + * @var array|string |
|
21 | + */ |
|
22 | + protected $_update_text; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var JobParameters |
|
26 | + */ |
|
27 | + protected $_job_parameters; |
|
28 | + |
|
29 | + /** |
|
30 | + * Extra data to include as part of the response. |
|
31 | + * |
|
32 | + * @var array |
|
33 | + */ |
|
34 | + protected $_extra_data = []; |
|
35 | 35 | |
36 | 36 | // phpcs:enable |
37 | 37 | |
38 | 38 | // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
39 | - /** |
|
40 | - * @param JobParameters $job_parameters |
|
41 | - * @param array|string $update_text |
|
42 | - * @param array $extra_data |
|
43 | - */ |
|
44 | - public function __construct(JobParameters $job_parameters, $update_text = [], array $extra_data = []) |
|
45 | - { |
|
46 | - $this->_job_parameters = $job_parameters; |
|
47 | - $this->_update_text = (array) $update_text; |
|
48 | - $this->_extra_data = $extra_data; |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * @return JobParameters |
|
54 | - */ |
|
55 | - public function job_parameters(): JobParameters |
|
56 | - { |
|
57 | - return $this->_job_parameters; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * Gets the update_text of what happened in this job during the current step |
|
63 | - * |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function update_text(): string |
|
67 | - { |
|
68 | - return implode('', array_filter(array_map('trim', $this->_update_text))); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @param string $update_text |
|
74 | - */ |
|
75 | - public function addUpdateText(string $update_text) |
|
76 | - { |
|
77 | - $this->_update_text[] = $update_text; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * Returns any extra data we may want to include with this response |
|
83 | - * |
|
84 | - * @return array |
|
85 | - */ |
|
86 | - public function extra_data(): array |
|
87 | - { |
|
88 | - return $this->_extra_data ?: []; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * Converts this response into an array that can be easily serialized. |
|
94 | - * This is most useful for serializing or json encoding |
|
95 | - * |
|
96 | - * @return array { |
|
97 | - * @type string $status , one of JobParameters::valid_stati() |
|
98 | - * @type int $units_processed count of units processed |
|
99 | - * @type int $job_size total number of units TO process |
|
100 | - * @type string $job_id unique string identifying the job |
|
101 | - * @type string $update_text string describing what happened during this step |
|
102 | - * } and any other items from $this->extra_data() |
|
103 | - */ |
|
104 | - public function to_array(): array |
|
105 | - { |
|
106 | - return apply_filters( |
|
107 | - 'FHEE__EventEspressoBatchRequest\Helpers\JobStepResponse__to_array__return', |
|
108 | - [ |
|
109 | - 'status' => $this->job_parameters()->status(), |
|
110 | - 'units_processed' => $this->job_parameters()->units_processed(), |
|
111 | - 'job_size' => $this->job_parameters()->job_size(), |
|
112 | - 'job_id' => $this->job_parameters()->job_id(), |
|
113 | - 'update_text' => $this->update_text(), |
|
114 | - ] |
|
115 | - + $this->extra_data() |
|
116 | - + $this->job_parameters()->extra_data(), |
|
117 | - $this |
|
118 | - ); |
|
119 | - } |
|
39 | + /** |
|
40 | + * @param JobParameters $job_parameters |
|
41 | + * @param array|string $update_text |
|
42 | + * @param array $extra_data |
|
43 | + */ |
|
44 | + public function __construct(JobParameters $job_parameters, $update_text = [], array $extra_data = []) |
|
45 | + { |
|
46 | + $this->_job_parameters = $job_parameters; |
|
47 | + $this->_update_text = (array) $update_text; |
|
48 | + $this->_extra_data = $extra_data; |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * @return JobParameters |
|
54 | + */ |
|
55 | + public function job_parameters(): JobParameters |
|
56 | + { |
|
57 | + return $this->_job_parameters; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * Gets the update_text of what happened in this job during the current step |
|
63 | + * |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function update_text(): string |
|
67 | + { |
|
68 | + return implode('', array_filter(array_map('trim', $this->_update_text))); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @param string $update_text |
|
74 | + */ |
|
75 | + public function addUpdateText(string $update_text) |
|
76 | + { |
|
77 | + $this->_update_text[] = $update_text; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * Returns any extra data we may want to include with this response |
|
83 | + * |
|
84 | + * @return array |
|
85 | + */ |
|
86 | + public function extra_data(): array |
|
87 | + { |
|
88 | + return $this->_extra_data ?: []; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * Converts this response into an array that can be easily serialized. |
|
94 | + * This is most useful for serializing or json encoding |
|
95 | + * |
|
96 | + * @return array { |
|
97 | + * @type string $status , one of JobParameters::valid_stati() |
|
98 | + * @type int $units_processed count of units processed |
|
99 | + * @type int $job_size total number of units TO process |
|
100 | + * @type string $job_id unique string identifying the job |
|
101 | + * @type string $update_text string describing what happened during this step |
|
102 | + * } and any other items from $this->extra_data() |
|
103 | + */ |
|
104 | + public function to_array(): array |
|
105 | + { |
|
106 | + return apply_filters( |
|
107 | + 'FHEE__EventEspressoBatchRequest\Helpers\JobStepResponse__to_array__return', |
|
108 | + [ |
|
109 | + 'status' => $this->job_parameters()->status(), |
|
110 | + 'units_processed' => $this->job_parameters()->units_processed(), |
|
111 | + 'job_size' => $this->job_parameters()->job_size(), |
|
112 | + 'job_id' => $this->job_parameters()->job_id(), |
|
113 | + 'update_text' => $this->update_text(), |
|
114 | + ] |
|
115 | + + $this->extra_data() |
|
116 | + + $this->job_parameters()->extra_data(), |
|
117 | + $this |
|
118 | + ); |
|
119 | + } |
|
120 | 120 | } |
@@ -6,8 +6,8 @@ |
||
6 | 6 | |
7 | 7 | class JobParametersWordPressOption extends WordPressOption |
8 | 8 | { |
9 | - public function __construct($option_name) |
|
10 | - { |
|
11 | - parent::__construct($option_name, [], false); |
|
12 | - } |
|
9 | + public function __construct($option_name) |
|
10 | + { |
|
11 | + parent::__construct($option_name, [], false); |
|
12 | + } |
|
13 | 13 | } |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | { |
27 | 27 | wp_enqueue_style( |
28 | 28 | 'status_change_notice', |
29 | - EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.css', |
|
29 | + EE_PLUGIN_DIR_URL.'core/domain/services/admin/notices/status_change/status_change_notice.css', |
|
30 | 30 | ['espresso_menu'], |
31 | 31 | EVENT_ESPRESSO_VERSION |
32 | 32 | ); |
33 | 33 | wp_enqueue_script( |
34 | 34 | 'status_change_notice', |
35 | - EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.js', |
|
35 | + EE_PLUGIN_DIR_URL.'core/domain/services/admin/notices/status_change/status_change_notice.js', |
|
36 | 36 | ['jquery'], |
37 | 37 | EVENT_ESPRESSO_VERSION, |
38 | 38 | true |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | return $this->isNotDismissed() |
64 | 64 | ? EEH_Template::display_template( |
65 | - __DIR__ . '/status_change_notice.template.php', |
|
65 | + __DIR__.'/status_change_notice.template.php', |
|
66 | 66 | [ |
67 | 67 | 'context' => $context, |
68 | 68 | 'page_slug' => ! empty($page_slug) ? "$page_slug-page" : '', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | { |
82 | 82 | $user = $this->getCurrentUser(); |
83 | 83 | $dismissed = (array) $this->loadOption(); |
84 | - if (! in_array($user, $dismissed)) { |
|
84 | + if ( ! in_array($user, $dismissed)) { |
|
85 | 85 | $dismissed[] = $user; |
86 | 86 | } |
87 | 87 | return $this->updateOption($dismissed); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | private function getCurrentUser(): string |
118 | 118 | { |
119 | 119 | $user = wp_get_current_user(); |
120 | - if (! $user instanceof WP_User || ! $user->exists()) { |
|
120 | + if ( ! $user instanceof WP_User || ! $user->exists()) { |
|
121 | 121 | throw new RuntimeException( |
122 | 122 | esc_html__('A valid WP User could not be retrieved.', 'event_espresso') |
123 | 123 | ); |
@@ -16,112 +16,112 @@ |
||
16 | 16 | */ |
17 | 17 | class StatusChangeNotice extends WordPressOption |
18 | 18 | { |
19 | - public function __construct() |
|
20 | - { |
|
21 | - parent::__construct('ee_hide_status_change_notices_for_users', []); |
|
22 | - } |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + parent::__construct('ee_hide_status_change_notices_for_users', []); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - public static function loadAssets() |
|
26 | - { |
|
27 | - wp_enqueue_style( |
|
28 | - 'status_change_notice', |
|
29 | - EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.css', |
|
30 | - ['espresso_menu'], |
|
31 | - EVENT_ESPRESSO_VERSION |
|
32 | - ); |
|
33 | - wp_enqueue_script( |
|
34 | - 'status_change_notice', |
|
35 | - EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.js', |
|
36 | - ['jquery'], |
|
37 | - EVENT_ESPRESSO_VERSION, |
|
38 | - true |
|
39 | - ); |
|
40 | - wp_localize_script( |
|
41 | - 'status_change_notice', |
|
42 | - 'eeStatusChangeNotice', |
|
43 | - [ |
|
44 | - 'failed_request_msg' => wp_strip_all_tags( |
|
45 | - __( |
|
46 | - 'Request failed. The server returned status code: ', |
|
47 | - 'event_espresso' |
|
48 | - ) |
|
49 | - ), |
|
50 | - 'unknown_error_msg' => wp_strip_all_tags( |
|
51 | - __( |
|
52 | - 'Oops... an unknown error has occurred on the server and this notice could not be dismissed.', |
|
53 | - 'event_espresso' |
|
54 | - ) |
|
55 | - ), |
|
56 | - ] |
|
57 | - ); |
|
58 | - } |
|
25 | + public static function loadAssets() |
|
26 | + { |
|
27 | + wp_enqueue_style( |
|
28 | + 'status_change_notice', |
|
29 | + EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.css', |
|
30 | + ['espresso_menu'], |
|
31 | + EVENT_ESPRESSO_VERSION |
|
32 | + ); |
|
33 | + wp_enqueue_script( |
|
34 | + 'status_change_notice', |
|
35 | + EE_PLUGIN_DIR_URL . 'core/domain/services/admin/notices/status_change/status_change_notice.js', |
|
36 | + ['jquery'], |
|
37 | + EVENT_ESPRESSO_VERSION, |
|
38 | + true |
|
39 | + ); |
|
40 | + wp_localize_script( |
|
41 | + 'status_change_notice', |
|
42 | + 'eeStatusChangeNotice', |
|
43 | + [ |
|
44 | + 'failed_request_msg' => wp_strip_all_tags( |
|
45 | + __( |
|
46 | + 'Request failed. The server returned status code: ', |
|
47 | + 'event_espresso' |
|
48 | + ) |
|
49 | + ), |
|
50 | + 'unknown_error_msg' => wp_strip_all_tags( |
|
51 | + __( |
|
52 | + 'Oops... an unknown error has occurred on the server and this notice could not be dismissed.', |
|
53 | + 'event_espresso' |
|
54 | + ) |
|
55 | + ), |
|
56 | + ] |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - public function display(string $context, string $page_slug): string |
|
62 | - { |
|
63 | - return $this->isNotDismissed() |
|
64 | - ? EEH_Template::display_template( |
|
65 | - __DIR__ . '/status_change_notice.template.php', |
|
66 | - [ |
|
67 | - 'context' => $context, |
|
68 | - 'page_slug' => ! empty($page_slug) ? "$page_slug-page" : '', |
|
69 | - ], |
|
70 | - true |
|
71 | - ) |
|
72 | - : ''; |
|
73 | - } |
|
61 | + public function display(string $context, string $page_slug): string |
|
62 | + { |
|
63 | + return $this->isNotDismissed() |
|
64 | + ? EEH_Template::display_template( |
|
65 | + __DIR__ . '/status_change_notice.template.php', |
|
66 | + [ |
|
67 | + 'context' => $context, |
|
68 | + 'page_slug' => ! empty($page_slug) ? "$page_slug-page" : '', |
|
69 | + ], |
|
70 | + true |
|
71 | + ) |
|
72 | + : ''; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * @return int |
|
78 | - * @throws RuntimeException |
|
79 | - */ |
|
80 | - public function dismiss(): int |
|
81 | - { |
|
82 | - $user = $this->getCurrentUser(); |
|
83 | - $dismissed = (array) $this->loadOption(); |
|
84 | - if (! in_array($user, $dismissed)) { |
|
85 | - $dismissed[] = $user; |
|
86 | - } |
|
87 | - return $this->updateOption($dismissed); |
|
88 | - } |
|
76 | + /** |
|
77 | + * @return int |
|
78 | + * @throws RuntimeException |
|
79 | + */ |
|
80 | + public function dismiss(): int |
|
81 | + { |
|
82 | + $user = $this->getCurrentUser(); |
|
83 | + $dismissed = (array) $this->loadOption(); |
|
84 | + if (! in_array($user, $dismissed)) { |
|
85 | + $dismissed[] = $user; |
|
86 | + } |
|
87 | + return $this->updateOption($dismissed); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * @return bool |
|
93 | - * @throws RuntimeException |
|
94 | - */ |
|
95 | - public function isDismissed(): bool |
|
96 | - { |
|
97 | - $user = $this->getCurrentUser(); |
|
98 | - $dismissed = (array) $this->loadOption(); |
|
99 | - return in_array($user, $dismissed); |
|
100 | - } |
|
91 | + /** |
|
92 | + * @return bool |
|
93 | + * @throws RuntimeException |
|
94 | + */ |
|
95 | + public function isDismissed(): bool |
|
96 | + { |
|
97 | + $user = $this->getCurrentUser(); |
|
98 | + $dismissed = (array) $this->loadOption(); |
|
99 | + return in_array($user, $dismissed); |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * @return bool |
|
105 | - * @throws RuntimeException |
|
106 | - */ |
|
107 | - public function isNotDismissed(): bool |
|
108 | - { |
|
109 | - return ! $this->isDismissed(); |
|
110 | - } |
|
103 | + /** |
|
104 | + * @return bool |
|
105 | + * @throws RuntimeException |
|
106 | + */ |
|
107 | + public function isNotDismissed(): bool |
|
108 | + { |
|
109 | + return ! $this->isDismissed(); |
|
110 | + } |
|
111 | 111 | |
112 | 112 | |
113 | - /** |
|
114 | - * @return string |
|
115 | - * @throws RuntimeException |
|
116 | - */ |
|
117 | - private function getCurrentUser(): string |
|
118 | - { |
|
119 | - $user = wp_get_current_user(); |
|
120 | - if (! $user instanceof WP_User || ! $user->exists()) { |
|
121 | - throw new RuntimeException( |
|
122 | - esc_html__('A valid WP User could not be retrieved.', 'event_espresso') |
|
123 | - ); |
|
124 | - } |
|
125 | - return $user->user_login; |
|
126 | - } |
|
113 | + /** |
|
114 | + * @return string |
|
115 | + * @throws RuntimeException |
|
116 | + */ |
|
117 | + private function getCurrentUser(): string |
|
118 | + { |
|
119 | + $user = wp_get_current_user(); |
|
120 | + if (! $user instanceof WP_User || ! $user->exists()) { |
|
121 | + throw new RuntimeException( |
|
122 | + esc_html__('A valid WP User could not be retrieved.', 'event_espresso') |
|
123 | + ); |
|
124 | + } |
|
125 | + return $user->user_login; |
|
126 | + } |
|
127 | 127 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | bool $autoload = false |
42 | 42 | ) { |
43 | 43 | $this->json_data_handler = $json_data_handler; |
44 | - if (! $this->json_data_handler->dataType()) { |
|
44 | + if ( ! $this->json_data_handler->dataType()) { |
|
45 | 45 | $this->json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT); |
46 | 46 | } |
47 | 47 | parent::__construct($option_name, $default_value, $autoload); |
@@ -15,94 +15,94 @@ |
||
15 | 15 | */ |
16 | 16 | abstract class JsonDataWordpressOption extends WordPressOption |
17 | 17 | { |
18 | - private JsonDataHandler $json_data_handler; |
|
19 | - |
|
20 | - /** |
|
21 | - * @var array|mixed|stdClass |
|
22 | - */ |
|
23 | - private $options = []; |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * JsonDataWordpressOption constructor. |
|
28 | - * |
|
29 | - * @param JsonDataHandler $json_data_handler |
|
30 | - * @param string $option_name |
|
31 | - * @param $default_value |
|
32 | - * @param bool $autoload |
|
33 | - */ |
|
34 | - public function __construct( |
|
35 | - JsonDataHandler $json_data_handler, |
|
36 | - string $option_name, |
|
37 | - $default_value, |
|
38 | - bool $autoload = false |
|
39 | - ) { |
|
40 | - $this->json_data_handler = $json_data_handler; |
|
41 | - if (! $this->json_data_handler->dataType()) { |
|
42 | - $this->json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT); |
|
43 | - } |
|
44 | - parent::__construct($option_name, $default_value, $autoload); |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @param $value |
|
50 | - * @return int |
|
51 | - */ |
|
52 | - public function updateOption($value, bool $force_update = false): int |
|
53 | - { |
|
54 | - $update = parent::updateOption($this->json_data_handler->encodeData($value), $force_update); |
|
55 | - if ($update === WordPressOption::UPDATE_SUCCESS) { |
|
56 | - $this->options = $value; |
|
57 | - } |
|
58 | - return $update; |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @param string $property |
|
64 | - * @param mixed $value |
|
65 | - * @return void |
|
66 | - */ |
|
67 | - public function addProperty(string $property, $value) |
|
68 | - { |
|
69 | - $options = $this->getAll(); |
|
70 | - $options->{$property} = $value; |
|
71 | - $this->updateOption($options); |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @param string $property |
|
77 | - * @return mixed |
|
78 | - */ |
|
79 | - public function getProperty(string $property) |
|
80 | - { |
|
81 | - $options = $this->getAll(); |
|
82 | - return property_exists($options, $property) ? $options->{$property} : null; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @return array|mixed|stdClass |
|
88 | - */ |
|
89 | - public function getAll() |
|
90 | - { |
|
91 | - if (empty($this->options)) { |
|
92 | - $this->options = $this->json_data_handler->decodeJson($this->loadOption()); |
|
93 | - } |
|
94 | - return $this->options; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @param string $property |
|
100 | - * @return void |
|
101 | - */ |
|
102 | - public function removeProperty(string $property) |
|
103 | - { |
|
104 | - $options = $this->getAll(); |
|
105 | - unset($options->{$property}); |
|
106 | - $this->updateOption($options); |
|
107 | - } |
|
18 | + private JsonDataHandler $json_data_handler; |
|
19 | + |
|
20 | + /** |
|
21 | + * @var array|mixed|stdClass |
|
22 | + */ |
|
23 | + private $options = []; |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * JsonDataWordpressOption constructor. |
|
28 | + * |
|
29 | + * @param JsonDataHandler $json_data_handler |
|
30 | + * @param string $option_name |
|
31 | + * @param $default_value |
|
32 | + * @param bool $autoload |
|
33 | + */ |
|
34 | + public function __construct( |
|
35 | + JsonDataHandler $json_data_handler, |
|
36 | + string $option_name, |
|
37 | + $default_value, |
|
38 | + bool $autoload = false |
|
39 | + ) { |
|
40 | + $this->json_data_handler = $json_data_handler; |
|
41 | + if (! $this->json_data_handler->dataType()) { |
|
42 | + $this->json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT); |
|
43 | + } |
|
44 | + parent::__construct($option_name, $default_value, $autoload); |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @param $value |
|
50 | + * @return int |
|
51 | + */ |
|
52 | + public function updateOption($value, bool $force_update = false): int |
|
53 | + { |
|
54 | + $update = parent::updateOption($this->json_data_handler->encodeData($value), $force_update); |
|
55 | + if ($update === WordPressOption::UPDATE_SUCCESS) { |
|
56 | + $this->options = $value; |
|
57 | + } |
|
58 | + return $update; |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @param string $property |
|
64 | + * @param mixed $value |
|
65 | + * @return void |
|
66 | + */ |
|
67 | + public function addProperty(string $property, $value) |
|
68 | + { |
|
69 | + $options = $this->getAll(); |
|
70 | + $options->{$property} = $value; |
|
71 | + $this->updateOption($options); |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @param string $property |
|
77 | + * @return mixed |
|
78 | + */ |
|
79 | + public function getProperty(string $property) |
|
80 | + { |
|
81 | + $options = $this->getAll(); |
|
82 | + return property_exists($options, $property) ? $options->{$property} : null; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @return array|mixed|stdClass |
|
88 | + */ |
|
89 | + public function getAll() |
|
90 | + { |
|
91 | + if (empty($this->options)) { |
|
92 | + $this->options = $this->json_data_handler->decodeJson($this->loadOption()); |
|
93 | + } |
|
94 | + return $this->options; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @param string $property |
|
100 | + * @return void |
|
101 | + */ |
|
102 | + public function removeProperty(string $property) |
|
103 | + { |
|
104 | + $options = $this->getAll(); |
|
105 | + unset($options->{$property}); |
|
106 | + $this->updateOption($options); |
|
107 | + } |
|
108 | 108 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | <div class="ee-batch-runner__wrapper ee-admin-container"> |
6 | 6 | <div class="padding"> |
7 | - <h1><?php esc_html_e('Running Batch Job...', 'event_espresso');?></h1> |
|
7 | + <h1><?php esc_html_e('Running Batch Job...', 'event_espresso'); ?></h1> |
|
8 | 8 | <div class="progress-bar-wrapper"> |
9 | 9 | <div id='batch-progress' class='progress-responsive'></div> |
10 | 10 | <label><?php esc_html_e('progress', 'event_espresso'); ?></label> |