@@ -4,6 +4,7 @@ |
||
| 4 | 4 | * Overrides parent so it doesn't need to provide so many non-applicable fields |
| 5 | 5 | * @param string $table_column |
| 6 | 6 | * @param string $nicename |
| 7 | + * @param integer|null $default |
|
| 7 | 8 | */ |
| 8 | 9 | public function __construct($table_column, $nicename,$default) { |
| 9 | 10 | parent::__construct($table_column, $nicename, false, $default, null); |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | -abstract class EE_Primary_Key_Field_Base extends EE_Field_With_Model_Name{ |
|
| 2 | +abstract class EE_Primary_Key_Field_Base extends EE_Field_With_Model_Name { |
|
| 3 | 3 | /** |
| 4 | 4 | * Overrides parent so it doesn't need to provide so many non-applicable fields |
| 5 | 5 | * @param string $table_column |
| 6 | 6 | * @param string $nicename |
| 7 | 7 | */ |
| 8 | - public function __construct($table_column, $nicename,$default) { |
|
| 8 | + public function __construct($table_column, $nicename, $default) { |
|
| 9 | 9 | parent::__construct($table_column, $nicename, false, $default, null); |
| 10 | 10 | } |
| 11 | 11 | /** |
| 12 | 12 | * @param $table_alias |
| 13 | 13 | * @param $name |
| 14 | 14 | */ |
| 15 | - function _construct_finalize($table_alias, $name, $model_name){ |
|
| 15 | + function _construct_finalize($table_alias, $name, $model_name) { |
|
| 16 | 16 | $this->_model_name_pointed_to = $model_name; |
| 17 | 17 | parent::_construct_finalize($table_alias, $name, $model_name); |
| 18 | 18 | } |
@@ -4,6 +4,10 @@ |
||
| 4 | 4 | function get_wpdb_data_type(){ |
| 5 | 5 | return '%d'; |
| 6 | 6 | } |
| 7 | + |
|
| 8 | + /** |
|
| 9 | + * @param string $table_column |
|
| 10 | + */ |
|
| 7 | 11 | public function __construct($table_column, $nicename) { |
| 8 | 12 | parent::__construct($table_column, $nicename, 0); |
| 9 | 13 | } |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | -require_once( EE_MODELS . 'fields/EE_Primary_Key_Field_Base.php'); |
|
| 3 | -class EE_Primary_Key_Int_Field extends EE_Primary_Key_Field_Base{ |
|
| 4 | - function get_wpdb_data_type(){ |
|
| 2 | +require_once(EE_MODELS.'fields/EE_Primary_Key_Field_Base.php'); |
|
| 3 | +class EE_Primary_Key_Int_Field extends EE_Primary_Key_Field_Base { |
|
| 4 | + function get_wpdb_data_type() { |
|
| 5 | 5 | return '%d'; |
| 6 | 6 | } |
| 7 | 7 | public function __construct($table_column, $nicename) { |
| 8 | 8 | parent::__construct($table_column, $nicename, 0); |
| 9 | 9 | } |
| 10 | 10 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
| 11 | - if($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)){ |
|
| 11 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
| 12 | 12 | $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
| 13 | 13 | } |
| 14 | 14 | return absint($value_inputted_for_field_on_model_object); |
@@ -4,6 +4,10 @@ |
||
| 4 | 4 | function get_wpdb_data_type(){ |
| 5 | 5 | return '%s'; |
| 6 | 6 | } |
| 7 | + |
|
| 8 | + /** |
|
| 9 | + * @param string $table_column |
|
| 10 | + */ |
|
| 7 | 11 | public function __construct($table_column, $nicename) { |
| 8 | 12 | parent::__construct($table_column, $nicename, NULL); |
| 9 | 13 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once('EE_Primary_Key_Field_Base.php'); |
| 3 | -class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base{ |
|
| 4 | - function get_wpdb_data_type(){ |
|
| 3 | +class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base { |
|
| 4 | + function get_wpdb_data_type() { |
|
| 5 | 5 | return '%s'; |
| 6 | 6 | } |
| 7 | 7 | public function __construct($table_column, $nicename) { |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * @return string |
| 14 | 14 | */ |
| 15 | 15 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
| 16 | - if($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)){ |
|
| 16 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
| 17 | 17 | $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
| 18 | 18 | } |
| 19 | 19 | return wp_strip_all_tags($value_inputted_for_field_on_model_object); |
@@ -26,7 +26,6 @@ |
||
| 26 | 26 | * ) |
| 27 | 27 | * ) |
| 28 | 28 | * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
| 29 | - * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is set to true, it will be stored as an INT |
|
| 30 | 29 | */ |
| 31 | 30 | function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()){ |
| 32 | 31 | $this->_register_new_stati( $new_stati ); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -require_once( EE_MODELS . 'fields/EE_Enum_Text_Field.php' ); |
|
| 3 | -class EE_WP_Post_Status_Field extends EE_Enum_Text_Field{ |
|
| 2 | +require_once(EE_MODELS.'fields/EE_Enum_Text_Field.php'); |
|
| 3 | +class EE_WP_Post_Status_Field extends EE_Enum_Text_Field { |
|
| 4 | 4 | |
| 5 | 5 | protected $_wp_post_stati; |
| 6 | 6 | |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
| 29 | 29 | * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is set to true, it will be stored as an INT |
| 30 | 30 | */ |
| 31 | - function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()){ |
|
| 32 | - $this->_register_new_stati( $new_stati ); |
|
| 31 | + function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) { |
|
| 32 | + $this->_register_new_stati($new_stati); |
|
| 33 | 33 | $this->_set_allowed_enum_values(); |
| 34 | 34 | parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values); |
| 35 | 35 | } |
@@ -46,18 +46,18 @@ discard block |
||
| 46 | 46 | * @param array $new_stati statuses |
| 47 | 47 | * @return void |
| 48 | 48 | */ |
| 49 | - protected function _register_new_stati( $new_stati ) { |
|
| 49 | + protected function _register_new_stati($new_stati) { |
|
| 50 | 50 | |
| 51 | - foreach ( (array) $new_stati as $status_key => $status_args ) { |
|
| 51 | + foreach ((array) $new_stati as $status_key => $status_args) { |
|
| 52 | 52 | $args = array( |
| 53 | - 'label' => isset( $status_args['label'] ) ? $status_args['label'] : $status_key, |
|
| 54 | - 'public' => isset( $status_args['public'] ) && is_bool( $status_args['public'] ) ? $status_args['public'] : TRUE, |
|
| 55 | - 'exclude_from_search' => isset( $status_args['exclude_from_search'] ) && is_bool($status_args['exclude_from_search'] ) ? $status_args['exclude_from_search'] : FALSE, |
|
| 56 | - 'show_in_admin_all_list' => isset( $status_args['show_in_admin_all_list'] ) && is_bool( $status_args['show_in_admin_all_list'] ) ? $status_args['show_in_admin_all_list'] : FALSE, |
|
| 57 | - 'show_in_admin_status_list' => isset( $status_args['show_in_admin_status_list'] ) && is_bool( $status_args['show_in_admin_status_list'] ) ? $status_args['show_in_admin_status_list'] : TRUE, |
|
| 58 | - 'label_count' => isset( $status_args['label_count'] ) ? $status_args['label_count'] : '' |
|
| 53 | + 'label' => isset($status_args['label']) ? $status_args['label'] : $status_key, |
|
| 54 | + 'public' => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : TRUE, |
|
| 55 | + 'exclude_from_search' => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : FALSE, |
|
| 56 | + 'show_in_admin_all_list' => isset($status_args['show_in_admin_all_list']) && is_bool($status_args['show_in_admin_all_list']) ? $status_args['show_in_admin_all_list'] : FALSE, |
|
| 57 | + 'show_in_admin_status_list' => isset($status_args['show_in_admin_status_list']) && is_bool($status_args['show_in_admin_status_list']) ? $status_args['show_in_admin_status_list'] : TRUE, |
|
| 58 | + 'label_count' => isset($status_args['label_count']) ? $status_args['label_count'] : '' |
|
| 59 | 59 | ); |
| 60 | - register_post_status( $status_key, $status_args ); |
|
| 60 | + register_post_status($status_key, $status_args); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | global $wp_post_statuses; |
| 79 | 79 | $this->_wp_post_stati = $wp_post_statuses; |
| 80 | 80 | |
| 81 | - foreach( $this->_wp_post_stati as $post_status => $args_object ) { |
|
| 81 | + foreach ($this->_wp_post_stati as $post_status => $args_object) { |
|
| 82 | 82 | $this->_allowed_enum_values[$post_status] = $args_object->label; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param string $status What status object you want |
| 109 | 109 | * @return std_object the status object or FALSE if it doesn't exist. |
| 110 | 110 | */ |
| 111 | - public function get_status_object( $status ) { |
|
| 112 | - return isset( $this->_wp_post_stati[$status] ) ? $this->_wp_post_stati[$status] : FALSE; |
|
| 111 | + public function get_status_object($status) { |
|
| 112 | + return isset($this->_wp_post_stati[$status]) ? $this->_wp_post_stati[$status] : FALSE; |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | \ No newline at end of file |
@@ -43,16 +43,30 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | private $_group_by_sql; |
| 45 | 45 | |
| 46 | + /** |
|
| 47 | + * @param string $limit_sql |
|
| 48 | + */ |
|
| 46 | 49 | function set_limit_sql($limit_sql){ |
| 47 | 50 | $this->_limit_sql = $limit_sql; |
| 48 | 51 | } |
| 49 | 52 | |
| 53 | + /** |
|
| 54 | + * @param string $order_by_sql |
|
| 55 | + */ |
|
| 50 | 56 | function set_order_by_sql($order_by_sql){ |
| 51 | 57 | $this->_order_by_sql = $order_by_sql; |
| 52 | 58 | } |
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @param string $group_by_sql |
|
| 62 | + */ |
|
| 53 | 63 | function set_group_by_sql($group_by_sql){ |
| 54 | 64 | $this->_group_by_sql = $group_by_sql; |
| 55 | 65 | } |
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @param string $having_sql |
|
| 69 | + */ |
|
| 56 | 70 | function set_having_sql($having_sql){ |
| 57 | 71 | $this->_having_sql = $having_sql; |
| 58 | 72 | } |
@@ -72,7 +86,6 @@ discard block |
||
| 72 | 86 | * |
| 73 | 87 | * @param type $model_included_name |
| 74 | 88 | * @param type $join_sql |
| 75 | - * @param type $data_types |
|
| 76 | 89 | */ |
| 77 | 90 | public function __construct($model_included_name= array(), $join_sql = ''){ |
| 78 | 91 | $this->_models_included = $model_included_name; |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | class EE_Model_Query_Info_Carrier extends EE_Base{ |
| 13 | 13 | /** |
| 14 | - * @var string SQL for performing joins (Eg, "INNER JOIN blah ON blah=blah INNER JOIN FOO ON foo=foo...") |
|
| 15 | - */ |
|
| 14 | + * @var string SQL for performing joins (Eg, "INNER JOIN blah ON blah=blah INNER JOIN FOO ON foo=foo...") |
|
| 15 | + */ |
|
| 16 | 16 | private $_join_sql; |
| 17 | 17 | /** |
| 18 | 18 | * |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @return string |
| 133 | 133 | */ |
| 134 | 134 | public function get_main_model_join_sql() { |
| 135 | - return $this->_main_join_sql; |
|
| 135 | + return $this->_main_join_sql; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * We could have returned an array |
| 10 | 10 | * with two keys 'join_sql' and 'data_types', but this better-defines the data being passed around |
| 11 | 11 | */ |
| 12 | -class EE_Model_Query_Info_Carrier extends EE_Base{ |
|
| 12 | +class EE_Model_Query_Info_Carrier extends EE_Base { |
|
| 13 | 13 | /** |
| 14 | 14 | * @var string SQL for performing joins (Eg, "INNER JOIN blah ON blah=blah INNER JOIN FOO ON foo=foo...") |
| 15 | 15 | */ |
@@ -43,29 +43,29 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | private $_group_by_sql; |
| 45 | 45 | |
| 46 | - function set_limit_sql($limit_sql){ |
|
| 46 | + function set_limit_sql($limit_sql) { |
|
| 47 | 47 | $this->_limit_sql = $limit_sql; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - function set_order_by_sql($order_by_sql){ |
|
| 50 | + function set_order_by_sql($order_by_sql) { |
|
| 51 | 51 | $this->_order_by_sql = $order_by_sql; |
| 52 | 52 | } |
| 53 | - function set_group_by_sql($group_by_sql){ |
|
| 53 | + function set_group_by_sql($group_by_sql) { |
|
| 54 | 54 | $this->_group_by_sql = $group_by_sql; |
| 55 | 55 | } |
| 56 | - function set_having_sql($having_sql){ |
|
| 56 | + function set_having_sql($having_sql) { |
|
| 57 | 57 | $this->_having_sql = $having_sql; |
| 58 | 58 | } |
| 59 | - function get_limit_sql(){ |
|
| 59 | + function get_limit_sql() { |
|
| 60 | 60 | return $this->_limit_sql; |
| 61 | 61 | } |
| 62 | - function get_order_by_sql(){ |
|
| 62 | + function get_order_by_sql() { |
|
| 63 | 63 | return $this->_order_by_sql; |
| 64 | 64 | } |
| 65 | - function get_group_by_sql(){ |
|
| 65 | + function get_group_by_sql() { |
|
| 66 | 66 | return $this->_group_by_sql; |
| 67 | 67 | } |
| 68 | - function get_having_sql(){ |
|
| 68 | + function get_having_sql() { |
|
| 69 | 69 | return $this->_having_sql; |
| 70 | 70 | } |
| 71 | 71 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param type $join_sql |
| 75 | 75 | * @param type $data_types |
| 76 | 76 | */ |
| 77 | - public function __construct($model_included_name= array(), $join_sql = ''){ |
|
| 77 | + public function __construct($model_included_name = array(), $join_sql = '') { |
|
| 78 | 78 | $this->_models_included = $model_included_name; |
| 79 | 79 | $this->_join_sql = $join_sql; |
| 80 | 80 | } |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | * Merges info from the other EEM_Related_Model_Info_Carrier into this one. |
| 84 | 84 | * @param EE_Model_Query_Info_Carrier $other_model_query_info_carrier |
| 85 | 85 | */ |
| 86 | - public function merge( $other_model_query_info_carrier ){ |
|
| 87 | - if( $other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())){ |
|
| 88 | - $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
| 89 | - $this->_models_included = array_merge( $this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier ); |
|
| 86 | + public function merge($other_model_query_info_carrier) { |
|
| 87 | + if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
|
| 88 | + $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
| 89 | + $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
|
| 90 | 90 | $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
| 91 | 91 | } |
| 92 | 92 | //otherwise don't merge our data. |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | * @param array $model_names just like EE_MOdel_QUery_Info_Carrier::_models_included: keys are model chain paths, values are the model names only |
| 101 | 101 | * @return boolean |
| 102 | 102 | */ |
| 103 | - protected function _have_already_included_one_of_these_models($model_names){ |
|
| 104 | - foreach($this->_models_included as $model_relation_path=>$model_included){ |
|
| 105 | - if(array_key_exists($model_relation_path, $model_names)){ |
|
| 103 | + protected function _have_already_included_one_of_these_models($model_names) { |
|
| 104 | + foreach ($this->_models_included as $model_relation_path=>$model_included) { |
|
| 105 | + if (array_key_exists($model_relation_path, $model_names)) { |
|
| 106 | 106 | return true; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -112,17 +112,17 @@ discard block |
||
| 112 | 112 | * Array keys are model names, values are "model relation paths". See EE_Model_Query_Info_Carrier::_models_included for details |
| 113 | 113 | * @return array like EE_Model_Query_Info_Carrier::_models_included |
| 114 | 114 | */ |
| 115 | - public function get_model_names_included(){ |
|
| 115 | + public function get_model_names_included() { |
|
| 116 | 116 | return $this->_models_included; |
| 117 | 117 | } |
| 118 | 118 | /** |
| 119 | 119 | * sets the $where_sql for later use from client code |
| 120 | 120 | * @param string $where_sql |
| 121 | 121 | */ |
| 122 | - public function set_where_sql($where_sql){ |
|
| 122 | + public function set_where_sql($where_sql) { |
|
| 123 | 123 | $this->_where_sql = $where_sql; |
| 124 | 124 | } |
| 125 | - public function get_where_sql(){ |
|
| 125 | + public function get_where_sql() { |
|
| 126 | 126 | return $this->_where_sql; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | * after the FROM and before the WHERE.) |
| 144 | 144 | * @param string $join_sql |
| 145 | 145 | */ |
| 146 | - public function set_main_model_join_sql($join_sql){ |
|
| 146 | + public function set_main_model_join_sql($join_sql) { |
|
| 147 | 147 | $this->_main_join_sql = $join_sql; |
| 148 | 148 | } |
| 149 | - public function get_full_join_sql(){ |
|
| 150 | - return $this->_main_join_sql . $this->_join_sql; |
|
| 149 | + public function get_full_join_sql() { |
|
| 150 | + return $this->_main_join_sql.$this->_join_sql; |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | \ No newline at end of file |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * creates join statement FROM primary table |
| 50 | 50 | * gets SQL like "LEFT JOIN table_name AS table_alias ON other_table_alias.pk = table_alias.fk |
| 51 | 51 | * |
| 52 | - * @param string $table allows us to set special conditions on the $table_name portion of the join query (i.e. doing a subquery) |
|
| 52 | + * @param string $primary_table_alias_with_model_chain_prefix |
|
| 53 | 53 | * @return string of SQL |
| 54 | 54 | */ |
| 55 | 55 | function get_join_sql( $primary_table_alias_with_model_chain_prefix ){ |
@@ -72,6 +72,7 @@ discard block |
||
| 72 | 72 | * " LEFT JOIN secondary_table_table AS Secondary ON ..." like get_join_sql, this function returns |
| 73 | 73 | * " LEFT JOIN primary_table AS Primary ON ...". |
| 74 | 74 | * This is useful if the secondary table is already included in the SQL, but the primary table is not yet. |
| 75 | + * @param string $secondary_table_alias_with_model_chain_prefix |
|
| 75 | 76 | * @return string |
| 76 | 77 | */ |
| 77 | 78 | function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix){ |
@@ -5,8 +5,8 @@ discard block |
||
| 5 | 5 | * table's rows. Ie, it can't have many rows in the secondary table that point to |
| 6 | 6 | * a single row in the primary table |
| 7 | 7 | */ |
| 8 | -require_once( EE_MODELS . 'helpers/EE_Table_Base.php'); |
|
| 9 | -class EE_Secondary_Table extends EE_Table_Base{ |
|
| 8 | +require_once(EE_MODELS.'helpers/EE_Table_Base.php'); |
|
| 9 | +class EE_Secondary_Table extends EE_Table_Base { |
|
| 10 | 10 | protected $_extra_join_conditions; |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -19,15 +19,15 @@ discard block |
||
| 19 | 19 | * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install, |
| 20 | 20 | * or whether each site on a multisite install has a copy of this table |
| 21 | 21 | */ |
| 22 | - function __construct($table_name, $pk_column, $fk_column = null, $extra_join_conditions = null, $global = false ){ |
|
| 22 | + function __construct($table_name, $pk_column, $fk_column = null, $extra_join_conditions = null, $global = false) { |
|
| 23 | 23 | $this->_fk_on_table = $fk_column; |
| 24 | 24 | $this->_extra_join_conditions = $extra_join_conditions; |
| 25 | - parent::__construct( $table_name, $pk_column, $global ); |
|
| 25 | + parent::__construct($table_name, $pk_column, $global); |
|
| 26 | 26 | } |
| 27 | - function get_fk_on_table(){ |
|
| 27 | + function get_fk_on_table() { |
|
| 28 | 28 | return $this->_fk_on_table; |
| 29 | 29 | } |
| 30 | - function _construct_finalize_set_table_to_join_with(EE_Table_Base $table){ |
|
| 30 | + function _construct_finalize_set_table_to_join_with(EE_Table_Base $table) { |
|
| 31 | 31 | $this->_table_to_join_with = $table; |
| 32 | 32 | } |
| 33 | 33 | /** |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | * @return string of sql like "Event.post_type = 'event'", which gets added to |
| 36 | 36 | * the end of the join statement with the primary table |
| 37 | 37 | */ |
| 38 | - function get_extra_join_conditions(){ |
|
| 38 | + function get_extra_join_conditions() { |
|
| 39 | 39 | return $this->_extra_join_conditions; |
| 40 | 40 | } |
| 41 | 41 | /** |
| 42 | 42 | * |
| 43 | 43 | * @return EE_Primary_Table |
| 44 | 44 | */ |
| 45 | - function get_table_to_join_with(){ |
|
| 45 | + function get_table_to_join_with() { |
|
| 46 | 46 | return $this->_table_to_join_with; |
| 47 | 47 | } |
| 48 | 48 | /** |
@@ -52,15 +52,15 @@ discard block |
||
| 52 | 52 | * @param string $table allows us to set special conditions on the $table_name portion of the join query (i.e. doing a subquery) |
| 53 | 53 | * @return string of SQL |
| 54 | 54 | */ |
| 55 | - function get_join_sql( $primary_table_alias_with_model_chain_prefix ){ |
|
| 55 | + function get_join_sql($primary_table_alias_with_model_chain_prefix) { |
|
| 56 | 56 | |
| 57 | 57 | $table_name = $this->get_table_name(); |
| 58 | - $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix) . $this->get_table_alias(); |
|
| 58 | + $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix).$this->get_table_alias(); |
|
| 59 | 59 | $other_table_pk = $this->get_table_to_join_with()->get_pk_column(); |
| 60 | 60 | $fk = $this->get_fk_on_table(); |
| 61 | 61 | $join_sql = " LEFT JOIN $table_name AS $secondary_table_alias ON $primary_table_alias_with_model_chain_prefix.$other_table_pk = $secondary_table_alias.$fk "; |
| 62 | - if($this->get_extra_join_conditions()){ |
|
| 63 | - $join_sql.="AND ".$this->get_extra_join_conditions(); |
|
| 62 | + if ($this->get_extra_join_conditions()) { |
|
| 63 | + $join_sql .= "AND ".$this->get_extra_join_conditions(); |
|
| 64 | 64 | } |
| 65 | 65 | return $join_sql; |
| 66 | 66 | } |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | * This is useful if the secondary table is already included in the SQL, but the primary table is not yet. |
| 75 | 75 | * @return string |
| 76 | 76 | */ |
| 77 | - function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix){ |
|
| 78 | - $primary_table_name =$this->get_table_to_join_with()->get_table_name(); |
|
| 79 | - $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix) . $this->get_table_to_join_with()->get_table_alias(); |
|
| 80 | - $primary_table_pk = $this->get_table_to_join_with()->get_pk_column();//$this->get_pk_column(); |
|
| 77 | + function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix) { |
|
| 78 | + $primary_table_name = $this->get_table_to_join_with()->get_table_name(); |
|
| 79 | + $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix).$this->get_table_to_join_with()->get_table_alias(); |
|
| 80 | + $primary_table_pk = $this->get_table_to_join_with()->get_pk_column(); //$this->get_pk_column(); |
|
| 81 | 81 | $fk = $this->get_fk_on_table(); |
| 82 | 82 | $join_sql = " LEFT JOIN $primary_table_name AS $primary_table_alias ON $primary_table_alias.$primary_table_pk = $secondary_table_alias_with_model_chain_prefix.$fk "; |
| 83 | - if($this->get_extra_join_conditions()){ |
|
| 84 | - $join_sql.="AND ".$this->get_extra_join_conditions(); |
|
| 83 | + if ($this->get_extra_join_conditions()) { |
|
| 84 | + $join_sql .= "AND ".$this->get_extra_join_conditions(); |
|
| 85 | 85 | } |
| 86 | 86 | return $join_sql; |
| 87 | 87 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | public function get_select_join_limit_join($limit) { |
| 95 | 95 | //first get the select |
| 96 | 96 | $select = $this->get_select_join_limit($limit); |
| 97 | - $join_sql = $this->get_join_sql( $select ); |
|
| 97 | + $join_sql = $this->get_join_sql($select); |
|
| 98 | 98 | return $join_sql; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -103,12 +103,12 @@ discard block |
||
| 103 | 103 | function get_fully_qualified_fk_column() { |
| 104 | 104 | $table_alias = $this->get_table_alias(); |
| 105 | 105 | $fk = $this->get_fk_on_table(); |
| 106 | - return $table_alias . '.' . $fk; |
|
| 106 | + return $table_alias.'.'.$fk; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | function get_fully_qualified_pk_on_fk_table() { |
| 110 | 110 | $table_alias = $this->get_table_to_join_with()->get_table_alias(); |
| 111 | 111 | $pk = $this->get_table_to_join_with()->get_pk_column(); |
| 112 | - return $table_alias . '.' . $pk; |
|
| 112 | + return $table_alias.'.'.$pk; |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | \ No newline at end of file |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | * @since 4.5.0 |
| 558 | 558 | * |
| 559 | 559 | * @param string $meta_cap What meta capability is this mapping. |
| 560 | - * @param array $map_values array { |
|
| 560 | + * @param string[] $map_values array { |
|
| 561 | 561 | * //array of values that MUST match a count of 4. It's okay to send an empty string for capabilities that don't get mapped to. |
| 562 | 562 | * @type $map_values[0] string A string representing the model name. Required. String's |
| 563 | 563 | * should always be used when Menu Maps are registered via the |
@@ -625,8 +625,8 @@ discard block |
||
| 625 | 625 | * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
| 626 | 626 | * @since 4.6.x |
| 627 | 627 | * @param $caps |
| 628 | - * @param $cap |
|
| 629 | - * @param $user_id |
|
| 628 | + * @param string $cap |
|
| 629 | + * @param integer $user_id |
|
| 630 | 630 | * @param $args |
| 631 | 631 | * |
| 632 | 632 | * @return array |
@@ -113,7 +113,6 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * This sets the meta caps property. |
| 116 | - |
|
| 117 | 116 | * @since 4.5.0 |
| 118 | 117 | * |
| 119 | 118 | * @return void |
@@ -227,7 +226,7 @@ discard block |
||
| 227 | 226 | * capability mapping which will be used for accessing payment methods owned by |
| 228 | 227 | * other users. This is not fully implemented yet in the payment method ui. |
| 229 | 228 | * Currently only the "plural" caps are in active use. (Specific payment method caps are in use as well). |
| 230 | - **/ |
|
| 229 | + **/ |
|
| 231 | 230 | 'ee_manage_gateways', |
| 232 | 231 | 'ee_read_payment_method', |
| 233 | 232 | 'ee_read_payment_methods', |
@@ -739,15 +738,15 @@ discard block |
||
| 739 | 738 | } |
| 740 | 739 | } |
| 741 | 740 | } else { |
| 742 | - //not a cpt object so handled differently |
|
| 743 | - $has_cap = false; |
|
| 744 | - try { |
|
| 745 | - $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user(); |
|
| 746 | - } catch (Exception $e) { |
|
| 747 | - if (WP_DEBUG) { |
|
| 748 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 749 | - } |
|
| 750 | - } |
|
| 741 | + //not a cpt object so handled differently |
|
| 742 | + $has_cap = false; |
|
| 743 | + try { |
|
| 744 | + $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user(); |
|
| 745 | + } catch (Exception $e) { |
|
| 746 | + if (WP_DEBUG) { |
|
| 747 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 748 | + } |
|
| 749 | + } |
|
| 751 | 750 | if ($has_cap) { |
| 752 | 751 | $caps[] = $cap; |
| 753 | 752 | } else { |
@@ -854,15 +853,15 @@ discard block |
||
| 854 | 853 | $caps[] = $cap; |
| 855 | 854 | } |
| 856 | 855 | } else { |
| 857 | - //not a cpt object so handled differently |
|
| 858 | - $has_cap = false; |
|
| 859 | - try { |
|
| 860 | - $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user(); |
|
| 861 | - } catch (Exception $e) { |
|
| 862 | - if (WP_DEBUG) { |
|
| 863 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 864 | - } |
|
| 865 | - } |
|
| 856 | + //not a cpt object so handled differently |
|
| 857 | + $has_cap = false; |
|
| 858 | + try { |
|
| 859 | + $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user(); |
|
| 860 | + } catch (Exception $e) { |
|
| 861 | + if (WP_DEBUG) { |
|
| 862 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 863 | + } |
|
| 864 | + } |
|
| 866 | 865 | if ($has_cap) { |
| 867 | 866 | $caps[] = $cap; |
| 868 | 867 | } elseif ( ! empty( $this->private_cap ) ) { |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | * @package Event Espresso |
| 8 | 8 | * @subpackage core, capabilities |
| 9 | 9 | */ |
| 10 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 11 | - exit( 'No direct script access allowed' ); |
|
| 10 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 11 | + exit('No direct script access allowed'); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public static function instance() { |
| 73 | 73 | //check if instantiated, and if not do so. |
| 74 | - if ( ! self::$_instance instanceof EE_Capabilities ) { |
|
| 74 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
| 75 | 75 | self::$_instance = new self(); |
| 76 | 76 | } |
| 77 | 77 | return self::$_instance; |
@@ -100,10 +100,10 @@ discard block |
||
| 100 | 100 | * @since 4.5.0 |
| 101 | 101 | * @return void |
| 102 | 102 | */ |
| 103 | - public function init_caps( $reset = false ) { |
|
| 104 | - if ( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
| 103 | + public function init_caps($reset = false) { |
|
| 104 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 105 | 105 | $this->_caps_map = $this->_init_caps_map(); |
| 106 | - $this->init_role_caps( $reset ); |
|
| 106 | + $this->init_role_caps($reset); |
|
| 107 | 107 | $this->_set_meta_caps(); |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
| 123 | 123 | $this->_meta_caps = $this->_get_default_meta_caps_array(); |
| 124 | 124 | |
| 125 | - $this->_meta_caps = apply_filters( 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps ); |
|
| 125 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
| 126 | 126 | |
| 127 | 127 | //add filter for map_meta_caps but only if models can query. |
| 128 | - if ( EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ) ) ) { |
|
| 129 | - add_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10, 4 ); |
|
| 128 | + if (EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
| 129 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
@@ -139,37 +139,37 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | private function _get_default_meta_caps_array() { |
| 141 | 141 | static $default_meta_caps = array(); |
| 142 | - if ( empty( $default_meta_caps ) ) { |
|
| 142 | + if (empty($default_meta_caps)) { |
|
| 143 | 143 | $default_meta_caps = array( |
| 144 | 144 | //edits |
| 145 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_event', array( 'Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events' ) ), |
|
| 146 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_venue', array( 'Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues' ) ), |
|
| 147 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_registration', array( 'Registration', '', 'ee_edit_others_registrations', '' ) ), |
|
| 148 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_checkin', array( 'Registration', '', 'ee_edit_others_checkins', '' ) ), |
|
| 149 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_edit_message', array( 'Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages' ) ), |
|
| 150 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_default_ticket', array( 'Ticket', '', 'ee_edit_others_default_tickets', '' ) ), |
|
| 151 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question', array( 'Question', '', '', 'ee_edit_system_questions' ) ), |
|
| 152 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question_group', array( 'Question_Group', '', '', 'ee_edit_system_question_groups' ) ), |
|
| 153 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_payment_method', array( 'Payment_Method', '', 'ee_edit_others_payment_methods', '' ) ), |
|
| 145 | + new EE_Meta_Capability_Map_Edit('ee_edit_event', array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')), |
|
| 146 | + new EE_Meta_Capability_Map_Edit('ee_edit_venue', array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')), |
|
| 147 | + new EE_Meta_Capability_Map_Edit('ee_edit_registration', array('Registration', '', 'ee_edit_others_registrations', '')), |
|
| 148 | + new EE_Meta_Capability_Map_Edit('ee_edit_checkin', array('Registration', '', 'ee_edit_others_checkins', '')), |
|
| 149 | + new EE_Meta_Capability_Map_Messages_Cap('ee_edit_message', array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')), |
|
| 150 | + new EE_Meta_Capability_Map_Edit('ee_edit_default_ticket', array('Ticket', '', 'ee_edit_others_default_tickets', '')), |
|
| 151 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question', array('Question', '', '', 'ee_edit_system_questions')), |
|
| 152 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question_group', array('Question_Group', '', '', 'ee_edit_system_question_groups')), |
|
| 153 | + new EE_Meta_Capability_Map_Edit('ee_edit_payment_method', array('Payment_Method', '', 'ee_edit_others_payment_methods', '')), |
|
| 154 | 154 | //reads |
| 155 | - new EE_Meta_Capability_Map_Read( 'ee_read_event', array( 'Event', '', 'ee_read_others_events', 'ee_read_private_events' ) ), |
|
| 156 | - new EE_Meta_Capability_Map_Read( 'ee_read_venue', array( 'Venue', '', 'ee_read_others_venues', 'ee_read_private_venues' ) ), |
|
| 157 | - new EE_Meta_Capability_Map_Read( 'ee_read_registration', array( 'Registration', '', '', 'ee_edit_others_registrations' ) ), |
|
| 158 | - new EE_Meta_Capability_Map_Read( 'ee_read_checkin', array( 'Registration', '', '', 'ee_read_others_checkins' ) ), |
|
| 159 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_read_message', array( 'Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages' ) ), |
|
| 160 | - new EE_Meta_Capability_Map_Read( 'ee_read_default_ticket', array( 'Ticket', '', '', 'ee_read_others_default_tickets' ) ), |
|
| 161 | - new EE_Meta_Capability_Map_Read( 'ee_read_payment_method', array( 'Payment_Method', '', '', 'ee_read_others_payment_methods' ) ), |
|
| 155 | + new EE_Meta_Capability_Map_Read('ee_read_event', array('Event', '', 'ee_read_others_events', 'ee_read_private_events')), |
|
| 156 | + new EE_Meta_Capability_Map_Read('ee_read_venue', array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')), |
|
| 157 | + new EE_Meta_Capability_Map_Read('ee_read_registration', array('Registration', '', '', 'ee_edit_others_registrations')), |
|
| 158 | + new EE_Meta_Capability_Map_Read('ee_read_checkin', array('Registration', '', '', 'ee_read_others_checkins')), |
|
| 159 | + new EE_Meta_Capability_Map_Messages_Cap('ee_read_message', array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')), |
|
| 160 | + new EE_Meta_Capability_Map_Read('ee_read_default_ticket', array('Ticket', '', '', 'ee_read_others_default_tickets')), |
|
| 161 | + new EE_Meta_Capability_Map_Read('ee_read_payment_method', array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
| 162 | 162 | |
| 163 | 163 | //deletes |
| 164 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_event', array( 'Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events' ) ), |
|
| 165 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_venue', array( 'Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues' ) ), |
|
| 166 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_registration', array( 'Registration', '', 'ee_delete_others_registrations', '' ) ), |
|
| 167 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_checkin', array( 'Registration', '', 'ee_delete_others_checkins', '' ) ), |
|
| 168 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_delete_message', array( 'Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages' ) ), |
|
| 169 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_default_ticket', array( 'Ticket', '', 'ee_delete_others_default_tickets', '' ) ), |
|
| 170 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question', array( 'Question', '', '', 'delete_system_questions' ) ), |
|
| 171 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question_group', array( 'Question_Group', '', '', 'delete_system_question_groups' ) ), |
|
| 172 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_payment_method', array( 'Payment_Method', '', 'ee_delete_others_payment_methods', '' ) ), |
|
| 164 | + new EE_Meta_Capability_Map_Delete('ee_delete_event', array('Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events')), |
|
| 165 | + new EE_Meta_Capability_Map_Delete('ee_delete_venue', array('Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues')), |
|
| 166 | + new EE_Meta_Capability_Map_Delete('ee_delete_registration', array('Registration', '', 'ee_delete_others_registrations', '')), |
|
| 167 | + new EE_Meta_Capability_Map_Delete('ee_delete_checkin', array('Registration', '', 'ee_delete_others_checkins', '')), |
|
| 168 | + new EE_Meta_Capability_Map_Messages_Cap('ee_delete_message', array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')), |
|
| 169 | + new EE_Meta_Capability_Map_Delete('ee_delete_default_ticket', array('Ticket', '', 'ee_delete_others_default_tickets', '')), |
|
| 170 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question', array('Question', '', '', 'delete_system_questions')), |
|
| 171 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question_group', array('Question_Group', '', '', 'delete_system_question_groups')), |
|
| 172 | + new EE_Meta_Capability_Map_Delete('ee_delete_payment_method', array('Payment_Method', '', 'ee_delete_others_payment_methods', '')), |
|
| 173 | 173 | ); |
| 174 | 174 | } |
| 175 | 175 | return $default_meta_caps; |
@@ -193,15 +193,15 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @return array actual users capabilities |
| 195 | 195 | */ |
| 196 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
| 196 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
| 197 | 197 | //loop through our _meta_caps array |
| 198 | - foreach ( $this->_meta_caps as $meta_map ) { |
|
| 199 | - if ( ! $meta_map instanceof EE_Meta_Capability_Map ) { |
|
| 198 | + foreach ($this->_meta_caps as $meta_map) { |
|
| 199 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
| 200 | 200 | continue; |
| 201 | 201 | } |
| 202 | 202 | $meta_map->ensure_is_model(); |
| 203 | 203 | |
| 204 | - $caps = $meta_map->map_meta_caps( $caps, $cap, $user_id, $args ); |
|
| 204 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
| 205 | 205 | } |
| 206 | 206 | return $caps; |
| 207 | 207 | } |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | ) |
| 529 | 529 | ); |
| 530 | 530 | |
| 531 | - $caps = apply_filters( 'FHEE__EE_Capabilities__init_caps_map__caps', $caps ); |
|
| 531 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
| 532 | 532 | return $caps; |
| 533 | 533 | } |
| 534 | 534 | |
@@ -545,27 +545,27 @@ discard block |
||
| 545 | 545 | * |
| 546 | 546 | * @return void |
| 547 | 547 | */ |
| 548 | - public function init_role_caps( $reset = false, $custom_map = array() ) { |
|
| 548 | + public function init_role_caps($reset = false, $custom_map = array()) { |
|
| 549 | 549 | |
| 550 | - $caps_map = empty( $custom_map ) ? $this->_caps_map : $custom_map; |
|
| 550 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
| 551 | 551 | |
| 552 | 552 | //first let's determine if these caps have already been set. |
| 553 | - $caps_set_before = get_option( self::option_name, array() ); |
|
| 553 | + $caps_set_before = get_option(self::option_name, array()); |
|
| 554 | 554 | //if not reset, see what caps are new for each role. if they're new, add them. |
| 555 | - foreach ( $caps_map as $role => $caps_for_role ) { |
|
| 556 | - foreach ( $caps_for_role as $cap ) { |
|
| 555 | + foreach ($caps_map as $role => $caps_for_role) { |
|
| 556 | + foreach ($caps_for_role as $cap) { |
|
| 557 | 557 | //first check we haven't already added this cap before, or it's a reset |
| 558 | - if ( $reset || ! isset( $caps_set_before[ $role ] ) || ! in_array( $cap, $caps_set_before[ $role ] ) ) { |
|
| 559 | - if ( $this->add_cap_to_role( $role, $cap ) ) { |
|
| 560 | - $caps_set_before[ $role ][] = $cap; |
|
| 558 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
| 559 | + if ($this->add_cap_to_role($role, $cap)) { |
|
| 560 | + $caps_set_before[$role][] = $cap; |
|
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | //now let's just save the cap that has been set. |
| 567 | - update_option( self::option_name, $caps_set_before ); |
|
| 568 | - do_action( 'AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before ); |
|
| 567 | + update_option(self::option_name, $caps_set_before); |
|
| 568 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | |
@@ -584,20 +584,20 @@ discard block |
||
| 584 | 584 | * @param bool $grant Whether to grant access to this cap on this role. |
| 585 | 585 | * @return bool |
| 586 | 586 | */ |
| 587 | - public function add_cap_to_role( $role, $cap, $grant = true ) { |
|
| 588 | - $role_object = get_role( $role ); |
|
| 587 | + public function add_cap_to_role($role, $cap, $grant = true) { |
|
| 588 | + $role_object = get_role($role); |
|
| 589 | 589 | //if the role isn't available then we create it. |
| 590 | - if ( ! $role_object instanceof WP_Role ) { |
|
| 590 | + if ( ! $role_object instanceof WP_Role) { |
|
| 591 | 591 | //if a plugin wants to create a specific role name then they should create the role before |
| 592 | 592 | //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
| 593 | 593 | // - removes any `ee_` namespacing from the start of the slug. |
| 594 | 594 | // - replaces `_` with ` ` (empty space). |
| 595 | 595 | // - sentence case on the resulting string. |
| 596 | - $role_label = ucwords( str_replace( '_', ' ', str_replace( 'ee_', '', $role ) ) ); |
|
| 597 | - $role_object = add_role( $role, $role_label ); |
|
| 596 | + $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
| 597 | + $role_object = add_role($role, $role_label); |
|
| 598 | 598 | } |
| 599 | - if ( $role_object instanceof WP_Role ) { |
|
| 600 | - $role_object->add_cap( $cap, $grant ); |
|
| 599 | + if ($role_object instanceof WP_Role) { |
|
| 600 | + $role_object->add_cap($cap, $grant); |
|
| 601 | 601 | return true; |
| 602 | 602 | } |
| 603 | 603 | return false; |
@@ -619,10 +619,10 @@ discard block |
||
| 619 | 619 | * |
| 620 | 620 | * @return void |
| 621 | 621 | */ |
| 622 | - public function remove_cap_from_role( $role, $cap ) { |
|
| 623 | - $role = get_role( $role ); |
|
| 624 | - if ( $role instanceof WP_Role ) { |
|
| 625 | - $role->remove_cap( $cap ); |
|
| 622 | + public function remove_cap_from_role($role, $cap) { |
|
| 623 | + $role = get_role($role); |
|
| 624 | + if ($role instanceof WP_Role) { |
|
| 625 | + $role->remove_cap($cap); |
|
| 626 | 626 | } |
| 627 | 627 | } |
| 628 | 628 | |
@@ -643,11 +643,11 @@ discard block |
||
| 643 | 643 | * |
| 644 | 644 | * @return bool Whether user can or not. |
| 645 | 645 | */ |
| 646 | - public function current_user_can( $cap, $context, $id = 0 ) { |
|
| 646 | + public function current_user_can($cap, $context, $id = 0) { |
|
| 647 | 647 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
| 648 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id ); |
|
| 649 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id ); |
|
| 650 | - return ! empty( $id ) ? current_user_can( $filtered_cap, $id ) : current_user_can( $filtered_cap ); |
|
| 648 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
| 649 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id); |
|
| 650 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | |
@@ -664,11 +664,11 @@ discard block |
||
| 664 | 664 | * |
| 665 | 665 | * @return bool Whether user can or not. |
| 666 | 666 | */ |
| 667 | - public function user_can( $user, $cap, $context, $id = 0 ) { |
|
| 667 | + public function user_can($user, $cap, $context, $id = 0) { |
|
| 668 | 668 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
| 669 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id ); |
|
| 670 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id ); |
|
| 671 | - return ! empty( $id ) ? user_can( $user, $filtered_cap, $id ) : user_can( $user, $filtered_cap ); |
|
| 669 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
| 670 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id); |
|
| 671 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | |
@@ -688,12 +688,12 @@ discard block |
||
| 688 | 688 | * |
| 689 | 689 | * @return bool Whether user can or not. |
| 690 | 690 | */ |
| 691 | - public function current_user_can_for_blog( $blog_id, $cap, $context, $id = 0 ) { |
|
| 692 | - $user_can = ! empty( $id ) ? current_user_can_for_blog( $blog_id, $cap, $id ) : current_user_can( $blog_id, $cap ); |
|
| 691 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) { |
|
| 692 | + $user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap); |
|
| 693 | 693 | |
| 694 | 694 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
| 695 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can, $blog_id, $cap, $id ); |
|
| 696 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id ); |
|
| 695 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, $user_can, $blog_id, $cap, $id); |
|
| 696 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id); |
|
| 697 | 697 | return $user_can; |
| 698 | 698 | } |
| 699 | 699 | |
@@ -709,12 +709,12 @@ discard block |
||
| 709 | 709 | * |
| 710 | 710 | * @return array |
| 711 | 711 | */ |
| 712 | - public function get_ee_capabilities( $role = 'administrator' ) { |
|
| 712 | + public function get_ee_capabilities($role = 'administrator') { |
|
| 713 | 713 | $capabilities = $this->_init_caps_map(); |
| 714 | - if ( empty( $role ) ) { |
|
| 714 | + if (empty($role)) { |
|
| 715 | 715 | return $capabilities; |
| 716 | 716 | } |
| 717 | - return isset( $capabilities[ $role ] ) ? $capabilities[ $role ] : array(); |
|
| 717 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | 720 | |
@@ -762,11 +762,11 @@ discard block |
||
| 762 | 762 | * } |
| 763 | 763 | * @throws EE_Error |
| 764 | 764 | */ |
| 765 | - public function __construct( $meta_cap, $map_values ) { |
|
| 765 | + public function __construct($meta_cap, $map_values) { |
|
| 766 | 766 | $this->meta_cap = $meta_cap; |
| 767 | 767 | //verify there are four args in the $map_values array; |
| 768 | - if ( count( $map_values ) !== 4 ) { |
|
| 769 | - throw new EE_Error( sprintf( __( 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso' ), '<br>' . print_r( $map_values, true ) ) ); |
|
| 768 | + if (count($map_values) !== 4) { |
|
| 769 | + throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso'), '<br>'.print_r($map_values, true))); |
|
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | //set properties |
@@ -780,8 +780,8 @@ discard block |
||
| 780 | 780 | /** |
| 781 | 781 | * Makes it so this object stops filtering caps |
| 782 | 782 | */ |
| 783 | - public function remove_filters(){ |
|
| 784 | - remove_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10 ); |
|
| 783 | + public function remove_filters() { |
|
| 784 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | |
@@ -796,19 +796,19 @@ discard block |
||
| 796 | 796 | */ |
| 797 | 797 | public function ensure_is_model() { |
| 798 | 798 | //is it already instantiated? |
| 799 | - if ( $this->_model instanceof EEM_Base ) { |
|
| 799 | + if ($this->_model instanceof EEM_Base) { |
|
| 800 | 800 | return; |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | //ensure model name is string |
| 804 | 804 | $this->_model_name = (string) $this->_model_name; |
| 805 | 805 | //error proof if the name has EEM in it |
| 806 | - $this->_model_name = str_replace( 'EEM', '', $this->_model_name ); |
|
| 806 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
| 807 | 807 | |
| 808 | - $this->_model = EE_Registry::instance()->load_model( $this->_model_name ); |
|
| 808 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
| 809 | 809 | |
| 810 | - if ( ! $this->_model instanceof EEM_Base ) { |
|
| 811 | - throw new EE_Error( sprintf( __( 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso' ), get_class( $this ), $this->_model ) ); |
|
| 810 | + if ( ! $this->_model instanceof EEM_Base) { |
|
| 811 | + throw new EE_Error(sprintf(__('This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso'), get_class($this), $this->_model)); |
|
| 812 | 812 | } |
| 813 | 813 | } |
| 814 | 814 | |
@@ -824,8 +824,8 @@ discard block |
||
| 824 | 824 | * |
| 825 | 825 | * @return array |
| 826 | 826 | */ |
| 827 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
| 828 | - return $this->_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
| 827 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
| 828 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | * |
| 844 | 844 | * @return array actual users capabilities |
| 845 | 845 | */ |
| 846 | - abstract protected function _map_meta_caps( $caps, $cap, $user_id, $args ); |
|
| 846 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | |
@@ -875,28 +875,28 @@ discard block |
||
| 875 | 875 | * |
| 876 | 876 | * @return array actual users capabilities |
| 877 | 877 | */ |
| 878 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
| 878 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
| 879 | 879 | //only process if we're checking our mapped_cap |
| 880 | - if ( $cap !== $this->meta_cap ) { |
|
| 880 | + if ($cap !== $this->meta_cap) { |
|
| 881 | 881 | return $caps; |
| 882 | 882 | } |
| 883 | 883 | |
| 884 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
| 884 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
| 885 | 885 | |
| 886 | 886 | //if no obj then let's just do cap |
| 887 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
| 887 | + if ( ! $obj instanceof EE_Base_Class) { |
|
| 888 | 888 | $caps[] = $cap; |
| 889 | 889 | return $caps; |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - if ( $obj instanceof EE_CPT_Base ) { |
|
| 892 | + if ($obj instanceof EE_CPT_Base) { |
|
| 893 | 893 | //if the item author is set and the user is the author... |
| 894 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
| 895 | - if ( empty( $this->published_cap ) ) { |
|
| 894 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
| 895 | + if (empty($this->published_cap)) { |
|
| 896 | 896 | $caps[] = $cap; |
| 897 | 897 | } else { |
| 898 | 898 | //if obj is published... |
| 899 | - if ( $obj->status() == 'publish' ) { |
|
| 899 | + if ($obj->status() == 'publish') { |
|
| 900 | 900 | $caps[] = $this->published_cap; |
| 901 | 901 | } else { |
| 902 | 902 | $caps[] = $cap; |
@@ -904,12 +904,12 @@ discard block |
||
| 904 | 904 | } |
| 905 | 905 | } else { |
| 906 | 906 | //the user is trying to edit someone else's obj |
| 907 | - if ( ! empty( $this->others_cap ) ) { |
|
| 907 | + if ( ! empty($this->others_cap)) { |
|
| 908 | 908 | $caps[] = $this->others_cap; |
| 909 | 909 | } |
| 910 | - if ( ! empty( $this->published_cap ) && $obj->status() == 'publish' ) { |
|
| 910 | + if ( ! empty($this->published_cap) && $obj->status() == 'publish') { |
|
| 911 | 911 | $caps[] = $this->published_cap; |
| 912 | - } elseif ( ! empty( $this->private_cap ) && $obj->status() == 'private' ) { |
|
| 912 | + } elseif ( ! empty($this->private_cap) && $obj->status() == 'private') { |
|
| 913 | 913 | $caps[] = $this->private_cap; |
| 914 | 914 | } |
| 915 | 915 | } |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | if ($has_cap) { |
| 927 | 927 | $caps[] = $cap; |
| 928 | 928 | } else { |
| 929 | - if ( ! empty( $this->others_cap ) ) { |
|
| 929 | + if ( ! empty($this->others_cap)) { |
|
| 930 | 930 | $caps[] = $this->others_cap; |
| 931 | 931 | } |
| 932 | 932 | } |
@@ -963,8 +963,8 @@ discard block |
||
| 963 | 963 | * |
| 964 | 964 | * @return array actual users capabilities |
| 965 | 965 | */ |
| 966 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
| 967 | - return parent::_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
| 966 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
| 967 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
| 968 | 968 | } |
| 969 | 969 | } |
| 970 | 970 | |
@@ -996,34 +996,34 @@ discard block |
||
| 996 | 996 | * |
| 997 | 997 | * @return array actual users capabilities |
| 998 | 998 | */ |
| 999 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
| 999 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
| 1000 | 1000 | //only process if we're checking our mapped cap; |
| 1001 | - if ( $cap !== $this->meta_cap ) { |
|
| 1001 | + if ($cap !== $this->meta_cap) { |
|
| 1002 | 1002 | return $caps; |
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
| 1005 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
| 1006 | 1006 | |
| 1007 | 1007 | //if no obj then let's just do cap |
| 1008 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
| 1008 | + if ( ! $obj instanceof EE_Base_Class) { |
|
| 1009 | 1009 | $caps[] = $cap; |
| 1010 | 1010 | return $caps; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - if ( $obj instanceof EE_CPT_Base ) { |
|
| 1014 | - $status_obj = get_post_status_object( $obj->status() ); |
|
| 1015 | - if ( $status_obj->public ) { |
|
| 1013 | + if ($obj instanceof EE_CPT_Base) { |
|
| 1014 | + $status_obj = get_post_status_object($obj->status()); |
|
| 1015 | + if ($status_obj->public) { |
|
| 1016 | 1016 | $caps[] = $cap; |
| 1017 | 1017 | return $caps; |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | //if the item author is set and the user is the author... |
| 1021 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
| 1021 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
| 1022 | 1022 | $caps[] = $cap; |
| 1023 | - } elseif ( $status_obj->private && ! empty( $this->private_cap ) ) { |
|
| 1023 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
| 1024 | 1024 | //the user is trying to view someone else's obj |
| 1025 | 1025 | $caps[] = $this->private_cap; |
| 1026 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
| 1026 | + } elseif ( ! empty($this->others_cap)) { |
|
| 1027 | 1027 | $caps[] = $this->others_cap; |
| 1028 | 1028 | } else { |
| 1029 | 1029 | $caps[] = $cap; |
@@ -1040,9 +1040,9 @@ discard block |
||
| 1040 | 1040 | } |
| 1041 | 1041 | if ($has_cap) { |
| 1042 | 1042 | $caps[] = $cap; |
| 1043 | - } elseif ( ! empty( $this->private_cap ) ) { |
|
| 1043 | + } elseif ( ! empty($this->private_cap)) { |
|
| 1044 | 1044 | $caps[] = $this->private_cap; |
| 1045 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
| 1045 | + } elseif ( ! empty($this->others_cap)) { |
|
| 1046 | 1046 | $caps[] = $this->others_cap; |
| 1047 | 1047 | } else { |
| 1048 | 1048 | $caps[] = $cap; |
@@ -1079,30 +1079,30 @@ discard block |
||
| 1079 | 1079 | * |
| 1080 | 1080 | * @return array actual users capabilities |
| 1081 | 1081 | */ |
| 1082 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
| 1082 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
| 1083 | 1083 | //only process if we're checking our mapped_cap |
| 1084 | - if ( $cap !== $this->meta_cap ) { |
|
| 1084 | + if ($cap !== $this->meta_cap) { |
|
| 1085 | 1085 | return $caps; |
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
| 1088 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
| 1089 | 1089 | |
| 1090 | 1090 | //if no obj then let's just do cap |
| 1091 | - if ( ! $obj instanceof EE_Message_Template_Group ) { |
|
| 1091 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
| 1092 | 1092 | $caps[] = $cap; |
| 1093 | 1093 | return $caps; |
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | 1096 | $is_global = $obj->is_global(); |
| 1097 | 1097 | |
| 1098 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
| 1099 | - if ( $is_global ) { |
|
| 1100 | - $caps[] = $this->private_cap; |
|
| 1098 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
| 1099 | + if ($is_global) { |
|
| 1100 | + $caps[] = $this->private_cap; |
|
| 1101 | 1101 | } else { |
| 1102 | 1102 | $caps[] = $cap; |
| 1103 | 1103 | } |
| 1104 | 1104 | } else { |
| 1105 | - if ( $is_global ) { |
|
| 1105 | + if ($is_global) { |
|
| 1106 | 1106 | $caps[] = $this->private_cap; |
| 1107 | 1107 | } else { |
| 1108 | 1108 | $caps[] = $this->others_cap; |
@@ -1140,16 +1140,16 @@ discard block |
||
| 1140 | 1140 | * |
| 1141 | 1141 | * @return array actual users capabilities |
| 1142 | 1142 | */ |
| 1143 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
| 1143 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
| 1144 | 1144 | //only process if we're checking our mapped_cap |
| 1145 | - if ( $cap !== $this->meta_cap ) { |
|
| 1145 | + if ($cap !== $this->meta_cap) { |
|
| 1146 | 1146 | return $caps; |
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
| 1149 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
| 1150 | 1150 | |
| 1151 | 1151 | //if no obj then let's just do cap |
| 1152 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
| 1152 | + if ( ! $obj instanceof EE_Base_Class) { |
|
| 1153 | 1153 | $caps[] = $cap; |
| 1154 | 1154 | return $caps; |
| 1155 | 1155 | } |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
| 1158 | 1158 | $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
| 1159 | 1159 | |
| 1160 | - if ( $is_system ) { |
|
| 1160 | + if ($is_system) { |
|
| 1161 | 1161 | $caps[] = $this->private_cap; |
| 1162 | 1162 | } else { |
| 1163 | 1163 | $caps[] = $cap; |
@@ -184,7 +184,7 @@ |
||
| 184 | 184 | * returns TRUE if M-Mode is engaged and the current request is not for the admin |
| 185 | 185 | * |
| 186 | 186 | * @access public |
| 187 | - * @return string |
|
| 187 | + * @return boolean |
|
| 188 | 188 | */ |
| 189 | 189 | public static function disable_frontend_for_maintenance() { |
| 190 | 190 | return ! is_admin() && EE_Maintenance_Mode::instance()->level() ? TRUE : FALSE; |
@@ -48,10 +48,10 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | const option_name_maintenance_mode = 'ee_maintenance_mode'; |
| 50 | 50 | /** |
| 51 | - * EE_Maintenance_Mode Object |
|
| 52 | - * @var EE_Maintenance_Mode $_instance |
|
| 53 | - * @access private |
|
| 54 | - */ |
|
| 51 | + * EE_Maintenance_Mode Object |
|
| 52 | + * @var EE_Maintenance_Mode $_instance |
|
| 53 | + * @access private |
|
| 54 | + */ |
|
| 55 | 55 | private static $_instance = NULL; |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | current_user_can('administrator') && //when the user is an admin |
| 142 | 142 | $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance){//and we're in level 1 |
| 143 | 143 | $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
| 144 | - }else{ |
|
| 144 | + } else{ |
|
| 145 | 145 | $maintenance_mode_level = $real_maintenance_mode_level; |
| 146 | 146 | } |
| 147 | 147 | return $maintenance_mode_level; |
@@ -156,12 +156,12 @@ discard block |
||
| 156 | 156 | if( EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){ |
| 157 | 157 | update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
| 158 | 158 | return true; |
| 159 | - }elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
| 159 | + } elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
| 160 | 160 | //we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
| 161 | 161 | //then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
| 162 | 162 | update_option( self::option_name_maintenance_mode, self::level_0_not_in_maintenance ); |
| 163 | 163 | return false; |
| 164 | - }else{ |
|
| 164 | + } else{ |
|
| 165 | 165 | return false; |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public static function instance() { |
| 75 | 75 | // check if class object is instantiated |
| 76 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Maintenance_Mode )) { |
|
| 76 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Maintenance_Mode)) { |
|
| 77 | 77 | self::$_instance = new self(); |
| 78 | 78 | } |
| 79 | 79 | return self::$_instance; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode) |
| 84 | 84 | * @return EE_Maintenance_Mode |
| 85 | 85 | */ |
| 86 | - public static function reset(){ |
|
| 86 | + public static function reset() { |
|
| 87 | 87 | self::instance()->set_maintenance_mode_if_db_old(); |
| 88 | 88 | return self::instance(); |
| 89 | 89 | } |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | private function __construct() { |
| 100 | 100 | // if M-Mode level 2 is engaged, we still need basic assets loaded |
| 101 | - add_action( 'wp_enqueue_scripts', array( $this, 'load_assets_required_for_m_mode' )); |
|
| 101 | + add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode')); |
|
| 102 | 102 | // shut 'er down down for maintenance ? |
| 103 | - add_filter( 'the_content', array( $this, 'the_content' ), 2 ); |
|
| 103 | + add_filter('the_content', array($this, 'the_content'), 2); |
|
| 104 | 104 | // add powered by EE msg |
| 105 | - add_action( 'shutdown', array( $this, 'display_maintenance_mode_notice' ), 10 ); |
|
| 105 | + add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | * retrieves the maintenance mode option value from the db |
| 113 | 113 | * @return int |
| 114 | 114 | */ |
| 115 | - public function real_level(){ |
|
| 116 | - return get_option( self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance ); |
|
| 115 | + public function real_level() { |
|
| 116 | + return get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * thinks their tables are present and up-to-date). |
| 122 | 122 | * @return boolean |
| 123 | 123 | */ |
| 124 | - public function models_can_query(){ |
|
| 124 | + public function models_can_query() { |
|
| 125 | 125 | return $this->real_level() != EE_Maintenance_Mode::level_2_complete_maintenance; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode |
| 135 | 135 | * @return int |
| 136 | 136 | */ |
| 137 | - public function level(){ |
|
| 137 | + public function level() { |
|
| 138 | 138 | $real_maintenance_mode_level = $this->real_level(); |
| 139 | 139 | //if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend |
| 140 | - if( ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests |
|
| 140 | + if (( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests |
|
| 141 | 141 | current_user_can('administrator') && //when the user is an admin |
| 142 | - $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance){//and we're in level 1 |
|
| 142 | + $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance) {//and we're in level 1 |
|
| 143 | 143 | $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
| 144 | - }else{ |
|
| 144 | + } else { |
|
| 145 | 145 | $maintenance_mode_level = $real_maintenance_mode_level; |
| 146 | 146 | } |
| 147 | 147 | return $maintenance_mode_level; |
@@ -151,17 +151,17 @@ discard block |
||
| 151 | 151 | * Determines if we need to put EE in maintenance mode because the database needs updating |
| 152 | 152 | * @return boolean true if DB is old and maintenance mode was triggered; false otherwise |
| 153 | 153 | */ |
| 154 | - public function set_maintenance_mode_if_db_old(){ |
|
| 155 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
| 156 | - if( EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){ |
|
| 154 | + public function set_maintenance_mode_if_db_old() { |
|
| 155 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
| 156 | + if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
| 157 | 157 | update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
| 158 | 158 | return true; |
| 159 | - }elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
| 159 | + }elseif ($this->level() == self::level_2_complete_maintenance) { |
|
| 160 | 160 | //we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
| 161 | 161 | //then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
| 162 | - update_option( self::option_name_maintenance_mode, self::level_0_not_in_maintenance ); |
|
| 162 | + update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance); |
|
| 163 | 163 | return false; |
| 164 | - }else{ |
|
| 164 | + } else { |
|
| 165 | 165 | return false; |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | * @param int $level |
| 172 | 172 | * @return void |
| 173 | 173 | */ |
| 174 | - public function set_maintenance_level($level){ |
|
| 175 | - do_action( 'AHEE__EE_Maintenance_Mode__set_maintenance_level', $level ); |
|
| 174 | + public function set_maintenance_level($level) { |
|
| 175 | + do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level); |
|
| 176 | 176 | update_option(self::option_name_maintenance_mode, intval($level)); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | * @return string |
| 200 | 200 | */ |
| 201 | 201 | public function load_assets_required_for_m_mode() { |
| 202 | - if ( $this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is( 'espresso_core', 'enqueued' )) { |
|
| 203 | - wp_register_style( 'espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
| 202 | + if ($this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is('espresso_core', 'enqueued')) { |
|
| 203 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
| 204 | 204 | wp_enqueue_style('espresso_default'); |
| 205 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 206 | - wp_enqueue_script( 'espresso_core' ); |
|
| 205 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 206 | + wp_enqueue_script('espresso_core'); |
|
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | public static function template_include() { |
| 223 | 223 | // shut 'er down down for maintenance ? then don't use any of our templates for our endpoints |
| 224 | - return get_template_directory() . '/index.php'; |
|
| 224 | + return get_template_directory().'/index.php'; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | |
@@ -235,12 +235,12 @@ discard block |
||
| 235 | 235 | * @param string $the_content |
| 236 | 236 | * @return string |
| 237 | 237 | */ |
| 238 | - public function the_content( $the_content ) { |
|
| 238 | + public function the_content($the_content) { |
|
| 239 | 239 | // check if M-mode is engaged and for EE shortcode |
| 240 | - if ( $this->level() && strpos( $the_content, '[ESPRESSO_' ) !== false ) { |
|
| 240 | + if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) { |
|
| 241 | 241 | // this can eventually be moved to a template, or edited via admin. But for now... |
| 242 | 242 | $the_content = sprintf( |
| 243 | - __( '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso' ), |
|
| 243 | + __('%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso'), |
|
| 244 | 244 | '<h3>', |
| 245 | 245 | '</h3><p>', |
| 246 | 246 | '</p>' |
@@ -264,16 +264,16 @@ discard block |
||
| 264 | 264 | // check if M-mode is engaged and for EE shortcode |
| 265 | 265 | if ( |
| 266 | 266 | $this->real_level() && |
| 267 | - current_user_can( 'administrator' ) && |
|
| 267 | + current_user_can('administrator') && |
|
| 268 | 268 | ! is_admin() && |
| 269 | - ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
| 269 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
| 270 | 270 | && EE_Registry::instance()->REQ->is_espresso_page() |
| 271 | 271 | ) { |
| 272 | 272 | printf( |
| 273 | - __( '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso' ), |
|
| 273 | + __('%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso'), |
|
| 274 | 274 | '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="', |
| 275 | 275 | '">×</a><p>', |
| 276 | - ' » <a href="' . add_query_arg( array( 'page' => 'espresso_maintenance_settings' ), admin_url( 'admin.php' )) . '">', |
|
| 276 | + ' » <a href="'.add_query_arg(array('page' => 'espresso_maintenance_settings'), admin_url('admin.php')).'">', |
|
| 277 | 277 | '</a></p></div>' |
| 278 | 278 | ); |
| 279 | 279 | } |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | * @ return void |
| 292 | 292 | */ |
| 293 | 293 | final function __destruct() {} |
| 294 | - final function __call($a,$b) {} |
|
| 294 | + final function __call($a, $b) {} |
|
| 295 | 295 | final function __get($a) {} |
| 296 | - final function __set($a,$b) {} |
|
| 296 | + final function __set($a, $b) {} |
|
| 297 | 297 | final function __isset($a) {} |
| 298 | 298 | final function __unset($a) {} |
| 299 | 299 | final function __sleep() { |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | final function __invoke() {} |
| 305 | 305 | final function __set_state() {} |
| 306 | 306 | final function __clone() {} |
| 307 | - final static function __callStatic($a,$b) {} |
|
| 307 | + final static function __callStatic($a, $b) {} |
|
| 308 | 308 | |
| 309 | 309 | } |
| 310 | 310 | // End of file EE_Maintenance_Mode.core.php |
@@ -204,7 +204,7 @@ |
||
| 204 | 204 | * |
| 205 | 205 | * @access private |
| 206 | 206 | * @param string $sort |
| 207 | - * @return array |
|
| 207 | + * @return string |
|
| 208 | 208 | */ |
| 209 | 209 | private static function _sort( $sort = 'ASC' ) { |
| 210 | 210 | $sort = EE_Registry::instance()->REQ->is_set( 'event_query_sort' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_sort' ) ) : $sort; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 2 | - exit( 'No direct script access allowed' ); |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /** |
| 5 | 5 | * Event Espresso |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public static function add_query_filters() { |
| 87 | 87 | //add query filters |
| 88 | - add_action( 'pre_get_posts', array( 'EEH_Event_Query', 'filter_query_parts' ), 10, 1 ); |
|
| 88 | + add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | * @param \WP_Query $WP_Query |
| 98 | 98 | * @return bool |
| 99 | 99 | */ |
| 100 | - public static function apply_query_filters( WP_Query $WP_Query ) { |
|
| 101 | - return ( isset( $WP_Query->query, $WP_Query->query['post_type'] ) && $WP_Query->query['post_type'] == 'espresso_events' ) || apply_filters( 'FHEE__EEH_Event_Query__apply_query_filters', false ) ? true : false; |
|
| 100 | + public static function apply_query_filters(WP_Query $WP_Query) { |
|
| 101 | + return (isset($WP_Query->query, $WP_Query->query['post_type']) && $WP_Query->query['post_type'] == 'espresso_events') || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false) ? true : false; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
@@ -108,15 +108,15 @@ discard block |
||
| 108 | 108 | * @access public |
| 109 | 109 | * @param \WP_Query $WP_Query |
| 110 | 110 | */ |
| 111 | - public static function filter_query_parts( WP_Query $WP_Query ) { |
|
| 111 | + public static function filter_query_parts(WP_Query $WP_Query) { |
|
| 112 | 112 | //ONLY add our filters if this isn't the main wp_query, because if this is the main wp_query we already have our cpt strategies take care of adding things in. |
| 113 | - if ( $WP_Query instanceof WP_Query && ! $WP_Query->is_main_query() ) { |
|
| 113 | + if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) { |
|
| 114 | 114 | // build event list query |
| 115 | - add_filter( 'posts_fields', array( 'EEH_Event_Query', 'posts_fields' ), 10, 2 ); |
|
| 116 | - add_filter( 'posts_join', array( 'EEH_Event_Query', 'posts_join' ), 10, 2 ); |
|
| 117 | - add_filter( 'posts_where', array( 'EEH_Event_Query', 'posts_where' ), 10, 2 ); |
|
| 118 | - add_filter( 'posts_orderby', array( 'EEH_Event_Query', 'posts_orderby' ), 10, 2 ); |
|
| 119 | - add_filter( 'posts_clauses_request', array( 'EEH_Event_Query', 'posts_clauses' ), 10, 2 ); |
|
| 115 | + add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2); |
|
| 116 | + add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2); |
|
| 117 | + add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2); |
|
| 118 | + add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2); |
|
| 119 | + add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -131,13 +131,13 @@ discard block |
||
| 131 | 131 | * @param string $orderby |
| 132 | 132 | * @param string $sort |
| 133 | 133 | */ |
| 134 | - public static function set_query_params( $month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC' ) { |
|
| 134 | + public static function set_query_params($month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC') { |
|
| 135 | 135 | self::$_query_params = array(); |
| 136 | - EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month( $month ); |
|
| 137 | - EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug( $category ); |
|
| 138 | - EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired( $show_expired ); |
|
| 139 | - EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby( $orderby ); |
|
| 140 | - EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort( $sort ); |
|
| 136 | + EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month); |
|
| 137 | + EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category); |
|
| 138 | + EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired); |
|
| 139 | + EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby); |
|
| 140 | + EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | * @param string $month |
| 150 | 150 | * @return string |
| 151 | 151 | */ |
| 152 | - private static function _display_month( $month = '' ) { |
|
| 153 | - return EE_Registry::instance()->REQ->is_set( 'event_query_month' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_month' ) ) : $month; |
|
| 152 | + private static function _display_month($month = '') { |
|
| 153 | + return EE_Registry::instance()->REQ->is_set('event_query_month') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month')) : $month; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | * @param string $category |
| 163 | 163 | * @return string |
| 164 | 164 | */ |
| 165 | - private static function _event_category_slug( $category = '' ) { |
|
| 166 | - return EE_Registry::instance()->REQ->is_set( 'event_query_category' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_category' ) ) : $category; |
|
| 165 | + private static function _event_category_slug($category = '') { |
|
| 166 | + return EE_Registry::instance()->REQ->is_set('event_query_category') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_category')) : $category; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | * @param bool $show_expired |
| 176 | 176 | * @return boolean |
| 177 | 177 | */ |
| 178 | - private static function _show_expired( $show_expired = FALSE ) { |
|
| 178 | + private static function _show_expired($show_expired = FALSE) { |
|
| 179 | 179 | // override default expired option if set via filter |
| 180 | - $_event_query_show_expired =EE_Registry::instance()->REQ->is_set( 'event_query_show_expired' ) ? EE_Registry::instance()->REQ->get( 'event_query_show_expired' ) : $show_expired; |
|
| 181 | - return filter_var( $_event_query_show_expired, FILTER_VALIDATE_BOOLEAN ); |
|
| 180 | + $_event_query_show_expired = EE_Registry::instance()->REQ->is_set('event_query_show_expired') ? EE_Registry::instance()->REQ->get('event_query_show_expired') : $show_expired; |
|
| 181 | + return filter_var($_event_query_show_expired, FILTER_VALIDATE_BOOLEAN); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
@@ -190,10 +190,10 @@ discard block |
||
| 190 | 190 | * @param string $orderby |
| 191 | 191 | * @return array |
| 192 | 192 | */ |
| 193 | - private static function _orderby( $orderby = 'start_date' ) { |
|
| 194 | - $event_query_orderby = EE_Registry::instance()->REQ->is_set( 'event_query_orderby' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_orderby' ) ) : $orderby; |
|
| 195 | - $event_query_orderby = is_array( $event_query_orderby ) ? $event_query_orderby : explode( ',', $event_query_orderby ); |
|
| 196 | - $event_query_orderby = array_map( 'trim', $event_query_orderby ); |
|
| 193 | + private static function _orderby($orderby = 'start_date') { |
|
| 194 | + $event_query_orderby = EE_Registry::instance()->REQ->is_set('event_query_orderby') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_orderby')) : $orderby; |
|
| 195 | + $event_query_orderby = is_array($event_query_orderby) ? $event_query_orderby : explode(',', $event_query_orderby); |
|
| 196 | + $event_query_orderby = array_map('trim', $event_query_orderby); |
|
| 197 | 197 | return $event_query_orderby; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | * @param string $sort |
| 207 | 207 | * @return array |
| 208 | 208 | */ |
| 209 | - private static function _sort( $sort = 'ASC' ) { |
|
| 210 | - $sort = EE_Registry::instance()->REQ->is_set( 'event_query_sort' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_sort' ) ) : $sort; |
|
| 211 | - return in_array( $sort, array( 'ASC', 'asc', 'DESC', 'desc' )) ? strtoupper( $sort ) : 'ASC'; |
|
| 209 | + private static function _sort($sort = 'ASC') { |
|
| 210 | + $sort = EE_Registry::instance()->REQ->is_set('event_query_sort') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_sort')) : $sort; |
|
| 211 | + return in_array($sort, array('ASC', 'asc', 'DESC', 'desc')) ? strtoupper($sort) : 'ASC'; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | |
@@ -221,10 +221,10 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @return array array of clauses |
| 223 | 223 | */ |
| 224 | - public static function posts_clauses( $clauses, WP_Query $wp_query ) { |
|
| 225 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
| 224 | + public static function posts_clauses($clauses, WP_Query $wp_query) { |
|
| 225 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
| 226 | 226 | global $wpdb; |
| 227 | - $clauses['groupby'] = $wpdb->posts . '.ID '; |
|
| 227 | + $clauses['groupby'] = $wpdb->posts.'.ID '; |
|
| 228 | 228 | } |
| 229 | 229 | return $clauses; |
| 230 | 230 | } |
@@ -239,10 +239,10 @@ discard block |
||
| 239 | 239 | * @param WP_Query $wp_query |
| 240 | 240 | * @return string |
| 241 | 241 | */ |
| 242 | - public static function posts_fields( $SQL, WP_Query $wp_query ) { |
|
| 243 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
| 242 | + public static function posts_fields($SQL, WP_Query $wp_query) { |
|
| 243 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
| 244 | 244 | // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement |
| 245 | - $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby( EEH_Event_Query::$_event_query_orderby ); |
|
| 245 | + $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby); |
|
| 246 | 246 | } |
| 247 | 247 | return $SQL; |
| 248 | 248 | } |
@@ -257,29 +257,29 @@ discard block |
||
| 257 | 257 | * @internal param bool|string $mixed $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet |
| 258 | 258 | * @return string |
| 259 | 259 | */ |
| 260 | - public static function posts_fields_sql_for_orderby( $orderby_params = array() ) { |
|
| 261 | - $SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ; |
|
| 262 | - foreach( (array)$orderby_params as $orderby ) { |
|
| 263 | - switch ( $orderby ) { |
|
| 260 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) { |
|
| 261 | + $SQL = ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date '; |
|
| 262 | + foreach ((array) $orderby_params as $orderby) { |
|
| 263 | + switch ($orderby) { |
|
| 264 | 264 | |
| 265 | 265 | case 'ticket_start' : |
| 266 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date' ; |
|
| 266 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_start_date'; |
|
| 267 | 267 | break; |
| 268 | 268 | |
| 269 | 269 | case 'ticket_end' : |
| 270 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date' ; |
|
| 270 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_end_date'; |
|
| 271 | 271 | break; |
| 272 | 272 | |
| 273 | 273 | case 'venue_title' : |
| 274 | - $SQL .= ', Venue.post_title AS venue_title' ; |
|
| 274 | + $SQL .= ', Venue.post_title AS venue_title'; |
|
| 275 | 275 | break; |
| 276 | 276 | |
| 277 | 277 | case 'city' : |
| 278 | - $SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city' ; |
|
| 278 | + $SQL .= ', '.EEM_Venue::instance()->second_table().'.VNU_city'; |
|
| 279 | 279 | break; |
| 280 | 280 | |
| 281 | 281 | case 'state' : |
| 282 | - $SQL .= ', ' . EEM_State::instance()->table() . '.STA_name' ; |
|
| 282 | + $SQL .= ', '.EEM_State::instance()->table().'.STA_name'; |
|
| 283 | 283 | break; |
| 284 | 284 | |
| 285 | 285 | } |
@@ -297,12 +297,12 @@ discard block |
||
| 297 | 297 | * @param WP_Query $wp_query |
| 298 | 298 | * @return string |
| 299 | 299 | */ |
| 300 | - public static function posts_join( $SQL = '', WP_Query $wp_query ) { |
|
| 301 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
| 300 | + public static function posts_join($SQL = '', WP_Query $wp_query) { |
|
| 301 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
| 302 | 302 | // Category |
| 303 | - $SQL = EEH_Event_Query::posts_join_sql_for_show_expired( $SQL, EEH_Event_Query::$_event_query_show_expired ); |
|
| 304 | - $SQL = EEH_Event_Query::posts_join_sql_for_terms( $SQL, EEH_Event_Query::$_event_query_category ); |
|
| 305 | - $SQL = EEH_Event_Query::posts_join_for_orderby( $SQL, EEH_Event_Query::$_event_query_orderby ); |
|
| 303 | + $SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired); |
|
| 304 | + $SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category); |
|
| 305 | + $SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby); |
|
| 306 | 306 | } |
| 307 | 307 | return $SQL; |
| 308 | 308 | } |
@@ -317,11 +317,11 @@ discard block |
||
| 317 | 317 | * @param boolean $show_expired if TRUE, then displayed past events |
| 318 | 318 | * @return string |
| 319 | 319 | */ |
| 320 | - public static function posts_join_sql_for_show_expired( $SQL = '', $show_expired = FALSE ) { |
|
| 321 | - if ( ! $show_expired ) { |
|
| 322 | - $join = EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
| 323 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
| 324 | - $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) '; |
|
| 320 | + public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = FALSE) { |
|
| 321 | + if ( ! $show_expired) { |
|
| 322 | + $join = EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
| 323 | + if (strpos($SQL, $join) === FALSE) { |
|
| 324 | + $SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' ) '; |
|
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | return $SQL; |
@@ -337,8 +337,8 @@ discard block |
||
| 337 | 337 | * @param string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet |
| 338 | 338 | * @return string |
| 339 | 339 | */ |
| 340 | - public static function posts_join_sql_for_terms( $SQL = '', $join_terms = '' ) { |
|
| 341 | - if ( ! empty( $join_terms ) ) { |
|
| 340 | + public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') { |
|
| 341 | + if ( ! empty($join_terms)) { |
|
| 342 | 342 | global $wpdb; |
| 343 | 343 | $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
| 344 | 344 | $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
@@ -358,25 +358,25 @@ discard block |
||
| 358 | 358 | * @param array $orderby_params |
| 359 | 359 | * @return string |
| 360 | 360 | */ |
| 361 | - public static function posts_join_for_orderby( $SQL = '', $orderby_params = array() ) { |
|
| 362 | - foreach ( (array)$orderby_params as $orderby ) { |
|
| 363 | - switch ( $orderby ) { |
|
| 361 | + public static function posts_join_for_orderby($SQL = '', $orderby_params = array()) { |
|
| 362 | + foreach ((array) $orderby_params as $orderby) { |
|
| 363 | + switch ($orderby) { |
|
| 364 | 364 | case 'ticket_start' : |
| 365 | 365 | case 'ticket_end' : |
| 366 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() ); |
|
| 367 | - $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' = ' . EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' )'; |
|
| 366 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Datetime_Ticket::instance()->table().'.'.EEM_Datetime::instance()->primary_key_name()); |
|
| 367 | + $SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('.EEM_Datetime_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' = '.EEM_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' )'; |
|
| 368 | 368 | break; |
| 369 | 369 | case 'venue_title' : |
| 370 | 370 | case 'city' : |
| 371 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL ); |
|
| 371 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
| 372 | 372 | break; |
| 373 | 373 | case 'state' : |
| 374 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL ); |
|
| 375 | - $SQL .= EEH_Event_Query::_posts_join_for_venue_state( $SQL ); |
|
| 374 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
| 375 | + $SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL); |
|
| 376 | 376 | break; |
| 377 | 377 | case 'start_date' : |
| 378 | 378 | default : |
| 379 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Event::instance()->table() . '.ID' ); |
|
| 379 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table().'.ID'); |
|
| 380 | 380 | break; |
| 381 | 381 | |
| 382 | 382 | } |
@@ -394,11 +394,11 @@ discard block |
||
| 394 | 394 | * @param string $join |
| 395 | 395 | * @return string |
| 396 | 396 | */ |
| 397 | - protected static function _posts_join_for_datetime( $SQL = '', $join = '' ) { |
|
| 398 | - if ( ! empty( $join )) { |
|
| 399 | - $join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
| 400 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
| 401 | - return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )'; |
|
| 397 | + protected static function _posts_join_for_datetime($SQL = '', $join = '') { |
|
| 398 | + if ( ! empty($join)) { |
|
| 399 | + $join .= ' = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
| 400 | + if (strpos($SQL, $join) === FALSE) { |
|
| 401 | + return ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' )'; |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | return ''; |
@@ -413,13 +413,13 @@ discard block |
||
| 413 | 413 | * @param string $SQL |
| 414 | 414 | * @return string |
| 415 | 415 | */ |
| 416 | - protected static function _posts_join_for_event_venue( $SQL = '' ) { |
|
| 416 | + protected static function _posts_join_for_event_venue($SQL = '') { |
|
| 417 | 417 | // Event Venue table name |
| 418 | 418 | $event_venue_table = EEM_Event_Venue::instance()->table(); |
| 419 | 419 | // generate conditions for: Event <=> Event Venue JOIN clause |
| 420 | - $event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = ' . $event_venue_table . '.' . EEM_Event::instance()->primary_key_name(); |
|
| 420 | + $event_to_event_venue_join = EEM_Event::instance()->table().'.ID = '.$event_venue_table.'.'.EEM_Event::instance()->primary_key_name(); |
|
| 421 | 421 | // don't add joins if they have already been added |
| 422 | - if ( strpos( $SQL, $event_to_event_venue_join ) === FALSE ) { |
|
| 422 | + if (strpos($SQL, $event_to_event_venue_join) === FALSE) { |
|
| 423 | 423 | // Venue table name |
| 424 | 424 | $venue_table = EEM_Venue::instance()->table(); |
| 425 | 425 | // Venue table pk |
@@ -432,10 +432,10 @@ discard block |
||
| 432 | 432 | $venue_SQL .= " LEFT JOIN $venue_table as Venue ON ( $event_venue_table.$venue_table_pk = Venue.ID )"; |
| 433 | 433 | // generate JOIN clause for: Venue <=> Venue Meta |
| 434 | 434 | $venue_SQL .= " LEFT JOIN $venue_meta_table ON ( Venue.ID = $venue_meta_table.$venue_table_pk )"; |
| 435 | - unset( $event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table ); |
|
| 435 | + unset($event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table); |
|
| 436 | 436 | return $venue_SQL; |
| 437 | 437 | } |
| 438 | - unset( $event_venue_table, $event_to_event_venue_join ); |
|
| 438 | + unset($event_venue_table, $event_to_event_venue_join); |
|
| 439 | 439 | return ''; |
| 440 | 440 | } |
| 441 | 441 | |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | * @param string $SQL |
| 449 | 449 | * @return string |
| 450 | 450 | */ |
| 451 | - protected static function _posts_join_for_venue_state( $SQL = '' ) { |
|
| 451 | + protected static function _posts_join_for_venue_state($SQL = '') { |
|
| 452 | 452 | // Venue Meta table name |
| 453 | 453 | $venue_meta_table = EEM_Venue::instance()->second_table(); |
| 454 | 454 | // State table name |
@@ -456,16 +456,16 @@ discard block |
||
| 456 | 456 | // State table pk |
| 457 | 457 | $state_table_pk = EEM_State::instance()->primary_key_name(); |
| 458 | 458 | // verify vars |
| 459 | - if ( $venue_meta_table && $state_table && $state_table_pk ) { |
|
| 459 | + if ($venue_meta_table && $state_table && $state_table_pk) { |
|
| 460 | 460 | // like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID |
| 461 | 461 | $join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk"; |
| 462 | 462 | // don't add join if it has already been added |
| 463 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
| 464 | - unset( $state_table_pk, $venue_meta_table, $venue_table_pk ); |
|
| 463 | + if (strpos($SQL, $join) === FALSE) { |
|
| 464 | + unset($state_table_pk, $venue_meta_table, $venue_table_pk); |
|
| 465 | 465 | return " LEFT JOIN $state_table ON ( $join )"; |
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | - unset( $join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk ); |
|
| 468 | + unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk); |
|
| 469 | 469 | return ''; |
| 470 | 470 | } |
| 471 | 471 | |
@@ -479,14 +479,14 @@ discard block |
||
| 479 | 479 | * @param WP_Query $wp_query |
| 480 | 480 | * @return string |
| 481 | 481 | */ |
| 482 | - public static function posts_where( $SQL = '', WP_Query $wp_query ) { |
|
| 483 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
| 482 | + public static function posts_where($SQL = '', WP_Query $wp_query) { |
|
| 483 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
| 484 | 484 | // Show Expired ? |
| 485 | - $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired( EEH_Event_Query::$_event_query_show_expired ); |
|
| 485 | + $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired); |
|
| 486 | 486 | // Category |
| 487 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug( EEH_Event_Query::$_event_query_category ); |
|
| 487 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category); |
|
| 488 | 488 | // Start Date |
| 489 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month( EEH_Event_Query::$_event_query_month ); |
|
| 489 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month); |
|
| 490 | 490 | } |
| 491 | 491 | return $SQL; |
| 492 | 492 | } |
@@ -500,8 +500,8 @@ discard block |
||
| 500 | 500 | * @param boolean $show_expired if TRUE, then displayed past events |
| 501 | 501 | * @return string |
| 502 | 502 | */ |
| 503 | - public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) { |
|
| 504 | - return ! $show_expired ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . current_time( 'mysql', TRUE ) . '" ' : ''; |
|
| 503 | + public static function posts_where_sql_for_show_expired($show_expired = FALSE) { |
|
| 504 | + return ! $show_expired ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.current_time('mysql', TRUE).'" ' : ''; |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | |
@@ -513,9 +513,9 @@ discard block |
||
| 513 | 513 | * @param boolean $event_category_slug |
| 514 | 514 | * @return string |
| 515 | 515 | */ |
| 516 | - public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) { |
|
| 516 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) { |
|
| 517 | 517 | global $wpdb; |
| 518 | - return ! empty( $event_category_slug ) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : ''; |
|
| 518 | + return ! empty($event_category_slug) ? ' AND '.$wpdb->terms.'.slug = "'.$event_category_slug.'" ' : ''; |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | |
@@ -527,13 +527,13 @@ discard block |
||
| 527 | 527 | * @param boolean $month |
| 528 | 528 | * @return string |
| 529 | 529 | */ |
| 530 | - public static function posts_where_sql_for_event_list_month( $month = NULL ) { |
|
| 530 | + public static function posts_where_sql_for_event_list_month($month = NULL) { |
|
| 531 | 531 | $SQL = ''; |
| 532 | - if ( ! empty( $month ) ) { |
|
| 532 | + if ( ! empty($month)) { |
|
| 533 | 533 | // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
| 534 | - $SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start <= "' . gmdate( 'Y-m-t 23:59:59', strtotime( $month ) ) . '"'; |
|
| 534 | + $SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start <= "'.gmdate('Y-m-t 23:59:59', strtotime($month)).'"'; |
|
| 535 | 535 | // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
| 536 | - $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end >= "' . gmdate( 'Y-m-01 0:0:00', strtotime( $month ) ) . '" '; |
|
| 536 | + $SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end >= "'.gmdate('Y-m-01 0:0:00', strtotime($month)).'" '; |
|
| 537 | 537 | } |
| 538 | 538 | return $SQL; |
| 539 | 539 | } |
@@ -548,9 +548,9 @@ discard block |
||
| 548 | 548 | * @param WP_Query $wp_query |
| 549 | 549 | * @return string |
| 550 | 550 | */ |
| 551 | - public static function posts_orderby( $SQL = '', WP_Query $wp_query ) { |
|
| 552 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
| 553 | - $SQL = EEH_Event_Query::posts_orderby_sql( EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort ); |
|
| 551 | + public static function posts_orderby($SQL = '', WP_Query $wp_query) { |
|
| 552 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
| 553 | + $SQL = EEH_Event_Query::posts_orderby_sql(EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort); |
|
| 554 | 554 | } |
| 555 | 555 | return $SQL; |
| 556 | 556 | } |
@@ -581,63 +581,63 @@ discard block |
||
| 581 | 581 | * @param string $sort |
| 582 | 582 | * @return string |
| 583 | 583 | */ |
| 584 | - public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) { |
|
| 584 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') { |
|
| 585 | 585 | global $wpdb; |
| 586 | 586 | $SQL = ''; |
| 587 | 587 | $counter = 0; |
| 588 | 588 | //make sure 'orderby' is set in query params |
| 589 | - if ( ! isset( self::$_query_params['orderby'] )) { |
|
| 589 | + if ( ! isset(self::$_query_params['orderby'])) { |
|
| 590 | 590 | self::$_query_params['orderby'] = array(); |
| 591 | 591 | } |
| 592 | 592 | // loop thru $orderby_params (type cast as array) |
| 593 | - foreach ( (array)$orderby_params as $orderby ) { |
|
| 593 | + foreach ((array) $orderby_params as $orderby) { |
|
| 594 | 594 | // check if we have already added this param |
| 595 | - if ( isset( self::$_query_params['orderby'][ $orderby ] )) { |
|
| 595 | + if (isset(self::$_query_params['orderby'][$orderby])) { |
|
| 596 | 596 | // if so then remove from the $orderby_params so that the count() method below is accurate |
| 597 | - unset( $orderby_params[ $orderby ] ); |
|
| 597 | + unset($orderby_params[$orderby]); |
|
| 598 | 598 | // then bump ahead to the next param |
| 599 | 599 | continue; |
| 600 | 600 | } |
| 601 | 601 | // this will ad a comma depending on whether this is the first or last param |
| 602 | - $glue = $counter == 0 || $counter == count( $orderby_params ) ? ' ' : ', '; |
|
| 602 | + $glue = $counter == 0 || $counter == count($orderby_params) ? ' ' : ', '; |
|
| 603 | 603 | // ok what's we dealing with? |
| 604 | - switch ( $orderby ) { |
|
| 604 | + switch ($orderby) { |
|
| 605 | 605 | case 'id' : |
| 606 | 606 | case 'ID' : |
| 607 | - $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
| 607 | + $SQL .= $glue.$wpdb->posts.'.ID '.$sort; |
|
| 608 | 608 | break; |
| 609 | 609 | case 'end_date' : |
| 610 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
| 610 | + $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort; |
|
| 611 | 611 | break; |
| 612 | 612 | case 'event_name' : |
| 613 | - $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
| 613 | + $SQL .= $glue.$wpdb->posts.'.post_title '.$sort; |
|
| 614 | 614 | break; |
| 615 | 615 | case 'category_slug' : |
| 616 | - $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
| 616 | + $SQL .= $glue.$wpdb->terms.'.slug '.$sort; |
|
| 617 | 617 | break; |
| 618 | 618 | case 'ticket_start' : |
| 619 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
| 619 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort; |
|
| 620 | 620 | break; |
| 621 | 621 | case 'ticket_end' : |
| 622 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
| 622 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort; |
|
| 623 | 623 | break; |
| 624 | 624 | case 'venue_title' : |
| 625 | - $SQL .= $glue . 'venue_title ' . $sort; |
|
| 625 | + $SQL .= $glue.'venue_title '.$sort; |
|
| 626 | 626 | break; |
| 627 | 627 | case 'city' : |
| 628 | - $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
| 628 | + $SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort; |
|
| 629 | 629 | break; |
| 630 | 630 | case 'state' : |
| 631 | - $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
| 631 | + $SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort; |
|
| 632 | 632 | break; |
| 633 | 633 | case 'start_date' : |
| 634 | 634 | default : |
| 635 | - $SQL .= $glue . ' event_start_date ' . $sort; |
|
| 635 | + $SQL .= $glue.' event_start_date '.$sort; |
|
| 636 | 636 | break; |
| 637 | 637 | } |
| 638 | 638 | // add to array of orderby params that have been added |
| 639 | - self::$_query_params['orderby'][ $orderby ] = TRUE; |
|
| 640 | - $counter ++; |
|
| 639 | + self::$_query_params['orderby'][$orderby] = TRUE; |
|
| 640 | + $counter++; |
|
| 641 | 641 | } |
| 642 | 642 | return $SQL; |
| 643 | 643 | } |