@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function createFromModel($model_name) |
42 | 42 | { |
43 | - return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\' . $model_name); |
|
43 | + return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\'.$model_name); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public function createFromClassname($calculator_classname) |
52 | 52 | { |
53 | 53 | $calculator = $this->loader->getShared($calculator_classname); |
54 | - if (!$calculator instanceof Base) { |
|
54 | + if ( ! $calculator instanceof Base) { |
|
55 | 55 | throw new UnexpectedEntityException( |
56 | 56 | $calculator_classname, |
57 | 57 | 'EventEspresso\core\libraries\rest_api\calculations\Base' |
@@ -18,46 +18,46 @@ |
||
18 | 18 | */ |
19 | 19 | class CalculatedModelFieldsFactory |
20 | 20 | { |
21 | - private $loader; |
|
21 | + private $loader; |
|
22 | 22 | |
23 | - /** |
|
24 | - * CalculatedModelFieldsFactory constructor. |
|
25 | - * @param LoaderInterface $loader |
|
26 | - */ |
|
27 | - public function __construct(LoaderInterface $loader) |
|
28 | - { |
|
29 | - $this->loader = $loader; |
|
30 | - } |
|
23 | + /** |
|
24 | + * CalculatedModelFieldsFactory constructor. |
|
25 | + * @param LoaderInterface $loader |
|
26 | + */ |
|
27 | + public function __construct(LoaderInterface $loader) |
|
28 | + { |
|
29 | + $this->loader = $loader; |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Creates the calculator class that corresponds to that particular model |
|
34 | - * @since 4.9.68.p |
|
35 | - * @param string $model_name |
|
36 | - * @return Base |
|
37 | - * @throws UnexpectedEntityException |
|
38 | - */ |
|
39 | - public function createFromModel($model_name) |
|
40 | - { |
|
41 | - return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\' . $model_name); |
|
42 | - } |
|
32 | + /** |
|
33 | + * Creates the calculator class that corresponds to that particular model |
|
34 | + * @since 4.9.68.p |
|
35 | + * @param string $model_name |
|
36 | + * @return Base |
|
37 | + * @throws UnexpectedEntityException |
|
38 | + */ |
|
39 | + public function createFromModel($model_name) |
|
40 | + { |
|
41 | + return $this->createFromClassname('EventEspresso\core\libraries\rest_api\calculations\\' . $model_name); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Creates the calculator class that corresponds to that classname and verifies it's of the correct type |
|
46 | - * @param string $calculator_classname |
|
47 | - * @return Base |
|
48 | - * @throws UnexpectedEntityException |
|
49 | - */ |
|
50 | - public function createFromClassname($calculator_classname) |
|
51 | - { |
|
52 | - $calculator = $this->loader->getShared($calculator_classname); |
|
53 | - if (!$calculator instanceof Base) { |
|
54 | - throw new UnexpectedEntityException( |
|
55 | - $calculator_classname, |
|
56 | - 'EventEspresso\core\libraries\rest_api\calculations\Base' |
|
57 | - ); |
|
58 | - } |
|
59 | - return $calculator; |
|
60 | - } |
|
44 | + /** |
|
45 | + * Creates the calculator class that corresponds to that classname and verifies it's of the correct type |
|
46 | + * @param string $calculator_classname |
|
47 | + * @return Base |
|
48 | + * @throws UnexpectedEntityException |
|
49 | + */ |
|
50 | + public function createFromClassname($calculator_classname) |
|
51 | + { |
|
52 | + $calculator = $this->loader->getShared($calculator_classname); |
|
53 | + if (!$calculator instanceof Base) { |
|
54 | + throw new UnexpectedEntityException( |
|
55 | + $calculator_classname, |
|
56 | + 'EventEspresso\core\libraries\rest_api\calculations\Base' |
|
57 | + ); |
|
58 | + } |
|
59 | + return $calculator; |
|
60 | + } |
|
61 | 61 | } |
62 | 62 | // End of file CalculationsFactory.php |
63 | 63 | // Location: EventEspresso\core\libraries\rest_api\calculations/CalculationsFactory.php |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | protected function verifyCurrentUserCan($required_permission, $attempted_calculation) |
25 | 25 | { |
26 | - if (! current_user_can($required_permission)) { |
|
26 | + if ( ! current_user_can($required_permission)) { |
|
27 | 27 | throw new RestException( |
28 | 28 | 'permission_denied', |
29 | 29 | sprintf( |
@@ -75,6 +75,6 @@ discard block |
||
75 | 75 | public function schemaForCalculation($calculation_index) |
76 | 76 | { |
77 | 77 | $schema_map = $this->schemaForCalculations(); |
78 | - return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array(); |
|
78 | + return isset($schema_map[$calculation_index]) ? $schema_map[$calculation_index] : array(); |
|
79 | 79 | } |
80 | 80 | } |
@@ -15,65 +15,65 @@ |
||
15 | 15 | */ |
16 | 16 | class Base |
17 | 17 | { |
18 | - /** |
|
19 | - * @param $required_permission |
|
20 | - * @param $attempted_calculation |
|
21 | - * @throws RestException |
|
22 | - */ |
|
23 | - protected function verifyCurrentUserCan($required_permission, $attempted_calculation) |
|
24 | - { |
|
25 | - if (! current_user_can($required_permission)) { |
|
26 | - throw new RestException( |
|
27 | - 'permission_denied', |
|
28 | - sprintf( |
|
29 | - esc_html__( |
|
30 | - // @codingStandardsIgnoreStart |
|
31 | - 'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', |
|
32 | - // @codingStandardsIgnoreEnd |
|
33 | - 'event_espresso' |
|
34 | - ), |
|
35 | - $attempted_calculation, |
|
36 | - EEH_Inflector::pluralize_and_lower($this->getResourceName()), |
|
37 | - $required_permission |
|
38 | - ) |
|
39 | - ); |
|
40 | - } |
|
41 | - } |
|
18 | + /** |
|
19 | + * @param $required_permission |
|
20 | + * @param $attempted_calculation |
|
21 | + * @throws RestException |
|
22 | + */ |
|
23 | + protected function verifyCurrentUserCan($required_permission, $attempted_calculation) |
|
24 | + { |
|
25 | + if (! current_user_can($required_permission)) { |
|
26 | + throw new RestException( |
|
27 | + 'permission_denied', |
|
28 | + sprintf( |
|
29 | + esc_html__( |
|
30 | + // @codingStandardsIgnoreStart |
|
31 | + 'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', |
|
32 | + // @codingStandardsIgnoreEnd |
|
33 | + 'event_espresso' |
|
34 | + ), |
|
35 | + $attempted_calculation, |
|
36 | + EEH_Inflector::pluralize_and_lower($this->getResourceName()), |
|
37 | + $required_permission |
|
38 | + ) |
|
39 | + ); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * Gets the name of the resource of the called class |
|
46 | - * |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function getResourceName() |
|
50 | - { |
|
51 | - return substr(__CLASS__, strrpos(__CLASS__, '\\') + 1); |
|
52 | - } |
|
44 | + /** |
|
45 | + * Gets the name of the resource of the called class |
|
46 | + * |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function getResourceName() |
|
50 | + { |
|
51 | + return substr(__CLASS__, strrpos(__CLASS__, '\\') + 1); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Returns an array to be used for the schema for the calculated fields. |
|
56 | - * @since 4.9.68.p |
|
57 | - * @return array keys are calculated field names (eg "optimum_sales_at_start") values are arrays { |
|
58 | - * @type string $description |
|
59 | - * @type string $type, eg "string", "int", "boolean", "object", "array", etc |
|
60 | - * } |
|
61 | - */ |
|
62 | - public function schemaForCalculations() |
|
63 | - { |
|
64 | - return array(); |
|
65 | - } |
|
54 | + /** |
|
55 | + * Returns an array to be used for the schema for the calculated fields. |
|
56 | + * @since 4.9.68.p |
|
57 | + * @return array keys are calculated field names (eg "optimum_sales_at_start") values are arrays { |
|
58 | + * @type string $description |
|
59 | + * @type string $type, eg "string", "int", "boolean", "object", "array", etc |
|
60 | + * } |
|
61 | + */ |
|
62 | + public function schemaForCalculations() |
|
63 | + { |
|
64 | + return array(); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Returns the json schema for the given calculation index. |
|
69 | - * |
|
70 | - * @since 4.9.68.p |
|
71 | - * @param $calculation_index |
|
72 | - * @return array |
|
73 | - */ |
|
74 | - public function schemaForCalculation($calculation_index) |
|
75 | - { |
|
76 | - $schema_map = $this->schemaForCalculations(); |
|
77 | - return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array(); |
|
78 | - } |
|
67 | + /** |
|
68 | + * Returns the json schema for the given calculation index. |
|
69 | + * |
|
70 | + * @since 4.9.68.p |
|
71 | + * @param $calculation_index |
|
72 | + * @return array |
|
73 | + */ |
|
74 | + public function schemaForCalculation($calculation_index) |
|
75 | + { |
|
76 | + $schema_map = $this->schemaForCalculations(); |
|
77 | + return isset($schema_map[ $calculation_index ]) ? $schema_map[ $calculation_index ] : array(); |
|
78 | + } |
|
79 | 79 | } |
@@ -80,7 +80,7 @@ |
||
80 | 80 | extract($attributes, EXTR_OVERWRITE); |
81 | 81 | $event_id = isset($event_id) ? $event_id : 0; |
82 | 82 | $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
83 | - if (! $event instanceof EE_Event) { |
|
83 | + if ( ! $event instanceof EE_Event) { |
|
84 | 84 | if (WP_DEBUG === true && current_user_can('edit_pages')) { |
85 | 85 | new ExceptionStackTraceDisplay( |
86 | 86 | new InvalidArgumentException( |
@@ -22,92 +22,92 @@ |
||
22 | 22 | */ |
23 | 23 | class EspressoTicketSelector extends EspressoShortcode |
24 | 24 | { |
25 | - /** |
|
26 | - * the actual shortcode tag that gets registered with WordPress |
|
27 | - * |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function getTag() |
|
31 | - { |
|
32 | - return 'ESPRESSO_TICKET_SELECTOR'; |
|
33 | - } |
|
25 | + /** |
|
26 | + * the actual shortcode tag that gets registered with WordPress |
|
27 | + * |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function getTag() |
|
31 | + { |
|
32 | + return 'ESPRESSO_TICKET_SELECTOR'; |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * the time in seconds to cache the results of the processShortcode() method |
|
38 | - * 0 means the processShortcode() results will NOT be cached at all |
|
39 | - * |
|
40 | - * @return int |
|
41 | - */ |
|
42 | - public function cacheExpiration() |
|
43 | - { |
|
44 | - return 0; |
|
45 | - } |
|
36 | + /** |
|
37 | + * the time in seconds to cache the results of the processShortcode() method |
|
38 | + * 0 means the processShortcode() results will NOT be cached at all |
|
39 | + * |
|
40 | + * @return int |
|
41 | + */ |
|
42 | + public function cacheExpiration() |
|
43 | + { |
|
44 | + return 0; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | - * this may be required for shortcodes that utilize a corresponding module, |
|
51 | - * and need to enqueue assets for that module |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function initializeShortcode() |
|
56 | - { |
|
57 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
58 | - $this->shortcodeHasBeenInitialized(); |
|
59 | - } |
|
48 | + /** |
|
49 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | + * this may be required for shortcodes that utilize a corresponding module, |
|
51 | + * and need to enqueue assets for that module |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function initializeShortcode() |
|
56 | + { |
|
57 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
58 | + $this->shortcodeHasBeenInitialized(); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * callback that runs when the shortcode is encountered in post content. |
|
64 | - * IMPORTANT !!! |
|
65 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
66 | - * |
|
67 | - * @param array $attributes |
|
68 | - * @return string |
|
69 | - * @throws InvalidArgumentException |
|
70 | - * @throws EE_Error |
|
71 | - * @throws InvalidDataTypeException |
|
72 | - * @throws InvalidInterfaceException |
|
73 | - * @throws ReflectionException |
|
74 | - * @throws Exception |
|
75 | - */ |
|
76 | - public function processShortcode($attributes = array()) |
|
77 | - { |
|
78 | - extract($attributes, EXTR_OVERWRITE); |
|
79 | - $event_id = isset($event_id) ? $event_id : 0; |
|
80 | - $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
81 | - if (! $event instanceof EE_Event) { |
|
82 | - if (WP_DEBUG === true && current_user_can('edit_pages')) { |
|
83 | - new ExceptionStackTraceDisplay( |
|
84 | - new InvalidArgumentException( |
|
85 | - sprintf( |
|
86 | - esc_html__( |
|
87 | - 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that its value corresponds to a valid Event ID.', |
|
88 | - 'event_espresso' |
|
89 | - ), |
|
90 | - $this->getTag(), |
|
91 | - $event_id, |
|
92 | - 'event_id', |
|
93 | - '<br />' |
|
94 | - ) |
|
95 | - ) |
|
96 | - ); |
|
97 | - return ''; |
|
98 | - } |
|
99 | - return sprintf( |
|
100 | - esc_html__( |
|
101 | - 'An Event with an ID of "%s" could not be found. Please contact the event administrator for assistance.', |
|
102 | - 'event_espresso' |
|
103 | - ), |
|
104 | - $event_id |
|
105 | - ); |
|
106 | - } |
|
107 | - ob_start(); |
|
108 | - do_action('AHEE_event_details_before_post', $event_id); |
|
109 | - espresso_ticket_selector($event); |
|
110 | - do_action('AHEE_event_details_after_post'); |
|
111 | - return ob_get_clean(); |
|
112 | - } |
|
62 | + /** |
|
63 | + * callback that runs when the shortcode is encountered in post content. |
|
64 | + * IMPORTANT !!! |
|
65 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
66 | + * |
|
67 | + * @param array $attributes |
|
68 | + * @return string |
|
69 | + * @throws InvalidArgumentException |
|
70 | + * @throws EE_Error |
|
71 | + * @throws InvalidDataTypeException |
|
72 | + * @throws InvalidInterfaceException |
|
73 | + * @throws ReflectionException |
|
74 | + * @throws Exception |
|
75 | + */ |
|
76 | + public function processShortcode($attributes = array()) |
|
77 | + { |
|
78 | + extract($attributes, EXTR_OVERWRITE); |
|
79 | + $event_id = isset($event_id) ? $event_id : 0; |
|
80 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
81 | + if (! $event instanceof EE_Event) { |
|
82 | + if (WP_DEBUG === true && current_user_can('edit_pages')) { |
|
83 | + new ExceptionStackTraceDisplay( |
|
84 | + new InvalidArgumentException( |
|
85 | + sprintf( |
|
86 | + esc_html__( |
|
87 | + 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that its value corresponds to a valid Event ID.', |
|
88 | + 'event_espresso' |
|
89 | + ), |
|
90 | + $this->getTag(), |
|
91 | + $event_id, |
|
92 | + 'event_id', |
|
93 | + '<br />' |
|
94 | + ) |
|
95 | + ) |
|
96 | + ); |
|
97 | + return ''; |
|
98 | + } |
|
99 | + return sprintf( |
|
100 | + esc_html__( |
|
101 | + 'An Event with an ID of "%s" could not be found. Please contact the event administrator for assistance.', |
|
102 | + 'event_espresso' |
|
103 | + ), |
|
104 | + $event_id |
|
105 | + ); |
|
106 | + } |
|
107 | + ob_start(); |
|
108 | + do_action('AHEE_event_details_before_post', $event_id); |
|
109 | + espresso_ticket_selector($event); |
|
110 | + do_action('AHEE_event_details_after_post'); |
|
111 | + return ob_get_clean(); |
|
112 | + } |
|
113 | 113 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
260 | 260 | 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
261 | 261 | 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
262 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
262 | + 'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css', |
|
263 | 263 | 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
264 | 264 | ); |
265 | 265 | $this->_deregister_wp_hooks(); |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | $invoice_name = $this->_subject; |
324 | 324 | |
325 | 325 | // only load dompdf if nobody else has yet... |
326 | - if (! class_exists('Dompdf\Dompdf')) { |
|
327 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
326 | + if ( ! class_exists('Dompdf\Dompdf')) { |
|
327 | + require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php'); |
|
328 | 328 | Dompdf\Autoloader::register(); |
329 | 329 | } |
330 | 330 | $options = new Dompdf\Options(); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $dompdf->loadHtml($content); |
337 | 337 | $dompdf->render(); |
338 | 338 | // forcing the browser to open a download dialog. |
339 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
339 | + $dompdf->stream($invoice_name.".pdf", array('Attachment' => true)); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 |
@@ -13,349 +13,349 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_Pdf_messenger extends EE_messenger |
15 | 15 | { |
16 | - /** |
|
17 | - * The following are the properties that this messenger requires for generating pdf |
|
18 | - */ |
|
19 | - |
|
20 | - /** |
|
21 | - * This is the pdf body generated by the template via the message type. |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - protected $_content; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * This is for the page title that gets displayed. This will end up being the filename for the generated pdf. |
|
30 | - * |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - protected $_subject; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @return EE_Pdf_messenger |
|
38 | - */ |
|
39 | - public function __construct() |
|
40 | - { |
|
41 | - // set properties |
|
42 | - $this->name = 'pdf'; |
|
43 | - $this->description = esc_html__('This messenger is used for generating a pdf version of the message.', 'event_espresso'); |
|
44 | - $this->label = array( |
|
45 | - 'singular' => esc_html__('PDF', 'event_espresso'), |
|
46 | - 'plural' => esc_html__('PDFs', 'event_espresso') |
|
47 | - ); |
|
48 | - $this->activate_on_install = true; |
|
49 | - |
|
50 | - parent::__construct(); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * PDF Messenger desires execution immediately. |
|
56 | - * @see parent::send_now() for documentation. |
|
57 | - * @since 4.9.0 |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - public function send_now() |
|
61 | - { |
|
62 | - return true; |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * HTML Messenger allows an empty to field. |
|
68 | - * @see parent::allow_empty_to_field() for documentation |
|
69 | - * @since 4.9.0 |
|
70 | - * @return bool |
|
71 | - */ |
|
72 | - public function allow_empty_to_field() |
|
73 | - { |
|
74 | - return true; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @see abstract declaration in EE_messenger for details. |
|
80 | - */ |
|
81 | - protected function _set_admin_pages() |
|
82 | - { |
|
83 | - $this->admin_registered_pages = array('events_edit' => false); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @see abstract declaration in EE_messenger for details. |
|
89 | - */ |
|
90 | - protected function _set_valid_shortcodes() |
|
91 | - { |
|
92 | - $this->_valid_shortcodes = array(); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @see abstract declaration in EE_messenger for details. |
|
98 | - */ |
|
99 | - protected function _set_validator_config() |
|
100 | - { |
|
101 | - $this->_validator_config = array( |
|
102 | - 'subject' => array( |
|
103 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
104 | - ), |
|
105 | - 'content' => array( |
|
106 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
107 | - ), |
|
108 | - 'attendee_list' => array( |
|
109 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
110 | - 'required' => array('[ATTENDEE_LIST]') |
|
111 | - ), |
|
112 | - 'event_list' => array( |
|
113 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'), |
|
114 | - 'required' => array('[EVENT_LIST]') |
|
115 | - ), |
|
116 | - 'ticket_list' => array( |
|
117 | - 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
118 | - 'required' => array('[TICKET_LIST]') |
|
119 | - ), |
|
120 | - 'datetime_list' => array( |
|
121 | - 'shortcodes' => array('datetime'), |
|
122 | - 'required' => array('[DATETIME_LIST]') |
|
123 | - ), |
|
124 | - ); |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this messenger can add their own js. |
|
130 | - * |
|
131 | - * @return void. |
|
132 | - */ |
|
133 | - public function enqueue_scripts_styles() |
|
134 | - { |
|
135 | - parent::enqueue_scripts_styles(); |
|
136 | - do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * _set_template_fields |
|
142 | - * This sets up the fields that a messenger requires for the message to go out. |
|
143 | - * |
|
144 | - * @access protected |
|
145 | - * @return void |
|
146 | - */ |
|
147 | - protected function _set_template_fields() |
|
148 | - { |
|
149 | - // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to. This is important for the Messages_admin to know what fields to display to the user. Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed. |
|
150 | - $this->_template_fields = array( |
|
151 | - 'subject' => array( |
|
152 | - 'input' => 'text', |
|
153 | - 'label' => esc_html__('Page Title', 'event_espresso'), |
|
154 | - 'type' => 'string', |
|
155 | - 'required' => true, |
|
156 | - 'validation' => true, |
|
157 | - 'css_class' => 'large-text', |
|
158 | - 'format' => '%s' |
|
159 | - ), |
|
160 | - 'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
161 | - 'extra' => array( |
|
162 | - 'content' => array( |
|
163 | - 'main' => array( |
|
164 | - 'input' => 'wp_editor', |
|
165 | - 'label' => esc_html__('Main Content', 'event_espresso'), |
|
166 | - 'type' => 'string', |
|
167 | - 'required' => true, |
|
168 | - 'validation' => true, |
|
169 | - 'format' => '%s', |
|
170 | - 'rows' => '15' |
|
171 | - ), |
|
172 | - 'event_list' => array( |
|
173 | - 'input' => 'wp_editor', |
|
174 | - 'label' => '[EVENT_LIST]', |
|
175 | - 'type' => 'string', |
|
176 | - 'required' => true, |
|
177 | - 'validation' => true, |
|
178 | - 'format' => '%s', |
|
179 | - 'rows' => '15', |
|
180 | - 'shortcodes_required' => array('[EVENT_LIST]') |
|
181 | - ), |
|
182 | - 'attendee_list' => array( |
|
183 | - 'input' => 'textarea', |
|
184 | - 'label' => '[ATTENDEE_LIST]', |
|
185 | - 'type' => 'string', |
|
186 | - 'required' => true, |
|
187 | - 'validation' => true, |
|
188 | - 'format' => '%s', |
|
189 | - 'css_class' => 'large-text', |
|
190 | - 'rows' => '5', |
|
191 | - 'shortcodes_required' => array('[ATTENDEE_LIST]') |
|
192 | - ), |
|
193 | - 'ticket_list' => array( |
|
194 | - 'input' => 'textarea', |
|
195 | - 'label' => '[TICKET_LIST]', |
|
196 | - 'type' => 'string', |
|
197 | - 'required' => true, |
|
198 | - 'validation' => true, |
|
199 | - 'format' => '%s', |
|
200 | - 'css_class' => 'large-text', |
|
201 | - 'rows' => '10', |
|
202 | - 'shortcodes_required' => array('[TICKET_LIST]') |
|
203 | - ), |
|
204 | - 'datetime_list' => array( |
|
205 | - 'input' => 'textarea', |
|
206 | - 'label' => '[DATETIME_LIST]', |
|
207 | - 'type' => 'string', |
|
208 | - 'required' => true, |
|
209 | - 'validation' => true, |
|
210 | - 'format' => '%s', |
|
211 | - 'css_class' => 'large-text', |
|
212 | - 'rows' => '10', |
|
213 | - 'shortcodes_required' => array('[DATETIME_LIST]') |
|
214 | - ) |
|
215 | - ) |
|
216 | - ) |
|
217 | - ); |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * @see definition of this method in parent |
|
223 | - * |
|
224 | - * @since 4.5.0 |
|
225 | - * |
|
226 | - */ |
|
227 | - protected function _set_default_message_types() |
|
228 | - { |
|
229 | - // note currently PDF is only a secondary messenger so it never has any associated message types. |
|
230 | - $this->_default_message_types = array(); |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - /** |
|
235 | - * @see definition of this method in parent |
|
236 | - * |
|
237 | - * @since 4.5.0 |
|
238 | - */ |
|
239 | - protected function _set_valid_message_types() |
|
240 | - { |
|
241 | - $this->_valid_message_types = array(); |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * Generates html version of the message content and then sends it to the pdf generator. |
|
247 | - * |
|
248 | - * |
|
249 | - * @since 4.5.0 |
|
250 | - * |
|
251 | - * @return string. |
|
252 | - */ |
|
253 | - protected function _send_message() |
|
254 | - { |
|
255 | - $this->_template_args = array( |
|
256 | - 'page_title' => $this->_subject, |
|
257 | - 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
|
258 | - 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
|
259 | - 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
|
260 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
261 | - 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
|
262 | - ); |
|
263 | - $this->_deregister_wp_hooks(); |
|
264 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
265 | - $content = $this->_get_main_template(); |
|
16 | + /** |
|
17 | + * The following are the properties that this messenger requires for generating pdf |
|
18 | + */ |
|
19 | + |
|
20 | + /** |
|
21 | + * This is the pdf body generated by the template via the message type. |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + protected $_content; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * This is for the page title that gets displayed. This will end up being the filename for the generated pdf. |
|
30 | + * |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + protected $_subject; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @return EE_Pdf_messenger |
|
38 | + */ |
|
39 | + public function __construct() |
|
40 | + { |
|
41 | + // set properties |
|
42 | + $this->name = 'pdf'; |
|
43 | + $this->description = esc_html__('This messenger is used for generating a pdf version of the message.', 'event_espresso'); |
|
44 | + $this->label = array( |
|
45 | + 'singular' => esc_html__('PDF', 'event_espresso'), |
|
46 | + 'plural' => esc_html__('PDFs', 'event_espresso') |
|
47 | + ); |
|
48 | + $this->activate_on_install = true; |
|
49 | + |
|
50 | + parent::__construct(); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * PDF Messenger desires execution immediately. |
|
56 | + * @see parent::send_now() for documentation. |
|
57 | + * @since 4.9.0 |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + public function send_now() |
|
61 | + { |
|
62 | + return true; |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * HTML Messenger allows an empty to field. |
|
68 | + * @see parent::allow_empty_to_field() for documentation |
|
69 | + * @since 4.9.0 |
|
70 | + * @return bool |
|
71 | + */ |
|
72 | + public function allow_empty_to_field() |
|
73 | + { |
|
74 | + return true; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @see abstract declaration in EE_messenger for details. |
|
80 | + */ |
|
81 | + protected function _set_admin_pages() |
|
82 | + { |
|
83 | + $this->admin_registered_pages = array('events_edit' => false); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @see abstract declaration in EE_messenger for details. |
|
89 | + */ |
|
90 | + protected function _set_valid_shortcodes() |
|
91 | + { |
|
92 | + $this->_valid_shortcodes = array(); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @see abstract declaration in EE_messenger for details. |
|
98 | + */ |
|
99 | + protected function _set_validator_config() |
|
100 | + { |
|
101 | + $this->_validator_config = array( |
|
102 | + 'subject' => array( |
|
103 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
104 | + ), |
|
105 | + 'content' => array( |
|
106 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
107 | + ), |
|
108 | + 'attendee_list' => array( |
|
109 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
110 | + 'required' => array('[ATTENDEE_LIST]') |
|
111 | + ), |
|
112 | + 'event_list' => array( |
|
113 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'), |
|
114 | + 'required' => array('[EVENT_LIST]') |
|
115 | + ), |
|
116 | + 'ticket_list' => array( |
|
117 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
118 | + 'required' => array('[TICKET_LIST]') |
|
119 | + ), |
|
120 | + 'datetime_list' => array( |
|
121 | + 'shortcodes' => array('datetime'), |
|
122 | + 'required' => array('[DATETIME_LIST]') |
|
123 | + ), |
|
124 | + ); |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this messenger can add their own js. |
|
130 | + * |
|
131 | + * @return void. |
|
132 | + */ |
|
133 | + public function enqueue_scripts_styles() |
|
134 | + { |
|
135 | + parent::enqueue_scripts_styles(); |
|
136 | + do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * _set_template_fields |
|
142 | + * This sets up the fields that a messenger requires for the message to go out. |
|
143 | + * |
|
144 | + * @access protected |
|
145 | + * @return void |
|
146 | + */ |
|
147 | + protected function _set_template_fields() |
|
148 | + { |
|
149 | + // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to. This is important for the Messages_admin to know what fields to display to the user. Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed. |
|
150 | + $this->_template_fields = array( |
|
151 | + 'subject' => array( |
|
152 | + 'input' => 'text', |
|
153 | + 'label' => esc_html__('Page Title', 'event_espresso'), |
|
154 | + 'type' => 'string', |
|
155 | + 'required' => true, |
|
156 | + 'validation' => true, |
|
157 | + 'css_class' => 'large-text', |
|
158 | + 'format' => '%s' |
|
159 | + ), |
|
160 | + 'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
161 | + 'extra' => array( |
|
162 | + 'content' => array( |
|
163 | + 'main' => array( |
|
164 | + 'input' => 'wp_editor', |
|
165 | + 'label' => esc_html__('Main Content', 'event_espresso'), |
|
166 | + 'type' => 'string', |
|
167 | + 'required' => true, |
|
168 | + 'validation' => true, |
|
169 | + 'format' => '%s', |
|
170 | + 'rows' => '15' |
|
171 | + ), |
|
172 | + 'event_list' => array( |
|
173 | + 'input' => 'wp_editor', |
|
174 | + 'label' => '[EVENT_LIST]', |
|
175 | + 'type' => 'string', |
|
176 | + 'required' => true, |
|
177 | + 'validation' => true, |
|
178 | + 'format' => '%s', |
|
179 | + 'rows' => '15', |
|
180 | + 'shortcodes_required' => array('[EVENT_LIST]') |
|
181 | + ), |
|
182 | + 'attendee_list' => array( |
|
183 | + 'input' => 'textarea', |
|
184 | + 'label' => '[ATTENDEE_LIST]', |
|
185 | + 'type' => 'string', |
|
186 | + 'required' => true, |
|
187 | + 'validation' => true, |
|
188 | + 'format' => '%s', |
|
189 | + 'css_class' => 'large-text', |
|
190 | + 'rows' => '5', |
|
191 | + 'shortcodes_required' => array('[ATTENDEE_LIST]') |
|
192 | + ), |
|
193 | + 'ticket_list' => array( |
|
194 | + 'input' => 'textarea', |
|
195 | + 'label' => '[TICKET_LIST]', |
|
196 | + 'type' => 'string', |
|
197 | + 'required' => true, |
|
198 | + 'validation' => true, |
|
199 | + 'format' => '%s', |
|
200 | + 'css_class' => 'large-text', |
|
201 | + 'rows' => '10', |
|
202 | + 'shortcodes_required' => array('[TICKET_LIST]') |
|
203 | + ), |
|
204 | + 'datetime_list' => array( |
|
205 | + 'input' => 'textarea', |
|
206 | + 'label' => '[DATETIME_LIST]', |
|
207 | + 'type' => 'string', |
|
208 | + 'required' => true, |
|
209 | + 'validation' => true, |
|
210 | + 'format' => '%s', |
|
211 | + 'css_class' => 'large-text', |
|
212 | + 'rows' => '10', |
|
213 | + 'shortcodes_required' => array('[DATETIME_LIST]') |
|
214 | + ) |
|
215 | + ) |
|
216 | + ) |
|
217 | + ); |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * @see definition of this method in parent |
|
223 | + * |
|
224 | + * @since 4.5.0 |
|
225 | + * |
|
226 | + */ |
|
227 | + protected function _set_default_message_types() |
|
228 | + { |
|
229 | + // note currently PDF is only a secondary messenger so it never has any associated message types. |
|
230 | + $this->_default_message_types = array(); |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + /** |
|
235 | + * @see definition of this method in parent |
|
236 | + * |
|
237 | + * @since 4.5.0 |
|
238 | + */ |
|
239 | + protected function _set_valid_message_types() |
|
240 | + { |
|
241 | + $this->_valid_message_types = array(); |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * Generates html version of the message content and then sends it to the pdf generator. |
|
247 | + * |
|
248 | + * |
|
249 | + * @since 4.5.0 |
|
250 | + * |
|
251 | + * @return string. |
|
252 | + */ |
|
253 | + protected function _send_message() |
|
254 | + { |
|
255 | + $this->_template_args = array( |
|
256 | + 'page_title' => $this->_subject, |
|
257 | + 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
|
258 | + 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
|
259 | + 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
|
260 | + 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
261 | + 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
|
262 | + ); |
|
263 | + $this->_deregister_wp_hooks(); |
|
264 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
265 | + $content = $this->_get_main_template(); |
|
266 | 266 | // die( $content ); |
267 | - $this->_do_pdf($content); |
|
268 | - exit(0); |
|
269 | - } |
|
270 | - |
|
271 | - |
|
272 | - /** |
|
273 | - * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates. If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook. |
|
274 | - * |
|
275 | - * @since 4.5.0 |
|
276 | - * |
|
277 | - * @return void |
|
278 | - */ |
|
279 | - protected function _deregister_wp_hooks() |
|
280 | - { |
|
281 | - remove_all_actions('wp_head'); |
|
282 | - remove_all_actions('wp_footer'); |
|
283 | - remove_all_actions('wp_print_footer_scripts'); |
|
284 | - remove_all_actions('wp_enqueue_scripts'); |
|
285 | - global $wp_scripts, $wp_styles; |
|
286 | - $wp_scripts = $wp_styles = array(); |
|
287 | - |
|
288 | - // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
289 | - add_action('wp_head', 'wp_enqueue_scripts'); |
|
290 | - add_action('wp_footer', 'wp_print_footer_scripts'); |
|
291 | - add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
292 | - } |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * Overwrite parent _get_main_template for pdf purposes. |
|
297 | - * |
|
298 | - * @since 4.5.0 |
|
299 | - * |
|
300 | - * @param bool $preview |
|
301 | - * @return string |
|
302 | - */ |
|
303 | - protected function _get_main_template($preview = false) |
|
304 | - { |
|
305 | - $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
306 | - // add message type to template_args |
|
307 | - $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
308 | - return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * This takes care of loading the dompdf library and generating the actual pdf |
|
314 | - * |
|
315 | - * @param string $content This is the generated html content being converted into a pdf. |
|
316 | - * |
|
317 | - * @return void |
|
318 | - */ |
|
319 | - protected function _do_pdf($content = '') |
|
320 | - { |
|
321 | - $invoice_name = $this->_subject; |
|
322 | - |
|
323 | - // only load dompdf if nobody else has yet... |
|
324 | - if (! class_exists('Dompdf\Dompdf')) { |
|
325 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
326 | - Dompdf\Autoloader::register(); |
|
327 | - } |
|
328 | - $options = new Dompdf\Options(); |
|
329 | - $options->set('isRemoteEnabled', true); |
|
330 | - $options->set('isJavascriptEnabled', false); |
|
331 | - if (defined('DOMPDF_FONT_DIR')) { |
|
332 | - $options->setFontDir(DOMPDF_FONT_DIR); |
|
333 | - $options->setFontCache(DOMPDF_FONT_DIR); |
|
334 | - } |
|
335 | - // Allow changing the paper size. |
|
336 | - if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
|
337 | - $options->set('defaultPaperSize', DOMPDF_DEFAULT_PAPER_SIZE); |
|
338 | - } |
|
339 | - $dompdf = new Dompdf\Dompdf($options); |
|
340 | - // Remove all spaces between HTML tags |
|
341 | - $content = preg_replace('/>\s+</', '><', $content); |
|
342 | - $dompdf->loadHtml($content); |
|
343 | - $dompdf->render(); |
|
344 | - // forcing the browser to open a download dialog. |
|
345 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * @return string |
|
351 | - */ |
|
352 | - protected function _preview() |
|
353 | - { |
|
354 | - return $this->_send_message(); |
|
355 | - } |
|
356 | - |
|
357 | - |
|
358 | - protected function _set_admin_settings_fields() |
|
359 | - { |
|
360 | - } |
|
267 | + $this->_do_pdf($content); |
|
268 | + exit(0); |
|
269 | + } |
|
270 | + |
|
271 | + |
|
272 | + /** |
|
273 | + * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates. If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook. |
|
274 | + * |
|
275 | + * @since 4.5.0 |
|
276 | + * |
|
277 | + * @return void |
|
278 | + */ |
|
279 | + protected function _deregister_wp_hooks() |
|
280 | + { |
|
281 | + remove_all_actions('wp_head'); |
|
282 | + remove_all_actions('wp_footer'); |
|
283 | + remove_all_actions('wp_print_footer_scripts'); |
|
284 | + remove_all_actions('wp_enqueue_scripts'); |
|
285 | + global $wp_scripts, $wp_styles; |
|
286 | + $wp_scripts = $wp_styles = array(); |
|
287 | + |
|
288 | + // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
289 | + add_action('wp_head', 'wp_enqueue_scripts'); |
|
290 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
291 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
292 | + } |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * Overwrite parent _get_main_template for pdf purposes. |
|
297 | + * |
|
298 | + * @since 4.5.0 |
|
299 | + * |
|
300 | + * @param bool $preview |
|
301 | + * @return string |
|
302 | + */ |
|
303 | + protected function _get_main_template($preview = false) |
|
304 | + { |
|
305 | + $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
306 | + // add message type to template_args |
|
307 | + $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
308 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * This takes care of loading the dompdf library and generating the actual pdf |
|
314 | + * |
|
315 | + * @param string $content This is the generated html content being converted into a pdf. |
|
316 | + * |
|
317 | + * @return void |
|
318 | + */ |
|
319 | + protected function _do_pdf($content = '') |
|
320 | + { |
|
321 | + $invoice_name = $this->_subject; |
|
322 | + |
|
323 | + // only load dompdf if nobody else has yet... |
|
324 | + if (! class_exists('Dompdf\Dompdf')) { |
|
325 | + require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
326 | + Dompdf\Autoloader::register(); |
|
327 | + } |
|
328 | + $options = new Dompdf\Options(); |
|
329 | + $options->set('isRemoteEnabled', true); |
|
330 | + $options->set('isJavascriptEnabled', false); |
|
331 | + if (defined('DOMPDF_FONT_DIR')) { |
|
332 | + $options->setFontDir(DOMPDF_FONT_DIR); |
|
333 | + $options->setFontCache(DOMPDF_FONT_DIR); |
|
334 | + } |
|
335 | + // Allow changing the paper size. |
|
336 | + if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
|
337 | + $options->set('defaultPaperSize', DOMPDF_DEFAULT_PAPER_SIZE); |
|
338 | + } |
|
339 | + $dompdf = new Dompdf\Dompdf($options); |
|
340 | + // Remove all spaces between HTML tags |
|
341 | + $content = preg_replace('/>\s+</', '><', $content); |
|
342 | + $dompdf->loadHtml($content); |
|
343 | + $dompdf->render(); |
|
344 | + // forcing the browser to open a download dialog. |
|
345 | + $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * @return string |
|
351 | + */ |
|
352 | + protected function _preview() |
|
353 | + { |
|
354 | + return $this->_send_message(); |
|
355 | + } |
|
356 | + |
|
357 | + |
|
358 | + protected function _set_admin_settings_fields() |
|
359 | + { |
|
360 | + } |
|
361 | 361 | } |
@@ -16,16 +16,16 @@ |
||
16 | 16 | */ |
17 | 17 | class URLValidator |
18 | 18 | { |
19 | - /** |
|
20 | - * Returns whether or not the URL is valid |
|
21 | - * @since 4.9.68.p |
|
22 | - * @param $url |
|
23 | - * @return boolean |
|
24 | - */ |
|
25 | - public function isValid($url) |
|
26 | - { |
|
27 | - return esc_url_raw($url) === $url; |
|
28 | - } |
|
19 | + /** |
|
20 | + * Returns whether or not the URL is valid |
|
21 | + * @since 4.9.68.p |
|
22 | + * @param $url |
|
23 | + * @return boolean |
|
24 | + */ |
|
25 | + public function isValid($url) |
|
26 | + { |
|
27 | + return esc_url_raw($url) === $url; |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | // End of file URLValidator.php |
31 | 31 | // Location: ${NAMESPACE}/URLValidator.php |
@@ -44,43 +44,43 @@ discard block |
||
44 | 44 | ); |
45 | 45 | $this->_wp_core_model = true; |
46 | 46 | $path_to_tax_model = 'Term_Taxonomy'; |
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
47 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
48 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
49 | 49 | $path_to_tax_model |
50 | 50 | ); |
51 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
52 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
53 | - $path_to_tax_model = $path_to_tax_model . '.'; |
|
51 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
|
52 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
|
53 | + $path_to_tax_model = $path_to_tax_model.'.'; |
|
54 | 54 | // add cap restrictions for editing relating to the "ee_edit_*" |
55 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
55 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
56 | 56 | array( |
57 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
57 | + $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
58 | 58 | ) |
59 | 59 | ); |
60 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
60 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
61 | 61 | array( |
62 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
62 | + $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
63 | 63 | ) |
64 | 64 | ); |
65 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
65 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
66 | 66 | array( |
67 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
67 | + $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | // add cap restrictions for deleting relating to the "ee_deleting_*" |
71 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
71 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
72 | 72 | array( |
73 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
73 | + $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
74 | 74 | ) |
75 | 75 | ); |
76 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
76 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
77 | 77 | array( |
78 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
78 | + $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
79 | 79 | ) |
80 | 80 | ); |
81 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
81 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
82 | 82 | array( |
83 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
83 | + $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
84 | 84 | ) |
85 | 85 | ); |
86 | 86 | parent::__construct($timezone); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | $post_tag_row = reset($post_tag_results); |
187 | 187 | $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
188 | - if (! $post_tag instanceof EE_Term) { |
|
188 | + if ( ! $post_tag instanceof EE_Term) { |
|
189 | 189 | return null; |
190 | 190 | } |
191 | 191 | |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | ) |
217 | 217 | ); |
218 | 218 | foreach ($post_tags as $key => $post_tag) { |
219 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
220 | - $post_tags[ $key ]->post_type = array(); |
|
219 | + if ( ! isset($post_tags[$key]->post_type)) { |
|
220 | + $post_tags[$key]->post_type = array(); |
|
221 | 221 | } |
222 | - $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
222 | + $post_tags[$key]->post_type[] = 'espresso_events'; |
|
223 | 223 | } |
224 | 224 | return $post_tags; |
225 | 225 | } |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | ) |
245 | 245 | ); |
246 | 246 | foreach ($post_tags as $key => $post_tag) { |
247 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
248 | - $post_tags[ $key ]->post_type = array(); |
|
247 | + if ( ! isset($post_tags[$key]->post_type)) { |
|
248 | + $post_tags[$key]->post_type = array(); |
|
249 | 249 | } |
250 | - $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
250 | + $post_tags[$key]->post_type[] = 'espresso_venues'; |
|
251 | 251 | } |
252 | 252 | return $post_tags; |
253 | 253 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | { |
268 | 268 | if ($model === EEM_Term::instance()) { |
269 | 269 | $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
270 | - if (! empty($taxonomies)) { |
|
270 | + if ( ! empty($taxonomies)) { |
|
271 | 271 | $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
272 | 272 | } |
273 | 273 | } |
@@ -13,263 +13,263 @@ |
||
13 | 13 | */ |
14 | 14 | class EEM_Term extends EEM_Base |
15 | 15 | { |
16 | - // private instance of the Attendee object |
|
17 | - protected static $_instance = null; |
|
16 | + // private instance of the Attendee object |
|
17 | + protected static $_instance = null; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - *__construct |
|
23 | - * |
|
24 | - * @param string $timezone |
|
25 | - */ |
|
26 | - protected function __construct($timezone = null) |
|
27 | - { |
|
28 | - $this->singular_item = esc_html__('Term', 'event_espresso'); |
|
29 | - $this->plural_item = esc_html__('Terms', 'event_espresso'); |
|
30 | - $this->_tables = array( |
|
31 | - 'Term' => new EE_Primary_Table('terms', 'term_id'), |
|
32 | - ); |
|
33 | - $this->_fields = array( |
|
34 | - 'Term' => array( |
|
35 | - 'term_id' => new EE_Primary_Key_Int_Field('term_id', esc_html__('Term ID', 'event_espresso')), |
|
36 | - 'name' => new EE_Plain_Text_Field('name', esc_html__('Term Name', 'event_espresso'), false, ''), |
|
37 | - 'slug' => new EE_Slug_Field('slug', esc_html__('Term Slug', 'event_espresso'), false), |
|
38 | - 'term_group' => new EE_Integer_Field('term_group', esc_html__("Term Group", "event_espresso"), false, 0), |
|
39 | - ), |
|
40 | - ); |
|
41 | - $this->_model_relations = array( |
|
42 | - 'Term_Taxonomy' => new EE_Has_Many_Relation(), |
|
43 | - ); |
|
44 | - $this->_wp_core_model = true; |
|
45 | - $path_to_tax_model = 'Term_Taxonomy'; |
|
46 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
48 | - $path_to_tax_model |
|
49 | - ); |
|
50 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
51 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
52 | - $path_to_tax_model = $path_to_tax_model . '.'; |
|
53 | - // add cap restrictions for editing relating to the "ee_edit_*" |
|
54 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
55 | - array( |
|
56 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
57 | - ) |
|
58 | - ); |
|
59 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
60 | - array( |
|
61 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
62 | - ) |
|
63 | - ); |
|
64 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
65 | - array( |
|
66 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
67 | - ) |
|
68 | - ); |
|
69 | - // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
70 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
71 | - array( |
|
72 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
73 | - ) |
|
74 | - ); |
|
75 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
76 | - array( |
|
77 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
78 | - ) |
|
79 | - ); |
|
80 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
81 | - array( |
|
82 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
83 | - ) |
|
84 | - ); |
|
85 | - parent::__construct($timezone); |
|
86 | - add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3); |
|
87 | - } |
|
21 | + /** |
|
22 | + *__construct |
|
23 | + * |
|
24 | + * @param string $timezone |
|
25 | + */ |
|
26 | + protected function __construct($timezone = null) |
|
27 | + { |
|
28 | + $this->singular_item = esc_html__('Term', 'event_espresso'); |
|
29 | + $this->plural_item = esc_html__('Terms', 'event_espresso'); |
|
30 | + $this->_tables = array( |
|
31 | + 'Term' => new EE_Primary_Table('terms', 'term_id'), |
|
32 | + ); |
|
33 | + $this->_fields = array( |
|
34 | + 'Term' => array( |
|
35 | + 'term_id' => new EE_Primary_Key_Int_Field('term_id', esc_html__('Term ID', 'event_espresso')), |
|
36 | + 'name' => new EE_Plain_Text_Field('name', esc_html__('Term Name', 'event_espresso'), false, ''), |
|
37 | + 'slug' => new EE_Slug_Field('slug', esc_html__('Term Slug', 'event_espresso'), false), |
|
38 | + 'term_group' => new EE_Integer_Field('term_group', esc_html__("Term Group", "event_espresso"), false, 0), |
|
39 | + ), |
|
40 | + ); |
|
41 | + $this->_model_relations = array( |
|
42 | + 'Term_Taxonomy' => new EE_Has_Many_Relation(), |
|
43 | + ); |
|
44 | + $this->_wp_core_model = true; |
|
45 | + $path_to_tax_model = 'Term_Taxonomy'; |
|
46 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
47 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
48 | + $path_to_tax_model |
|
49 | + ); |
|
50 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
51 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
52 | + $path_to_tax_model = $path_to_tax_model . '.'; |
|
53 | + // add cap restrictions for editing relating to the "ee_edit_*" |
|
54 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
55 | + array( |
|
56 | + $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
57 | + ) |
|
58 | + ); |
|
59 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
60 | + array( |
|
61 | + $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
62 | + ) |
|
63 | + ); |
|
64 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
65 | + array( |
|
66 | + $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
67 | + ) |
|
68 | + ); |
|
69 | + // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
70 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
71 | + array( |
|
72 | + $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
73 | + ) |
|
74 | + ); |
|
75 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
76 | + array( |
|
77 | + $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
78 | + ) |
|
79 | + ); |
|
80 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
81 | + array( |
|
82 | + $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
83 | + ) |
|
84 | + ); |
|
85 | + parent::__construct($timezone); |
|
86 | + add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * retrieves a list of all EE event categories |
|
93 | - * |
|
94 | - * @access public |
|
95 | - * @param bool $show_uncategorized |
|
96 | - * @return \EE_Base_Class[] |
|
97 | - */ |
|
98 | - public function get_all_ee_categories($show_uncategorized = false) |
|
99 | - { |
|
100 | - $where_params = array( |
|
101 | - 'Term_Taxonomy.taxonomy' => 'espresso_event_categories', |
|
102 | - 'NOT' => array('name' => esc_html__('Uncategorized', 'event_espresso')), |
|
103 | - ); |
|
104 | - if ($show_uncategorized) { |
|
105 | - unset($where_params['NOT']); |
|
106 | - } |
|
107 | - return EEM_Term::instance()->get_all( |
|
108 | - array( |
|
109 | - $where_params, |
|
110 | - 'order_by' => array('name' => 'ASC'), |
|
111 | - ) |
|
112 | - ); |
|
113 | - } |
|
91 | + /** |
|
92 | + * retrieves a list of all EE event categories |
|
93 | + * |
|
94 | + * @access public |
|
95 | + * @param bool $show_uncategorized |
|
96 | + * @return \EE_Base_Class[] |
|
97 | + */ |
|
98 | + public function get_all_ee_categories($show_uncategorized = false) |
|
99 | + { |
|
100 | + $where_params = array( |
|
101 | + 'Term_Taxonomy.taxonomy' => 'espresso_event_categories', |
|
102 | + 'NOT' => array('name' => esc_html__('Uncategorized', 'event_espresso')), |
|
103 | + ); |
|
104 | + if ($show_uncategorized) { |
|
105 | + unset($where_params['NOT']); |
|
106 | + } |
|
107 | + return EEM_Term::instance()->get_all( |
|
108 | + array( |
|
109 | + $where_params, |
|
110 | + 'order_by' => array('name' => 'ASC'), |
|
111 | + ) |
|
112 | + ); |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | 116 | |
117 | - /** |
|
118 | - * retrieves a list of all post_tags associated with an EE CPT |
|
119 | - * |
|
120 | - * @access public |
|
121 | - * @param string $post_type |
|
122 | - * @return array |
|
123 | - */ |
|
124 | - public function get_all_CPT_post_tags($post_type = '') |
|
125 | - { |
|
126 | - switch ($post_type) { |
|
127 | - case 'espresso_events': |
|
128 | - return $this->get_all_event_post_tags(); |
|
129 | - break; |
|
130 | - case 'espresso_venues': |
|
131 | - return $this->get_all_venue_post_tags(); |
|
132 | - break; |
|
133 | - default: |
|
134 | - $event_tags = $this->get_all_event_post_tags(); |
|
135 | - $venue_tags = $this->get_all_venue_post_tags(); |
|
136 | - return array_merge($event_tags, $venue_tags); |
|
137 | - } |
|
138 | - } |
|
117 | + /** |
|
118 | + * retrieves a list of all post_tags associated with an EE CPT |
|
119 | + * |
|
120 | + * @access public |
|
121 | + * @param string $post_type |
|
122 | + * @return array |
|
123 | + */ |
|
124 | + public function get_all_CPT_post_tags($post_type = '') |
|
125 | + { |
|
126 | + switch ($post_type) { |
|
127 | + case 'espresso_events': |
|
128 | + return $this->get_all_event_post_tags(); |
|
129 | + break; |
|
130 | + case 'espresso_venues': |
|
131 | + return $this->get_all_venue_post_tags(); |
|
132 | + break; |
|
133 | + default: |
|
134 | + $event_tags = $this->get_all_event_post_tags(); |
|
135 | + $venue_tags = $this->get_all_venue_post_tags(); |
|
136 | + return array_merge($event_tags, $venue_tags); |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | 140 | |
141 | - /** |
|
142 | - * returns an EE_Term object for the given tag |
|
143 | - * if it has been utilized by any EE_Events or EE_Venues |
|
144 | - * |
|
145 | - * @param string $tag |
|
146 | - * @return EE_Term|null |
|
147 | - * @throws EE_Error |
|
148 | - * @throws InvalidArgumentException |
|
149 | - * @throws InvalidDataTypeException |
|
150 | - * @throws InvalidInterfaceException |
|
151 | - */ |
|
152 | - public function get_post_tag_for_event_or_venue($tag) |
|
153 | - { |
|
154 | - $post_tag_results = $this->get_all_wpdb_results( |
|
155 | - array( |
|
156 | - array( |
|
157 | - 'slug' => $tag, |
|
158 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
159 | - 'OR' => array( |
|
160 | - 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
161 | - 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
162 | - ), |
|
163 | - ), |
|
164 | - 'default_where_conditions' => 'none', |
|
165 | - 'extra_selects' => array( |
|
166 | - 'event_post_type' => array('Term_Taxonomy___Event_CPT.post_type', '%s'), |
|
167 | - 'venue_post_type' => array('Term_Taxonomy___Venue_CPT.post_type', '%s') |
|
168 | - ), |
|
169 | - 'group_by' => array( |
|
170 | - 'event_post_type', |
|
171 | - 'venue_post_type', |
|
172 | - ), |
|
173 | - 'limit' => 2 |
|
174 | - ) |
|
175 | - ); |
|
141 | + /** |
|
142 | + * returns an EE_Term object for the given tag |
|
143 | + * if it has been utilized by any EE_Events or EE_Venues |
|
144 | + * |
|
145 | + * @param string $tag |
|
146 | + * @return EE_Term|null |
|
147 | + * @throws EE_Error |
|
148 | + * @throws InvalidArgumentException |
|
149 | + * @throws InvalidDataTypeException |
|
150 | + * @throws InvalidInterfaceException |
|
151 | + */ |
|
152 | + public function get_post_tag_for_event_or_venue($tag) |
|
153 | + { |
|
154 | + $post_tag_results = $this->get_all_wpdb_results( |
|
155 | + array( |
|
156 | + array( |
|
157 | + 'slug' => $tag, |
|
158 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
159 | + 'OR' => array( |
|
160 | + 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
161 | + 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
162 | + ), |
|
163 | + ), |
|
164 | + 'default_where_conditions' => 'none', |
|
165 | + 'extra_selects' => array( |
|
166 | + 'event_post_type' => array('Term_Taxonomy___Event_CPT.post_type', '%s'), |
|
167 | + 'venue_post_type' => array('Term_Taxonomy___Venue_CPT.post_type', '%s') |
|
168 | + ), |
|
169 | + 'group_by' => array( |
|
170 | + 'event_post_type', |
|
171 | + 'venue_post_type', |
|
172 | + ), |
|
173 | + 'limit' => 2 |
|
174 | + ) |
|
175 | + ); |
|
176 | 176 | |
177 | - $post_types = array(); |
|
178 | - foreach ((array) $post_tag_results as $row) { |
|
179 | - if ($row['event_post_type'] === 'espresso_events') { |
|
180 | - $post_types[] = EEM_Event::instance()->post_type(); |
|
181 | - } elseif ($row['venue_post_type'] === 'espresso_venues') { |
|
182 | - $post_types[] = EEM_Venue::instance()->post_type(); |
|
183 | - } |
|
184 | - } |
|
185 | - $post_tag_row = reset($post_tag_results); |
|
186 | - $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
|
187 | - if (! $post_tag instanceof EE_Term) { |
|
188 | - return null; |
|
189 | - } |
|
177 | + $post_types = array(); |
|
178 | + foreach ((array) $post_tag_results as $row) { |
|
179 | + if ($row['event_post_type'] === 'espresso_events') { |
|
180 | + $post_types[] = EEM_Event::instance()->post_type(); |
|
181 | + } elseif ($row['venue_post_type'] === 'espresso_venues') { |
|
182 | + $post_types[] = EEM_Venue::instance()->post_type(); |
|
183 | + } |
|
184 | + } |
|
185 | + $post_tag_row = reset($post_tag_results); |
|
186 | + $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
|
187 | + if (! $post_tag instanceof EE_Term) { |
|
188 | + return null; |
|
189 | + } |
|
190 | 190 | |
191 | - if ($post_tag->post_type === null) { |
|
192 | - $post_tag->post_type = array(); |
|
193 | - } |
|
194 | - $post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types)); |
|
195 | - return $post_tag; |
|
196 | - } |
|
191 | + if ($post_tag->post_type === null) { |
|
192 | + $post_tag->post_type = array(); |
|
193 | + } |
|
194 | + $post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types)); |
|
195 | + return $post_tag; |
|
196 | + } |
|
197 | 197 | |
198 | 198 | |
199 | 199 | |
200 | - /** |
|
201 | - * get_all_event_post_tags |
|
202 | - * |
|
203 | - * @return EE_Base_Class[] |
|
204 | - */ |
|
205 | - public function get_all_event_post_tags() |
|
206 | - { |
|
207 | - $post_tags = EEM_Term::instance()->get_all( |
|
208 | - array( |
|
209 | - array( |
|
210 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
211 | - 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
212 | - ), |
|
213 | - 'order_by' => array('name' => 'ASC'), |
|
214 | - 'force_join' => array('Term_Taxonomy.Event'), |
|
215 | - ) |
|
216 | - ); |
|
217 | - foreach ($post_tags as $key => $post_tag) { |
|
218 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
219 | - $post_tags[ $key ]->post_type = array(); |
|
220 | - } |
|
221 | - $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
222 | - } |
|
223 | - return $post_tags; |
|
224 | - } |
|
200 | + /** |
|
201 | + * get_all_event_post_tags |
|
202 | + * |
|
203 | + * @return EE_Base_Class[] |
|
204 | + */ |
|
205 | + public function get_all_event_post_tags() |
|
206 | + { |
|
207 | + $post_tags = EEM_Term::instance()->get_all( |
|
208 | + array( |
|
209 | + array( |
|
210 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
211 | + 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
212 | + ), |
|
213 | + 'order_by' => array('name' => 'ASC'), |
|
214 | + 'force_join' => array('Term_Taxonomy.Event'), |
|
215 | + ) |
|
216 | + ); |
|
217 | + foreach ($post_tags as $key => $post_tag) { |
|
218 | + if (! isset($post_tags[ $key ]->post_type)) { |
|
219 | + $post_tags[ $key ]->post_type = array(); |
|
220 | + } |
|
221 | + $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
222 | + } |
|
223 | + return $post_tags; |
|
224 | + } |
|
225 | 225 | |
226 | 226 | |
227 | 227 | |
228 | - /** |
|
229 | - * get_all_venue_post_tags |
|
230 | - * |
|
231 | - * @return EE_Base_Class[] |
|
232 | - */ |
|
233 | - public function get_all_venue_post_tags() |
|
234 | - { |
|
235 | - $post_tags = EEM_Term::instance()->get_all( |
|
236 | - array( |
|
237 | - array( |
|
238 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
239 | - 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
240 | - ), |
|
241 | - 'order_by' => array('name' => 'ASC'), |
|
242 | - 'force_join' => array('Term_Taxonomy'), |
|
243 | - ) |
|
244 | - ); |
|
245 | - foreach ($post_tags as $key => $post_tag) { |
|
246 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
247 | - $post_tags[ $key ]->post_type = array(); |
|
248 | - } |
|
249 | - $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
250 | - } |
|
251 | - return $post_tags; |
|
252 | - } |
|
228 | + /** |
|
229 | + * get_all_venue_post_tags |
|
230 | + * |
|
231 | + * @return EE_Base_Class[] |
|
232 | + */ |
|
233 | + public function get_all_venue_post_tags() |
|
234 | + { |
|
235 | + $post_tags = EEM_Term::instance()->get_all( |
|
236 | + array( |
|
237 | + array( |
|
238 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
239 | + 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
240 | + ), |
|
241 | + 'order_by' => array('name' => 'ASC'), |
|
242 | + 'force_join' => array('Term_Taxonomy'), |
|
243 | + ) |
|
244 | + ); |
|
245 | + foreach ($post_tags as $key => $post_tag) { |
|
246 | + if (! isset($post_tags[ $key ]->post_type)) { |
|
247 | + $post_tags[ $key ]->post_type = array(); |
|
248 | + } |
|
249 | + $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
250 | + } |
|
251 | + return $post_tags; |
|
252 | + } |
|
253 | 253 | |
254 | 254 | |
255 | 255 | |
256 | - /** |
|
257 | - * Makes sure that during REST API queries, we only return terms |
|
258 | - * for term taxonomies which should be shown in the rest api |
|
259 | - * |
|
260 | - * @param array $model_query_params |
|
261 | - * @param array $querystring_query_params |
|
262 | - * @param EEM_Base $model |
|
263 | - * @return array |
|
264 | - */ |
|
265 | - public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
266 | - { |
|
267 | - if ($model === EEM_Term::instance()) { |
|
268 | - $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
269 | - if (! empty($taxonomies)) { |
|
270 | - $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
271 | - } |
|
272 | - } |
|
273 | - return $model_query_params; |
|
274 | - } |
|
256 | + /** |
|
257 | + * Makes sure that during REST API queries, we only return terms |
|
258 | + * for term taxonomies which should be shown in the rest api |
|
259 | + * |
|
260 | + * @param array $model_query_params |
|
261 | + * @param array $querystring_query_params |
|
262 | + * @param EEM_Base $model |
|
263 | + * @return array |
|
264 | + */ |
|
265 | + public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
266 | + { |
|
267 | + if ($model === EEM_Term::instance()) { |
|
268 | + $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
269 | + if (! empty($taxonomies)) { |
|
270 | + $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
271 | + } |
|
272 | + } |
|
273 | + return $model_query_params; |
|
274 | + } |
|
275 | 275 | } |
@@ -14,80 +14,80 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Country_Select_Input extends EE_Select_Input |
16 | 16 | { |
17 | - /** |
|
18 | - * $input_settings key used for detecting the "get" option |
|
19 | - */ |
|
20 | - const OPTION_GET_KEY = 'get'; |
|
17 | + /** |
|
18 | + * $input_settings key used for detecting the "get" option |
|
19 | + */ |
|
20 | + const OPTION_GET_KEY = 'get'; |
|
21 | 21 | |
22 | - /** |
|
23 | - * indicates that ALL countries should be retrieved from the db for the input |
|
24 | - */ |
|
25 | - const OPTION_GET_ALL = 'all'; |
|
22 | + /** |
|
23 | + * indicates that ALL countries should be retrieved from the db for the input |
|
24 | + */ |
|
25 | + const OPTION_GET_ALL = 'all'; |
|
26 | 26 | |
27 | - /** |
|
28 | - * indicates that only ACTIVE countries should be retrieved from the db for the input |
|
29 | - */ |
|
30 | - const OPTION_GET_ACTIVE = 'active'; |
|
27 | + /** |
|
28 | + * indicates that only ACTIVE countries should be retrieved from the db for the input |
|
29 | + */ |
|
30 | + const OPTION_GET_ACTIVE = 'active'; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @param array $country_options |
|
35 | - * @param array $input_settings |
|
36 | - * @throws EE_Error |
|
37 | - * @throws InvalidArgumentException |
|
38 | - * @throws InvalidDataTypeException |
|
39 | - * @throws InvalidInterfaceException |
|
40 | - * @throws ReflectionException |
|
41 | - */ |
|
42 | - public function __construct($country_options = null, $input_settings = array()) |
|
43 | - { |
|
44 | - $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
45 | - ? $input_settings[ self::OPTION_GET_KEY ] |
|
46 | - : self::OPTION_GET_ACTIVE; |
|
47 | - $country_options = apply_filters( |
|
48 | - 'FHEE__EE_Country_Select_Input____construct__country_options', |
|
49 | - $this->get_country_answer_options($country_options, $get), |
|
50 | - $this, |
|
51 | - $get |
|
52 | - ); |
|
53 | - $input_settings['html_class'] = isset($input_settings['html_class']) |
|
54 | - ? $input_settings['html_class'] . ' ee-country-select-js' |
|
55 | - : 'ee-country-select-js'; |
|
56 | - parent::__construct($country_options, $input_settings); |
|
57 | - } |
|
33 | + /** |
|
34 | + * @param array $country_options |
|
35 | + * @param array $input_settings |
|
36 | + * @throws EE_Error |
|
37 | + * @throws InvalidArgumentException |
|
38 | + * @throws InvalidDataTypeException |
|
39 | + * @throws InvalidInterfaceException |
|
40 | + * @throws ReflectionException |
|
41 | + */ |
|
42 | + public function __construct($country_options = null, $input_settings = array()) |
|
43 | + { |
|
44 | + $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
45 | + ? $input_settings[ self::OPTION_GET_KEY ] |
|
46 | + : self::OPTION_GET_ACTIVE; |
|
47 | + $country_options = apply_filters( |
|
48 | + 'FHEE__EE_Country_Select_Input____construct__country_options', |
|
49 | + $this->get_country_answer_options($country_options, $get), |
|
50 | + $this, |
|
51 | + $get |
|
52 | + ); |
|
53 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
54 | + ? $input_settings['html_class'] . ' ee-country-select-js' |
|
55 | + : 'ee-country-select-js'; |
|
56 | + parent::__construct($country_options, $input_settings); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * get_country_answer_options |
|
62 | - * |
|
63 | - * @param array $country_options |
|
64 | - * @param string $get |
|
65 | - * @return array |
|
66 | - * @throws EE_Error |
|
67 | - * @throws InvalidArgumentException |
|
68 | - * @throws ReflectionException |
|
69 | - * @throws InvalidDataTypeException |
|
70 | - * @throws InvalidInterfaceException |
|
71 | - */ |
|
72 | - public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
|
73 | - { |
|
74 | - // if passed something that is NOT an array |
|
75 | - if (! is_array($country_options)) { |
|
76 | - // get possibly cached list of countries |
|
77 | - $countries = $get === self::OPTION_GET_ALL |
|
78 | - ? EEM_Country::instance()->get_all_countries() |
|
79 | - : EEM_Country::instance()->get_all_active_countries(); |
|
80 | - if (! empty($countries)) { |
|
81 | - $country_options[''] = ''; |
|
82 | - foreach ($countries as $country) { |
|
83 | - if ($country instanceof EE_Country) { |
|
84 | - $country_options[ $country->ID() ] = $country->name(); |
|
85 | - } |
|
86 | - } |
|
87 | - } else { |
|
88 | - $country_options = array(); |
|
89 | - } |
|
90 | - } |
|
91 | - return $country_options; |
|
92 | - } |
|
60 | + /** |
|
61 | + * get_country_answer_options |
|
62 | + * |
|
63 | + * @param array $country_options |
|
64 | + * @param string $get |
|
65 | + * @return array |
|
66 | + * @throws EE_Error |
|
67 | + * @throws InvalidArgumentException |
|
68 | + * @throws ReflectionException |
|
69 | + * @throws InvalidDataTypeException |
|
70 | + * @throws InvalidInterfaceException |
|
71 | + */ |
|
72 | + public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
|
73 | + { |
|
74 | + // if passed something that is NOT an array |
|
75 | + if (! is_array($country_options)) { |
|
76 | + // get possibly cached list of countries |
|
77 | + $countries = $get === self::OPTION_GET_ALL |
|
78 | + ? EEM_Country::instance()->get_all_countries() |
|
79 | + : EEM_Country::instance()->get_all_active_countries(); |
|
80 | + if (! empty($countries)) { |
|
81 | + $country_options[''] = ''; |
|
82 | + foreach ($countries as $country) { |
|
83 | + if ($country instanceof EE_Country) { |
|
84 | + $country_options[ $country->ID() ] = $country->name(); |
|
85 | + } |
|
86 | + } |
|
87 | + } else { |
|
88 | + $country_options = array(); |
|
89 | + } |
|
90 | + } |
|
91 | + return $country_options; |
|
92 | + } |
|
93 | 93 | } |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __construct($country_options = null, $input_settings = array()) |
43 | 43 | { |
44 | - $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
45 | - ? $input_settings[ self::OPTION_GET_KEY ] |
|
44 | + $get = isset($input_settings[self::OPTION_GET_KEY]) |
|
45 | + ? $input_settings[self::OPTION_GET_KEY] |
|
46 | 46 | : self::OPTION_GET_ACTIVE; |
47 | 47 | $country_options = apply_filters( |
48 | 48 | 'FHEE__EE_Country_Select_Input____construct__country_options', |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $get |
52 | 52 | ); |
53 | 53 | $input_settings['html_class'] = isset($input_settings['html_class']) |
54 | - ? $input_settings['html_class'] . ' ee-country-select-js' |
|
54 | + ? $input_settings['html_class'].' ee-country-select-js' |
|
55 | 55 | : 'ee-country-select-js'; |
56 | 56 | parent::__construct($country_options, $input_settings); |
57 | 57 | } |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
73 | 73 | { |
74 | 74 | // if passed something that is NOT an array |
75 | - if (! is_array($country_options)) { |
|
75 | + if ( ! is_array($country_options)) { |
|
76 | 76 | // get possibly cached list of countries |
77 | 77 | $countries = $get === self::OPTION_GET_ALL |
78 | 78 | ? EEM_Country::instance()->get_all_countries() |
79 | 79 | : EEM_Country::instance()->get_all_active_countries(); |
80 | - if (! empty($countries)) { |
|
80 | + if ( ! empty($countries)) { |
|
81 | 81 | $country_options[''] = ''; |
82 | 82 | foreach ($countries as $country) { |
83 | 83 | if ($country instanceof EE_Country) { |
84 | - $country_options[ $country->ID() ] = $country->name(); |
|
84 | + $country_options[$country->ID()] = $country->name(); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } else { |
@@ -14,8 +14,8 @@ |
||
14 | 14 | */ |
15 | 15 | class AnyFrontendRequest extends RouteMatchSpecification |
16 | 16 | { |
17 | - public function isMatchingRoute() |
|
18 | - { |
|
19 | - return $this->request->isFrontend(); |
|
20 | - } |
|
17 | + public function isMatchingRoute() |
|
18 | + { |
|
19 | + return $this->request->isFrontend(); |
|
20 | + } |
|
21 | 21 | } |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function isValid($file, $func, $line) |
34 | 34 | { |
35 | - if (! defined('JSON_ERROR_RECURSION')) { |
|
35 | + if ( ! defined('JSON_ERROR_RECURSION')) { |
|
36 | 36 | define('JSON_ERROR_RECURSION', 6); |
37 | 37 | } |
38 | - if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
38 | + if ( ! defined('JSON_ERROR_INF_OR_NAN')) { |
|
39 | 39 | define('JSON_ERROR_INF_OR_NAN', 7); |
40 | 40 | } |
41 | - if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
41 | + if ( ! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
42 | 42 | define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
43 | 43 | } |
44 | - if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
44 | + if ( ! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
45 | 45 | define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
46 | 46 | } |
47 | - if (! defined('JSON_ERROR_UTF16')) { |
|
47 | + if ( ! defined('JSON_ERROR_UTF16')) { |
|
48 | 48 | define('JSON_ERROR_UTF16', 10); |
49 | 49 | } |
50 | 50 | switch (json_last_error()) { |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $error = ': Unknown error'; |
85 | 85 | break; |
86 | 86 | } |
87 | - EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
87 | + EE_Error::add_error('JSON decoding failed'.$error, $file, $func, $line); |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | } |
@@ -17,76 +17,76 @@ |
||
17 | 17 | */ |
18 | 18 | class JsonValidator |
19 | 19 | { |
20 | - /** |
|
21 | - * Call this method IMMEDIATELY after json_decode() and |
|
22 | - * it will will return true if the decoded JSON was valid, |
|
23 | - * or return false after adding an error if not valid. |
|
24 | - * The actual JSON file does not need to be supplied, |
|
25 | - * but details re: code execution location are required. |
|
26 | - * ex: |
|
27 | - * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__) |
|
28 | - * |
|
29 | - * @param string $file |
|
30 | - * @param string $func |
|
31 | - * @param string $line |
|
32 | - * @return boolean |
|
33 | - * @since 4.9.70.p |
|
34 | - */ |
|
35 | - public function isValid($file, $func, $line) |
|
36 | - { |
|
37 | - if (! defined('JSON_ERROR_RECURSION')) { |
|
38 | - define('JSON_ERROR_RECURSION', 6); |
|
39 | - } |
|
40 | - if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
41 | - define('JSON_ERROR_INF_OR_NAN', 7); |
|
42 | - } |
|
43 | - if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
44 | - define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
|
45 | - } |
|
46 | - if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
47 | - define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
|
48 | - } |
|
49 | - if (! defined('JSON_ERROR_UTF16')) { |
|
50 | - define('JSON_ERROR_UTF16', 10); |
|
51 | - } |
|
52 | - switch (json_last_error()) { |
|
53 | - case JSON_ERROR_NONE: |
|
54 | - return true; |
|
55 | - case JSON_ERROR_DEPTH: |
|
56 | - $error = ': Maximum stack depth exceeded'; |
|
57 | - break; |
|
58 | - case JSON_ERROR_STATE_MISMATCH: |
|
59 | - $error = ': Invalid or malformed JSON'; |
|
60 | - break; |
|
61 | - case JSON_ERROR_CTRL_CHAR: |
|
62 | - $error = ': Control character error, possible malformed JSON'; |
|
63 | - break; |
|
64 | - case JSON_ERROR_SYNTAX: |
|
65 | - $error = ': Syntax error, malformed JSON'; |
|
66 | - break; |
|
67 | - case JSON_ERROR_UTF8: |
|
68 | - $error = ': Malformed UTF-8 characters, possible malformed JSON'; |
|
69 | - break; |
|
70 | - case JSON_ERROR_RECURSION: |
|
71 | - $error = ': One or more recursive references in the value to be encoded'; |
|
72 | - break; |
|
73 | - case JSON_ERROR_INF_OR_NAN: |
|
74 | - $error = ': One or more NAN or INF values in the value to be encoded'; |
|
75 | - break; |
|
76 | - case JSON_ERROR_UNSUPPORTED_TYPE: |
|
77 | - $error = ': A value of a type that cannot be encoded was given'; |
|
78 | - break; |
|
79 | - case JSON_ERROR_INVALID_PROPERTY_NAME: |
|
80 | - $error = ': A property name that cannot be encoded was given'; |
|
81 | - break; |
|
82 | - case JSON_ERROR_UTF16: |
|
83 | - $error = ': Malformed UTF-16 characters, possibly incorrectly encoded'; |
|
84 | - break; |
|
85 | - default: |
|
86 | - $error = ': Unknown error'; |
|
87 | - break; |
|
88 | - } |
|
89 | - EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
90 | - return false; |
|
91 | - } |
|
20 | + /** |
|
21 | + * Call this method IMMEDIATELY after json_decode() and |
|
22 | + * it will will return true if the decoded JSON was valid, |
|
23 | + * or return false after adding an error if not valid. |
|
24 | + * The actual JSON file does not need to be supplied, |
|
25 | + * but details re: code execution location are required. |
|
26 | + * ex: |
|
27 | + * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__) |
|
28 | + * |
|
29 | + * @param string $file |
|
30 | + * @param string $func |
|
31 | + * @param string $line |
|
32 | + * @return boolean |
|
33 | + * @since 4.9.70.p |
|
34 | + */ |
|
35 | + public function isValid($file, $func, $line) |
|
36 | + { |
|
37 | + if (! defined('JSON_ERROR_RECURSION')) { |
|
38 | + define('JSON_ERROR_RECURSION', 6); |
|
39 | + } |
|
40 | + if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
41 | + define('JSON_ERROR_INF_OR_NAN', 7); |
|
42 | + } |
|
43 | + if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
44 | + define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
|
45 | + } |
|
46 | + if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
47 | + define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
|
48 | + } |
|
49 | + if (! defined('JSON_ERROR_UTF16')) { |
|
50 | + define('JSON_ERROR_UTF16', 10); |
|
51 | + } |
|
52 | + switch (json_last_error()) { |
|
53 | + case JSON_ERROR_NONE: |
|
54 | + return true; |
|
55 | + case JSON_ERROR_DEPTH: |
|
56 | + $error = ': Maximum stack depth exceeded'; |
|
57 | + break; |
|
58 | + case JSON_ERROR_STATE_MISMATCH: |
|
59 | + $error = ': Invalid or malformed JSON'; |
|
60 | + break; |
|
61 | + case JSON_ERROR_CTRL_CHAR: |
|
62 | + $error = ': Control character error, possible malformed JSON'; |
|
63 | + break; |
|
64 | + case JSON_ERROR_SYNTAX: |
|
65 | + $error = ': Syntax error, malformed JSON'; |
|
66 | + break; |
|
67 | + case JSON_ERROR_UTF8: |
|
68 | + $error = ': Malformed UTF-8 characters, possible malformed JSON'; |
|
69 | + break; |
|
70 | + case JSON_ERROR_RECURSION: |
|
71 | + $error = ': One or more recursive references in the value to be encoded'; |
|
72 | + break; |
|
73 | + case JSON_ERROR_INF_OR_NAN: |
|
74 | + $error = ': One or more NAN or INF values in the value to be encoded'; |
|
75 | + break; |
|
76 | + case JSON_ERROR_UNSUPPORTED_TYPE: |
|
77 | + $error = ': A value of a type that cannot be encoded was given'; |
|
78 | + break; |
|
79 | + case JSON_ERROR_INVALID_PROPERTY_NAME: |
|
80 | + $error = ': A property name that cannot be encoded was given'; |
|
81 | + break; |
|
82 | + case JSON_ERROR_UTF16: |
|
83 | + $error = ': Malformed UTF-16 characters, possibly incorrectly encoded'; |
|
84 | + break; |
|
85 | + default: |
|
86 | + $error = ': Unknown error'; |
|
87 | + break; |
|
88 | + } |
|
89 | + EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
90 | + return false; |
|
91 | + } |
|
92 | 92 | } |