@@ -38,216 +38,216 @@ |
||
| 38 | 38 | * @since 4.0 |
| 39 | 39 | */ |
| 40 | 40 | if (function_exists('espresso_version')) { |
| 41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | - /** |
|
| 43 | - * espresso_duplicate_plugin_error |
|
| 44 | - * displays if more than one version of EE is activated at the same time |
|
| 45 | - */ |
|
| 46 | - function espresso_duplicate_plugin_error() |
|
| 47 | - { |
|
| 48 | - ?> |
|
| 41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | + /** |
|
| 43 | + * espresso_duplicate_plugin_error |
|
| 44 | + * displays if more than one version of EE is activated at the same time |
|
| 45 | + */ |
|
| 46 | + function espresso_duplicate_plugin_error() |
|
| 47 | + { |
|
| 48 | + ?> |
|
| 49 | 49 | <div class="error"> |
| 50 | 50 | <p> |
| 51 | 51 | <?php |
| 52 | - echo esc_html__( |
|
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 52 | + echo esc_html__( |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | |
| 64 | 64 | } else { |
| 65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 67 | - /** |
|
| 68 | - * espresso_minimum_php_version_error |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 67 | + /** |
|
| 68 | + * espresso_minimum_php_version_error |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | - /** |
|
| 98 | - * espresso_version |
|
| 99 | - * Returns the plugin version |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function espresso_version() |
|
| 104 | - { |
|
| 105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.58.rc.018'); |
|
| 106 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | + /** |
|
| 98 | + * espresso_version |
|
| 99 | + * Returns the plugin version |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function espresso_version() |
|
| 104 | + { |
|
| 105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.58.rc.018'); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * espresso_plugin_activation |
|
| 110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | - */ |
|
| 112 | - function espresso_plugin_activation() |
|
| 113 | - { |
|
| 114 | - update_option('ee_espresso_activation', true); |
|
| 115 | - } |
|
| 108 | + /** |
|
| 109 | + * espresso_plugin_activation |
|
| 110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | + */ |
|
| 112 | + function espresso_plugin_activation() |
|
| 113 | + { |
|
| 114 | + update_option('ee_espresso_activation', true); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 118 | - /** |
|
| 119 | - * espresso_load_error_handling |
|
| 120 | - * this function loads EE's class for handling exceptions and errors |
|
| 121 | - */ |
|
| 122 | - function espresso_load_error_handling() |
|
| 123 | - { |
|
| 124 | - static $error_handling_loaded = false; |
|
| 125 | - if ($error_handling_loaded) { |
|
| 126 | - return; |
|
| 127 | - } |
|
| 128 | - // load debugging tools |
|
| 129 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 130 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
| 131 | - \EEH_Debug_Tools::instance(); |
|
| 132 | - } |
|
| 133 | - // load error handling |
|
| 134 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 135 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
| 136 | - } else { |
|
| 137 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 138 | - } |
|
| 139 | - $error_handling_loaded = true; |
|
| 140 | - } |
|
| 117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 118 | + /** |
|
| 119 | + * espresso_load_error_handling |
|
| 120 | + * this function loads EE's class for handling exceptions and errors |
|
| 121 | + */ |
|
| 122 | + function espresso_load_error_handling() |
|
| 123 | + { |
|
| 124 | + static $error_handling_loaded = false; |
|
| 125 | + if ($error_handling_loaded) { |
|
| 126 | + return; |
|
| 127 | + } |
|
| 128 | + // load debugging tools |
|
| 129 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 130 | + require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
| 131 | + \EEH_Debug_Tools::instance(); |
|
| 132 | + } |
|
| 133 | + // load error handling |
|
| 134 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 135 | + require_once EE_CORE . 'EE_Error.core.php'; |
|
| 136 | + } else { |
|
| 137 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 138 | + } |
|
| 139 | + $error_handling_loaded = true; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * espresso_load_required |
|
| 144 | - * given a class name and path, this function will load that file or throw an exception |
|
| 145 | - * |
|
| 146 | - * @param string $classname |
|
| 147 | - * @param string $full_path_to_file |
|
| 148 | - * @throws EE_Error |
|
| 149 | - */ |
|
| 150 | - function espresso_load_required($classname, $full_path_to_file) |
|
| 151 | - { |
|
| 152 | - if (is_readable($full_path_to_file)) { |
|
| 153 | - require_once $full_path_to_file; |
|
| 154 | - } else { |
|
| 155 | - throw new \EE_Error ( |
|
| 156 | - sprintf( |
|
| 157 | - esc_html__( |
|
| 158 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 159 | - 'event_espresso' |
|
| 160 | - ), |
|
| 161 | - $classname |
|
| 162 | - ) |
|
| 163 | - ); |
|
| 164 | - } |
|
| 165 | - } |
|
| 142 | + /** |
|
| 143 | + * espresso_load_required |
|
| 144 | + * given a class name and path, this function will load that file or throw an exception |
|
| 145 | + * |
|
| 146 | + * @param string $classname |
|
| 147 | + * @param string $full_path_to_file |
|
| 148 | + * @throws EE_Error |
|
| 149 | + */ |
|
| 150 | + function espresso_load_required($classname, $full_path_to_file) |
|
| 151 | + { |
|
| 152 | + if (is_readable($full_path_to_file)) { |
|
| 153 | + require_once $full_path_to_file; |
|
| 154 | + } else { |
|
| 155 | + throw new \EE_Error ( |
|
| 156 | + sprintf( |
|
| 157 | + esc_html__( |
|
| 158 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 159 | + 'event_espresso' |
|
| 160 | + ), |
|
| 161 | + $classname |
|
| 162 | + ) |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * @since 4.9.27 |
|
| 169 | - * @throws \EE_Error |
|
| 170 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 171 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 172 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
| 173 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
| 174 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 175 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
| 176 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
| 177 | - * @throws \OutOfBoundsException |
|
| 178 | - */ |
|
| 179 | - function bootstrap_espresso() |
|
| 180 | - { |
|
| 181 | - require_once __DIR__ . '/core/espresso_definitions.php'; |
|
| 182 | - try { |
|
| 183 | - espresso_load_error_handling(); |
|
| 184 | - espresso_load_required( |
|
| 185 | - 'EEH_Base', |
|
| 186 | - EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
| 187 | - ); |
|
| 188 | - espresso_load_required( |
|
| 189 | - 'EEH_File', |
|
| 190 | - EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
| 191 | - ); |
|
| 192 | - espresso_load_required( |
|
| 193 | - 'EEH_File', |
|
| 194 | - EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
| 195 | - ); |
|
| 196 | - espresso_load_required( |
|
| 197 | - 'EEH_Array', |
|
| 198 | - EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
| 199 | - ); |
|
| 200 | - // instantiate and configure PSR4 autoloader |
|
| 201 | - espresso_load_required( |
|
| 202 | - 'Psr4Autoloader', |
|
| 203 | - EE_CORE . 'Psr4Autoloader.php' |
|
| 204 | - ); |
|
| 205 | - espresso_load_required( |
|
| 206 | - 'EE_Psr4AutoloaderInit', |
|
| 207 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
| 208 | - ); |
|
| 209 | - $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
| 210 | - $AutoloaderInit->initializeAutoloader(); |
|
| 211 | - espresso_load_required( |
|
| 212 | - 'EE_Request', |
|
| 213 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 214 | - ); |
|
| 215 | - espresso_load_required( |
|
| 216 | - 'EE_Response', |
|
| 217 | - EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
| 218 | - ); |
|
| 219 | - espresso_load_required( |
|
| 220 | - 'EE_Bootstrap', |
|
| 221 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
| 222 | - ); |
|
| 223 | - // bootstrap EE and the request stack |
|
| 224 | - new EE_Bootstrap( |
|
| 225 | - new EE_Request($_GET, $_POST, $_COOKIE), |
|
| 226 | - new EE_Response() |
|
| 227 | - ); |
|
| 228 | - } catch (Exception $e) { |
|
| 229 | - require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
| 230 | - new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - bootstrap_espresso(); |
|
| 234 | - } |
|
| 167 | + /** |
|
| 168 | + * @since 4.9.27 |
|
| 169 | + * @throws \EE_Error |
|
| 170 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 171 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 172 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
| 173 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
| 174 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 175 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
| 176 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
| 177 | + * @throws \OutOfBoundsException |
|
| 178 | + */ |
|
| 179 | + function bootstrap_espresso() |
|
| 180 | + { |
|
| 181 | + require_once __DIR__ . '/core/espresso_definitions.php'; |
|
| 182 | + try { |
|
| 183 | + espresso_load_error_handling(); |
|
| 184 | + espresso_load_required( |
|
| 185 | + 'EEH_Base', |
|
| 186 | + EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
| 187 | + ); |
|
| 188 | + espresso_load_required( |
|
| 189 | + 'EEH_File', |
|
| 190 | + EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
| 191 | + ); |
|
| 192 | + espresso_load_required( |
|
| 193 | + 'EEH_File', |
|
| 194 | + EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
| 195 | + ); |
|
| 196 | + espresso_load_required( |
|
| 197 | + 'EEH_Array', |
|
| 198 | + EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
| 199 | + ); |
|
| 200 | + // instantiate and configure PSR4 autoloader |
|
| 201 | + espresso_load_required( |
|
| 202 | + 'Psr4Autoloader', |
|
| 203 | + EE_CORE . 'Psr4Autoloader.php' |
|
| 204 | + ); |
|
| 205 | + espresso_load_required( |
|
| 206 | + 'EE_Psr4AutoloaderInit', |
|
| 207 | + EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
| 208 | + ); |
|
| 209 | + $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
| 210 | + $AutoloaderInit->initializeAutoloader(); |
|
| 211 | + espresso_load_required( |
|
| 212 | + 'EE_Request', |
|
| 213 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 214 | + ); |
|
| 215 | + espresso_load_required( |
|
| 216 | + 'EE_Response', |
|
| 217 | + EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
| 218 | + ); |
|
| 219 | + espresso_load_required( |
|
| 220 | + 'EE_Bootstrap', |
|
| 221 | + EE_CORE . 'EE_Bootstrap.core.php' |
|
| 222 | + ); |
|
| 223 | + // bootstrap EE and the request stack |
|
| 224 | + new EE_Bootstrap( |
|
| 225 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
| 226 | + new EE_Response() |
|
| 227 | + ); |
|
| 228 | + } catch (Exception $e) { |
|
| 229 | + require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
| 230 | + new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + bootstrap_espresso(); |
|
| 234 | + } |
|
| 235 | 235 | } |
| 236 | 236 | if (! function_exists('espresso_deactivate_plugin')) { |
| 237 | - /** |
|
| 238 | - * deactivate_plugin |
|
| 239 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 240 | - * |
|
| 241 | - * @access public |
|
| 242 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 243 | - * @return void |
|
| 244 | - */ |
|
| 245 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 246 | - { |
|
| 247 | - if (! function_exists('deactivate_plugins')) { |
|
| 248 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 249 | - } |
|
| 250 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 251 | - deactivate_plugins($plugin_basename); |
|
| 252 | - } |
|
| 237 | + /** |
|
| 238 | + * deactivate_plugin |
|
| 239 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 240 | + * |
|
| 241 | + * @access public |
|
| 242 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 243 | + * @return void |
|
| 244 | + */ |
|
| 245 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 246 | + { |
|
| 247 | + if (! function_exists('deactivate_plugins')) { |
|
| 248 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 249 | + } |
|
| 250 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 251 | + deactivate_plugins($plugin_basename); |
|
| 252 | + } |
|
| 253 | 253 | } |
@@ -21,199 +21,199 @@ |
||
| 21 | 21 | { |
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * converts a Request to a Response |
|
| 26 | - * |
|
| 27 | - * @param EE_Request $request |
|
| 28 | - * @param EE_Response $response |
|
| 29 | - * @return EE_Response |
|
| 30 | - * @throws InvalidDataTypeException |
|
| 31 | - */ |
|
| 32 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
| 33 | - { |
|
| 34 | - $this->_request = $request; |
|
| 35 | - $this->_response = $response; |
|
| 36 | - //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
|
| 37 | - //$this->_response->set_notice( 1, 'hey look at this' ); |
|
| 38 | - // check required WP version |
|
| 39 | - if (! $this->_minimum_wp_version_required()) { |
|
| 40 | - $this->_request->un_set('activate', true); |
|
| 41 | - add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
| 42 | - //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
|
| 43 | - $this->_response->terminate_request(); |
|
| 44 | - $this->_response->deactivate_plugin(); |
|
| 45 | - } |
|
| 46 | - // check recommended PHP version |
|
| 47 | - if (! $this->_minimum_php_version_recommended()) { |
|
| 48 | - $this->_display_minimum_recommended_php_version_notice(); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - //upcoming required version |
|
| 52 | - if (! $this->upcomingRequiredPhpVersion()) { |
|
| 53 | - $this->displayUpcomingRequiredVersion(); |
|
| 54 | - } |
|
| 55 | - $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
| 56 | - //$this->_response->add_output( "\n\t OUT << " . __CLASS__ ); |
|
| 57 | - return $this->_response; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Helper method to assess installed wp version against given values. |
|
| 63 | - * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
| 64 | - * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
| 65 | - * against) so consider that when sending in your values. |
|
| 66 | - * |
|
| 67 | - * @param string $version_to_check |
|
| 68 | - * @param string $operator |
|
| 69 | - * @return bool |
|
| 70 | - */ |
|
| 71 | - public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
| 72 | - { |
|
| 73 | - global $wp_version; |
|
| 74 | - return version_compare( |
|
| 75 | - // first account for wp_version being pre-release |
|
| 76 | - // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
| 77 | - strpos($wp_version, '-') > 0 |
|
| 78 | - ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
| 79 | - : $wp_version, |
|
| 80 | - $version_to_check, |
|
| 81 | - $operator |
|
| 82 | - ); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * _minimum_wp_version_required |
|
| 89 | - * |
|
| 90 | - * @access private |
|
| 91 | - * @return boolean |
|
| 92 | - */ |
|
| 93 | - private function _minimum_wp_version_required() |
|
| 94 | - { |
|
| 95 | - return EE_Recommended_Versions::check_wp_version(); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * _check_php_version |
|
| 102 | - * |
|
| 103 | - * @access private |
|
| 104 | - * @param string $min_version |
|
| 105 | - * @return boolean |
|
| 106 | - */ |
|
| 107 | - private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
| 108 | - { |
|
| 109 | - return version_compare(PHP_VERSION, $min_version, '>='); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * _minimum_php_version_recommended |
|
| 116 | - * |
|
| 117 | - * @access private |
|
| 118 | - * @return boolean |
|
| 119 | - */ |
|
| 120 | - private function _minimum_php_version_recommended() |
|
| 121 | - { |
|
| 122 | - return $this->_check_php_version(); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Returns whether the provided php version number is greater than the current version of php installed on the server. |
|
| 128 | - * @param string $version_required |
|
| 129 | - * @return bool |
|
| 130 | - */ |
|
| 131 | - private function upcomingRequiredPhpVersion($version_required = '5.4.45') |
|
| 132 | - { |
|
| 133 | - return $this->_check_php_version($version_required); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * minimum_wp_version_error |
|
| 140 | - * |
|
| 141 | - * @return void |
|
| 142 | - */ |
|
| 143 | - public function minimum_wp_version_error() |
|
| 144 | - { |
|
| 145 | - global $wp_version; |
|
| 146 | - ?> |
|
| 24 | + /** |
|
| 25 | + * converts a Request to a Response |
|
| 26 | + * |
|
| 27 | + * @param EE_Request $request |
|
| 28 | + * @param EE_Response $response |
|
| 29 | + * @return EE_Response |
|
| 30 | + * @throws InvalidDataTypeException |
|
| 31 | + */ |
|
| 32 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
| 33 | + { |
|
| 34 | + $this->_request = $request; |
|
| 35 | + $this->_response = $response; |
|
| 36 | + //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
|
| 37 | + //$this->_response->set_notice( 1, 'hey look at this' ); |
|
| 38 | + // check required WP version |
|
| 39 | + if (! $this->_minimum_wp_version_required()) { |
|
| 40 | + $this->_request->un_set('activate', true); |
|
| 41 | + add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
| 42 | + //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
|
| 43 | + $this->_response->terminate_request(); |
|
| 44 | + $this->_response->deactivate_plugin(); |
|
| 45 | + } |
|
| 46 | + // check recommended PHP version |
|
| 47 | + if (! $this->_minimum_php_version_recommended()) { |
|
| 48 | + $this->_display_minimum_recommended_php_version_notice(); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + //upcoming required version |
|
| 52 | + if (! $this->upcomingRequiredPhpVersion()) { |
|
| 53 | + $this->displayUpcomingRequiredVersion(); |
|
| 54 | + } |
|
| 55 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
| 56 | + //$this->_response->add_output( "\n\t OUT << " . __CLASS__ ); |
|
| 57 | + return $this->_response; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Helper method to assess installed wp version against given values. |
|
| 63 | + * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
| 64 | + * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked |
|
| 65 | + * against) so consider that when sending in your values. |
|
| 66 | + * |
|
| 67 | + * @param string $version_to_check |
|
| 68 | + * @param string $operator |
|
| 69 | + * @return bool |
|
| 70 | + */ |
|
| 71 | + public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
| 72 | + { |
|
| 73 | + global $wp_version; |
|
| 74 | + return version_compare( |
|
| 75 | + // first account for wp_version being pre-release |
|
| 76 | + // (like RC, beta etc) which are usually in the format like 4.7-RC3-39519 |
|
| 77 | + strpos($wp_version, '-') > 0 |
|
| 78 | + ? substr($wp_version, 0, strpos($wp_version, '-')) |
|
| 79 | + : $wp_version, |
|
| 80 | + $version_to_check, |
|
| 81 | + $operator |
|
| 82 | + ); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * _minimum_wp_version_required |
|
| 89 | + * |
|
| 90 | + * @access private |
|
| 91 | + * @return boolean |
|
| 92 | + */ |
|
| 93 | + private function _minimum_wp_version_required() |
|
| 94 | + { |
|
| 95 | + return EE_Recommended_Versions::check_wp_version(); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * _check_php_version |
|
| 102 | + * |
|
| 103 | + * @access private |
|
| 104 | + * @param string $min_version |
|
| 105 | + * @return boolean |
|
| 106 | + */ |
|
| 107 | + private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
| 108 | + { |
|
| 109 | + return version_compare(PHP_VERSION, $min_version, '>='); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * _minimum_php_version_recommended |
|
| 116 | + * |
|
| 117 | + * @access private |
|
| 118 | + * @return boolean |
|
| 119 | + */ |
|
| 120 | + private function _minimum_php_version_recommended() |
|
| 121 | + { |
|
| 122 | + return $this->_check_php_version(); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Returns whether the provided php version number is greater than the current version of php installed on the server. |
|
| 128 | + * @param string $version_required |
|
| 129 | + * @return bool |
|
| 130 | + */ |
|
| 131 | + private function upcomingRequiredPhpVersion($version_required = '5.4.45') |
|
| 132 | + { |
|
| 133 | + return $this->_check_php_version($version_required); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * minimum_wp_version_error |
|
| 140 | + * |
|
| 141 | + * @return void |
|
| 142 | + */ |
|
| 143 | + public function minimum_wp_version_error() |
|
| 144 | + { |
|
| 145 | + global $wp_version; |
|
| 146 | + ?> |
|
| 147 | 147 | <div class="error"> |
| 148 | 148 | <p> |
| 149 | 149 | <?php |
| 150 | - printf( |
|
| 151 | - __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
| 152 | - 'event_espresso'), |
|
| 153 | - EE_MIN_WP_VER_REQUIRED, |
|
| 154 | - $wp_version, |
|
| 155 | - '<br/>', |
|
| 156 | - '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
| 157 | - ); |
|
| 158 | - ?> |
|
| 150 | + printf( |
|
| 151 | + __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
| 152 | + 'event_espresso'), |
|
| 153 | + EE_MIN_WP_VER_REQUIRED, |
|
| 154 | + $wp_version, |
|
| 155 | + '<br/>', |
|
| 156 | + '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
| 157 | + ); |
|
| 158 | + ?> |
|
| 159 | 159 | </p> |
| 160 | 160 | </div> |
| 161 | 161 | <?php |
| 162 | - } |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * _display_minimum_recommended_php_version_notice |
|
| 168 | - * |
|
| 169 | - * @access private |
|
| 170 | - * @return void |
|
| 171 | - * @throws InvalidDataTypeException |
|
| 172 | - */ |
|
| 173 | - private function _display_minimum_recommended_php_version_notice() |
|
| 174 | - { |
|
| 175 | - if($this->_request->isAdmin()){ |
|
| 176 | - new PersistentAdminNotice( |
|
| 177 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
| 178 | - sprintf( |
|
| 179 | - __( |
|
| 180 | - 'Event Espresso recommends PHP version %1$s or greater for optimal performance. 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.', |
|
| 181 | - 'event_espresso' |
|
| 182 | - ), |
|
| 183 | - EE_MIN_PHP_VER_RECOMMENDED, |
|
| 184 | - PHP_VERSION, |
|
| 185 | - '<br/>', |
|
| 186 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 187 | - ) |
|
| 188 | - ); |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
| 195 | - */ |
|
| 196 | - private function displayUpcomingRequiredVersion() |
|
| 197 | - { |
|
| 198 | - if ($this->_request->isAdmin() |
|
| 199 | - && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->_request) |
|
| 200 | - && current_user_can('update_plugins') |
|
| 201 | - ) { |
|
| 202 | - add_action('admin_notices', function () { |
|
| 203 | - echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
| 204 | - . sprintf( |
|
| 205 | - esc_html__( |
|
| 206 | - 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
| 207 | - 'event_espresso' |
|
| 208 | - ), |
|
| 209 | - '<strong>', |
|
| 210 | - '</strong>', |
|
| 211 | - PHP_VERSION, |
|
| 212 | - '<a href="https://wordpress.org/support/upgrade-php/">', |
|
| 213 | - '</a>' |
|
| 214 | - ) |
|
| 215 | - . '</p></div>'; |
|
| 216 | - }); |
|
| 217 | - } |
|
| 218 | - } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * _display_minimum_recommended_php_version_notice |
|
| 168 | + * |
|
| 169 | + * @access private |
|
| 170 | + * @return void |
|
| 171 | + * @throws InvalidDataTypeException |
|
| 172 | + */ |
|
| 173 | + private function _display_minimum_recommended_php_version_notice() |
|
| 174 | + { |
|
| 175 | + if($this->_request->isAdmin()){ |
|
| 176 | + new PersistentAdminNotice( |
|
| 177 | + 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
| 178 | + sprintf( |
|
| 179 | + __( |
|
| 180 | + 'Event Espresso recommends PHP version %1$s or greater for optimal performance. 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.', |
|
| 181 | + 'event_espresso' |
|
| 182 | + ), |
|
| 183 | + EE_MIN_PHP_VER_RECOMMENDED, |
|
| 184 | + PHP_VERSION, |
|
| 185 | + '<br/>', |
|
| 186 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 187 | + ) |
|
| 188 | + ); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Sets a notice for an upcoming required version of PHP in the next update of EE core. |
|
| 195 | + */ |
|
| 196 | + private function displayUpcomingRequiredVersion() |
|
| 197 | + { |
|
| 198 | + if ($this->_request->isAdmin() |
|
| 199 | + && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->_request) |
|
| 200 | + && current_user_can('update_plugins') |
|
| 201 | + ) { |
|
| 202 | + add_action('admin_notices', function () { |
|
| 203 | + echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
|
| 204 | + . sprintf( |
|
| 205 | + esc_html__( |
|
| 206 | + 'Please note: The next update of Event Espresso 4 will %1$srequire%2$s PHP 5.4.45 or greater. Your web server\'s PHP version is %3$s. You can contact your host and ask them to update your PHP version to at least PHP 5.6. Please do not update to the new version of Event Espresso 4 until the PHP update is completed. Read about why keeping your server on the latest version of PHP is a good idea %4$shere%5$s', |
|
| 207 | + 'event_espresso' |
|
| 208 | + ), |
|
| 209 | + '<strong>', |
|
| 210 | + '</strong>', |
|
| 211 | + PHP_VERSION, |
|
| 212 | + '<a href="https://wordpress.org/support/upgrade-php/">', |
|
| 213 | + '</a>' |
|
| 214 | + ) |
|
| 215 | + . '</p></div>'; |
|
| 216 | + }); |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | 219 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
| 37 | 37 | //$this->_response->set_notice( 1, 'hey look at this' ); |
| 38 | 38 | // check required WP version |
| 39 | - if (! $this->_minimum_wp_version_required()) { |
|
| 39 | + if ( ! $this->_minimum_wp_version_required()) { |
|
| 40 | 40 | $this->_request->un_set('activate', true); |
| 41 | 41 | add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
| 42 | 42 | //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | $this->_response->deactivate_plugin(); |
| 45 | 45 | } |
| 46 | 46 | // check recommended PHP version |
| 47 | - if (! $this->_minimum_php_version_recommended()) { |
|
| 47 | + if ( ! $this->_minimum_php_version_recommended()) { |
|
| 48 | 48 | $this->_display_minimum_recommended_php_version_notice(); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | //upcoming required version |
| 52 | - if (! $this->upcomingRequiredPhpVersion()) { |
|
| 52 | + if ( ! $this->upcomingRequiredPhpVersion()) { |
|
| 53 | 53 | $this->displayUpcomingRequiredVersion(); |
| 54 | 54 | } |
| 55 | 55 | $this->_response = $this->process_request_stack($this->_request, $this->_response); |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | private function _display_minimum_recommended_php_version_notice() |
| 174 | 174 | { |
| 175 | - if($this->_request->isAdmin()){ |
|
| 175 | + if ($this->_request->isAdmin()) { |
|
| 176 | 176 | new PersistentAdminNotice( |
| 177 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
| 177 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
| 178 | 178 | sprintf( |
| 179 | 179 | __( |
| 180 | 180 | 'Event Espresso recommends PHP version %1$s or greater for optimal performance. 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.', |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | && apply_filters('FHEE__EE_Recommended_Versions__displayUpcomingRequiredVersion', true, $this->_request) |
| 200 | 200 | && current_user_can('update_plugins') |
| 201 | 201 | ) { |
| 202 | - add_action('admin_notices', function () { |
|
| 202 | + add_action('admin_notices', function() { |
|
| 203 | 203 | echo '<div class="notice event-espresso-admin-notice notice-warning"><p>' |
| 204 | 204 | . sprintf( |
| 205 | 205 | esc_html__( |
@@ -18,530 +18,530 @@ |
||
| 18 | 18 | class Events_Admin_List_Table extends EE_Admin_List_Table |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var EE_Datetime |
|
| 23 | - */ |
|
| 24 | - private $_dtt; |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Initial setup of data properties for the list table. |
|
| 30 | - */ |
|
| 31 | - protected function _setup_data() |
|
| 32 | - { |
|
| 33 | - $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page); |
|
| 34 | - $this->_all_data_count = $this->_admin_page->get_events(0, 0, true); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Set up of additional properties for the list table. |
|
| 41 | - */ |
|
| 42 | - protected function _set_properties() |
|
| 43 | - { |
|
| 44 | - $this->_wp_list_args = array( |
|
| 45 | - 'singular' => esc_html__('event', 'event_espresso'), |
|
| 46 | - 'plural' => esc_html__('events', 'event_espresso'), |
|
| 47 | - 'ajax' => true, //for now |
|
| 48 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 49 | - ); |
|
| 50 | - $this->_columns = array( |
|
| 51 | - 'cb' => '<input type="checkbox" />', |
|
| 52 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
| 53 | - 'name' => esc_html__('Name', 'event_espresso'), |
|
| 54 | - 'author' => esc_html__('Author', 'event_espresso'), |
|
| 55 | - 'venue' => esc_html__('Venue', 'event_espresso'), |
|
| 56 | - 'start_date_time' => esc_html__('Event Start', 'event_espresso'), |
|
| 57 | - 'reg_begins' => esc_html__('On Sale', 'event_espresso'), |
|
| 58 | - 'attendees' => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20">' |
|
| 59 | - . '<span class="screen-reader-text">' |
|
| 60 | - . esc_html__('Approved Registrations', 'event_espresso') |
|
| 61 | - . '</span>' |
|
| 62 | - . '</span>', |
|
| 63 | - //'tkts_sold' => esc_html__('Tickets Sold', 'event_espresso'), |
|
| 64 | - 'actions' => esc_html__('Actions', 'event_espresso'), |
|
| 65 | - ); |
|
| 66 | - $this->_sortable_columns = array( |
|
| 67 | - 'id' => array('EVT_ID' => true), |
|
| 68 | - 'name' => array('EVT_name' => false), |
|
| 69 | - 'author' => array('EVT_wp_user' => false), |
|
| 70 | - 'venue' => array('Venue.VNU_name' => false), |
|
| 71 | - 'start_date_time' => array('Datetime.DTT_EVT_start' => false), |
|
| 72 | - 'reg_begins' => array('Datetime.Ticket.TKT_start_date' => false), |
|
| 73 | - ); |
|
| 74 | - $this->_primary_column = 'id'; |
|
| 75 | - $this->_hidden_columns = array('author'); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @return array |
|
| 82 | - */ |
|
| 83 | - protected function _get_table_filters() |
|
| 84 | - { |
|
| 85 | - return array(); //no filters with decaf |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Setup of views properties. |
|
| 92 | - * |
|
| 93 | - * @throws InvalidDataTypeException |
|
| 94 | - * @throws InvalidInterfaceException |
|
| 95 | - * @throws InvalidArgumentException |
|
| 96 | - */ |
|
| 97 | - protected function _add_view_counts() |
|
| 98 | - { |
|
| 99 | - $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
| 100 | - $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
| 101 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 102 | - 'ee_delete_events', |
|
| 103 | - 'espresso_events_trash_events' |
|
| 104 | - )) { |
|
| 105 | - $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * @param EE_Event $item |
|
| 113 | - * @return string |
|
| 114 | - * @throws EE_Error |
|
| 115 | - */ |
|
| 116 | - protected function _get_row_class($item) |
|
| 117 | - { |
|
| 118 | - $class = parent::_get_row_class($item); |
|
| 119 | - //add status class |
|
| 120 | - $class .= $item instanceof EE_Event |
|
| 121 | - ? ' ee-status-strip event-status-' . $item->get_active_status() |
|
| 122 | - : ''; |
|
| 123 | - if ($this->_has_checkbox_column) { |
|
| 124 | - $class .= ' has-checkbox-column'; |
|
| 125 | - } |
|
| 126 | - return $class; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @param EE_Event $item |
|
| 133 | - * @return string |
|
| 134 | - * @throws EE_Error |
|
| 135 | - */ |
|
| 136 | - public function column_status(EE_Event $item) |
|
| 137 | - { |
|
| 138 | - return '<span class="ee-status-strip ee-status-strip-td event-status-' |
|
| 139 | - . $item->get_active_status() |
|
| 140 | - . '"></span>'; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * @param EE_Event $item |
|
| 147 | - * @return string |
|
| 148 | - * @throws EE_Error |
|
| 149 | - */ |
|
| 150 | - public function column_cb($item) |
|
| 151 | - { |
|
| 152 | - if (! $item instanceof EE_Event) { |
|
| 153 | - return ''; |
|
| 154 | - } |
|
| 155 | - $this->_dtt = $item->primary_datetime(); //set this for use in other columns |
|
| 156 | - //does event have any attached registrations? |
|
| 157 | - $regs = $item->count_related('Registration'); |
|
| 158 | - return $regs > 0 && $this->_view === 'trash' |
|
| 159 | - ? '<span class="ee-lock-icon"></span>' |
|
| 160 | - : sprintf( |
|
| 161 | - '<input type="checkbox" name="EVT_IDs[]" value="%s" />', |
|
| 162 | - $item->ID() |
|
| 163 | - ); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * @param EE_Event $item |
|
| 170 | - * @return mixed|string |
|
| 171 | - * @throws EE_Error |
|
| 172 | - */ |
|
| 173 | - public function column_id(EE_Event $item) |
|
| 174 | - { |
|
| 175 | - $content = $item->ID(); |
|
| 176 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
| 177 | - return $content; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * @param EE_Event $item |
|
| 184 | - * @return string |
|
| 185 | - * @throws EE_Error |
|
| 186 | - * @throws InvalidArgumentException |
|
| 187 | - * @throws InvalidDataTypeException |
|
| 188 | - * @throws InvalidInterfaceException |
|
| 189 | - */ |
|
| 190 | - public function column_name(EE_Event $item) |
|
| 191 | - { |
|
| 192 | - $edit_query_args = array( |
|
| 193 | - 'action' => 'edit', |
|
| 194 | - 'post' => $item->ID(), |
|
| 195 | - ); |
|
| 196 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 197 | - $actions = $this->_column_name_action_setup($item); |
|
| 198 | - $status = ''; //$item->status() !== 'publish' ? ' (' . $item->status() . ')' : ''; |
|
| 199 | - $content = '<strong><a class="row-title" href="' |
|
| 200 | - . $edit_link . '">' |
|
| 201 | - . $item->name() |
|
| 202 | - . '</a></strong>' |
|
| 203 | - . $status; |
|
| 204 | - $content .= '<br><span class="ee-status-text-small">' |
|
| 205 | - . EEH_Template::pretty_status( |
|
| 206 | - $item->get_active_status(), |
|
| 207 | - false, |
|
| 208 | - 'sentence' |
|
| 209 | - ) |
|
| 210 | - . '</span>'; |
|
| 211 | - $content .= $this->row_actions($actions); |
|
| 212 | - return $content; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * Just a method for setting up the actions for the name column |
|
| 219 | - * |
|
| 220 | - * @param EE_Event $item |
|
| 221 | - * @return array array of actions |
|
| 222 | - * @throws EE_Error |
|
| 223 | - * @throws InvalidArgumentException |
|
| 224 | - * @throws InvalidDataTypeException |
|
| 225 | - * @throws InvalidInterfaceException |
|
| 226 | - */ |
|
| 227 | - protected function _column_name_action_setup(EE_Event $item) |
|
| 228 | - { |
|
| 229 | - //todo: remove when attendees is active |
|
| 230 | - if (! defined('REG_ADMIN_URL')) { |
|
| 231 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 232 | - } |
|
| 233 | - $actions = array(); |
|
| 234 | - $restore_event_link = ''; |
|
| 235 | - $delete_event_link = ''; |
|
| 236 | - $trash_event_link = ''; |
|
| 237 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 238 | - 'ee_edit_event', |
|
| 239 | - 'espresso_events_edit', |
|
| 240 | - $item->ID() |
|
| 241 | - )) { |
|
| 242 | - $edit_query_args = array( |
|
| 243 | - 'action' => 'edit', |
|
| 244 | - 'post' => $item->ID(), |
|
| 245 | - ); |
|
| 246 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 247 | - $actions['edit'] = '<a href="' . $edit_link . '"' |
|
| 248 | - . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 249 | - . esc_html__('Edit', 'event_espresso') |
|
| 250 | - . '</a>'; |
|
| 251 | - } |
|
| 252 | - if ( |
|
| 253 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 254 | - 'ee_read_registrations', |
|
| 255 | - 'espresso_registrations_view_registration' |
|
| 256 | - ) |
|
| 257 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 258 | - 'ee_read_event', |
|
| 259 | - 'espresso_registrations_view_registration', |
|
| 260 | - $item->ID() |
|
| 261 | - ) |
|
| 262 | - ) { |
|
| 263 | - $attendees_query_args = array( |
|
| 264 | - 'action' => 'default', |
|
| 265 | - 'event_id' => $item->ID(), |
|
| 266 | - ); |
|
| 267 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 268 | - $actions['attendees'] = '<a href="' . $attendees_link . '"' |
|
| 269 | - . ' title="' . esc_attr__('View Registrations', 'event_espresso') . '">' |
|
| 270 | - . esc_html__('Registrations', 'event_espresso') |
|
| 271 | - . '</a>'; |
|
| 272 | - } |
|
| 273 | - if ( |
|
| 274 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 275 | - 'ee_delete_event', |
|
| 276 | - 'espresso_events_trash_event', |
|
| 277 | - $item->ID() |
|
| 278 | - ) |
|
| 279 | - ) { |
|
| 280 | - $trash_event_query_args = array( |
|
| 281 | - 'action' => 'trash_event', |
|
| 282 | - 'EVT_ID' => $item->ID(), |
|
| 283 | - ); |
|
| 284 | - $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 285 | - $trash_event_query_args, |
|
| 286 | - EVENTS_ADMIN_URL |
|
| 287 | - ); |
|
| 288 | - } |
|
| 289 | - if ( |
|
| 290 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 291 | - 'ee_delete_event', |
|
| 292 | - 'espresso_events_restore_event', |
|
| 293 | - $item->ID() |
|
| 294 | - ) |
|
| 295 | - ) { |
|
| 296 | - $restore_event_query_args = array( |
|
| 297 | - 'action' => 'restore_event', |
|
| 298 | - 'EVT_ID' => $item->ID(), |
|
| 299 | - ); |
|
| 300 | - $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 301 | - $restore_event_query_args, |
|
| 302 | - EVENTS_ADMIN_URL |
|
| 303 | - ); |
|
| 304 | - } |
|
| 305 | - if ( |
|
| 306 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 307 | - 'ee_delete_event', |
|
| 308 | - 'espresso_events_delete_event', |
|
| 309 | - $item->ID() |
|
| 310 | - ) |
|
| 311 | - ) { |
|
| 312 | - $delete_event_query_args = array( |
|
| 313 | - 'action' => 'delete_event', |
|
| 314 | - 'EVT_ID' => $item->ID(), |
|
| 315 | - ); |
|
| 316 | - $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 317 | - $delete_event_query_args, |
|
| 318 | - EVENTS_ADMIN_URL |
|
| 319 | - ); |
|
| 320 | - } |
|
| 321 | - $view_link = get_permalink($item->ID()); |
|
| 322 | - $actions['view'] = '<a href="' . $view_link . '"' |
|
| 323 | - . ' title="' . esc_attr__('View Event', 'event_espresso') . '">' |
|
| 324 | - . esc_html__('View', 'event_espresso') |
|
| 325 | - . '</a>'; |
|
| 326 | - if ($item->get('status') === 'trash') { |
|
| 327 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 328 | - 'ee_delete_event', |
|
| 329 | - 'espresso_events_restore_event', |
|
| 330 | - $item->ID() |
|
| 331 | - )) { |
|
| 332 | - $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"' |
|
| 333 | - . ' title="' . esc_attr__('Restore from Trash', 'event_espresso') |
|
| 334 | - . '">' |
|
| 335 | - . esc_html__('Restore from Trash', 'event_espresso') |
|
| 336 | - . '</a>'; |
|
| 337 | - } |
|
| 338 | - if ( |
|
| 339 | - $item->count_related('Registration') === 0 |
|
| 340 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 341 | - 'ee_delete_event', |
|
| 342 | - 'espresso_events_delete_event', |
|
| 343 | - $item->ID() |
|
| 344 | - ) |
|
| 345 | - ) { |
|
| 346 | - $actions['delete'] = '<a href="' . $delete_event_link . '"' |
|
| 347 | - . ' title="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' |
|
| 348 | - . esc_html__('Delete Permanently', 'event_espresso') |
|
| 349 | - . '</a>'; |
|
| 350 | - } |
|
| 351 | - } else { |
|
| 352 | - if ( |
|
| 353 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 354 | - 'ee_delete_event', |
|
| 355 | - 'espresso_events_trash_event', |
|
| 356 | - $item->ID() |
|
| 357 | - ) |
|
| 358 | - ) { |
|
| 359 | - $actions['move to trash'] = '<a href="' . $trash_event_link . '"' |
|
| 360 | - . ' title="' . esc_attr__('Trash Event', 'event_espresso') . '">' |
|
| 361 | - . esc_html__('Trash', 'event_espresso') |
|
| 362 | - . '</a>'; |
|
| 363 | - } |
|
| 364 | - } |
|
| 365 | - return $actions; |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * @param EE_Event $item |
|
| 372 | - * @return string |
|
| 373 | - * @throws EE_Error |
|
| 374 | - */ |
|
| 375 | - public function column_author(EE_Event $item) |
|
| 376 | - { |
|
| 377 | - //user author info |
|
| 378 | - $event_author = get_userdata($item->wp_user()); |
|
| 379 | - $gravatar = get_avatar($item->wp_user(), '15'); |
|
| 380 | - //filter link |
|
| 381 | - $query_args = array( |
|
| 382 | - 'action' => 'default', |
|
| 383 | - 'EVT_wp_user' => $item->wp_user(), |
|
| 384 | - ); |
|
| 385 | - $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
| 386 | - return $gravatar . ' <a href="' . $filter_url . '"' |
|
| 387 | - . ' title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
| 388 | - . $event_author->display_name |
|
| 389 | - . '</a>'; |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * @param EE_Event $item |
|
| 396 | - * @return string |
|
| 397 | - * @throws EE_Error |
|
| 398 | - */ |
|
| 399 | - public function column_venue(EE_Event $item) |
|
| 400 | - { |
|
| 401 | - $venue = $item->get_first_related('Venue'); |
|
| 402 | - return ! empty($venue) |
|
| 403 | - ? $venue->name() |
|
| 404 | - : ''; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * @param EE_Event $item |
|
| 410 | - * @return string |
|
| 411 | - * @throws EE_Error |
|
| 412 | - */ |
|
| 413 | - public function column_start_date_time(EE_Event $item) |
|
| 414 | - { |
|
| 415 | - return $this->_dtt instanceof EE_Datetime |
|
| 416 | - ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') |
|
| 417 | - : esc_html__('No Date was saved for this Event', 'event_espresso'); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * @param EE_Event $item |
|
| 423 | - * @return string |
|
| 424 | - * @throws EE_Error |
|
| 425 | - */ |
|
| 426 | - public function column_reg_begins(EE_Event $item) |
|
| 427 | - { |
|
| 428 | - $reg_start = $item->get_ticket_with_earliest_start_time(); |
|
| 429 | - return $reg_start instanceof EE_Ticket |
|
| 430 | - ? $reg_start->get_i18n_datetime('TKT_start_date') |
|
| 431 | - : esc_html__('No Tickets have been setup for this Event', 'event_espresso'); |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - |
|
| 435 | - |
|
| 436 | - /** |
|
| 437 | - * @param EE_Event $item |
|
| 438 | - * @return int|string |
|
| 439 | - * @throws EE_Error |
|
| 440 | - * @throws InvalidArgumentException |
|
| 441 | - * @throws InvalidDataTypeException |
|
| 442 | - * @throws InvalidInterfaceException |
|
| 443 | - */ |
|
| 444 | - public function column_attendees(EE_Event $item) |
|
| 445 | - { |
|
| 446 | - $attendees_query_args = array( |
|
| 447 | - 'action' => 'default', |
|
| 448 | - 'event_id' => $item->ID(), |
|
| 449 | - ); |
|
| 450 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 451 | - $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID()); |
|
| 452 | - return EE_Registry::instance()->CAP->current_user_can( |
|
| 453 | - 'ee_read_event', |
|
| 454 | - 'espresso_registrations_view_registration', |
|
| 455 | - $item->ID() |
|
| 456 | - ) |
|
| 457 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 458 | - 'ee_read_registrations', |
|
| 459 | - 'espresso_registrations_view_registration' |
|
| 460 | - ) |
|
| 461 | - ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
| 462 | - : $registered_attendees; |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * @param EE_Event $item |
|
| 469 | - * @return float |
|
| 470 | - * @throws EE_Error |
|
| 471 | - * @throws InvalidArgumentException |
|
| 472 | - * @throws InvalidDataTypeException |
|
| 473 | - * @throws InvalidInterfaceException |
|
| 474 | - */ |
|
| 475 | - public function column_tkts_sold(EE_Event $item) |
|
| 476 | - { |
|
| 477 | - return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold'); |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - |
|
| 481 | - |
|
| 482 | - /** |
|
| 483 | - * @param EE_Event $item |
|
| 484 | - * @return string |
|
| 485 | - * @throws EE_Error |
|
| 486 | - * @throws InvalidArgumentException |
|
| 487 | - * @throws InvalidDataTypeException |
|
| 488 | - * @throws InvalidInterfaceException |
|
| 489 | - */ |
|
| 490 | - public function column_actions(EE_Event $item) |
|
| 491 | - { |
|
| 492 | - //todo: remove when attendees is active |
|
| 493 | - if (! defined('REG_ADMIN_URL')) { |
|
| 494 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 495 | - } |
|
| 496 | - $action_links = array(); |
|
| 497 | - $view_link = get_permalink($item->ID()); |
|
| 498 | - $action_links[] = '<a href="' . $view_link . '"' |
|
| 499 | - . ' title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">'; |
|
| 500 | - $action_links[] = '<div class="dashicons dashicons-search"></div></a>'; |
|
| 501 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 502 | - 'ee_edit_event', |
|
| 503 | - 'espresso_events_edit', |
|
| 504 | - $item->ID() |
|
| 505 | - )) { |
|
| 506 | - $edit_query_args = array( |
|
| 507 | - 'action' => 'edit', |
|
| 508 | - 'post' => $item->ID(), |
|
| 509 | - ); |
|
| 510 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 511 | - $action_links[] = '<a href="' . $edit_link . '"' |
|
| 512 | - . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 513 | - . '<div class="ee-icon ee-icon-calendar-edit"></div>' |
|
| 514 | - . '</a>'; |
|
| 515 | - } |
|
| 516 | - if ( |
|
| 517 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 518 | - 'ee_read_registrations', |
|
| 519 | - 'espresso_registrations_view_registration' |
|
| 520 | - ) && EE_Registry::instance()->CAP->current_user_can( |
|
| 521 | - 'ee_read_event', |
|
| 522 | - 'espresso_registrations_view_registration', |
|
| 523 | - $item->ID() |
|
| 524 | - ) |
|
| 525 | - ) { |
|
| 526 | - $attendees_query_args = array( |
|
| 527 | - 'action' => 'default', |
|
| 528 | - 'event_id' => $item->ID(), |
|
| 529 | - ); |
|
| 530 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 531 | - $action_links[] = '<a href="' . $attendees_link . '"' |
|
| 532 | - . ' title="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
| 533 | - . '<div class="dashicons dashicons-groups"></div>' |
|
| 534 | - . '</a>'; |
|
| 535 | - } |
|
| 536 | - $action_links = apply_filters( |
|
| 537 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
| 538 | - $action_links, |
|
| 539 | - $item |
|
| 540 | - ); |
|
| 541 | - return $this->_action_string( |
|
| 542 | - implode("\n\t", $action_links), |
|
| 543 | - $item, |
|
| 544 | - 'div' |
|
| 545 | - ); |
|
| 546 | - } |
|
| 21 | + /** |
|
| 22 | + * @var EE_Datetime |
|
| 23 | + */ |
|
| 24 | + private $_dtt; |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Initial setup of data properties for the list table. |
|
| 30 | + */ |
|
| 31 | + protected function _setup_data() |
|
| 32 | + { |
|
| 33 | + $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page); |
|
| 34 | + $this->_all_data_count = $this->_admin_page->get_events(0, 0, true); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Set up of additional properties for the list table. |
|
| 41 | + */ |
|
| 42 | + protected function _set_properties() |
|
| 43 | + { |
|
| 44 | + $this->_wp_list_args = array( |
|
| 45 | + 'singular' => esc_html__('event', 'event_espresso'), |
|
| 46 | + 'plural' => esc_html__('events', 'event_espresso'), |
|
| 47 | + 'ajax' => true, //for now |
|
| 48 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 49 | + ); |
|
| 50 | + $this->_columns = array( |
|
| 51 | + 'cb' => '<input type="checkbox" />', |
|
| 52 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
| 53 | + 'name' => esc_html__('Name', 'event_espresso'), |
|
| 54 | + 'author' => esc_html__('Author', 'event_espresso'), |
|
| 55 | + 'venue' => esc_html__('Venue', 'event_espresso'), |
|
| 56 | + 'start_date_time' => esc_html__('Event Start', 'event_espresso'), |
|
| 57 | + 'reg_begins' => esc_html__('On Sale', 'event_espresso'), |
|
| 58 | + 'attendees' => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20">' |
|
| 59 | + . '<span class="screen-reader-text">' |
|
| 60 | + . esc_html__('Approved Registrations', 'event_espresso') |
|
| 61 | + . '</span>' |
|
| 62 | + . '</span>', |
|
| 63 | + //'tkts_sold' => esc_html__('Tickets Sold', 'event_espresso'), |
|
| 64 | + 'actions' => esc_html__('Actions', 'event_espresso'), |
|
| 65 | + ); |
|
| 66 | + $this->_sortable_columns = array( |
|
| 67 | + 'id' => array('EVT_ID' => true), |
|
| 68 | + 'name' => array('EVT_name' => false), |
|
| 69 | + 'author' => array('EVT_wp_user' => false), |
|
| 70 | + 'venue' => array('Venue.VNU_name' => false), |
|
| 71 | + 'start_date_time' => array('Datetime.DTT_EVT_start' => false), |
|
| 72 | + 'reg_begins' => array('Datetime.Ticket.TKT_start_date' => false), |
|
| 73 | + ); |
|
| 74 | + $this->_primary_column = 'id'; |
|
| 75 | + $this->_hidden_columns = array('author'); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @return array |
|
| 82 | + */ |
|
| 83 | + protected function _get_table_filters() |
|
| 84 | + { |
|
| 85 | + return array(); //no filters with decaf |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Setup of views properties. |
|
| 92 | + * |
|
| 93 | + * @throws InvalidDataTypeException |
|
| 94 | + * @throws InvalidInterfaceException |
|
| 95 | + * @throws InvalidArgumentException |
|
| 96 | + */ |
|
| 97 | + protected function _add_view_counts() |
|
| 98 | + { |
|
| 99 | + $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
| 100 | + $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
| 101 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 102 | + 'ee_delete_events', |
|
| 103 | + 'espresso_events_trash_events' |
|
| 104 | + )) { |
|
| 105 | + $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * @param EE_Event $item |
|
| 113 | + * @return string |
|
| 114 | + * @throws EE_Error |
|
| 115 | + */ |
|
| 116 | + protected function _get_row_class($item) |
|
| 117 | + { |
|
| 118 | + $class = parent::_get_row_class($item); |
|
| 119 | + //add status class |
|
| 120 | + $class .= $item instanceof EE_Event |
|
| 121 | + ? ' ee-status-strip event-status-' . $item->get_active_status() |
|
| 122 | + : ''; |
|
| 123 | + if ($this->_has_checkbox_column) { |
|
| 124 | + $class .= ' has-checkbox-column'; |
|
| 125 | + } |
|
| 126 | + return $class; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @param EE_Event $item |
|
| 133 | + * @return string |
|
| 134 | + * @throws EE_Error |
|
| 135 | + */ |
|
| 136 | + public function column_status(EE_Event $item) |
|
| 137 | + { |
|
| 138 | + return '<span class="ee-status-strip ee-status-strip-td event-status-' |
|
| 139 | + . $item->get_active_status() |
|
| 140 | + . '"></span>'; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * @param EE_Event $item |
|
| 147 | + * @return string |
|
| 148 | + * @throws EE_Error |
|
| 149 | + */ |
|
| 150 | + public function column_cb($item) |
|
| 151 | + { |
|
| 152 | + if (! $item instanceof EE_Event) { |
|
| 153 | + return ''; |
|
| 154 | + } |
|
| 155 | + $this->_dtt = $item->primary_datetime(); //set this for use in other columns |
|
| 156 | + //does event have any attached registrations? |
|
| 157 | + $regs = $item->count_related('Registration'); |
|
| 158 | + return $regs > 0 && $this->_view === 'trash' |
|
| 159 | + ? '<span class="ee-lock-icon"></span>' |
|
| 160 | + : sprintf( |
|
| 161 | + '<input type="checkbox" name="EVT_IDs[]" value="%s" />', |
|
| 162 | + $item->ID() |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * @param EE_Event $item |
|
| 170 | + * @return mixed|string |
|
| 171 | + * @throws EE_Error |
|
| 172 | + */ |
|
| 173 | + public function column_id(EE_Event $item) |
|
| 174 | + { |
|
| 175 | + $content = $item->ID(); |
|
| 176 | + $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
| 177 | + return $content; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * @param EE_Event $item |
|
| 184 | + * @return string |
|
| 185 | + * @throws EE_Error |
|
| 186 | + * @throws InvalidArgumentException |
|
| 187 | + * @throws InvalidDataTypeException |
|
| 188 | + * @throws InvalidInterfaceException |
|
| 189 | + */ |
|
| 190 | + public function column_name(EE_Event $item) |
|
| 191 | + { |
|
| 192 | + $edit_query_args = array( |
|
| 193 | + 'action' => 'edit', |
|
| 194 | + 'post' => $item->ID(), |
|
| 195 | + ); |
|
| 196 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 197 | + $actions = $this->_column_name_action_setup($item); |
|
| 198 | + $status = ''; //$item->status() !== 'publish' ? ' (' . $item->status() . ')' : ''; |
|
| 199 | + $content = '<strong><a class="row-title" href="' |
|
| 200 | + . $edit_link . '">' |
|
| 201 | + . $item->name() |
|
| 202 | + . '</a></strong>' |
|
| 203 | + . $status; |
|
| 204 | + $content .= '<br><span class="ee-status-text-small">' |
|
| 205 | + . EEH_Template::pretty_status( |
|
| 206 | + $item->get_active_status(), |
|
| 207 | + false, |
|
| 208 | + 'sentence' |
|
| 209 | + ) |
|
| 210 | + . '</span>'; |
|
| 211 | + $content .= $this->row_actions($actions); |
|
| 212 | + return $content; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * Just a method for setting up the actions for the name column |
|
| 219 | + * |
|
| 220 | + * @param EE_Event $item |
|
| 221 | + * @return array array of actions |
|
| 222 | + * @throws EE_Error |
|
| 223 | + * @throws InvalidArgumentException |
|
| 224 | + * @throws InvalidDataTypeException |
|
| 225 | + * @throws InvalidInterfaceException |
|
| 226 | + */ |
|
| 227 | + protected function _column_name_action_setup(EE_Event $item) |
|
| 228 | + { |
|
| 229 | + //todo: remove when attendees is active |
|
| 230 | + if (! defined('REG_ADMIN_URL')) { |
|
| 231 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 232 | + } |
|
| 233 | + $actions = array(); |
|
| 234 | + $restore_event_link = ''; |
|
| 235 | + $delete_event_link = ''; |
|
| 236 | + $trash_event_link = ''; |
|
| 237 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 238 | + 'ee_edit_event', |
|
| 239 | + 'espresso_events_edit', |
|
| 240 | + $item->ID() |
|
| 241 | + )) { |
|
| 242 | + $edit_query_args = array( |
|
| 243 | + 'action' => 'edit', |
|
| 244 | + 'post' => $item->ID(), |
|
| 245 | + ); |
|
| 246 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 247 | + $actions['edit'] = '<a href="' . $edit_link . '"' |
|
| 248 | + . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 249 | + . esc_html__('Edit', 'event_espresso') |
|
| 250 | + . '</a>'; |
|
| 251 | + } |
|
| 252 | + if ( |
|
| 253 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 254 | + 'ee_read_registrations', |
|
| 255 | + 'espresso_registrations_view_registration' |
|
| 256 | + ) |
|
| 257 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 258 | + 'ee_read_event', |
|
| 259 | + 'espresso_registrations_view_registration', |
|
| 260 | + $item->ID() |
|
| 261 | + ) |
|
| 262 | + ) { |
|
| 263 | + $attendees_query_args = array( |
|
| 264 | + 'action' => 'default', |
|
| 265 | + 'event_id' => $item->ID(), |
|
| 266 | + ); |
|
| 267 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 268 | + $actions['attendees'] = '<a href="' . $attendees_link . '"' |
|
| 269 | + . ' title="' . esc_attr__('View Registrations', 'event_espresso') . '">' |
|
| 270 | + . esc_html__('Registrations', 'event_espresso') |
|
| 271 | + . '</a>'; |
|
| 272 | + } |
|
| 273 | + if ( |
|
| 274 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 275 | + 'ee_delete_event', |
|
| 276 | + 'espresso_events_trash_event', |
|
| 277 | + $item->ID() |
|
| 278 | + ) |
|
| 279 | + ) { |
|
| 280 | + $trash_event_query_args = array( |
|
| 281 | + 'action' => 'trash_event', |
|
| 282 | + 'EVT_ID' => $item->ID(), |
|
| 283 | + ); |
|
| 284 | + $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 285 | + $trash_event_query_args, |
|
| 286 | + EVENTS_ADMIN_URL |
|
| 287 | + ); |
|
| 288 | + } |
|
| 289 | + if ( |
|
| 290 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 291 | + 'ee_delete_event', |
|
| 292 | + 'espresso_events_restore_event', |
|
| 293 | + $item->ID() |
|
| 294 | + ) |
|
| 295 | + ) { |
|
| 296 | + $restore_event_query_args = array( |
|
| 297 | + 'action' => 'restore_event', |
|
| 298 | + 'EVT_ID' => $item->ID(), |
|
| 299 | + ); |
|
| 300 | + $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 301 | + $restore_event_query_args, |
|
| 302 | + EVENTS_ADMIN_URL |
|
| 303 | + ); |
|
| 304 | + } |
|
| 305 | + if ( |
|
| 306 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 307 | + 'ee_delete_event', |
|
| 308 | + 'espresso_events_delete_event', |
|
| 309 | + $item->ID() |
|
| 310 | + ) |
|
| 311 | + ) { |
|
| 312 | + $delete_event_query_args = array( |
|
| 313 | + 'action' => 'delete_event', |
|
| 314 | + 'EVT_ID' => $item->ID(), |
|
| 315 | + ); |
|
| 316 | + $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 317 | + $delete_event_query_args, |
|
| 318 | + EVENTS_ADMIN_URL |
|
| 319 | + ); |
|
| 320 | + } |
|
| 321 | + $view_link = get_permalink($item->ID()); |
|
| 322 | + $actions['view'] = '<a href="' . $view_link . '"' |
|
| 323 | + . ' title="' . esc_attr__('View Event', 'event_espresso') . '">' |
|
| 324 | + . esc_html__('View', 'event_espresso') |
|
| 325 | + . '</a>'; |
|
| 326 | + if ($item->get('status') === 'trash') { |
|
| 327 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 328 | + 'ee_delete_event', |
|
| 329 | + 'espresso_events_restore_event', |
|
| 330 | + $item->ID() |
|
| 331 | + )) { |
|
| 332 | + $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"' |
|
| 333 | + . ' title="' . esc_attr__('Restore from Trash', 'event_espresso') |
|
| 334 | + . '">' |
|
| 335 | + . esc_html__('Restore from Trash', 'event_espresso') |
|
| 336 | + . '</a>'; |
|
| 337 | + } |
|
| 338 | + if ( |
|
| 339 | + $item->count_related('Registration') === 0 |
|
| 340 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 341 | + 'ee_delete_event', |
|
| 342 | + 'espresso_events_delete_event', |
|
| 343 | + $item->ID() |
|
| 344 | + ) |
|
| 345 | + ) { |
|
| 346 | + $actions['delete'] = '<a href="' . $delete_event_link . '"' |
|
| 347 | + . ' title="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' |
|
| 348 | + . esc_html__('Delete Permanently', 'event_espresso') |
|
| 349 | + . '</a>'; |
|
| 350 | + } |
|
| 351 | + } else { |
|
| 352 | + if ( |
|
| 353 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 354 | + 'ee_delete_event', |
|
| 355 | + 'espresso_events_trash_event', |
|
| 356 | + $item->ID() |
|
| 357 | + ) |
|
| 358 | + ) { |
|
| 359 | + $actions['move to trash'] = '<a href="' . $trash_event_link . '"' |
|
| 360 | + . ' title="' . esc_attr__('Trash Event', 'event_espresso') . '">' |
|
| 361 | + . esc_html__('Trash', 'event_espresso') |
|
| 362 | + . '</a>'; |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | + return $actions; |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * @param EE_Event $item |
|
| 372 | + * @return string |
|
| 373 | + * @throws EE_Error |
|
| 374 | + */ |
|
| 375 | + public function column_author(EE_Event $item) |
|
| 376 | + { |
|
| 377 | + //user author info |
|
| 378 | + $event_author = get_userdata($item->wp_user()); |
|
| 379 | + $gravatar = get_avatar($item->wp_user(), '15'); |
|
| 380 | + //filter link |
|
| 381 | + $query_args = array( |
|
| 382 | + 'action' => 'default', |
|
| 383 | + 'EVT_wp_user' => $item->wp_user(), |
|
| 384 | + ); |
|
| 385 | + $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
| 386 | + return $gravatar . ' <a href="' . $filter_url . '"' |
|
| 387 | + . ' title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
| 388 | + . $event_author->display_name |
|
| 389 | + . '</a>'; |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * @param EE_Event $item |
|
| 396 | + * @return string |
|
| 397 | + * @throws EE_Error |
|
| 398 | + */ |
|
| 399 | + public function column_venue(EE_Event $item) |
|
| 400 | + { |
|
| 401 | + $venue = $item->get_first_related('Venue'); |
|
| 402 | + return ! empty($venue) |
|
| 403 | + ? $venue->name() |
|
| 404 | + : ''; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * @param EE_Event $item |
|
| 410 | + * @return string |
|
| 411 | + * @throws EE_Error |
|
| 412 | + */ |
|
| 413 | + public function column_start_date_time(EE_Event $item) |
|
| 414 | + { |
|
| 415 | + return $this->_dtt instanceof EE_Datetime |
|
| 416 | + ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') |
|
| 417 | + : esc_html__('No Date was saved for this Event', 'event_espresso'); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * @param EE_Event $item |
|
| 423 | + * @return string |
|
| 424 | + * @throws EE_Error |
|
| 425 | + */ |
|
| 426 | + public function column_reg_begins(EE_Event $item) |
|
| 427 | + { |
|
| 428 | + $reg_start = $item->get_ticket_with_earliest_start_time(); |
|
| 429 | + return $reg_start instanceof EE_Ticket |
|
| 430 | + ? $reg_start->get_i18n_datetime('TKT_start_date') |
|
| 431 | + : esc_html__('No Tickets have been setup for this Event', 'event_espresso'); |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + |
|
| 435 | + |
|
| 436 | + /** |
|
| 437 | + * @param EE_Event $item |
|
| 438 | + * @return int|string |
|
| 439 | + * @throws EE_Error |
|
| 440 | + * @throws InvalidArgumentException |
|
| 441 | + * @throws InvalidDataTypeException |
|
| 442 | + * @throws InvalidInterfaceException |
|
| 443 | + */ |
|
| 444 | + public function column_attendees(EE_Event $item) |
|
| 445 | + { |
|
| 446 | + $attendees_query_args = array( |
|
| 447 | + 'action' => 'default', |
|
| 448 | + 'event_id' => $item->ID(), |
|
| 449 | + ); |
|
| 450 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 451 | + $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID()); |
|
| 452 | + return EE_Registry::instance()->CAP->current_user_can( |
|
| 453 | + 'ee_read_event', |
|
| 454 | + 'espresso_registrations_view_registration', |
|
| 455 | + $item->ID() |
|
| 456 | + ) |
|
| 457 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 458 | + 'ee_read_registrations', |
|
| 459 | + 'espresso_registrations_view_registration' |
|
| 460 | + ) |
|
| 461 | + ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
| 462 | + : $registered_attendees; |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * @param EE_Event $item |
|
| 469 | + * @return float |
|
| 470 | + * @throws EE_Error |
|
| 471 | + * @throws InvalidArgumentException |
|
| 472 | + * @throws InvalidDataTypeException |
|
| 473 | + * @throws InvalidInterfaceException |
|
| 474 | + */ |
|
| 475 | + public function column_tkts_sold(EE_Event $item) |
|
| 476 | + { |
|
| 477 | + return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold'); |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + |
|
| 481 | + |
|
| 482 | + /** |
|
| 483 | + * @param EE_Event $item |
|
| 484 | + * @return string |
|
| 485 | + * @throws EE_Error |
|
| 486 | + * @throws InvalidArgumentException |
|
| 487 | + * @throws InvalidDataTypeException |
|
| 488 | + * @throws InvalidInterfaceException |
|
| 489 | + */ |
|
| 490 | + public function column_actions(EE_Event $item) |
|
| 491 | + { |
|
| 492 | + //todo: remove when attendees is active |
|
| 493 | + if (! defined('REG_ADMIN_URL')) { |
|
| 494 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 495 | + } |
|
| 496 | + $action_links = array(); |
|
| 497 | + $view_link = get_permalink($item->ID()); |
|
| 498 | + $action_links[] = '<a href="' . $view_link . '"' |
|
| 499 | + . ' title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">'; |
|
| 500 | + $action_links[] = '<div class="dashicons dashicons-search"></div></a>'; |
|
| 501 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 502 | + 'ee_edit_event', |
|
| 503 | + 'espresso_events_edit', |
|
| 504 | + $item->ID() |
|
| 505 | + )) { |
|
| 506 | + $edit_query_args = array( |
|
| 507 | + 'action' => 'edit', |
|
| 508 | + 'post' => $item->ID(), |
|
| 509 | + ); |
|
| 510 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 511 | + $action_links[] = '<a href="' . $edit_link . '"' |
|
| 512 | + . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 513 | + . '<div class="ee-icon ee-icon-calendar-edit"></div>' |
|
| 514 | + . '</a>'; |
|
| 515 | + } |
|
| 516 | + if ( |
|
| 517 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 518 | + 'ee_read_registrations', |
|
| 519 | + 'espresso_registrations_view_registration' |
|
| 520 | + ) && EE_Registry::instance()->CAP->current_user_can( |
|
| 521 | + 'ee_read_event', |
|
| 522 | + 'espresso_registrations_view_registration', |
|
| 523 | + $item->ID() |
|
| 524 | + ) |
|
| 525 | + ) { |
|
| 526 | + $attendees_query_args = array( |
|
| 527 | + 'action' => 'default', |
|
| 528 | + 'event_id' => $item->ID(), |
|
| 529 | + ); |
|
| 530 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 531 | + $action_links[] = '<a href="' . $attendees_link . '"' |
|
| 532 | + . ' title="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
| 533 | + . '<div class="dashicons dashicons-groups"></div>' |
|
| 534 | + . '</a>'; |
|
| 535 | + } |
|
| 536 | + $action_links = apply_filters( |
|
| 537 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
| 538 | + $action_links, |
|
| 539 | + $item |
|
| 540 | + ); |
|
| 541 | + return $this->_action_string( |
|
| 542 | + implode("\n\t", $action_links), |
|
| 543 | + $item, |
|
| 544 | + 'div' |
|
| 545 | + ); |
|
| 546 | + } |
|
| 547 | 547 | } |