@@ -715,7 +715,7 @@ |
||
| 715 | 715 | } |
| 716 | 716 | } |
| 717 | 717 | } |
| 718 | - } |
|
| 718 | + } |
|
| 719 | 719 | /** |
| 720 | 720 | * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731 |
| 721 | 721 | * which should just be a temporary issue for folks who installed 4.8.0-4.8.5; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * @author Brent Christensen |
| 15 | 15 | * |
| 16 | 16 | */ |
| 17 | -class EE_DMS_4_9_0_Answers_With_No_Registration extends EE_Data_Migration_Script_Stage{ |
|
| 17 | +class EE_DMS_4_9_0_Answers_With_No_Registration extends EE_Data_Migration_Script_Stage { |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @return EE_DMS_4_9_0_Answers_With_No_Registration |
| 25 | 25 | */ |
| 26 | 26 | public function __construct() { |
| 27 | - $this->_pretty_name = __( 'Answer Cleanup', 'event_espresso' ); |
|
| 27 | + $this->_pretty_name = __('Answer Cleanup', 'event_espresso'); |
|
| 28 | 28 | parent::__construct(); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | protected function _migration_step($num_items_to_migrate = 50) { |
| 49 | 49 | global $wpdb; |
| 50 | 50 | $wpdb->delete( |
| 51 | - $wpdb->prefix . 'esp_answer', |
|
| 52 | - array( 'REG_ID' => 0 ), |
|
| 53 | - array( '%d' ) |
|
| 51 | + $wpdb->prefix.'esp_answer', |
|
| 52 | + array('REG_ID' => 0), |
|
| 53 | + array('%d') |
|
| 54 | 54 | ); |
| 55 | 55 | $this->set_completed(); |
| 56 | 56 | return 1; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @return EED_Core_Rest_Api |
| 28 | 28 | */ |
| 29 | 29 | public static function instance() { |
| 30 | - return parent::get_instance( __CLASS__ ); |
|
| 30 | + return parent::get_instance(__CLASS__); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | public static function set_hooks_both() { |
| 60 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
| 61 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
| 62 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
| 63 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
| 60 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
| 61 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
| 62 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
| 63 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
| 64 | 64 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | protected static function _set_hooks_for_changes() { |
| 77 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
| 78 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
| 77 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
| 78 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
| 79 | 79 | //ignore the base parent class |
| 80 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
| 80 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
| 81 | 81 | continue; |
| 82 | 82 | } |
| 83 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
| 84 | - if ( class_exists( $full_classname )) { |
|
| 83 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
| 84 | + if (class_exists($full_classname)) { |
|
| 85 | 85 | $instance_of_class = new $full_classname; |
| 86 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
| 86 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
| 87 | 87 | $instance_of_class->set_hooks(); |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -96,16 +96,16 @@ discard block |
||
| 96 | 96 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
| 97 | 97 | */ |
| 98 | 98 | public static function register_routes() { |
| 99 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
| 100 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
| 101 | - foreach( $routes as $route ) { |
|
| 99 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
| 100 | + foreach ($relative_urls as $endpoint => $routes) { |
|
| 101 | + foreach ($routes as $route) { |
|
| 102 | 102 | register_rest_route( |
| 103 | 103 | $namespace, |
| 104 | 104 | $endpoint, |
| 105 | 105 | array( |
| 106 | - 'callback' => $route[ 'callback' ], |
|
| 107 | - 'methods' => $route[ 'methods' ], |
|
| 108 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
| 106 | + 'callback' => $route['callback'], |
|
| 107 | + 'methods' => $route['methods'], |
|
| 108 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
| 109 | 109 | ) |
| 110 | 110 | ); |
| 111 | 111 | } |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | * next time the WP API is used |
| 120 | 120 | */ |
| 121 | 121 | public static function invalidate_cached_route_data_on_version_change() { |
| 122 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
| 122 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
| 123 | 123 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
| 124 | 124 | } |
| 125 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
| 126 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
| 125 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
| 126 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
| 127 | 127 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public static function invalidate_cached_route_data() { |
| 136 | 136 | //delete the saved EE REST API routes |
| 137 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names ); |
|
| 137 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | * } |
| 147 | 147 | */ |
| 148 | 148 | public static function get_ee_route_data() { |
| 149 | - $ee_routes = get_option( self::saved_routes_option_names, null ); |
|
| 150 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
| 149 | + $ee_routes = get_option(self::saved_routes_option_names, null); |
|
| 150 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
| 151 | 151 | self::save_ee_routes(); |
| 152 | - $ee_routes = get_option( self::saved_routes_option_names, array() ); |
|
| 152 | + $ee_routes = get_option(self::saved_routes_option_names, array()); |
|
| 153 | 153 | } |
| 154 | 154 | return $ee_routes; |
| 155 | 155 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * @return void |
| 161 | 161 | */ |
| 162 | 162 | public static function save_ee_routes() { |
| 163 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
| 163 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 164 | 164 | $instance = self::instance(); |
| 165 | 165 | $routes = apply_filters( |
| 166 | 166 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $instance->_register_rpc_routes() |
| 172 | 172 | ) |
| 173 | 173 | ); |
| 174 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
| 174 | + update_option(self::saved_routes_option_names, $routes, true); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @return array @see get_ee_route_data |
| 181 | 181 | */ |
| 182 | 182 | protected function _register_model_routes() { |
| 183 | - EE_Registry::instance()->load_helper( 'Inflector' ); |
|
| 183 | + EE_Registry::instance()->load_helper('Inflector'); |
|
| 184 | 184 | $models_to_register = apply_filters( |
| 185 | 185 | 'FHEE__EED_Core_REST_API___register_model_routes', |
| 186 | 186 | EE_Registry::instance()->non_abstract_db_models |
@@ -189,23 +189,23 @@ discard block |
||
| 189 | 189 | unset($models_to_register['Extra_Meta']); |
| 190 | 190 | unset($models_to_register['Extra_Join']); |
| 191 | 191 | $model_routes = array( ); |
| 192 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
| 192 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
| 193 | 193 | |
| 194 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
| 194 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
| 195 | 195 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
| 196 | - $ee_namespace = self::ee_api_namespace . $version; |
|
| 197 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
| 198 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
| 199 | - $model_routes[ $ee_namespace ][ $plural_model_route ] = array( |
|
| 196 | + $ee_namespace = self::ee_api_namespace.$version; |
|
| 197 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
| 198 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
| 199 | + $model_routes[$ee_namespace][$plural_model_route] = array( |
|
| 200 | 200 | array( |
| 201 | 201 | 'callback' => array( |
| 202 | 202 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
| 203 | 203 | 'handle_request_get_all' ), |
| 204 | 204 | 'methods' => WP_REST_Server::READABLE, |
| 205 | 205 | 'hidden_endpoint' => $hidden_endpoint, |
| 206 | - 'args' => $this->_get_read_query_params( $model_name ), |
|
| 206 | + 'args' => $this->_get_read_query_params($model_name), |
|
| 207 | 207 | '_links' => array( |
| 208 | - 'self' => rest_url( $ee_namespace . $singular_model_route ), |
|
| 208 | + 'self' => rest_url($ee_namespace.$singular_model_route), |
|
| 209 | 209 | ) |
| 210 | 210 | ), |
| 211 | 211 | // array( |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | // 'hidden_endpoint' => $hidden_endpoint |
| 217 | 217 | // ) |
| 218 | 218 | ); |
| 219 | - $model_routes[ $ee_namespace ][ $singular_model_route ] = array( |
|
| 219 | + $model_routes[$ee_namespace][$singular_model_route] = array( |
|
| 220 | 220 | array( |
| 221 | 221 | 'callback' => array( |
| 222 | 222 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | 'include' => array( |
| 228 | 228 | 'required' => false, |
| 229 | 229 | 'default' => '*', |
| 230 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
| 230 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
| 231 | 231 | ), |
| 232 | 232 | ) |
| 233 | 233 | ), |
@@ -240,20 +240,20 @@ discard block |
||
| 240 | 240 | // ), |
| 241 | 241 | ); |
| 242 | 242 | //@todo: also handle DELETE for a single item |
| 243 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
| 244 | - foreach ( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
| 243 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
| 244 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
| 245 | 245 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
| 246 | 246 | $relation_name, |
| 247 | 247 | $relation_obj |
| 248 | 248 | ); |
| 249 | - $model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
| 249 | + $model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
| 250 | 250 | array( |
| 251 | 251 | 'callback' => array( |
| 252 | 252 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
| 253 | 253 | 'handle_request_get_related' ), |
| 254 | 254 | 'methods' => WP_REST_Server::READABLE, |
| 255 | 255 | 'hidden_endpoint' => $hidden_endpoint, |
| 256 | - 'args' => $this->_get_read_query_params( $relation_name ), |
|
| 256 | + 'args' => $this->_get_read_query_params($relation_name), |
|
| 257 | 257 | ), |
| 258 | 258 | // array( |
| 259 | 259 | // 'callback' => array( |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | protected function _register_rpc_routes() { |
| 279 | 279 | $routes = array(); |
| 280 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
| 281 | - $ee_namespace = self::ee_api_namespace . $version; |
|
| 280 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
| 281 | + $ee_namespace = self::ee_api_namespace.$version; |
|
| 282 | 282 | $this_versions_routes = array(); |
| 283 | 283 | //checkin endpoint |
| 284 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
| 284 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
| 285 | 285 | array( |
| 286 | 286 | 'callback' => array( |
| 287 | 287 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -292,12 +292,12 @@ discard block |
||
| 292 | 292 | 'force' => array( |
| 293 | 293 | 'required' => false, |
| 294 | 294 | 'default' => false, |
| 295 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
| 295 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
| 296 | 296 | ) |
| 297 | 297 | ) |
| 298 | 298 | ) |
| 299 | 299 | ); |
| 300 | - $routes[ $ee_namespace ] = apply_filters( |
|
| 300 | + $routes[$ee_namespace] = apply_filters( |
|
| 301 | 301 | 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
| 302 | 302 | $this_versions_routes, |
| 303 | 303 | $version, |
@@ -312,47 +312,47 @@ discard block |
||
| 312 | 312 | * @param string $model_name eg 'Event' or 'Venue' |
| 313 | 313 | * @return array describing the args acceptable when querying this model |
| 314 | 314 | */ |
| 315 | - protected function _get_read_query_params( $model_name ) { |
|
| 316 | - $model = EE_Registry::instance()->load_model( $model_name ); |
|
| 315 | + protected function _get_read_query_params($model_name) { |
|
| 316 | + $model = EE_Registry::instance()->load_model($model_name); |
|
| 317 | 317 | $default_orderby = array(); |
| 318 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
| 319 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
| 318 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
| 319 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
| 320 | 320 | } |
| 321 | 321 | return array( |
| 322 | 322 | 'where' => array( |
| 323 | 323 | 'required' => false, |
| 324 | 324 | 'default' => array(), |
| 325 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso' ), |
|
| 325 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso'), |
|
| 326 | 326 | ), |
| 327 | 327 | 'limit' => array( |
| 328 | 328 | 'required' => false, |
| 329 | 329 | 'default' => 50, |
| 330 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso' ) |
|
| 330 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso') |
|
| 331 | 331 | ), |
| 332 | 332 | 'order_by' => array( |
| 333 | 333 | 'required' => false, |
| 334 | 334 | 'default' => $default_orderby, |
| 335 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso' ) |
|
| 335 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso') |
|
| 336 | 336 | ), |
| 337 | 337 | 'group_by' => array( |
| 338 | 338 | 'required' => false, |
| 339 | 339 | 'default' => null, |
| 340 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso' ) |
|
| 340 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso') |
|
| 341 | 341 | ), |
| 342 | 342 | 'having' => array( |
| 343 | 343 | 'required' => false, |
| 344 | 344 | 'default' => null, |
| 345 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso' ) |
|
| 345 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso') |
|
| 346 | 346 | ), |
| 347 | 347 | 'caps' => array( |
| 348 | 348 | 'required' => false, |
| 349 | 349 | 'default' => EEM_Base::caps_read, |
| 350 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso' ) |
|
| 350 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso') |
|
| 351 | 351 | ), |
| 352 | 352 | 'include' => array( |
| 353 | 353 | 'required' => false, |
| 354 | 354 | 'default' => '*', |
| 355 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
| 355 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
| 356 | 356 | ), |
| 357 | 357 | ); |
| 358 | 358 | } |
@@ -363,8 +363,8 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | protected function _register_config_routes() { |
| 365 | 365 | $config_routes = array(); |
| 366 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
| 367 | - $config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array( |
|
| 366 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
| 367 | + $config_routes[self::ee_api_namespace.$version]['config'] = array( |
|
| 368 | 368 | array( |
| 369 | 369 | 'callback' => array( |
| 370 | 370 | 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
@@ -383,8 +383,8 @@ discard block |
||
| 383 | 383 | */ |
| 384 | 384 | protected function _register_meta_routes() { |
| 385 | 385 | $meta_routes = array(); |
| 386 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
| 387 | - $meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array( |
|
| 386 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
| 387 | + $meta_routes[self::ee_api_namespace.$version]['/resources'] = array( |
|
| 388 | 388 | array( |
| 389 | 389 | 'callback' => array( |
| 390 | 390 | 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
@@ -405,13 +405,13 @@ discard block |
||
| 405 | 405 | * @param array $route_data |
| 406 | 406 | * @return array |
| 407 | 407 | */ |
| 408 | - public static function hide_old_endpoints( $route_data ) { |
|
| 409 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
| 410 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
| 411 | - foreach( $routes as $route ) { |
|
| 412 | - if( $route[ 'hidden_endpoint' ] ) { |
|
| 413 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
| 414 | - unset( $route_data[ $full_route ] ); |
|
| 408 | + public static function hide_old_endpoints($route_data) { |
|
| 409 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
| 410 | + foreach ($relative_urls as $endpoint => $routes) { |
|
| 411 | + foreach ($routes as $route) { |
|
| 412 | + if ($route['hidden_endpoint']) { |
|
| 413 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
| 414 | + unset($route_data[$full_route]); |
|
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | } |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | */ |
| 449 | 449 | public static function latest_rest_api_version() { |
| 450 | 450 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
| 451 | - return end( array_keys( $versions_served ) ); |
|
| 451 | + return end(array_keys($versions_served)); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -462,32 +462,32 @@ discard block |
||
| 462 | 462 | public static function versions_served() { |
| 463 | 463 | $versions_served = array(); |
| 464 | 464 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
| 465 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
| 466 | - reset( $possibly_served_versions ); |
|
| 467 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
| 468 | - $latest_version = end( $versions_served_historically ); |
|
| 469 | - reset( $versions_served_historically ); |
|
| 465 | + $lowest_compatible_version = end($possibly_served_versions); |
|
| 466 | + reset($possibly_served_versions); |
|
| 467 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
| 468 | + $latest_version = end($versions_served_historically); |
|
| 469 | + reset($versions_served_historically); |
|
| 470 | 470 | //for each version of core we have ever served: |
| 471 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
| 471 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
| 472 | 472 | //if it's not above the current core version, and it's compatible with the current version of core |
| 473 | - if( $key_versioned_endpoint == $latest_version ) { |
|
| 473 | + if ($key_versioned_endpoint == $latest_version) { |
|
| 474 | 474 | //don't hide the latest version in the index |
| 475 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
| 476 | - } else if( |
|
| 475 | + $versions_served[$key_versioned_endpoint] = false; |
|
| 476 | + } else if ( |
|
| 477 | 477 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
| 478 | 478 | && $key_versioned_endpoint >= $lowest_compatible_version |
| 479 | 479 | ) { |
| 480 | 480 | //include, but hide, previous versions which are still supported |
| 481 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
| 482 | - } elseif( |
|
| 481 | + $versions_served[$key_versioned_endpoint] = true; |
|
| 482 | + } elseif ( |
|
| 483 | 483 | apply_filters( |
| 484 | 484 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
| 485 | 485 | false, |
| 486 | 486 | $possibly_served_versions |
| 487 | 487 | ) |
| 488 | - ){ |
|
| 488 | + ) { |
|
| 489 | 489 | //if a version is no longer supported, don't include it in index or list of versions served |
| 490 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
| 490 | + $versions_served[$key_versioned_endpoint] = true; |
|
| 491 | 491 | } |
| 492 | 492 | } |
| 493 | 493 | return $versions_served; |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | * @return string |
| 501 | 501 | */ |
| 502 | 502 | public static function core_version() { |
| 503 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
| 503 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | * @param WP $WP |
| 513 | 513 | * @return void |
| 514 | 514 | */ |
| 515 | - public function run( $WP ) { |
|
| 515 | + public function run($WP) { |
|
| 516 | 516 | |
| 517 | 517 | } |
| 518 | 518 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 3 | 3 | exit('NO direct script access allowed'); |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | class Event_Categories_Admin_List_Table extends EE_Admin_List_Table { |
| 33 | 33 | |
| 34 | - public function __construct( $admin_page ) { |
|
| 34 | + public function __construct($admin_page) { |
|
| 35 | 35 | parent::__construct($admin_page); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | protected function _setup_data() { |
| 42 | - $this->_data = $this->_admin_page->get_categories( $this->_per_page, $this->_current_page); |
|
| 43 | - $this->_all_data_count = EEM_Term_Taxonomy::instance()->count( array( array( 'taxonomy' => 'espresso_event_categories' ) ) ); |
|
| 42 | + $this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page); |
|
| 43 | + $this->_all_data_count = EEM_Term_Taxonomy::instance()->count(array(array('taxonomy' => 'espresso_event_categories'))); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | protected function _set_properties() { |
| 51 | 51 | $this->_wp_list_args = array( |
| 52 | - 'singular' => __('event category', 'event_espresso' ), |
|
| 53 | - 'plural' => __('event categories', 'event_espresso' ), |
|
| 52 | + 'singular' => __('event category', 'event_espresso'), |
|
| 53 | + 'plural' => __('event categories', 'event_espresso'), |
|
| 54 | 54 | 'ajax' => TRUE, //for now, |
| 55 | 55 | 'screen' => $this->_admin_page->get_current_screen()->id |
| 56 | 56 | ); |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | $this->_sortable_columns = array( |
| 67 | - 'id' => array( 'Term.term_id' => true ), |
|
| 68 | - 'name' => array( 'Term.slug' => false ), |
|
| 69 | - 'count' => array( 'term_count' => false ) |
|
| 67 | + 'id' => array('Term.term_id' => true), |
|
| 68 | + 'name' => array('Term.slug' => false), |
|
| 69 | + 'count' => array('term_count' => false) |
|
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | 72 | $this->_primary_column = 'id'; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | |
| 100 | 100 | public function column_cb($item) { |
| 101 | - return sprintf( '<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id') ); |
|
| 101 | + return sprintf('<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id')); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | public function column_id($item) { |
| 109 | 109 | $content = $item->get('term_id'); |
| 110 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get('name') . '</span>'; |
|
| 110 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->get_first_related('Term')->get('name').'</span>'; |
|
| 111 | 111 | return $content; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -127,17 +127,17 @@ discard block |
||
| 127 | 127 | 'EVT_CAT_ID' => $item->get('term_id') |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL ); |
|
| 131 | - $delete_link = EE_Admin_Page::add_query_args_and_nonce( $delete_query_args, EVENTS_ADMIN_URL ); |
|
| 130 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 131 | + $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EVENTS_ADMIN_URL); |
|
| 132 | 132 | |
| 133 | 133 | $actions = array( |
| 134 | - 'edit' => '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Category', 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>' |
|
| 134 | + 'edit' => '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Category', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>' |
|
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | 137 | |
| 138 | - $actions['delete'] = '<a href="' . $delete_link . '" title="' . esc_attr__('Delete Category', 'event_espresso') . '">' . __('Delete', 'event_espresso') . '</a>'; |
|
| 138 | + $actions['delete'] = '<a href="'.$delete_link.'" title="'.esc_attr__('Delete Category', 'event_espresso').'">'.__('Delete', 'event_espresso').'</a>'; |
|
| 139 | 139 | |
| 140 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->get_first_related('Term')->get('name') . '</a></strong>'; |
|
| 140 | + $content = '<strong><a class="row-title" href="'.$edit_link.'">'.$item->get_first_related('Term')->get('name').'</a></strong>'; |
|
| 141 | 141 | $content .= $this->row_actions($actions); |
| 142 | 142 | return $content; |
| 143 | 143 | } |
@@ -146,20 +146,20 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | |
| 148 | 148 | public function column_shortcode($item) { |
| 149 | - $content = '[ESPRESSO_EVENTS category_slug=' . $item->get_first_related('Term')->get('slug') . ']'; |
|
| 149 | + $content = '[ESPRESSO_EVENTS category_slug='.$item->get_first_related('Term')->get('slug').']'; |
|
| 150 | 150 | return $content; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
| 154 | 154 | |
| 155 | 155 | |
| 156 | - public function column_count( $item ) { |
|
| 156 | + public function column_count($item) { |
|
| 157 | 157 | $e_args = array( |
| 158 | 158 | 'action' => 'default', |
| 159 | 159 | 'EVT_CAT' => $item->get_first_related('Term')->ID() |
| 160 | 160 | ); |
| 161 | - $e_link = EE_Admin_Page::add_query_args_and_nonce( $e_args, EVENTS_ADMIN_URL ); |
|
| 162 | - $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
| 161 | + $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EVENTS_ADMIN_URL); |
|
| 162 | + $content = '<a href="'.$e_link.'">'.$item->get('term_count').'</a>'; |
|
| 163 | 163 | return $content; |
| 164 | 164 | } |
| 165 | 165 | } |
@@ -1,26 +1,26 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
| 2 | 2 | /** |
| 3 | - * Event Espresso |
|
| 4 | - * |
|
| 5 | - * Event Registration and Management Plugin for WordPress |
|
| 6 | - * |
|
| 7 | - * @ package Event Espresso |
|
| 8 | - * @ author Seth Shoultes |
|
| 9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
| 10 | - * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
| 11 | - * @ link {@link http://www.eventespresso.com} |
|
| 12 | - * @ since 4.0 |
|
| 13 | - * |
|
| 14 | - * ------------------------------------------------------------------------ |
|
| 15 | - * |
|
| 16 | - * Registrations_Admin_Page class |
|
| 17 | - * |
|
| 18 | - * @package Event Espresso |
|
| 19 | - * @subpackage includes/core/admin/transactions/Registrations_Admin_Page.core.php |
|
| 20 | - * @author Brent Christensen |
|
| 21 | - * |
|
| 22 | - * ------------------------------------------------------------------------ |
|
| 23 | - */ |
|
| 3 | + * Event Espresso |
|
| 4 | + * |
|
| 5 | + * Event Registration and Management Plugin for WordPress |
|
| 6 | + * |
|
| 7 | + * @ package Event Espresso |
|
| 8 | + * @ author Seth Shoultes |
|
| 9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
| 10 | + * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
| 11 | + * @ link {@link http://www.eventespresso.com} |
|
| 12 | + * @ since 4.0 |
|
| 13 | + * |
|
| 14 | + * ------------------------------------------------------------------------ |
|
| 15 | + * |
|
| 16 | + * Registrations_Admin_Page class |
|
| 17 | + * |
|
| 18 | + * @package Event Espresso |
|
| 19 | + * @subpackage includes/core/admin/transactions/Registrations_Admin_Page.core.php |
|
| 20 | + * @author Brent Christensen |
|
| 21 | + * |
|
| 22 | + * ------------------------------------------------------------------------ |
|
| 23 | + */ |
|
| 24 | 24 | class Registrations_Admin_Page extends EE_Admin_Page_CPT { |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * grab url requests and route them |
| 166 | - * @access private |
|
| 167 | - * @return void |
|
| 168 | - */ |
|
| 166 | + * @access private |
|
| 167 | + * @return void |
|
| 168 | + */ |
|
| 169 | 169 | public function _set_page_routes() { |
| 170 | 170 | |
| 171 | 171 | $this->_get_registration_status_array(); |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | 'title' => __('Registrations Other', 'event_espresso'), |
| 437 | 437 | 'filename' => 'registrations_overview_other' |
| 438 | 438 | ) |
| 439 | - ), |
|
| 439 | + ), |
|
| 440 | 440 | 'help_tour' => array( 'Registration_Overview_Help_Tour' ), |
| 441 | 441 | 'qtips' => array('Registration_List_Table_Tips'), |
| 442 | 442 | 'list_table' => 'EE_Registrations_List_Table', |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | 'url' => isset($this->_req_data['_REG_ID']) ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url, |
| 451 | 451 | 'persistent' => FALSE |
| 452 | 452 | ), |
| 453 | - 'help_tabs' => array( |
|
| 453 | + 'help_tabs' => array( |
|
| 454 | 454 | 'registrations_details_help_tab' => array( |
| 455 | 455 | 'title' => __('Registration Details', 'event_espresso'), |
| 456 | 456 | 'filename' => 'registrations_details' |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | 'order' => 20 |
| 515 | 515 | ), |
| 516 | 516 | 'list_table' => 'EE_Attendee_Contact_List_Table', |
| 517 | - 'help_tabs' => array( |
|
| 517 | + 'help_tabs' => array( |
|
| 518 | 518 | 'registrations_contact_list_help_tab' => array( |
| 519 | 519 | 'title' => __('Registrations Contact List', 'event_espresso'), |
| 520 | 520 | 'filename' => 'registrations_contact_list' |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | 'title' => __('Contact List Other', 'event_espresso'), |
| 532 | 532 | 'filename' => 'registrations_contact_list_other' |
| 533 | 533 | ) |
| 534 | - ), |
|
| 534 | + ), |
|
| 535 | 535 | 'help_tour' => array( 'Contact_List_Help_Tour' ), |
| 536 | 536 | 'metaboxes' => array(), |
| 537 | 537 | 'require_nonce' => FALSE |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | /** |
| 567 | 567 | * get list of registration statuses |
| 568 | - * @access private |
|
| 569 | - * @return void |
|
| 570 | - */ |
|
| 568 | + * @access private |
|
| 569 | + * @return void |
|
| 570 | + */ |
|
| 571 | 571 | private function _get_registration_status_array() { |
| 572 | 572 | self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE); |
| 573 | 573 | } |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | return TRUE; |
| 875 | 875 | } |
| 876 | 876 | |
| 877 | - $REG = EEM_Registration::instance(); |
|
| 877 | + $REG = EEM_Registration::instance(); |
|
| 878 | 878 | |
| 879 | 879 | $REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
| 880 | 880 | |
@@ -1097,9 +1097,9 @@ discard block |
||
| 1097 | 1097 | |
| 1098 | 1098 | /** |
| 1099 | 1099 | * generates HTML for the View Registration Details Admin page |
| 1100 | - * @access protected |
|
| 1101 | - * @return void |
|
| 1102 | - */ |
|
| 1100 | + * @access protected |
|
| 1101 | + * @return void |
|
| 1102 | + */ |
|
| 1103 | 1103 | protected function _registration_details() { |
| 1104 | 1104 | |
| 1105 | 1105 | $this->_template_args = array(); |
@@ -1177,9 +1177,9 @@ discard block |
||
| 1177 | 1177 | |
| 1178 | 1178 | /** |
| 1179 | 1179 | * _set_approve_or_decline_reg_status_buttons |
| 1180 | - * @access protected |
|
| 1181 | - * @return string |
|
| 1182 | - */ |
|
| 1180 | + * @access protected |
|
| 1181 | + * @return string |
|
| 1182 | + */ |
|
| 1183 | 1183 | public function set_reg_status_buttons_metabox() { |
| 1184 | 1184 | |
| 1185 | 1185 | //is registration for free event OR for a completed transaction? This will determine whether the set to pending option is shown. |
@@ -1368,10 +1368,10 @@ discard block |
||
| 1368 | 1368 | |
| 1369 | 1369 | /** |
| 1370 | 1370 | * approve_registration |
| 1371 | - * @access protected |
|
| 1372 | - * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1373 | - * @return void |
|
| 1374 | - */ |
|
| 1371 | + * @access protected |
|
| 1372 | + * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1373 | + * @return void |
|
| 1374 | + */ |
|
| 1375 | 1375 | protected function approve_registration( $notify = false ) { |
| 1376 | 1376 | $this->_reg_status_change_return( EEM_Registration::status_id_approved, $notify ); |
| 1377 | 1377 | } |
@@ -1381,10 +1381,10 @@ discard block |
||
| 1381 | 1381 | |
| 1382 | 1382 | /** |
| 1383 | 1383 | * decline_registration |
| 1384 | - * @access protected |
|
| 1385 | - * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1386 | - * @return void |
|
| 1387 | - */ |
|
| 1384 | + * @access protected |
|
| 1385 | + * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1386 | + * @return void |
|
| 1387 | + */ |
|
| 1388 | 1388 | protected function decline_registration( $notify = false ) { |
| 1389 | 1389 | $this->_reg_status_change_return( EEM_Registration::status_id_declined, $notify ); |
| 1390 | 1390 | } |
@@ -1394,10 +1394,10 @@ discard block |
||
| 1394 | 1394 | |
| 1395 | 1395 | /** |
| 1396 | 1396 | * cancel_registration |
| 1397 | - * @access protected |
|
| 1398 | - * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1399 | - * @return void |
|
| 1400 | - */ |
|
| 1397 | + * @access protected |
|
| 1398 | + * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1399 | + * @return void |
|
| 1400 | + */ |
|
| 1401 | 1401 | protected function cancel_registration( $notify = false ) { |
| 1402 | 1402 | $this->_reg_status_change_return( EEM_Registration::status_id_cancelled, $notify ); |
| 1403 | 1403 | } |
@@ -1408,10 +1408,10 @@ discard block |
||
| 1408 | 1408 | |
| 1409 | 1409 | /** |
| 1410 | 1410 | * not_approve_registration |
| 1411 | - * @access protected |
|
| 1412 | - * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1413 | - * @return void |
|
| 1414 | - */ |
|
| 1411 | + * @access protected |
|
| 1412 | + * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1413 | + * @return void |
|
| 1414 | + */ |
|
| 1415 | 1415 | protected function not_approve_registration( $notify = false ) { |
| 1416 | 1416 | $this->_reg_status_change_return( EEM_Registration::status_id_not_approved, $notify ); |
| 1417 | 1417 | } |
@@ -1420,10 +1420,10 @@ discard block |
||
| 1420 | 1420 | |
| 1421 | 1421 | /** |
| 1422 | 1422 | * decline_registration |
| 1423 | - * @access protected |
|
| 1424 | - * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1425 | - * @return void |
|
| 1426 | - */ |
|
| 1423 | + * @access protected |
|
| 1424 | + * @param bool $notify whether or not to notify the registrant about their approval. |
|
| 1425 | + * @return void |
|
| 1426 | + */ |
|
| 1427 | 1427 | protected function pending_registration( $notify = false ) { |
| 1428 | 1428 | $this->_reg_status_change_return( EEM_Registration::status_id_pending_payment, $notify ); |
| 1429 | 1429 | } |
@@ -1433,9 +1433,9 @@ discard block |
||
| 1433 | 1433 | |
| 1434 | 1434 | /** |
| 1435 | 1435 | * generates HTML for the Registration main meta box |
| 1436 | - * @access public |
|
| 1437 | - * @return void |
|
| 1438 | - */ |
|
| 1436 | + * @access public |
|
| 1437 | + * @return void |
|
| 1438 | + */ |
|
| 1439 | 1439 | public function _reg_details_meta_box() { |
| 1440 | 1440 | EEH_Autoloader::register_line_item_display_autoloaders(); |
| 1441 | 1441 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
@@ -1518,7 +1518,7 @@ discard block |
||
| 1518 | 1518 | * |
| 1519 | 1519 | * @access public |
| 1520 | 1520 | * @return void |
| 1521 | - */ |
|
| 1521 | + */ |
|
| 1522 | 1522 | public function _reg_questions_meta_box() { |
| 1523 | 1523 | //allow someone to override this method entirely |
| 1524 | 1524 | if( apply_filters( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration ) ) { |
@@ -1720,12 +1720,12 @@ discard block |
||
| 1720 | 1720 | |
| 1721 | 1721 | /** |
| 1722 | 1722 | * generates HTML for the Registration main meta box |
| 1723 | - * @access public |
|
| 1724 | - * @return void |
|
| 1725 | - */ |
|
| 1723 | + * @access public |
|
| 1724 | + * @return void |
|
| 1725 | + */ |
|
| 1726 | 1726 | public function _reg_attendees_meta_box() { |
| 1727 | 1727 | |
| 1728 | - $REG = EEM_Registration::instance(); |
|
| 1728 | + $REG = EEM_Registration::instance(); |
|
| 1729 | 1729 | //get all other registrations on this transaction, and cache |
| 1730 | 1730 | //the attendees for them so we don't have to run another query using force_join |
| 1731 | 1731 | $registrations = $REG->get_all(array( |
@@ -1778,9 +1778,9 @@ discard block |
||
| 1778 | 1778 | |
| 1779 | 1779 | /** |
| 1780 | 1780 | * generates HTML for the Edit Registration side meta box |
| 1781 | - * @access public |
|
| 1782 | - * @return void |
|
| 1783 | - */ |
|
| 1781 | + * @access public |
|
| 1782 | + * @return void |
|
| 1783 | + */ |
|
| 1784 | 1784 | public function _reg_registrant_side_meta_box() { |
| 1785 | 1785 | |
| 1786 | 1786 | /*@var $attendee EE_Attendee */ |
@@ -2159,9 +2159,9 @@ discard block |
||
| 2159 | 2159 | |
| 2160 | 2160 | /** |
| 2161 | 2161 | * set_reg_event |
| 2162 | - * @access private |
|
| 2163 | - * @return boolean |
|
| 2164 | - */ |
|
| 2162 | + * @access private |
|
| 2163 | + * @return boolean |
|
| 2164 | + */ |
|
| 2165 | 2165 | private function _set_reg_event() { |
| 2166 | 2166 | if ( is_object( $this->_reg_event )) { |
| 2167 | 2167 | return TRUE; |
@@ -2301,9 +2301,9 @@ discard block |
||
| 2301 | 2301 | |
| 2302 | 2302 | /** |
| 2303 | 2303 | * generates HTML for the Attendee Contact List |
| 2304 | - * @access protected |
|
| 2305 | - * @return void |
|
| 2306 | - */ |
|
| 2304 | + * @access protected |
|
| 2305 | + * @return void |
|
| 2306 | + */ |
|
| 2307 | 2307 | protected function _attendee_contact_list_table() { |
| 2308 | 2308 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
| 2309 | 2309 | $this->_search_btn_label = __('Contacts', 'event_espresso'); |
@@ -2317,9 +2317,9 @@ discard block |
||
| 2317 | 2317 | /** |
| 2318 | 2318 | * get_attendees |
| 2319 | 2319 | * @param bool $count whether to return count or data. |
| 2320 | - * @access public |
|
| 2321 | - * @return array |
|
| 2322 | - */ |
|
| 2320 | + * @access public |
|
| 2321 | + * @return array |
|
| 2322 | + */ |
|
| 2323 | 2323 | public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) { |
| 2324 | 2324 | |
| 2325 | 2325 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -2655,9 +2655,9 @@ discard block |
||
| 2655 | 2655 | |
| 2656 | 2656 | /** |
| 2657 | 2657 | * _attendee_details |
| 2658 | - * @access protected |
|
| 2659 | - * @return void |
|
| 2660 | - */ |
|
| 2658 | + * @access protected |
|
| 2659 | + * @return void |
|
| 2660 | + */ |
|
| 2661 | 2661 | public function attendee_registrations_meta_box( $post ) { |
| 2662 | 2662 | |
| 2663 | 2663 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
@@ -2690,10 +2690,10 @@ discard block |
||
| 2690 | 2690 | |
| 2691 | 2691 | /** |
| 2692 | 2692 | * _trash_or_restore_attendee |
| 2693 | - * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 2694 | - * @access protected |
|
| 2695 | - * @return void |
|
| 2696 | - */ |
|
| 2693 | + * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
| 2694 | + * @access protected |
|
| 2695 | + * @return void |
|
| 2696 | + */ |
|
| 2697 | 2697 | protected function _trash_or_restore_attendees( $trash = TRUE ) { |
| 2698 | 2698 | |
| 2699 | 2699 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -92,42 +92,42 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return EEM_Message |
| 94 | 94 | */ |
| 95 | - protected function __construct( $timezone = null ) { |
|
| 96 | - $this->singular_item = __('Message','event_espresso'); |
|
| 97 | - $this->plural_item = __('Messages','event_espresso'); |
|
| 95 | + protected function __construct($timezone = null) { |
|
| 96 | + $this->singular_item = __('Message', 'event_espresso'); |
|
| 97 | + $this->plural_item = __('Messages', 'event_espresso'); |
|
| 98 | 98 | |
| 99 | 99 | //used for token generator |
| 100 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
| 100 | + EE_Registry::instance()->load_helper('URL'); |
|
| 101 | 101 | |
| 102 | 102 | $this->_tables = array( |
| 103 | - 'Message'=>new EE_Primary_Table('esp_message','MSG_ID') |
|
| 103 | + 'Message'=>new EE_Primary_Table('esp_message', 'MSG_ID') |
|
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | 106 | $allowed_priority = array( |
| 107 | - self::priority_high => __( 'high', 'event_espresso' ), |
|
| 108 | - self::priority_medium => __( 'medium', 'event_espresso' ), |
|
| 109 | - self::priority_low => __( 'low', 'event_espresso' ) |
|
| 107 | + self::priority_high => __('high', 'event_espresso'), |
|
| 108 | + self::priority_medium => __('medium', 'event_espresso'), |
|
| 109 | + self::priority_low => __('low', 'event_espresso') |
|
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | 112 | $this->_fields = array( |
| 113 | 113 | 'Message'=>array( |
| 114 | - 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID','event_espresso')), |
|
| 115 | - 'MSG_token' => new EE_Plain_Text_Field( 'MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso' ), false, EEH_URL::generate_unique_token() ), |
|
| 116 | - 'GRP_ID'=>new EE_Foreign_Key_Int_Field( 'GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso' ), true, 0, 'Message_Template_Group' ), |
|
| 117 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( 'Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso' ), true, 0, 'Transaction' ), |
|
| 118 | - 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __( 'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso' ), false, 'email' ), |
|
| 119 | - 'MSG_message_type' => new EE_Plain_Text_Field( 'MSG_message_type', __( 'Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso' ), false, 'receipt' ), |
|
| 120 | - 'MSG_context' => new EE_Plain_Text_Field( 'MSG_context', __( 'Context', 'event_espresso' ), false ), |
|
| 121 | - 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field( 'MSG_recipient_ID', __( 'Recipient ID', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
| 122 | - 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field( 'MSG_recipient_type', __( 'Recipient Type', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
| 123 | - 'MSG_content' => new EE_Maybe_Serialized_Text_Field( 'MSG_content', __( 'Content', 'event_espresso' ), true, '' ), |
|
| 124 | - 'MSG_to' => new EE_Maybe_Serialized_Text_Field( 'MSG_to', __( 'Address To', 'event_espresso' ), true ), |
|
| 125 | - 'MSG_from' => new EE_Maybe_Serialized_Text_Field( 'MSG_from', __( 'Address From', 'event_espresso' ), true ), |
|
| 126 | - 'MSG_subject' => new EE_Maybe_Serialized_Text_Field( 'MSG_subject', __( 'Subject', 'event_espresso' ), true, '' ), |
|
| 127 | - 'MSG_priority' => new EE_Enum_Integer_Field( 'MSG_priority', __( 'Priority', 'event_espresso' ), false, self::priority_low, $allowed_priority ), |
|
| 128 | - 'STS_ID' => new EE_Foreign_Key_String_Field( 'STS_ID', __( 'Status', 'event_espresso' ), false, self::status_incomplete, 'Status' ), |
|
| 129 | - 'MSG_created' => new EE_Datetime_Field( 'MSG_created', __( 'Created', 'event_espresso' ), false, time() ), |
|
| 130 | - 'MSG_modified' => new EE_Datetime_Field( 'MSG_modified', __( 'Modified', 'event_espresso' ), true, time() ) |
|
| 114 | + 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')), |
|
| 115 | + 'MSG_token' => new EE_Plain_Text_Field('MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso'), false, EEH_URL::generate_unique_token()), |
|
| 116 | + 'GRP_ID'=>new EE_Foreign_Key_Int_Field('GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, 'Message_Template_Group'), |
|
| 117 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso'), true, 0, 'Transaction'), |
|
| 118 | + 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso'), false, 'email'), |
|
| 119 | + 'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), false, 'receipt'), |
|
| 120 | + 'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false), |
|
| 121 | + 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
| 122 | + 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
| 123 | + 'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', __('Content', 'event_espresso'), true, ''), |
|
| 124 | + 'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), true), |
|
| 125 | + 'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', __('Address From', 'event_espresso'), true), |
|
| 126 | + 'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', __('Subject', 'event_espresso'), true, ''), |
|
| 127 | + 'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), false, self::priority_low, $allowed_priority), |
|
| 128 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, self::status_incomplete, 'Status'), |
|
| 129 | + 'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, time()), |
|
| 130 | + 'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, time()) |
|
| 131 | 131 | ) |
| 132 | 132 | ); |
| 133 | 133 | $this->_model_relations = array( |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
| 138 | 138 | 'Transaction' => new EE_Belongs_To_Relation() |
| 139 | 139 | ); |
| 140 | - parent::__construct( $timezone ); |
|
| 140 | + parent::__construct($timezone); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | public function create_default_object() { |
| 149 | 149 | /** @type EE_Message $message */ |
| 150 | 150 | $message = parent::create_default_object(); |
| 151 | - if ( $message instanceof EE_Message ) { |
|
| 152 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
| 151 | + if ($message instanceof EE_Message) { |
|
| 152 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
| 153 | 153 | } |
| 154 | 154 | return null; |
| 155 | 155 | } |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | * @param mixed $cols_n_values |
| 161 | 161 | * @return \EE_Message |
| 162 | 162 | */ |
| 163 | - public function instantiate_class_from_array_or_object( $cols_n_values ) { |
|
| 163 | + public function instantiate_class_from_array_or_object($cols_n_values) { |
|
| 164 | 164 | /** @type EE_Message $message */ |
| 165 | - $message = parent::instantiate_class_from_array_or_object( $cols_n_values ); |
|
| 166 | - if ( $message instanceof EE_Message ) { |
|
| 167 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
| 165 | + $message = parent::instantiate_class_from_array_or_object($cols_n_values); |
|
| 166 | + if ($message instanceof EE_Message) { |
|
| 167 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
| 168 | 168 | } |
| 169 | 169 | return null; |
| 170 | 170 | } |
@@ -177,13 +177,13 @@ discard block |
||
| 177 | 177 | * @param string $message_type the message type slug |
| 178 | 178 | * @return boolean |
| 179 | 179 | */ |
| 180 | - public function message_sent_for_attendee( $attendee, $message_type ) { |
|
| 181 | - $attendee_ID = EEM_Attendee::instance()->ensure_is_ID( $attendee ); |
|
| 182 | - return $this->exists( array( array( |
|
| 180 | + public function message_sent_for_attendee($attendee, $message_type) { |
|
| 181 | + $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee); |
|
| 182 | + return $this->exists(array(array( |
|
| 183 | 183 | 'Attendee.ATT_ID' => $attendee_ID, |
| 184 | 184 | 'MSG_message_type' => $message_type, |
| 185 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
| 186 | - ) ) ); |
|
| 185 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
| 186 | + ))); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -195,13 +195,13 @@ discard block |
||
| 195 | 195 | * @param string $message_type the message type slug |
| 196 | 196 | * @return boolean |
| 197 | 197 | */ |
| 198 | - public function message_sent_for_registration( $registration, $message_type ) { |
|
| 199 | - $registrationID = EEM_Registration::instance()->ensure_is_ID( $registration ); |
|
| 200 | - return $this->exists( array( array( |
|
| 198 | + public function message_sent_for_registration($registration, $message_type) { |
|
| 199 | + $registrationID = EEM_Registration::instance()->ensure_is_ID($registration); |
|
| 200 | + return $this->exists(array(array( |
|
| 201 | 201 | 'Registration.REG_ID' => $registrationID, |
| 202 | 202 | 'MSG_message_type' => $message_type, |
| 203 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
| 204 | - ) ) ); |
|
| 203 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
| 204 | + ))); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | |
@@ -212,10 +212,10 @@ discard block |
||
| 212 | 212 | * @param string $token |
| 213 | 213 | * @return EE_Message |
| 214 | 214 | */ |
| 215 | - public function get_one_by_token( $token ) { |
|
| 216 | - return $this->get_one( array( array( |
|
| 215 | + public function get_one_by_token($token) { |
|
| 216 | + return $this->get_one(array(array( |
|
| 217 | 217 | 'MSG_token' => $token |
| 218 | - ) ) ); |
|
| 218 | + ))); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | * Returns stati that indicate the message HAS been sent |
| 224 | 224 | * @return array of strings for possible stati |
| 225 | 225 | */ |
| 226 | - public function stati_indicating_sent(){ |
|
| 227 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_sent', array( self::status_sent ) ); |
|
| 226 | + public function stati_indicating_sent() { |
|
| 227 | + return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent)); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | * @return array of strings for possible stati. |
| 236 | 236 | */ |
| 237 | 237 | public function stati_indicating_to_send() { |
| 238 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_to_send', array( self::status_idle, self::status_resend ) ); |
|
| 238 | + return apply_filters('FHEE__EEM_Message__stati_indicating_to_send', array(self::status_idle, self::status_resend)); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | |
| 242 | 242 | |
| 243 | 243 | public function stati_indicating_failed_sending() { |
| 244 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_failed_sending', array( self::status_failed, self::status_retry ) ); |
|
| 244 | + return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', array(self::status_failed, self::status_retry)); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
@@ -275,11 +275,11 @@ discard block |
||
| 275 | 275 | // the value, matches the corresponding EEM_Base child reference. |
| 276 | 276 | $expected_vars = $this->_expected_vars_for_query_inject(); |
| 277 | 277 | $query_params[0] = array(); |
| 278 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
| 279 | - $request_value = EE_Registry::instance()->REQ->get( $request_key ); |
|
| 280 | - if ( $request_value ) { |
|
| 278 | + foreach ($expected_vars as $request_key => $model_name) { |
|
| 279 | + $request_value = EE_Registry::instance()->REQ->get($request_key); |
|
| 280 | + if ($request_value) { |
|
| 281 | 281 | //special case |
| 282 | - switch ( $request_key ) { |
|
| 282 | + switch ($request_key) { |
|
| 283 | 283 | case '_REG_ID' : |
| 284 | 284 | $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array( |
| 285 | 285 | 'Transaction.Registration.REG_ID' => $request_value, |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | ); |
| 292 | 292 | break; |
| 293 | 293 | default : |
| 294 | - $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value; |
|
| 294 | + $query_params[0]['AND**filter_by']['OR**filter_by_'.$request_key][$model_name.'.'.$request_key] = $request_value; |
|
| 295 | 295 | break; |
| 296 | 296 | } |
| 297 | 297 | } |
@@ -307,53 +307,53 @@ discard block |
||
| 307 | 307 | $expected_vars = $this->_expected_vars_for_query_inject(); |
| 308 | 308 | $pretty_label = ''; |
| 309 | 309 | $label_parts = array(); |
| 310 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
| 311 | - $model = EE_Registry::instance()->load_model( $model_name ); |
|
| 312 | - if ( $model_field_value = EE_Registry::instance()->REQ->get( $request_key ) ) { |
|
| 313 | - switch ( $request_key ) { |
|
| 310 | + foreach ($expected_vars as $request_key => $model_name) { |
|
| 311 | + $model = EE_Registry::instance()->load_model($model_name); |
|
| 312 | + if ($model_field_value = EE_Registry::instance()->REQ->get($request_key)) { |
|
| 313 | + switch ($request_key) { |
|
| 314 | 314 | case '_REG_ID' : |
| 315 | 315 | $label_parts[] = sprintf( |
| 316 | - esc_html__( 'Registration with the ID: %s', 'event_espresso' ), |
|
| 316 | + esc_html__('Registration with the ID: %s', 'event_espresso'), |
|
| 317 | 317 | $model_field_value |
| 318 | 318 | ); |
| 319 | 319 | break; |
| 320 | 320 | case 'ATT_ID' : |
| 321 | 321 | /** @var EE_Attendee $attendee */ |
| 322 | - $attendee = $model->get_one_by_ID( $model_field_value ); |
|
| 322 | + $attendee = $model->get_one_by_ID($model_field_value); |
|
| 323 | 323 | $label_parts[] = $attendee instanceof EE_Attendee |
| 324 | - ? sprintf( esc_html__( 'Attendee %s', 'event_espresso' ), $attendee->full_name() ) |
|
| 325 | - : sprintf( esc_html__( 'Attendee ID: %s', 'event_espresso' ), $model_field_value ); |
|
| 324 | + ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name()) |
|
| 325 | + : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value); |
|
| 326 | 326 | break; |
| 327 | 327 | case 'ID' : |
| 328 | 328 | /** @var EE_WP_User $wpUser */ |
| 329 | - $wpUser = $model->get_one_by_ID( $model_field_value ); |
|
| 329 | + $wpUser = $model->get_one_by_ID($model_field_value); |
|
| 330 | 330 | $label_parts[] = $wpUser instanceof EE_WP_User |
| 331 | - ? sprintf( esc_html__( 'WP User: %s', 'event_espresso' ), $wpUser->name() ) |
|
| 332 | - : sprintf( esc_html__( 'WP User ID: %s', 'event_espresso' ), $model_field_value ); |
|
| 331 | + ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name()) |
|
| 332 | + : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value); |
|
| 333 | 333 | break; |
| 334 | 334 | case 'TXN_ID' : |
| 335 | 335 | $label_parts[] = sprintf( |
| 336 | - esc_html__( 'Transaction with the ID: %s', 'event_espresso' ), |
|
| 336 | + esc_html__('Transaction with the ID: %s', 'event_espresso'), |
|
| 337 | 337 | $model_field_value |
| 338 | 338 | ); |
| 339 | 339 | break; |
| 340 | 340 | case 'EVT_ID' : |
| 341 | 341 | /** @var EE_Event $Event */ |
| 342 | - $Event = $model->get_one_by_ID( $model_field_value ); |
|
| 342 | + $Event = $model->get_one_by_ID($model_field_value); |
|
| 343 | 343 | $label_parts[] = $Event instanceof EE_Event |
| 344 | - ? sprintf( esc_html__( 'for the Event: %s', 'event_espresso' ), $Event->name() ) |
|
| 345 | - : sprintf( esc_html__( 'for the Event with ID: %s', 'event_espresso' ), $model_field_value ); |
|
| 344 | + ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name()) |
|
| 345 | + : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value); |
|
| 346 | 346 | break; |
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - if ( $label_parts ) { |
|
| 351 | + if ($label_parts) { |
|
| 352 | 352 | |
| 353 | 353 | //prepend to the last element of $label_parts an "and". |
| 354 | - if ( count( $label_parts ) > 1 ) { |
|
| 355 | - $label_parts_index_to_prepend = count( $label_parts ) - 1; |
|
| 356 | - $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ]; |
|
| 354 | + if (count($label_parts) > 1) { |
|
| 355 | + $label_parts_index_to_prepend = count($label_parts) - 1; |
|
| 356 | + $label_parts[$label_parts_index_to_prepend] = 'and'.$label_parts[$label_parts_index_to_prepend]; |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | $pretty_label .= sprintf( |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | 'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.', |
| 363 | 363 | 'event_espresso' |
| 364 | 364 | ), |
| 365 | - implode( ', ', $label_parts ) |
|
| 365 | + implode(', ', $label_parts) |
|
| 366 | 366 | ); |
| 367 | 367 | } |
| 368 | 368 | return $pretty_label; |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @param \EE_Message_Repository $message_repository |
| 73 | 73 | */ |
| 74 | - public function __construct( EE_Message_Repository $message_repository ) { |
|
| 75 | - $this->_batch_count = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 ); |
|
| 74 | + public function __construct(EE_Message_Repository $message_repository) { |
|
| 75 | + $this->_batch_count = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50); |
|
| 76 | 76 | $this->_rate_limit = $this->get_rate_limit(); |
| 77 | 77 | $this->_queue = $message_repository; |
| 78 | 78 | } |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | * use the messenger send method but typically is based on preview data. |
| 92 | 92 | * @return bool Whether the message was successfully added to the repository or not. |
| 93 | 93 | */ |
| 94 | - public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) { |
|
| 94 | + public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) { |
|
| 95 | 95 | $data['preview'] = $preview; |
| 96 | 96 | $data['test_send'] = $test_send; |
| 97 | - return $this->_queue->add( $message, $data ); |
|
| 97 | + return $this->_queue->add($message, $data); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | * @param bool $persist This flag indicates whether to attempt to delete the object from the db as well. |
| 107 | 107 | * @return bool |
| 108 | 108 | */ |
| 109 | - public function remove( EE_Message $message, $persist = false ) { |
|
| 110 | - if ( $persist && $this->_queue->current() !== $message ) { |
|
| 109 | + public function remove(EE_Message $message, $persist = false) { |
|
| 110 | + if ($persist && $this->_queue->current() !== $message) { |
|
| 111 | 111 | //get pointer on right message |
| 112 | - if ( $this->_queue->has( $message ) ) { |
|
| 112 | + if ($this->_queue->has($message)) { |
|
| 113 | 113 | $this->_queue->rewind(); |
| 114 | - while( $this->_queue->valid() ) { |
|
| 115 | - if ( $this->_queue->current() === $message ) { |
|
| 114 | + while ($this->_queue->valid()) { |
|
| 115 | + if ($this->_queue->current() === $message) { |
|
| 116 | 116 | break; |
| 117 | 117 | } |
| 118 | 118 | $this->_queue->next(); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | return false; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | - return $persist ? $this->_queue->delete() : $this->_queue->remove( $message ); |
|
| 124 | + return $persist ? $this->_queue->delete() : $this->_queue->remove($message); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
@@ -161,29 +161,29 @@ discard block |
||
| 161 | 161 | * @return bool true if successfully retrieved batch, false no batch ready. |
| 162 | 162 | */ |
| 163 | 163 | public function get_batch_to_generate() { |
| 164 | - if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) { |
|
| 164 | + if ($this->is_locked(EE_Messages_Queue::action_generating)) { |
|
| 165 | 165 | return false; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | //lock batch generation to prevent race conditions. |
| 169 | - $this->lock_queue( EE_Messages_Queue::action_generating ); |
|
| 169 | + $this->lock_queue(EE_Messages_Queue::action_generating); |
|
| 170 | 170 | |
| 171 | 171 | $query_args = array( |
| 172 | 172 | // key 0 = where conditions |
| 173 | - 0 => array( 'STS_ID' => EEM_Message::status_incomplete ), |
|
| 173 | + 0 => array('STS_ID' => EEM_Message::status_incomplete), |
|
| 174 | 174 | 'order_by' => $this->_get_priority_orderby(), |
| 175 | 175 | 'limit' => $this->_batch_count |
| 176 | 176 | ); |
| 177 | - $messages = EEM_Message::instance()->get_all( $query_args ); |
|
| 177 | + $messages = EEM_Message::instance()->get_all($query_args); |
|
| 178 | 178 | |
| 179 | - if ( ! $messages ) { |
|
| 179 | + if ( ! $messages) { |
|
| 180 | 180 | return false; //nothing to generate |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - foreach ( $messages as $message ) { |
|
| 184 | - if ( $message instanceof EE_Message ) { |
|
| 183 | + foreach ($messages as $message) { |
|
| 184 | + if ($message instanceof EE_Message) { |
|
| 185 | 185 | $data = $message->all_extra_meta_array(); |
| 186 | - $this->add( $message, $data ); |
|
| 186 | + $this->add($message, $data); |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | return true; |
@@ -206,34 +206,34 @@ discard block |
||
| 206 | 206 | * to assist with notifying user. |
| 207 | 207 | */ |
| 208 | 208 | public function get_to_send_batch_and_send() { |
| 209 | - if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) { |
|
| 209 | + if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) { |
|
| 210 | 210 | return false; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - $this->lock_queue( EE_Messages_Queue::action_sending ); |
|
| 213 | + $this->lock_queue(EE_Messages_Queue::action_sending); |
|
| 214 | 214 | |
| 215 | 215 | $batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit; |
| 216 | 216 | |
| 217 | 217 | $query_args = array( |
| 218 | 218 | // key 0 = where conditions |
| 219 | - 0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ), |
|
| 219 | + 0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())), |
|
| 220 | 220 | 'order_by' => $this->_get_priority_orderby(), |
| 221 | 221 | 'limit' => $batch |
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | - $messages_to_send = EEM_Message::instance()->get_all( $query_args ); |
|
| 224 | + $messages_to_send = EEM_Message::instance()->get_all($query_args); |
|
| 225 | 225 | |
| 226 | 226 | |
| 227 | 227 | //any to send? |
| 228 | - if ( ! $messages_to_send ) { |
|
| 229 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
| 228 | + if ( ! $messages_to_send) { |
|
| 229 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
| 230 | 230 | return false; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | //add to queue. |
| 234 | - foreach ( $messages_to_send as $message ) { |
|
| 235 | - if ( $message instanceof EE_Message ) { |
|
| 236 | - $this->add( $message ); |
|
| 234 | + foreach ($messages_to_send as $message) { |
|
| 235 | + if ($message instanceof EE_Message) { |
|
| 236 | + $this->add($message); |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $this->execute(); |
| 242 | 242 | |
| 243 | 243 | //release lock |
| 244 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
| 244 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
| 245 | 245 | return true; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @param string $type The type of queue being locked. |
| 255 | 255 | */ |
| 256 | - public function lock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
| 257 | - set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) ); |
|
| 256 | + public function lock_queue($type = EE_Messages_Queue::action_generating) { |
|
| 257 | + set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type)); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
@@ -265,8 +265,8 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @param string $type The type of queue being unlocked. |
| 267 | 267 | */ |
| 268 | - public function unlock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
| 269 | - delete_transient( $this->_get_lock_key( $type ) ); |
|
| 268 | + public function unlock_queue($type = EE_Messages_Queue::action_generating) { |
|
| 269 | + delete_transient($this->_get_lock_key($type)); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | |
@@ -277,8 +277,8 @@ discard block |
||
| 277 | 277 | * @param string $type The type of lock. |
| 278 | 278 | * @return string |
| 279 | 279 | */ |
| 280 | - protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) { |
|
| 281 | - return '_ee_lock_' . $type; |
|
| 280 | + protected function _get_lock_key($type = EE_Messages_Queue::action_generating) { |
|
| 281 | + return '_ee_lock_'.$type; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | * @param string $type The type of lock |
| 290 | 290 | * @return int time to expiry in seconds. |
| 291 | 291 | */ |
| 292 | - protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) { |
|
| 293 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type ); |
|
| 292 | + protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) { |
|
| 293 | + return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * @return int |
| 309 | 309 | */ |
| 310 | 310 | protected function _get_rate_limit_expiry() { |
| 311 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS ); |
|
| 311 | + return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * @return int |
| 320 | 320 | */ |
| 321 | 321 | protected function _default_rate_limit() { |
| 322 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 ); |
|
| 322 | + return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -345,8 +345,8 @@ discard block |
||
| 345 | 345 | * @param string $type The type of lock being checked for. |
| 346 | 346 | * @return bool |
| 347 | 347 | */ |
| 348 | - public function is_locked( $type = EE_Messages_Queue::action_generating ) { |
|
| 349 | - return (bool) get_transient( $this->_get_lock_key( $type ) ); |
|
| 348 | + public function is_locked($type = EE_Messages_Queue::action_generating) { |
|
| 349 | + return (bool) get_transient($this->_get_lock_key($type)); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | |
@@ -361,9 +361,9 @@ discard block |
||
| 361 | 361 | * @return int |
| 362 | 362 | */ |
| 363 | 363 | public function get_rate_limit() { |
| 364 | - if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) { |
|
| 364 | + if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) { |
|
| 365 | 365 | $rate_limit = $this->_default_rate_limit(); |
| 366 | - set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() ); |
|
| 366 | + set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key()); |
|
| 367 | 367 | } |
| 368 | 368 | return $rate_limit; |
| 369 | 369 | } |
@@ -375,12 +375,12 @@ discard block |
||
| 375 | 375 | * This updates existing rate limit with the new limit which is the old minus the batch. |
| 376 | 376 | * @param int $batch_completed This sets the new rate limit based on the given batch that was completed. |
| 377 | 377 | */ |
| 378 | - public function set_rate_limit( $batch_completed ) { |
|
| 378 | + public function set_rate_limit($batch_completed) { |
|
| 379 | 379 | //first get the most up to date rate limit (in case its expired and reset) |
| 380 | 380 | $rate_limit = $this->get_rate_limit(); |
| 381 | 381 | $new_limit = $rate_limit - $batch_completed; |
| 382 | 382 | //updating the transient option directly to avoid resetting the expiry. |
| 383 | - update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit ); |
|
| 383 | + update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | * @param string $task This indicates what type of request is going to be initiated. |
| 394 | 394 | * @param int $priority This indicates the priority that triggers initiating the request. |
| 395 | 395 | */ |
| 396 | - public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) { |
|
| 396 | + public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { |
|
| 397 | 397 | //determine what status is matched with the priority as part of the trigger conditions. |
| 398 | 398 | $status = $task == 'generate' |
| 399 | 399 | ? EEM_Message::status_incomplete |
@@ -401,8 +401,8 @@ discard block |
||
| 401 | 401 | // always make sure we save because either this will get executed immediately on a separate request |
| 402 | 402 | // or remains in the queue for the regularly scheduled queue batch. |
| 403 | 403 | $this->save(); |
| 404 | - if ( $this->_queue->count_by_priority_and_status( $priority, $status ) ) { |
|
| 405 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task ); |
|
| 404 | + if ($this->_queue->count_by_priority_and_status($priority, $status)) { |
|
| 405 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); |
|
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | |
@@ -427,50 +427,50 @@ discard block |
||
| 427 | 427 | * Also, if the messenger is an request type messenger (or a preview), |
| 428 | 428 | * its entirely possible that the messenger will exit before |
| 429 | 429 | */ |
| 430 | - public function execute( $save = true, $sending_messenger = null, $by_priority = false ) { |
|
| 430 | + public function execute($save = true, $sending_messenger = null, $by_priority = false) { |
|
| 431 | 431 | $messages_sent = 0; |
| 432 | 432 | $this->_did_hook = array(); |
| 433 | 433 | $this->_queue->rewind(); |
| 434 | - while ( $this->_queue->valid() ) { |
|
| 434 | + while ($this->_queue->valid()) { |
|
| 435 | 435 | $error_messages = array(); |
| 436 | 436 | /** @type EE_Message $message */ |
| 437 | 437 | $message = $this->_queue->current(); |
| 438 | 438 | //if the message in the queue has a sent status, then skip |
| 439 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_sent() ) ) { |
|
| 439 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_sent())) { |
|
| 440 | 440 | continue; |
| 441 | 441 | } |
| 442 | 442 | //if $by_priority is set and does not match then continue; |
| 443 | - if ( $by_priority && $by_priority != $message->priority() ) { |
|
| 443 | + if ($by_priority && $by_priority != $message->priority()) { |
|
| 444 | 444 | continue; |
| 445 | 445 | } |
| 446 | 446 | //error checking |
| 447 | - if ( ! $message->valid_messenger() ) { |
|
| 447 | + if ( ! $message->valid_messenger()) { |
|
| 448 | 448 | $error_messages[] = sprintf( |
| 449 | - __( 'The %s messenger is not active at time of sending.', 'event_espresso' ), |
|
| 449 | + __('The %s messenger is not active at time of sending.', 'event_espresso'), |
|
| 450 | 450 | $message->messenger() |
| 451 | 451 | ); |
| 452 | 452 | } |
| 453 | - if ( ! $message->valid_message_type() ) { |
|
| 453 | + if ( ! $message->valid_message_type()) { |
|
| 454 | 454 | $error_messages[] = sprintf( |
| 455 | - __( 'The %s message type is not active at the time of sending.', 'event_espresso' ), |
|
| 455 | + __('The %s message type is not active at the time of sending.', 'event_espresso'), |
|
| 456 | 456 | $message->message_type() |
| 457 | 457 | ); |
| 458 | 458 | } |
| 459 | 459 | // if there was supposed to be a sending messenger for this message, but it was invalid/inactive, |
| 460 | 460 | // then it will instead be an EE_Error object, so let's check for that |
| 461 | - if ( $sending_messenger instanceof EE_Error ) { |
|
| 461 | + if ($sending_messenger instanceof EE_Error) { |
|
| 462 | 462 | $error_messages[] = $sending_messenger->getMessage(); |
| 463 | 463 | } |
| 464 | 464 | // if there are no errors, then let's process the message |
| 465 | - if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) { |
|
| 465 | + if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) { |
|
| 466 | 466 | $messages_sent++; |
| 467 | 467 | } |
| 468 | - $this->_set_error_message( $message, $error_messages ); |
|
| 468 | + $this->_set_error_message($message, $error_messages); |
|
| 469 | 469 | //add modified time |
| 470 | - $message->set_modified( time() ); |
|
| 470 | + $message->set_modified(time()); |
|
| 471 | 471 | $this->_queue->next(); |
| 472 | 472 | } |
| 473 | - if ( $save ) { |
|
| 473 | + if ($save) { |
|
| 474 | 474 | $this->save(); |
| 475 | 475 | } |
| 476 | 476 | return $messages_sent; |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | * @param mixed $sending_messenger (optional) |
| 486 | 486 | * @return bool |
| 487 | 487 | */ |
| 488 | - protected function _process_message( EE_Message $message, $sending_messenger = null ) { |
|
| 488 | + protected function _process_message(EE_Message $message, $sending_messenger = null) { |
|
| 489 | 489 | // these *should* have been validated in the execute() method above |
| 490 | 490 | $messenger = $message->messenger_object(); |
| 491 | 491 | $message_type = $message->message_type_object(); |
@@ -495,20 +495,20 @@ discard block |
||
| 495 | 495 | && $messenger instanceof EE_messenger |
| 496 | 496 | && $sending_messenger->name != $messenger->name |
| 497 | 497 | ) { |
| 498 | - $messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
| 498 | + $messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
| 499 | 499 | $messenger = $sending_messenger; |
| 500 | 500 | } |
| 501 | 501 | // send using messenger, but double check objects |
| 502 | - if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) { |
|
| 502 | + if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) { |
|
| 503 | 503 | //set hook for message type (but only if not using another messenger to send). |
| 504 | - if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) { |
|
| 505 | - $message_type->do_messenger_hooks( $messenger ); |
|
| 506 | - $this->_did_hook[ $message_type->name ] = 1; |
|
| 504 | + if ( ! isset($this->_did_hook[$message_type->name])) { |
|
| 505 | + $message_type->do_messenger_hooks($messenger); |
|
| 506 | + $this->_did_hook[$message_type->name] = 1; |
|
| 507 | 507 | } |
| 508 | 508 | //if preview then use preview method |
| 509 | 509 | return $this->_queue->is_preview() |
| 510 | - ? $this->_do_preview( $message, $messenger, $message_type, $this->_queue->is_test_send() ) |
|
| 511 | - : $this->_do_send( $message, $messenger, $message_type ); |
|
| 510 | + ? $this->_do_preview($message, $messenger, $message_type, $this->_queue->is_test_send()) |
|
| 511 | + : $this->_do_send($message, $messenger, $message_type); |
|
| 512 | 512 | } |
| 513 | 513 | return false; |
| 514 | 514 | } |
@@ -526,12 +526,12 @@ discard block |
||
| 526 | 526 | * @param array $status Stati to check for in queue |
| 527 | 527 | * @return int Count of EE_Message's matching the given status. |
| 528 | 528 | */ |
| 529 | - public function count_STS_in_queue( $status ) { |
|
| 529 | + public function count_STS_in_queue($status) { |
|
| 530 | 530 | $count = 0; |
| 531 | - $status = is_array( $status ) ? $status : array( $status ); |
|
| 531 | + $status = is_array($status) ? $status : array($status); |
|
| 532 | 532 | $this->_queue->rewind(); |
| 533 | - foreach( $this->_queue as $message ) { |
|
| 534 | - if ( in_array( $message->STS_ID(), $status ) ) { |
|
| 533 | + foreach ($this->_queue as $message) { |
|
| 534 | + if (in_array($message->STS_ID(), $status)) { |
|
| 535 | 535 | $count++; |
| 536 | 536 | } |
| 537 | 537 | } |
@@ -548,15 +548,15 @@ discard block |
||
| 548 | 548 | * @param $test_send |
| 549 | 549 | * @return bool true means all went well, false means, not so much. |
| 550 | 550 | */ |
| 551 | - protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
|
| 552 | - if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) { |
|
| 553 | - if ( ! $test_send ) { |
|
| 554 | - $message->set_content( $preview ); |
|
| 551 | + protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) { |
|
| 552 | + if ($preview = $messenger->get_preview($message, $message_type, $test_send)) { |
|
| 553 | + if ( ! $test_send) { |
|
| 554 | + $message->set_content($preview); |
|
| 555 | 555 | } |
| 556 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
| 556 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
| 557 | 557 | return true; |
| 558 | 558 | } else { |
| 559 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
| 559 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
| 560 | 560 | return false; |
| 561 | 561 | } |
| 562 | 562 | } |
@@ -572,12 +572,12 @@ discard block |
||
| 572 | 572 | * @param EE_message_type $message_type |
| 573 | 573 | * @return bool true means all went well, false means, not so much. |
| 574 | 574 | */ |
| 575 | - protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) { |
|
| 576 | - if ( $messenger->send_message( $message, $message_type ) ) { |
|
| 577 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
| 575 | + protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) { |
|
| 576 | + if ($messenger->send_message($message, $message_type)) { |
|
| 577 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
| 578 | 578 | return true; |
| 579 | 579 | } else { |
| 580 | - $message->set_STS_ID( EEM_Message::status_retry ); |
|
| 580 | + $message->set_STS_ID(EEM_Message::status_retry); |
|
| 581 | 581 | return false; |
| 582 | 582 | } |
| 583 | 583 | } |
@@ -591,21 +591,21 @@ discard block |
||
| 591 | 591 | * @param EE_Message $message |
| 592 | 592 | * @param array $error_messages the response from the messenger. |
| 593 | 593 | */ |
| 594 | - protected function _set_error_message( EE_Message $message, $error_messages ) { |
|
| 594 | + protected function _set_error_message(EE_Message $message, $error_messages) { |
|
| 595 | 595 | $error_messages = (array) $error_messages; |
| 596 | - if ( $message->STS_ID() === EEM_Message::status_failed || $message->STS_ID() === EEM_Message::status_retry ) { |
|
| 596 | + if ($message->STS_ID() === EEM_Message::status_failed || $message->STS_ID() === EEM_Message::status_retry) { |
|
| 597 | 597 | $notices = EE_Error::has_notices(); |
| 598 | - $error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' ); |
|
| 599 | - if ( $notices === 1 ) { |
|
| 598 | + $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); |
|
| 599 | + if ($notices === 1) { |
|
| 600 | 600 | $notices = EE_Error::get_vanilla_notices(); |
| 601 | - $notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array(); |
|
| 602 | - $error_messages[] = implode( "\n", $notices['errors'] ); |
|
| 601 | + $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); |
|
| 602 | + $error_messages[] = implode("\n", $notices['errors']); |
|
| 603 | 603 | } |
| 604 | 604 | } |
| 605 | - if ( count( $error_messages ) > 0 ) { |
|
| 606 | - $msg = __( 'Message was not executed successfully.', 'event_espresso' ); |
|
| 607 | - $msg = $msg . "\n" . implode( "\n", $error_messages ); |
|
| 608 | - $message->set_error_message( $msg ); |
|
| 605 | + if (count($error_messages) > 0) { |
|
| 606 | + $msg = __('Message was not executed successfully.', 'event_espresso'); |
|
| 607 | + $msg = $msg."\n".implode("\n", $error_messages); |
|
| 608 | + $message->set_error_message($msg); |
|
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | 611 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @return EED_Module |
| 70 | 70 | */ |
| 71 | 71 | public static function instance() { |
| 72 | - return parent::get_instance( __CLASS__ ); |
|
| 72 | + return parent::get_instance(__CLASS__); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public static function set_hooks() { |
| 86 | 86 | //actions |
| 87 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
| 88 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 2 ); |
|
| 87 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
| 88 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 2); |
|
| 89 | 89 | //filters |
| 90 | - add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
| 91 | - add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
| 90 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 91 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 92 | 92 | //register routes |
| 93 | 93 | self::_register_routes(); |
| 94 | 94 | } |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public static function set_hooks_admin() { |
| 103 | 103 | //actions |
| 104 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
| 105 | - add_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array( 'EED_Messages', 'payment_reminder' ), 10 ); |
|
| 106 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 3 ); |
|
| 107 | - add_action( 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', array( 'EED_Messages', 'send_newsletter_message' ), 10, 2 ); |
|
| 108 | - add_action( 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array( 'EED_Messages', 'cancelled_registration' ), 10 ); |
|
| 109 | - add_action( 'AHEE__EE_Admin_Page___process_admin_payment_notification', array( 'EED_Messages', 'process_admin_payment' ), 10, 1 ); |
|
| 104 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
| 105 | + add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array('EED_Messages', 'payment_reminder'), 10); |
|
| 106 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 3); |
|
| 107 | + add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', array('EED_Messages', 'send_newsletter_message'), 10, 2); |
|
| 108 | + add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array('EED_Messages', 'cancelled_registration'), 10); |
|
| 109 | + add_action('AHEE__EE_Admin_Page___process_admin_payment_notification', array('EED_Messages', 'process_admin_payment'), 10, 1); |
|
| 110 | 110 | //filters |
| 111 | - add_filter( 'FHEE__EE_Admin_Page___process_resend_registration__success', array( 'EED_Messages', 'process_resend' ), 10, 2 ); |
|
| 112 | - add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
| 113 | - add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
| 111 | + add_filter('FHEE__EE_Admin_Page___process_resend_registration__success', array('EED_Messages', 'process_resend'), 10, 2); |
|
| 112 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 113 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
@@ -124,11 +124,11 @@ discard block |
||
| 124 | 124 | * @return void |
| 125 | 125 | */ |
| 126 | 126 | protected static function _register_routes() { |
| 127 | - EE_Config::register_route( 'msg_url_trigger', 'Messages', 'run' ); |
|
| 128 | - EE_Config::register_route( 'msg_cron_trigger', 'Messages', 'run_cron' ); |
|
| 129 | - EE_Config::register_route( 'msg_browser_trigger', 'Messages', 'browser_trigger' ); |
|
| 130 | - EE_Config::register_route( 'msg_browser_error_trigger', 'Messages', 'browser_error_trigger' ); |
|
| 131 | - do_action( 'AHEE__EED_Messages___register_routes' ); |
|
| 127 | + EE_Config::register_route('msg_url_trigger', 'Messages', 'run'); |
|
| 128 | + EE_Config::register_route('msg_cron_trigger', 'Messages', 'run_cron'); |
|
| 129 | + EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
| 130 | + EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
| 131 | + do_action('AHEE__EED_Messages___register_routes'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | |
@@ -139,18 +139,18 @@ discard block |
||
| 139 | 139 | * @since 4.9.0 |
| 140 | 140 | * @param WP $WP |
| 141 | 141 | */ |
| 142 | - public function browser_trigger( $WP ) { |
|
| 142 | + public function browser_trigger($WP) { |
|
| 143 | 143 | //ensure controller is loaded |
| 144 | 144 | self::_load_controller(); |
| 145 | - $token = EE_Registry::instance()->REQ->get( 'token' ); |
|
| 145 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
| 146 | 146 | try { |
| 147 | - $mtg = new EE_Message_Generated_From_Token( $token, 'html', self::$_message_resource_manager ); |
|
| 148 | - self::$_MSG_PROCESSOR->generate_and_send_now( $mtg ); |
|
| 149 | - } catch( EE_Error $e ) { |
|
| 150 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
| 147 | + $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
| 148 | + self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
| 149 | + } catch (EE_Error $e) { |
|
| 150 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
| 151 | 151 | // add specific message for developers if WP_DEBUG in on |
| 152 | - $error_msg .= '||' . $e->getMessage(); |
|
| 153 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 152 | + $error_msg .= '||'.$e->getMessage(); |
|
| 153 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -166,20 +166,20 @@ discard block |
||
| 166 | 166 | * @since 4.9.0 |
| 167 | 167 | * @param $WP |
| 168 | 168 | */ |
| 169 | - public function browser_error_trigger( $WP ) { |
|
| 170 | - $token = EE_Registry::instance()->REQ->get( 'token' ); |
|
| 171 | - if ( $token ) { |
|
| 172 | - $message = EEM_Message::instance()->get_one_by_token( $token ); |
|
| 173 | - if ( $message instanceof EE_Message ) { |
|
| 174 | - header( 'HTTP/1.1 200 OK' ); |
|
| 175 | - $error_msg = nl2br( $message->error_message() ); |
|
| 169 | + public function browser_error_trigger($WP) { |
|
| 170 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
| 171 | + if ($token) { |
|
| 172 | + $message = EEM_Message::instance()->get_one_by_token($token); |
|
| 173 | + if ($message instanceof EE_Message) { |
|
| 174 | + header('HTTP/1.1 200 OK'); |
|
| 175 | + $error_msg = nl2br($message->error_message()); |
|
| 176 | 176 | ?> |
| 177 | 177 | <!DOCTYPE html> |
| 178 | 178 | <html> |
| 179 | 179 | <head></head> |
| 180 | 180 | <body> |
| 181 | - <?php echo empty( $error_msg ) |
|
| 182 | - ? esc_html__( 'Unfortunately, we were unable to capture the error message for this message.', 'event_espresso' ) |
|
| 181 | + <?php echo empty($error_msg) |
|
| 182 | + ? esc_html__('Unfortunately, we were unable to capture the error message for this message.', 'event_espresso') |
|
| 183 | 183 | : wp_kses( |
| 184 | 184 | $error_msg, |
| 185 | 185 | array( |
@@ -214,19 +214,19 @@ discard block |
||
| 214 | 214 | * @throws EE_Error |
| 215 | 215 | * @return void |
| 216 | 216 | */ |
| 217 | - public function run( $WP ) { |
|
| 217 | + public function run($WP) { |
|
| 218 | 218 | //ensure controller is loaded |
| 219 | 219 | self::_load_controller(); |
| 220 | 220 | // attempt to process message |
| 221 | 221 | try { |
| 222 | 222 | /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
| 223 | - $message_to_generate = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
| 224 | - self::$_MSG_PROCESSOR->generate_and_send_now( $message_to_generate ); |
|
| 225 | - } catch ( EE_Error $e ) { |
|
| 226 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
| 223 | + $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
| 224 | + self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
| 225 | + } catch (EE_Error $e) { |
|
| 226 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
| 227 | 227 | // add specific message for developers if WP_DEBUG in on |
| 228 | - $error_msg .= '||' . $e->getMessage(); |
|
| 229 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 228 | + $error_msg .= '||'.$e->getMessage(); |
|
| 229 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
@@ -235,30 +235,30 @@ discard block |
||
| 235 | 235 | * This is triggered by the 'msg_cron_trigger' route. |
| 236 | 236 | * @param WP $WP |
| 237 | 237 | */ |
| 238 | - public function run_cron( $WP ) { |
|
| 238 | + public function run_cron($WP) { |
|
| 239 | 239 | self::_load_controller(); |
| 240 | 240 | //get required vars |
| 241 | - $cron_type = EE_Registry::instance()->REQ->get( 'type' ); |
|
| 242 | - $nonce = EE_Registry::instance()->REQ->get( '_nonce' ); |
|
| 243 | - header( 'HTTP/1.1 200 OK' ); |
|
| 241 | + $cron_type = EE_Registry::instance()->REQ->get('type'); |
|
| 242 | + $nonce = EE_Registry::instance()->REQ->get('_nonce'); |
|
| 243 | + header('HTTP/1.1 200 OK'); |
|
| 244 | 244 | |
| 245 | 245 | //now let's verify nonce, if not valid exit immediately |
| 246 | - if ( ! wp_verify_nonce( $nonce, 'EE_Messages_Scheduler_' . $cron_type ) ) { |
|
| 246 | + if ( ! wp_verify_nonce($nonce, 'EE_Messages_Scheduler_'.$cron_type)) { |
|
| 247 | 247 | /** |
| 248 | 248 | * trigger error so this gets in the error logs. This is important because it happens on a non-user request. |
| 249 | 249 | */ |
| 250 | - trigger_error( esc_attr__( 'Invalid Nonce', 'event_espresso' ) ); |
|
| 250 | + trigger_error(esc_attr__('Invalid Nonce', 'event_espresso')); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
| 254 | - if ( method_exists( self::$_MSG_PROCESSOR, $method ) ) { |
|
| 253 | + $method = 'batch_'.$cron_type.'_from_queue'; |
|
| 254 | + if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
| 255 | 255 | self::$_MSG_PROCESSOR->$method(); |
| 256 | 256 | } else { |
| 257 | 257 | //no matching task |
| 258 | 258 | /** |
| 259 | 259 | * trigger error so this gets in the error logs. This is important because it happens on a non user request. |
| 260 | 260 | */ |
| 261 | - trigger_error( esc_attr( sprintf( __( 'There is no task corresponding to this route %s', 'event_espresso' ), $cron_type ) ) ); |
|
| 261 | + trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'), $cron_type))); |
|
| 262 | 262 | } |
| 263 | 263 | exit(); |
| 264 | 264 | } |
@@ -276,9 +276,9 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return EE_Messages_Template_Pack |
| 278 | 278 | */ |
| 279 | - public static function get_template_pack( $template_pack_name ) { |
|
| 280 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 281 | - return EEH_MSG_Template::get_template_pack( $template_pack_name ); |
|
| 279 | + public static function get_template_pack($template_pack_name) { |
|
| 280 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 281 | + return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
@@ -292,14 +292,14 @@ discard block |
||
| 292 | 292 | * @return EE_Messages_Template_Pack[] |
| 293 | 293 | */ |
| 294 | 294 | public static function get_template_packs() { |
| 295 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 295 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 296 | 296 | |
| 297 | 297 | //for backward compat, let's make sure this returns in the same format as originally. |
| 298 | 298 | $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
| 299 | 299 | $template_pack_collection->rewind(); |
| 300 | 300 | $template_packs = array(); |
| 301 | - while ( $template_pack_collection->valid() ) { |
|
| 302 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
| 301 | + while ($template_pack_collection->valid()) { |
|
| 302 | + $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current(); |
|
| 303 | 303 | $template_pack_collection->next(); |
| 304 | 304 | } |
| 305 | 305 | return $template_packs; |
@@ -315,15 +315,15 @@ discard block |
||
| 315 | 315 | * @return void |
| 316 | 316 | */ |
| 317 | 317 | public static function set_autoloaders() { |
| 318 | - if ( empty( self::$_MSG_PATHS ) ) { |
|
| 318 | + if (empty(self::$_MSG_PATHS)) { |
|
| 319 | 319 | self::_set_messages_paths(); |
| 320 | - EE_Registry::instance()->load_helper( 'Autoloader' ); |
|
| 321 | - foreach ( self::$_MSG_PATHS as $path ) { |
|
| 322 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $path ); |
|
| 320 | + EE_Registry::instance()->load_helper('Autoloader'); |
|
| 321 | + foreach (self::$_MSG_PATHS as $path) { |
|
| 322 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
| 323 | 323 | } |
| 324 | 324 | // add aliases |
| 325 | - EEH_Autoloader::add_alias( 'EE_messages', 'EE_messages' ); |
|
| 326 | - EEH_Autoloader::add_alias( 'EE_messenger', 'EE_messenger' ); |
|
| 325 | + EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
| 326 | + EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | 'shortcodes', |
| 352 | 352 | ); |
| 353 | 353 | $paths = array(); |
| 354 | - foreach ( $dir_ref as $index => $dir ) { |
|
| 355 | - $paths[ $index ] = EE_LIBRARIES . $dir; |
|
| 354 | + foreach ($dir_ref as $index => $dir) { |
|
| 355 | + $paths[$index] = EE_LIBRARIES.$dir; |
|
| 356 | 356 | } |
| 357 | - self::$_MSG_PATHS = apply_filters( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths ); |
|
| 357 | + self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | |
@@ -365,12 +365,12 @@ discard block |
||
| 365 | 365 | * @return void |
| 366 | 366 | */ |
| 367 | 367 | protected static function _load_controller() { |
| 368 | - if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor ) { |
|
| 369 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
| 368 | + if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
| 369 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
| 370 | 370 | self::set_autoloaders(); |
| 371 | - self::$_EEMSG = EE_Registry::instance()->load_lib( 'messages' ); |
|
| 372 | - self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
| 373 | - self::$_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 371 | + self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
| 372 | + self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
| 373 | + self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | |
@@ -379,10 +379,10 @@ discard block |
||
| 379 | 379 | /** |
| 380 | 380 | * @param EE_Transaction $transaction |
| 381 | 381 | */ |
| 382 | - public static function payment_reminder( EE_Transaction $transaction ) { |
|
| 382 | + public static function payment_reminder(EE_Transaction $transaction) { |
|
| 383 | 383 | self::_load_controller(); |
| 384 | - $data = array( $transaction, null ); |
|
| 385 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'payment_reminder', $data ); |
|
| 384 | + $data = array($transaction, null); |
|
| 385 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | |
@@ -393,14 +393,14 @@ discard block |
||
| 393 | 393 | * @param EE_Payment object |
| 394 | 394 | * @return void |
| 395 | 395 | */ |
| 396 | - public static function payment( EE_Transaction $transaction, EE_Payment $payment ) { |
|
| 396 | + public static function payment(EE_Transaction $transaction, EE_Payment $payment) { |
|
| 397 | 397 | self::_load_controller(); |
| 398 | - $data = array( $transaction, $payment ); |
|
| 399 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 400 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
| 398 | + $data = array($transaction, $payment); |
|
| 399 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 400 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
| 401 | 401 | //if payment amount is less than 0 then switch to payment_refund message type. |
| 402 | 402 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
| 403 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
| 403 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | |
@@ -408,10 +408,10 @@ discard block |
||
| 408 | 408 | /** |
| 409 | 409 | * @param EE_Transaction $transaction |
| 410 | 410 | */ |
| 411 | - public static function cancelled_registration( EE_Transaction $transaction ) { |
|
| 411 | + public static function cancelled_registration(EE_Transaction $transaction) { |
|
| 412 | 412 | self::_load_controller(); |
| 413 | - $data = array( $transaction, null ); |
|
| 414 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'cancelled_registration', $data ); |
|
| 413 | + $data = array($transaction, null); |
|
| 414 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | |
@@ -424,14 +424,14 @@ discard block |
||
| 424 | 424 | * @param array $extra_details |
| 425 | 425 | * @return void |
| 426 | 426 | */ |
| 427 | - public static function maybe_registration( EE_Registration $registration, $extra_details = array() ) { |
|
| 427 | + public static function maybe_registration(EE_Registration $registration, $extra_details = array()) { |
|
| 428 | 428 | |
| 429 | - if ( ! self::_verify_registration_notification_send( $registration, $extra_details ) ) { |
|
| 429 | + if ( ! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
| 430 | 430 | //no messages please |
| 431 | 431 | return; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 434 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 435 | 435 | |
| 436 | 436 | //get all registrations so we make sure we send messages for the right status. |
| 437 | 437 | $all_registrations = $registration->transaction()->registrations(); |
@@ -442,22 +442,22 @@ discard block |
||
| 442 | 442 | $mtgs = array(); |
| 443 | 443 | |
| 444 | 444 | //loop through registrations and trigger messages once per status. |
| 445 | - foreach ( $all_registrations as $reg ) { |
|
| 445 | + foreach ($all_registrations as $reg) { |
|
| 446 | 446 | |
| 447 | 447 | //already triggered? |
| 448 | - if ( in_array( $reg->status_ID(), $statuses_sent ) ) { |
|
| 448 | + if (in_array($reg->status_ID(), $statuses_sent)) { |
|
| 449 | 449 | continue; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - $message_type = EEH_MSG_Template::convert_reg_status_to_message_type( $reg->status_ID() ); |
|
| 453 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( $message_type, array( $registration->transaction(), null, $reg->status_ID() ) ); |
|
| 452 | + $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
| 453 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers($message_type, array($registration->transaction(), null, $reg->status_ID())); |
|
| 454 | 454 | $statuses_sent[] = $reg->status_ID(); |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( 'registration_summary', array( $registration->transaction(), null ) ); |
|
| 457 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers('registration_summary', array($registration->transaction(), null)); |
|
| 458 | 458 | |
| 459 | 459 | //batch queue and initiate request |
| 460 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $mtgs ); |
|
| 460 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
| 461 | 461 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
| 462 | 462 | } |
| 463 | 463 | |
@@ -472,39 +472,39 @@ discard block |
||
| 472 | 472 | * |
| 473 | 473 | * @return bool true = send away, false = nope halt the presses. |
| 474 | 474 | */ |
| 475 | - protected static function _verify_registration_notification_send( EE_Registration $registration, $extra_details = array() ) { |
|
| 475 | + protected static function _verify_registration_notification_send(EE_Registration $registration, $extra_details = array()) { |
|
| 476 | 476 | //self::log( |
| 477 | 477 | // __CLASS__, __FUNCTION__, __LINE__, |
| 478 | 478 | // $registration->transaction(), |
| 479 | 479 | // array( '$extra_details' => $extra_details ) |
| 480 | 480 | //); |
| 481 | 481 | // currently only using this to send messages for the primary registrant |
| 482 | - if ( ! $registration->is_primary_registrant() ) { |
|
| 482 | + if ( ! $registration->is_primary_registrant()) { |
|
| 483 | 483 | return false; |
| 484 | 484 | } |
| 485 | 485 | // first we check if we're in admin and not doing front ajax |
| 486 | - if ( is_admin() && ! EE_FRONT_AJAX ) { |
|
| 486 | + if (is_admin() && ! EE_FRONT_AJAX) { |
|
| 487 | 487 | //make sure appropriate admin params are set for sending messages |
| 488 | - if ( empty( $_REQUEST['txn_reg_status_change']['send_notifications'] ) || ! absint( $_REQUEST['txn_reg_status_change']['send_notifications'] ) ) { |
|
| 488 | + if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) { |
|
| 489 | 489 | //no messages sent please. |
| 490 | 490 | return false; |
| 491 | 491 | } |
| 492 | 492 | } else { |
| 493 | 493 | // frontend request (either regular or via AJAX) |
| 494 | 494 | // TXN is NOT finalized ? |
| 495 | - if ( ! isset( $extra_details['finalized'] ) || $extra_details['finalized'] === false ) { |
|
| 495 | + if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
| 496 | 496 | return false; |
| 497 | 497 | } |
| 498 | 498 | // return visit but nothing changed ??? |
| 499 | 499 | if ( |
| 500 | - isset( $extra_details['revisit'], $extra_details['status_updates'] ) && |
|
| 500 | + isset($extra_details['revisit'], $extra_details['status_updates']) && |
|
| 501 | 501 | $extra_details['revisit'] && ! $extra_details['status_updates'] |
| 502 | 502 | ) { |
| 503 | 503 | return false; |
| 504 | 504 | } |
| 505 | 505 | // NOT sending messages && reg status is something other than "Not-Approved" |
| 506 | 506 | if ( |
| 507 | - ! apply_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', false ) && |
|
| 507 | + ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
| 508 | 508 | $registration->status_ID() !== EEM_Registration::status_id_not_approved |
| 509 | 509 | ) { |
| 510 | 510 | return false; |
@@ -526,10 +526,10 @@ discard block |
||
| 526 | 526 | * |
| 527 | 527 | * @return array |
| 528 | 528 | */ |
| 529 | - protected static function _get_reg_status_array( $reg_status = '' ) { |
|
| 530 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 531 | - return EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
| 532 | - ? EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
| 529 | + protected static function _get_reg_status_array($reg_status = '') { |
|
| 530 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 531 | + return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
| 532 | + ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
| 533 | 533 | : EEH_MSG_Template::reg_status_to_message_type_array(); |
| 534 | 534 | } |
| 535 | 535 | |
@@ -545,10 +545,10 @@ discard block |
||
| 545 | 545 | * |
| 546 | 546 | * @return string|bool The payment message type slug matching the status or false if no match. |
| 547 | 547 | */ |
| 548 | - protected static function _get_payment_message_type( $payment_status ) { |
|
| 549 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 550 | - return EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
| 551 | - ? EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
| 548 | + protected static function _get_payment_message_type($payment_status) { |
|
| 549 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 550 | + return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
| 551 | + ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
| 552 | 552 | : false; |
| 553 | 553 | } |
| 554 | 554 | |
@@ -562,33 +562,33 @@ discard block |
||
| 562 | 562 | * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
| 563 | 563 | * @return bool success/fail |
| 564 | 564 | */ |
| 565 | - public static function process_resend( $req_data ) { |
|
| 565 | + public static function process_resend($req_data) { |
|
| 566 | 566 | self::_load_controller(); |
| 567 | 567 | |
| 568 | 568 | //if $msgID in this request then skip to the new resend_message |
| 569 | - if ( EE_Registry::instance()->REQ->get( 'MSG_ID' ) ) { |
|
| 569 | + if (EE_Registry::instance()->REQ->get('MSG_ID')) { |
|
| 570 | 570 | return self::resend_message(); |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | //make sure any incoming request data is set on the REQ so that it gets picked up later. |
| 574 | 574 | $req_data = (array) $req_data; |
| 575 | - foreach( $req_data as $request_key => $request_value ) { |
|
| 576 | - EE_Registry::instance()->REQ->set( $request_key, $request_value ); |
|
| 575 | + foreach ($req_data as $request_key => $request_value) { |
|
| 576 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() ) { |
|
| 579 | + if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) { |
|
| 580 | 580 | return false; |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | try { |
| 584 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $messages_to_send ); |
|
| 584 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
| 585 | 585 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
| 586 | - } catch( EE_Error $e ) { |
|
| 587 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 586 | + } catch (EE_Error $e) { |
|
| 587 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 588 | 588 | return false; |
| 589 | 589 | } |
| 590 | 590 | EE_Error::add_success( |
| 591 | - __( 'Messages have been successfully queued for generation and sending.', 'event_espresso' ) |
|
| 591 | + __('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
| 592 | 592 | ); |
| 593 | 593 | return true; //everything got queued. |
| 594 | 594 | } |
@@ -601,17 +601,17 @@ discard block |
||
| 601 | 601 | public static function resend_message() { |
| 602 | 602 | self::_load_controller(); |
| 603 | 603 | |
| 604 | - $msgID = EE_Registry::instance()->REQ->get( 'MSG_ID' ); |
|
| 605 | - if ( ! $msgID ) { |
|
| 606 | - EE_Error::add_error( __( 'Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 604 | + $msgID = EE_Registry::instance()->REQ->get('MSG_ID'); |
|
| 605 | + if ( ! $msgID) { |
|
| 606 | + EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 607 | 607 | return false; |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( (array) $msgID ); |
|
| 610 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
| 611 | 611 | |
| 612 | 612 | //setup success message. |
| 613 | - $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
| 614 | - EE_Error::add_success( sprintf( |
|
| 613 | + $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
| 614 | + EE_Error::add_success(sprintf( |
|
| 615 | 615 | _n( |
| 616 | 616 | 'There was %d message queued for resending.', |
| 617 | 617 | 'There were %d messages queued for resending.', |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | 'event_espresso' |
| 620 | 620 | ), |
| 621 | 621 | $count_ready_for_resend |
| 622 | - ) ); |
|
| 622 | + )); |
|
| 623 | 623 | return true; |
| 624 | 624 | } |
| 625 | 625 | |
@@ -632,13 +632,13 @@ discard block |
||
| 632 | 632 | * @param EE_Payment $payment EE_payment object |
| 633 | 633 | * @return bool success/fail |
| 634 | 634 | */ |
| 635 | - public static function process_admin_payment( EE_Payment $payment ) { |
|
| 636 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 635 | + public static function process_admin_payment(EE_Payment $payment) { |
|
| 636 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 637 | 637 | //we need to get the transaction object |
| 638 | 638 | $transaction = $payment->transaction(); |
| 639 | - if ( $transaction instanceof EE_Transaction ) { |
|
| 640 | - $data = array( $transaction, $payment ); |
|
| 641 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
| 639 | + if ($transaction instanceof EE_Transaction) { |
|
| 640 | + $data = array($transaction, $payment); |
|
| 641 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
| 642 | 642 | |
| 643 | 643 | //if payment amount is less than 0 then switch to payment_refund message type. |
| 644 | 644 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
@@ -648,17 +648,17 @@ discard block |
||
| 648 | 648 | |
| 649 | 649 | self::_load_controller(); |
| 650 | 650 | |
| 651 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
| 651 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
| 652 | 652 | |
| 653 | 653 | //get count of queued for generation |
| 654 | - $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
| 654 | + $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
| 655 | 655 | |
| 656 | - if ( $count_to_generate > 0 ) { |
|
| 657 | - add_filter( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true' ); |
|
| 656 | + if ($count_to_generate > 0) { |
|
| 657 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
| 658 | 658 | return true; |
| 659 | 659 | } else { |
| 660 | - $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::instance()->stati_indicating_failed_sending() ); |
|
| 661 | - EE_Error::add_error( sprintf( |
|
| 660 | + $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending()); |
|
| 661 | + EE_Error::add_error(sprintf( |
|
| 662 | 662 | _n( |
| 663 | 663 | 'The payment notification generation failed.', |
| 664 | 664 | '%d payment notifications failed being sent.', |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | 'event_espresso' |
| 667 | 667 | ), |
| 668 | 668 | $count_failed |
| 669 | - ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 669 | + ), __FILE__, __FUNCTION__, __LINE__); |
|
| 670 | 670 | return false; |
| 671 | 671 | } |
| 672 | 672 | } else { |
@@ -689,11 +689,11 @@ discard block |
||
| 689 | 689 | * @param int $grp_id a specific message template group id. |
| 690 | 690 | * @return void |
| 691 | 691 | */ |
| 692 | - public static function send_newsletter_message( $contacts, $grp_id ) { |
|
| 692 | + public static function send_newsletter_message($contacts, $grp_id) { |
|
| 693 | 693 | //make sure mtp is id and set it in the EE_Request Handler later messages setup. |
| 694 | - EE_Registry::instance()->REQ->set( 'GRP_ID', (int) $grp_id ); |
|
| 694 | + EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id); |
|
| 695 | 695 | self::_load_controller(); |
| 696 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'newsletter', $contacts ); |
|
| 696 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $contacts); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | |
@@ -708,10 +708,10 @@ discard block |
||
| 708 | 708 | * @param string $message_type |
| 709 | 709 | * @return string |
| 710 | 710 | */ |
| 711 | - public static function registration_message_trigger_url( $registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice' ) { |
|
| 712 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 711 | + public static function registration_message_trigger_url($registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice') { |
|
| 712 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 713 | 713 | // whitelist $messenger |
| 714 | - switch ( $messenger ) { |
|
| 714 | + switch ($messenger) { |
|
| 715 | 715 | case 'pdf' : |
| 716 | 716 | $sending_messenger = 'pdf'; |
| 717 | 717 | $generating_messenger = 'html'; |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | break; |
| 724 | 724 | } |
| 725 | 725 | // whitelist $message_type |
| 726 | - switch ( $message_type ) { |
|
| 726 | + switch ($message_type) { |
|
| 727 | 727 | case 'receipt' : |
| 728 | 728 | $message_type = 'receipt'; |
| 729 | 729 | break; |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | break; |
| 734 | 734 | } |
| 735 | 735 | // verify that both the messenger AND the message type are active |
| 736 | - if ( EEH_MSG_Template::is_messenger_active( $sending_messenger ) && EEH_MSG_Template::is_mt_active( $message_type ) ) { |
|
| 736 | + if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) { |
|
| 737 | 737 | //need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?) |
| 738 | 738 | $template_query_params = array( |
| 739 | 739 | 'MTP_is_active' => true, |
@@ -742,16 +742,16 @@ discard block |
||
| 742 | 742 | 'Event.EVT_ID' => $registration->event_ID() |
| 743 | 743 | ); |
| 744 | 744 | //get the message template group. |
| 745 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
| 745 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
| 746 | 746 | //if we don't have an EE_Message_Template_Group then return |
| 747 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
| 747 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
| 748 | 748 | // remove EVT_ID from query params so that global templates get picked up |
| 749 | - unset( $template_query_params['Event.EVT_ID'] ); |
|
| 749 | + unset($template_query_params['Event.EVT_ID']); |
|
| 750 | 750 | //get global template as the fallback |
| 751 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
| 751 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
| 752 | 752 | } |
| 753 | 753 | //if we don't have an EE_Message_Template_Group then return |
| 754 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
| 754 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
| 755 | 755 | return ''; |
| 756 | 756 | } |
| 757 | 757 | // generate the URL |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
| 781 | 781 | * @return string The body of the message. |
| 782 | 782 | */ |
| 783 | - public static function preview_message( $type, $context, $messenger, $send = false ) { |
|
| 783 | + public static function preview_message($type, $context, $messenger, $send = false) { |
|
| 784 | 784 | self::_load_controller(); |
| 785 | 785 | $mtg = new EE_Message_To_Generate( |
| 786 | 786 | $messenger, |
@@ -789,8 +789,8 @@ discard block |
||
| 789 | 789 | $context, |
| 790 | 790 | true |
| 791 | 791 | ); |
| 792 | - $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview( $mtg ); |
|
| 793 | - if ( $generated_preview_queue instanceof EE_Messages_Queue ) { |
|
| 792 | + $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg); |
|
| 793 | + if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
| 794 | 794 | return $generated_preview_queue->get_queue()->current()->content(); |
| 795 | 795 | } else { |
| 796 | 796 | return $generated_preview_queue; |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | * |
| 818 | 818 | * @return bool success or fail. |
| 819 | 819 | */ |
| 820 | - public static function send_message_with_messenger_only( $messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '' ) { |
|
| 820 | + public static function send_message_with_messenger_only($messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '') { |
|
| 821 | 821 | self::_load_controller(); |
| 822 | 822 | /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
| 823 | 823 | $message_to_generate = EE_Registry::instance()->load_lib( |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | $custom_subject, |
| 830 | 830 | ) |
| 831 | 831 | ); |
| 832 | - return self::$_MSG_PROCESSOR->queue_for_sending( $message_to_generate ); |
|
| 832 | + return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | |
@@ -842,22 +842,22 @@ discard block |
||
| 842 | 842 | * @param array $message_ids An array of message ids |
| 843 | 843 | * @return bool | EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated messages. |
| 844 | 844 | */ |
| 845 | - public static function generate_now( $message_ids ) { |
|
| 845 | + public static function generate_now($message_ids) { |
|
| 846 | 846 | self::_load_controller(); |
| 847 | 847 | $messages = EEM_Message::instance()->get_all( |
| 848 | 848 | array( |
| 849 | 849 | 0 => array( |
| 850 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
| 850 | + 'MSG_ID' => array('IN', $message_ids), |
|
| 851 | 851 | 'STS_ID' => EEM_Message::status_incomplete, |
| 852 | 852 | ) |
| 853 | 853 | ) |
| 854 | 854 | ); |
| 855 | 855 | |
| 856 | - $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue( $messages ); |
|
| 856 | + $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
| 857 | 857 | |
| 858 | - if ( ! $generated_queue instanceof EE_Messages_Queue ) { |
|
| 858 | + if ( ! $generated_queue instanceof EE_Messages_Queue) { |
|
| 859 | 859 | EE_Error::add_error( |
| 860 | - __( 'The messages were not generated. This is usually because there is already a batch being generated on a separate request. You can wait a minute or two and try again.', 'event_espresso' ), |
|
| 860 | + __('The messages were not generated. This is usually because there is already a batch being generated on a separate request. You can wait a minute or two and try again.', 'event_espresso'), |
|
| 861 | 861 | __FILE__, __FUNCTION__, __LINE__ |
| 862 | 862 | ); |
| 863 | 863 | } |
@@ -876,28 +876,28 @@ discard block |
||
| 876 | 876 | * |
| 877 | 877 | * @return bool | EE_Messages_Queue false if no messages sent. |
| 878 | 878 | */ |
| 879 | - public static function send_now( $message_ids ) { |
|
| 879 | + public static function send_now($message_ids) { |
|
| 880 | 880 | self::_load_controller(); |
| 881 | 881 | $messages = EEM_Message::instance()->get_all( |
| 882 | 882 | array( |
| 883 | 883 | 0 => array( |
| 884 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
| 885 | - 'STS_ID' => array( 'IN', array( EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry ) ) |
|
| 884 | + 'MSG_ID' => array('IN', $message_ids), |
|
| 885 | + 'STS_ID' => array('IN', array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry)) |
|
| 886 | 886 | ) |
| 887 | 887 | ) |
| 888 | 888 | ); |
| 889 | 889 | |
| 890 | - $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue( $messages ); |
|
| 890 | + $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
| 891 | 891 | |
| 892 | - if ( ! $sent_queue instanceof EE_Messages_Queue ) { |
|
| 892 | + if ( ! $sent_queue instanceof EE_Messages_Queue) { |
|
| 893 | 893 | EE_Error::add_error( |
| 894 | - __( 'The messages were not sent. This is usually because there is already a batch being sent on a separate request. You can wait a minute or two and try again.', 'event_espresso' ), |
|
| 894 | + __('The messages were not sent. This is usually because there is already a batch being sent on a separate request. You can wait a minute or two and try again.', 'event_espresso'), |
|
| 895 | 895 | __FILE__, __FUNCTION__, __LINE__ |
| 896 | 896 | ); |
| 897 | 897 | } else { |
| 898 | 898 | //can count how many sent by using the messages in the queue |
| 899 | - $sent_count = $sent_queue->count_STS_in_queue( EEM_Message::instance()->stati_indicating_sent() ); |
|
| 900 | - if ( $sent_count > 0 ) { |
|
| 899 | + $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
| 900 | + if ($sent_count > 0) { |
|
| 901 | 901 | EE_Error::add_success( |
| 902 | 902 | sprintf( |
| 903 | 903 | _n( |
@@ -912,8 +912,8 @@ discard block |
||
| 912 | 912 | } else { |
| 913 | 913 | EE_Error::overwrite_errors(); |
| 914 | 914 | EE_Error::add_error( |
| 915 | - __( 'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
| 916 | - If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso' ), |
|
| 915 | + __('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
| 916 | + If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso'), |
|
| 917 | 917 | __FILE__, __FUNCTION__, __LINE__ |
| 918 | 918 | ); |
| 919 | 919 | } |
@@ -934,13 +934,13 @@ discard block |
||
| 934 | 934 | * |
| 935 | 935 | * @return bool true means messages were successfully queued for resending, false means none were queued for resending. |
| 936 | 936 | */ |
| 937 | - public static function queue_for_resending( $message_ids ) { |
|
| 937 | + public static function queue_for_resending($message_ids) { |
|
| 938 | 938 | self::_load_controller(); |
| 939 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( $message_ids ); |
|
| 939 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
| 940 | 940 | |
| 941 | 941 | //get queue and count |
| 942 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
| 943 | - if ( $queue_count > 0 ) { |
|
| 942 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
| 943 | + if ($queue_count > 0) { |
|
| 944 | 944 | EE_Error::add_success( |
| 945 | 945 | sprintf( |
| 946 | 946 | _n( |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | ); |
| 955 | 955 | } else { |
| 956 | 956 | EE_Error::add_error( |
| 957 | - __( 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso' ), |
|
| 957 | + __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso'), |
|
| 958 | 958 | __FILE__, __FUNCTION__, __LINE__ |
| 959 | 959 | ); |
| 960 | 960 | } |
@@ -976,17 +976,17 @@ discard block |
||
| 976 | 976 | * @param array $info |
| 977 | 977 | * @param bool $display_request |
| 978 | 978 | */ |
| 979 | - protected static function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) { |
|
| 980 | - EE_Registry::instance()->load_helper( 'Debug_Tools' ); |
|
| 981 | - if ( WP_DEBUG && false ) { |
|
| 982 | - if ( $transaction instanceof EE_Transaction ) { |
|
| 979 | + protected static function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) { |
|
| 980 | + EE_Registry::instance()->load_helper('Debug_Tools'); |
|
| 981 | + if (WP_DEBUG && false) { |
|
| 982 | + if ($transaction instanceof EE_Transaction) { |
|
| 983 | 983 | // don't serialize objects |
| 984 | - $info = EEH_Debug_Tools::strip_objects( $info ); |
|
| 984 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
| 985 | 985 | $info['TXN_status'] = $transaction->status_ID(); |
| 986 | 986 | $info['TXN_reg_steps'] = $transaction->reg_steps(); |
| 987 | - if ( $transaction->ID() ) { |
|
| 988 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
| 989 | - EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index ); |
|
| 987 | + if ($transaction->ID()) { |
|
| 988 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
| 989 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | } |
@@ -23,18 +23,18 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct() { |
| 25 | 25 | //register tasks (and make sure only registered once). |
| 26 | - if ( ! has_action( 'FHEE__EEH_Activation__get_cron_tasks', array( $this, 'register_scheduled_tasks' ) ) ) { |
|
| 27 | - add_action( 'FHEE__EEH_Activation__get_cron_tasks', array( $this, 'register_scheduled_tasks' ), 10 ); |
|
| 26 | + if ( ! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
| 27 | + add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | //register callbacks for scheduled events (but make sure they are set only once). |
| 31 | - if ( ! has_action( 'AHEE__EE_Messages_Scheduler__generation', array( 'EE_Messages_Scheduler', 'batch_generation' ) ) ) { |
|
| 32 | - add_action( 'AHEE__EE_Messages_Scheduler__generation', array( 'EE_Messages_Scheduler', 'batch_generation') ); |
|
| 33 | - add_action( 'AHEE__EE_Messages_Scheduler__sending', array( 'EE_Messages_Scheduler', 'batch_sending' ) ); |
|
| 31 | + if ( ! has_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation'))) { |
|
| 32 | + add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
| 33 | + add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | //add custom schedules |
| 37 | - add_filter( 'cron_schedules', array( $this, 'custom_schedules' ) ); |
|
| 37 | + add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
@@ -44,10 +44,10 @@ discard block |
||
| 44 | 44 | * Add custom schedules for wp_cron |
| 45 | 45 | * @param $schedules |
| 46 | 46 | */ |
| 47 | - public function custom_schedules( $schedules ) { |
|
| 47 | + public function custom_schedules($schedules) { |
|
| 48 | 48 | $schedules['ee_message_cron'] = array( |
| 49 | 49 | 'interval' => self::message_cron_schedule, |
| 50 | - 'display' => __( 'This is the cron time interval for EE Message schedules (defaults to once every 10 minutes)', 'event_espresso' ) |
|
| 50 | + 'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 10 minutes)', 'event_espresso') |
|
| 51 | 51 | ); |
| 52 | 52 | return $schedules; |
| 53 | 53 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param array $tasks already existing scheduled tasks |
| 59 | 59 | * @return array |
| 60 | 60 | */ |
| 61 | - public function register_scheduled_tasks( $tasks ) { |
|
| 61 | + public function register_scheduled_tasks($tasks) { |
|
| 62 | 62 | $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
| 63 | 63 | $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
| 64 | 64 | return $tasks; |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | * Note: The EED_Messages module has the handlers for these requests. |
| 71 | 71 | * @param string $task The task the request is being generated for. |
| 72 | 72 | */ |
| 73 | - public static function initiate_scheduled_non_blocking_request( $task ) { |
|
| 73 | + public static function initiate_scheduled_non_blocking_request($task) { |
|
| 74 | 74 | //create nonce (this ensures that only valid requests are accepted) |
| 75 | - $nonce = wp_create_nonce( 'EE_Messages_Scheduler_' . $task ); |
|
| 75 | + $nonce = wp_create_nonce('EE_Messages_Scheduler_'.$task); |
|
| 76 | 76 | $request_url = add_query_arg( |
| 77 | 77 | array( |
| 78 | 78 | 'ee' => 'msg_cron_trigger', |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | ); |
| 84 | 84 | $request_args = array( |
| 85 | 85 | 'timeout' => 300, |
| 86 | - 'blocking' => ( defined( 'DOING_CRON' ) && DOING_CRON ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? true : false, |
|
| 86 | + 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
| 87 | 87 | 'sslverify' => false, |
| 88 | 88 | 'redirection' => 10, |
| 89 | 89 | ); |
| 90 | - $response = wp_remote_get( $request_url, $request_args ); |
|
| 91 | - if ( is_wp_error( $response ) ) { |
|
| 92 | - trigger_error( $response->get_error_message() ); |
|
| 90 | + $response = wp_remote_get($request_url, $request_args); |
|
| 91 | + if (is_wp_error($response)) { |
|
| 92 | + trigger_error($response->get_error_message()); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event |
| 102 | 102 | */ |
| 103 | 103 | public static function batch_generation() { |
| 104 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( 'generate' ); |
|
| 104 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request('generate'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * Callback for scheduled AHEE__EE_Messages_Scheduler__sending |
| 112 | 112 | */ |
| 113 | 113 | public static function batch_sending() { |
| 114 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( 'send' ); |
|
| 114 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request('send'); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | } //end EE_Messages_Scheduler |
| 118 | 118 | \ No newline at end of file |