@@ -10,52 +10,52 @@ |
||
10 | 10 | */ |
11 | 11 | trait MessagesAdmin |
12 | 12 | { |
13 | - /** |
|
14 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
15 | - * a string. |
|
16 | - */ |
|
17 | - public function amOnMessagesActivityListTablePage($additional_params = '') |
|
18 | - { |
|
19 | - $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
20 | - } |
|
21 | - |
|
22 | - /** |
|
23 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
24 | - * a string. |
|
25 | - */ |
|
26 | - public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
27 | - { |
|
28 | - $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
29 | - } |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
34 | - * a string. |
|
35 | - */ |
|
36 | - public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
37 | - { |
|
38 | - $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * Directs to message settings page |
|
44 | - */ |
|
45 | - public function amOnMessageSettingsPage() |
|
46 | - { |
|
47 | - $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Assumes you are already on the list table page that has the ui for editing the template. |
|
53 | - * @param string $message_type_slug |
|
54 | - * @param string $context [optional] if you want to click directly to the given context in the editor |
|
55 | - */ |
|
56 | - public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
57 | - { |
|
58 | - $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
59 | - } |
|
13 | + /** |
|
14 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
15 | + * a string. |
|
16 | + */ |
|
17 | + public function amOnMessagesActivityListTablePage($additional_params = '') |
|
18 | + { |
|
19 | + $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
20 | + } |
|
21 | + |
|
22 | + /** |
|
23 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
24 | + * a string. |
|
25 | + */ |
|
26 | + public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
27 | + { |
|
28 | + $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
29 | + } |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
34 | + * a string. |
|
35 | + */ |
|
36 | + public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
37 | + { |
|
38 | + $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Directs to message settings page |
|
44 | + */ |
|
45 | + public function amOnMessageSettingsPage() |
|
46 | + { |
|
47 | + $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Assumes you are already on the list table page that has the ui for editing the template. |
|
53 | + * @param string $message_type_slug |
|
54 | + * @param string $context [optional] if you want to click directly to the given context in the editor |
|
55 | + */ |
|
56 | + public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
57 | + { |
|
58 | + $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | \ No newline at end of file |
@@ -13,28 +13,28 @@ |
||
13 | 13 | class CoreAdmin |
14 | 14 | { |
15 | 15 | |
16 | - const URL_PREFIX = 'admin.php?page='; |
|
16 | + const URL_PREFIX = 'admin.php?page='; |
|
17 | 17 | |
18 | 18 | |
19 | - const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page'; |
|
19 | + const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page'; |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * Get the EE admin url for the given properties. |
|
24 | - * Note, this is JUST the endpoint for the admin route. It is expected that the actor/test would be calling this |
|
25 | - * with `amOnAdminPage` action. |
|
26 | - * |
|
27 | - * @param string $page |
|
28 | - * @param string $action |
|
29 | - * @param string $additional_params |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '') |
|
33 | - { |
|
34 | - $url = self::URL_PREFIX . $page; |
|
35 | - $url .= $action ? '&action=' . $action : ''; |
|
36 | - $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : ''; |
|
37 | - return $url; |
|
38 | - } |
|
22 | + /** |
|
23 | + * Get the EE admin url for the given properties. |
|
24 | + * Note, this is JUST the endpoint for the admin route. It is expected that the actor/test would be calling this |
|
25 | + * with `amOnAdminPage` action. |
|
26 | + * |
|
27 | + * @param string $page |
|
28 | + * @param string $action |
|
29 | + * @param string $additional_params |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '') |
|
33 | + { |
|
34 | + $url = self::URL_PREFIX . $page; |
|
35 | + $url .= $action ? '&action=' . $action : ''; |
|
36 | + $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : ''; |
|
37 | + return $url; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | \ No newline at end of file |
@@ -31,9 +31,9 @@ |
||
31 | 31 | */ |
32 | 32 | public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '') |
33 | 33 | { |
34 | - $url = self::URL_PREFIX . $page; |
|
35 | - $url .= $action ? '&action=' . $action : ''; |
|
36 | - $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : ''; |
|
34 | + $url = self::URL_PREFIX.$page; |
|
35 | + $url .= $action ? '&action='.$action : ''; |
|
36 | + $url .= $additional_params ? '&'.ltrim('&', ltrim('?', $additional_params)) : ''; |
|
37 | 37 | return $url; |
38 | 38 | } |
39 | 39 |
@@ -4,58 +4,58 @@ |
||
4 | 4 | class MessagesAdmin extends CoreAdmin |
5 | 5 | { |
6 | 6 | |
7 | - /** |
|
8 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
9 | - * a string. |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - public static function messageActivityListTableUrl($additional_params = '') |
|
13 | - { |
|
14 | - return self::adminUrl('espresso_messages', 'default', $additional_params); |
|
15 | - } |
|
16 | - |
|
17 | - |
|
18 | - /** |
|
19 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
20 | - * a string. |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public static function defaultMessageTemplateListTableUrl($additional_params = '') |
|
24 | - { |
|
25 | - return self::adminUrl('espresso_messages', 'global_mtps', $additional_params); |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
31 | - * a string. |
|
32 | - * @return string |
|
33 | - */ |
|
34 | - public static function customMessageTemplateListTableUrl($additional_params = '') |
|
35 | - { |
|
36 | - return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public static function messageSettingsUrl() |
|
44 | - { |
|
45 | - return self::adminUrl('espresso_messages', 'settings'); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * @param string $message_type_slug |
|
51 | - * @param string $context |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '') |
|
55 | - { |
|
56 | - return $context |
|
57 | - ? '.' . $message_type_slug . '-' . $context . '-edit-link' |
|
58 | - : '.' . $message_type_slug . '-edit-link'; |
|
59 | - } |
|
7 | + /** |
|
8 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
9 | + * a string. |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + public static function messageActivityListTableUrl($additional_params = '') |
|
13 | + { |
|
14 | + return self::adminUrl('espresso_messages', 'default', $additional_params); |
|
15 | + } |
|
16 | + |
|
17 | + |
|
18 | + /** |
|
19 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
20 | + * a string. |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public static function defaultMessageTemplateListTableUrl($additional_params = '') |
|
24 | + { |
|
25 | + return self::adminUrl('espresso_messages', 'global_mtps', $additional_params); |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
31 | + * a string. |
|
32 | + * @return string |
|
33 | + */ |
|
34 | + public static function customMessageTemplateListTableUrl($additional_params = '') |
|
35 | + { |
|
36 | + return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public static function messageSettingsUrl() |
|
44 | + { |
|
45 | + return self::adminUrl('espresso_messages', 'settings'); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * @param string $message_type_slug |
|
51 | + * @param string $context |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '') |
|
55 | + { |
|
56 | + return $context |
|
57 | + ? '.' . $message_type_slug . '-' . $context . '-edit-link' |
|
58 | + : '.' . $message_type_slug . '-edit-link'; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | \ No newline at end of file |
@@ -54,8 +54,8 @@ |
||
54 | 54 | public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '') |
55 | 55 | { |
56 | 56 | return $context |
57 | - ? '.' . $message_type_slug . '-' . $context . '-edit-link' |
|
58 | - : '.' . $message_type_slug . '-edit-link'; |
|
57 | + ? '.'.$message_type_slug.'-'.$context.'-edit-link' |
|
58 | + : '.'.$message_type_slug.'-edit-link'; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | } |
62 | 62 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.39.rc.034'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.39.rc.034'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -15,129 +15,129 @@ discard block |
||
15 | 15 | class EEM_WP_User extends EEM_Base |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * private instance of the EEM_WP_User object |
|
20 | - * |
|
21 | - * @type EEM_WP_User |
|
22 | - */ |
|
23 | - protected static $_instance = null; |
|
18 | + /** |
|
19 | + * private instance of the EEM_WP_User object |
|
20 | + * |
|
21 | + * @type EEM_WP_User |
|
22 | + */ |
|
23 | + protected static $_instance = null; |
|
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * constructor |
|
29 | - * |
|
30 | - * @param null $timezone |
|
31 | - * @throws \EE_Error |
|
32 | - */ |
|
33 | - protected function __construct($timezone = null) |
|
34 | - { |
|
35 | - $this->singular_item = __('WP_User', 'event_espresso'); |
|
36 | - $this->plural_item = __('WP_Users', 'event_espresso'); |
|
37 | - global $wpdb; |
|
38 | - $this->_tables = array( |
|
39 | - 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
40 | - ); |
|
41 | - $this->_fields = array( |
|
42 | - 'WP_User' => array( |
|
43 | - 'ID' => new EE_Primary_Key_Int_Field('ID', __('WP_User ID', 'event_espresso')), |
|
44 | - 'user_login' => new EE_Plain_Text_Field( |
|
45 | - 'user_login', |
|
46 | - __('User Login', 'event_espresso'), |
|
47 | - false, |
|
48 | - '' |
|
49 | - ), |
|
50 | - 'user_pass' => new EE_Plain_Text_Field( |
|
51 | - 'user_pass', |
|
52 | - __('User Password', 'event_espresso'), |
|
53 | - false, |
|
54 | - '' |
|
55 | - ), |
|
56 | - 'user_nicename' => new EE_Plain_Text_Field( |
|
57 | - 'user_nicename', |
|
58 | - __(' User Nice Name', 'event_espresso'), |
|
59 | - false, |
|
60 | - '' |
|
61 | - ), |
|
62 | - 'user_email' => new EE_Email_Field( |
|
63 | - 'user_email', |
|
64 | - __('User Email', 'event_espresso'), |
|
65 | - false |
|
66 | - ), |
|
67 | - 'user_registered' => new EE_Datetime_Field( |
|
68 | - 'user_registered', |
|
69 | - __('Date User Registered', 'event_espresso'), |
|
70 | - false, |
|
71 | - EE_Datetime_Field::now, |
|
72 | - $timezone |
|
73 | - ), |
|
74 | - 'user_activation_key' => new EE_Plain_Text_Field( |
|
75 | - 'user_activation_key', |
|
76 | - __('User Activation Key', 'event_espresso'), |
|
77 | - false, |
|
78 | - '' |
|
79 | - ), |
|
80 | - 'user_status' => new EE_Integer_Field( |
|
81 | - 'user_status', |
|
82 | - __('User Status', 'event_espresso'), |
|
83 | - false, |
|
84 | - 0 |
|
85 | - ), |
|
86 | - 'display_name' => new EE_Plain_Text_Field( |
|
87 | - 'display_name', |
|
88 | - __('Display Name', 'event_espresso'), |
|
89 | - false, |
|
90 | - '' |
|
91 | - ), |
|
92 | - ), |
|
93 | - ); |
|
94 | - $this->_model_relations = array( |
|
95 | - 'Attendee' => new EE_Has_Many_Relation(), |
|
96 | - 'Change_Log' => new EE_Has_Many_Relation(), |
|
97 | - 'Event' => new EE_Has_Many_Relation(), |
|
98 | - 'Payment_Method' => new EE_Has_Many_Relation(), |
|
99 | - 'Price' => new EE_Has_Many_Relation(), |
|
100 | - 'Price_Type' => new EE_Has_Many_Relation(), |
|
101 | - 'Question' => new EE_Has_Many_Relation(), |
|
102 | - 'Question_Group' => new EE_Has_Many_Relation(), |
|
103 | - 'Ticket' => new EE_Has_Many_Relation(), |
|
104 | - 'Venue' => new EE_Has_Many_Relation(), |
|
105 | - 'Message' => new EE_Has_Many_Relation(), |
|
106 | - ); |
|
107 | - $this->_wp_core_model = true; |
|
108 | - $this->_caps_slug = 'users'; |
|
109 | - $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read] = 'list'; |
|
110 | - $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read_admin] = 'list'; |
|
111 | - foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
112 | - $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_WP_User(); |
|
113 | - } |
|
114 | - //@todo: account for create_users controls whether they can create users at all |
|
115 | - parent::__construct($timezone); |
|
116 | - } |
|
27 | + /** |
|
28 | + * constructor |
|
29 | + * |
|
30 | + * @param null $timezone |
|
31 | + * @throws \EE_Error |
|
32 | + */ |
|
33 | + protected function __construct($timezone = null) |
|
34 | + { |
|
35 | + $this->singular_item = __('WP_User', 'event_espresso'); |
|
36 | + $this->plural_item = __('WP_Users', 'event_espresso'); |
|
37 | + global $wpdb; |
|
38 | + $this->_tables = array( |
|
39 | + 'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true), |
|
40 | + ); |
|
41 | + $this->_fields = array( |
|
42 | + 'WP_User' => array( |
|
43 | + 'ID' => new EE_Primary_Key_Int_Field('ID', __('WP_User ID', 'event_espresso')), |
|
44 | + 'user_login' => new EE_Plain_Text_Field( |
|
45 | + 'user_login', |
|
46 | + __('User Login', 'event_espresso'), |
|
47 | + false, |
|
48 | + '' |
|
49 | + ), |
|
50 | + 'user_pass' => new EE_Plain_Text_Field( |
|
51 | + 'user_pass', |
|
52 | + __('User Password', 'event_espresso'), |
|
53 | + false, |
|
54 | + '' |
|
55 | + ), |
|
56 | + 'user_nicename' => new EE_Plain_Text_Field( |
|
57 | + 'user_nicename', |
|
58 | + __(' User Nice Name', 'event_espresso'), |
|
59 | + false, |
|
60 | + '' |
|
61 | + ), |
|
62 | + 'user_email' => new EE_Email_Field( |
|
63 | + 'user_email', |
|
64 | + __('User Email', 'event_espresso'), |
|
65 | + false |
|
66 | + ), |
|
67 | + 'user_registered' => new EE_Datetime_Field( |
|
68 | + 'user_registered', |
|
69 | + __('Date User Registered', 'event_espresso'), |
|
70 | + false, |
|
71 | + EE_Datetime_Field::now, |
|
72 | + $timezone |
|
73 | + ), |
|
74 | + 'user_activation_key' => new EE_Plain_Text_Field( |
|
75 | + 'user_activation_key', |
|
76 | + __('User Activation Key', 'event_espresso'), |
|
77 | + false, |
|
78 | + '' |
|
79 | + ), |
|
80 | + 'user_status' => new EE_Integer_Field( |
|
81 | + 'user_status', |
|
82 | + __('User Status', 'event_espresso'), |
|
83 | + false, |
|
84 | + 0 |
|
85 | + ), |
|
86 | + 'display_name' => new EE_Plain_Text_Field( |
|
87 | + 'display_name', |
|
88 | + __('Display Name', 'event_espresso'), |
|
89 | + false, |
|
90 | + '' |
|
91 | + ), |
|
92 | + ), |
|
93 | + ); |
|
94 | + $this->_model_relations = array( |
|
95 | + 'Attendee' => new EE_Has_Many_Relation(), |
|
96 | + 'Change_Log' => new EE_Has_Many_Relation(), |
|
97 | + 'Event' => new EE_Has_Many_Relation(), |
|
98 | + 'Payment_Method' => new EE_Has_Many_Relation(), |
|
99 | + 'Price' => new EE_Has_Many_Relation(), |
|
100 | + 'Price_Type' => new EE_Has_Many_Relation(), |
|
101 | + 'Question' => new EE_Has_Many_Relation(), |
|
102 | + 'Question_Group' => new EE_Has_Many_Relation(), |
|
103 | + 'Ticket' => new EE_Has_Many_Relation(), |
|
104 | + 'Venue' => new EE_Has_Many_Relation(), |
|
105 | + 'Message' => new EE_Has_Many_Relation(), |
|
106 | + ); |
|
107 | + $this->_wp_core_model = true; |
|
108 | + $this->_caps_slug = 'users'; |
|
109 | + $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read] = 'list'; |
|
110 | + $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read_admin] = 'list'; |
|
111 | + foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) { |
|
112 | + $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_WP_User(); |
|
113 | + } |
|
114 | + //@todo: account for create_users controls whether they can create users at all |
|
115 | + parent::__construct($timezone); |
|
116 | + } |
|
117 | 117 | |
118 | 118 | |
119 | 119 | |
120 | - /** |
|
121 | - * We don't need a foreign key to the WP_User model, we just need its primary key |
|
122 | - * |
|
123 | - * @return string |
|
124 | - */ |
|
125 | - public function wp_user_field_name() |
|
126 | - { |
|
127 | - return $this->primary_key_name(); |
|
128 | - } |
|
120 | + /** |
|
121 | + * We don't need a foreign key to the WP_User model, we just need its primary key |
|
122 | + * |
|
123 | + * @return string |
|
124 | + */ |
|
125 | + public function wp_user_field_name() |
|
126 | + { |
|
127 | + return $this->primary_key_name(); |
|
128 | + } |
|
129 | 129 | |
130 | 130 | |
131 | 131 | |
132 | - /** |
|
133 | - * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
134 | - * |
|
135 | - * @return boolean |
|
136 | - */ |
|
137 | - public function is_owned() |
|
138 | - { |
|
139 | - return true; |
|
140 | - } |
|
132 | + /** |
|
133 | + * This WP_User model IS owned, even though it doesn't have a foreign key to itself |
|
134 | + * |
|
135 | + * @return boolean |
|
136 | + */ |
|
137 | + public function is_owned() |
|
138 | + { |
|
139 | + return true; |
|
140 | + } |
|
141 | 141 | } |
142 | 142 | // End of file EEM_WP_User.model.php |
143 | 143 | // Location: /core/db_models/EEM_WP_User.model.php |
@@ -1,4 +1,4 @@ |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -25,127 +25,127 @@ discard block |
||
25 | 25 | class EEM_Term_Taxonomy extends EEM_Base |
26 | 26 | { |
27 | 27 | |
28 | - // private instance of the Attendee object |
|
29 | - protected static $_instance = null; |
|
28 | + // private instance of the Attendee object |
|
29 | + protected static $_instance = null; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - protected function __construct($timezone = null) |
|
34 | - { |
|
35 | - $this->singular_item = __('Term Taxonomy', 'event_espresso'); |
|
36 | - $this->plural_item = __('Term Taxonomy', 'event_espresso'); |
|
37 | - $this->_tables = array( |
|
38 | - 'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'), |
|
39 | - ); |
|
40 | - $this->_fields = array( |
|
41 | - 'Term_Taxonomy' => array( |
|
42 | - 'term_taxonomy_id' => new EE_Primary_Key_Int_Field( |
|
43 | - 'term_taxonomy_id', |
|
44 | - __('Term-Taxonomy ID', 'event_espresso') |
|
45 | - ), |
|
46 | - 'term_id' => new EE_Foreign_Key_Int_Field( |
|
47 | - 'term_id', |
|
48 | - __("Term Id", "event_espresso"), |
|
49 | - false, |
|
50 | - 0, |
|
51 | - 'Term' |
|
52 | - ), |
|
53 | - 'taxonomy' => new EE_Plain_Text_Field( |
|
54 | - 'taxonomy', |
|
55 | - __('Taxonomy Name', 'event_espresso'), |
|
56 | - false, |
|
57 | - 'category' |
|
58 | - ), |
|
59 | - 'description' => new EE_Post_Content_Field( |
|
60 | - 'description', |
|
61 | - __("Description of Term", "event_espresso"), |
|
62 | - false, |
|
63 | - '' |
|
64 | - ), |
|
65 | - 'parent' => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0), |
|
66 | - 'term_count' => new EE_Integer_Field( |
|
67 | - 'count', |
|
68 | - __("Count of Objects attached", 'event_espresso'), |
|
69 | - false, |
|
70 | - 0 |
|
71 | - ), |
|
72 | - ), |
|
73 | - ); |
|
74 | - $this->_model_relations = array( |
|
75 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
76 | - 'Term' => new EE_Belongs_To_Relation(), |
|
77 | - ); |
|
78 | - $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); |
|
79 | - foreach ($cpt_models as $model_name) { |
|
80 | - $this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship'); |
|
81 | - } |
|
82 | - $this->_indexes = array( |
|
83 | - 'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')), |
|
84 | - ); |
|
85 | - $path_to_tax_model = ''; |
|
86 | - $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
87 | - $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
88 | - $path_to_tax_model |
|
89 | - ); |
|
90 | - $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
|
91 | - $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
|
92 | - //add cap restrictions for editing relating to the "ee_edit_*" |
|
93 | - $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
94 | - array( |
|
95 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
96 | - ) |
|
97 | - ); |
|
98 | - $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
99 | - array( |
|
100 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
101 | - ) |
|
102 | - ); |
|
103 | - $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
104 | - array( |
|
105 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
106 | - ) |
|
107 | - ); |
|
108 | - //add cap restrictions for deleting relating to the "ee_deleting_*" |
|
109 | - $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
110 | - array( |
|
111 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
112 | - ) |
|
113 | - ); |
|
114 | - $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
115 | - array( |
|
116 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
117 | - ) |
|
118 | - ); |
|
119 | - $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
120 | - array( |
|
121 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
122 | - ) |
|
123 | - ); |
|
124 | - parent::__construct($timezone); |
|
125 | - add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3); |
|
126 | - } |
|
33 | + protected function __construct($timezone = null) |
|
34 | + { |
|
35 | + $this->singular_item = __('Term Taxonomy', 'event_espresso'); |
|
36 | + $this->plural_item = __('Term Taxonomy', 'event_espresso'); |
|
37 | + $this->_tables = array( |
|
38 | + 'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'), |
|
39 | + ); |
|
40 | + $this->_fields = array( |
|
41 | + 'Term_Taxonomy' => array( |
|
42 | + 'term_taxonomy_id' => new EE_Primary_Key_Int_Field( |
|
43 | + 'term_taxonomy_id', |
|
44 | + __('Term-Taxonomy ID', 'event_espresso') |
|
45 | + ), |
|
46 | + 'term_id' => new EE_Foreign_Key_Int_Field( |
|
47 | + 'term_id', |
|
48 | + __("Term Id", "event_espresso"), |
|
49 | + false, |
|
50 | + 0, |
|
51 | + 'Term' |
|
52 | + ), |
|
53 | + 'taxonomy' => new EE_Plain_Text_Field( |
|
54 | + 'taxonomy', |
|
55 | + __('Taxonomy Name', 'event_espresso'), |
|
56 | + false, |
|
57 | + 'category' |
|
58 | + ), |
|
59 | + 'description' => new EE_Post_Content_Field( |
|
60 | + 'description', |
|
61 | + __("Description of Term", "event_espresso"), |
|
62 | + false, |
|
63 | + '' |
|
64 | + ), |
|
65 | + 'parent' => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0), |
|
66 | + 'term_count' => new EE_Integer_Field( |
|
67 | + 'count', |
|
68 | + __("Count of Objects attached", 'event_espresso'), |
|
69 | + false, |
|
70 | + 0 |
|
71 | + ), |
|
72 | + ), |
|
73 | + ); |
|
74 | + $this->_model_relations = array( |
|
75 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
76 | + 'Term' => new EE_Belongs_To_Relation(), |
|
77 | + ); |
|
78 | + $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); |
|
79 | + foreach ($cpt_models as $model_name) { |
|
80 | + $this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship'); |
|
81 | + } |
|
82 | + $this->_indexes = array( |
|
83 | + 'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')), |
|
84 | + ); |
|
85 | + $path_to_tax_model = ''; |
|
86 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
87 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
88 | + $path_to_tax_model |
|
89 | + ); |
|
90 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
|
91 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
|
92 | + //add cap restrictions for editing relating to the "ee_edit_*" |
|
93 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
94 | + array( |
|
95 | + $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
96 | + ) |
|
97 | + ); |
|
98 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
99 | + array( |
|
100 | + $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
101 | + ) |
|
102 | + ); |
|
103 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
104 | + array( |
|
105 | + $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
106 | + ) |
|
107 | + ); |
|
108 | + //add cap restrictions for deleting relating to the "ee_deleting_*" |
|
109 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
110 | + array( |
|
111 | + $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
112 | + ) |
|
113 | + ); |
|
114 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
115 | + array( |
|
116 | + $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
117 | + ) |
|
118 | + ); |
|
119 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
120 | + array( |
|
121 | + $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
122 | + ) |
|
123 | + ); |
|
124 | + parent::__construct($timezone); |
|
125 | + add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3); |
|
126 | + } |
|
127 | 127 | |
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * Makes sure that during REST API queries, we only return term-taxonomies |
|
132 | - * for term taxonomies which should be shown in the rest api |
|
133 | - * |
|
134 | - * @param array $model_query_params |
|
135 | - * @param array $querystring_query_params |
|
136 | - * @param EEM_Base $model |
|
137 | - * @return array |
|
138 | - */ |
|
139 | - public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
140 | - { |
|
141 | - if ($model === EEM_Term_Taxonomy::instance()) { |
|
142 | - $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
143 | - if (! empty($taxonomies)) { |
|
144 | - $model_query_params[0]['taxonomy'] = array('IN', $taxonomies); |
|
145 | - } |
|
146 | - } |
|
147 | - return $model_query_params; |
|
148 | - } |
|
130 | + /** |
|
131 | + * Makes sure that during REST API queries, we only return term-taxonomies |
|
132 | + * for term taxonomies which should be shown in the rest api |
|
133 | + * |
|
134 | + * @param array $model_query_params |
|
135 | + * @param array $querystring_query_params |
|
136 | + * @param EEM_Base $model |
|
137 | + * @return array |
|
138 | + */ |
|
139 | + public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
140 | + { |
|
141 | + if ($model === EEM_Term_Taxonomy::instance()) { |
|
142 | + $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
143 | + if (! empty($taxonomies)) { |
|
144 | + $model_query_params[0]['taxonomy'] = array('IN', $taxonomies); |
|
145 | + } |
|
146 | + } |
|
147 | + return $model_query_params; |
|
148 | + } |
|
149 | 149 | } |
150 | 150 | // End of file EEM_Term_Taxonomy.model.php |
151 | 151 | // Location: /includes/models/EEM_Term_Taxonomy.model.php |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | /** |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @author Michael Nelson |
19 | 19 | * ------------------------------------------------------------------------ |
20 | 20 | */ |
21 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
21 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
22 | 22 | |
23 | 23 | |
24 | 24 | |
@@ -92,33 +92,33 @@ discard block |
||
92 | 92 | //add cap restrictions for editing relating to the "ee_edit_*" |
93 | 93 | $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
94 | 94 | array( |
95 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
95 | + $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
96 | 96 | ) |
97 | 97 | ); |
98 | 98 | $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
99 | 99 | array( |
100 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
100 | + $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
101 | 101 | ) |
102 | 102 | ); |
103 | 103 | $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
104 | 104 | array( |
105 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
105 | + $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
106 | 106 | ) |
107 | 107 | ); |
108 | 108 | //add cap restrictions for deleting relating to the "ee_deleting_*" |
109 | 109 | $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
110 | 110 | array( |
111 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
111 | + $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
112 | 112 | ) |
113 | 113 | ); |
114 | 114 | $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
115 | 115 | array( |
116 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
116 | + $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
117 | 117 | ) |
118 | 118 | ); |
119 | 119 | $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
120 | 120 | array( |
121 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
121 | + $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
122 | 122 | ) |
123 | 123 | ); |
124 | 124 | parent::__construct($timezone); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | if ($model === EEM_Term_Taxonomy::instance()) { |
142 | 142 | $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
143 | - if (! empty($taxonomies)) { |
|
143 | + if ( ! empty($taxonomies)) { |
|
144 | 144 | $model_query_params[0]['taxonomy'] = array('IN', $taxonomies); |
145 | 145 | } |
146 | 146 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -15,206 +15,206 @@ discard block |
||
15 | 15 | class EEM_Term extends EEM_Base |
16 | 16 | { |
17 | 17 | |
18 | - // private instance of the Attendee object |
|
19 | - protected static $_instance = null; |
|
20 | - |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - *__construct |
|
25 | - * |
|
26 | - * @param string $timezone |
|
27 | - */ |
|
28 | - protected function __construct($timezone = null) |
|
29 | - { |
|
30 | - $this->singular_item = __('Term', 'event_espresso'); |
|
31 | - $this->plural_item = __('Terms', 'event_espresso'); |
|
32 | - $this->_tables = array( |
|
33 | - 'Term' => new EE_Primary_Table('terms', 'term_id'), |
|
34 | - ); |
|
35 | - $this->_fields = array( |
|
36 | - 'Term' => array( |
|
37 | - 'term_id' => new EE_Primary_Key_Int_Field('term_id', __('Term ID', 'event_espresso')), |
|
38 | - 'name' => new EE_Plain_Text_Field('name', __('Term Name', 'event_espresso'), false, ''), |
|
39 | - 'slug' => new EE_Slug_Field('slug', __('Term Slug', 'event_espresso'), false), |
|
40 | - 'term_group' => new EE_Integer_Field('term_group', __("Term Group", "event_espresso"), false, 0), |
|
41 | - ), |
|
42 | - ); |
|
43 | - $this->_model_relations = array( |
|
44 | - 'Term_Taxonomy' => new EE_Has_Many_Relation(), |
|
45 | - ); |
|
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( |
|
49 | - $path_to_tax_model |
|
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 . '.'; |
|
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( |
|
56 | - array( |
|
57 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
58 | - ) |
|
59 | - ); |
|
60 | - $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
61 | - array( |
|
62 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
63 | - ) |
|
64 | - ); |
|
65 | - $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
66 | - array( |
|
67 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
68 | - ) |
|
69 | - ); |
|
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( |
|
72 | - array( |
|
73 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
74 | - ) |
|
75 | - ); |
|
76 | - $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
77 | - array( |
|
78 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
79 | - ) |
|
80 | - ); |
|
81 | - $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
82 | - array( |
|
83 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
84 | - ) |
|
85 | - ); |
|
86 | - parent::__construct($timezone); |
|
87 | - add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3); |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * retrieves a list of all EE event categories |
|
94 | - * |
|
95 | - * @access public |
|
96 | - * @param bool $show_uncategorized |
|
97 | - * @return \EE_Base_Class[] |
|
98 | - */ |
|
99 | - public function get_all_ee_categories($show_uncategorized = false) |
|
100 | - { |
|
101 | - $where_params = array( |
|
102 | - 'Term_Taxonomy.taxonomy' => 'espresso_event_categories', |
|
103 | - 'NOT' => array('name' => __('Uncategorized', 'event_espresso')), |
|
104 | - ); |
|
105 | - if ($show_uncategorized) { |
|
106 | - unset($where_params['NOT']); |
|
107 | - } |
|
108 | - return EEM_Term::instance()->get_all( |
|
109 | - array( |
|
110 | - $where_params, |
|
111 | - 'order_by' => array('name' => 'ASC'), |
|
112 | - ) |
|
113 | - ); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * retrieves a list of all post_tags associated with an EE CPT |
|
120 | - * |
|
121 | - * @access public |
|
122 | - * @param string $post_type |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function get_all_CPT_post_tags($post_type = '') |
|
126 | - { |
|
127 | - switch ($post_type) { |
|
128 | - case 'espresso_events': |
|
129 | - return $this->get_all_event_post_tags(); |
|
130 | - break; |
|
131 | - case 'espresso_venues': |
|
132 | - return $this->get_all_venue_post_tags(); |
|
133 | - break; |
|
134 | - default: |
|
135 | - $event_tags = $this->get_all_event_post_tags(); |
|
136 | - $venue_tags = $this->get_all_venue_post_tags(); |
|
137 | - return array_merge($event_tags, $venue_tags); |
|
138 | - } |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * get_all_event_post_tags |
|
145 | - * |
|
146 | - * @return EE_Base_Class[] |
|
147 | - */ |
|
148 | - public function get_all_event_post_tags() |
|
149 | - { |
|
150 | - $post_tags = EEM_Term::instance()->get_all( |
|
151 | - array( |
|
152 | - array( |
|
153 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
154 | - 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
155 | - ), |
|
156 | - 'order_by' => array('name' => 'ASC'), |
|
157 | - 'force_join' => array('Term_Taxonomy.Event'), |
|
158 | - ) |
|
159 | - ); |
|
160 | - foreach ($post_tags as $key => $post_tag) { |
|
161 | - if (! isset($post_tags[$key]->post_type)) { |
|
162 | - $post_tags[$key]->post_type = array(); |
|
163 | - } |
|
164 | - $post_tags[$key]->post_type[] = 'espresso_events'; |
|
165 | - } |
|
166 | - return $post_tags; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * get_all_venue_post_tags |
|
173 | - * |
|
174 | - * @return EE_Base_Class[] |
|
175 | - */ |
|
176 | - public function get_all_venue_post_tags() |
|
177 | - { |
|
178 | - $post_tags = EEM_Term::instance()->get_all( |
|
179 | - array( |
|
180 | - array( |
|
181 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
182 | - 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
183 | - ), |
|
184 | - 'order_by' => array('name' => 'ASC'), |
|
185 | - 'force_join' => array('Term_Taxonomy'), |
|
186 | - ) |
|
187 | - ); |
|
188 | - foreach ($post_tags as $key => $post_tag) { |
|
189 | - if (! isset($post_tags[$key]->post_type)) { |
|
190 | - $post_tags[$key]->post_type = array(); |
|
191 | - } |
|
192 | - $post_tags[$key]->post_type[] = 'espresso_venues'; |
|
193 | - } |
|
194 | - return $post_tags; |
|
195 | - } |
|
196 | - |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * Makes sure that during REST API queries, we only return terms |
|
201 | - * for term taxonomies which should be shown in the rest api |
|
202 | - * |
|
203 | - * @param array $model_query_params |
|
204 | - * @param array $querystring_query_params |
|
205 | - * @param EEM_Base $model |
|
206 | - * @return array |
|
207 | - */ |
|
208 | - public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
209 | - { |
|
210 | - if ($model === EEM_Term::instance()) { |
|
211 | - $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
212 | - if (! empty($taxonomies)) { |
|
213 | - $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
214 | - } |
|
215 | - } |
|
216 | - return $model_query_params; |
|
217 | - } |
|
18 | + // private instance of the Attendee object |
|
19 | + protected static $_instance = null; |
|
20 | + |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + *__construct |
|
25 | + * |
|
26 | + * @param string $timezone |
|
27 | + */ |
|
28 | + protected function __construct($timezone = null) |
|
29 | + { |
|
30 | + $this->singular_item = __('Term', 'event_espresso'); |
|
31 | + $this->plural_item = __('Terms', 'event_espresso'); |
|
32 | + $this->_tables = array( |
|
33 | + 'Term' => new EE_Primary_Table('terms', 'term_id'), |
|
34 | + ); |
|
35 | + $this->_fields = array( |
|
36 | + 'Term' => array( |
|
37 | + 'term_id' => new EE_Primary_Key_Int_Field('term_id', __('Term ID', 'event_espresso')), |
|
38 | + 'name' => new EE_Plain_Text_Field('name', __('Term Name', 'event_espresso'), false, ''), |
|
39 | + 'slug' => new EE_Slug_Field('slug', __('Term Slug', 'event_espresso'), false), |
|
40 | + 'term_group' => new EE_Integer_Field('term_group', __("Term Group", "event_espresso"), false, 0), |
|
41 | + ), |
|
42 | + ); |
|
43 | + $this->_model_relations = array( |
|
44 | + 'Term_Taxonomy' => new EE_Has_Many_Relation(), |
|
45 | + ); |
|
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( |
|
49 | + $path_to_tax_model |
|
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 . '.'; |
|
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( |
|
56 | + array( |
|
57 | + $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
58 | + ) |
|
59 | + ); |
|
60 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
61 | + array( |
|
62 | + $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
63 | + ) |
|
64 | + ); |
|
65 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
66 | + array( |
|
67 | + $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
68 | + ) |
|
69 | + ); |
|
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( |
|
72 | + array( |
|
73 | + $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
74 | + ) |
|
75 | + ); |
|
76 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
77 | + array( |
|
78 | + $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
79 | + ) |
|
80 | + ); |
|
81 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
82 | + array( |
|
83 | + $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
84 | + ) |
|
85 | + ); |
|
86 | + parent::__construct($timezone); |
|
87 | + add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3); |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * retrieves a list of all EE event categories |
|
94 | + * |
|
95 | + * @access public |
|
96 | + * @param bool $show_uncategorized |
|
97 | + * @return \EE_Base_Class[] |
|
98 | + */ |
|
99 | + public function get_all_ee_categories($show_uncategorized = false) |
|
100 | + { |
|
101 | + $where_params = array( |
|
102 | + 'Term_Taxonomy.taxonomy' => 'espresso_event_categories', |
|
103 | + 'NOT' => array('name' => __('Uncategorized', 'event_espresso')), |
|
104 | + ); |
|
105 | + if ($show_uncategorized) { |
|
106 | + unset($where_params['NOT']); |
|
107 | + } |
|
108 | + return EEM_Term::instance()->get_all( |
|
109 | + array( |
|
110 | + $where_params, |
|
111 | + 'order_by' => array('name' => 'ASC'), |
|
112 | + ) |
|
113 | + ); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * retrieves a list of all post_tags associated with an EE CPT |
|
120 | + * |
|
121 | + * @access public |
|
122 | + * @param string $post_type |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function get_all_CPT_post_tags($post_type = '') |
|
126 | + { |
|
127 | + switch ($post_type) { |
|
128 | + case 'espresso_events': |
|
129 | + return $this->get_all_event_post_tags(); |
|
130 | + break; |
|
131 | + case 'espresso_venues': |
|
132 | + return $this->get_all_venue_post_tags(); |
|
133 | + break; |
|
134 | + default: |
|
135 | + $event_tags = $this->get_all_event_post_tags(); |
|
136 | + $venue_tags = $this->get_all_venue_post_tags(); |
|
137 | + return array_merge($event_tags, $venue_tags); |
|
138 | + } |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * get_all_event_post_tags |
|
145 | + * |
|
146 | + * @return EE_Base_Class[] |
|
147 | + */ |
|
148 | + public function get_all_event_post_tags() |
|
149 | + { |
|
150 | + $post_tags = EEM_Term::instance()->get_all( |
|
151 | + array( |
|
152 | + array( |
|
153 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
154 | + 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
155 | + ), |
|
156 | + 'order_by' => array('name' => 'ASC'), |
|
157 | + 'force_join' => array('Term_Taxonomy.Event'), |
|
158 | + ) |
|
159 | + ); |
|
160 | + foreach ($post_tags as $key => $post_tag) { |
|
161 | + if (! isset($post_tags[$key]->post_type)) { |
|
162 | + $post_tags[$key]->post_type = array(); |
|
163 | + } |
|
164 | + $post_tags[$key]->post_type[] = 'espresso_events'; |
|
165 | + } |
|
166 | + return $post_tags; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * get_all_venue_post_tags |
|
173 | + * |
|
174 | + * @return EE_Base_Class[] |
|
175 | + */ |
|
176 | + public function get_all_venue_post_tags() |
|
177 | + { |
|
178 | + $post_tags = EEM_Term::instance()->get_all( |
|
179 | + array( |
|
180 | + array( |
|
181 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
182 | + 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
183 | + ), |
|
184 | + 'order_by' => array('name' => 'ASC'), |
|
185 | + 'force_join' => array('Term_Taxonomy'), |
|
186 | + ) |
|
187 | + ); |
|
188 | + foreach ($post_tags as $key => $post_tag) { |
|
189 | + if (! isset($post_tags[$key]->post_type)) { |
|
190 | + $post_tags[$key]->post_type = array(); |
|
191 | + } |
|
192 | + $post_tags[$key]->post_type[] = 'espresso_venues'; |
|
193 | + } |
|
194 | + return $post_tags; |
|
195 | + } |
|
196 | + |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * Makes sure that during REST API queries, we only return terms |
|
201 | + * for term taxonomies which should be shown in the rest api |
|
202 | + * |
|
203 | + * @param array $model_query_params |
|
204 | + * @param array $querystring_query_params |
|
205 | + * @param EEM_Base $model |
|
206 | + * @return array |
|
207 | + */ |
|
208 | + public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
209 | + { |
|
210 | + if ($model === EEM_Term::instance()) { |
|
211 | + $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
212 | + if (! empty($taxonomies)) { |
|
213 | + $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
214 | + } |
|
215 | + } |
|
216 | + return $model_query_params; |
|
217 | + } |
|
218 | 218 | |
219 | 219 | |
220 | 220 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -50,37 +50,37 @@ discard block |
||
50 | 50 | ); |
51 | 51 | $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
52 | 52 | $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
53 | - $path_to_tax_model = $path_to_tax_model . '.'; |
|
53 | + $path_to_tax_model = $path_to_tax_model.'.'; |
|
54 | 54 | //add cap restrictions for editing relating to the "ee_edit_*" |
55 | 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 | 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 | 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 | 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 | 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 | 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); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | ) |
159 | 159 | ); |
160 | 160 | foreach ($post_tags as $key => $post_tag) { |
161 | - if (! isset($post_tags[$key]->post_type)) { |
|
161 | + if ( ! isset($post_tags[$key]->post_type)) { |
|
162 | 162 | $post_tags[$key]->post_type = array(); |
163 | 163 | } |
164 | 164 | $post_tags[$key]->post_type[] = 'espresso_events'; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | ) |
187 | 187 | ); |
188 | 188 | foreach ($post_tags as $key => $post_tag) { |
189 | - if (! isset($post_tags[$key]->post_type)) { |
|
189 | + if ( ! isset($post_tags[$key]->post_type)) { |
|
190 | 190 | $post_tags[$key]->post_type = array(); |
191 | 191 | } |
192 | 192 | $post_tags[$key]->post_type[] = 'espresso_venues'; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | { |
210 | 210 | if ($model === EEM_Term::instance()) { |
211 | 211 | $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
212 | - if (! empty($taxonomies)) { |
|
212 | + if ( ! empty($taxonomies)) { |
|
213 | 213 | $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
214 | 214 | } |
215 | 215 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -33,57 +33,57 @@ discard block |
||
33 | 33 | class EEM_Post_Meta extends EEM_Base |
34 | 34 | { |
35 | 35 | |
36 | - // private instance of the EE_Post_Meta object |
|
37 | - protected static $_instance = null; |
|
36 | + // private instance of the EE_Post_Meta object |
|
37 | + protected static $_instance = null; |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | - protected function __construct($timezone = null) |
|
42 | - { |
|
43 | - $this->singular_item = __('Post Meta', 'event_espresso'); |
|
44 | - $this->plural_item = __('Post Metas', 'event_espresso'); |
|
45 | - $this->_tables = array( |
|
46 | - 'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'), |
|
47 | - ); |
|
48 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
49 | - $this->_fields = array( |
|
50 | - 'Post_Meta' => array( |
|
51 | - 'meta_id' => new EE_Primary_Key_Int_Field( |
|
52 | - 'meta_id', |
|
53 | - __("Meta ID", "event_espresso") |
|
54 | - ), |
|
55 | - 'post_id' => new EE_Foreign_Key_Int_Field( |
|
56 | - 'post_id', |
|
57 | - __("Primary Key of Post", "event_espresso"), |
|
58 | - false, |
|
59 | - 0, |
|
60 | - $models_this_can_attach_to |
|
61 | - ), |
|
62 | - 'meta_key' => new EE_Plain_Text_Field( |
|
63 | - 'meta_key', |
|
64 | - __("Meta Key", "event_espresso"), |
|
65 | - false, |
|
66 | - '' |
|
67 | - ), |
|
68 | - 'meta_value' => new EE_Maybe_Serialized_Text_Field( |
|
69 | - 'meta_value', |
|
70 | - __("Meta Value", "event_espresso"), |
|
71 | - true |
|
72 | - ), |
|
73 | - ), |
|
74 | - ); |
|
75 | - $this->_model_relations = array(); |
|
76 | - foreach ($models_this_can_attach_to as $model) { |
|
77 | - $this->_model_relations[$model] = new EE_Belongs_To_Relation(); |
|
78 | - } |
|
79 | - foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
80 | - $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta( |
|
81 | - 'meta_key', |
|
82 | - 'meta_value' |
|
83 | - ); |
|
84 | - } |
|
85 | - parent::__construct($timezone); |
|
86 | - } |
|
41 | + protected function __construct($timezone = null) |
|
42 | + { |
|
43 | + $this->singular_item = __('Post Meta', 'event_espresso'); |
|
44 | + $this->plural_item = __('Post Metas', 'event_espresso'); |
|
45 | + $this->_tables = array( |
|
46 | + 'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'), |
|
47 | + ); |
|
48 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
49 | + $this->_fields = array( |
|
50 | + 'Post_Meta' => array( |
|
51 | + 'meta_id' => new EE_Primary_Key_Int_Field( |
|
52 | + 'meta_id', |
|
53 | + __("Meta ID", "event_espresso") |
|
54 | + ), |
|
55 | + 'post_id' => new EE_Foreign_Key_Int_Field( |
|
56 | + 'post_id', |
|
57 | + __("Primary Key of Post", "event_espresso"), |
|
58 | + false, |
|
59 | + 0, |
|
60 | + $models_this_can_attach_to |
|
61 | + ), |
|
62 | + 'meta_key' => new EE_Plain_Text_Field( |
|
63 | + 'meta_key', |
|
64 | + __("Meta Key", "event_espresso"), |
|
65 | + false, |
|
66 | + '' |
|
67 | + ), |
|
68 | + 'meta_value' => new EE_Maybe_Serialized_Text_Field( |
|
69 | + 'meta_value', |
|
70 | + __("Meta Value", "event_espresso"), |
|
71 | + true |
|
72 | + ), |
|
73 | + ), |
|
74 | + ); |
|
75 | + $this->_model_relations = array(); |
|
76 | + foreach ($models_this_can_attach_to as $model) { |
|
77 | + $this->_model_relations[$model] = new EE_Belongs_To_Relation(); |
|
78 | + } |
|
79 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
80 | + $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta( |
|
81 | + 'meta_key', |
|
82 | + 'meta_value' |
|
83 | + ); |
|
84 | + } |
|
85 | + parent::__construct($timezone); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | 89 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @author Michael Nelson |
27 | 27 | * ------------------------------------------------------------------------ |
28 | 28 | */ |
29 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
29 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
30 | 30 | |
31 | 31 | |
32 | 32 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | require_once(EE_MODELS . 'EEM_Base.model.php'); |
5 | 5 | |
@@ -15,229 +15,229 @@ discard block |
||
15 | 15 | class EEM_Term_Relationship extends EEM_Base |
16 | 16 | { |
17 | 17 | |
18 | - // private instance of the Attendee object |
|
19 | - protected static $_instance = null; |
|
20 | - |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * EEM_Term_Relationship constructor. |
|
25 | - * |
|
26 | - * @param string $timezone |
|
27 | - */ |
|
28 | - protected function __construct($timezone = null) |
|
29 | - { |
|
30 | - $this->singular_item = __('Term Relationship', 'event_espresso'); |
|
31 | - $this->plural_item = __('Term Relationships', 'event_espresso'); |
|
32 | - $this->_tables = array( |
|
33 | - 'Term_Relationship' => new EE_Primary_Table('term_relationships'), |
|
34 | - ); |
|
35 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
36 | - $this->_fields = array( |
|
37 | - 'Term_Relationship' => array( |
|
38 | - 'object_id' => new EE_Foreign_Key_Int_Field( |
|
39 | - 'object_id', |
|
40 | - __('Object(Post) ID', 'event_espresso'), |
|
41 | - false, |
|
42 | - 0, |
|
43 | - $models_this_can_attach_to |
|
44 | - ), |
|
45 | - 'term_taxonomy_id' => new EE_Foreign_Key_Int_Field( |
|
46 | - 'term_taxonomy_id', |
|
47 | - __( |
|
48 | - 'Term (in context of a taxonomy) ID', |
|
49 | - 'event_espresso' |
|
50 | - ), |
|
51 | - false, |
|
52 | - 0, |
|
53 | - 'Term_Taxonomy' |
|
54 | - ), |
|
55 | - 'term_order' => new EE_Integer_Field( |
|
56 | - 'term_order', |
|
57 | - __('Term Order', 'event_espresso'), |
|
58 | - false, |
|
59 | - 0 |
|
60 | - ), |
|
61 | - ), |
|
62 | - ); |
|
63 | - $this->_model_relations = array( |
|
64 | - 'Term_Taxonomy' => new EE_Belongs_To_Relation(), |
|
65 | - ); |
|
66 | - foreach ($models_this_can_attach_to as $model_name) { |
|
67 | - $this->_model_relations[$model_name] = new EE_Belongs_To_Relation(); |
|
68 | - } |
|
69 | - $this->_indexes = array( |
|
70 | - 'PRIMARY' => new EE_Primary_Key_Index(array('object_id', 'term_taxonomy_id')), |
|
71 | - ); |
|
72 | - $path_to_event_model = 'Event.'; |
|
73 | - $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public( |
|
74 | - $path_to_event_model |
|
75 | - ); |
|
76 | - $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = |
|
77 | - new EE_Restriction_Generator_Event_Related_Protected( |
|
78 | - $path_to_event_model |
|
79 | - ); |
|
80 | - $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected( |
|
81 | - $path_to_event_model |
|
82 | - ); |
|
83 | - $this->_cap_restriction_generators[EEM_Base::caps_delete] = |
|
84 | - new EE_Restriction_Generator_Event_Related_Protected( |
|
85 | - $path_to_event_model, |
|
86 | - EEM_Base::caps_edit |
|
87 | - ); |
|
88 | - $path_to_tax_model = 'Term_Taxonomy.'; |
|
89 | - //add cap restrictions for editing term relations to the "ee_assign_*" |
|
90 | - //and for deleting term relations too |
|
91 | - $cap_contexts_affected = array(EEM_Base::caps_edit, EEM_Base::caps_delete); |
|
92 | - foreach ($cap_contexts_affected as $cap_context_affected) { |
|
93 | - $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_category'] = |
|
94 | - new EE_Default_Where_Conditions( |
|
95 | - array( |
|
96 | - $path_to_tax_model . 'taxonomy*ee_assign_event_category' => array( |
|
97 | - '!=', |
|
98 | - 'espresso_event_categories', |
|
99 | - ), |
|
100 | - ) |
|
101 | - ); |
|
102 | - $this->_cap_restrictions[$cap_context_affected]['ee_assign_venue_category'] = |
|
103 | - new EE_Default_Where_Conditions( |
|
104 | - array( |
|
105 | - $path_to_tax_model . 'taxonomy*ee_assign_venue_category' => array( |
|
106 | - '!=', |
|
107 | - 'espresso_venue_categories', |
|
108 | - ), |
|
109 | - ) |
|
110 | - ); |
|
111 | - $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
|
112 | - array( |
|
113 | - $path_to_tax_model . 'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type'), |
|
114 | - ) |
|
115 | - ); |
|
116 | - } |
|
117 | - parent::__construct($timezone); |
|
118 | - add_filter( |
|
119 | - 'FHEE__Read__create_model_query_params', |
|
120 | - array('EEM_Term_Relationship', 'rest_api_query_params'), |
|
121 | - 10, |
|
122 | - 3 |
|
123 | - ); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * Makes sure all term-taxonomy counts are correct |
|
130 | - * |
|
131 | - * @param int $term_taxonomy_id the id of the term taxonomy to update. If NULL, updates ALL |
|
132 | - * @global wpdb $wpdb |
|
133 | - * @return int the number of rows affected |
|
134 | - */ |
|
135 | - public function update_term_taxonomy_counts($term_taxonomy_id = null) |
|
136 | - { |
|
137 | - //because this uses a subquery and sometimes assigning to column to be another column's |
|
138 | - //value, we just write the SQL directly. |
|
139 | - global $wpdb; |
|
140 | - if ($term_taxonomy_id) { |
|
141 | - $second_operand = $wpdb->prepare('%d', $term_taxonomy_id); |
|
142 | - } else { |
|
143 | - $second_operand = 'tr.term_taxonomy_id'; |
|
144 | - } |
|
145 | - $rows_affected = $this->_do_wpdb_query( |
|
146 | - 'query', |
|
147 | - array( |
|
148 | - " |
|
18 | + // private instance of the Attendee object |
|
19 | + protected static $_instance = null; |
|
20 | + |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * EEM_Term_Relationship constructor. |
|
25 | + * |
|
26 | + * @param string $timezone |
|
27 | + */ |
|
28 | + protected function __construct($timezone = null) |
|
29 | + { |
|
30 | + $this->singular_item = __('Term Relationship', 'event_espresso'); |
|
31 | + $this->plural_item = __('Term Relationships', 'event_espresso'); |
|
32 | + $this->_tables = array( |
|
33 | + 'Term_Relationship' => new EE_Primary_Table('term_relationships'), |
|
34 | + ); |
|
35 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
36 | + $this->_fields = array( |
|
37 | + 'Term_Relationship' => array( |
|
38 | + 'object_id' => new EE_Foreign_Key_Int_Field( |
|
39 | + 'object_id', |
|
40 | + __('Object(Post) ID', 'event_espresso'), |
|
41 | + false, |
|
42 | + 0, |
|
43 | + $models_this_can_attach_to |
|
44 | + ), |
|
45 | + 'term_taxonomy_id' => new EE_Foreign_Key_Int_Field( |
|
46 | + 'term_taxonomy_id', |
|
47 | + __( |
|
48 | + 'Term (in context of a taxonomy) ID', |
|
49 | + 'event_espresso' |
|
50 | + ), |
|
51 | + false, |
|
52 | + 0, |
|
53 | + 'Term_Taxonomy' |
|
54 | + ), |
|
55 | + 'term_order' => new EE_Integer_Field( |
|
56 | + 'term_order', |
|
57 | + __('Term Order', 'event_espresso'), |
|
58 | + false, |
|
59 | + 0 |
|
60 | + ), |
|
61 | + ), |
|
62 | + ); |
|
63 | + $this->_model_relations = array( |
|
64 | + 'Term_Taxonomy' => new EE_Belongs_To_Relation(), |
|
65 | + ); |
|
66 | + foreach ($models_this_can_attach_to as $model_name) { |
|
67 | + $this->_model_relations[$model_name] = new EE_Belongs_To_Relation(); |
|
68 | + } |
|
69 | + $this->_indexes = array( |
|
70 | + 'PRIMARY' => new EE_Primary_Key_Index(array('object_id', 'term_taxonomy_id')), |
|
71 | + ); |
|
72 | + $path_to_event_model = 'Event.'; |
|
73 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public( |
|
74 | + $path_to_event_model |
|
75 | + ); |
|
76 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = |
|
77 | + new EE_Restriction_Generator_Event_Related_Protected( |
|
78 | + $path_to_event_model |
|
79 | + ); |
|
80 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected( |
|
81 | + $path_to_event_model |
|
82 | + ); |
|
83 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = |
|
84 | + new EE_Restriction_Generator_Event_Related_Protected( |
|
85 | + $path_to_event_model, |
|
86 | + EEM_Base::caps_edit |
|
87 | + ); |
|
88 | + $path_to_tax_model = 'Term_Taxonomy.'; |
|
89 | + //add cap restrictions for editing term relations to the "ee_assign_*" |
|
90 | + //and for deleting term relations too |
|
91 | + $cap_contexts_affected = array(EEM_Base::caps_edit, EEM_Base::caps_delete); |
|
92 | + foreach ($cap_contexts_affected as $cap_context_affected) { |
|
93 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_category'] = |
|
94 | + new EE_Default_Where_Conditions( |
|
95 | + array( |
|
96 | + $path_to_tax_model . 'taxonomy*ee_assign_event_category' => array( |
|
97 | + '!=', |
|
98 | + 'espresso_event_categories', |
|
99 | + ), |
|
100 | + ) |
|
101 | + ); |
|
102 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_venue_category'] = |
|
103 | + new EE_Default_Where_Conditions( |
|
104 | + array( |
|
105 | + $path_to_tax_model . 'taxonomy*ee_assign_venue_category' => array( |
|
106 | + '!=', |
|
107 | + 'espresso_venue_categories', |
|
108 | + ), |
|
109 | + ) |
|
110 | + ); |
|
111 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
|
112 | + array( |
|
113 | + $path_to_tax_model . 'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type'), |
|
114 | + ) |
|
115 | + ); |
|
116 | + } |
|
117 | + parent::__construct($timezone); |
|
118 | + add_filter( |
|
119 | + 'FHEE__Read__create_model_query_params', |
|
120 | + array('EEM_Term_Relationship', 'rest_api_query_params'), |
|
121 | + 10, |
|
122 | + 3 |
|
123 | + ); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * Makes sure all term-taxonomy counts are correct |
|
130 | + * |
|
131 | + * @param int $term_taxonomy_id the id of the term taxonomy to update. If NULL, updates ALL |
|
132 | + * @global wpdb $wpdb |
|
133 | + * @return int the number of rows affected |
|
134 | + */ |
|
135 | + public function update_term_taxonomy_counts($term_taxonomy_id = null) |
|
136 | + { |
|
137 | + //because this uses a subquery and sometimes assigning to column to be another column's |
|
138 | + //value, we just write the SQL directly. |
|
139 | + global $wpdb; |
|
140 | + if ($term_taxonomy_id) { |
|
141 | + $second_operand = $wpdb->prepare('%d', $term_taxonomy_id); |
|
142 | + } else { |
|
143 | + $second_operand = 'tr.term_taxonomy_id'; |
|
144 | + } |
|
145 | + $rows_affected = $this->_do_wpdb_query( |
|
146 | + 'query', |
|
147 | + array( |
|
148 | + " |
|
149 | 149 | UPDATE {$wpdb->term_taxonomy} AS tt |
150 | 150 | SET count = ( |
151 | 151 | select count(*) as proper_count from {$wpdb->term_relationships} AS tr |
152 | 152 | WHERE tt.term_taxonomy_id = $second_operand |
153 | 153 | )", |
154 | - ) |
|
155 | - ); |
|
156 | - return $rows_affected; |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Overrides the parent to also make sure term-taxonomy counts are up-to-date after |
|
163 | - * inserting |
|
164 | - * |
|
165 | - * @param array $field_n_values @see EEM_Base::insert |
|
166 | - * @return boolean |
|
167 | - */ |
|
168 | - public function insert($field_n_values) |
|
169 | - { |
|
170 | - $return = parent::insert($field_n_values); |
|
171 | - if (isset($field_n_values['term_taxonomy_id'])) { |
|
172 | - $this->update_term_taxonomy_counts($field_n_values['term_taxonomy_id']); |
|
173 | - } |
|
174 | - return $return; |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * Overrides parent so that after an update, we also check the term_taxonomy_counts are |
|
181 | - * all ok |
|
182 | - * |
|
183 | - * @param array $fields_n_values see EEM_Base::update |
|
184 | - * @param array $query_params @see EEM_Base::get_all |
|
185 | - * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
186 | - * in this model's entity map according to $fields_n_values that match |
|
187 | - * $query_params. This obviously has some overhead, so you can disable it |
|
188 | - * by setting this to FALSE, but be aware that model objects being used |
|
189 | - * could get out-of-sync with the database |
|
190 | - * @return int |
|
191 | - */ |
|
192 | - public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
193 | - { |
|
194 | - $count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
195 | - if ($count) { |
|
196 | - $this->update_term_taxonomy_counts(); |
|
197 | - } |
|
198 | - return $count; |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * Overrides parent so that after running this, we also double-check |
|
205 | - * the term taxonomy counts are up-to-date |
|
206 | - * |
|
207 | - * @param array $query_params @see EEM_Base::get_all |
|
208 | - * @param boolean $allow_blocking |
|
209 | - * @return int @see EEM_Base::delete |
|
210 | - */ |
|
211 | - public function delete($query_params, $allow_blocking = true) |
|
212 | - { |
|
213 | - $count = parent::delete($query_params, $allow_blocking); |
|
214 | - if ($count) { |
|
215 | - $this->update_term_taxonomy_counts(); |
|
216 | - } |
|
217 | - return $count; |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * Makes sure that during REST API queries, we only return term relationships |
|
224 | - * for term taxonomies which should be shown in the rest api |
|
225 | - * |
|
226 | - * @param array $model_query_params |
|
227 | - * @param array $querystring_query_params |
|
228 | - * @param EEM_Base $model |
|
229 | - * @return array |
|
230 | - */ |
|
231 | - public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
232 | - { |
|
233 | - if ($model === EEM_Term_Relationship::instance()) { |
|
234 | - $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
235 | - if (! empty($taxonomies)) { |
|
236 | - $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
237 | - } |
|
238 | - } |
|
239 | - return $model_query_params; |
|
240 | - } |
|
154 | + ) |
|
155 | + ); |
|
156 | + return $rows_affected; |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Overrides the parent to also make sure term-taxonomy counts are up-to-date after |
|
163 | + * inserting |
|
164 | + * |
|
165 | + * @param array $field_n_values @see EEM_Base::insert |
|
166 | + * @return boolean |
|
167 | + */ |
|
168 | + public function insert($field_n_values) |
|
169 | + { |
|
170 | + $return = parent::insert($field_n_values); |
|
171 | + if (isset($field_n_values['term_taxonomy_id'])) { |
|
172 | + $this->update_term_taxonomy_counts($field_n_values['term_taxonomy_id']); |
|
173 | + } |
|
174 | + return $return; |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * Overrides parent so that after an update, we also check the term_taxonomy_counts are |
|
181 | + * all ok |
|
182 | + * |
|
183 | + * @param array $fields_n_values see EEM_Base::update |
|
184 | + * @param array $query_params @see EEM_Base::get_all |
|
185 | + * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
186 | + * in this model's entity map according to $fields_n_values that match |
|
187 | + * $query_params. This obviously has some overhead, so you can disable it |
|
188 | + * by setting this to FALSE, but be aware that model objects being used |
|
189 | + * could get out-of-sync with the database |
|
190 | + * @return int |
|
191 | + */ |
|
192 | + public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
193 | + { |
|
194 | + $count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
195 | + if ($count) { |
|
196 | + $this->update_term_taxonomy_counts(); |
|
197 | + } |
|
198 | + return $count; |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * Overrides parent so that after running this, we also double-check |
|
205 | + * the term taxonomy counts are up-to-date |
|
206 | + * |
|
207 | + * @param array $query_params @see EEM_Base::get_all |
|
208 | + * @param boolean $allow_blocking |
|
209 | + * @return int @see EEM_Base::delete |
|
210 | + */ |
|
211 | + public function delete($query_params, $allow_blocking = true) |
|
212 | + { |
|
213 | + $count = parent::delete($query_params, $allow_blocking); |
|
214 | + if ($count) { |
|
215 | + $this->update_term_taxonomy_counts(); |
|
216 | + } |
|
217 | + return $count; |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * Makes sure that during REST API queries, we only return term relationships |
|
224 | + * for term taxonomies which should be shown in the rest api |
|
225 | + * |
|
226 | + * @param array $model_query_params |
|
227 | + * @param array $querystring_query_params |
|
228 | + * @param EEM_Base $model |
|
229 | + * @return array |
|
230 | + */ |
|
231 | + public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
232 | + { |
|
233 | + if ($model === EEM_Term_Relationship::instance()) { |
|
234 | + $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
235 | + if (! empty($taxonomies)) { |
|
236 | + $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
237 | + } |
|
238 | + } |
|
239 | + return $model_query_params; |
|
240 | + } |
|
241 | 241 | |
242 | 242 | |
243 | 243 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
4 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_category'] = |
94 | 94 | new EE_Default_Where_Conditions( |
95 | 95 | array( |
96 | - $path_to_tax_model . 'taxonomy*ee_assign_event_category' => array( |
|
96 | + $path_to_tax_model.'taxonomy*ee_assign_event_category' => array( |
|
97 | 97 | '!=', |
98 | 98 | 'espresso_event_categories', |
99 | 99 | ), |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $this->_cap_restrictions[$cap_context_affected]['ee_assign_venue_category'] = |
103 | 103 | new EE_Default_Where_Conditions( |
104 | 104 | array( |
105 | - $path_to_tax_model . 'taxonomy*ee_assign_venue_category' => array( |
|
105 | + $path_to_tax_model.'taxonomy*ee_assign_venue_category' => array( |
|
106 | 106 | '!=', |
107 | 107 | 'espresso_venue_categories', |
108 | 108 | ), |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | ); |
111 | 111 | $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
112 | 112 | array( |
113 | - $path_to_tax_model . 'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type'), |
|
113 | + $path_to_tax_model.'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type'), |
|
114 | 114 | ) |
115 | 115 | ); |
116 | 116 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | { |
233 | 233 | if ($model === EEM_Term_Relationship::instance()) { |
234 | 234 | $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
235 | - if (! empty($taxonomies)) { |
|
235 | + if ( ! empty($taxonomies)) { |
|
236 | 236 | $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
237 | 237 | } |
238 | 238 | } |