@@ -19,78 +19,78 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * the actual shortcode tag that gets registered with WordPress |
|
24 | - * |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - public function getTag() |
|
28 | - { |
|
29 | - return 'ESPRESSO_TICKET_SELECTOR'; |
|
30 | - } |
|
22 | + /** |
|
23 | + * the actual shortcode tag that gets registered with WordPress |
|
24 | + * |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + public function getTag() |
|
28 | + { |
|
29 | + return 'ESPRESSO_TICKET_SELECTOR'; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * the time in seconds to cache the results of the processShortcode() method |
|
35 | - * 0 means the processShortcode() results will NOT be cached at all |
|
36 | - * |
|
37 | - * @return int |
|
38 | - */ |
|
39 | - public function cacheExpiration() |
|
40 | - { |
|
41 | - return 0; |
|
42 | - } |
|
33 | + /** |
|
34 | + * the time in seconds to cache the results of the processShortcode() method |
|
35 | + * 0 means the processShortcode() results will NOT be cached at all |
|
36 | + * |
|
37 | + * @return int |
|
38 | + */ |
|
39 | + public function cacheExpiration() |
|
40 | + { |
|
41 | + return 0; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
47 | - * this may be required for shortcodes that utilize a corresponding module, |
|
48 | - * and need to enqueue assets for that module |
|
49 | - * |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public function initializeShortcode() |
|
53 | - { |
|
54 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
55 | - $this->shortcodeHasBeenInitialized(); |
|
56 | - } |
|
45 | + /** |
|
46 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
47 | + * this may be required for shortcodes that utilize a corresponding module, |
|
48 | + * and need to enqueue assets for that module |
|
49 | + * |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public function initializeShortcode() |
|
53 | + { |
|
54 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
55 | + $this->shortcodeHasBeenInitialized(); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * callback that runs when the shortcode is encountered in post content. |
|
61 | - * IMPORTANT !!! |
|
62 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
63 | - * |
|
64 | - * @param array $attributes |
|
65 | - * @return string |
|
66 | - * @throws InvalidArgumentException |
|
67 | - */ |
|
68 | - public function processShortcode($attributes = array()) |
|
69 | - { |
|
70 | - extract($attributes, EXTR_OVERWRITE); |
|
71 | - $event_id = isset($event_id) ? $event_id : 0; |
|
72 | - $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
73 | - if (! $event instanceof EE_Event) { |
|
74 | - new ExceptionStackTraceDisplay( |
|
75 | - new InvalidArgumentException( |
|
76 | - sprintf( |
|
77 | - esc_html__( |
|
78 | - '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 it\'s value corresponds to a valid Event ID.', |
|
79 | - 'event_espresso' |
|
80 | - ), |
|
81 | - $this->getTag(), |
|
82 | - $event_id, |
|
83 | - 'event_id', |
|
84 | - '<br />' |
|
85 | - ) |
|
86 | - ) |
|
87 | - ); |
|
88 | - return ''; |
|
89 | - } |
|
90 | - ob_start(); |
|
91 | - do_action('AHEE_event_details_before_post', $event_id); |
|
92 | - espresso_ticket_selector($event); |
|
93 | - do_action('AHEE_event_details_after_post'); |
|
94 | - return ob_get_clean(); |
|
95 | - } |
|
59 | + /** |
|
60 | + * callback that runs when the shortcode is encountered in post content. |
|
61 | + * IMPORTANT !!! |
|
62 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
63 | + * |
|
64 | + * @param array $attributes |
|
65 | + * @return string |
|
66 | + * @throws InvalidArgumentException |
|
67 | + */ |
|
68 | + public function processShortcode($attributes = array()) |
|
69 | + { |
|
70 | + extract($attributes, EXTR_OVERWRITE); |
|
71 | + $event_id = isset($event_id) ? $event_id : 0; |
|
72 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
73 | + if (! $event instanceof EE_Event) { |
|
74 | + new ExceptionStackTraceDisplay( |
|
75 | + new InvalidArgumentException( |
|
76 | + sprintf( |
|
77 | + esc_html__( |
|
78 | + '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 it\'s value corresponds to a valid Event ID.', |
|
79 | + 'event_espresso' |
|
80 | + ), |
|
81 | + $this->getTag(), |
|
82 | + $event_id, |
|
83 | + 'event_id', |
|
84 | + '<br />' |
|
85 | + ) |
|
86 | + ) |
|
87 | + ); |
|
88 | + return ''; |
|
89 | + } |
|
90 | + ob_start(); |
|
91 | + do_action('AHEE_event_details_before_post', $event_id); |
|
92 | + espresso_ticket_selector($event); |
|
93 | + do_action('AHEE_event_details_after_post'); |
|
94 | + return ob_get_clean(); |
|
95 | + } |
|
96 | 96 | } |
@@ -22,87 +22,87 @@ |
||
22 | 22 | { |
23 | 23 | |
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_TXN_PAGE'; |
|
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_TXN_PAGE'; |
|
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 | - * @throws \Exception |
|
55 | - * @throws \EE_Error |
|
56 | - */ |
|
57 | - public function initializeShortcode() |
|
58 | - { |
|
59 | - $transaction = null; |
|
60 | - if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
61 | - /** @var EEM_Transaction $EEM_Transaction */ |
|
62 | - $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
63 | - $transaction = $EEM_Transaction->get_transaction_from_reg_url_link(); |
|
64 | - } |
|
65 | - if ($transaction instanceof EE_Transaction) { |
|
66 | - $payment_method = null; |
|
67 | - $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null); |
|
68 | - if ($payment_method_slug) { |
|
69 | - $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug); |
|
70 | - } |
|
71 | - if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) { |
|
72 | - $gateway = $payment_method->type_obj()->get_gateway(); |
|
73 | - if ($gateway instanceof EE_Offsite_Gateway |
|
74 | - && $gateway->handle_IPN_in_this_request( |
|
75 | - \EE_Registry::instance()->REQ->params(), |
|
76 | - true |
|
77 | - ) |
|
78 | - ) { |
|
79 | - /** @type EE_Payment_Processor $payment_processor */ |
|
80 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
81 | - $payment_processor->process_ipn($_REQUEST, $transaction, $payment_method); |
|
82 | - } |
|
83 | - } |
|
84 | - // allow gateways to add a filter to stop rendering the page |
|
85 | - if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) { |
|
86 | - exit; |
|
87 | - } |
|
88 | - } |
|
89 | - $this->shortcodeHasBeenInitialized(); |
|
90 | - } |
|
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 | + * @throws \Exception |
|
55 | + * @throws \EE_Error |
|
56 | + */ |
|
57 | + public function initializeShortcode() |
|
58 | + { |
|
59 | + $transaction = null; |
|
60 | + if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
61 | + /** @var EEM_Transaction $EEM_Transaction */ |
|
62 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
63 | + $transaction = $EEM_Transaction->get_transaction_from_reg_url_link(); |
|
64 | + } |
|
65 | + if ($transaction instanceof EE_Transaction) { |
|
66 | + $payment_method = null; |
|
67 | + $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null); |
|
68 | + if ($payment_method_slug) { |
|
69 | + $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug); |
|
70 | + } |
|
71 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) { |
|
72 | + $gateway = $payment_method->type_obj()->get_gateway(); |
|
73 | + if ($gateway instanceof EE_Offsite_Gateway |
|
74 | + && $gateway->handle_IPN_in_this_request( |
|
75 | + \EE_Registry::instance()->REQ->params(), |
|
76 | + true |
|
77 | + ) |
|
78 | + ) { |
|
79 | + /** @type EE_Payment_Processor $payment_processor */ |
|
80 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
81 | + $payment_processor->process_ipn($_REQUEST, $transaction, $payment_method); |
|
82 | + } |
|
83 | + } |
|
84 | + // allow gateways to add a filter to stop rendering the page |
|
85 | + if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) { |
|
86 | + exit; |
|
87 | + } |
|
88 | + } |
|
89 | + $this->shortcodeHasBeenInitialized(); |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * callback that runs when the shortcode is encountered in post content. |
|
95 | - * IMPORTANT !!! |
|
96 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
97 | - * |
|
98 | - * @param array $attributes |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public function processShortcode($attributes = array()) |
|
102 | - { |
|
103 | - return esc_html__( |
|
104 | - 'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', |
|
105 | - 'event_espresso' |
|
106 | - ); |
|
107 | - } |
|
93 | + /** |
|
94 | + * callback that runs when the shortcode is encountered in post content. |
|
95 | + * IMPORTANT !!! |
|
96 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
97 | + * |
|
98 | + * @param array $attributes |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public function processShortcode($attributes = array()) |
|
102 | + { |
|
103 | + return esc_html__( |
|
104 | + 'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', |
|
105 | + 'event_espresso' |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | } |
@@ -16,54 +16,54 @@ |
||
16 | 16 | class Factory |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param string $class_name |
|
21 | - * @param array $arguments |
|
22 | - * @return mixed|null |
|
23 | - * @throws \EE_Error |
|
24 | - */ |
|
25 | - public static function create($class_name, $arguments = array()) |
|
26 | - { |
|
27 | - if (empty($class_name)) { |
|
28 | - throw new \EE_Error( |
|
29 | - __('You must provide a class name in order to instantiate it.', 'event_espresso') |
|
30 | - ); |
|
31 | - } |
|
32 | - // if ( ! class_exists( $class_name ) ) { |
|
33 | - // throw new \EE_Error( |
|
34 | - // sprintf( |
|
35 | - // __('The "%1$s" class was not found. Please include the correct file or set an autoloader for it', |
|
36 | - // 'event_espresso'), |
|
37 | - // $class_name |
|
38 | - // ) |
|
39 | - // ); |
|
40 | - // } |
|
41 | - $object = null; |
|
42 | - switch ($class_name) { |
|
43 | - case 'EE_Request': |
|
44 | - $object = new \EE_Request($_GET, $_POST, $_COOKIE); |
|
45 | - break; |
|
46 | - case 'Iframe': |
|
47 | - $title = isset($arguments['title']) ? $arguments['title'] : null; |
|
48 | - $content = isset($arguments['content']) ? $arguments['content'] : null; |
|
49 | - $object = new Iframe($title, $content); |
|
50 | - break; |
|
51 | - default: |
|
52 | - $object = new $class_name($arguments); |
|
53 | - } |
|
19 | + /** |
|
20 | + * @param string $class_name |
|
21 | + * @param array $arguments |
|
22 | + * @return mixed|null |
|
23 | + * @throws \EE_Error |
|
24 | + */ |
|
25 | + public static function create($class_name, $arguments = array()) |
|
26 | + { |
|
27 | + if (empty($class_name)) { |
|
28 | + throw new \EE_Error( |
|
29 | + __('You must provide a class name in order to instantiate it.', 'event_espresso') |
|
30 | + ); |
|
31 | + } |
|
32 | + // if ( ! class_exists( $class_name ) ) { |
|
33 | + // throw new \EE_Error( |
|
34 | + // sprintf( |
|
35 | + // __('The "%1$s" class was not found. Please include the correct file or set an autoloader for it', |
|
36 | + // 'event_espresso'), |
|
37 | + // $class_name |
|
38 | + // ) |
|
39 | + // ); |
|
40 | + // } |
|
41 | + $object = null; |
|
42 | + switch ($class_name) { |
|
43 | + case 'EE_Request': |
|
44 | + $object = new \EE_Request($_GET, $_POST, $_COOKIE); |
|
45 | + break; |
|
46 | + case 'Iframe': |
|
47 | + $title = isset($arguments['title']) ? $arguments['title'] : null; |
|
48 | + $content = isset($arguments['content']) ? $arguments['content'] : null; |
|
49 | + $object = new Iframe($title, $content); |
|
50 | + break; |
|
51 | + default: |
|
52 | + $object = new $class_name($arguments); |
|
53 | + } |
|
54 | 54 | |
55 | - // if ( ! $object instanceof $class_name ) { |
|
56 | - // throw new \EE_Error( |
|
57 | - // sprintf( |
|
58 | - // __( |
|
59 | - // 'An error occurred during class instantiation and the requested object could not be created. The result was: %1$s %2$s', |
|
60 | - // 'event_espresso' |
|
61 | - // ), |
|
62 | - // '<br />', |
|
63 | - // var_export($object, true) |
|
64 | - // ) |
|
65 | - // ); |
|
66 | - // } |
|
67 | - return $object; |
|
68 | - } |
|
55 | + // if ( ! $object instanceof $class_name ) { |
|
56 | + // throw new \EE_Error( |
|
57 | + // sprintf( |
|
58 | + // __( |
|
59 | + // 'An error occurred during class instantiation and the requested object could not be created. The result was: %1$s %2$s', |
|
60 | + // 'event_espresso' |
|
61 | + // ), |
|
62 | + // '<br />', |
|
63 | + // var_export($object, true) |
|
64 | + // ) |
|
65 | + // ); |
|
66 | + // } |
|
67 | + return $object; |
|
68 | + } |
|
69 | 69 | } |
@@ -12,138 +12,138 @@ |
||
12 | 12 | class PostShortcodeTracking |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @deprecated 4.9.26 |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public static function set_hooks_admin() |
|
20 | - { |
|
21 | - \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
22 | - } |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * @deprecated 4.9.26 |
|
27 | - * @param $post_ID |
|
28 | - * @param $post |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public static function parse_post_content_on_save($post_ID, $post) |
|
32 | - { |
|
33 | - \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @deprecated 4.9.26 |
|
39 | - * @param $page_for_posts |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - protected static function set_post_shortcodes_for_posts_page($page_for_posts) |
|
43 | - { |
|
44 | - \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @deprecated 4.9.26 |
|
50 | - * @param $page_for_posts |
|
51 | - * @param $EES_Shortcode |
|
52 | - * @param $post_ID |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID) |
|
56 | - { |
|
57 | - \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * @deprecated 4.9.26 |
|
63 | - * @param $ID |
|
64 | - * @return void |
|
65 | - */ |
|
66 | - public static function unset_post_shortcodes_on_delete($ID) |
|
67 | - { |
|
68 | - \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @deprecated 4.9.26 |
|
74 | - * @param $ID |
|
75 | - * @param $shortcode_class |
|
76 | - * @param $shortcode_posts |
|
77 | - * @param $page_for_posts |
|
78 | - * @param bool $update_post_shortcodes |
|
79 | - * @return void |
|
80 | - */ |
|
81 | - protected static function unset_posts_page_shortcode_for_post( |
|
82 | - $ID, |
|
83 | - $shortcode_class, |
|
84 | - $shortcode_posts, |
|
85 | - $page_for_posts, |
|
86 | - $update_post_shortcodes = false |
|
87 | - ) { |
|
88 | - \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @deprecated 4.9.26 |
|
94 | - * @param string $page_for_posts |
|
95 | - * @return void |
|
96 | - */ |
|
97 | - public static function update_post_shortcodes($page_for_posts = '') |
|
98 | - { |
|
99 | - \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * @deprecated 4.9.26 |
|
105 | - * @param $option |
|
106 | - * @param $value |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - public static function reset_page_for_posts_on_initial_set($option, $value) |
|
110 | - { |
|
111 | - \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @deprecated 4.9.26 |
|
117 | - * @param $option |
|
118 | - * @param string $old_value |
|
119 | - * @param string $value |
|
120 | - * @return void |
|
121 | - */ |
|
122 | - public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '') |
|
123 | - { |
|
124 | - \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @deprecated 4.9.26 |
|
130 | - * @param $option |
|
131 | - * @return void |
|
132 | - */ |
|
133 | - public static function reset_page_for_posts_on_delete($option) |
|
134 | - { |
|
135 | - \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @deprecated 4.9.26 |
|
141 | - * @param $shortcodes |
|
142 | - * @param bool $index_results |
|
143 | - * @return void |
|
144 | - */ |
|
145 | - public static function get_post_ids_for_shortcode($shortcodes, $index_results = true) |
|
146 | - { |
|
147 | - \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
148 | - } |
|
15 | + /** |
|
16 | + * @deprecated 4.9.26 |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public static function set_hooks_admin() |
|
20 | + { |
|
21 | + \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
22 | + } |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * @deprecated 4.9.26 |
|
27 | + * @param $post_ID |
|
28 | + * @param $post |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public static function parse_post_content_on_save($post_ID, $post) |
|
32 | + { |
|
33 | + \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @deprecated 4.9.26 |
|
39 | + * @param $page_for_posts |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + protected static function set_post_shortcodes_for_posts_page($page_for_posts) |
|
43 | + { |
|
44 | + \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @deprecated 4.9.26 |
|
50 | + * @param $page_for_posts |
|
51 | + * @param $EES_Shortcode |
|
52 | + * @param $post_ID |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID) |
|
56 | + { |
|
57 | + \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * @deprecated 4.9.26 |
|
63 | + * @param $ID |
|
64 | + * @return void |
|
65 | + */ |
|
66 | + public static function unset_post_shortcodes_on_delete($ID) |
|
67 | + { |
|
68 | + \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @deprecated 4.9.26 |
|
74 | + * @param $ID |
|
75 | + * @param $shortcode_class |
|
76 | + * @param $shortcode_posts |
|
77 | + * @param $page_for_posts |
|
78 | + * @param bool $update_post_shortcodes |
|
79 | + * @return void |
|
80 | + */ |
|
81 | + protected static function unset_posts_page_shortcode_for_post( |
|
82 | + $ID, |
|
83 | + $shortcode_class, |
|
84 | + $shortcode_posts, |
|
85 | + $page_for_posts, |
|
86 | + $update_post_shortcodes = false |
|
87 | + ) { |
|
88 | + \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @deprecated 4.9.26 |
|
94 | + * @param string $page_for_posts |
|
95 | + * @return void |
|
96 | + */ |
|
97 | + public static function update_post_shortcodes($page_for_posts = '') |
|
98 | + { |
|
99 | + \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * @deprecated 4.9.26 |
|
105 | + * @param $option |
|
106 | + * @param $value |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + public static function reset_page_for_posts_on_initial_set($option, $value) |
|
110 | + { |
|
111 | + \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @deprecated 4.9.26 |
|
117 | + * @param $option |
|
118 | + * @param string $old_value |
|
119 | + * @param string $value |
|
120 | + * @return void |
|
121 | + */ |
|
122 | + public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '') |
|
123 | + { |
|
124 | + \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @deprecated 4.9.26 |
|
130 | + * @param $option |
|
131 | + * @return void |
|
132 | + */ |
|
133 | + public static function reset_page_for_posts_on_delete($option) |
|
134 | + { |
|
135 | + \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @deprecated 4.9.26 |
|
141 | + * @param $shortcodes |
|
142 | + * @param bool $index_results |
|
143 | + * @return void |
|
144 | + */ |
|
145 | + public static function get_post_ids_for_shortcode($shortcodes, $index_results = true) |
|
146 | + { |
|
147 | + \EE_Error::doing_it_wrong(__METHOD__, __('Usage is deprecated.', 'event_espresso'), '4.9.26'); |
|
148 | + } |
|
149 | 149 | } |
@@ -14,62 +14,62 @@ |
||
14 | 14 | class Context implements ContextInterface |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @var string $slug |
|
19 | - */ |
|
20 | - private $slug; |
|
17 | + /** |
|
18 | + * @var string $slug |
|
19 | + */ |
|
20 | + private $slug; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @var string $description |
|
24 | - */ |
|
25 | - private $description; |
|
22 | + /** |
|
23 | + * @var string $description |
|
24 | + */ |
|
25 | + private $description; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * Context constructor. |
|
30 | - * |
|
31 | - * @param string $slug |
|
32 | - * @param string $description |
|
33 | - */ |
|
34 | - public function __construct($slug, $description) |
|
35 | - { |
|
36 | - $this->setSlug($slug); |
|
37 | - $this->setDescription($description); |
|
38 | - } |
|
28 | + /** |
|
29 | + * Context constructor. |
|
30 | + * |
|
31 | + * @param string $slug |
|
32 | + * @param string $description |
|
33 | + */ |
|
34 | + public function __construct($slug, $description) |
|
35 | + { |
|
36 | + $this->setSlug($slug); |
|
37 | + $this->setDescription($description); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function slug() |
|
45 | - { |
|
46 | - return $this->slug; |
|
47 | - } |
|
41 | + /** |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function slug() |
|
45 | + { |
|
46 | + return $this->slug; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param string $slug |
|
52 | - */ |
|
53 | - private function setSlug($slug) |
|
54 | - { |
|
55 | - $this->slug = sanitize_key($slug); |
|
56 | - } |
|
50 | + /** |
|
51 | + * @param string $slug |
|
52 | + */ |
|
53 | + private function setSlug($slug) |
|
54 | + { |
|
55 | + $this->slug = sanitize_key($slug); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function description() |
|
63 | - { |
|
64 | - return $this->description; |
|
65 | - } |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function description() |
|
63 | + { |
|
64 | + return $this->description; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @param string $description |
|
70 | - */ |
|
71 | - private function setDescription($description) |
|
72 | - { |
|
73 | - $this->description = sanitize_text_field($description); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @param string $description |
|
70 | + */ |
|
71 | + private function setDescription($description) |
|
72 | + { |
|
73 | + $this->description = sanitize_text_field($description); |
|
74 | + } |
|
75 | 75 | } |
@@ -18,128 +18,128 @@ |
||
18 | 18 | class CalculatedModelFields |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $mapping; |
|
21 | + /** |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $mapping; |
|
25 | 25 | |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * @param bool $refresh |
|
30 | - * @return array top-level-keys are model names (eg "Event") |
|
31 | - * next-level are the calculated field names AND method names on classes |
|
32 | - * which perform calculations, values are the fully qualified classnames which do the calculations |
|
33 | - * These callbacks should accept as arguments: |
|
34 | - * the wpdb row results, |
|
35 | - * the WP_Request object, |
|
36 | - * the controller object |
|
37 | - */ |
|
38 | - public function mapping($refresh = false) |
|
39 | - { |
|
40 | - if (! $this->mapping || $refresh) { |
|
41 | - $this->mapping = $this->generateNewMapping(); |
|
42 | - } |
|
43 | - return $this->mapping; |
|
44 | - } |
|
28 | + /** |
|
29 | + * @param bool $refresh |
|
30 | + * @return array top-level-keys are model names (eg "Event") |
|
31 | + * next-level are the calculated field names AND method names on classes |
|
32 | + * which perform calculations, values are the fully qualified classnames which do the calculations |
|
33 | + * These callbacks should accept as arguments: |
|
34 | + * the wpdb row results, |
|
35 | + * the WP_Request object, |
|
36 | + * the controller object |
|
37 | + */ |
|
38 | + public function mapping($refresh = false) |
|
39 | + { |
|
40 | + if (! $this->mapping || $refresh) { |
|
41 | + $this->mapping = $this->generateNewMapping(); |
|
42 | + } |
|
43 | + return $this->mapping; |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Generates anew mapping between model calculated fields and their callbacks |
|
50 | - * |
|
51 | - * @return array |
|
52 | - */ |
|
53 | - protected function generateNewMapping() |
|
54 | - { |
|
55 | - $rest_api_calculations_namespace = 'EventEspresso\core\libraries\rest_api\calculations\\'; |
|
56 | - $event_calculations_class = $rest_api_calculations_namespace . 'Event'; |
|
57 | - $datetime_calculations_class = $rest_api_calculations_namespace . 'Datetime'; |
|
58 | - $registration_class = $rest_api_calculations_namespace . 'Registration'; |
|
59 | - return apply_filters( |
|
60 | - 'FHEE__EventEspresso\core\libraries\rest_api\Calculated_Model_Fields__mapping', |
|
61 | - array( |
|
62 | - 'Event' => array( |
|
63 | - 'optimum_sales_at_start' => $event_calculations_class, |
|
64 | - 'optimum_sales_now' => $event_calculations_class, |
|
65 | - 'spots_taken' => $event_calculations_class, |
|
66 | - 'spots_taken_pending_payment' => $event_calculations_class, |
|
67 | - 'spaces_remaining' => $event_calculations_class, |
|
68 | - 'registrations_checked_in_count' => $event_calculations_class, |
|
69 | - 'registrations_checked_out_count' => $event_calculations_class, |
|
70 | - 'image_thumbnail' => $event_calculations_class, |
|
71 | - 'image_medium' => $event_calculations_class, |
|
72 | - 'image_medium_large' => $event_calculations_class, |
|
73 | - 'image_large' => $event_calculations_class, |
|
74 | - 'image_post_thumbnail' => $event_calculations_class, |
|
75 | - 'image_full' => $event_calculations_class, |
|
76 | - ), |
|
77 | - 'Datetime' => array( |
|
78 | - 'spaces_remaining_considering_tickets' => $datetime_calculations_class, |
|
79 | - 'registrations_checked_in_count' => $datetime_calculations_class, |
|
80 | - 'registrations_checked_out_count' => $datetime_calculations_class, |
|
81 | - 'spots_taken_pending_payment' => $datetime_calculations_class, |
|
82 | - ), |
|
83 | - 'Registration' => array( |
|
84 | - 'datetime_checkin_stati' => $registration_class, |
|
85 | - ), |
|
86 | - ) |
|
87 | - ); |
|
88 | - } |
|
48 | + /** |
|
49 | + * Generates anew mapping between model calculated fields and their callbacks |
|
50 | + * |
|
51 | + * @return array |
|
52 | + */ |
|
53 | + protected function generateNewMapping() |
|
54 | + { |
|
55 | + $rest_api_calculations_namespace = 'EventEspresso\core\libraries\rest_api\calculations\\'; |
|
56 | + $event_calculations_class = $rest_api_calculations_namespace . 'Event'; |
|
57 | + $datetime_calculations_class = $rest_api_calculations_namespace . 'Datetime'; |
|
58 | + $registration_class = $rest_api_calculations_namespace . 'Registration'; |
|
59 | + return apply_filters( |
|
60 | + 'FHEE__EventEspresso\core\libraries\rest_api\Calculated_Model_Fields__mapping', |
|
61 | + array( |
|
62 | + 'Event' => array( |
|
63 | + 'optimum_sales_at_start' => $event_calculations_class, |
|
64 | + 'optimum_sales_now' => $event_calculations_class, |
|
65 | + 'spots_taken' => $event_calculations_class, |
|
66 | + 'spots_taken_pending_payment' => $event_calculations_class, |
|
67 | + 'spaces_remaining' => $event_calculations_class, |
|
68 | + 'registrations_checked_in_count' => $event_calculations_class, |
|
69 | + 'registrations_checked_out_count' => $event_calculations_class, |
|
70 | + 'image_thumbnail' => $event_calculations_class, |
|
71 | + 'image_medium' => $event_calculations_class, |
|
72 | + 'image_medium_large' => $event_calculations_class, |
|
73 | + 'image_large' => $event_calculations_class, |
|
74 | + 'image_post_thumbnail' => $event_calculations_class, |
|
75 | + 'image_full' => $event_calculations_class, |
|
76 | + ), |
|
77 | + 'Datetime' => array( |
|
78 | + 'spaces_remaining_considering_tickets' => $datetime_calculations_class, |
|
79 | + 'registrations_checked_in_count' => $datetime_calculations_class, |
|
80 | + 'registrations_checked_out_count' => $datetime_calculations_class, |
|
81 | + 'spots_taken_pending_payment' => $datetime_calculations_class, |
|
82 | + ), |
|
83 | + 'Registration' => array( |
|
84 | + 'datetime_checkin_stati' => $registration_class, |
|
85 | + ), |
|
86 | + ) |
|
87 | + ); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * Gets the known calculated fields for model |
|
94 | - * |
|
95 | - * @param EEM_Base $model |
|
96 | - * @return array allowable values for this field |
|
97 | - */ |
|
98 | - public function retrieveCalculatedFieldsForModel(EEM_Base $model) |
|
99 | - { |
|
100 | - $mapping = $this->mapping(); |
|
101 | - if (isset($mapping[$model->get_this_model_name()])) { |
|
102 | - return array_keys($mapping[$model->get_this_model_name()]); |
|
103 | - } else { |
|
104 | - return array(); |
|
105 | - } |
|
106 | - } |
|
92 | + /** |
|
93 | + * Gets the known calculated fields for model |
|
94 | + * |
|
95 | + * @param EEM_Base $model |
|
96 | + * @return array allowable values for this field |
|
97 | + */ |
|
98 | + public function retrieveCalculatedFieldsForModel(EEM_Base $model) |
|
99 | + { |
|
100 | + $mapping = $this->mapping(); |
|
101 | + if (isset($mapping[$model->get_this_model_name()])) { |
|
102 | + return array_keys($mapping[$model->get_this_model_name()]); |
|
103 | + } else { |
|
104 | + return array(); |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | 108 | |
109 | 109 | |
110 | - /** |
|
111 | - * Retrieves the value for this calculation |
|
112 | - * |
|
113 | - * @param EEM_Base $model |
|
114 | - * @param string $field_name |
|
115 | - * @param array $wpdb_row |
|
116 | - * @param \WP_REST_Request |
|
117 | - * @param \EventEspresso\core\libraries\rest_api\controllers\Base $controller |
|
118 | - * @return mixed|null |
|
119 | - * @throws \EE_Error |
|
120 | - */ |
|
121 | - public function retrieveCalculatedFieldValue( |
|
122 | - EEM_Base $model, |
|
123 | - $field_name, |
|
124 | - $wpdb_row, |
|
125 | - $rest_request, |
|
126 | - Base $controller |
|
127 | - ) { |
|
128 | - $mapping = $this->mapping(); |
|
129 | - if (isset($mapping[$model->get_this_model_name()]) |
|
130 | - && isset($mapping[$model->get_this_model_name()][$field_name]) |
|
131 | - ) { |
|
132 | - $classname = $mapping[$model->get_this_model_name()][$field_name]; |
|
133 | - $class_method_name = EEH_Inflector::camelize_all_but_first($field_name); |
|
134 | - return call_user_func(array($classname, $class_method_name), $wpdb_row, $rest_request, $controller); |
|
135 | - } |
|
136 | - throw new RestException( |
|
137 | - 'calculated_field_does_not_exist', |
|
138 | - sprintf( |
|
139 | - __('There is no calculated field %1$s on resource %2$s', 'event_espresso'), |
|
140 | - $field_name, |
|
141 | - $model->get_this_model_name() |
|
142 | - ) |
|
143 | - ); |
|
144 | - } |
|
110 | + /** |
|
111 | + * Retrieves the value for this calculation |
|
112 | + * |
|
113 | + * @param EEM_Base $model |
|
114 | + * @param string $field_name |
|
115 | + * @param array $wpdb_row |
|
116 | + * @param \WP_REST_Request |
|
117 | + * @param \EventEspresso\core\libraries\rest_api\controllers\Base $controller |
|
118 | + * @return mixed|null |
|
119 | + * @throws \EE_Error |
|
120 | + */ |
|
121 | + public function retrieveCalculatedFieldValue( |
|
122 | + EEM_Base $model, |
|
123 | + $field_name, |
|
124 | + $wpdb_row, |
|
125 | + $rest_request, |
|
126 | + Base $controller |
|
127 | + ) { |
|
128 | + $mapping = $this->mapping(); |
|
129 | + if (isset($mapping[$model->get_this_model_name()]) |
|
130 | + && isset($mapping[$model->get_this_model_name()][$field_name]) |
|
131 | + ) { |
|
132 | + $classname = $mapping[$model->get_this_model_name()][$field_name]; |
|
133 | + $class_method_name = EEH_Inflector::camelize_all_but_first($field_name); |
|
134 | + return call_user_func(array($classname, $class_method_name), $wpdb_row, $rest_request, $controller); |
|
135 | + } |
|
136 | + throw new RestException( |
|
137 | + 'calculated_field_does_not_exist', |
|
138 | + sprintf( |
|
139 | + __('There is no calculated field %1$s on resource %2$s', 'event_espresso'), |
|
140 | + $field_name, |
|
141 | + $model->get_this_model_name() |
|
142 | + ) |
|
143 | + ); |
|
144 | + } |
|
145 | 145 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function mapping($refresh = false) |
39 | 39 | { |
40 | - if (! $this->mapping || $refresh) { |
|
40 | + if ( ! $this->mapping || $refresh) { |
|
41 | 41 | $this->mapping = $this->generateNewMapping(); |
42 | 42 | } |
43 | 43 | return $this->mapping; |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | protected function generateNewMapping() |
54 | 54 | { |
55 | 55 | $rest_api_calculations_namespace = 'EventEspresso\core\libraries\rest_api\calculations\\'; |
56 | - $event_calculations_class = $rest_api_calculations_namespace . 'Event'; |
|
57 | - $datetime_calculations_class = $rest_api_calculations_namespace . 'Datetime'; |
|
58 | - $registration_class = $rest_api_calculations_namespace . 'Registration'; |
|
56 | + $event_calculations_class = $rest_api_calculations_namespace.'Event'; |
|
57 | + $datetime_calculations_class = $rest_api_calculations_namespace.'Datetime'; |
|
58 | + $registration_class = $rest_api_calculations_namespace.'Registration'; |
|
59 | 59 | return apply_filters( |
60 | 60 | 'FHEE__EventEspresso\core\libraries\rest_api\Calculated_Model_Fields__mapping', |
61 | 61 | array( |
@@ -22,124 +22,124 @@ |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @param \WP_REST_Request $request |
|
27 | - * @param string $version |
|
28 | - * @return array|\WP_REST_Response |
|
29 | - */ |
|
30 | - public static function handleRequestModelsMeta(\WP_REST_Request $request, $version) |
|
31 | - { |
|
32 | - $controller = new Meta(); |
|
33 | - try { |
|
34 | - $controller->setRequestedVersion($version); |
|
35 | - return $controller->sendResponse($controller->getModelsMetadataEntity()); |
|
36 | - } catch (Exception $e) { |
|
37 | - return $controller->sendResponse($e); |
|
38 | - } |
|
39 | - } |
|
25 | + /** |
|
26 | + * @param \WP_REST_Request $request |
|
27 | + * @param string $version |
|
28 | + * @return array|\WP_REST_Response |
|
29 | + */ |
|
30 | + public static function handleRequestModelsMeta(\WP_REST_Request $request, $version) |
|
31 | + { |
|
32 | + $controller = new Meta(); |
|
33 | + try { |
|
34 | + $controller->setRequestedVersion($version); |
|
35 | + return $controller->sendResponse($controller->getModelsMetadataEntity()); |
|
36 | + } catch (Exception $e) { |
|
37 | + return $controller->sendResponse($e); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | 42 | |
43 | - /* |
|
43 | + /* |
|
44 | 44 | * Gets the model metadata resource entity |
45 | 45 | * @return array for JSON response, describing all the models available in teh requested version |
46 | 46 | */ |
47 | - protected function getModelsMetadataEntity() |
|
48 | - { |
|
49 | - $response = array(); |
|
50 | - foreach ($this->getModelVersionInfo()->modelsForRequestedVersion() as $model_name => $model_classname) { |
|
51 | - $model = $this->getModelVersionInfo()->loadModel($model_name); |
|
52 | - $fields_json = array(); |
|
53 | - foreach ($this->getModelVersionInfo()->fieldsOnModelInThisVersion($model) as $field_name => $field_obj) { |
|
54 | - if ($this->getModelVersionInfo()->fieldIsIgnored($field_obj)) { |
|
55 | - continue; |
|
56 | - } |
|
57 | - if ($field_obj instanceof EE_Boolean_Field) { |
|
58 | - $datatype = 'Boolean'; |
|
59 | - } elseif ($field_obj->get_wpdb_data_type() == '%d') { |
|
60 | - $datatype = 'Number'; |
|
61 | - } elseif ($field_name instanceof EE_Serialized_Text_Field) { |
|
62 | - $datatype = 'Object'; |
|
63 | - } else { |
|
64 | - $datatype = 'String'; |
|
65 | - } |
|
66 | - $default_value = ModelDataTranslator::prepareFieldValueForJson( |
|
67 | - $field_obj, |
|
68 | - $field_obj->get_default_value(), |
|
69 | - $this->getModelVersionInfo()->requestedVersion() |
|
70 | - ); |
|
71 | - $field_json = array( |
|
72 | - 'name' => $field_name, |
|
73 | - 'nicename' => wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES), |
|
74 | - 'has_rendered_format' => $this->getModelVersionInfo()->fieldHasRenderedFormat($field_obj), |
|
75 | - 'has_pretty_format' => $this->getModelVersionInfo()->fieldHasPrettyFormat($field_obj), |
|
76 | - 'type' => str_replace('EE_', '', get_class($field_obj)), |
|
77 | - 'datatype' => $datatype, |
|
78 | - 'nullable' => $field_obj->is_nullable(), |
|
79 | - 'default' => $default_value, |
|
80 | - 'table_alias' => $field_obj->get_table_alias(), |
|
81 | - 'table_column' => $field_obj->get_table_column(), |
|
82 | - ); |
|
83 | - $fields_json[$field_json['name']] = $field_json; |
|
84 | - } |
|
85 | - $fields_json = array_merge( |
|
86 | - $fields_json, |
|
87 | - $this->getModelVersionInfo()->extraResourcePropertiesForModel($model) |
|
88 | - ); |
|
89 | - $response[$model_name]['fields'] = apply_filters( |
|
90 | - 'FHEE__Meta__handle_request_models_meta__fields', |
|
91 | - $fields_json, |
|
92 | - $model |
|
93 | - ); |
|
94 | - $relations_json = array(); |
|
95 | - foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
96 | - $relation_json = array( |
|
97 | - 'name' => $relation_name, |
|
98 | - 'type' => str_replace('EE_', '', get_class($relation_obj)), |
|
99 | - 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false, |
|
100 | - ); |
|
101 | - $relations_json[$relation_name] = $relation_json; |
|
102 | - } |
|
103 | - $response[$model_name]['relations'] = apply_filters( |
|
104 | - 'FHEE__Meta__handle_request_models_meta__relations', |
|
105 | - $relations_json, |
|
106 | - $model |
|
107 | - ); |
|
108 | - } |
|
109 | - return $response; |
|
110 | - } |
|
47 | + protected function getModelsMetadataEntity() |
|
48 | + { |
|
49 | + $response = array(); |
|
50 | + foreach ($this->getModelVersionInfo()->modelsForRequestedVersion() as $model_name => $model_classname) { |
|
51 | + $model = $this->getModelVersionInfo()->loadModel($model_name); |
|
52 | + $fields_json = array(); |
|
53 | + foreach ($this->getModelVersionInfo()->fieldsOnModelInThisVersion($model) as $field_name => $field_obj) { |
|
54 | + if ($this->getModelVersionInfo()->fieldIsIgnored($field_obj)) { |
|
55 | + continue; |
|
56 | + } |
|
57 | + if ($field_obj instanceof EE_Boolean_Field) { |
|
58 | + $datatype = 'Boolean'; |
|
59 | + } elseif ($field_obj->get_wpdb_data_type() == '%d') { |
|
60 | + $datatype = 'Number'; |
|
61 | + } elseif ($field_name instanceof EE_Serialized_Text_Field) { |
|
62 | + $datatype = 'Object'; |
|
63 | + } else { |
|
64 | + $datatype = 'String'; |
|
65 | + } |
|
66 | + $default_value = ModelDataTranslator::prepareFieldValueForJson( |
|
67 | + $field_obj, |
|
68 | + $field_obj->get_default_value(), |
|
69 | + $this->getModelVersionInfo()->requestedVersion() |
|
70 | + ); |
|
71 | + $field_json = array( |
|
72 | + 'name' => $field_name, |
|
73 | + 'nicename' => wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES), |
|
74 | + 'has_rendered_format' => $this->getModelVersionInfo()->fieldHasRenderedFormat($field_obj), |
|
75 | + 'has_pretty_format' => $this->getModelVersionInfo()->fieldHasPrettyFormat($field_obj), |
|
76 | + 'type' => str_replace('EE_', '', get_class($field_obj)), |
|
77 | + 'datatype' => $datatype, |
|
78 | + 'nullable' => $field_obj->is_nullable(), |
|
79 | + 'default' => $default_value, |
|
80 | + 'table_alias' => $field_obj->get_table_alias(), |
|
81 | + 'table_column' => $field_obj->get_table_column(), |
|
82 | + ); |
|
83 | + $fields_json[$field_json['name']] = $field_json; |
|
84 | + } |
|
85 | + $fields_json = array_merge( |
|
86 | + $fields_json, |
|
87 | + $this->getModelVersionInfo()->extraResourcePropertiesForModel($model) |
|
88 | + ); |
|
89 | + $response[$model_name]['fields'] = apply_filters( |
|
90 | + 'FHEE__Meta__handle_request_models_meta__fields', |
|
91 | + $fields_json, |
|
92 | + $model |
|
93 | + ); |
|
94 | + $relations_json = array(); |
|
95 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
96 | + $relation_json = array( |
|
97 | + 'name' => $relation_name, |
|
98 | + 'type' => str_replace('EE_', '', get_class($relation_obj)), |
|
99 | + 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false, |
|
100 | + ); |
|
101 | + $relations_json[$relation_name] = $relation_json; |
|
102 | + } |
|
103 | + $response[$model_name]['relations'] = apply_filters( |
|
104 | + 'FHEE__Meta__handle_request_models_meta__relations', |
|
105 | + $relations_json, |
|
106 | + $model |
|
107 | + ); |
|
108 | + } |
|
109 | + return $response; |
|
110 | + } |
|
111 | 111 | |
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * Adds EE metadata to the index |
|
116 | - * |
|
117 | - * @param \WP_REST_Response $rest_response_obj |
|
118 | - * @return \WP_REST_Response |
|
119 | - */ |
|
120 | - public static function filterEeMetadataIntoIndex(\WP_REST_Response $rest_response_obj) |
|
121 | - { |
|
122 | - $response_data = $rest_response_obj->get_data(); |
|
123 | - $addons = array(); |
|
124 | - foreach (EE_Registry::instance()->addons as $addon) { |
|
125 | - $addon_json = array( |
|
126 | - 'name' => $addon->name(), |
|
127 | - 'version' => $addon->version(), |
|
128 | - ); |
|
129 | - $addons[$addon_json['name']] = $addon_json; |
|
130 | - } |
|
131 | - $response_data['ee'] = array( |
|
132 | - 'version' => EEM_System_Status::instance()->get_ee_version(), |
|
133 | - // @codingStandardsIgnoreStart |
|
134 | - 'documentation_url' => 'https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API', |
|
135 | - // @codingStandardsIgnoreEnd |
|
136 | - 'addons' => $addons, |
|
137 | - 'maintenance_mode' => EE_Maintenance_Mode::instance()->real_level(), |
|
138 | - 'served_core_versions' => array_keys(EED_Core_Rest_Api::versions_served()), |
|
139 | - ); |
|
140 | - $rest_response_obj->set_data($response_data); |
|
141 | - return $rest_response_obj; |
|
142 | - } |
|
114 | + /** |
|
115 | + * Adds EE metadata to the index |
|
116 | + * |
|
117 | + * @param \WP_REST_Response $rest_response_obj |
|
118 | + * @return \WP_REST_Response |
|
119 | + */ |
|
120 | + public static function filterEeMetadataIntoIndex(\WP_REST_Response $rest_response_obj) |
|
121 | + { |
|
122 | + $response_data = $rest_response_obj->get_data(); |
|
123 | + $addons = array(); |
|
124 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
125 | + $addon_json = array( |
|
126 | + 'name' => $addon->name(), |
|
127 | + 'version' => $addon->version(), |
|
128 | + ); |
|
129 | + $addons[$addon_json['name']] = $addon_json; |
|
130 | + } |
|
131 | + $response_data['ee'] = array( |
|
132 | + 'version' => EEM_System_Status::instance()->get_ee_version(), |
|
133 | + // @codingStandardsIgnoreStart |
|
134 | + 'documentation_url' => 'https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API', |
|
135 | + // @codingStandardsIgnoreEnd |
|
136 | + 'addons' => $addons, |
|
137 | + 'maintenance_mode' => EE_Maintenance_Mode::instance()->real_level(), |
|
138 | + 'served_core_versions' => array_keys(EED_Core_Rest_Api::versions_served()), |
|
139 | + ); |
|
140 | + $rest_response_obj->set_data($response_data); |
|
141 | + return $rest_response_obj; |
|
142 | + } |
|
143 | 143 | } |
144 | 144 | |
145 | 145 |
@@ -16,69 +16,69 @@ |
||
16 | 16 | class Base extends Controller_Base |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Holds reference to the model version info, which knows the requested version |
|
21 | - * |
|
22 | - * @var ModelVersionInfo |
|
23 | - */ |
|
24 | - protected $model_version_info; |
|
19 | + /** |
|
20 | + * Holds reference to the model version info, which knows the requested version |
|
21 | + * |
|
22 | + * @var ModelVersionInfo |
|
23 | + */ |
|
24 | + protected $model_version_info; |
|
25 | 25 | |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * Sets the version the user requested |
|
30 | - * |
|
31 | - * @param string $version eg '4.8' |
|
32 | - */ |
|
33 | - public function setRequestedVersion($version) |
|
34 | - { |
|
35 | - parent::setRequestedVersion($version); |
|
36 | - $this->model_version_info = new ModelVersionInfo($version); |
|
37 | - } |
|
28 | + /** |
|
29 | + * Sets the version the user requested |
|
30 | + * |
|
31 | + * @param string $version eg '4.8' |
|
32 | + */ |
|
33 | + public function setRequestedVersion($version) |
|
34 | + { |
|
35 | + parent::setRequestedVersion($version); |
|
36 | + $this->model_version_info = new ModelVersionInfo($version); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Gets the object that should be used for getting any info from the models, |
|
43 | - * because it's takes the requested and current core version into account |
|
44 | - * |
|
45 | - * @return \EventEspresso\core\libraries\rest_api\ModelVersionInfo |
|
46 | - * @throws EE_Error |
|
47 | - */ |
|
48 | - public function getModelVersionInfo() |
|
49 | - { |
|
50 | - if (! $this->model_version_info) { |
|
51 | - throw new EE_Error( |
|
52 | - sprintf( |
|
53 | - __( |
|
54 | - 'Cannot use model version info before setting the requested version in the controller', |
|
55 | - 'event_espresso' |
|
56 | - ) |
|
57 | - ) |
|
58 | - ); |
|
59 | - } |
|
60 | - return $this->model_version_info; |
|
61 | - } |
|
41 | + /** |
|
42 | + * Gets the object that should be used for getting any info from the models, |
|
43 | + * because it's takes the requested and current core version into account |
|
44 | + * |
|
45 | + * @return \EventEspresso\core\libraries\rest_api\ModelVersionInfo |
|
46 | + * @throws EE_Error |
|
47 | + */ |
|
48 | + public function getModelVersionInfo() |
|
49 | + { |
|
50 | + if (! $this->model_version_info) { |
|
51 | + throw new EE_Error( |
|
52 | + sprintf( |
|
53 | + __( |
|
54 | + 'Cannot use model version info before setting the requested version in the controller', |
|
55 | + 'event_espresso' |
|
56 | + ) |
|
57 | + ) |
|
58 | + ); |
|
59 | + } |
|
60 | + return $this->model_version_info; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * Determines if $object is of one of the classes of $classes. Similar to |
|
67 | - * in_array(), except this checks if $object is a subclass of the classnames provided |
|
68 | - * in $classnames |
|
69 | - * |
|
70 | - * @param object $object |
|
71 | - * @param array $classnames |
|
72 | - * @return boolean |
|
73 | - */ |
|
74 | - public function isSubclassOfOne($object, $classnames) |
|
75 | - { |
|
76 | - foreach ($classnames as $classname) { |
|
77 | - if (is_a($object, $classname)) { |
|
78 | - return true; |
|
79 | - } |
|
80 | - } |
|
81 | - return false; |
|
82 | - } |
|
65 | + /** |
|
66 | + * Determines if $object is of one of the classes of $classes. Similar to |
|
67 | + * in_array(), except this checks if $object is a subclass of the classnames provided |
|
68 | + * in $classnames |
|
69 | + * |
|
70 | + * @param object $object |
|
71 | + * @param array $classnames |
|
72 | + * @return boolean |
|
73 | + */ |
|
74 | + public function isSubclassOfOne($object, $classnames) |
|
75 | + { |
|
76 | + foreach ($classnames as $classname) { |
|
77 | + if (is_a($object, $classname)) { |
|
78 | + return true; |
|
79 | + } |
|
80 | + } |
|
81 | + return false; |
|
82 | + } |
|
83 | 83 | } |
84 | 84 | // End of file Base.php |
@@ -47,7 +47,7 @@ |
||
47 | 47 | */ |
48 | 48 | public function getModelVersionInfo() |
49 | 49 | { |
50 | - if (! $this->model_version_info) { |
|
50 | + if ( ! $this->model_version_info) { |
|
51 | 51 | throw new EE_Error( |
52 | 52 | sprintf( |
53 | 53 | __( |
@@ -19,85 +19,85 @@ |
||
19 | 19 | class Read |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @param WP_REST_Request $request |
|
24 | - * @param string $version |
|
25 | - * @return EE_Config|WP_Error |
|
26 | - */ |
|
27 | - public static function handleRequest(WP_REST_Request $request, $version) |
|
28 | - { |
|
29 | - $cap = EE_Restriction_Generator_Base::get_default_restrictions_cap(); |
|
30 | - if (EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) { |
|
31 | - return EE_Config::instance(); |
|
32 | - } else { |
|
33 | - return new WP_Error( |
|
34 | - 'cannot_read_config', |
|
35 | - sprintf( |
|
36 | - __( |
|
37 | - 'You do not have the necessary capabilities (%s) to read Event Espresso Configuration data', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - $cap |
|
41 | - ), |
|
42 | - array('status' => 403) |
|
43 | - ); |
|
44 | - } |
|
45 | - } |
|
22 | + /** |
|
23 | + * @param WP_REST_Request $request |
|
24 | + * @param string $version |
|
25 | + * @return EE_Config|WP_Error |
|
26 | + */ |
|
27 | + public static function handleRequest(WP_REST_Request $request, $version) |
|
28 | + { |
|
29 | + $cap = EE_Restriction_Generator_Base::get_default_restrictions_cap(); |
|
30 | + if (EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) { |
|
31 | + return EE_Config::instance(); |
|
32 | + } else { |
|
33 | + return new WP_Error( |
|
34 | + 'cannot_read_config', |
|
35 | + sprintf( |
|
36 | + __( |
|
37 | + 'You do not have the necessary capabilities (%s) to read Event Espresso Configuration data', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + $cap |
|
41 | + ), |
|
42 | + array('status' => 403) |
|
43 | + ); |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Handles the request for public site info |
|
51 | - * |
|
52 | - * @global $wp_json_basic_auth_success boolean set by the basic auth plugin, indicates if the |
|
53 | - * current user could be authenticated using basic auth data |
|
54 | - * @global $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if |
|
55 | - * basic auth data was somehow received |
|
56 | - * @param WP_REST_Request $request |
|
57 | - * @param string $version |
|
58 | - * @return array|WP_Error |
|
59 | - */ |
|
60 | - public static function handleRequestSiteInfo(WP_REST_Request $request, $version) |
|
61 | - { |
|
62 | - global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data; |
|
63 | - $insecure_usage_of_basic_auth = apply_filters( |
|
64 | - // @codingStandardsIgnoreStart |
|
65 | - 'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth', |
|
66 | - // @codingStandardsIgnoreEnd |
|
67 | - $wp_json_basic_auth_success && ! is_ssl(), |
|
68 | - $request |
|
69 | - ); |
|
70 | - if ($insecure_usage_of_basic_auth) { |
|
71 | - $warning = sprintf( |
|
72 | - esc_html__( |
|
73 | - // @codingStandardsIgnoreStart |
|
74 | - 'Notice: We strongly recommend installing an SSL Certificate on your website to keep your data secure. %1$sPlease see our recommendations.%2$s', |
|
75 | - // @codingStandardsIgnoreEnd |
|
76 | - 'event_espresso' |
|
77 | - ), |
|
78 | - '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">', |
|
79 | - '</a>' |
|
80 | - ); |
|
81 | - } else { |
|
82 | - $warning = ''; |
|
83 | - } |
|
84 | - return apply_filters( |
|
85 | - 'FHEE__EventEspresso_core_libraries_rest_api_controllers_config__handleRequestSiteInfo__return_val', |
|
86 | - array( |
|
87 | - 'default_timezone' => array( |
|
88 | - 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
89 | - 'string' => get_option('timezone_string'), |
|
90 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
91 | - ), |
|
92 | - 'default_currency' => EE_Config::instance()->currency, |
|
93 | - 'authentication' => array( |
|
94 | - 'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data, |
|
95 | - 'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth, |
|
96 | - 'warning' => $warning |
|
97 | - ) |
|
98 | - ) |
|
99 | - ); |
|
100 | - } |
|
49 | + /** |
|
50 | + * Handles the request for public site info |
|
51 | + * |
|
52 | + * @global $wp_json_basic_auth_success boolean set by the basic auth plugin, indicates if the |
|
53 | + * current user could be authenticated using basic auth data |
|
54 | + * @global $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if |
|
55 | + * basic auth data was somehow received |
|
56 | + * @param WP_REST_Request $request |
|
57 | + * @param string $version |
|
58 | + * @return array|WP_Error |
|
59 | + */ |
|
60 | + public static function handleRequestSiteInfo(WP_REST_Request $request, $version) |
|
61 | + { |
|
62 | + global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data; |
|
63 | + $insecure_usage_of_basic_auth = apply_filters( |
|
64 | + // @codingStandardsIgnoreStart |
|
65 | + 'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth', |
|
66 | + // @codingStandardsIgnoreEnd |
|
67 | + $wp_json_basic_auth_success && ! is_ssl(), |
|
68 | + $request |
|
69 | + ); |
|
70 | + if ($insecure_usage_of_basic_auth) { |
|
71 | + $warning = sprintf( |
|
72 | + esc_html__( |
|
73 | + // @codingStandardsIgnoreStart |
|
74 | + 'Notice: We strongly recommend installing an SSL Certificate on your website to keep your data secure. %1$sPlease see our recommendations.%2$s', |
|
75 | + // @codingStandardsIgnoreEnd |
|
76 | + 'event_espresso' |
|
77 | + ), |
|
78 | + '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">', |
|
79 | + '</a>' |
|
80 | + ); |
|
81 | + } else { |
|
82 | + $warning = ''; |
|
83 | + } |
|
84 | + return apply_filters( |
|
85 | + 'FHEE__EventEspresso_core_libraries_rest_api_controllers_config__handleRequestSiteInfo__return_val', |
|
86 | + array( |
|
87 | + 'default_timezone' => array( |
|
88 | + 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
89 | + 'string' => get_option('timezone_string'), |
|
90 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
91 | + ), |
|
92 | + 'default_currency' => EE_Config::instance()->currency, |
|
93 | + 'authentication' => array( |
|
94 | + 'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data, |
|
95 | + 'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth, |
|
96 | + 'warning' => $warning |
|
97 | + ) |
|
98 | + ) |
|
99 | + ); |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | // End of file Read.php |
@@ -91,8 +91,8 @@ |
||
91 | 91 | ), |
92 | 92 | 'default_currency' => EE_Config::instance()->currency, |
93 | 93 | 'authentication' => array( |
94 | - 'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data, |
|
95 | - 'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth, |
|
94 | + 'received_basic_auth_data' => (bool) $wp_json_basic_auth_received_data, |
|
95 | + 'insecure_usage_of_basic_auth' => (bool) $insecure_usage_of_basic_auth, |
|
96 | 96 | 'warning' => $warning |
97 | 97 | ) |
98 | 98 | ) |