Completed
Branch FET-10325-remove-caffeinated-m... (ba33af)
by
unknown
34:17 queued 23:38
created
core/db_models/relations/EE_HABTM_Relation.php 2 patches
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -12,203 +12,203 @@
 block discarded – undo
12 12
  */
13 13
 class EE_HABTM_Relation extends EE_Model_Relation_Base
14 14
 {
15
-    /**
16
-     * Model which defines the relation between two other models. Eg, the EE_Event_Question_Group model,
17
-     * which joins EE_Event and EE_Question_Group
18
-     *
19
-     * @var EEM_Base
20
-     */
21
-    protected $_joining_model_name;
22
-
23
-    protected $_model_relation_chain_to_join_model;
24
-
25
-
26
-    /**
27
-     * Object representing the relationship between two models. HasAndBelongsToMany relations always use a join-table
28
-     * (and an ee joining-model.) This knows how to join the models,
29
-     * get related models across the relation, and add-and-remove the relationships.
30
-     *
31
-     * @param bool    $joining_model_name
32
-     * @param boolean $block_deletes                 for this type of relation, we block by default for now. if there
33
-     *                                               are related models across this relation, block (prevent and add an
34
-     *                                               error) the deletion of this model
35
-     * @param string  $blocking_delete_error_message a customized error message on blocking deletes instead of the
36
-     *                                               default
37
-     */
38
-    public function __construct($joining_model_name, $block_deletes = true, $blocking_delete_error_message = '')
39
-    {
40
-        $this->_joining_model_name = $joining_model_name;
41
-        parent::__construct($block_deletes, $blocking_delete_error_message);
42
-    }
43
-
44
-    /**
45
-     * Gets the joining model's object
46
-     *
47
-     * @return EEM_Base
48
-     */
49
-    public function get_join_model()
50
-    {
51
-        return $this->_get_model($this->_joining_model_name);
52
-    }
53
-
54
-
55
-    /**
56
-     * Gets the SQL string for joining the main model's table containing the pk to the join table. Eg "LEFT JOIN
57
-     * real_join_table AS join_table_alias ON this_table_alias.pk = join_table_alias.fk_to_this_table"
58
-     *
59
-     * @param string $model_relation_chain like 'Event.Event_Venue.Venue'
60
-     * @return string of SQL
61
-     * @throws \EE_Error
62
-     */
63
-    public function get_join_to_intermediate_model_statement($model_relation_chain)
64
-    {
65
-        //create sql like
66
-        //LEFT JOIN join_table AS join_table_alias ON this_table_alias.this_table_pk = join_table_alias.join_table_fk_to_this
67
-        //LEFT JOIN other_table AS other_table_alias ON join_table_alias.join_table_fk_to_other = other_table_alias.other_table_pk
68
-        //remember the model relation chain to the JOIN model, because we'll
69
-        //need it for get_join_statement()
70
-        $this->_model_relation_chain_to_join_model = $model_relation_chain;
71
-        $this_table_pk_field                       = $this->get_this_model()->get_primary_key_field();//get_foreign_key_to($this->get_other_model()->get_this_model_name());
72
-        $join_table_fk_field_to_this_table         = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
73
-        $this_table_alias                          = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
74
-                $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias();
75
-
76
-        $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
77
-                $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias();
78
-        $join_table       = $this->get_join_model()->get_table_for_alias($join_table_alias);
79
-        //phew! ok, we have all the info we need, now we can create the SQL join string
80
-        $SQL = $this->_left_join($join_table, $join_table_alias, $join_table_fk_field_to_this_table->get_table_column(),
81
-                $this_table_alias,
82
-                $this_table_pk_field->get_table_column()) . $this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias);
83
-
84
-        return $SQL;
85
-    }
86
-
87
-
88
-    /**
89
-     * Gets the SQL string for joining the join table to the other model's pk's table. Eg "LEFT JOIN real_other_table
90
-     * AS other_table_alias ON join_table_alias.fk_to_other_table = other_table_alias.pk" If you want to join between
91
-     * modelA -> joinModelAB -> modelB (eg, Event -> Event_Question_Group -> Question_Group), you should prepend the
92
-     * result of this function with results from get_join_to_intermediate_model_statement(), so that you join first to
93
-     * the intermediate join table, and then to the other model's pk's table
94
-     *
95
-     * @param string $model_relation_chain like 'Event.Event_Venue.Venue'
96
-     * @return string of SQL
97
-     * @throws \EE_Error
98
-     */
99
-    public function get_join_statement($model_relation_chain)
100
-    {
101
-        if ($this->_model_relation_chain_to_join_model === null) {
102
-            throw new EE_Error(sprintf(__('When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement',
103
-                'event_espresso')));
104
-        }
105
-        $join_table_fk_field_to_this_table  = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
106
-        $join_table_alias                   = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model,
107
-                $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias();
108
-        $other_table_pk_field               = $this->get_other_model()->get_primary_key_field();
109
-        $join_table_fk_field_to_other_table = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
110
-        $other_table_alias                  = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
111
-                $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias();
112
-        $other_table                        = $this->get_other_model()->get_table_for_alias($other_table_alias);
113
-
114
-        $SQL = $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(),
115
-                $join_table_alias,
116
-                $join_table_fk_field_to_other_table->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
117
-        return $SQL;
118
-    }
119
-
120
-
121
-    /**
122
-     * Ensures there is an entry in the join table between these two models. Feel free to do this manually if you like.
123
-     * If the join table has additional columns (eg, the Event_Question_Group table has a is_primary column), then
124
-     * you'll want to directly use the EEM_Event_Question_Group model to add the entry to the table and set those extra
125
-     * columns' values
126
-     *
127
-     * @param EE_Base_Class|int $this_obj_or_id
128
-     * @param EE_Base_Class|int $other_obj_or_id
129
-     * @param array             $extra_join_model_fields_n_values col=>val pairs that are used as extra conditions for
130
-     *                                                            checking existing values and for setting new rows if
131
-     *                                                            no exact matches.
132
-     * @return EE_Base_Class
133
-     * @throws \EE_Error
134
-     */
135
-    public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array())
136
-    {
137
-        $this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
138
-        $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
139
-        //check if such a relationship already exists
140
-        $join_model_fk_to_this_model  = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
141
-        $join_model_fk_to_other_model = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
142
-
143
-        $cols_n_values = array(
144
-            $join_model_fk_to_this_model->get_name()  => $this_model_obj->ID(),
145
-            $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(),
146
-        );
147
-
148
-        //if $where_query exists lets add them to the query_params.
149
-        if (! empty($extra_join_model_fields_n_values)) {
150
-            //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name)
151
-            //make sure we strip THIS models name from the query param
152
-            $parsed_query = array();
153
-            foreach ($extra_join_model_fields_n_values as $query_param => $val) {
154
-                $query_param                = str_replace($this->get_join_model()->get_this_model_name() . ".", "",
155
-                    $query_param);
156
-                $parsed_query[$query_param] = $val;
157
-            }
158
-            $cols_n_values = array_merge($cols_n_values, $parsed_query);
159
-        }
160
-
161
-        $query_params = array($cols_n_values);
162
-
163
-
164
-        $existing_entry_in_join_table = $this->get_join_model()->get_one($query_params);
165
-        //if there is already an entry in the join table, indicating a relationship, we're done
166
-        //again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to
167
-        //the other tables, use the joining model directly!
168
-        if (! $existing_entry_in_join_table) {
169
-            $this->get_join_model()->insert($cols_n_values);
170
-        }
171
-        return $other_model_obj;
172
-    }
173
-
174
-
175
-    /**
176
-     * Deletes any rows in the join table that have foreign keys matching the other model objects specified
177
-     *
178
-     * @param EE_Base_Class|int $this_obj_or_id
179
-     * @param EE_Base_Class|int $other_obj_or_id
180
-     * @param array             $where_query col=>val pairs that are used as extra conditions for checking existing
181
-     *                                       values and for removing existing rows if exact matches exist.
182
-     * @return EE_Base_Class
183
-     * @throws \EE_Error
184
-     */
185
-    public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array())
186
-    {
187
-        $this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
188
-        $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
189
-        //check if such a relationship already exists
190
-        $join_model_fk_to_this_model  = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
191
-        $join_model_fk_to_other_model = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
192
-
193
-        $cols_n_values = array(
194
-            $join_model_fk_to_this_model->get_name()  => $this_model_obj->ID(),
195
-            $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(),
196
-        );
197
-
198
-        //if $where_query exists lets add them to the query_params.
199
-        if (! empty($where_query)) {
200
-            //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name)
201
-            //make sure we strip THIS models name from the query param
202
-            $parsed_query = array();
203
-            foreach ($where_query as $query_param => $val) {
204
-                $query_param                = str_replace($this->get_join_model()->get_this_model_name() . ".", "",
205
-                    $query_param);
206
-                $parsed_query[$query_param] = $val;
207
-            }
208
-            $cols_n_values = array_merge($cols_n_values, $parsed_query);
209
-        }
210
-
211
-        $this->get_join_model()->delete(array($cols_n_values));
212
-        return $other_model_obj;
213
-    }
15
+	/**
16
+	 * Model which defines the relation between two other models. Eg, the EE_Event_Question_Group model,
17
+	 * which joins EE_Event and EE_Question_Group
18
+	 *
19
+	 * @var EEM_Base
20
+	 */
21
+	protected $_joining_model_name;
22
+
23
+	protected $_model_relation_chain_to_join_model;
24
+
25
+
26
+	/**
27
+	 * Object representing the relationship between two models. HasAndBelongsToMany relations always use a join-table
28
+	 * (and an ee joining-model.) This knows how to join the models,
29
+	 * get related models across the relation, and add-and-remove the relationships.
30
+	 *
31
+	 * @param bool    $joining_model_name
32
+	 * @param boolean $block_deletes                 for this type of relation, we block by default for now. if there
33
+	 *                                               are related models across this relation, block (prevent and add an
34
+	 *                                               error) the deletion of this model
35
+	 * @param string  $blocking_delete_error_message a customized error message on blocking deletes instead of the
36
+	 *                                               default
37
+	 */
38
+	public function __construct($joining_model_name, $block_deletes = true, $blocking_delete_error_message = '')
39
+	{
40
+		$this->_joining_model_name = $joining_model_name;
41
+		parent::__construct($block_deletes, $blocking_delete_error_message);
42
+	}
43
+
44
+	/**
45
+	 * Gets the joining model's object
46
+	 *
47
+	 * @return EEM_Base
48
+	 */
49
+	public function get_join_model()
50
+	{
51
+		return $this->_get_model($this->_joining_model_name);
52
+	}
53
+
54
+
55
+	/**
56
+	 * Gets the SQL string for joining the main model's table containing the pk to the join table. Eg "LEFT JOIN
57
+	 * real_join_table AS join_table_alias ON this_table_alias.pk = join_table_alias.fk_to_this_table"
58
+	 *
59
+	 * @param string $model_relation_chain like 'Event.Event_Venue.Venue'
60
+	 * @return string of SQL
61
+	 * @throws \EE_Error
62
+	 */
63
+	public function get_join_to_intermediate_model_statement($model_relation_chain)
64
+	{
65
+		//create sql like
66
+		//LEFT JOIN join_table AS join_table_alias ON this_table_alias.this_table_pk = join_table_alias.join_table_fk_to_this
67
+		//LEFT JOIN other_table AS other_table_alias ON join_table_alias.join_table_fk_to_other = other_table_alias.other_table_pk
68
+		//remember the model relation chain to the JOIN model, because we'll
69
+		//need it for get_join_statement()
70
+		$this->_model_relation_chain_to_join_model = $model_relation_chain;
71
+		$this_table_pk_field                       = $this->get_this_model()->get_primary_key_field();//get_foreign_key_to($this->get_other_model()->get_this_model_name());
72
+		$join_table_fk_field_to_this_table         = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
73
+		$this_table_alias                          = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
74
+				$this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias();
75
+
76
+		$join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
77
+				$this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias();
78
+		$join_table       = $this->get_join_model()->get_table_for_alias($join_table_alias);
79
+		//phew! ok, we have all the info we need, now we can create the SQL join string
80
+		$SQL = $this->_left_join($join_table, $join_table_alias, $join_table_fk_field_to_this_table->get_table_column(),
81
+				$this_table_alias,
82
+				$this_table_pk_field->get_table_column()) . $this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias);
83
+
84
+		return $SQL;
85
+	}
86
+
87
+
88
+	/**
89
+	 * Gets the SQL string for joining the join table to the other model's pk's table. Eg "LEFT JOIN real_other_table
90
+	 * AS other_table_alias ON join_table_alias.fk_to_other_table = other_table_alias.pk" If you want to join between
91
+	 * modelA -> joinModelAB -> modelB (eg, Event -> Event_Question_Group -> Question_Group), you should prepend the
92
+	 * result of this function with results from get_join_to_intermediate_model_statement(), so that you join first to
93
+	 * the intermediate join table, and then to the other model's pk's table
94
+	 *
95
+	 * @param string $model_relation_chain like 'Event.Event_Venue.Venue'
96
+	 * @return string of SQL
97
+	 * @throws \EE_Error
98
+	 */
99
+	public function get_join_statement($model_relation_chain)
100
+	{
101
+		if ($this->_model_relation_chain_to_join_model === null) {
102
+			throw new EE_Error(sprintf(__('When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement',
103
+				'event_espresso')));
104
+		}
105
+		$join_table_fk_field_to_this_table  = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
106
+		$join_table_alias                   = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model,
107
+				$this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias();
108
+		$other_table_pk_field               = $this->get_other_model()->get_primary_key_field();
109
+		$join_table_fk_field_to_other_table = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
110
+		$other_table_alias                  = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
111
+				$this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias();
112
+		$other_table                        = $this->get_other_model()->get_table_for_alias($other_table_alias);
113
+
114
+		$SQL = $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(),
115
+				$join_table_alias,
116
+				$join_table_fk_field_to_other_table->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
117
+		return $SQL;
118
+	}
119
+
120
+
121
+	/**
122
+	 * Ensures there is an entry in the join table between these two models. Feel free to do this manually if you like.
123
+	 * If the join table has additional columns (eg, the Event_Question_Group table has a is_primary column), then
124
+	 * you'll want to directly use the EEM_Event_Question_Group model to add the entry to the table and set those extra
125
+	 * columns' values
126
+	 *
127
+	 * @param EE_Base_Class|int $this_obj_or_id
128
+	 * @param EE_Base_Class|int $other_obj_or_id
129
+	 * @param array             $extra_join_model_fields_n_values col=>val pairs that are used as extra conditions for
130
+	 *                                                            checking existing values and for setting new rows if
131
+	 *                                                            no exact matches.
132
+	 * @return EE_Base_Class
133
+	 * @throws \EE_Error
134
+	 */
135
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array())
136
+	{
137
+		$this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
138
+		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
139
+		//check if such a relationship already exists
140
+		$join_model_fk_to_this_model  = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
141
+		$join_model_fk_to_other_model = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
142
+
143
+		$cols_n_values = array(
144
+			$join_model_fk_to_this_model->get_name()  => $this_model_obj->ID(),
145
+			$join_model_fk_to_other_model->get_name() => $other_model_obj->ID(),
146
+		);
147
+
148
+		//if $where_query exists lets add them to the query_params.
149
+		if (! empty($extra_join_model_fields_n_values)) {
150
+			//make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name)
151
+			//make sure we strip THIS models name from the query param
152
+			$parsed_query = array();
153
+			foreach ($extra_join_model_fields_n_values as $query_param => $val) {
154
+				$query_param                = str_replace($this->get_join_model()->get_this_model_name() . ".", "",
155
+					$query_param);
156
+				$parsed_query[$query_param] = $val;
157
+			}
158
+			$cols_n_values = array_merge($cols_n_values, $parsed_query);
159
+		}
160
+
161
+		$query_params = array($cols_n_values);
162
+
163
+
164
+		$existing_entry_in_join_table = $this->get_join_model()->get_one($query_params);
165
+		//if there is already an entry in the join table, indicating a relationship, we're done
166
+		//again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to
167
+		//the other tables, use the joining model directly!
168
+		if (! $existing_entry_in_join_table) {
169
+			$this->get_join_model()->insert($cols_n_values);
170
+		}
171
+		return $other_model_obj;
172
+	}
173
+
174
+
175
+	/**
176
+	 * Deletes any rows in the join table that have foreign keys matching the other model objects specified
177
+	 *
178
+	 * @param EE_Base_Class|int $this_obj_or_id
179
+	 * @param EE_Base_Class|int $other_obj_or_id
180
+	 * @param array             $where_query col=>val pairs that are used as extra conditions for checking existing
181
+	 *                                       values and for removing existing rows if exact matches exist.
182
+	 * @return EE_Base_Class
183
+	 * @throws \EE_Error
184
+	 */
185
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array())
186
+	{
187
+		$this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
188
+		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
189
+		//check if such a relationship already exists
190
+		$join_model_fk_to_this_model  = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
191
+		$join_model_fk_to_other_model = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
192
+
193
+		$cols_n_values = array(
194
+			$join_model_fk_to_this_model->get_name()  => $this_model_obj->ID(),
195
+			$join_model_fk_to_other_model->get_name() => $other_model_obj->ID(),
196
+		);
197
+
198
+		//if $where_query exists lets add them to the query_params.
199
+		if (! empty($where_query)) {
200
+			//make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name)
201
+			//make sure we strip THIS models name from the query param
202
+			$parsed_query = array();
203
+			foreach ($where_query as $query_param => $val) {
204
+				$query_param                = str_replace($this->get_join_model()->get_this_model_name() . ".", "",
205
+					$query_param);
206
+				$parsed_query[$query_param] = $val;
207
+			}
208
+			$cols_n_values = array_merge($cols_n_values, $parsed_query);
209
+		}
210
+
211
+		$this->get_join_model()->delete(array($cols_n_values));
212
+		return $other_model_obj;
213
+	}
214 214
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once(EE_MODELS . 'relations/EE_Model_Relation_Base.php');
3
+require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php');
4 4
 
5 5
 
6 6
 /**
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
         //remember the model relation chain to the JOIN model, because we'll
69 69
         //need it for get_join_statement()
70 70
         $this->_model_relation_chain_to_join_model = $model_relation_chain;
71
-        $this_table_pk_field                       = $this->get_this_model()->get_primary_key_field();//get_foreign_key_to($this->get_other_model()->get_this_model_name());
71
+        $this_table_pk_field                       = $this->get_this_model()->get_primary_key_field(); //get_foreign_key_to($this->get_other_model()->get_this_model_name());
72 72
         $join_table_fk_field_to_this_table         = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
73 73
         $this_table_alias                          = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
74
-                $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias();
74
+                $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias();
75 75
 
76 76
         $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
77
-                $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias();
77
+                $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias();
78 78
         $join_table       = $this->get_join_model()->get_table_for_alias($join_table_alias);
79 79
         //phew! ok, we have all the info we need, now we can create the SQL join string
80 80
         $SQL = $this->_left_join($join_table, $join_table_alias, $join_table_fk_field_to_this_table->get_table_column(),
81 81
                 $this_table_alias,
82
-                $this_table_pk_field->get_table_column()) . $this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias);
82
+                $this_table_pk_field->get_table_column()).$this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias);
83 83
 
84 84
         return $SQL;
85 85
     }
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
         }
105 105
         $join_table_fk_field_to_this_table  = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
106 106
         $join_table_alias                   = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model,
107
-                $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias();
107
+                $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias();
108 108
         $other_table_pk_field               = $this->get_other_model()->get_primary_key_field();
109 109
         $join_table_fk_field_to_other_table = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
110 110
         $other_table_alias                  = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
111
-                $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias();
111
+                $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias();
112 112
         $other_table                        = $this->get_other_model()->get_table_for_alias($other_table_alias);
113 113
 
114 114
         $SQL = $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(),
115 115
                 $join_table_alias,
116
-                $join_table_fk_field_to_other_table->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
116
+                $join_table_fk_field_to_other_table->get_table_column()).$this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
117 117
         return $SQL;
118 118
     }
119 119
 
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
         );
147 147
 
148 148
         //if $where_query exists lets add them to the query_params.
149
-        if (! empty($extra_join_model_fields_n_values)) {
149
+        if ( ! empty($extra_join_model_fields_n_values)) {
150 150
             //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name)
151 151
             //make sure we strip THIS models name from the query param
152 152
             $parsed_query = array();
153 153
             foreach ($extra_join_model_fields_n_values as $query_param => $val) {
154
-                $query_param                = str_replace($this->get_join_model()->get_this_model_name() . ".", "",
154
+                $query_param                = str_replace($this->get_join_model()->get_this_model_name().".", "",
155 155
                     $query_param);
156 156
                 $parsed_query[$query_param] = $val;
157 157
             }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
         //if there is already an entry in the join table, indicating a relationship, we're done
166 166
         //again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to
167 167
         //the other tables, use the joining model directly!
168
-        if (! $existing_entry_in_join_table) {
168
+        if ( ! $existing_entry_in_join_table) {
169 169
             $this->get_join_model()->insert($cols_n_values);
170 170
         }
171 171
         return $other_model_obj;
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
         );
197 197
 
198 198
         //if $where_query exists lets add them to the query_params.
199
-        if (! empty($where_query)) {
199
+        if ( ! empty($where_query)) {
200 200
             //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name)
201 201
             //make sure we strip THIS models name from the query param
202 202
             $parsed_query = array();
203 203
             foreach ($where_query as $query_param => $val) {
204
-                $query_param                = str_replace($this->get_join_model()->get_this_model_name() . ".", "",
204
+                $query_param                = str_replace($this->get_join_model()->get_this_model_name().".", "",
205 205
                     $query_param);
206 206
                 $parsed_query[$query_param] = $val;
207 207
             }
Please login to merge, or discard this patch.
core/db_models/relations/EE_Belongs_To_Relation.php 2 patches
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -13,128 +13,128 @@
 block discarded – undo
13 13
 class EE_Belongs_To_Relation extends EE_Model_Relation_Base
14 14
 {
15 15
 
16
-    /**
17
-     * Object representing the relationship between two models. Belongs_To means that THIS model has the foreign key
18
-     * to the other model. This knows how to join the models,
19
-     * get related models across the relation, and add-and-remove the relationships.
20
-     *
21
-     * @param boolean $block_deletes                                For Belongs_To relations, this is set to FALSE by
22
-     *                                                              default. if there are related models across this
23
-     *                                                              relation, block (prevent and add an error) the
24
-     *                                                              deletion of this model
25
-     * @param string  $related_model_objects_deletion_error_message a customized error message on blocking deletes
26
-     *                                                              instead of the default
27
-     */
28
-    public function __construct($block_deletes = false, $related_model_objects_deletion_error_message = null)
29
-    {
30
-        parent::__construct($block_deletes, $related_model_objects_deletion_error_message);
31
-    }
16
+	/**
17
+	 * Object representing the relationship between two models. Belongs_To means that THIS model has the foreign key
18
+	 * to the other model. This knows how to join the models,
19
+	 * get related models across the relation, and add-and-remove the relationships.
20
+	 *
21
+	 * @param boolean $block_deletes                                For Belongs_To relations, this is set to FALSE by
22
+	 *                                                              default. if there are related models across this
23
+	 *                                                              relation, block (prevent and add an error) the
24
+	 *                                                              deletion of this model
25
+	 * @param string  $related_model_objects_deletion_error_message a customized error message on blocking deletes
26
+	 *                                                              instead of the default
27
+	 */
28
+	public function __construct($block_deletes = false, $related_model_objects_deletion_error_message = null)
29
+	{
30
+		parent::__construct($block_deletes, $related_model_objects_deletion_error_message);
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * get_join_statement
36
-     *
37
-     * @param string $model_relation_chain
38
-     * @return string
39
-     * @throws \EE_Error
40
-     */
41
-    public function get_join_statement($model_relation_chain)
42
-    {
43
-        //create the sql string like
44
-        $this_table_fk_field  = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
45
-        $other_table_pk_field = $this->get_other_model()->get_primary_key_field();
46
-        $this_table_alias     = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
47
-                $this->get_this_model()->get_this_model_name()) . $this_table_fk_field->get_table_alias();
48
-        $other_table_alias    = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
49
-                $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias();
50
-        $other_table          = $this->get_other_model()->get_table_for_alias($other_table_alias);
51
-        return $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(),
52
-                $this_table_alias,
53
-                $this_table_fk_field->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
54
-    }
34
+	/**
35
+	 * get_join_statement
36
+	 *
37
+	 * @param string $model_relation_chain
38
+	 * @return string
39
+	 * @throws \EE_Error
40
+	 */
41
+	public function get_join_statement($model_relation_chain)
42
+	{
43
+		//create the sql string like
44
+		$this_table_fk_field  = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
45
+		$other_table_pk_field = $this->get_other_model()->get_primary_key_field();
46
+		$this_table_alias     = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
47
+				$this->get_this_model()->get_this_model_name()) . $this_table_fk_field->get_table_alias();
48
+		$other_table_alias    = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
49
+				$this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias();
50
+		$other_table          = $this->get_other_model()->get_table_for_alias($other_table_alias);
51
+		return $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(),
52
+				$this_table_alias,
53
+				$this_table_fk_field->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * Sets this model object's foreign key to the other model object's primary key. Feel free to do this manually if
59
-     * you like.
60
-     *
61
-     * @param EE_Base_Class|int $this_obj_or_id
62
-     * @param EE_Base_Class|int $other_obj_or_id
63
-     * @param array             $extra_join_model_fields_n_values
64
-     * @return \EE_Base_Class
65
-     * @throws \EE_Error
66
-     */
67
-    public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array())
68
-    {
69
-        $this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
70
-        $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
71
-        //find the field on the other model which is a foreign key to this model
72
-        $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
73
-        if ($this_model_obj->get($fk_on_this_model->get_name()) != $other_model_obj->ID()) {
74
-            //set that field on the other model to this model's ID
75
-            $this_model_obj->set($fk_on_this_model->get_name(), $other_model_obj->ID());
76
-            $this_model_obj->save();
77
-        }
78
-        return $other_model_obj;
79
-    }
57
+	/**
58
+	 * Sets this model object's foreign key to the other model object's primary key. Feel free to do this manually if
59
+	 * you like.
60
+	 *
61
+	 * @param EE_Base_Class|int $this_obj_or_id
62
+	 * @param EE_Base_Class|int $other_obj_or_id
63
+	 * @param array             $extra_join_model_fields_n_values
64
+	 * @return \EE_Base_Class
65
+	 * @throws \EE_Error
66
+	 */
67
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array())
68
+	{
69
+		$this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
70
+		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
71
+		//find the field on the other model which is a foreign key to this model
72
+		$fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
73
+		if ($this_model_obj->get($fk_on_this_model->get_name()) != $other_model_obj->ID()) {
74
+			//set that field on the other model to this model's ID
75
+			$this_model_obj->set($fk_on_this_model->get_name(), $other_model_obj->ID());
76
+			$this_model_obj->save();
77
+		}
78
+		return $other_model_obj;
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * Sets the this model object's foreign key to its default, instead of pointing to the other model object
84
-     *
85
-     * @param EE_Base_Class|int $this_obj_or_id
86
-     * @param EE_Base_Class|int $other_obj_or_id
87
-     * @param array             $where_query
88
-     * @return \EE_Base_Class
89
-     * @throws \EE_Error
90
-     */
91
-    public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array())
92
-    {
93
-        $this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
94
-        $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id);
95
-        //find the field on the other model which is a foreign key to this model
96
-        $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
97
-        //set that field on the other model to this model's ID
98
-        $this_model_obj->set($fk_on_this_model->get_name(), null, true);
99
-        $this_model_obj->save();
100
-        return $other_model_obj;
101
-    }
82
+	/**
83
+	 * Sets the this model object's foreign key to its default, instead of pointing to the other model object
84
+	 *
85
+	 * @param EE_Base_Class|int $this_obj_or_id
86
+	 * @param EE_Base_Class|int $other_obj_or_id
87
+	 * @param array             $where_query
88
+	 * @return \EE_Base_Class
89
+	 * @throws \EE_Error
90
+	 */
91
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array())
92
+	{
93
+		$this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
94
+		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id);
95
+		//find the field on the other model which is a foreign key to this model
96
+		$fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
97
+		//set that field on the other model to this model's ID
98
+		$this_model_obj->set($fk_on_this_model->get_name(), null, true);
99
+		$this_model_obj->save();
100
+		return $other_model_obj;
101
+	}
102 102
 
103 103
 
104
-    /**
105
-     * Overrides parent so that we don't NEED to save the $model_object before getting the related objects.
106
-     *
107
-     * @param EE_Base_Class $model_obj_or_id
108
-     * @param array         $query_params                            like EEM_Base::get_all's $query_params
109
-     * @param boolean       $values_already_prepared_by_model_object @deprecated since 4.8.1
110
-     * @return EE_Base_Class[]
111
-     * @throws \EE_Error
112
-     */
113
-    public function get_all_related(
114
-        $model_obj_or_id,
115
-        $query_params = array(),
116
-        $values_already_prepared_by_model_object = false
117
-    ) {
118
-        if ($values_already_prepared_by_model_object !== false) {
119
-            EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related',
120
-                __('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'),
121
-                '4.8.1');
122
-        }
123
-        //get column on this model object which is a foreign key to the other model
124
-        $fk_field_obj = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
125
-        //get its value
126
-        if ($model_obj_or_id instanceof EE_Base_Class) {
127
-            $model_obj = $model_obj_or_id;
128
-        } else {
129
-            $model_obj = $this->get_this_model()->ensure_is_obj($model_obj_or_id);
130
-        }
131
-        $ID_value_on_other_model = $model_obj->get($fk_field_obj->get_name());
132
-        //get all where their PK matches that value
133
-        $query_params[0][$this->get_other_model()->get_primary_key_field()->get_name()] = $ID_value_on_other_model;
134
-        $query_params                                                                   = $this->_disable_default_where_conditions_on_query_param($query_params);
104
+	/**
105
+	 * Overrides parent so that we don't NEED to save the $model_object before getting the related objects.
106
+	 *
107
+	 * @param EE_Base_Class $model_obj_or_id
108
+	 * @param array         $query_params                            like EEM_Base::get_all's $query_params
109
+	 * @param boolean       $values_already_prepared_by_model_object @deprecated since 4.8.1
110
+	 * @return EE_Base_Class[]
111
+	 * @throws \EE_Error
112
+	 */
113
+	public function get_all_related(
114
+		$model_obj_or_id,
115
+		$query_params = array(),
116
+		$values_already_prepared_by_model_object = false
117
+	) {
118
+		if ($values_already_prepared_by_model_object !== false) {
119
+			EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related',
120
+				__('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'),
121
+				'4.8.1');
122
+		}
123
+		//get column on this model object which is a foreign key to the other model
124
+		$fk_field_obj = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
125
+		//get its value
126
+		if ($model_obj_or_id instanceof EE_Base_Class) {
127
+			$model_obj = $model_obj_or_id;
128
+		} else {
129
+			$model_obj = $this->get_this_model()->ensure_is_obj($model_obj_or_id);
130
+		}
131
+		$ID_value_on_other_model = $model_obj->get($fk_field_obj->get_name());
132
+		//get all where their PK matches that value
133
+		$query_params[0][$this->get_other_model()->get_primary_key_field()->get_name()] = $ID_value_on_other_model;
134
+		$query_params                                                                   = $this->_disable_default_where_conditions_on_query_param($query_params);
135 135
 //		echo '$query_params';
136 136
 //		var_dump($query_params);
137
-        return $this->get_other_model()->get_all($query_params);
138
-    }
137
+		return $this->get_other_model()->get_all($query_params);
138
+	}
139 139
 
140 140
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once(EE_MODELS . 'relations/EE_Model_Relation_Base.php');
2
+require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php');
3 3
 
4 4
 /**
5 5
  * Class EE_Belongs_To_Relation
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
         $this_table_fk_field  = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
45 45
         $other_table_pk_field = $this->get_other_model()->get_primary_key_field();
46 46
         $this_table_alias     = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
47
-                $this->get_this_model()->get_this_model_name()) . $this_table_fk_field->get_table_alias();
47
+                $this->get_this_model()->get_this_model_name()).$this_table_fk_field->get_table_alias();
48 48
         $other_table_alias    = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,
49
-                $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias();
49
+                $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias();
50 50
         $other_table          = $this->get_other_model()->get_table_for_alias($other_table_alias);
51 51
         return $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(),
52 52
                 $this_table_alias,
53
-                $this_table_fk_field->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
53
+                $this_table_fk_field->get_table_column()).$this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
54 54
     }
55 55
 
56 56
 
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
         $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474 474
         $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475 475
         global $ee_menu_slugs;
476
-        $ee_menu_slugs = (array)$ee_menu_slugs;
476
+        $ee_menu_slugs = (array) $ee_menu_slugs;
477 477
         if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478 478
             return false;
479 479
         }
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
         //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489 489
         $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490 490
         $this->_current_view = $this->_req_action;
491
-        $this->_req_nonce = $this->_req_action . '_nonce';
491
+        $this->_req_nonce = $this->_req_action.'_nonce';
492 492
         $this->_define_page_props();
493 493
         $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494 494
         //default things
@@ -509,11 +509,11 @@  discard block
 block discarded – undo
509 509
             $this->_extend_page_config_for_cpt();
510 510
         }
511 511
         //filter routes and page_config so addons can add their stuff. Filtering done per class
512
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
512
+        $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this);
513
+        $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this);
514 514
         //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
515
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
515
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
516
+            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2);
517 517
         }
518 518
         //next route only if routing enabled
519 519
         if ($this->_routing && ! defined('DOING_AJAX')) {
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
             if ($this->_is_UI_request) {
524 524
                 //admin_init stuff - global, all views for this page class, specific view
525 525
                 add_action('admin_init', array($this, 'admin_init'), 10);
526
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
526
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
527
+                    add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
528 528
                 }
529 529
             } else {
530 530
                 //hijack regular WP loading and route admin request immediately
@@ -544,17 +544,17 @@  discard block
 block discarded – undo
544 544
      */
545 545
     private function _do_other_page_hooks()
546 546
     {
547
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
547
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
548 548
         foreach ($registered_pages as $page) {
549 549
             //now let's setup the file name and class that should be present
550 550
             $classname = str_replace('.class.php', '', $page);
551 551
             //autoloaders should take care of loading file
552 552
             if ( ! class_exists($classname)) {
553
-                $error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
553
+                $error_msg[] = sprintf(esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
554 554
                 $error_msg[] = $error_msg[0]
555 555
                                . "\r\n"
556
-                               . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
557
-                                'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>');
556
+                               . sprintf(esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
557
+                                'event_espresso'), $page, '<br />', '<strong>'.$classname.'</strong>');
558 558
                 throw new EE_Error(implode('||', $error_msg));
559 559
             }
560 560
             $a = new ReflectionClass($classname);
@@ -590,13 +590,13 @@  discard block
 block discarded – undo
590 590
         //load admin_notices - global, page class, and view specific
591 591
         add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592 592
         add_action('admin_notices', array($this, 'admin_notices'), 10);
593
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
593
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
594
+            add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
595 595
         }
596 596
         //load network admin_notices - global, page class, and view specific
597 597
         add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
598
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
599
+            add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
600 600
         }
601 601
         //this will save any per_page screen options if they are present
602 602
         $this->_set_per_page_screen_options();
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
         //add screen options - global, page child class, and view specific
609 609
         $this->_add_global_screen_options();
610 610
         $this->_add_screen_options();
611
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
611
+        if (method_exists($this, '_add_screen_options_'.$this->_current_view)) {
612
+            call_user_func(array($this, '_add_screen_options_'.$this->_current_view));
613 613
         }
614 614
         //add help tab(s) and tours- set via page_config and qtips.
615 615
         $this->_add_help_tour();
@@ -618,31 +618,31 @@  discard block
 block discarded – undo
618 618
         //add feature_pointers - global, page child class, and view specific
619 619
         $this->_add_feature_pointers();
620 620
         $this->_add_global_feature_pointers();
621
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
621
+        if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) {
622
+            call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view));
623 623
         }
624 624
         //enqueue scripts/styles - global, page class, and view specific
625 625
         add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626 626
         add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
627
+        if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) {
628
+            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15);
629 629
         }
630 630
         add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631 631
         //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
632 632
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633 633
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
634
+        if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) {
635
+            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101);
636 636
         }
637 637
         //admin footer scripts
638 638
         add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639 639
         add_action('admin_footer', array($this, 'admin_footer'), 100);
640
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
640
+        if (method_exists($this, 'admin_footer_'.$this->_current_view)) {
641
+            add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101);
642 642
         }
643 643
         do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644 644
         //targeted hook
645
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
645
+        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action);
646 646
     }
647 647
 
648 648
 
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
             // user error msg
719 719
             $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720 720
             // developer error msg
721
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
721
+            $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722 722
             throw new EE_Error($error_msg);
723 723
         }
724 724
         // and that the requested page route exists
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
             // user error msg
730 730
             $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731 731
             // developer error msg
732
-            $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
732
+            $error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733 733
             throw new EE_Error($error_msg);
734 734
         }
735 735
         // and that a default route exists
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
             // user error msg
738 738
             $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739 739
             // developer error msg
740
-            $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
740
+            $error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741 741
             throw new EE_Error($error_msg);
742 742
         }
743 743
         //first lets' catch if the UI request has EVER been set.
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
             // user error msg
767 767
             $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768 768
             // developer error msg
769
-            $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
769
+            $error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770 770
             throw new EE_Error($error_msg);
771 771
         }
772 772
     }
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
             // these are not the droids you are looking for !!!
789 789
             $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790 790
             if (WP_DEBUG) {
791
-                $msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
791
+                $msg .= "\n  ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792 792
             }
793 793
             if ( ! defined('DOING_AJAX')) {
794 794
                 wp_die($msg);
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
                 if (strpos($key, 'nonce') !== false) {
967 967
                     continue;
968 968
                 }
969
-                $args['wp_referer[' . $key . ']'] = $value;
969
+                $args['wp_referer['.$key.']'] = $value;
970 970
             }
971 971
         }
972 972
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
                     if ($tour instanceof EE_Help_Tour_final_stop) {
1013 1013
                         continue;
1014 1014
                     }
1015
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1015
+                    $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>';
1016 1016
                 }
1017 1017
                 $tour_buttons .= implode('<br />', $tb);
1018 1018
                 $tour_buttons .= '</div></div>';
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
                     throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1025 1025
                             'event_espresso'), $config['help_sidebar'], get_class($this)));
1026 1026
                 }
1027
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1027
+                $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1028 1028
                 $content .= $tour_buttons; //add help tour buttons.
1029 1029
                 //do we have any help tours setup?  Cause if we do we want to add the buttons
1030 1030
                 $this->_current_screen->set_help_sidebar($content);
@@ -1037,13 +1037,13 @@  discard block
 block discarded – undo
1037 1037
             if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1038 1038
                 $_ht['id'] = $this->page_slug;
1039 1039
                 $_ht['title'] = __('Help Tours', 'event_espresso');
1040
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1040
+                $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>';
1041 1041
                 $this->_current_screen->add_help_tab($_ht);
1042 1042
             }/**/
1043 1043
             if ( ! isset($config['help_tabs'])) {
1044 1044
                 return;
1045 1045
             } //no help tabs for this route
1046
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1046
+            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1047 1047
                 //we're here so there ARE help tabs!
1048 1048
                 //make sure we've got what we need
1049 1049
                 if ( ! isset($cfg['title'])) {
@@ -1058,9 +1058,9 @@  discard block
 block discarded – undo
1058 1058
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1059 1059
                     //second priority goes to filename
1060 1060
                 } else if ( ! empty($cfg['filename'])) {
1061
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1061
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1062 1062
                     //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1063
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1063
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path;
1064 1064
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1065 1065
                     if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1066 1066
                         EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
                     return;
1080 1080
                 }
1081 1081
                 //setup config array for help tab method
1082
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1082
+                $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1083 1083
                 $_ht = array(
1084 1084
                         'id'       => $id,
1085 1085
                         'title'    => $cfg['title'],
@@ -1117,9 +1117,9 @@  discard block
 block discarded – undo
1117 1117
             }
1118 1118
             if (isset($config['help_tour'])) {
1119 1119
                 foreach ($config['help_tour'] as $tour) {
1120
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1120
+                    $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1121 1121
                     //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1122
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1122
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path;
1123 1123
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1124 1124
                     if ( ! is_readable($file_path)) {
1125 1125
                         EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
                     require_once $file_path;
1130 1130
                     if ( ! class_exists($tour)) {
1131 1131
                         $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1132
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1132
+                        $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1133 1133
                                         'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1134 1134
                         throw new EE_Error(implode('||', $error_msg));
1135 1135
                     }
@@ -1161,11 +1161,11 @@  discard block
 block discarded – undo
1161 1161
     protected function _add_qtips()
1162 1162
     {
1163 1163
         if (isset($this->_route_config['qtips'])) {
1164
-            $qtips = (array)$this->_route_config['qtips'];
1164
+            $qtips = (array) $this->_route_config['qtips'];
1165 1165
             //load qtip loader
1166 1166
             $path = array(
1167
-                    $this->_get_dir() . '/qtips/',
1168
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1167
+                    $this->_get_dir().'/qtips/',
1168
+                    EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1169 1169
             );
1170 1170
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1171 1171
         }
@@ -1195,11 +1195,11 @@  discard block
 block discarded – undo
1195 1195
             if ( ! $this->check_user_access($slug, true)) {
1196 1196
                 continue;
1197 1197
             } //no nav tab becasue current user does not have access.
1198
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1198
+            $css_class = isset($config['css_class']) ? $config['css_class'].' ' : '';
1199 1199
             $this->_nav_tabs[$slug] = array(
1200 1200
                     'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1201 1201
                     'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1202
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1202
+                    'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class,
1203 1203
                     'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1204 1204
             );
1205 1205
             $i++;
@@ -1262,11 +1262,11 @@  discard block
 block discarded – undo
1262 1262
             $capability = empty($capability) ? 'manage_options' : $capability;
1263 1263
         }
1264 1264
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1265
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1265
+        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) {
1266 1266
             if ($verify_only) {
1267 1267
                 return false;
1268 1268
             } else {
1269
-                if ( is_user_logged_in() ) {
1269
+                if (is_user_logged_in()) {
1270 1270
                     wp_die(__('You do not have access to this route.', 'event_espresso'));
1271 1271
                 } else {
1272 1272
                     return false;
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
     public function admin_footer_global()
1359 1359
     {
1360 1360
         //dialog container for dialog helper
1361
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1361
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1362 1362
         $d_cont .= '<div class="ee-notices"></div>';
1363 1363
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1364 1364
         $d_cont .= '</div>';
@@ -1368,7 +1368,7 @@  discard block
 block discarded – undo
1368 1368
             echo implode('<br />', $this->_help_tour[$this->_req_action]);
1369 1369
         }
1370 1370
         //current set timezone for timezone js
1371
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1371
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1372 1372
     }
1373 1373
 
1374 1374
 
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
     {
1394 1394
         $content = '';
1395 1395
         $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1396
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1396
+        $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php';
1397 1397
         //loop through the array and setup content
1398 1398
         foreach ($help_array as $trigger => $help) {
1399 1399
             //make sure the array is setup properly
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
     private function _get_help_content()
1428 1428
     {
1429 1429
         //what is the method we're looking for?
1430
-        $method_name = '_help_popup_content_' . $this->_req_action;
1430
+        $method_name = '_help_popup_content_'.$this->_req_action;
1431 1431
         //if method doesn't exist let's get out.
1432 1432
         if ( ! method_exists($this, $method_name)) {
1433 1433
             return array();
@@ -1471,8 +1471,8 @@  discard block
 block discarded – undo
1471 1471
             $help_content = $this->_set_help_popup_content($help_array, false);
1472 1472
         }
1473 1473
         //let's setup the trigger
1474
-        $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1475
-        $content = $content . $help_content;
1474
+        $content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1475
+        $content = $content.$help_content;
1476 1476
         if ($display) {
1477 1477
             echo $content;
1478 1478
         } else {
@@ -1532,32 +1532,32 @@  discard block
 block discarded – undo
1532 1532
             add_action('admin_head', array($this, 'add_xdebug_style'));
1533 1533
         }
1534 1534
         //register all styles
1535
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1536
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1535
+        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1536
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1537 1537
         //helpers styles
1538
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1538
+        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1539 1539
         //enqueue global styles
1540 1540
         wp_enqueue_style('ee-admin-css');
1541 1541
         /** SCRIPTS **/
1542 1542
         //register all scripts
1543
-        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1544
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1545
-        wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1546
-        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1543
+        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1544
+        wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1545
+        wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1546
+        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1547 1547
         // register jQuery Validate - see /includes/functions/wp_hooks.php
1548 1548
         add_filter('FHEE_load_jquery_validate', '__return_true');
1549 1549
         add_filter('FHEE_load_joyride', '__return_true');
1550 1550
         //script for sorting tables
1551
-        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1551
+        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1552 1552
         //script for parsing uri's
1553
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1553
+        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1554 1554
         //and parsing associative serialized form elements
1555
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1555
+        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1556 1556
         //helpers scripts
1557
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1558
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1559
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1560
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1557
+        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1558
+        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1559
+        wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1560
+        wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1561 1561
         //google charts
1562 1562
         wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1563 1563
         //enqueue global scripts
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
          */
1579 1579
         if ( ! empty($this->_help_tour)) {
1580 1580
             //register the js for kicking things off
1581
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1581
+            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1582 1582
             //setup tours for the js tour object
1583 1583
             foreach ($this->_help_tour['tours'] as $tour) {
1584 1584
                 $tours[] = array(
@@ -1677,17 +1677,17 @@  discard block
 block discarded – undo
1677 1677
             return;
1678 1678
         } //not a list_table view so get out.
1679 1679
         //list table functions are per view specific (because some admin pages might have more than one listtable!)
1680
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1680
+        if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === false) {
1681 1681
             //user error msg
1682 1682
             $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1683 1683
             //developer error msg
1684
-            $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1685
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1684
+            $error_msg .= '||'.sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1685
+                            $this->_req_action, '_set_list_table_views_'.$this->_req_action);
1686 1686
             throw new EE_Error($error_msg);
1687 1687
         }
1688 1688
         //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1689
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1690
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1689
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views);
1690
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1691 1691
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1692 1692
         $this->_set_list_table_view();
1693 1693
         $this->_set_list_table_object();
@@ -1762,7 +1762,7 @@  discard block
 block discarded – undo
1762 1762
             // check for current view
1763 1763
             $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1764 1764
             $query_args['action'] = $this->_req_action;
1765
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1765
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
1766 1766
             $query_args['status'] = $view['slug'];
1767 1767
             //merge any other arguments sent in.
1768 1768
             if (isset($extra_query_args[$view['slug']])) {
@@ -1800,14 +1800,14 @@  discard block
 block discarded – undo
1800 1800
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1801 1801
         foreach ($values as $value) {
1802 1802
             if ($value < $max_entries) {
1803
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1803
+                $selected = $value == $per_page ? ' selected="'.$per_page.'"' : '';
1804 1804
                 $entries_per_page_dropdown .= '
1805
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1805
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
1806 1806
             }
1807 1807
         }
1808
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1808
+        $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : '';
1809 1809
         $entries_per_page_dropdown .= '
1810
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1810
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
1811 1811
         $entries_per_page_dropdown .= '
1812 1812
 					</select>
1813 1813
 					entries
@@ -1829,7 +1829,7 @@  discard block
 block discarded – undo
1829 1829
     public function _set_search_attributes()
1830 1830
     {
1831 1831
         $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1832
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1832
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
1833 1833
     }
1834 1834
 
1835 1835
     /*** END LIST TABLE METHODS **/
@@ -1867,7 +1867,7 @@  discard block
 block discarded – undo
1867 1867
                     // user error msg
1868 1868
                     $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1869 1869
                     // developer error msg
1870
-                    $error_msg .= '||' . sprintf(
1870
+                    $error_msg .= '||'.sprintf(
1871 1871
                                     __(
1872 1872
                                             'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1873 1873
                                             'event_espresso'
@@ -1897,15 +1897,15 @@  discard block
 block discarded – undo
1897 1897
                 && is_array($this->_route_config['columns'])
1898 1898
                 && count($this->_route_config['columns']) === 2
1899 1899
         ) {
1900
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1900
+            add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1]));
1901 1901
             $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1902 1902
             $screen_id = $this->_current_screen->id;
1903
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1903
+            $screen_columns = (int) get_user_option("screen_layout_$screen_id");
1904 1904
             $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1905
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1905
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
1906 1906
             $this->_template_args['current_page'] = $this->_wp_page_slug;
1907 1907
             $this->_template_args['screen'] = $this->_current_screen;
1908
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1908
+            $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php';
1909 1909
             //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1910 1910
             $this->_route_config['has_metaboxes'] = true;
1911 1911
         }
@@ -1952,7 +1952,7 @@  discard block
 block discarded – undo
1952 1952
      */
1953 1953
     public function espresso_ratings_request()
1954 1954
     {
1955
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1955
+        $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php';
1956 1956
         EEH_Template::display_template($template_path, array());
1957 1957
     }
1958 1958
 
@@ -1960,18 +1960,18 @@  discard block
 block discarded – undo
1960 1960
 
1961 1961
     public static function cached_rss_display($rss_id, $url)
1962 1962
     {
1963
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1963
+        $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading&#8230;').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>';
1964 1964
         $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1965
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1966
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1967
-        $post = '</div>' . "\n";
1968
-        $cache_key = 'ee_rss_' . md5($rss_id);
1965
+        $pre = '<div class="espresso-rss-display">'."\n\t";
1966
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
1967
+        $post = '</div>'."\n";
1968
+        $cache_key = 'ee_rss_'.md5($rss_id);
1969 1969
         if (false != ($output = get_transient($cache_key))) {
1970
-            echo $pre . $output . $post;
1970
+            echo $pre.$output.$post;
1971 1971
             return true;
1972 1972
         }
1973 1973
         if ( ! $doing_ajax) {
1974
-            echo $pre . $loading . $post;
1974
+            echo $pre.$loading.$post;
1975 1975
             return false;
1976 1976
         }
1977 1977
         ob_start();
@@ -2030,7 +2030,7 @@  discard block
 block discarded – undo
2030 2030
 
2031 2031
     public function espresso_sponsors_post_box()
2032 2032
     {
2033
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2033
+        $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php';
2034 2034
         EEH_Template::display_template($templatepath);
2035 2035
     }
2036 2036
 
@@ -2038,7 +2038,7 @@  discard block
 block discarded – undo
2038 2038
 
2039 2039
     private function _publish_post_box()
2040 2040
     {
2041
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2041
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2042 2042
         //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2043 2043
         if ( ! empty($this->_labels['publishbox'])) {
2044 2044
             $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
@@ -2055,7 +2055,7 @@  discard block
 block discarded – undo
2055 2055
     {
2056 2056
         //if we have extra content set let's add it in if not make sure its empty
2057 2057
         $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2058
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2058
+        $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php';
2059 2059
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2060 2060
     }
2061 2061
 
@@ -2224,7 +2224,7 @@  discard block
 block discarded – undo
2224 2224
         //if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2225 2225
         $call_back_func = $create_func ? create_function('$post, $metabox',
2226 2226
                 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2227
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2227
+        add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2228 2228
     }
2229 2229
 
2230 2230
 
@@ -2304,10 +2304,10 @@  discard block
 block discarded – undo
2304 2304
                 ? 'poststuff'
2305 2305
                 : 'espresso-default-admin';
2306 2306
         $template_path = $sidebar
2307
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2308
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2307
+                ? EE_ADMIN_TEMPLATE.'admin_details_wrapper.template.php'
2308
+                : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2309 2309
         if (defined('DOING_AJAX') && DOING_AJAX) {
2310
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2310
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2311 2311
         }
2312 2312
         $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2313 2313
         $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
@@ -2353,7 +2353,7 @@  discard block
 block discarded – undo
2353 2353
                         true
2354 2354
                 )
2355 2355
                 : $this->_template_args['preview_action_button'];
2356
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2356
+        $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php';
2357 2357
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2358 2358
                 $template_path,
2359 2359
                 $this->_template_args,
@@ -2404,7 +2404,7 @@  discard block
 block discarded – undo
2404 2404
         //setup search attributes
2405 2405
         $this->_set_search_attributes();
2406 2406
         $this->_template_args['current_page'] = $this->_wp_page_slug;
2407
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2407
+        $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2408 2408
         $this->_template_args['table_url'] = defined('DOING_AJAX')
2409 2409
                 ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2410 2410
                 : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
@@ -2414,22 +2414,22 @@  discard block
 block discarded – undo
2414 2414
         $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2415 2415
         if ( ! empty($ajax_sorting_callback)) {
2416 2416
             $sortable_list_table_form_fields = wp_nonce_field(
2417
-                    $ajax_sorting_callback . '_nonce',
2418
-                    $ajax_sorting_callback . '_nonce',
2417
+                    $ajax_sorting_callback.'_nonce',
2418
+                    $ajax_sorting_callback.'_nonce',
2419 2419
                     false,
2420 2420
                     false
2421 2421
             );
2422 2422
             //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2423 2423
             //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2424
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2425
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2424
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />';
2425
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />';
2426 2426
         } else {
2427 2427
             $sortable_list_table_form_fields = '';
2428 2428
         }
2429 2429
         $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2430 2430
         $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2431
-        $nonce_ref = $this->_req_action . '_nonce';
2432
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2431
+        $nonce_ref = $this->_req_action.'_nonce';
2432
+        $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
2433 2433
         $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2434 2434
         //display message about search results?
2435 2435
         $this->_template_args['before_list_table'] .= apply_filters(
@@ -2441,7 +2441,7 @@  discard block
 block discarded – undo
2441 2441
                                         'Displaying search results for the search string: %1$s',
2442 2442
                                         'event_espresso'
2443 2443
                                 ),
2444
-                                '<strong><em>' . trim( $this->_req_data['s'], '%' ) . '</em></strong>'
2444
+                                '<strong><em>'.trim($this->_req_data['s'], '%').'</em></strong>'
2445 2445
                             )
2446 2446
                             . '</p>'
2447 2447
                         : '',
@@ -2479,8 +2479,8 @@  discard block
 block discarded – undo
2479 2479
      */
2480 2480
     protected function _display_legend($items)
2481 2481
     {
2482
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2483
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2482
+        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this);
2483
+        $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php';
2484 2484
         return EEH_Template::display_template($legend_template, $this->_template_args, true);
2485 2485
     }
2486 2486
 
@@ -2572,15 +2572,15 @@  discard block
 block discarded – undo
2572 2572
         $this->_nav_tabs = $this->_get_main_nav_tabs();
2573 2573
         $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2574 2574
         $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2575
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2575
+        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view,
2576 2576
                 isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2577
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2577
+        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view,
2578 2578
                 isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2579 2579
         $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2580 2580
         // load settings page wrapper template
2581
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2581
+        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE.'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php';
2582 2582
         //about page?
2583
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2583
+        $template_path = $about ? EE_ADMIN_TEMPLATE.'about_admin_wrapper.template.php' : $template_path;
2584 2584
         if (defined('DOING_AJAX')) {
2585 2585
             $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2586 2586
             $this->_return_json();
@@ -2652,20 +2652,20 @@  discard block
 block discarded – undo
2652 2652
     protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2653 2653
     {
2654 2654
         //make sure $text and $actions are in an array
2655
-        $text = (array)$text;
2656
-        $actions = (array)$actions;
2655
+        $text = (array) $text;
2656
+        $actions = (array) $actions;
2657 2657
         $referrer_url = empty($referrer) ? '' : $referrer;
2658
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2659
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2658
+        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />'
2659
+                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />';
2660 2660
         $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2661 2661
         $default_names = array('save', 'save_and_close');
2662 2662
         //add in a hidden index for the current page (so save and close redirects properly)
2663 2663
         $this->_template_args['save_buttons'] = $referrer_url;
2664 2664
         foreach ($button_text as $key => $button) {
2665 2665
             $ref = $default_names[$key];
2666
-            $id = $this->_current_view . '_' . $ref;
2666
+            $id = $this->_current_view.'_'.$ref;
2667 2667
             $name = ! empty($actions) ? $actions[$key] : $ref;
2668
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2668
+            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />';
2669 2669
             if ( ! $both) {
2670 2670
                 break;
2671 2671
             }
@@ -2701,15 +2701,15 @@  discard block
 block discarded – undo
2701 2701
     {
2702 2702
         if (empty($route)) {
2703 2703
             $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2704
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2705
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2704
+            $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2705
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
2706 2706
         }
2707 2707
         // open form
2708
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2708
+        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >';
2709 2709
         // add nonce
2710
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2710
+        $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
2711 2711
         //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2712
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2712
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
2713 2713
         // add REQUIRED form action
2714 2714
         $hidden_fields = array(
2715 2715
                 'action' => array('type' => 'hidden', 'value' => $route),
@@ -2719,8 +2719,8 @@  discard block
 block discarded – undo
2719 2719
         // generate form fields
2720 2720
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2721 2721
         // add fields to form
2722
-        foreach ((array)$form_fields as $field_name => $form_field) {
2723
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2722
+        foreach ((array) $form_fields as $field_name => $form_field) {
2723
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
2724 2724
         }
2725 2725
         // close form
2726 2726
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -2801,7 +2801,7 @@  discard block
 block discarded – undo
2801 2801
          * @param array $query_args       The original query_args array coming into the
2802 2802
          *                                method.
2803 2803
          */
2804
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2804
+        do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args);
2805 2805
         //calculate where we're going (if we have a "save and close" button pushed)
2806 2806
         if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2807 2807
             // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
@@ -2817,7 +2817,7 @@  discard block
 block discarded – undo
2817 2817
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
2818 2818
                 //is there a wp_referer array in our _default_route_query_args property?
2819 2819
                 if ($query_param == 'wp_referer') {
2820
-                    $query_value = (array)$query_value;
2820
+                    $query_value = (array) $query_value;
2821 2821
                     foreach ($query_value as $reference => $value) {
2822 2822
                         if (strpos($reference, 'nonce') !== false) {
2823 2823
                             continue;
@@ -2843,11 +2843,11 @@  discard block
 block discarded – undo
2843 2843
         // if redirecting to anything other than the main page, add a nonce
2844 2844
         if (isset($query_args['action'])) {
2845 2845
             // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2846
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2846
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
2847 2847
         }
2848 2848
         //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2849
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2850
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2849
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
2850
+        $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2851 2851
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2852 2852
         if (defined('DOING_AJAX')) {
2853 2853
             $default_data = array(
@@ -2977,7 +2977,7 @@  discard block
 block discarded – undo
2977 2977
         $args = array(
2978 2978
                 'label'   => $this->_admin_page_title,
2979 2979
                 'default' => 10,
2980
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2980
+                'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
2981 2981
         );
2982 2982
         //ONLY add the screen option if the user has access to it.
2983 2983
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3010,8 +3010,8 @@  discard block
 block discarded – undo
3010 3010
             $map_option = $option;
3011 3011
             $option = str_replace('-', '_', $option);
3012 3012
             switch ($map_option) {
3013
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3014
-                    $value = (int)$value;
3013
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3014
+                    $value = (int) $value;
3015 3015
                     if ($value < 1 || $value > 999) {
3016 3016
                         return;
3017 3017
                     }
@@ -3038,7 +3038,7 @@  discard block
 block discarded – undo
3038 3038
      */
3039 3039
     public function set_template_args($data)
3040 3040
     {
3041
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3041
+        $this->_template_args = array_merge($this->_template_args, (array) $data);
3042 3042
     }
3043 3043
 
3044 3044
 
@@ -3060,12 +3060,12 @@  discard block
 block discarded – undo
3060 3060
             $this->_verify_route($route);
3061 3061
         }
3062 3062
         //now let's set the string for what kind of transient we're setting
3063
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3063
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3064 3064
         $data = $notices ? array('notices' => $data) : $data;
3065 3065
         //is there already a transient for this route?  If there is then let's ADD to that transient
3066 3066
         $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3067 3067
         if ($existing) {
3068
-            $data = array_merge((array)$data, (array)$existing);
3068
+            $data = array_merge((array) $data, (array) $existing);
3069 3069
         }
3070 3070
         if (is_multisite() && is_network_admin()) {
3071 3071
             set_site_transient($transient, $data, 8);
@@ -3086,7 +3086,7 @@  discard block
 block discarded – undo
3086 3086
     {
3087 3087
         $user_id = get_current_user_id();
3088 3088
         $route = ! $route ? $this->_req_action : $route;
3089
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3089
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3090 3090
         $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3091 3091
         //delete transient after retrieval (just in case it hasn't expired);
3092 3092
         if (is_multisite() && is_network_admin()) {
@@ -3327,7 +3327,7 @@  discard block
 block discarded – undo
3327 3327
      */
3328 3328
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3329 3329
     {
3330
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3330
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3331 3331
     }
3332 3332
 
3333 3333
 
@@ -3341,7 +3341,7 @@  discard block
 block discarded – undo
3341 3341
      */
3342 3342
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3343 3343
     {
3344
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3344
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3345 3345
     }
3346 3346
 
3347 3347
 
Please login to merge, or discard this patch.
Indentation   +3273 added lines, -3273 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -28,2119 +28,2119 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    //set in _init_page_props()
32
-    public $page_slug;
31
+	//set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    //set in define_page_props()
39
-    protected $_admin_base_url;
38
+	//set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    //set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	//set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    //navtabs
52
-    protected $_nav_tabs;
51
+	//navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56
-    //helptourstops
57
-    protected $_help_tour = array();
56
+	//helptourstops
57
+	protected $_help_tour = array();
58 58
 
59 59
 
60
-    //template variables (used by templates)
61
-    protected $_template_path;
60
+	//template variables (used by templates)
61
+	protected $_template_path;
62 62
 
63
-    protected $_column_template_path;
63
+	protected $_column_template_path;
64 64
 
65
-    /**
66
-     * @var array $_template_args
67
-     */
68
-    protected $_template_args = array();
65
+	/**
66
+	 * @var array $_template_args
67
+	 */
68
+	protected $_template_args = array();
69 69
 
70
-    /**
71
-     * this will hold the list table object for a given view.
72
-     *
73
-     * @var EE_Admin_List_Table $_list_table_object
74
-     */
75
-    protected $_list_table_object;
70
+	/**
71
+	 * this will hold the list table object for a given view.
72
+	 *
73
+	 * @var EE_Admin_List_Table $_list_table_object
74
+	 */
75
+	protected $_list_table_object;
76 76
 
77
-    //bools
78
-    protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
77
+	//bools
78
+	protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
79 79
 
80
-    protected $_routing;
80
+	protected $_routing;
81 81
 
82
-    //list table args
83
-    protected $_view;
82
+	//list table args
83
+	protected $_view;
84 84
 
85
-    protected $_views;
85
+	protected $_views;
86 86
 
87 87
 
88
-    //action => method pairs used for routing incoming requests
89
-    protected $_page_routes;
88
+	//action => method pairs used for routing incoming requests
89
+	protected $_page_routes;
90 90
 
91
-    protected $_page_config;
91
+	protected $_page_config;
92 92
 
93
-    //the current page route and route config
94
-    protected $_route;
93
+	//the current page route and route config
94
+	protected $_route;
95 95
 
96
-    protected $_route_config;
96
+	protected $_route_config;
97 97
 
98
-    /**
99
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
100
-     * actions.
101
-     *
102
-     * @since 4.6.x
103
-     * @var array.
104
-     */
105
-    protected $_default_route_query_args;
98
+	/**
99
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
100
+	 * actions.
101
+	 *
102
+	 * @since 4.6.x
103
+	 * @var array.
104
+	 */
105
+	protected $_default_route_query_args;
106 106
 
107
-    //set via request page and action args.
108
-    protected $_current_page;
107
+	//set via request page and action args.
108
+	protected $_current_page;
109 109
 
110
-    protected $_current_view;
110
+	protected $_current_view;
111 111
 
112
-    protected $_current_page_view_url;
112
+	protected $_current_page_view_url;
113 113
 
114
-    //sanitized request action (and nonce)
115
-    /**
116
-     * @var string $_req_action
117
-     */
118
-    protected $_req_action;
114
+	//sanitized request action (and nonce)
115
+	/**
116
+	 * @var string $_req_action
117
+	 */
118
+	protected $_req_action;
119 119
 
120
-    /**
121
-     * @var string $_req_nonce
122
-     */
123
-    protected $_req_nonce;
120
+	/**
121
+	 * @var string $_req_nonce
122
+	 */
123
+	protected $_req_nonce;
124 124
 
125
-    //search related
126
-    protected $_search_btn_label;
125
+	//search related
126
+	protected $_search_btn_label;
127 127
 
128
-    protected $_search_box_callback;
128
+	protected $_search_box_callback;
129 129
 
130
-    /**
131
-     * WP Current Screen object
132
-     *
133
-     * @var WP_Screen
134
-     */
135
-    protected $_current_screen;
130
+	/**
131
+	 * WP Current Screen object
132
+	 *
133
+	 * @var WP_Screen
134
+	 */
135
+	protected $_current_screen;
136 136
 
137
-    //for holding EE_Admin_Hooks object when needed (set via set_hook_object())
138
-    protected $_hook_obj;
137
+	//for holding EE_Admin_Hooks object when needed (set via set_hook_object())
138
+	protected $_hook_obj;
139 139
 
140
-    //for holding incoming request data
141
-    protected $_req_data;
140
+	//for holding incoming request data
141
+	protected $_req_data;
142 142
 
143
-    // yes / no array for admin form fields
144
-    protected $_yes_no_values = array();
145
-
146
-    //some default things shared by all child classes
147
-    protected $_default_espresso_metaboxes;
148
-
149
-    /**
150
-     *    EE_Registry Object
151
-     *
152
-     * @var    EE_Registry
153
-     * @access    protected
154
-     */
155
-    protected $EE = null;
156
-
157
-
158
-
159
-    /**
160
-     * This is just a property that flags whether the given route is a caffeinated route or not.
161
-     *
162
-     * @var boolean
163
-     */
164
-    protected $_is_caf = false;
165
-
166
-
167
-
168
-    /**
169
-     * @Constructor
170
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
171
-     * @access public
172
-     */
173
-    public function __construct($routing = true)
174
-    {
175
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
176
-            $this->_is_caf = true;
177
-        }
178
-        $this->_yes_no_values = array(
179
-                array('id' => true, 'text' => __('Yes', 'event_espresso')),
180
-                array('id' => false, 'text' => __('No', 'event_espresso')),
181
-        );
182
-        //set the _req_data property.
183
-        $this->_req_data = array_merge($_GET, $_POST);
184
-        //routing enabled?
185
-        $this->_routing = $routing;
186
-        //set initial page props (child method)
187
-        $this->_init_page_props();
188
-        //set global defaults
189
-        $this->_set_defaults();
190
-        //set early because incoming requests could be ajax related and we need to register those hooks.
191
-        $this->_global_ajax_hooks();
192
-        $this->_ajax_hooks();
193
-        //other_page_hooks have to be early too.
194
-        $this->_do_other_page_hooks();
195
-        //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup.
196
-        if (method_exists($this, '_before_page_setup')) {
197
-            $this->_before_page_setup();
198
-        }
199
-        //set up page dependencies
200
-        $this->_page_setup();
201
-    }
202
-
203
-
204
-
205
-    /**
206
-     * _init_page_props
207
-     * Child classes use to set at least the following properties:
208
-     * $page_slug.
209
-     * $page_label.
210
-     *
211
-     * @abstract
212
-     * @access protected
213
-     * @return void
214
-     */
215
-    abstract protected function _init_page_props();
216
-
217
-
218
-
219
-    /**
220
-     * _ajax_hooks
221
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
222
-     * Note: within the ajax callback methods.
223
-     *
224
-     * @abstract
225
-     * @access protected
226
-     * @return void
227
-     */
228
-    abstract protected function _ajax_hooks();
229
-
230
-
231
-
232
-    /**
233
-     * _define_page_props
234
-     * child classes define page properties in here.  Must include at least:
235
-     * $_admin_base_url = base_url for all admin pages
236
-     * $_admin_page_title = default admin_page_title for admin pages
237
-     * $_labels = array of default labels for various automatically generated elements:
238
-     *    array(
239
-     *        'buttons' => array(
240
-     *            'add' => __('label for add new button'),
241
-     *            'edit' => __('label for edit button'),
242
-     *            'delete' => __('label for delete button')
243
-     *            )
244
-     *        )
245
-     *
246
-     * @abstract
247
-     * @access protected
248
-     * @return void
249
-     */
250
-    abstract protected function _define_page_props();
251
-
252
-
253
-
254
-    /**
255
-     * _set_page_routes
256
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also have a 'default'
257
-     * route. Here's the format
258
-     * $this->_page_routes = array(
259
-     *        'default' => array(
260
-     *            'func' => '_default_method_handling_route',
261
-     *            'args' => array('array','of','args'),
262
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
263
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after.  The string you enter here should match the defined route reference for a headers sent route.
264
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
265
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
266
-     *        ),
267
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
268
-     *        )
269
-     * )
270
-     *
271
-     * @abstract
272
-     * @access protected
273
-     * @return void
274
-     */
275
-    abstract protected function _set_page_routes();
276
-
277
-
278
-
279
-    /**
280
-     * _set_page_config
281
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page.
282
-     * Format:
283
-     * $this->_page_config = array(
284
-     *        'default' => array(
285
-     *            'labels' => array(
286
-     *                'buttons' => array(
287
-     *                    'add' => __('label for adding item'),
288
-     *                    'edit' => __('label for editing item'),
289
-     *                    'delete' => __('label for deleting item')
290
-     *                ),
291
-     *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
292
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method
293
-     *            'nav' => array(
294
-     *                'label' => __('Label for Tab', 'event_espresso').
295
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
296
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
297
-     *                'order' => 10, //required to indicate tab position.
298
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
299
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
300
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
301
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added later.  We just use
302
-     *            this flag to make sure the necessary js gets enqueued on page load.
303
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
304
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The array indicates the max number of columns (4) and the default number of columns on page load (2).  There is an option
305
-     *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
306
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
307
-     *                'tab_id' => array(
308
-     *                    'title' => 'tab_title',
309
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content.  The fallback if it isn't present is to try a the callback.  Filename should match a file in the admin
310
-     *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
311
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class
312
-     *                    ),
313
-     *                'tab2_id' => array(
314
-     *                    'title' => 'tab2 title',
315
-     *                    'filename' => 'file_name_2'
316
-     *                    'callback' => 'callback_method_for_content',
317
-     *                 ),
318
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
319
-     *            'help_tour' => array(
320
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here
321
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
322
-     *            ),
323
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present).  To remove the requirement for a nonce check when this route is visited just set
324
-     *            'require_nonce' to FALSE
325
-     *            )
326
-     * )
327
-     *
328
-     * @abstract
329
-     * @access protected
330
-     * @return void
331
-     */
332
-    abstract protected function _set_page_config();
333
-
334
-
335
-
336
-
337
-
338
-    /** end sample help_tour methods **/
339
-    /**
340
-     * _add_screen_options
341
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
342
-     * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
343
-     *
344
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
345
-     *         see also WP_Screen object documents...
346
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
347
-     * @abstract
348
-     * @access protected
349
-     * @return void
350
-     */
351
-    abstract protected function _add_screen_options();
352
-
353
-
354
-
355
-    /**
356
-     * _add_feature_pointers
357
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
358
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
359
-     * Note: this is just a placeholder for now.  Implementation will come down the road
360
-     * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
361
-     *
362
-     * @link   http://eamann.com/tech/wordpress-portland/
363
-     * @abstract
364
-     * @access protected
365
-     * @return void
366
-     */
367
-    abstract protected function _add_feature_pointers();
368
-
369
-
370
-
371
-    /**
372
-     * load_scripts_styles
373
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific scripts/styles
374
-     * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
375
-     *
376
-     * @abstract
377
-     * @access public
378
-     * @return void
379
-     */
380
-    abstract public function load_scripts_styles();
381
-
382
-
383
-
384
-    /**
385
-     * admin_init
386
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to all pages/views loaded by child class.
387
-     *
388
-     * @abstract
389
-     * @access public
390
-     * @return void
391
-     */
392
-    abstract public function admin_init();
393
-
394
-
395
-
396
-    /**
397
-     * admin_notices
398
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to all pages/views loaded by child class.
399
-     *
400
-     * @abstract
401
-     * @access public
402
-     * @return void
403
-     */
404
-    abstract public function admin_notices();
405
-
406
-
407
-
408
-    /**
409
-     * admin_footer_scripts
410
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class.
411
-     *
412
-     * @access public
413
-     * @return void
414
-     */
415
-    abstract public function admin_footer_scripts();
416
-
417
-
418
-
419
-    /**
420
-     * admin_footer
421
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class.
422
-     *
423
-     * @access  public
424
-     * @return void
425
-     */
426
-    public function admin_footer()
427
-    {
428
-    }
429
-
430
-
431
-
432
-    /**
433
-     * _global_ajax_hooks
434
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
435
-     * Note: within the ajax callback methods.
436
-     *
437
-     * @abstract
438
-     * @access protected
439
-     * @return void
440
-     */
441
-    protected function _global_ajax_hooks()
442
-    {
443
-        //for lazy loading of metabox content
444
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
445
-    }
446
-
447
-
448
-
449
-    public function ajax_metabox_content()
450
-    {
451
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
452
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
453
-        self::cached_rss_display($contentid, $url);
454
-        wp_die();
455
-    }
456
-
457
-
458
-
459
-    /**
460
-     * _page_setup
461
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested doesn't match the object.
462
-     *
463
-     * @final
464
-     * @access protected
465
-     * @return void
466
-     */
467
-    final protected function _page_setup()
468
-    {
469
-        //requires?
470
-        //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
471
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
472
-        //next verify if we need to load anything...
473
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474
-        $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475
-        global $ee_menu_slugs;
476
-        $ee_menu_slugs = (array)$ee_menu_slugs;
477
-        if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478
-            return false;
479
-        }
480
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
481
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
482
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
483
-        }
484
-        // then set blank or -1 action values to 'default'
485
-        $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
486
-        //if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
487
-        $this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
488
-        //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490
-        $this->_current_view = $this->_req_action;
491
-        $this->_req_nonce = $this->_req_action . '_nonce';
492
-        $this->_define_page_props();
493
-        $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494
-        //default things
495
-        $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
496
-        //set page configs
497
-        $this->_set_page_routes();
498
-        $this->_set_page_config();
499
-        //let's include any referrer data in our default_query_args for this route for "stickiness".
500
-        if (isset($this->_req_data['wp_referer'])) {
501
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
502
-        }
503
-        //for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
504
-        if (method_exists($this, '_extend_page_config')) {
505
-            $this->_extend_page_config();
506
-        }
507
-        //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
508
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
509
-            $this->_extend_page_config_for_cpt();
510
-        }
511
-        //filter routes and page_config so addons can add their stuff. Filtering done per class
512
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
514
-        //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
515
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
517
-        }
518
-        //next route only if routing enabled
519
-        if ($this->_routing && ! defined('DOING_AJAX')) {
520
-            $this->_verify_routes();
521
-            //next let's just check user_access and kill if no access
522
-            $this->check_user_access();
523
-            if ($this->_is_UI_request) {
524
-                //admin_init stuff - global, all views for this page class, specific view
525
-                add_action('admin_init', array($this, 'admin_init'), 10);
526
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
528
-                }
529
-            } else {
530
-                //hijack regular WP loading and route admin request immediately
531
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
532
-                $this->route_admin_request();
533
-            }
534
-        }
535
-    }
536
-
537
-
538
-
539
-    /**
540
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
541
-     *
542
-     * @access private
543
-     * @return void
544
-     */
545
-    private function _do_other_page_hooks()
546
-    {
547
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
548
-        foreach ($registered_pages as $page) {
549
-            //now let's setup the file name and class that should be present
550
-            $classname = str_replace('.class.php', '', $page);
551
-            //autoloaders should take care of loading file
552
-            if ( ! class_exists($classname)) {
553
-                $error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
554
-                $error_msg[] = $error_msg[0]
555
-                               . "\r\n"
556
-                               . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
557
-                                'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>');
558
-                throw new EE_Error(implode('||', $error_msg));
559
-            }
560
-            $a = new ReflectionClass($classname);
561
-            //notice we are passing the instance of this class to the hook object.
562
-            $hookobj[] = $a->newInstance($this);
563
-        }
564
-    }
565
-
566
-
567
-
568
-    public function load_page_dependencies()
569
-    {
570
-        try {
571
-            $this->_load_page_dependencies();
572
-        } catch (EE_Error $e) {
573
-            $e->get_error();
574
-        }
575
-    }
576
-
577
-
578
-
579
-    /**
580
-     * load_page_dependencies
581
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
582
-     *
583
-     * @access public
584
-     * @return void
585
-     */
586
-    protected function _load_page_dependencies()
587
-    {
588
-        //let's set the current_screen and screen options to override what WP set
589
-        $this->_current_screen = get_current_screen();
590
-        //load admin_notices - global, page class, and view specific
591
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
593
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
595
-        }
596
-        //load network admin_notices - global, page class, and view specific
597
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
600
-        }
601
-        //this will save any per_page screen options if they are present
602
-        $this->_set_per_page_screen_options();
603
-        //setup list table properties
604
-        $this->_set_list_table();
605
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
606
-        $this->_add_registered_meta_boxes();
607
-        $this->_add_screen_columns();
608
-        //add screen options - global, page child class, and view specific
609
-        $this->_add_global_screen_options();
610
-        $this->_add_screen_options();
611
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
613
-        }
614
-        //add help tab(s) and tours- set via page_config and qtips.
615
-        $this->_add_help_tour();
616
-        $this->_add_help_tabs();
617
-        $this->_add_qtips();
618
-        //add feature_pointers - global, page child class, and view specific
619
-        $this->_add_feature_pointers();
620
-        $this->_add_global_feature_pointers();
621
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
623
-        }
624
-        //enqueue scripts/styles - global, page class, and view specific
625
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
629
-        }
630
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631
-        //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
632
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
636
-        }
637
-        //admin footer scripts
638
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
640
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
642
-        }
643
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644
-        //targeted hook
645
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
646
-    }
647
-
648
-
649
-
650
-    /**
651
-     * _set_defaults
652
-     * This sets some global defaults for class properties.
653
-     */
654
-    private function _set_defaults()
655
-    {
656
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
657
-        $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
658
-        $this->default_nav_tab_name = 'overview';
659
-        //init template args
660
-        $this->_template_args = array(
661
-                'admin_page_header'  => '',
662
-                'admin_page_content' => '',
663
-                'post_body_content'  => '',
664
-                'before_list_table'  => '',
665
-                'after_list_table'   => '',
666
-        );
667
-    }
668
-
669
-
670
-
671
-    /**
672
-     * route_admin_request
673
-     *
674
-     * @see    _route_admin_request()
675
-     * @access public
676
-     * @return void|exception error
677
-     */
678
-    public function route_admin_request()
679
-    {
680
-        try {
681
-            $this->_route_admin_request();
682
-        } catch (EE_Error $e) {
683
-            $e->get_error();
684
-        }
685
-    }
686
-
687
-
688
-
689
-    public function set_wp_page_slug($wp_page_slug)
690
-    {
691
-        $this->_wp_page_slug = $wp_page_slug;
692
-        //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
693
-        if (is_network_admin()) {
694
-            $this->_wp_page_slug .= '-network';
695
-        }
696
-    }
697
-
698
-
699
-
700
-    /**
701
-     * _verify_routes
702
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so we know if we need to drop out.
703
-     *
704
-     * @access protected
705
-     * @return void
706
-     */
707
-    protected function _verify_routes()
708
-    {
709
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
710
-        if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
711
-            return false;
712
-        }
713
-        $this->_route = false;
714
-        $func = false;
715
-        $args = array();
716
-        // check that the page_routes array is not empty
717
-        if (empty($this->_page_routes)) {
718
-            // user error msg
719
-            $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720
-            // developer error msg
721
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722
-            throw new EE_Error($error_msg);
723
-        }
724
-        // and that the requested page route exists
725
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
726
-            $this->_route = $this->_page_routes[$this->_req_action];
727
-            $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
728
-        } else {
729
-            // user error msg
730
-            $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731
-            // developer error msg
732
-            $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733
-            throw new EE_Error($error_msg);
734
-        }
735
-        // and that a default route exists
736
-        if ( ! array_key_exists('default', $this->_page_routes)) {
737
-            // user error msg
738
-            $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739
-            // developer error msg
740
-            $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741
-            throw new EE_Error($error_msg);
742
-        }
743
-        //first lets' catch if the UI request has EVER been set.
744
-        if ($this->_is_UI_request === null) {
745
-            //lets set if this is a UI request or not.
746
-            $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
747
-            //wait a minute... we might have a noheader in the route array
748
-            $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
749
-        }
750
-        $this->_set_current_labels();
751
-    }
752
-
753
-
754
-
755
-    /**
756
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
757
-     *
758
-     * @param  string $route the route name we're verifying
759
-     * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
760
-     */
761
-    protected function _verify_route($route)
762
-    {
763
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
764
-            return true;
765
-        } else {
766
-            // user error msg
767
-            $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768
-            // developer error msg
769
-            $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770
-            throw new EE_Error($error_msg);
771
-        }
772
-    }
773
-
774
-
775
-
776
-    /**
777
-     * perform nonce verification
778
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!)
779
-     *
780
-     * @param  string $nonce     The nonce sent
781
-     * @param  string $nonce_ref The nonce reference string (name0)
782
-     * @return mixed (bool|die)
783
-     */
784
-    protected function _verify_nonce($nonce, $nonce_ref)
785
-    {
786
-        // verify nonce against expected value
787
-        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
788
-            // these are not the droids you are looking for !!!
789
-            $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790
-            if (WP_DEBUG) {
791
-                $msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792
-            }
793
-            if ( ! defined('DOING_AJAX')) {
794
-                wp_die($msg);
795
-            } else {
796
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
797
-                $this->_return_json();
798
-            }
799
-        }
800
-    }
801
-
802
-
803
-
804
-    /**
805
-     * _route_admin_request()
806
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
807
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
808
-     * in the page routes and then will try to load the corresponding method.
809
-     *
810
-     * @access protected
811
-     * @return void
812
-     * @throws \EE_Error
813
-     */
814
-    protected function _route_admin_request()
815
-    {
816
-        if ( ! $this->_is_UI_request) {
817
-            $this->_verify_routes();
818
-        }
819
-        $nonce_check = isset($this->_route_config['require_nonce'])
820
-            ? $this->_route_config['require_nonce']
821
-            : true;
822
-        if ($this->_req_action !== 'default' && $nonce_check) {
823
-            // set nonce from post data
824
-            $nonce = isset($this->_req_data[$this->_req_nonce])
825
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce])
826
-                : '';
827
-            $this->_verify_nonce($nonce, $this->_req_nonce);
828
-        }
829
-        //set the nav_tabs array but ONLY if this is  UI_request
830
-        if ($this->_is_UI_request) {
831
-            $this->_set_nav_tabs();
832
-        }
833
-        // grab callback function
834
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
835
-        // check if callback has args
836
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
837
-        $error_msg = '';
838
-        // action right before calling route
839
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
840
-        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
841
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
842
-        }
843
-        // right before calling the route, let's remove _wp_http_referer from the
844
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
845
-        $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
846
-        if ( ! empty($func)) {
847
-            if (is_array($func)) {
848
-                list($class, $method) = $func;
849
-            } else if (strpos($func, '::') !== false) {
850
-                list($class, $method) = explode('::', $func);
851
-            } else {
852
-                $class = $this;
853
-                $method = $func;
854
-            }
855
-            if ( ! (is_object($class) && $class === $this)) {
856
-                // send along this admin page object for access by addons.
857
-                $args['admin_page_object'] = $this;
858
-            }
859
-
860
-            if (
861
-                //is it a method on a class that doesn't work?
862
-                (
863
-                    (
864
-                        method_exists($class, $method)
865
-                        && call_user_func_array(array($class, $method), $args) === false
866
-                    )
867
-                    && (
868
-                        //is it a standalone function that doesn't work?
869
-                        function_exists($method)
870
-                        && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
871
-                    )
872
-                )
873
-                || (
874
-                    //is it neither a class method NOR a standalone function?
875
-                    ! method_exists($class, $method)
876
-                    && ! function_exists($method)
877
-                )
878
-            ) {
879
-                // user error msg
880
-                $error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
881
-                // developer error msg
882
-                $error_msg .= '||';
883
-                $error_msg .= sprintf(
884
-                    __(
885
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
886
-                        'event_espresso'
887
-                    ),
888
-                    $method
889
-                );
890
-            }
891
-            if ( ! empty($error_msg)) {
892
-                throw new EE_Error($error_msg);
893
-            }
894
-        }
895
-        //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
896
-        //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
897
-        if ($this->_is_UI_request === false
898
-            && is_array($this->_route)
899
-            && ! empty($this->_route['headers_sent_route'])
900
-        ) {
901
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
902
-        }
903
-    }
904
-
905
-
906
-
907
-    /**
908
-     * This method just allows the resetting of page properties in the case where a no headers
909
-     * route redirects to a headers route in its route config.
910
-     *
911
-     * @since   4.3.0
912
-     * @param  string $new_route New (non header) route to redirect to.
913
-     * @return   void
914
-     */
915
-    protected function _reset_routing_properties($new_route)
916
-    {
917
-        $this->_is_UI_request = true;
918
-        //now we set the current route to whatever the headers_sent_route is set at
919
-        $this->_req_data['action'] = $new_route;
920
-        //rerun page setup
921
-        $this->_page_setup();
922
-    }
923
-
924
-
925
-
926
-    /**
927
-     * _add_query_arg
928
-     * adds nonce to array of arguments then calls WP add_query_arg function
929
-     *(internally just uses EEH_URL's function with the same name)
930
-     *
931
-     * @access public
932
-     * @param array  $args
933
-     * @param string $url
934
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
935
-     *                                        url in an associative array indexed by the key 'wp_referer';
936
-     *                                        Example usage:
937
-     *                                        If the current page is:
938
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
939
-     *                                        &action=default&event_id=20&month_range=March%202015
940
-     *                                        &_wpnonce=5467821
941
-     *                                        and you call:
942
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
943
-     *                                        array(
944
-     *                                        'action' => 'resend_something',
945
-     *                                        'page=>espresso_registrations'
946
-     *                                        ),
947
-     *                                        $some_url,
948
-     *                                        true
949
-     *                                        );
950
-     *                                        It will produce a url in this structure:
951
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
952
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
953
-     *                                        month_range]=March%202015
954
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
955
-     * @return string
956
-     */
957
-    public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
958
-    {
959
-        //if there is a _wp_http_referer include the values from the request but only if sticky = true
960
-        if ($sticky) {
961
-            $request = $_REQUEST;
962
-            unset($request['_wp_http_referer']);
963
-            unset($request['wp_referer']);
964
-            foreach ($request as $key => $value) {
965
-                //do not add nonces
966
-                if (strpos($key, 'nonce') !== false) {
967
-                    continue;
968
-                }
969
-                $args['wp_referer[' . $key . ']'] = $value;
970
-            }
971
-        }
972
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
973
-    }
974
-
975
-
976
-
977
-    /**
978
-     * This returns a generated link that will load the related help tab.
979
-     *
980
-     * @param  string $help_tab_id the id for the connected help tab
981
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
982
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
983
-     * @uses EEH_Template::get_help_tab_link()
984
-     * @return string              generated link
985
-     */
986
-    protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
987
-    {
988
-        return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
989
-    }
990
-
991
-
992
-
993
-    /**
994
-     * _add_help_tabs
995
-     * Note child classes define their help tabs within the page_config array.
996
-     *
997
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
998
-     * @access protected
999
-     * @return void
1000
-     */
1001
-    protected function _add_help_tabs()
1002
-    {
1003
-        $tour_buttons = '';
1004
-        if (isset($this->_page_config[$this->_req_action])) {
1005
-            $config = $this->_page_config[$this->_req_action];
1006
-            //is there a help tour for the current route?  if there is let's setup the tour buttons
1007
-            if (isset($this->_help_tour[$this->_req_action])) {
1008
-                $tb = array();
1009
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1010
-                foreach ($this->_help_tour['tours'] as $tour) {
1011
-                    //if this is the end tour then we don't need to setup a button
1012
-                    if ($tour instanceof EE_Help_Tour_final_stop) {
1013
-                        continue;
1014
-                    }
1015
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1016
-                }
1017
-                $tour_buttons .= implode('<br />', $tb);
1018
-                $tour_buttons .= '</div></div>';
1019
-            }
1020
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1021
-            if (is_array($config) && isset($config['help_sidebar'])) {
1022
-                //check that the callback given is valid
1023
-                if ( ! method_exists($this, $config['help_sidebar'])) {
1024
-                    throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1025
-                            'event_espresso'), $config['help_sidebar'], get_class($this)));
1026
-                }
1027
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1028
-                $content .= $tour_buttons; //add help tour buttons.
1029
-                //do we have any help tours setup?  Cause if we do we want to add the buttons
1030
-                $this->_current_screen->set_help_sidebar($content);
1031
-            }
1032
-            //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1033
-            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1034
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1035
-            }
1036
-            //handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1037
-            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1038
-                $_ht['id'] = $this->page_slug;
1039
-                $_ht['title'] = __('Help Tours', 'event_espresso');
1040
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1041
-                $this->_current_screen->add_help_tab($_ht);
1042
-            }/**/
1043
-            if ( ! isset($config['help_tabs'])) {
1044
-                return;
1045
-            } //no help tabs for this route
1046
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1047
-                //we're here so there ARE help tabs!
1048
-                //make sure we've got what we need
1049
-                if ( ! isset($cfg['title'])) {
1050
-                    throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1051
-                }
1052
-                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1053
-                    throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1054
-                            'event_espresso'));
1055
-                }
1056
-                //first priority goes to content.
1057
-                if ( ! empty($cfg['content'])) {
1058
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1059
-                    //second priority goes to filename
1060
-                } else if ( ! empty($cfg['filename'])) {
1061
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1062
-                    //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1063
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1064
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1065
-                    if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1066
-                        EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1067
-                                'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1068
-                        return;
1069
-                    }
1070
-                    $template_args['admin_page_obj'] = $this;
1071
-                    $content = EEH_Template::display_template($file_path, $template_args, true);
1072
-                } else {
1073
-                    $content = '';
1074
-                }
1075
-                //check if callback is valid
1076
-                if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1077
-                    EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1078
-                            'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1079
-                    return;
1080
-                }
1081
-                //setup config array for help tab method
1082
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1083
-                $_ht = array(
1084
-                        'id'       => $id,
1085
-                        'title'    => $cfg['title'],
1086
-                        'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1087
-                        'content'  => $content,
1088
-                );
1089
-                $this->_current_screen->add_help_tab($_ht);
1090
-            }
1091
-        }
1092
-    }
1093
-
1094
-
1095
-
1096
-    /**
1097
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is an array with properties for setting up usage of the joyride plugin
1098
-     *
1099
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1100
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1101
-     * @access protected
1102
-     * @return void
1103
-     */
1104
-    protected function _add_help_tour()
1105
-    {
1106
-        $tours = array();
1107
-        $this->_help_tour = array();
1108
-        //exit early if help tours are turned off globally
1109
-        if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1110
-            return;
1111
-        }
1112
-        //loop through _page_config to find any help_tour defined
1113
-        foreach ($this->_page_config as $route => $config) {
1114
-            //we're only going to set things up for this route
1115
-            if ($route !== $this->_req_action) {
1116
-                continue;
1117
-            }
1118
-            if (isset($config['help_tour'])) {
1119
-                foreach ($config['help_tour'] as $tour) {
1120
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1121
-                    //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1122
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1123
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1124
-                    if ( ! is_readable($file_path)) {
1125
-                        EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
1126
-                                $file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1127
-                        return;
1128
-                    }
1129
-                    require_once $file_path;
1130
-                    if ( ! class_exists($tour)) {
1131
-                        $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1132
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1133
-                                        'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1134
-                        throw new EE_Error(implode('||', $error_msg));
1135
-                    }
1136
-                    $a = new ReflectionClass($tour);
1137
-                    $tour_obj = $a->newInstance($this->_is_caf);
1138
-                    $tours[] = $tour_obj;
1139
-                    $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1140
-                }
1141
-                //let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1142
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1143
-                $tours[] = $end_stop_tour;
1144
-                $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1145
-            }
1146
-        }
1147
-        if ( ! empty($tours)) {
1148
-            $this->_help_tour['tours'] = $tours;
1149
-        }
1150
-        //thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1151
-    }
1152
-
1153
-
1154
-
1155
-    /**
1156
-     * This simply sets up any qtips that have been defined in the page config
1157
-     *
1158
-     * @access protected
1159
-     * @return void
1160
-     */
1161
-    protected function _add_qtips()
1162
-    {
1163
-        if (isset($this->_route_config['qtips'])) {
1164
-            $qtips = (array)$this->_route_config['qtips'];
1165
-            //load qtip loader
1166
-            $path = array(
1167
-                    $this->_get_dir() . '/qtips/',
1168
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1169
-            );
1170
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1171
-        }
1172
-    }
1173
-
1174
-
1175
-
1176
-    /**
1177
-     * _set_nav_tabs
1178
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly.
1179
-     *
1180
-     * @access protected
1181
-     * @return void
1182
-     */
1183
-    protected function _set_nav_tabs()
1184
-    {
1185
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1186
-        $i = 0;
1187
-        foreach ($this->_page_config as $slug => $config) {
1188
-            if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1189
-                continue;
1190
-            } //no nav tab for this config
1191
-            //check for persistent flag
1192
-            if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1193
-                continue;
1194
-            } //nav tab is only to appear when route requested.
1195
-            if ( ! $this->check_user_access($slug, true)) {
1196
-                continue;
1197
-            } //no nav tab becasue current user does not have access.
1198
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1199
-            $this->_nav_tabs[$slug] = array(
1200
-                    'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1201
-                    'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1202
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1203
-                    'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1204
-            );
1205
-            $i++;
1206
-        }
1207
-        //if $this->_nav_tabs is empty then lets set the default
1208
-        if (empty($this->_nav_tabs)) {
1209
-            $this->_nav_tabs[$this->default_nav_tab_name] = array(
1210
-                    'url'       => $this->admin_base_url,
1211
-                    'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1212
-                    'css_class' => 'nav-tab-active',
1213
-                    'order'     => 10,
1214
-            );
1215
-        }
1216
-        //now let's sort the tabs according to order
1217
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1218
-    }
1219
-
1220
-
1221
-
1222
-    /**
1223
-     * _set_current_labels
1224
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1225
-     *
1226
-     * @access private
1227
-     * @return void
1228
-     */
1229
-    private function _set_current_labels()
1230
-    {
1231
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1232
-            foreach ($this->_route_config['labels'] as $label => $text) {
1233
-                if (is_array($text)) {
1234
-                    foreach ($text as $sublabel => $subtext) {
1235
-                        $this->_labels[$label][$sublabel] = $subtext;
1236
-                    }
1237
-                } else {
1238
-                    $this->_labels[$label] = $text;
1239
-                }
1240
-            }
1241
-        }
1242
-    }
1243
-
1244
-
1245
-
1246
-    /**
1247
-     *        verifies user access for this admin page
1248
-     *
1249
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1250
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1251
-     * @return        BOOL|wp_die()
1252
-     */
1253
-    public function check_user_access($route_to_check = '', $verify_only = false)
1254
-    {
1255
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1256
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1257
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability'])
1258
-                ? $this->_page_routes[$route_to_check]['capability'] : null;
1259
-        if (empty($capability) && empty($route_to_check)) {
1260
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1261
-        } else {
1262
-            $capability = empty($capability) ? 'manage_options' : $capability;
1263
-        }
1264
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1265
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1266
-            if ($verify_only) {
1267
-                return false;
1268
-            } else {
1269
-                if ( is_user_logged_in() ) {
1270
-                    wp_die(__('You do not have access to this route.', 'event_espresso'));
1271
-                } else {
1272
-                    return false;
1273
-                }
1274
-            }
1275
-        }
1276
-        return true;
1277
-    }
1278
-
1279
-
1280
-
1281
-    /**
1282
-     * admin_init_global
1283
-     * This runs all the code that we want executed within the WP admin_init hook.
1284
-     * This method executes for ALL EE Admin pages.
1285
-     *
1286
-     * @access public
1287
-     * @return void
1288
-     */
1289
-    public function admin_init_global()
1290
-    {
1291
-    }
1292
-
1293
-
1294
-
1295
-    /**
1296
-     * wp_loaded_global
1297
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an EE_Admin page and will execute on every EE Admin Page load
1298
-     *
1299
-     * @access public
1300
-     * @return void
1301
-     */
1302
-    public function wp_loaded()
1303
-    {
1304
-    }
1305
-
1306
-
1307
-
1308
-    /**
1309
-     * admin_notices
1310
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1311
-     *
1312
-     * @access public
1313
-     * @return void
1314
-     */
1315
-    public function admin_notices_global()
1316
-    {
1317
-        $this->_display_no_javascript_warning();
1318
-        $this->_display_espresso_notices();
1319
-    }
1320
-
1321
-
1322
-
1323
-    public function network_admin_notices_global()
1324
-    {
1325
-        $this->_display_no_javascript_warning();
1326
-        $this->_display_espresso_notices();
1327
-    }
1328
-
1329
-
1330
-
1331
-    /**
1332
-     * admin_footer_scripts_global
1333
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages.
1334
-     *
1335
-     * @access public
1336
-     * @return void
1337
-     */
1338
-    public function admin_footer_scripts_global()
1339
-    {
1340
-        $this->_add_admin_page_ajax_loading_img();
1341
-        $this->_add_admin_page_overlay();
1342
-        //if metaboxes are present we need to add the nonce field
1343
-        if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1344
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1345
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1346
-        }
1347
-    }
1348
-
1349
-
1350
-
1351
-    /**
1352
-     * admin_footer_global
1353
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1354
-     *
1355
-     * @access  public
1356
-     * @return  void
1357
-     */
1358
-    public function admin_footer_global()
1359
-    {
1360
-        //dialog container for dialog helper
1361
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1362
-        $d_cont .= '<div class="ee-notices"></div>';
1363
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1364
-        $d_cont .= '</div>';
1365
-        echo $d_cont;
1366
-        //help tour stuff?
1367
-        if (isset($this->_help_tour[$this->_req_action])) {
1368
-            echo implode('<br />', $this->_help_tour[$this->_req_action]);
1369
-        }
1370
-        //current set timezone for timezone js
1371
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1372
-    }
1373
-
1374
-
1375
-
1376
-    /**
1377
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then we'll use the retrieved array to output the content using the template.
1378
-     * For child classes:
1379
-     * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for
1380
-     * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content for the
1381
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1382
-     *    'help_trigger_id' => array(
1383
-     *        'title' => __('localized title for popup', 'event_espresso'),
1384
-     *        'content' => __('localized content for popup', 'event_espresso')
1385
-     *    )
1386
-     * );
1387
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1388
-     *
1389
-     * @access protected
1390
-     * @return string content
1391
-     */
1392
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1393
-    {
1394
-        $content = '';
1395
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1396
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1397
-        //loop through the array and setup content
1398
-        foreach ($help_array as $trigger => $help) {
1399
-            //make sure the array is setup properly
1400
-            if ( ! isset($help['title']) || ! isset($help['content'])) {
1401
-                throw new EE_Error(__('Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1402
-                        'event_espresso'));
1403
-            }
1404
-            //we're good so let'd setup the template vars and then assign parsed template content to our content.
1405
-            $template_args = array(
1406
-                    'help_popup_id'      => $trigger,
1407
-                    'help_popup_title'   => $help['title'],
1408
-                    'help_popup_content' => $help['content'],
1409
-            );
1410
-            $content .= EEH_Template::display_template($template_path, $template_args, true);
1411
-        }
1412
-        if ($display) {
1413
-            echo $content;
1414
-        } else {
1415
-            return $content;
1416
-        }
1417
-    }
1418
-
1419
-
1420
-
1421
-    /**
1422
-     * All this does is retrive the help content array if set by the EE_Admin_Page child
1423
-     *
1424
-     * @access private
1425
-     * @return array properly formatted array for help popup content
1426
-     */
1427
-    private function _get_help_content()
1428
-    {
1429
-        //what is the method we're looking for?
1430
-        $method_name = '_help_popup_content_' . $this->_req_action;
1431
-        //if method doesn't exist let's get out.
1432
-        if ( ! method_exists($this, $method_name)) {
1433
-            return array();
1434
-        }
1435
-        //k we're good to go let's retrieve the help array
1436
-        $help_array = call_user_func(array($this, $method_name));
1437
-        //make sure we've got an array!
1438
-        if ( ! is_array($help_array)) {
1439
-            throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso'));
1440
-        }
1441
-        return $help_array;
1442
-    }
1443
-
1444
-
1445
-
1446
-    /**
1447
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1448
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1449
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1450
-     *
1451
-     * @access protected
1452
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1453
-     * @param boolean $display    if false then we return the trigger string
1454
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1455
-     * @return string
1456
-     */
1457
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1458
-    {
1459
-        if (defined('DOING_AJAX')) {
1460
-            return;
1461
-        }
1462
-        //let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1463
-        $help_array = $this->_get_help_content();
1464
-        $help_content = '';
1465
-        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1466
-            $help_array[$trigger_id] = array(
1467
-                    'title'   => __('Missing Content', 'event_espresso'),
1468
-                    'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1469
-                            'event_espresso'),
1470
-            );
1471
-            $help_content = $this->_set_help_popup_content($help_array, false);
1472
-        }
1473
-        //let's setup the trigger
1474
-        $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1475
-        $content = $content . $help_content;
1476
-        if ($display) {
1477
-            echo $content;
1478
-        } else {
1479
-            return $content;
1480
-        }
1481
-    }
1482
-
1483
-
1484
-
1485
-    /**
1486
-     * _add_global_screen_options
1487
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1488
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1489
-     *
1490
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1491
-     *         see also WP_Screen object documents...
1492
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1493
-     * @abstract
1494
-     * @access private
1495
-     * @return void
1496
-     */
1497
-    private function _add_global_screen_options()
1498
-    {
1499
-    }
1500
-
1501
-
1502
-
1503
-    /**
1504
-     * _add_global_feature_pointers
1505
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1506
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1507
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1508
-     *
1509
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1510
-     * @link   http://eamann.com/tech/wordpress-portland/
1511
-     * @abstract
1512
-     * @access protected
1513
-     * @return void
1514
-     */
1515
-    private function _add_global_feature_pointers()
1516
-    {
1517
-    }
1518
-
1519
-
1520
-
1521
-    /**
1522
-     * load_global_scripts_styles
1523
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1524
-     *
1525
-     * @return void
1526
-     */
1527
-    public function load_global_scripts_styles()
1528
-    {
1529
-        /** STYLES **/
1530
-        // add debugging styles
1531
-        if (WP_DEBUG) {
1532
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1533
-        }
1534
-        //register all styles
1535
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1536
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1537
-        //helpers styles
1538
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1539
-        //enqueue global styles
1540
-        wp_enqueue_style('ee-admin-css');
1541
-        /** SCRIPTS **/
1542
-        //register all scripts
1543
-        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1544
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1545
-        wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1546
-        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1547
-        // register jQuery Validate - see /includes/functions/wp_hooks.php
1548
-        add_filter('FHEE_load_jquery_validate', '__return_true');
1549
-        add_filter('FHEE_load_joyride', '__return_true');
1550
-        //script for sorting tables
1551
-        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1552
-        //script for parsing uri's
1553
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1554
-        //and parsing associative serialized form elements
1555
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1556
-        //helpers scripts
1557
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1558
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1559
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1560
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1561
-        //google charts
1562
-        wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1563
-        //enqueue global scripts
1564
-        //taking care of metaboxes
1565
-        if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) {
1566
-            wp_enqueue_script('dashboard');
1567
-        }
1568
-        //enqueue thickbox for ee help popups.  default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups
1569
-        if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) {
1570
-            wp_enqueue_script('ee_admin_js');
1571
-            wp_enqueue_style('ee-admin-css');
1572
-        }
1573
-        //localize script for ajax lazy loading
1574
-        $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1575
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1576
-        /**
1577
-         * help tour stuff
1578
-         */
1579
-        if ( ! empty($this->_help_tour)) {
1580
-            //register the js for kicking things off
1581
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1582
-            //setup tours for the js tour object
1583
-            foreach ($this->_help_tour['tours'] as $tour) {
1584
-                $tours[] = array(
1585
-                        'id'      => $tour->get_slug(),
1586
-                        'options' => $tour->get_options(),
1587
-                );
1588
-            }
1589
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1590
-            //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1591
-        }
1592
-    }
1593
-
1594
-
1595
-
1596
-    /**
1597
-     *        admin_footer_scripts_eei18n_js_strings
1598
-     *
1599
-     * @access        public
1600
-     * @return        void
1601
-     */
1602
-    public function admin_footer_scripts_eei18n_js_strings()
1603
-    {
1604
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1605
-        EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso');
1606
-        EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1607
-        EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1608
-        EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1609
-        EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1610
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1611
-        EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1612
-        EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1613
-        EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1614
-        EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1615
-        EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1616
-        EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1617
-        EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1618
-        EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1619
-        EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1620
-        EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1621
-        EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1622
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1623
-        EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1624
-        EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1625
-        EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1626
-        EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1627
-        EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1628
-        EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1629
-        EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1630
-        EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1631
-        EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1632
-        EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1633
-        EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1634
-        EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1635
-        EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1636
-        EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1637
-        EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1638
-        EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1639
-        EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1640
-        EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1641
-        EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1642
-        EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1643
-        EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1644
-        //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance
1645
-        //admin page when in maintenance mode and ee_admin_js is not loaded then.  This works everywhere else because
1646
-        //espresso_core is listed as a dependency of ee_admin_js.
1647
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
1648
-    }
1649
-
1650
-
1651
-
1652
-    /**
1653
-     *        load enhanced xdebug styles for ppl with failing eyesight
1654
-     *
1655
-     * @access        public
1656
-     * @return        void
1657
-     */
1658
-    public function add_xdebug_style()
1659
-    {
1660
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1661
-    }
1662
-
1663
-
1664
-    /************************/
1665
-    /** LIST TABLE METHODS **/
1666
-    /************************/
1667
-    /**
1668
-     * this sets up the list table if the current view requires it.
1669
-     *
1670
-     * @access protected
1671
-     * @return void
1672
-     */
1673
-    protected function _set_list_table()
1674
-    {
1675
-        //first is this a list_table view?
1676
-        if ( ! isset($this->_route_config['list_table'])) {
1677
-            return;
1678
-        } //not a list_table view so get out.
1679
-        //list table functions are per view specific (because some admin pages might have more than one listtable!)
1680
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1681
-            //user error msg
1682
-            $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1683
-            //developer error msg
1684
-            $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1685
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1686
-            throw new EE_Error($error_msg);
1687
-        }
1688
-        //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1689
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1690
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1691
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1692
-        $this->_set_list_table_view();
1693
-        $this->_set_list_table_object();
1694
-    }
1695
-
1696
-
1697
-
1698
-    /**
1699
-     *        set current view for List Table
1700
-     *
1701
-     * @access public
1702
-     * @return array
1703
-     */
1704
-    protected function _set_list_table_view()
1705
-    {
1706
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1707
-        // looking at active items or dumpster diving ?
1708
-        if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1709
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1710
-        } else {
1711
-            $this->_view = sanitize_key($this->_req_data['status']);
1712
-        }
1713
-    }
1714
-
1715
-
1716
-
1717
-    /**
1718
-     * _set_list_table_object
1719
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1720
-     *
1721
-     * @throws \EE_Error
1722
-     */
1723
-    protected function _set_list_table_object()
1724
-    {
1725
-        if (isset($this->_route_config['list_table'])) {
1726
-            if ( ! class_exists($this->_route_config['list_table'])) {
1727
-                throw new EE_Error(
1728
-                        sprintf(
1729
-                                __(
1730
-                                        'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
1731
-                                        'event_espresso'
1732
-                                ),
1733
-                                $this->_route_config['list_table'],
1734
-                                get_class($this)
1735
-                        )
1736
-                );
1737
-            }
1738
-            $list_table = $this->_route_config['list_table'];
1739
-            $this->_list_table_object = new $list_table($this);
1740
-        }
1741
-    }
1742
-
1743
-
1744
-
1745
-    /**
1746
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1747
-     *
1748
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1749
-     *                                                    urls.  The array should be indexed by the view it is being
1750
-     *                                                    added to.
1751
-     * @return array
1752
-     */
1753
-    public function get_list_table_view_RLs($extra_query_args = array())
1754
-    {
1755
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1756
-        if (empty($this->_views)) {
1757
-            $this->_views = array();
1758
-        }
1759
-        // cycle thru views
1760
-        foreach ($this->_views as $key => $view) {
1761
-            $query_args = array();
1762
-            // check for current view
1763
-            $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1764
-            $query_args['action'] = $this->_req_action;
1765
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1766
-            $query_args['status'] = $view['slug'];
1767
-            //merge any other arguments sent in.
1768
-            if (isset($extra_query_args[$view['slug']])) {
1769
-                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1770
-            }
1771
-            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1772
-        }
1773
-        return $this->_views;
1774
-    }
1775
-
1776
-
1777
-
1778
-    /**
1779
-     * _entries_per_page_dropdown
1780
-     * generates a drop down box for selecting the number of visiable rows in an admin page list table
1781
-     *
1782
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1783
-     * @access protected
1784
-     * @param int $max_entries total number of rows in the table
1785
-     * @return string
1786
-     */
1787
-    protected function _entries_per_page_dropdown($max_entries = false)
1788
-    {
1789
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1790
-        $values = array(10, 25, 50, 100);
1791
-        $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1792
-        if ($max_entries) {
1793
-            $values[] = $max_entries;
1794
-            sort($values);
1795
-        }
1796
-        $entries_per_page_dropdown = '
143
+	// yes / no array for admin form fields
144
+	protected $_yes_no_values = array();
145
+
146
+	//some default things shared by all child classes
147
+	protected $_default_espresso_metaboxes;
148
+
149
+	/**
150
+	 *    EE_Registry Object
151
+	 *
152
+	 * @var    EE_Registry
153
+	 * @access    protected
154
+	 */
155
+	protected $EE = null;
156
+
157
+
158
+
159
+	/**
160
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
161
+	 *
162
+	 * @var boolean
163
+	 */
164
+	protected $_is_caf = false;
165
+
166
+
167
+
168
+	/**
169
+	 * @Constructor
170
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
171
+	 * @access public
172
+	 */
173
+	public function __construct($routing = true)
174
+	{
175
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
176
+			$this->_is_caf = true;
177
+		}
178
+		$this->_yes_no_values = array(
179
+				array('id' => true, 'text' => __('Yes', 'event_espresso')),
180
+				array('id' => false, 'text' => __('No', 'event_espresso')),
181
+		);
182
+		//set the _req_data property.
183
+		$this->_req_data = array_merge($_GET, $_POST);
184
+		//routing enabled?
185
+		$this->_routing = $routing;
186
+		//set initial page props (child method)
187
+		$this->_init_page_props();
188
+		//set global defaults
189
+		$this->_set_defaults();
190
+		//set early because incoming requests could be ajax related and we need to register those hooks.
191
+		$this->_global_ajax_hooks();
192
+		$this->_ajax_hooks();
193
+		//other_page_hooks have to be early too.
194
+		$this->_do_other_page_hooks();
195
+		//This just allows us to have extending clases do something specific before the parent constructor runs _page_setup.
196
+		if (method_exists($this, '_before_page_setup')) {
197
+			$this->_before_page_setup();
198
+		}
199
+		//set up page dependencies
200
+		$this->_page_setup();
201
+	}
202
+
203
+
204
+
205
+	/**
206
+	 * _init_page_props
207
+	 * Child classes use to set at least the following properties:
208
+	 * $page_slug.
209
+	 * $page_label.
210
+	 *
211
+	 * @abstract
212
+	 * @access protected
213
+	 * @return void
214
+	 */
215
+	abstract protected function _init_page_props();
216
+
217
+
218
+
219
+	/**
220
+	 * _ajax_hooks
221
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
222
+	 * Note: within the ajax callback methods.
223
+	 *
224
+	 * @abstract
225
+	 * @access protected
226
+	 * @return void
227
+	 */
228
+	abstract protected function _ajax_hooks();
229
+
230
+
231
+
232
+	/**
233
+	 * _define_page_props
234
+	 * child classes define page properties in here.  Must include at least:
235
+	 * $_admin_base_url = base_url for all admin pages
236
+	 * $_admin_page_title = default admin_page_title for admin pages
237
+	 * $_labels = array of default labels for various automatically generated elements:
238
+	 *    array(
239
+	 *        'buttons' => array(
240
+	 *            'add' => __('label for add new button'),
241
+	 *            'edit' => __('label for edit button'),
242
+	 *            'delete' => __('label for delete button')
243
+	 *            )
244
+	 *        )
245
+	 *
246
+	 * @abstract
247
+	 * @access protected
248
+	 * @return void
249
+	 */
250
+	abstract protected function _define_page_props();
251
+
252
+
253
+
254
+	/**
255
+	 * _set_page_routes
256
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also have a 'default'
257
+	 * route. Here's the format
258
+	 * $this->_page_routes = array(
259
+	 *        'default' => array(
260
+	 *            'func' => '_default_method_handling_route',
261
+	 *            'args' => array('array','of','args'),
262
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
263
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after.  The string you enter here should match the defined route reference for a headers sent route.
264
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
265
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
266
+	 *        ),
267
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
268
+	 *        )
269
+	 * )
270
+	 *
271
+	 * @abstract
272
+	 * @access protected
273
+	 * @return void
274
+	 */
275
+	abstract protected function _set_page_routes();
276
+
277
+
278
+
279
+	/**
280
+	 * _set_page_config
281
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page.
282
+	 * Format:
283
+	 * $this->_page_config = array(
284
+	 *        'default' => array(
285
+	 *            'labels' => array(
286
+	 *                'buttons' => array(
287
+	 *                    'add' => __('label for adding item'),
288
+	 *                    'edit' => __('label for editing item'),
289
+	 *                    'delete' => __('label for deleting item')
290
+	 *                ),
291
+	 *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
292
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method
293
+	 *            'nav' => array(
294
+	 *                'label' => __('Label for Tab', 'event_espresso').
295
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
296
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
297
+	 *                'order' => 10, //required to indicate tab position.
298
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
299
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
300
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
301
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added later.  We just use
302
+	 *            this flag to make sure the necessary js gets enqueued on page load.
303
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
304
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The array indicates the max number of columns (4) and the default number of columns on page load (2).  There is an option
305
+	 *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
306
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
307
+	 *                'tab_id' => array(
308
+	 *                    'title' => 'tab_title',
309
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content.  The fallback if it isn't present is to try a the callback.  Filename should match a file in the admin
310
+	 *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
311
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class
312
+	 *                    ),
313
+	 *                'tab2_id' => array(
314
+	 *                    'title' => 'tab2 title',
315
+	 *                    'filename' => 'file_name_2'
316
+	 *                    'callback' => 'callback_method_for_content',
317
+	 *                 ),
318
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
319
+	 *            'help_tour' => array(
320
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here
321
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
322
+	 *            ),
323
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present).  To remove the requirement for a nonce check when this route is visited just set
324
+	 *            'require_nonce' to FALSE
325
+	 *            )
326
+	 * )
327
+	 *
328
+	 * @abstract
329
+	 * @access protected
330
+	 * @return void
331
+	 */
332
+	abstract protected function _set_page_config();
333
+
334
+
335
+
336
+
337
+
338
+	/** end sample help_tour methods **/
339
+	/**
340
+	 * _add_screen_options
341
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
342
+	 * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
343
+	 *
344
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
345
+	 *         see also WP_Screen object documents...
346
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
347
+	 * @abstract
348
+	 * @access protected
349
+	 * @return void
350
+	 */
351
+	abstract protected function _add_screen_options();
352
+
353
+
354
+
355
+	/**
356
+	 * _add_feature_pointers
357
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
358
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
359
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
360
+	 * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
361
+	 *
362
+	 * @link   http://eamann.com/tech/wordpress-portland/
363
+	 * @abstract
364
+	 * @access protected
365
+	 * @return void
366
+	 */
367
+	abstract protected function _add_feature_pointers();
368
+
369
+
370
+
371
+	/**
372
+	 * load_scripts_styles
373
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific scripts/styles
374
+	 * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
375
+	 *
376
+	 * @abstract
377
+	 * @access public
378
+	 * @return void
379
+	 */
380
+	abstract public function load_scripts_styles();
381
+
382
+
383
+
384
+	/**
385
+	 * admin_init
386
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to all pages/views loaded by child class.
387
+	 *
388
+	 * @abstract
389
+	 * @access public
390
+	 * @return void
391
+	 */
392
+	abstract public function admin_init();
393
+
394
+
395
+
396
+	/**
397
+	 * admin_notices
398
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to all pages/views loaded by child class.
399
+	 *
400
+	 * @abstract
401
+	 * @access public
402
+	 * @return void
403
+	 */
404
+	abstract public function admin_notices();
405
+
406
+
407
+
408
+	/**
409
+	 * admin_footer_scripts
410
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class.
411
+	 *
412
+	 * @access public
413
+	 * @return void
414
+	 */
415
+	abstract public function admin_footer_scripts();
416
+
417
+
418
+
419
+	/**
420
+	 * admin_footer
421
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class.
422
+	 *
423
+	 * @access  public
424
+	 * @return void
425
+	 */
426
+	public function admin_footer()
427
+	{
428
+	}
429
+
430
+
431
+
432
+	/**
433
+	 * _global_ajax_hooks
434
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
435
+	 * Note: within the ajax callback methods.
436
+	 *
437
+	 * @abstract
438
+	 * @access protected
439
+	 * @return void
440
+	 */
441
+	protected function _global_ajax_hooks()
442
+	{
443
+		//for lazy loading of metabox content
444
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
445
+	}
446
+
447
+
448
+
449
+	public function ajax_metabox_content()
450
+	{
451
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
452
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
453
+		self::cached_rss_display($contentid, $url);
454
+		wp_die();
455
+	}
456
+
457
+
458
+
459
+	/**
460
+	 * _page_setup
461
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested doesn't match the object.
462
+	 *
463
+	 * @final
464
+	 * @access protected
465
+	 * @return void
466
+	 */
467
+	final protected function _page_setup()
468
+	{
469
+		//requires?
470
+		//admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
471
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
472
+		//next verify if we need to load anything...
473
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474
+		$this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475
+		global $ee_menu_slugs;
476
+		$ee_menu_slugs = (array)$ee_menu_slugs;
477
+		if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478
+			return false;
479
+		}
480
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
481
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
482
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
483
+		}
484
+		// then set blank or -1 action values to 'default'
485
+		$this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
486
+		//if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
487
+		$this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
488
+		//however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490
+		$this->_current_view = $this->_req_action;
491
+		$this->_req_nonce = $this->_req_action . '_nonce';
492
+		$this->_define_page_props();
493
+		$this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494
+		//default things
495
+		$this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
496
+		//set page configs
497
+		$this->_set_page_routes();
498
+		$this->_set_page_config();
499
+		//let's include any referrer data in our default_query_args for this route for "stickiness".
500
+		if (isset($this->_req_data['wp_referer'])) {
501
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
502
+		}
503
+		//for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
504
+		if (method_exists($this, '_extend_page_config')) {
505
+			$this->_extend_page_config();
506
+		}
507
+		//for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
508
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
509
+			$this->_extend_page_config_for_cpt();
510
+		}
511
+		//filter routes and page_config so addons can add their stuff. Filtering done per class
512
+		$this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
+		$this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
514
+		//if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
515
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
+			add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
517
+		}
518
+		//next route only if routing enabled
519
+		if ($this->_routing && ! defined('DOING_AJAX')) {
520
+			$this->_verify_routes();
521
+			//next let's just check user_access and kill if no access
522
+			$this->check_user_access();
523
+			if ($this->_is_UI_request) {
524
+				//admin_init stuff - global, all views for this page class, specific view
525
+				add_action('admin_init', array($this, 'admin_init'), 10);
526
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
528
+				}
529
+			} else {
530
+				//hijack regular WP loading and route admin request immediately
531
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
532
+				$this->route_admin_request();
533
+			}
534
+		}
535
+	}
536
+
537
+
538
+
539
+	/**
540
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
541
+	 *
542
+	 * @access private
543
+	 * @return void
544
+	 */
545
+	private function _do_other_page_hooks()
546
+	{
547
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
548
+		foreach ($registered_pages as $page) {
549
+			//now let's setup the file name and class that should be present
550
+			$classname = str_replace('.class.php', '', $page);
551
+			//autoloaders should take care of loading file
552
+			if ( ! class_exists($classname)) {
553
+				$error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
554
+				$error_msg[] = $error_msg[0]
555
+							   . "\r\n"
556
+							   . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
557
+								'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>');
558
+				throw new EE_Error(implode('||', $error_msg));
559
+			}
560
+			$a = new ReflectionClass($classname);
561
+			//notice we are passing the instance of this class to the hook object.
562
+			$hookobj[] = $a->newInstance($this);
563
+		}
564
+	}
565
+
566
+
567
+
568
+	public function load_page_dependencies()
569
+	{
570
+		try {
571
+			$this->_load_page_dependencies();
572
+		} catch (EE_Error $e) {
573
+			$e->get_error();
574
+		}
575
+	}
576
+
577
+
578
+
579
+	/**
580
+	 * load_page_dependencies
581
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
582
+	 *
583
+	 * @access public
584
+	 * @return void
585
+	 */
586
+	protected function _load_page_dependencies()
587
+	{
588
+		//let's set the current_screen and screen options to override what WP set
589
+		$this->_current_screen = get_current_screen();
590
+		//load admin_notices - global, page class, and view specific
591
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
593
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
595
+		}
596
+		//load network admin_notices - global, page class, and view specific
597
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
600
+		}
601
+		//this will save any per_page screen options if they are present
602
+		$this->_set_per_page_screen_options();
603
+		//setup list table properties
604
+		$this->_set_list_table();
605
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
606
+		$this->_add_registered_meta_boxes();
607
+		$this->_add_screen_columns();
608
+		//add screen options - global, page child class, and view specific
609
+		$this->_add_global_screen_options();
610
+		$this->_add_screen_options();
611
+		if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
+			call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
613
+		}
614
+		//add help tab(s) and tours- set via page_config and qtips.
615
+		$this->_add_help_tour();
616
+		$this->_add_help_tabs();
617
+		$this->_add_qtips();
618
+		//add feature_pointers - global, page child class, and view specific
619
+		$this->_add_feature_pointers();
620
+		$this->_add_global_feature_pointers();
621
+		if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
+			call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
623
+		}
624
+		//enqueue scripts/styles - global, page class, and view specific
625
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
+		if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
+			add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
629
+		}
630
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631
+		//admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
632
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
+		if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
+			add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
636
+		}
637
+		//admin footer scripts
638
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
640
+		if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
+			add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
642
+		}
643
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644
+		//targeted hook
645
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
646
+	}
647
+
648
+
649
+
650
+	/**
651
+	 * _set_defaults
652
+	 * This sets some global defaults for class properties.
653
+	 */
654
+	private function _set_defaults()
655
+	{
656
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
657
+		$this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
658
+		$this->default_nav_tab_name = 'overview';
659
+		//init template args
660
+		$this->_template_args = array(
661
+				'admin_page_header'  => '',
662
+				'admin_page_content' => '',
663
+				'post_body_content'  => '',
664
+				'before_list_table'  => '',
665
+				'after_list_table'   => '',
666
+		);
667
+	}
668
+
669
+
670
+
671
+	/**
672
+	 * route_admin_request
673
+	 *
674
+	 * @see    _route_admin_request()
675
+	 * @access public
676
+	 * @return void|exception error
677
+	 */
678
+	public function route_admin_request()
679
+	{
680
+		try {
681
+			$this->_route_admin_request();
682
+		} catch (EE_Error $e) {
683
+			$e->get_error();
684
+		}
685
+	}
686
+
687
+
688
+
689
+	public function set_wp_page_slug($wp_page_slug)
690
+	{
691
+		$this->_wp_page_slug = $wp_page_slug;
692
+		//if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
693
+		if (is_network_admin()) {
694
+			$this->_wp_page_slug .= '-network';
695
+		}
696
+	}
697
+
698
+
699
+
700
+	/**
701
+	 * _verify_routes
702
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so we know if we need to drop out.
703
+	 *
704
+	 * @access protected
705
+	 * @return void
706
+	 */
707
+	protected function _verify_routes()
708
+	{
709
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
710
+		if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
711
+			return false;
712
+		}
713
+		$this->_route = false;
714
+		$func = false;
715
+		$args = array();
716
+		// check that the page_routes array is not empty
717
+		if (empty($this->_page_routes)) {
718
+			// user error msg
719
+			$error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720
+			// developer error msg
721
+			$error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722
+			throw new EE_Error($error_msg);
723
+		}
724
+		// and that the requested page route exists
725
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
726
+			$this->_route = $this->_page_routes[$this->_req_action];
727
+			$this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
728
+		} else {
729
+			// user error msg
730
+			$error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731
+			// developer error msg
732
+			$error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733
+			throw new EE_Error($error_msg);
734
+		}
735
+		// and that a default route exists
736
+		if ( ! array_key_exists('default', $this->_page_routes)) {
737
+			// user error msg
738
+			$error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739
+			// developer error msg
740
+			$error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741
+			throw new EE_Error($error_msg);
742
+		}
743
+		//first lets' catch if the UI request has EVER been set.
744
+		if ($this->_is_UI_request === null) {
745
+			//lets set if this is a UI request or not.
746
+			$this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
747
+			//wait a minute... we might have a noheader in the route array
748
+			$this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
749
+		}
750
+		$this->_set_current_labels();
751
+	}
752
+
753
+
754
+
755
+	/**
756
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
757
+	 *
758
+	 * @param  string $route the route name we're verifying
759
+	 * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
760
+	 */
761
+	protected function _verify_route($route)
762
+	{
763
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
764
+			return true;
765
+		} else {
766
+			// user error msg
767
+			$error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768
+			// developer error msg
769
+			$error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770
+			throw new EE_Error($error_msg);
771
+		}
772
+	}
773
+
774
+
775
+
776
+	/**
777
+	 * perform nonce verification
778
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!)
779
+	 *
780
+	 * @param  string $nonce     The nonce sent
781
+	 * @param  string $nonce_ref The nonce reference string (name0)
782
+	 * @return mixed (bool|die)
783
+	 */
784
+	protected function _verify_nonce($nonce, $nonce_ref)
785
+	{
786
+		// verify nonce against expected value
787
+		if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
788
+			// these are not the droids you are looking for !!!
789
+			$msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790
+			if (WP_DEBUG) {
791
+				$msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792
+			}
793
+			if ( ! defined('DOING_AJAX')) {
794
+				wp_die($msg);
795
+			} else {
796
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
797
+				$this->_return_json();
798
+			}
799
+		}
800
+	}
801
+
802
+
803
+
804
+	/**
805
+	 * _route_admin_request()
806
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
807
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
808
+	 * in the page routes and then will try to load the corresponding method.
809
+	 *
810
+	 * @access protected
811
+	 * @return void
812
+	 * @throws \EE_Error
813
+	 */
814
+	protected function _route_admin_request()
815
+	{
816
+		if ( ! $this->_is_UI_request) {
817
+			$this->_verify_routes();
818
+		}
819
+		$nonce_check = isset($this->_route_config['require_nonce'])
820
+			? $this->_route_config['require_nonce']
821
+			: true;
822
+		if ($this->_req_action !== 'default' && $nonce_check) {
823
+			// set nonce from post data
824
+			$nonce = isset($this->_req_data[$this->_req_nonce])
825
+				? sanitize_text_field($this->_req_data[$this->_req_nonce])
826
+				: '';
827
+			$this->_verify_nonce($nonce, $this->_req_nonce);
828
+		}
829
+		//set the nav_tabs array but ONLY if this is  UI_request
830
+		if ($this->_is_UI_request) {
831
+			$this->_set_nav_tabs();
832
+		}
833
+		// grab callback function
834
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
835
+		// check if callback has args
836
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
837
+		$error_msg = '';
838
+		// action right before calling route
839
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
840
+		if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
841
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
842
+		}
843
+		// right before calling the route, let's remove _wp_http_referer from the
844
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
845
+		$_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
846
+		if ( ! empty($func)) {
847
+			if (is_array($func)) {
848
+				list($class, $method) = $func;
849
+			} else if (strpos($func, '::') !== false) {
850
+				list($class, $method) = explode('::', $func);
851
+			} else {
852
+				$class = $this;
853
+				$method = $func;
854
+			}
855
+			if ( ! (is_object($class) && $class === $this)) {
856
+				// send along this admin page object for access by addons.
857
+				$args['admin_page_object'] = $this;
858
+			}
859
+
860
+			if (
861
+				//is it a method on a class that doesn't work?
862
+				(
863
+					(
864
+						method_exists($class, $method)
865
+						&& call_user_func_array(array($class, $method), $args) === false
866
+					)
867
+					&& (
868
+						//is it a standalone function that doesn't work?
869
+						function_exists($method)
870
+						&& call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
871
+					)
872
+				)
873
+				|| (
874
+					//is it neither a class method NOR a standalone function?
875
+					! method_exists($class, $method)
876
+					&& ! function_exists($method)
877
+				)
878
+			) {
879
+				// user error msg
880
+				$error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
881
+				// developer error msg
882
+				$error_msg .= '||';
883
+				$error_msg .= sprintf(
884
+					__(
885
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
886
+						'event_espresso'
887
+					),
888
+					$method
889
+				);
890
+			}
891
+			if ( ! empty($error_msg)) {
892
+				throw new EE_Error($error_msg);
893
+			}
894
+		}
895
+		//if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
896
+		//now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
897
+		if ($this->_is_UI_request === false
898
+			&& is_array($this->_route)
899
+			&& ! empty($this->_route['headers_sent_route'])
900
+		) {
901
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
902
+		}
903
+	}
904
+
905
+
906
+
907
+	/**
908
+	 * This method just allows the resetting of page properties in the case where a no headers
909
+	 * route redirects to a headers route in its route config.
910
+	 *
911
+	 * @since   4.3.0
912
+	 * @param  string $new_route New (non header) route to redirect to.
913
+	 * @return   void
914
+	 */
915
+	protected function _reset_routing_properties($new_route)
916
+	{
917
+		$this->_is_UI_request = true;
918
+		//now we set the current route to whatever the headers_sent_route is set at
919
+		$this->_req_data['action'] = $new_route;
920
+		//rerun page setup
921
+		$this->_page_setup();
922
+	}
923
+
924
+
925
+
926
+	/**
927
+	 * _add_query_arg
928
+	 * adds nonce to array of arguments then calls WP add_query_arg function
929
+	 *(internally just uses EEH_URL's function with the same name)
930
+	 *
931
+	 * @access public
932
+	 * @param array  $args
933
+	 * @param string $url
934
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
935
+	 *                                        url in an associative array indexed by the key 'wp_referer';
936
+	 *                                        Example usage:
937
+	 *                                        If the current page is:
938
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
939
+	 *                                        &action=default&event_id=20&month_range=March%202015
940
+	 *                                        &_wpnonce=5467821
941
+	 *                                        and you call:
942
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
943
+	 *                                        array(
944
+	 *                                        'action' => 'resend_something',
945
+	 *                                        'page=>espresso_registrations'
946
+	 *                                        ),
947
+	 *                                        $some_url,
948
+	 *                                        true
949
+	 *                                        );
950
+	 *                                        It will produce a url in this structure:
951
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
952
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
953
+	 *                                        month_range]=March%202015
954
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
955
+	 * @return string
956
+	 */
957
+	public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
958
+	{
959
+		//if there is a _wp_http_referer include the values from the request but only if sticky = true
960
+		if ($sticky) {
961
+			$request = $_REQUEST;
962
+			unset($request['_wp_http_referer']);
963
+			unset($request['wp_referer']);
964
+			foreach ($request as $key => $value) {
965
+				//do not add nonces
966
+				if (strpos($key, 'nonce') !== false) {
967
+					continue;
968
+				}
969
+				$args['wp_referer[' . $key . ']'] = $value;
970
+			}
971
+		}
972
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
973
+	}
974
+
975
+
976
+
977
+	/**
978
+	 * This returns a generated link that will load the related help tab.
979
+	 *
980
+	 * @param  string $help_tab_id the id for the connected help tab
981
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
982
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
983
+	 * @uses EEH_Template::get_help_tab_link()
984
+	 * @return string              generated link
985
+	 */
986
+	protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
987
+	{
988
+		return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
989
+	}
990
+
991
+
992
+
993
+	/**
994
+	 * _add_help_tabs
995
+	 * Note child classes define their help tabs within the page_config array.
996
+	 *
997
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
998
+	 * @access protected
999
+	 * @return void
1000
+	 */
1001
+	protected function _add_help_tabs()
1002
+	{
1003
+		$tour_buttons = '';
1004
+		if (isset($this->_page_config[$this->_req_action])) {
1005
+			$config = $this->_page_config[$this->_req_action];
1006
+			//is there a help tour for the current route?  if there is let's setup the tour buttons
1007
+			if (isset($this->_help_tour[$this->_req_action])) {
1008
+				$tb = array();
1009
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1010
+				foreach ($this->_help_tour['tours'] as $tour) {
1011
+					//if this is the end tour then we don't need to setup a button
1012
+					if ($tour instanceof EE_Help_Tour_final_stop) {
1013
+						continue;
1014
+					}
1015
+					$tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1016
+				}
1017
+				$tour_buttons .= implode('<br />', $tb);
1018
+				$tour_buttons .= '</div></div>';
1019
+			}
1020
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1021
+			if (is_array($config) && isset($config['help_sidebar'])) {
1022
+				//check that the callback given is valid
1023
+				if ( ! method_exists($this, $config['help_sidebar'])) {
1024
+					throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1025
+							'event_espresso'), $config['help_sidebar'], get_class($this)));
1026
+				}
1027
+				$content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1028
+				$content .= $tour_buttons; //add help tour buttons.
1029
+				//do we have any help tours setup?  Cause if we do we want to add the buttons
1030
+				$this->_current_screen->set_help_sidebar($content);
1031
+			}
1032
+			//if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1033
+			if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1034
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1035
+			}
1036
+			//handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1037
+			if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1038
+				$_ht['id'] = $this->page_slug;
1039
+				$_ht['title'] = __('Help Tours', 'event_espresso');
1040
+				$_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1041
+				$this->_current_screen->add_help_tab($_ht);
1042
+			}/**/
1043
+			if ( ! isset($config['help_tabs'])) {
1044
+				return;
1045
+			} //no help tabs for this route
1046
+			foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1047
+				//we're here so there ARE help tabs!
1048
+				//make sure we've got what we need
1049
+				if ( ! isset($cfg['title'])) {
1050
+					throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1051
+				}
1052
+				if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1053
+					throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1054
+							'event_espresso'));
1055
+				}
1056
+				//first priority goes to content.
1057
+				if ( ! empty($cfg['content'])) {
1058
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1059
+					//second priority goes to filename
1060
+				} else if ( ! empty($cfg['filename'])) {
1061
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1062
+					//it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1063
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1064
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1065
+					if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1066
+						EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1067
+								'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1068
+						return;
1069
+					}
1070
+					$template_args['admin_page_obj'] = $this;
1071
+					$content = EEH_Template::display_template($file_path, $template_args, true);
1072
+				} else {
1073
+					$content = '';
1074
+				}
1075
+				//check if callback is valid
1076
+				if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1077
+					EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1078
+							'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1079
+					return;
1080
+				}
1081
+				//setup config array for help tab method
1082
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1083
+				$_ht = array(
1084
+						'id'       => $id,
1085
+						'title'    => $cfg['title'],
1086
+						'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1087
+						'content'  => $content,
1088
+				);
1089
+				$this->_current_screen->add_help_tab($_ht);
1090
+			}
1091
+		}
1092
+	}
1093
+
1094
+
1095
+
1096
+	/**
1097
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is an array with properties for setting up usage of the joyride plugin
1098
+	 *
1099
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1100
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1101
+	 * @access protected
1102
+	 * @return void
1103
+	 */
1104
+	protected function _add_help_tour()
1105
+	{
1106
+		$tours = array();
1107
+		$this->_help_tour = array();
1108
+		//exit early if help tours are turned off globally
1109
+		if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1110
+			return;
1111
+		}
1112
+		//loop through _page_config to find any help_tour defined
1113
+		foreach ($this->_page_config as $route => $config) {
1114
+			//we're only going to set things up for this route
1115
+			if ($route !== $this->_req_action) {
1116
+				continue;
1117
+			}
1118
+			if (isset($config['help_tour'])) {
1119
+				foreach ($config['help_tour'] as $tour) {
1120
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1121
+					//let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1122
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1123
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1124
+					if ( ! is_readable($file_path)) {
1125
+						EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
1126
+								$file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1127
+						return;
1128
+					}
1129
+					require_once $file_path;
1130
+					if ( ! class_exists($tour)) {
1131
+						$error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1132
+						$error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1133
+										'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1134
+						throw new EE_Error(implode('||', $error_msg));
1135
+					}
1136
+					$a = new ReflectionClass($tour);
1137
+					$tour_obj = $a->newInstance($this->_is_caf);
1138
+					$tours[] = $tour_obj;
1139
+					$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1140
+				}
1141
+				//let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1142
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1143
+				$tours[] = $end_stop_tour;
1144
+				$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1145
+			}
1146
+		}
1147
+		if ( ! empty($tours)) {
1148
+			$this->_help_tour['tours'] = $tours;
1149
+		}
1150
+		//thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1151
+	}
1152
+
1153
+
1154
+
1155
+	/**
1156
+	 * This simply sets up any qtips that have been defined in the page config
1157
+	 *
1158
+	 * @access protected
1159
+	 * @return void
1160
+	 */
1161
+	protected function _add_qtips()
1162
+	{
1163
+		if (isset($this->_route_config['qtips'])) {
1164
+			$qtips = (array)$this->_route_config['qtips'];
1165
+			//load qtip loader
1166
+			$path = array(
1167
+					$this->_get_dir() . '/qtips/',
1168
+					EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1169
+			);
1170
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1171
+		}
1172
+	}
1173
+
1174
+
1175
+
1176
+	/**
1177
+	 * _set_nav_tabs
1178
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly.
1179
+	 *
1180
+	 * @access protected
1181
+	 * @return void
1182
+	 */
1183
+	protected function _set_nav_tabs()
1184
+	{
1185
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1186
+		$i = 0;
1187
+		foreach ($this->_page_config as $slug => $config) {
1188
+			if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1189
+				continue;
1190
+			} //no nav tab for this config
1191
+			//check for persistent flag
1192
+			if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1193
+				continue;
1194
+			} //nav tab is only to appear when route requested.
1195
+			if ( ! $this->check_user_access($slug, true)) {
1196
+				continue;
1197
+			} //no nav tab becasue current user does not have access.
1198
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1199
+			$this->_nav_tabs[$slug] = array(
1200
+					'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1201
+					'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1202
+					'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1203
+					'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1204
+			);
1205
+			$i++;
1206
+		}
1207
+		//if $this->_nav_tabs is empty then lets set the default
1208
+		if (empty($this->_nav_tabs)) {
1209
+			$this->_nav_tabs[$this->default_nav_tab_name] = array(
1210
+					'url'       => $this->admin_base_url,
1211
+					'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1212
+					'css_class' => 'nav-tab-active',
1213
+					'order'     => 10,
1214
+			);
1215
+		}
1216
+		//now let's sort the tabs according to order
1217
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1218
+	}
1219
+
1220
+
1221
+
1222
+	/**
1223
+	 * _set_current_labels
1224
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1225
+	 *
1226
+	 * @access private
1227
+	 * @return void
1228
+	 */
1229
+	private function _set_current_labels()
1230
+	{
1231
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1232
+			foreach ($this->_route_config['labels'] as $label => $text) {
1233
+				if (is_array($text)) {
1234
+					foreach ($text as $sublabel => $subtext) {
1235
+						$this->_labels[$label][$sublabel] = $subtext;
1236
+					}
1237
+				} else {
1238
+					$this->_labels[$label] = $text;
1239
+				}
1240
+			}
1241
+		}
1242
+	}
1243
+
1244
+
1245
+
1246
+	/**
1247
+	 *        verifies user access for this admin page
1248
+	 *
1249
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1250
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1251
+	 * @return        BOOL|wp_die()
1252
+	 */
1253
+	public function check_user_access($route_to_check = '', $verify_only = false)
1254
+	{
1255
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1256
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1257
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability'])
1258
+				? $this->_page_routes[$route_to_check]['capability'] : null;
1259
+		if (empty($capability) && empty($route_to_check)) {
1260
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1261
+		} else {
1262
+			$capability = empty($capability) ? 'manage_options' : $capability;
1263
+		}
1264
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1265
+		if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1266
+			if ($verify_only) {
1267
+				return false;
1268
+			} else {
1269
+				if ( is_user_logged_in() ) {
1270
+					wp_die(__('You do not have access to this route.', 'event_espresso'));
1271
+				} else {
1272
+					return false;
1273
+				}
1274
+			}
1275
+		}
1276
+		return true;
1277
+	}
1278
+
1279
+
1280
+
1281
+	/**
1282
+	 * admin_init_global
1283
+	 * This runs all the code that we want executed within the WP admin_init hook.
1284
+	 * This method executes for ALL EE Admin pages.
1285
+	 *
1286
+	 * @access public
1287
+	 * @return void
1288
+	 */
1289
+	public function admin_init_global()
1290
+	{
1291
+	}
1292
+
1293
+
1294
+
1295
+	/**
1296
+	 * wp_loaded_global
1297
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an EE_Admin page and will execute on every EE Admin Page load
1298
+	 *
1299
+	 * @access public
1300
+	 * @return void
1301
+	 */
1302
+	public function wp_loaded()
1303
+	{
1304
+	}
1305
+
1306
+
1307
+
1308
+	/**
1309
+	 * admin_notices
1310
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1311
+	 *
1312
+	 * @access public
1313
+	 * @return void
1314
+	 */
1315
+	public function admin_notices_global()
1316
+	{
1317
+		$this->_display_no_javascript_warning();
1318
+		$this->_display_espresso_notices();
1319
+	}
1320
+
1321
+
1322
+
1323
+	public function network_admin_notices_global()
1324
+	{
1325
+		$this->_display_no_javascript_warning();
1326
+		$this->_display_espresso_notices();
1327
+	}
1328
+
1329
+
1330
+
1331
+	/**
1332
+	 * admin_footer_scripts_global
1333
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages.
1334
+	 *
1335
+	 * @access public
1336
+	 * @return void
1337
+	 */
1338
+	public function admin_footer_scripts_global()
1339
+	{
1340
+		$this->_add_admin_page_ajax_loading_img();
1341
+		$this->_add_admin_page_overlay();
1342
+		//if metaboxes are present we need to add the nonce field
1343
+		if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1344
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1345
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1346
+		}
1347
+	}
1348
+
1349
+
1350
+
1351
+	/**
1352
+	 * admin_footer_global
1353
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1354
+	 *
1355
+	 * @access  public
1356
+	 * @return  void
1357
+	 */
1358
+	public function admin_footer_global()
1359
+	{
1360
+		//dialog container for dialog helper
1361
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1362
+		$d_cont .= '<div class="ee-notices"></div>';
1363
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1364
+		$d_cont .= '</div>';
1365
+		echo $d_cont;
1366
+		//help tour stuff?
1367
+		if (isset($this->_help_tour[$this->_req_action])) {
1368
+			echo implode('<br />', $this->_help_tour[$this->_req_action]);
1369
+		}
1370
+		//current set timezone for timezone js
1371
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1372
+	}
1373
+
1374
+
1375
+
1376
+	/**
1377
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then we'll use the retrieved array to output the content using the template.
1378
+	 * For child classes:
1379
+	 * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for
1380
+	 * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content for the
1381
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1382
+	 *    'help_trigger_id' => array(
1383
+	 *        'title' => __('localized title for popup', 'event_espresso'),
1384
+	 *        'content' => __('localized content for popup', 'event_espresso')
1385
+	 *    )
1386
+	 * );
1387
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1388
+	 *
1389
+	 * @access protected
1390
+	 * @return string content
1391
+	 */
1392
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1393
+	{
1394
+		$content = '';
1395
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1396
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1397
+		//loop through the array and setup content
1398
+		foreach ($help_array as $trigger => $help) {
1399
+			//make sure the array is setup properly
1400
+			if ( ! isset($help['title']) || ! isset($help['content'])) {
1401
+				throw new EE_Error(__('Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1402
+						'event_espresso'));
1403
+			}
1404
+			//we're good so let'd setup the template vars and then assign parsed template content to our content.
1405
+			$template_args = array(
1406
+					'help_popup_id'      => $trigger,
1407
+					'help_popup_title'   => $help['title'],
1408
+					'help_popup_content' => $help['content'],
1409
+			);
1410
+			$content .= EEH_Template::display_template($template_path, $template_args, true);
1411
+		}
1412
+		if ($display) {
1413
+			echo $content;
1414
+		} else {
1415
+			return $content;
1416
+		}
1417
+	}
1418
+
1419
+
1420
+
1421
+	/**
1422
+	 * All this does is retrive the help content array if set by the EE_Admin_Page child
1423
+	 *
1424
+	 * @access private
1425
+	 * @return array properly formatted array for help popup content
1426
+	 */
1427
+	private function _get_help_content()
1428
+	{
1429
+		//what is the method we're looking for?
1430
+		$method_name = '_help_popup_content_' . $this->_req_action;
1431
+		//if method doesn't exist let's get out.
1432
+		if ( ! method_exists($this, $method_name)) {
1433
+			return array();
1434
+		}
1435
+		//k we're good to go let's retrieve the help array
1436
+		$help_array = call_user_func(array($this, $method_name));
1437
+		//make sure we've got an array!
1438
+		if ( ! is_array($help_array)) {
1439
+			throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso'));
1440
+		}
1441
+		return $help_array;
1442
+	}
1443
+
1444
+
1445
+
1446
+	/**
1447
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1448
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1449
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1450
+	 *
1451
+	 * @access protected
1452
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1453
+	 * @param boolean $display    if false then we return the trigger string
1454
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1455
+	 * @return string
1456
+	 */
1457
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1458
+	{
1459
+		if (defined('DOING_AJAX')) {
1460
+			return;
1461
+		}
1462
+		//let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1463
+		$help_array = $this->_get_help_content();
1464
+		$help_content = '';
1465
+		if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1466
+			$help_array[$trigger_id] = array(
1467
+					'title'   => __('Missing Content', 'event_espresso'),
1468
+					'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1469
+							'event_espresso'),
1470
+			);
1471
+			$help_content = $this->_set_help_popup_content($help_array, false);
1472
+		}
1473
+		//let's setup the trigger
1474
+		$content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1475
+		$content = $content . $help_content;
1476
+		if ($display) {
1477
+			echo $content;
1478
+		} else {
1479
+			return $content;
1480
+		}
1481
+	}
1482
+
1483
+
1484
+
1485
+	/**
1486
+	 * _add_global_screen_options
1487
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1488
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1489
+	 *
1490
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1491
+	 *         see also WP_Screen object documents...
1492
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1493
+	 * @abstract
1494
+	 * @access private
1495
+	 * @return void
1496
+	 */
1497
+	private function _add_global_screen_options()
1498
+	{
1499
+	}
1500
+
1501
+
1502
+
1503
+	/**
1504
+	 * _add_global_feature_pointers
1505
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1506
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1507
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1508
+	 *
1509
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1510
+	 * @link   http://eamann.com/tech/wordpress-portland/
1511
+	 * @abstract
1512
+	 * @access protected
1513
+	 * @return void
1514
+	 */
1515
+	private function _add_global_feature_pointers()
1516
+	{
1517
+	}
1518
+
1519
+
1520
+
1521
+	/**
1522
+	 * load_global_scripts_styles
1523
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1524
+	 *
1525
+	 * @return void
1526
+	 */
1527
+	public function load_global_scripts_styles()
1528
+	{
1529
+		/** STYLES **/
1530
+		// add debugging styles
1531
+		if (WP_DEBUG) {
1532
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1533
+		}
1534
+		//register all styles
1535
+		wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1536
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1537
+		//helpers styles
1538
+		wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1539
+		//enqueue global styles
1540
+		wp_enqueue_style('ee-admin-css');
1541
+		/** SCRIPTS **/
1542
+		//register all scripts
1543
+		wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1544
+		wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1545
+		wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1546
+		wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1547
+		// register jQuery Validate - see /includes/functions/wp_hooks.php
1548
+		add_filter('FHEE_load_jquery_validate', '__return_true');
1549
+		add_filter('FHEE_load_joyride', '__return_true');
1550
+		//script for sorting tables
1551
+		wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1552
+		//script for parsing uri's
1553
+		wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1554
+		//and parsing associative serialized form elements
1555
+		wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1556
+		//helpers scripts
1557
+		wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1558
+		wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1559
+		wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1560
+		wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1561
+		//google charts
1562
+		wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1563
+		//enqueue global scripts
1564
+		//taking care of metaboxes
1565
+		if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) {
1566
+			wp_enqueue_script('dashboard');
1567
+		}
1568
+		//enqueue thickbox for ee help popups.  default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups
1569
+		if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) {
1570
+			wp_enqueue_script('ee_admin_js');
1571
+			wp_enqueue_style('ee-admin-css');
1572
+		}
1573
+		//localize script for ajax lazy loading
1574
+		$lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1575
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1576
+		/**
1577
+		 * help tour stuff
1578
+		 */
1579
+		if ( ! empty($this->_help_tour)) {
1580
+			//register the js for kicking things off
1581
+			wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1582
+			//setup tours for the js tour object
1583
+			foreach ($this->_help_tour['tours'] as $tour) {
1584
+				$tours[] = array(
1585
+						'id'      => $tour->get_slug(),
1586
+						'options' => $tour->get_options(),
1587
+				);
1588
+			}
1589
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1590
+			//admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1591
+		}
1592
+	}
1593
+
1594
+
1595
+
1596
+	/**
1597
+	 *        admin_footer_scripts_eei18n_js_strings
1598
+	 *
1599
+	 * @access        public
1600
+	 * @return        void
1601
+	 */
1602
+	public function admin_footer_scripts_eei18n_js_strings()
1603
+	{
1604
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1605
+		EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso');
1606
+		EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1607
+		EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1608
+		EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1609
+		EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1610
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1611
+		EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1612
+		EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1613
+		EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1614
+		EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1615
+		EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1616
+		EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1617
+		EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1618
+		EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1619
+		EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1620
+		EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1621
+		EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1622
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1623
+		EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1624
+		EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1625
+		EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1626
+		EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1627
+		EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1628
+		EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1629
+		EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1630
+		EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1631
+		EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1632
+		EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1633
+		EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1634
+		EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1635
+		EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1636
+		EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1637
+		EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1638
+		EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1639
+		EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1640
+		EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1641
+		EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1642
+		EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1643
+		EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1644
+		//setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance
1645
+		//admin page when in maintenance mode and ee_admin_js is not loaded then.  This works everywhere else because
1646
+		//espresso_core is listed as a dependency of ee_admin_js.
1647
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
1648
+	}
1649
+
1650
+
1651
+
1652
+	/**
1653
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1654
+	 *
1655
+	 * @access        public
1656
+	 * @return        void
1657
+	 */
1658
+	public function add_xdebug_style()
1659
+	{
1660
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1661
+	}
1662
+
1663
+
1664
+	/************************/
1665
+	/** LIST TABLE METHODS **/
1666
+	/************************/
1667
+	/**
1668
+	 * this sets up the list table if the current view requires it.
1669
+	 *
1670
+	 * @access protected
1671
+	 * @return void
1672
+	 */
1673
+	protected function _set_list_table()
1674
+	{
1675
+		//first is this a list_table view?
1676
+		if ( ! isset($this->_route_config['list_table'])) {
1677
+			return;
1678
+		} //not a list_table view so get out.
1679
+		//list table functions are per view specific (because some admin pages might have more than one listtable!)
1680
+		if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1681
+			//user error msg
1682
+			$error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1683
+			//developer error msg
1684
+			$error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1685
+							$this->_req_action, '_set_list_table_views_' . $this->_req_action);
1686
+			throw new EE_Error($error_msg);
1687
+		}
1688
+		//let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1689
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1690
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1691
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1692
+		$this->_set_list_table_view();
1693
+		$this->_set_list_table_object();
1694
+	}
1695
+
1696
+
1697
+
1698
+	/**
1699
+	 *        set current view for List Table
1700
+	 *
1701
+	 * @access public
1702
+	 * @return array
1703
+	 */
1704
+	protected function _set_list_table_view()
1705
+	{
1706
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1707
+		// looking at active items or dumpster diving ?
1708
+		if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1709
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1710
+		} else {
1711
+			$this->_view = sanitize_key($this->_req_data['status']);
1712
+		}
1713
+	}
1714
+
1715
+
1716
+
1717
+	/**
1718
+	 * _set_list_table_object
1719
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1720
+	 *
1721
+	 * @throws \EE_Error
1722
+	 */
1723
+	protected function _set_list_table_object()
1724
+	{
1725
+		if (isset($this->_route_config['list_table'])) {
1726
+			if ( ! class_exists($this->_route_config['list_table'])) {
1727
+				throw new EE_Error(
1728
+						sprintf(
1729
+								__(
1730
+										'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
1731
+										'event_espresso'
1732
+								),
1733
+								$this->_route_config['list_table'],
1734
+								get_class($this)
1735
+						)
1736
+				);
1737
+			}
1738
+			$list_table = $this->_route_config['list_table'];
1739
+			$this->_list_table_object = new $list_table($this);
1740
+		}
1741
+	}
1742
+
1743
+
1744
+
1745
+	/**
1746
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1747
+	 *
1748
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1749
+	 *                                                    urls.  The array should be indexed by the view it is being
1750
+	 *                                                    added to.
1751
+	 * @return array
1752
+	 */
1753
+	public function get_list_table_view_RLs($extra_query_args = array())
1754
+	{
1755
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1756
+		if (empty($this->_views)) {
1757
+			$this->_views = array();
1758
+		}
1759
+		// cycle thru views
1760
+		foreach ($this->_views as $key => $view) {
1761
+			$query_args = array();
1762
+			// check for current view
1763
+			$this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1764
+			$query_args['action'] = $this->_req_action;
1765
+			$query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1766
+			$query_args['status'] = $view['slug'];
1767
+			//merge any other arguments sent in.
1768
+			if (isset($extra_query_args[$view['slug']])) {
1769
+				$query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1770
+			}
1771
+			$this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1772
+		}
1773
+		return $this->_views;
1774
+	}
1775
+
1776
+
1777
+
1778
+	/**
1779
+	 * _entries_per_page_dropdown
1780
+	 * generates a drop down box for selecting the number of visiable rows in an admin page list table
1781
+	 *
1782
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1783
+	 * @access protected
1784
+	 * @param int $max_entries total number of rows in the table
1785
+	 * @return string
1786
+	 */
1787
+	protected function _entries_per_page_dropdown($max_entries = false)
1788
+	{
1789
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1790
+		$values = array(10, 25, 50, 100);
1791
+		$per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1792
+		if ($max_entries) {
1793
+			$values[] = $max_entries;
1794
+			sort($values);
1795
+		}
1796
+		$entries_per_page_dropdown = '
1797 1797
 			<div id="entries-per-page-dv" class="alignleft actions">
1798 1798
 				<label class="hide-if-no-js">
1799 1799
 					Show
1800 1800
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1801
-        foreach ($values as $value) {
1802
-            if ($value < $max_entries) {
1803
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1804
-                $entries_per_page_dropdown .= '
1801
+		foreach ($values as $value) {
1802
+			if ($value < $max_entries) {
1803
+				$selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1804
+				$entries_per_page_dropdown .= '
1805 1805
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1806
-            }
1807
-        }
1808
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1809
-        $entries_per_page_dropdown .= '
1806
+			}
1807
+		}
1808
+		$selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1809
+		$entries_per_page_dropdown .= '
1810 1810
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1811
-        $entries_per_page_dropdown .= '
1811
+		$entries_per_page_dropdown .= '
1812 1812
 					</select>
1813 1813
 					entries
1814 1814
 				</label>
1815 1815
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
1816 1816
 			</div>
1817 1817
 		';
1818
-        return $entries_per_page_dropdown;
1819
-    }
1820
-
1821
-
1822
-
1823
-    /**
1824
-     *        _set_search_attributes
1825
-     *
1826
-     * @access        protected
1827
-     * @return        void
1828
-     */
1829
-    public function _set_search_attributes()
1830
-    {
1831
-        $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1832
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1833
-    }
1834
-
1835
-    /*** END LIST TABLE METHODS **/
1836
-    /*****************************/
1837
-    /**
1838
-     *        _add_registered_metaboxes
1839
-     *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1840
-     *
1841
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1842
-     * @access private
1843
-     * @return void
1844
-     */
1845
-    private function _add_registered_meta_boxes()
1846
-    {
1847
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1848
-        //we only add meta boxes if the page_route calls for it
1849
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1850
-            && is_array(
1851
-                    $this->_route_config['metaboxes']
1852
-            )
1853
-        ) {
1854
-            // this simply loops through the callbacks provided
1855
-            // and checks if there is a corresponding callback registered by the child
1856
-            // if there is then we go ahead and process the metabox loader.
1857
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1858
-                // first check for Closures
1859
-                if ($metabox_callback instanceof Closure) {
1860
-                    $result = $metabox_callback();
1861
-                } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1862
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1863
-                } else {
1864
-                    $result = call_user_func(array($this, &$metabox_callback));
1865
-                }
1866
-                if ($result === false) {
1867
-                    // user error msg
1868
-                    $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1869
-                    // developer error msg
1870
-                    $error_msg .= '||' . sprintf(
1871
-                                    __(
1872
-                                            'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1873
-                                            'event_espresso'
1874
-                                    ),
1875
-                                    $metabox_callback
1876
-                            );
1877
-                    throw new EE_Error($error_msg);
1878
-                }
1879
-            }
1880
-        }
1881
-    }
1882
-
1883
-
1884
-
1885
-    /**
1886
-     * _add_screen_columns
1887
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page.
1888
-     *
1889
-     * @access private
1890
-     * @return void
1891
-     */
1892
-    private function _add_screen_columns()
1893
-    {
1894
-        if (
1895
-                is_array($this->_route_config)
1896
-                && isset($this->_route_config['columns'])
1897
-                && is_array($this->_route_config['columns'])
1898
-                && count($this->_route_config['columns']) === 2
1899
-        ) {
1900
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1901
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1902
-            $screen_id = $this->_current_screen->id;
1903
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1904
-            $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1905
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1906
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
1907
-            $this->_template_args['screen'] = $this->_current_screen;
1908
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1909
-            //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1910
-            $this->_route_config['has_metaboxes'] = true;
1911
-        }
1912
-    }
1913
-
1914
-
1915
-
1916
-    /**********************************/
1917
-    /** GLOBALLY AVAILABLE METABOXES **/
1918
-    /**
1919
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply referencing the callback in the _page_config array property.  This way you can be very specific about what pages these get
1920
-     * loaded on.
1921
-     */
1922
-    private function _espresso_news_post_box()
1923
-    {
1924
-        $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1925
-        add_meta_box('espresso_news_post_box', $news_box_title, array(
1926
-                $this,
1927
-                'espresso_news_post_box',
1928
-        ), $this->_wp_page_slug, 'side');
1929
-    }
1930
-
1931
-
1932
-
1933
-    /**
1934
-     * Code for setting up espresso ratings request metabox.
1935
-     */
1936
-    protected function _espresso_ratings_request()
1937
-    {
1938
-        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1939
-            return '';
1940
-        }
1941
-        $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1942
-        add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1943
-                $this,
1944
-                'espresso_ratings_request',
1945
-        ), $this->_wp_page_slug, 'side');
1946
-    }
1947
-
1948
-
1949
-
1950
-    /**
1951
-     * Code for setting up espresso ratings request metabox content.
1952
-     */
1953
-    public function espresso_ratings_request()
1954
-    {
1955
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1956
-        EEH_Template::display_template($template_path, array());
1957
-    }
1958
-
1959
-
1960
-
1961
-    public static function cached_rss_display($rss_id, $url)
1962
-    {
1963
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1964
-        $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1965
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1966
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1967
-        $post = '</div>' . "\n";
1968
-        $cache_key = 'ee_rss_' . md5($rss_id);
1969
-        if (false != ($output = get_transient($cache_key))) {
1970
-            echo $pre . $output . $post;
1971
-            return true;
1972
-        }
1973
-        if ( ! $doing_ajax) {
1974
-            echo $pre . $loading . $post;
1975
-            return false;
1976
-        }
1977
-        ob_start();
1978
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1979
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1980
-        return true;
1981
-    }
1982
-
1983
-
1984
-
1985
-    public function espresso_news_post_box()
1986
-    {
1987
-        ?>
1818
+		return $entries_per_page_dropdown;
1819
+	}
1820
+
1821
+
1822
+
1823
+	/**
1824
+	 *        _set_search_attributes
1825
+	 *
1826
+	 * @access        protected
1827
+	 * @return        void
1828
+	 */
1829
+	public function _set_search_attributes()
1830
+	{
1831
+		$this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1832
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1833
+	}
1834
+
1835
+	/*** END LIST TABLE METHODS **/
1836
+	/*****************************/
1837
+	/**
1838
+	 *        _add_registered_metaboxes
1839
+	 *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1840
+	 *
1841
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1842
+	 * @access private
1843
+	 * @return void
1844
+	 */
1845
+	private function _add_registered_meta_boxes()
1846
+	{
1847
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1848
+		//we only add meta boxes if the page_route calls for it
1849
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1850
+			&& is_array(
1851
+					$this->_route_config['metaboxes']
1852
+			)
1853
+		) {
1854
+			// this simply loops through the callbacks provided
1855
+			// and checks if there is a corresponding callback registered by the child
1856
+			// if there is then we go ahead and process the metabox loader.
1857
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1858
+				// first check for Closures
1859
+				if ($metabox_callback instanceof Closure) {
1860
+					$result = $metabox_callback();
1861
+				} else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1862
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1863
+				} else {
1864
+					$result = call_user_func(array($this, &$metabox_callback));
1865
+				}
1866
+				if ($result === false) {
1867
+					// user error msg
1868
+					$error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1869
+					// developer error msg
1870
+					$error_msg .= '||' . sprintf(
1871
+									__(
1872
+											'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1873
+											'event_espresso'
1874
+									),
1875
+									$metabox_callback
1876
+							);
1877
+					throw new EE_Error($error_msg);
1878
+				}
1879
+			}
1880
+		}
1881
+	}
1882
+
1883
+
1884
+
1885
+	/**
1886
+	 * _add_screen_columns
1887
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page.
1888
+	 *
1889
+	 * @access private
1890
+	 * @return void
1891
+	 */
1892
+	private function _add_screen_columns()
1893
+	{
1894
+		if (
1895
+				is_array($this->_route_config)
1896
+				&& isset($this->_route_config['columns'])
1897
+				&& is_array($this->_route_config['columns'])
1898
+				&& count($this->_route_config['columns']) === 2
1899
+		) {
1900
+			add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1901
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1902
+			$screen_id = $this->_current_screen->id;
1903
+			$screen_columns = (int)get_user_option("screen_layout_$screen_id");
1904
+			$total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1905
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1906
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
1907
+			$this->_template_args['screen'] = $this->_current_screen;
1908
+			$this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1909
+			//finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1910
+			$this->_route_config['has_metaboxes'] = true;
1911
+		}
1912
+	}
1913
+
1914
+
1915
+
1916
+	/**********************************/
1917
+	/** GLOBALLY AVAILABLE METABOXES **/
1918
+	/**
1919
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply referencing the callback in the _page_config array property.  This way you can be very specific about what pages these get
1920
+	 * loaded on.
1921
+	 */
1922
+	private function _espresso_news_post_box()
1923
+	{
1924
+		$news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1925
+		add_meta_box('espresso_news_post_box', $news_box_title, array(
1926
+				$this,
1927
+				'espresso_news_post_box',
1928
+		), $this->_wp_page_slug, 'side');
1929
+	}
1930
+
1931
+
1932
+
1933
+	/**
1934
+	 * Code for setting up espresso ratings request metabox.
1935
+	 */
1936
+	protected function _espresso_ratings_request()
1937
+	{
1938
+		if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1939
+			return '';
1940
+		}
1941
+		$ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1942
+		add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1943
+				$this,
1944
+				'espresso_ratings_request',
1945
+		), $this->_wp_page_slug, 'side');
1946
+	}
1947
+
1948
+
1949
+
1950
+	/**
1951
+	 * Code for setting up espresso ratings request metabox content.
1952
+	 */
1953
+	public function espresso_ratings_request()
1954
+	{
1955
+		$template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1956
+		EEH_Template::display_template($template_path, array());
1957
+	}
1958
+
1959
+
1960
+
1961
+	public static function cached_rss_display($rss_id, $url)
1962
+	{
1963
+		$loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1964
+		$doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1965
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
1966
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1967
+		$post = '</div>' . "\n";
1968
+		$cache_key = 'ee_rss_' . md5($rss_id);
1969
+		if (false != ($output = get_transient($cache_key))) {
1970
+			echo $pre . $output . $post;
1971
+			return true;
1972
+		}
1973
+		if ( ! $doing_ajax) {
1974
+			echo $pre . $loading . $post;
1975
+			return false;
1976
+		}
1977
+		ob_start();
1978
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1979
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1980
+		return true;
1981
+	}
1982
+
1983
+
1984
+
1985
+	public function espresso_news_post_box()
1986
+	{
1987
+		?>
1988 1988
         <div class="padding">
1989 1989
             <div id="espresso_news_post_box_content" class="infolinks">
1990 1990
                 <?php
1991
-                // Get RSS Feed(s)
1992
-                $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1993
-                $url = urlencode($feed_url);
1994
-                self::cached_rss_display('espresso_news_post_box_content', $url);
1995
-                ?>
1991
+				// Get RSS Feed(s)
1992
+				$feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1993
+				$url = urlencode($feed_url);
1994
+				self::cached_rss_display('espresso_news_post_box_content', $url);
1995
+				?>
1996 1996
             </div>
1997 1997
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
1998 1998
         </div>
1999 1999
         <?php
2000
-    }
2001
-
2002
-
2003
-
2004
-    private function _espresso_links_post_box()
2005
-    {
2006
-        //Hiding until we actually have content to put in here...
2007
-        //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2008
-    }
2009
-
2010
-
2011
-
2012
-    public function espresso_links_post_box()
2013
-    {
2014
-        //Hiding until we actually have content to put in here...
2015
-        //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2016
-        //EEH_Template::display_template( $templatepath );
2017
-    }
2018
-
2019
-
2020
-
2021
-    protected function _espresso_sponsors_post_box()
2022
-    {
2023
-        $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2024
-        if ($show_sponsors) {
2025
-            add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2026
-        }
2027
-    }
2028
-
2029
-
2030
-
2031
-    public function espresso_sponsors_post_box()
2032
-    {
2033
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2034
-        EEH_Template::display_template($templatepath);
2035
-    }
2036
-
2037
-
2038
-
2039
-    private function _publish_post_box()
2040
-    {
2041
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2042
-        //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2043
-        if ( ! empty($this->_labels['publishbox'])) {
2044
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2045
-        } else {
2046
-            $box_label = __('Publish', 'event_espresso');
2047
-        }
2048
-        $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2049
-        add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2050
-    }
2051
-
2052
-
2053
-
2054
-    public function editor_overview()
2055
-    {
2056
-        //if we have extra content set let's add it in if not make sure its empty
2057
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2058
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2059
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2060
-    }
2061
-
2062
-
2063
-    /** end of globally available metaboxes section **/
2064
-    /*************************************************/
2065
-    /**
2066
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2067
-     * protected method.
2068
-     *
2069
-     * @see   $this->_set_publish_post_box_vars for param details
2070
-     * @since 4.6.0
2071
-     */
2072
-    public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2073
-    {
2074
-        $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2075
-    }
2076
-
2077
-
2078
-
2079
-    /**
2080
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2081
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2082
-     * save, and save and close buttons to work properly, then you will want to include a
2083
-     * values for the name and id arguments.
2084
-     *
2085
-     * @todo  Add in validation for name/id arguments.
2086
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2087
-     * @param    int     $id                      id attached to the item published
2088
-     * @param    string  $delete                  page route callback for the delete action
2089
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2090
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2091
-     * @throws \EE_Error
2092
-     */
2093
-    protected function _set_publish_post_box_vars(
2094
-            $name = '',
2095
-            $id = 0,
2096
-            $delete = '',
2097
-            $save_close_redirect_URL = '',
2098
-            $both_btns = true
2099
-    ) {
2100
-        // if Save & Close, use a custom redirect URL or default to the main page?
2101
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2102
-        // create the Save & Close and Save buttons
2103
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2104
-        //if we have extra content set let's add it in if not make sure its empty
2105
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2106
-        if ($delete && ! empty($id)) {
2107
-            //make sure we have a default if just true is sent.
2108
-            $delete = ! empty($delete) ? $delete : 'delete';
2109
-            $delete_link_args = array($name => $id);
2110
-            $delete = $this->get_action_link_or_button(
2111
-                    $delete,
2112
-                    $delete,
2113
-                    $delete_link_args,
2114
-                    'submitdelete deletion',
2115
-                    '',
2116
-                    false
2117
-            );
2118
-        }
2119
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2120
-        if ( ! empty($name) && ! empty($id)) {
2121
-            $hidden_field_arr[$name] = array(
2122
-                    'type'  => 'hidden',
2123
-                    'value' => $id,
2124
-            );
2125
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2126
-        } else {
2127
-            $hf = '';
2128
-        }
2129
-        // add hidden field
2130
-        $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2131
-    }
2132
-
2133
-
2134
-
2135
-    /**
2136
-     *        displays an error message to ppl who have javascript disabled
2137
-     *
2138
-     * @access        private
2139
-     * @return        string
2140
-     */
2141
-    private function _display_no_javascript_warning()
2142
-    {
2143
-        ?>
2000
+	}
2001
+
2002
+
2003
+
2004
+	private function _espresso_links_post_box()
2005
+	{
2006
+		//Hiding until we actually have content to put in here...
2007
+		//add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2008
+	}
2009
+
2010
+
2011
+
2012
+	public function espresso_links_post_box()
2013
+	{
2014
+		//Hiding until we actually have content to put in here...
2015
+		//$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2016
+		//EEH_Template::display_template( $templatepath );
2017
+	}
2018
+
2019
+
2020
+
2021
+	protected function _espresso_sponsors_post_box()
2022
+	{
2023
+		$show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2024
+		if ($show_sponsors) {
2025
+			add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2026
+		}
2027
+	}
2028
+
2029
+
2030
+
2031
+	public function espresso_sponsors_post_box()
2032
+	{
2033
+		$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2034
+		EEH_Template::display_template($templatepath);
2035
+	}
2036
+
2037
+
2038
+
2039
+	private function _publish_post_box()
2040
+	{
2041
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2042
+		//if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2043
+		if ( ! empty($this->_labels['publishbox'])) {
2044
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2045
+		} else {
2046
+			$box_label = __('Publish', 'event_espresso');
2047
+		}
2048
+		$box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2049
+		add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2050
+	}
2051
+
2052
+
2053
+
2054
+	public function editor_overview()
2055
+	{
2056
+		//if we have extra content set let's add it in if not make sure its empty
2057
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2058
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2059
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2060
+	}
2061
+
2062
+
2063
+	/** end of globally available metaboxes section **/
2064
+	/*************************************************/
2065
+	/**
2066
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2067
+	 * protected method.
2068
+	 *
2069
+	 * @see   $this->_set_publish_post_box_vars for param details
2070
+	 * @since 4.6.0
2071
+	 */
2072
+	public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2073
+	{
2074
+		$this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2075
+	}
2076
+
2077
+
2078
+
2079
+	/**
2080
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2081
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2082
+	 * save, and save and close buttons to work properly, then you will want to include a
2083
+	 * values for the name and id arguments.
2084
+	 *
2085
+	 * @todo  Add in validation for name/id arguments.
2086
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2087
+	 * @param    int     $id                      id attached to the item published
2088
+	 * @param    string  $delete                  page route callback for the delete action
2089
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2090
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2091
+	 * @throws \EE_Error
2092
+	 */
2093
+	protected function _set_publish_post_box_vars(
2094
+			$name = '',
2095
+			$id = 0,
2096
+			$delete = '',
2097
+			$save_close_redirect_URL = '',
2098
+			$both_btns = true
2099
+	) {
2100
+		// if Save & Close, use a custom redirect URL or default to the main page?
2101
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2102
+		// create the Save & Close and Save buttons
2103
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2104
+		//if we have extra content set let's add it in if not make sure its empty
2105
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2106
+		if ($delete && ! empty($id)) {
2107
+			//make sure we have a default if just true is sent.
2108
+			$delete = ! empty($delete) ? $delete : 'delete';
2109
+			$delete_link_args = array($name => $id);
2110
+			$delete = $this->get_action_link_or_button(
2111
+					$delete,
2112
+					$delete,
2113
+					$delete_link_args,
2114
+					'submitdelete deletion',
2115
+					'',
2116
+					false
2117
+			);
2118
+		}
2119
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2120
+		if ( ! empty($name) && ! empty($id)) {
2121
+			$hidden_field_arr[$name] = array(
2122
+					'type'  => 'hidden',
2123
+					'value' => $id,
2124
+			);
2125
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2126
+		} else {
2127
+			$hf = '';
2128
+		}
2129
+		// add hidden field
2130
+		$this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2131
+	}
2132
+
2133
+
2134
+
2135
+	/**
2136
+	 *        displays an error message to ppl who have javascript disabled
2137
+	 *
2138
+	 * @access        private
2139
+	 * @return        string
2140
+	 */
2141
+	private function _display_no_javascript_warning()
2142
+	{
2143
+		?>
2144 2144
         <noscript>
2145 2145
             <div id="no-js-message" class="error">
2146 2146
                 <p style="font-size:1.3em;">
@@ -2150,1236 +2150,1236 @@  discard block
 block discarded – undo
2150 2150
             </div>
2151 2151
         </noscript>
2152 2152
         <?php
2153
-    }
2153
+	}
2154 2154
 
2155 2155
 
2156 2156
 
2157
-    /**
2158
-     *        displays espresso success and/or error notices
2159
-     *
2160
-     * @access        private
2161
-     * @return        string
2162
-     */
2163
-    private function _display_espresso_notices()
2164
-    {
2165
-        $notices = $this->_get_transient(true);
2166
-        echo stripslashes($notices);
2167
-    }
2157
+	/**
2158
+	 *        displays espresso success and/or error notices
2159
+	 *
2160
+	 * @access        private
2161
+	 * @return        string
2162
+	 */
2163
+	private function _display_espresso_notices()
2164
+	{
2165
+		$notices = $this->_get_transient(true);
2166
+		echo stripslashes($notices);
2167
+	}
2168 2168
 
2169 2169
 
2170 2170
 
2171
-    /**
2172
-     *        spinny things pacify the masses
2173
-     *
2174
-     * @access private
2175
-     * @return string
2176
-     */
2177
-    protected function _add_admin_page_ajax_loading_img()
2178
-    {
2179
-        ?>
2171
+	/**
2172
+	 *        spinny things pacify the masses
2173
+	 *
2174
+	 * @access private
2175
+	 * @return string
2176
+	 */
2177
+	protected function _add_admin_page_ajax_loading_img()
2178
+	{
2179
+		?>
2180 2180
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2181 2181
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php esc_html_e('loading...', 'event_espresso'); ?></span>
2182 2182
         </div>
2183 2183
         <?php
2184
-    }
2184
+	}
2185 2185
 
2186 2186
 
2187 2187
 
2188
-    /**
2189
-     *        add admin page overlay for modal boxes
2190
-     *
2191
-     * @access private
2192
-     * @return string
2193
-     */
2194
-    protected function _add_admin_page_overlay()
2195
-    {
2196
-        ?>
2188
+	/**
2189
+	 *        add admin page overlay for modal boxes
2190
+	 *
2191
+	 * @access private
2192
+	 * @return string
2193
+	 */
2194
+	protected function _add_admin_page_overlay()
2195
+	{
2196
+		?>
2197 2197
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2198 2198
         <?php
2199
-    }
2200
-
2201
-
2202
-
2203
-    /**
2204
-     * facade for add_meta_box
2205
-     *
2206
-     * @param string  $action        where the metabox get's displayed
2207
-     * @param string  $title         Title of Metabox (output in metabox header)
2208
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here.
2209
-     * @param array   $callback_args an array of args supplied for the metabox
2210
-     * @param string  $column        what metabox column
2211
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2212
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box.
2213
-     */
2214
-    public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2215
-    {
2216
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2217
-        //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2218
-        if (empty($callback_args) && $create_func) {
2219
-            $callback_args = array(
2220
-                    'template_path' => $this->_template_path,
2221
-                    'template_args' => $this->_template_args,
2222
-            );
2223
-        }
2224
-        //if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2225
-        $call_back_func = $create_func ? create_function('$post, $metabox',
2226
-                'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2227
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2228
-    }
2229
-
2230
-
2231
-
2232
-    /**
2233
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2234
-     *
2235
-     * @return [type] [description]
2236
-     */
2237
-    public function display_admin_page_with_metabox_columns()
2238
-    {
2239
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2240
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2241
-        //the final wrapper
2242
-        $this->admin_page_wrapper();
2243
-    }
2244
-
2245
-
2246
-
2247
-    /**
2248
-     *        generates  HTML wrapper for an admin details page
2249
-     *
2250
-     * @access public
2251
-     * @return void
2252
-     */
2253
-    public function display_admin_page_with_sidebar()
2254
-    {
2255
-        $this->_display_admin_page(true);
2256
-    }
2257
-
2258
-
2259
-
2260
-    /**
2261
-     *        generates  HTML wrapper for an admin details page (except no sidebar)
2262
-     *
2263
-     * @access public
2264
-     * @return void
2265
-     */
2266
-    public function display_admin_page_with_no_sidebar()
2267
-    {
2268
-        $this->_display_admin_page();
2269
-    }
2270
-
2271
-
2272
-
2273
-    /**
2274
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2275
-     *
2276
-     * @access public
2277
-     * @return void
2278
-     */
2279
-    public function display_about_admin_page()
2280
-    {
2281
-        $this->_display_admin_page(false, true);
2282
-    }
2283
-
2284
-
2285
-
2286
-    /**
2287
-     * display_admin_page
2288
-     * contains the code for actually displaying an admin page
2289
-     *
2290
-     * @access private
2291
-     * @param  boolean $sidebar true with sidebar, false without
2292
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2293
-     * @return void
2294
-     */
2295
-    private function _display_admin_page($sidebar = false, $about = false)
2296
-    {
2297
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2298
-        //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2299
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2300
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2301
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2302
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2303
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2304
-                ? 'poststuff'
2305
-                : 'espresso-default-admin';
2306
-        $template_path = $sidebar
2307
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2308
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2309
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2310
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2311
-        }
2312
-        $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2313
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2314
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2315
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2316
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2317
-        // the final template wrapper
2318
-        $this->admin_page_wrapper($about);
2319
-    }
2320
-
2321
-
2322
-
2323
-    /**
2324
-     * This is used to display caf preview pages.
2325
-     *
2326
-     * @since 4.3.2
2327
-     * @param string $utm_campaign_source what is the key used for google analytics link
2328
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2329
-     * @return void
2330
-     * @throws \EE_Error
2331
-     */
2332
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2333
-    {
2334
-        //let's generate a default preview action button if there isn't one already present.
2335
-        $this->_labels['buttons']['buy_now'] = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso');
2336
-        $buy_now_url = add_query_arg(
2337
-                array(
2338
-                        'ee_ver'       => 'ee4',
2339
-                        'utm_source'   => 'ee4_plugin_admin',
2340
-                        'utm_medium'   => 'link',
2341
-                        'utm_campaign' => $utm_campaign_source,
2342
-                        'utm_content'  => 'buy_now_button',
2343
-                ),
2344
-                'https://eventespresso.com/pricing/'
2345
-        );
2346
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2347
-                ? $this->get_action_link_or_button(
2348
-                        '',
2349
-                        'buy_now',
2350
-                        array(),
2351
-                        'button-primary button-large',
2352
-                        $buy_now_url,
2353
-                        true
2354
-                )
2355
-                : $this->_template_args['preview_action_button'];
2356
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2357
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2358
-                $template_path,
2359
-                $this->_template_args,
2360
-                true
2361
-        );
2362
-        $this->_display_admin_page($display_sidebar);
2363
-    }
2364
-
2365
-
2366
-
2367
-    /**
2368
-     * display_admin_list_table_page_with_sidebar
2369
-     * generates HTML wrapper for an admin_page with list_table
2370
-     *
2371
-     * @access public
2372
-     * @return void
2373
-     */
2374
-    public function display_admin_list_table_page_with_sidebar()
2375
-    {
2376
-        $this->_display_admin_list_table_page(true);
2377
-    }
2378
-
2379
-
2380
-
2381
-    /**
2382
-     * display_admin_list_table_page_with_no_sidebar
2383
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2384
-     *
2385
-     * @access public
2386
-     * @return void
2387
-     */
2388
-    public function display_admin_list_table_page_with_no_sidebar()
2389
-    {
2390
-        $this->_display_admin_list_table_page();
2391
-    }
2392
-
2393
-
2394
-
2395
-    /**
2396
-     * generates html wrapper for an admin_list_table page
2397
-     *
2398
-     * @access private
2399
-     * @param boolean $sidebar whether to display with sidebar or not.
2400
-     * @return void
2401
-     */
2402
-    private function _display_admin_list_table_page($sidebar = false)
2403
-    {
2404
-        //setup search attributes
2405
-        $this->_set_search_attributes();
2406
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2407
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2408
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
2409
-                ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2410
-                : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2411
-        $this->_template_args['list_table'] = $this->_list_table_object;
2412
-        $this->_template_args['current_route'] = $this->_req_action;
2413
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2414
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2415
-        if ( ! empty($ajax_sorting_callback)) {
2416
-            $sortable_list_table_form_fields = wp_nonce_field(
2417
-                    $ajax_sorting_callback . '_nonce',
2418
-                    $ajax_sorting_callback . '_nonce',
2419
-                    false,
2420
-                    false
2421
-            );
2422
-            //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2423
-            //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2424
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2425
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2426
-        } else {
2427
-            $sortable_list_table_form_fields = '';
2428
-        }
2429
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2430
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2431
-        $nonce_ref = $this->_req_action . '_nonce';
2432
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2433
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2434
-        //display message about search results?
2435
-        $this->_template_args['before_list_table'] .= apply_filters(
2436
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2437
-                ! empty($this->_req_data['s'])
2438
-                        ? '<p class="ee-search-results">'
2439
-                            . sprintf(
2440
-                                esc_html__(
2441
-                                        'Displaying search results for the search string: %1$s',
2442
-                                        'event_espresso'
2443
-                                ),
2444
-                                '<strong><em>' . trim( $this->_req_data['s'], '%' ) . '</em></strong>'
2445
-                            )
2446
-                            . '</p>'
2447
-                        : '',
2448
-                $this->page_slug,
2449
-                $this->_req_data,
2450
-                $this->_req_action
2451
-        );
2452
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2453
-                $template_path,
2454
-                $this->_template_args,
2455
-                true
2456
-        );
2457
-        // the final template wrapper
2458
-        if ($sidebar) {
2459
-            $this->display_admin_page_with_sidebar();
2460
-        } else {
2461
-            $this->display_admin_page_with_no_sidebar();
2462
-        }
2463
-    }
2464
-
2465
-
2466
-
2467
-    /**
2468
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend.
2469
-     * $items are expected in an array in the following format:
2470
-     * $legend_items = array(
2471
-     *        'item_id' => array(
2472
-     *            'icon' => 'http://url_to_icon_being_described.png',
2473
-     *            'desc' => __('localized description of item');
2474
-     *        )
2475
-     * );
2476
-     *
2477
-     * @param  array $items see above for format of array
2478
-     * @return string        html string of legend
2479
-     */
2480
-    protected function _display_legend($items)
2481
-    {
2482
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2483
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2484
-        return EEH_Template::display_template($legend_template, $this->_template_args, true);
2485
-    }
2486
-
2487
-
2488
-
2489
-    /**
2490
-     * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2491
-     *
2492
-     * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2493
-     *                             The returned json object is created from an array in the following format:
2494
-     *                             array(
2495
-     *                             'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2496
-     *                             'success' => FALSE, //(default FALSE) - contains any special success message.
2497
-     *                             'notices' => '', // - contains any EE_Error formatted notices
2498
-     *                             'content' => 'string can be html', //this is a string of formatted content (can be html)
2499
-     *                             'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any
2500
-     *                             specific template args that might be included in here)
2501
-     *                             )
2502
-     *                             The json object is populated by whatever is set in the $_template_args property.
2503
-     * @return void
2504
-     */
2505
-    protected function _return_json($sticky_notices = false)
2506
-    {
2507
-        //make sure any EE_Error notices have been handled.
2508
-        $this->_process_notices(array(), true, $sticky_notices);
2509
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2510
-        unset($this->_template_args['data']);
2511
-        $json = array(
2512
-                'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2513
-                'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2514
-                'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2515
-                'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2516
-                'notices'   => EE_Error::get_notices(),
2517
-                'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2518
-                'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2519
-                'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2520
-        );
2521
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2522
-        if (null === error_get_last() || ! headers_sent()) {
2523
-            header('Content-Type: application/json; charset=UTF-8');
2524
-        }
2525
-        echo wp_json_encode($json);
2526
-
2527
-        exit();
2528
-    }
2529
-
2530
-
2531
-
2532
-    /**
2533
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2534
-     *
2535
-     * @return void
2536
-     * @throws EE_Error
2537
-     */
2538
-    public function return_json()
2539
-    {
2540
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2541
-            $this->_return_json();
2542
-        } else {
2543
-            throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2544
-        }
2545
-    }
2546
-
2547
-
2548
-
2549
-    /**
2550
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
2551
-     *
2552
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2553
-     * @access   public
2554
-     */
2555
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
2556
-    {
2557
-        $this->_hook_obj = $hook_obj;
2558
-    }
2559
-
2560
-
2561
-
2562
-    /**
2563
-     *        generates  HTML wrapper with Tabbed nav for an admin page
2564
-     *
2565
-     * @access public
2566
-     * @param  boolean $about whether to use the special about page wrapper or default.
2567
-     * @return void
2568
-     */
2569
-    public function admin_page_wrapper($about = false)
2570
-    {
2571
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2572
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
2573
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2574
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2575
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2576
-                isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2577
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2578
-                isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2579
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2580
-        // load settings page wrapper template
2581
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2582
-        //about page?
2583
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2584
-        if (defined('DOING_AJAX')) {
2585
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2586
-            $this->_return_json();
2587
-        } else {
2588
-            EEH_Template::display_template($template_path, $this->_template_args);
2589
-        }
2590
-    }
2591
-
2592
-
2593
-
2594
-    /**
2595
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2596
-     *
2597
-     * @return string html
2598
-     */
2599
-    protected function _get_main_nav_tabs()
2600
-    {
2601
-        //let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
2602
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2603
-    }
2604
-
2605
-
2606
-
2607
-    /**
2608
-     *        sort nav tabs
2609
-     *
2610
-     * @access public
2611
-     * @param $a
2612
-     * @param $b
2613
-     * @return int
2614
-     */
2615
-    private function _sort_nav_tabs($a, $b)
2616
-    {
2617
-        if ($a['order'] == $b['order']) {
2618
-            return 0;
2619
-        }
2620
-        return ($a['order'] < $b['order']) ? -1 : 1;
2621
-    }
2622
-
2623
-
2624
-
2625
-    /**
2626
-     *    generates HTML for the forms used on admin pages
2627
-     *
2628
-     * @access protected
2629
-     * @param    array $input_vars - array of input field details
2630
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2631
-     * @return string
2632
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2633
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2634
-     */
2635
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2636
-    {
2637
-        $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2638
-        return $content;
2639
-    }
2640
-
2641
-
2642
-
2643
-    /**
2644
-     * generates the "Save" and "Save & Close" buttons for edit forms
2645
-     *
2646
-     * @access protected
2647
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2648
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2649
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button).  We can also use this to just dump default actions by submitting some other value.
2650
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling).
2651
-     */
2652
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2653
-    {
2654
-        //make sure $text and $actions are in an array
2655
-        $text = (array)$text;
2656
-        $actions = (array)$actions;
2657
-        $referrer_url = empty($referrer) ? '' : $referrer;
2658
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2659
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2660
-        $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2661
-        $default_names = array('save', 'save_and_close');
2662
-        //add in a hidden index for the current page (so save and close redirects properly)
2663
-        $this->_template_args['save_buttons'] = $referrer_url;
2664
-        foreach ($button_text as $key => $button) {
2665
-            $ref = $default_names[$key];
2666
-            $id = $this->_current_view . '_' . $ref;
2667
-            $name = ! empty($actions) ? $actions[$key] : $ref;
2668
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2669
-            if ( ! $both) {
2670
-                break;
2671
-            }
2672
-        }
2673
-    }
2674
-
2675
-
2676
-
2677
-    /**
2678
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2679
-     *
2680
-     * @see   $this->_set_add_edit_form_tags() for details on params
2681
-     * @since 4.6.0
2682
-     * @param string $route
2683
-     * @param array  $additional_hidden_fields
2684
-     */
2685
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2686
-    {
2687
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2688
-    }
2689
-
2690
-
2691
-
2692
-    /**
2693
-     * set form open and close tags on add/edit pages.
2694
-     *
2695
-     * @access protected
2696
-     * @param string $route                    the route you want the form to direct to
2697
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2698
-     * @return void
2699
-     */
2700
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2701
-    {
2702
-        if (empty($route)) {
2703
-            $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2704
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2705
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2706
-        }
2707
-        // open form
2708
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2709
-        // add nonce
2710
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2711
-        //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2712
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2713
-        // add REQUIRED form action
2714
-        $hidden_fields = array(
2715
-                'action' => array('type' => 'hidden', 'value' => $route),
2716
-        );
2717
-        // merge arrays
2718
-        $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2719
-        // generate form fields
2720
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2721
-        // add fields to form
2722
-        foreach ((array)$form_fields as $field_name => $form_field) {
2723
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2724
-        }
2725
-        // close form
2726
-        $this->_template_args['after_admin_page_content'] = '</form>';
2727
-    }
2728
-
2729
-
2730
-
2731
-    /**
2732
-     * Public Wrapper for _redirect_after_action() method since its
2733
-     * discovered it would be useful for external code to have access.
2734
-     *
2735
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
2736
-     * @since 4.5.0
2737
-     */
2738
-    public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2739
-    {
2740
-        $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2741
-    }
2742
-
2743
-
2744
-
2745
-    /**
2746
-     *    _redirect_after_action
2747
-     *
2748
-     * @param int    $success            - whether success was for two or more records, or just one, or none
2749
-     * @param string $what               - what the action was performed on
2750
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
2751
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2752
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2753
-     * @access protected
2754
-     * @return void
2755
-     */
2756
-    protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2757
-    {
2758
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2759
-        //class name for actions/filters.
2760
-        $classname = get_class($this);
2761
-        //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
2762
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2763
-        $notices = EE_Error::get_notices(false);
2764
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
2765
-        if ( ! $override_overwrite || ! empty($notices['errors'])) {
2766
-            EE_Error::overwrite_success();
2767
-        }
2768
-        if ( ! empty($what) && ! empty($action_desc)) {
2769
-            // how many records affected ? more than one record ? or just one ?
2770
-            if ($success > 1 && empty($notices['errors'])) {
2771
-                // set plural msg
2772
-                EE_Error::add_success(
2773
-                        sprintf(
2774
-                                __('The "%s" have been successfully %s.', 'event_espresso'),
2775
-                                $what,
2776
-                                $action_desc
2777
-                        ),
2778
-                        __FILE__, __FUNCTION__, __LINE__
2779
-                );
2780
-            } else if ($success == 1 && empty($notices['errors'])) {
2781
-                // set singular msg
2782
-                EE_Error::add_success(
2783
-                        sprintf(
2784
-                                __('The "%s" has been successfully %s.', 'event_espresso'),
2785
-                                $what,
2786
-                                $action_desc
2787
-                        ),
2788
-                        __FILE__, __FUNCTION__, __LINE__
2789
-                );
2790
-            }
2791
-        }
2792
-        // check that $query_args isn't something crazy
2793
-        if ( ! is_array($query_args)) {
2794
-            $query_args = array();
2795
-        }
2796
-        /**
2797
-         * Allow injecting actions before the query_args are modified for possible different
2798
-         * redirections on save and close actions
2799
-         *
2800
-         * @since 4.2.0
2801
-         * @param array $query_args       The original query_args array coming into the
2802
-         *                                method.
2803
-         */
2804
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2805
-        //calculate where we're going (if we have a "save and close" button pushed)
2806
-        if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2807
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2808
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2809
-            // regenerate query args array from referrer URL
2810
-            parse_str($parsed_url['query'], $query_args);
2811
-            // correct page and action will be in the query args now
2812
-            $redirect_url = admin_url('admin.php');
2813
-        }
2814
-        //merge any default query_args set in _default_route_query_args property
2815
-        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2816
-            $args_to_merge = array();
2817
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
2818
-                //is there a wp_referer array in our _default_route_query_args property?
2819
-                if ($query_param == 'wp_referer') {
2820
-                    $query_value = (array)$query_value;
2821
-                    foreach ($query_value as $reference => $value) {
2822
-                        if (strpos($reference, 'nonce') !== false) {
2823
-                            continue;
2824
-                        }
2825
-                        //finally we will override any arguments in the referer with
2826
-                        //what might be set on the _default_route_query_args array.
2827
-                        if (isset($this->_default_route_query_args[$reference])) {
2828
-                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2829
-                        } else {
2830
-                            $args_to_merge[$reference] = urlencode($value);
2831
-                        }
2832
-                    }
2833
-                    continue;
2834
-                }
2835
-                $args_to_merge[$query_param] = $query_value;
2836
-            }
2837
-            //now let's merge these arguments but override with what was specifically sent in to the
2838
-            //redirect.
2839
-            $query_args = array_merge($args_to_merge, $query_args);
2840
-        }
2841
-        $this->_process_notices($query_args);
2842
-        // generate redirect url
2843
-        // if redirecting to anything other than the main page, add a nonce
2844
-        if (isset($query_args['action'])) {
2845
-            // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2846
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2847
-        }
2848
-        //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2849
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2850
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2851
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2852
-        if (defined('DOING_AJAX')) {
2853
-            $default_data = array(
2854
-                    'close'        => true,
2855
-                    'redirect_url' => $redirect_url,
2856
-                    'where'        => 'main',
2857
-                    'what'         => 'append',
2858
-            );
2859
-            $this->_template_args['success'] = $success;
2860
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2861
-            $this->_return_json();
2862
-        }
2863
-        wp_safe_redirect($redirect_url);
2864
-        exit();
2865
-    }
2866
-
2867
-
2868
-
2869
-    /**
2870
-     * process any notices before redirecting (or returning ajax request)
2871
-     * This method sets the $this->_template_args['notices'] attribute;
2872
-     *
2873
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
2874
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2875
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
2876
-     * @return void
2877
-     */
2878
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2879
-    {
2880
-        //first let's set individual error properties if doing_ajax and the properties aren't already set.
2881
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2882
-            $notices = EE_Error::get_notices(false);
2883
-            if (empty($this->_template_args['success'])) {
2884
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2885
-            }
2886
-            if (empty($this->_template_args['errors'])) {
2887
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2888
-            }
2889
-            if (empty($this->_template_args['attention'])) {
2890
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2891
-            }
2892
-        }
2893
-        $this->_template_args['notices'] = EE_Error::get_notices();
2894
-        //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2895
-        if ( ! defined('DOING_AJAX') || $sticky_notices) {
2896
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
2897
-            $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2898
-        }
2899
-    }
2900
-
2901
-
2902
-
2903
-    /**
2904
-     * get_action_link_or_button
2905
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
2906
-     *
2907
-     * @param string $action        use this to indicate which action the url is generated with.
2908
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2909
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2910
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2911
-     * @param string $base_url      If this is not provided
2912
-     *                              the _admin_base_url will be used as the default for the button base_url.
2913
-     *                              Otherwise this value will be used.
2914
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2915
-     * @return string
2916
-     * @throws \EE_Error
2917
-     */
2918
-    public function get_action_link_or_button(
2919
-            $action,
2920
-            $type = 'add',
2921
-            $extra_request = array(),
2922
-            $class = 'button-primary',
2923
-            $base_url = '',
2924
-            $exclude_nonce = false
2925
-    ) {
2926
-        //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2927
-        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2928
-            throw new EE_Error(
2929
-                    sprintf(
2930
-                            __(
2931
-                                    'There is no page route for given action for the button.  This action was given: %s',
2932
-                                    'event_espresso'
2933
-                            ),
2934
-                            $action
2935
-                    )
2936
-            );
2937
-        }
2938
-        if ( ! isset($this->_labels['buttons'][$type])) {
2939
-            throw new EE_Error(
2940
-                    sprintf(
2941
-                            __(
2942
-                                    'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2943
-                                    'event_espresso'
2944
-                            ),
2945
-                            $type
2946
-                    )
2947
-            );
2948
-        }
2949
-        //finally check user access for this button.
2950
-        $has_access = $this->check_user_access($action, true);
2951
-        if ( ! $has_access) {
2952
-            return '';
2953
-        }
2954
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2955
-        $query_args = array(
2956
-                'action' => $action,
2957
-        );
2958
-        //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2959
-        if ( ! empty($extra_request)) {
2960
-            $query_args = array_merge($extra_request, $query_args);
2961
-        }
2962
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2963
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2964
-    }
2965
-
2966
-
2967
-
2968
-    /**
2969
-     * _per_page_screen_option
2970
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
2971
-     *
2972
-     * @return void
2973
-     */
2974
-    protected function _per_page_screen_option()
2975
-    {
2976
-        $option = 'per_page';
2977
-        $args = array(
2978
-                'label'   => $this->_admin_page_title,
2979
-                'default' => 10,
2980
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2981
-        );
2982
-        //ONLY add the screen option if the user has access to it.
2983
-        if ($this->check_user_access($this->_current_view, true)) {
2984
-            add_screen_option($option, $args);
2985
-        }
2986
-    }
2987
-
2988
-
2989
-
2990
-    /**
2991
-     * set_per_page_screen_option
2992
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
2993
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
2994
-     *
2995
-     * @access private
2996
-     * @return void
2997
-     */
2998
-    private function _set_per_page_screen_options()
2999
-    {
3000
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3001
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3002
-            if ( ! $user = wp_get_current_user()) {
3003
-                return;
3004
-            }
3005
-            $option = $_POST['wp_screen_options']['option'];
3006
-            $value = $_POST['wp_screen_options']['value'];
3007
-            if ($option != sanitize_key($option)) {
3008
-                return;
3009
-            }
3010
-            $map_option = $option;
3011
-            $option = str_replace('-', '_', $option);
3012
-            switch ($map_option) {
3013
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3014
-                    $value = (int)$value;
3015
-                    if ($value < 1 || $value > 999) {
3016
-                        return;
3017
-                    }
3018
-                    break;
3019
-                default:
3020
-                    $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3021
-                    if (false === $value) {
3022
-                        return;
3023
-                    }
3024
-                    break;
3025
-            }
3026
-            update_user_meta($user->ID, $option, $value);
3027
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3028
-            exit;
3029
-        }
3030
-    }
3031
-
3032
-
3033
-
3034
-    /**
3035
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3036
-     *
3037
-     * @param array $data array that will be assigned to template args.
3038
-     */
3039
-    public function set_template_args($data)
3040
-    {
3041
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3042
-    }
3043
-
3044
-
3045
-
3046
-    /**
3047
-     * This makes available the WP transient system for temporarily moving data between routes
3048
-     *
3049
-     * @access protected
3050
-     * @param string $route             the route that should receive the transient
3051
-     * @param array  $data              the data that gets sent
3052
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3053
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used when we are adding a transient before page_routes have been defined.
3054
-     * @return void
3055
-     */
3056
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3057
-    {
3058
-        $user_id = get_current_user_id();
3059
-        if ( ! $skip_route_verify) {
3060
-            $this->_verify_route($route);
3061
-        }
3062
-        //now let's set the string for what kind of transient we're setting
3063
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3064
-        $data = $notices ? array('notices' => $data) : $data;
3065
-        //is there already a transient for this route?  If there is then let's ADD to that transient
3066
-        $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3067
-        if ($existing) {
3068
-            $data = array_merge((array)$data, (array)$existing);
3069
-        }
3070
-        if (is_multisite() && is_network_admin()) {
3071
-            set_site_transient($transient, $data, 8);
3072
-        } else {
3073
-            set_transient($transient, $data, 8);
3074
-        }
3075
-    }
3076
-
3077
-
3078
-
3079
-    /**
3080
-     * this retrieves the temporary transient that has been set for moving data between routes.
3081
-     *
3082
-     * @param bool $notices true we get notices transient. False we just return normal route transient
3083
-     * @return mixed data
3084
-     */
3085
-    protected function _get_transient($notices = false, $route = false)
3086
-    {
3087
-        $user_id = get_current_user_id();
3088
-        $route = ! $route ? $this->_req_action : $route;
3089
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3090
-        $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3091
-        //delete transient after retrieval (just in case it hasn't expired);
3092
-        if (is_multisite() && is_network_admin()) {
3093
-            delete_site_transient($transient);
3094
-        } else {
3095
-            delete_transient($transient);
3096
-        }
3097
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3098
-    }
3099
-
3100
-
3101
-
3102
-    /**
3103
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later.
3104
-     * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.)
3105
-     *
3106
-     * @return void
3107
-     */
3108
-    protected function _transient_garbage_collection()
3109
-    {
3110
-        global $wpdb;
3111
-        //retrieve all existing transients
3112
-        $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3113
-        if ($results = $wpdb->get_results($query)) {
3114
-            foreach ($results as $result) {
3115
-                $transient = str_replace('_transient_', '', $result->option_name);
3116
-                get_transient($transient);
3117
-                if (is_multisite() && is_network_admin()) {
3118
-                    get_site_transient($transient);
3119
-                }
3120
-            }
3121
-        }
3122
-    }
3123
-
3124
-
3125
-
3126
-    /**
3127
-     * get_view
3128
-     *
3129
-     * @access public
3130
-     * @return string content of _view property
3131
-     */
3132
-    public function get_view()
3133
-    {
3134
-        return $this->_view;
3135
-    }
3136
-
3137
-
3138
-
3139
-    /**
3140
-     * getter for the protected $_views property
3141
-     *
3142
-     * @return array
3143
-     */
3144
-    public function get_views()
3145
-    {
3146
-        return $this->_views;
3147
-    }
3148
-
3149
-
3150
-
3151
-    /**
3152
-     * get_current_page
3153
-     *
3154
-     * @access public
3155
-     * @return string _current_page property value
3156
-     */
3157
-    public function get_current_page()
3158
-    {
3159
-        return $this->_current_page;
3160
-    }
3161
-
3162
-
3163
-
3164
-    /**
3165
-     * get_current_view
3166
-     *
3167
-     * @access public
3168
-     * @return string _current_view property value
3169
-     */
3170
-    public function get_current_view()
3171
-    {
3172
-        return $this->_current_view;
3173
-    }
3174
-
3175
-
3176
-
3177
-    /**
3178
-     * get_current_screen
3179
-     *
3180
-     * @access public
3181
-     * @return object The current WP_Screen object
3182
-     */
3183
-    public function get_current_screen()
3184
-    {
3185
-        return $this->_current_screen;
3186
-    }
3187
-
3188
-
3189
-
3190
-    /**
3191
-     * get_current_page_view_url
3192
-     *
3193
-     * @access public
3194
-     * @return string This returns the url for the current_page_view.
3195
-     */
3196
-    public function get_current_page_view_url()
3197
-    {
3198
-        return $this->_current_page_view_url;
3199
-    }
3200
-
3201
-
3202
-
3203
-    /**
3204
-     * just returns the _req_data property
3205
-     *
3206
-     * @return array
3207
-     */
3208
-    public function get_request_data()
3209
-    {
3210
-        return $this->_req_data;
3211
-    }
3212
-
3213
-
3214
-
3215
-    /**
3216
-     * returns the _req_data protected property
3217
-     *
3218
-     * @return string
3219
-     */
3220
-    public function get_req_action()
3221
-    {
3222
-        return $this->_req_action;
3223
-    }
3224
-
3225
-
3226
-
3227
-    /**
3228
-     * @return bool  value of $_is_caf property
3229
-     */
3230
-    public function is_caf()
3231
-    {
3232
-        return $this->_is_caf;
3233
-    }
3234
-
3235
-
3236
-
3237
-    /**
3238
-     * @return mixed
3239
-     */
3240
-    public function default_espresso_metaboxes()
3241
-    {
3242
-        return $this->_default_espresso_metaboxes;
3243
-    }
3244
-
3245
-
3246
-
3247
-    /**
3248
-     * @return mixed
3249
-     */
3250
-    public function admin_base_url()
3251
-    {
3252
-        return $this->_admin_base_url;
3253
-    }
3254
-
3255
-
3256
-
3257
-    /**
3258
-     * @return mixed
3259
-     */
3260
-    public function wp_page_slug()
3261
-    {
3262
-        return $this->_wp_page_slug;
3263
-    }
3264
-
3265
-
3266
-
3267
-    /**
3268
-     * updates  espresso configuration settings
3269
-     *
3270
-     * @access    protected
3271
-     * @param string                   $tab
3272
-     * @param EE_Config_Base|EE_Config $config
3273
-     * @param string                   $file file where error occurred
3274
-     * @param string                   $func function  where error occurred
3275
-     * @param string                   $line line no where error occurred
3276
-     * @return boolean
3277
-     */
3278
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3279
-    {
3280
-        //remove any options that are NOT going to be saved with the config settings.
3281
-        if (isset($config->core->ee_ueip_optin)) {
3282
-            $config->core->ee_ueip_has_notified = true;
3283
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3284
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3285
-            update_option('ee_ueip_has_notified', true);
3286
-        }
3287
-        // and save it (note we're also doing the network save here)
3288
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3289
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3290
-        if ($config_saved && $net_saved) {
3291
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3292
-            return true;
3293
-        } else {
3294
-            EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3295
-            return false;
3296
-        }
3297
-    }
3298
-
3299
-
3300
-
3301
-    /**
3302
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3303
-     *
3304
-     * @return array
3305
-     */
3306
-    public function get_yes_no_values()
3307
-    {
3308
-        return $this->_yes_no_values;
3309
-    }
3310
-
3311
-
3312
-
3313
-    protected function _get_dir()
3314
-    {
3315
-        $reflector = new ReflectionClass(get_class($this));
3316
-        return dirname($reflector->getFileName());
3317
-    }
3318
-
3319
-
3320
-
3321
-    /**
3322
-     * A helper for getting a "next link".
3323
-     *
3324
-     * @param string $url   The url to link to
3325
-     * @param string $class The class to use.
3326
-     * @return string
3327
-     */
3328
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3329
-    {
3330
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3331
-    }
3332
-
3333
-
3334
-
3335
-    /**
3336
-     * A helper for getting a "previous link".
3337
-     *
3338
-     * @param string $url   The url to link to
3339
-     * @param string $class The class to use.
3340
-     * @return string
3341
-     */
3342
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3343
-    {
3344
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3345
-    }
3346
-
3347
-
3348
-
3349
-
3350
-
3351
-
3352
-
3353
-    //below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3354
-    /**
3355
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data
3356
-     * array.
3357
-     *
3358
-     * @return bool success/fail
3359
-     */
3360
-    protected function _process_resend_registration()
3361
-    {
3362
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3363
-        do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3364
-        return $this->_template_args['success'];
3365
-    }
3366
-
3367
-
3368
-
3369
-    /**
3370
-     * This automatically processes any payment message notifications when manual payment has been applied.
3371
-     *
3372
-     * @access protected
3373
-     * @param \EE_Payment $payment
3374
-     * @return bool success/fail
3375
-     */
3376
-    protected function _process_payment_notification(EE_Payment $payment)
3377
-    {
3378
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3379
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3380
-        $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3381
-        return $this->_template_args['success'];
3382
-    }
2199
+	}
2200
+
2201
+
2202
+
2203
+	/**
2204
+	 * facade for add_meta_box
2205
+	 *
2206
+	 * @param string  $action        where the metabox get's displayed
2207
+	 * @param string  $title         Title of Metabox (output in metabox header)
2208
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here.
2209
+	 * @param array   $callback_args an array of args supplied for the metabox
2210
+	 * @param string  $column        what metabox column
2211
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2212
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box.
2213
+	 */
2214
+	public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2215
+	{
2216
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2217
+		//if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2218
+		if (empty($callback_args) && $create_func) {
2219
+			$callback_args = array(
2220
+					'template_path' => $this->_template_path,
2221
+					'template_args' => $this->_template_args,
2222
+			);
2223
+		}
2224
+		//if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2225
+		$call_back_func = $create_func ? create_function('$post, $metabox',
2226
+				'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2227
+		add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2228
+	}
2229
+
2230
+
2231
+
2232
+	/**
2233
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2234
+	 *
2235
+	 * @return [type] [description]
2236
+	 */
2237
+	public function display_admin_page_with_metabox_columns()
2238
+	{
2239
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2240
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2241
+		//the final wrapper
2242
+		$this->admin_page_wrapper();
2243
+	}
2244
+
2245
+
2246
+
2247
+	/**
2248
+	 *        generates  HTML wrapper for an admin details page
2249
+	 *
2250
+	 * @access public
2251
+	 * @return void
2252
+	 */
2253
+	public function display_admin_page_with_sidebar()
2254
+	{
2255
+		$this->_display_admin_page(true);
2256
+	}
2257
+
2258
+
2259
+
2260
+	/**
2261
+	 *        generates  HTML wrapper for an admin details page (except no sidebar)
2262
+	 *
2263
+	 * @access public
2264
+	 * @return void
2265
+	 */
2266
+	public function display_admin_page_with_no_sidebar()
2267
+	{
2268
+		$this->_display_admin_page();
2269
+	}
2270
+
2271
+
2272
+
2273
+	/**
2274
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2275
+	 *
2276
+	 * @access public
2277
+	 * @return void
2278
+	 */
2279
+	public function display_about_admin_page()
2280
+	{
2281
+		$this->_display_admin_page(false, true);
2282
+	}
2283
+
2284
+
2285
+
2286
+	/**
2287
+	 * display_admin_page
2288
+	 * contains the code for actually displaying an admin page
2289
+	 *
2290
+	 * @access private
2291
+	 * @param  boolean $sidebar true with sidebar, false without
2292
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2293
+	 * @return void
2294
+	 */
2295
+	private function _display_admin_page($sidebar = false, $about = false)
2296
+	{
2297
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2298
+		//custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2299
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2300
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2301
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2302
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2303
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2304
+				? 'poststuff'
2305
+				: 'espresso-default-admin';
2306
+		$template_path = $sidebar
2307
+				? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2308
+				: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2309
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2310
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2311
+		}
2312
+		$template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2313
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2314
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2315
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2316
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2317
+		// the final template wrapper
2318
+		$this->admin_page_wrapper($about);
2319
+	}
2320
+
2321
+
2322
+
2323
+	/**
2324
+	 * This is used to display caf preview pages.
2325
+	 *
2326
+	 * @since 4.3.2
2327
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2328
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2329
+	 * @return void
2330
+	 * @throws \EE_Error
2331
+	 */
2332
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2333
+	{
2334
+		//let's generate a default preview action button if there isn't one already present.
2335
+		$this->_labels['buttons']['buy_now'] = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso');
2336
+		$buy_now_url = add_query_arg(
2337
+				array(
2338
+						'ee_ver'       => 'ee4',
2339
+						'utm_source'   => 'ee4_plugin_admin',
2340
+						'utm_medium'   => 'link',
2341
+						'utm_campaign' => $utm_campaign_source,
2342
+						'utm_content'  => 'buy_now_button',
2343
+				),
2344
+				'https://eventespresso.com/pricing/'
2345
+		);
2346
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2347
+				? $this->get_action_link_or_button(
2348
+						'',
2349
+						'buy_now',
2350
+						array(),
2351
+						'button-primary button-large',
2352
+						$buy_now_url,
2353
+						true
2354
+				)
2355
+				: $this->_template_args['preview_action_button'];
2356
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2357
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2358
+				$template_path,
2359
+				$this->_template_args,
2360
+				true
2361
+		);
2362
+		$this->_display_admin_page($display_sidebar);
2363
+	}
2364
+
2365
+
2366
+
2367
+	/**
2368
+	 * display_admin_list_table_page_with_sidebar
2369
+	 * generates HTML wrapper for an admin_page with list_table
2370
+	 *
2371
+	 * @access public
2372
+	 * @return void
2373
+	 */
2374
+	public function display_admin_list_table_page_with_sidebar()
2375
+	{
2376
+		$this->_display_admin_list_table_page(true);
2377
+	}
2378
+
2379
+
2380
+
2381
+	/**
2382
+	 * display_admin_list_table_page_with_no_sidebar
2383
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2384
+	 *
2385
+	 * @access public
2386
+	 * @return void
2387
+	 */
2388
+	public function display_admin_list_table_page_with_no_sidebar()
2389
+	{
2390
+		$this->_display_admin_list_table_page();
2391
+	}
2392
+
2393
+
2394
+
2395
+	/**
2396
+	 * generates html wrapper for an admin_list_table page
2397
+	 *
2398
+	 * @access private
2399
+	 * @param boolean $sidebar whether to display with sidebar or not.
2400
+	 * @return void
2401
+	 */
2402
+	private function _display_admin_list_table_page($sidebar = false)
2403
+	{
2404
+		//setup search attributes
2405
+		$this->_set_search_attributes();
2406
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2407
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2408
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
2409
+				? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2410
+				: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2411
+		$this->_template_args['list_table'] = $this->_list_table_object;
2412
+		$this->_template_args['current_route'] = $this->_req_action;
2413
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2414
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2415
+		if ( ! empty($ajax_sorting_callback)) {
2416
+			$sortable_list_table_form_fields = wp_nonce_field(
2417
+					$ajax_sorting_callback . '_nonce',
2418
+					$ajax_sorting_callback . '_nonce',
2419
+					false,
2420
+					false
2421
+			);
2422
+			//			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2423
+			//			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2424
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2425
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2426
+		} else {
2427
+			$sortable_list_table_form_fields = '';
2428
+		}
2429
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2430
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2431
+		$nonce_ref = $this->_req_action . '_nonce';
2432
+		$hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2433
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2434
+		//display message about search results?
2435
+		$this->_template_args['before_list_table'] .= apply_filters(
2436
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2437
+				! empty($this->_req_data['s'])
2438
+						? '<p class="ee-search-results">'
2439
+							. sprintf(
2440
+								esc_html__(
2441
+										'Displaying search results for the search string: %1$s',
2442
+										'event_espresso'
2443
+								),
2444
+								'<strong><em>' . trim( $this->_req_data['s'], '%' ) . '</em></strong>'
2445
+							)
2446
+							. '</p>'
2447
+						: '',
2448
+				$this->page_slug,
2449
+				$this->_req_data,
2450
+				$this->_req_action
2451
+		);
2452
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2453
+				$template_path,
2454
+				$this->_template_args,
2455
+				true
2456
+		);
2457
+		// the final template wrapper
2458
+		if ($sidebar) {
2459
+			$this->display_admin_page_with_sidebar();
2460
+		} else {
2461
+			$this->display_admin_page_with_no_sidebar();
2462
+		}
2463
+	}
2464
+
2465
+
2466
+
2467
+	/**
2468
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend.
2469
+	 * $items are expected in an array in the following format:
2470
+	 * $legend_items = array(
2471
+	 *        'item_id' => array(
2472
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2473
+	 *            'desc' => __('localized description of item');
2474
+	 *        )
2475
+	 * );
2476
+	 *
2477
+	 * @param  array $items see above for format of array
2478
+	 * @return string        html string of legend
2479
+	 */
2480
+	protected function _display_legend($items)
2481
+	{
2482
+		$this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2483
+		$legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2484
+		return EEH_Template::display_template($legend_template, $this->_template_args, true);
2485
+	}
2486
+
2487
+
2488
+
2489
+	/**
2490
+	 * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2491
+	 *
2492
+	 * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2493
+	 *                             The returned json object is created from an array in the following format:
2494
+	 *                             array(
2495
+	 *                             'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2496
+	 *                             'success' => FALSE, //(default FALSE) - contains any special success message.
2497
+	 *                             'notices' => '', // - contains any EE_Error formatted notices
2498
+	 *                             'content' => 'string can be html', //this is a string of formatted content (can be html)
2499
+	 *                             'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any
2500
+	 *                             specific template args that might be included in here)
2501
+	 *                             )
2502
+	 *                             The json object is populated by whatever is set in the $_template_args property.
2503
+	 * @return void
2504
+	 */
2505
+	protected function _return_json($sticky_notices = false)
2506
+	{
2507
+		//make sure any EE_Error notices have been handled.
2508
+		$this->_process_notices(array(), true, $sticky_notices);
2509
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2510
+		unset($this->_template_args['data']);
2511
+		$json = array(
2512
+				'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2513
+				'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2514
+				'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2515
+				'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2516
+				'notices'   => EE_Error::get_notices(),
2517
+				'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2518
+				'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2519
+				'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2520
+		);
2521
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2522
+		if (null === error_get_last() || ! headers_sent()) {
2523
+			header('Content-Type: application/json; charset=UTF-8');
2524
+		}
2525
+		echo wp_json_encode($json);
2526
+
2527
+		exit();
2528
+	}
2529
+
2530
+
2531
+
2532
+	/**
2533
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2534
+	 *
2535
+	 * @return void
2536
+	 * @throws EE_Error
2537
+	 */
2538
+	public function return_json()
2539
+	{
2540
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2541
+			$this->_return_json();
2542
+		} else {
2543
+			throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2544
+		}
2545
+	}
2546
+
2547
+
2548
+
2549
+	/**
2550
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
2551
+	 *
2552
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2553
+	 * @access   public
2554
+	 */
2555
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
2556
+	{
2557
+		$this->_hook_obj = $hook_obj;
2558
+	}
2559
+
2560
+
2561
+
2562
+	/**
2563
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
2564
+	 *
2565
+	 * @access public
2566
+	 * @param  boolean $about whether to use the special about page wrapper or default.
2567
+	 * @return void
2568
+	 */
2569
+	public function admin_page_wrapper($about = false)
2570
+	{
2571
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2572
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
2573
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
2574
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
2575
+		$this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2576
+				isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2577
+		$this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2578
+				isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2579
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2580
+		// load settings page wrapper template
2581
+		$template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2582
+		//about page?
2583
+		$template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2584
+		if (defined('DOING_AJAX')) {
2585
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2586
+			$this->_return_json();
2587
+		} else {
2588
+			EEH_Template::display_template($template_path, $this->_template_args);
2589
+		}
2590
+	}
2591
+
2592
+
2593
+
2594
+	/**
2595
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2596
+	 *
2597
+	 * @return string html
2598
+	 */
2599
+	protected function _get_main_nav_tabs()
2600
+	{
2601
+		//let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
2602
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2603
+	}
2604
+
2605
+
2606
+
2607
+	/**
2608
+	 *        sort nav tabs
2609
+	 *
2610
+	 * @access public
2611
+	 * @param $a
2612
+	 * @param $b
2613
+	 * @return int
2614
+	 */
2615
+	private function _sort_nav_tabs($a, $b)
2616
+	{
2617
+		if ($a['order'] == $b['order']) {
2618
+			return 0;
2619
+		}
2620
+		return ($a['order'] < $b['order']) ? -1 : 1;
2621
+	}
2622
+
2623
+
2624
+
2625
+	/**
2626
+	 *    generates HTML for the forms used on admin pages
2627
+	 *
2628
+	 * @access protected
2629
+	 * @param    array $input_vars - array of input field details
2630
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2631
+	 * @return string
2632
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2633
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2634
+	 */
2635
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2636
+	{
2637
+		$content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2638
+		return $content;
2639
+	}
2640
+
2641
+
2642
+
2643
+	/**
2644
+	 * generates the "Save" and "Save & Close" buttons for edit forms
2645
+	 *
2646
+	 * @access protected
2647
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2648
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2649
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button).  We can also use this to just dump default actions by submitting some other value.
2650
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling).
2651
+	 */
2652
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2653
+	{
2654
+		//make sure $text and $actions are in an array
2655
+		$text = (array)$text;
2656
+		$actions = (array)$actions;
2657
+		$referrer_url = empty($referrer) ? '' : $referrer;
2658
+		$referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2659
+				: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2660
+		$button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2661
+		$default_names = array('save', 'save_and_close');
2662
+		//add in a hidden index for the current page (so save and close redirects properly)
2663
+		$this->_template_args['save_buttons'] = $referrer_url;
2664
+		foreach ($button_text as $key => $button) {
2665
+			$ref = $default_names[$key];
2666
+			$id = $this->_current_view . '_' . $ref;
2667
+			$name = ! empty($actions) ? $actions[$key] : $ref;
2668
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2669
+			if ( ! $both) {
2670
+				break;
2671
+			}
2672
+		}
2673
+	}
2674
+
2675
+
2676
+
2677
+	/**
2678
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2679
+	 *
2680
+	 * @see   $this->_set_add_edit_form_tags() for details on params
2681
+	 * @since 4.6.0
2682
+	 * @param string $route
2683
+	 * @param array  $additional_hidden_fields
2684
+	 */
2685
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2686
+	{
2687
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2688
+	}
2689
+
2690
+
2691
+
2692
+	/**
2693
+	 * set form open and close tags on add/edit pages.
2694
+	 *
2695
+	 * @access protected
2696
+	 * @param string $route                    the route you want the form to direct to
2697
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2698
+	 * @return void
2699
+	 */
2700
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2701
+	{
2702
+		if (empty($route)) {
2703
+			$user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2704
+			$dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2705
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2706
+		}
2707
+		// open form
2708
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2709
+		// add nonce
2710
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2711
+		//		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2712
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2713
+		// add REQUIRED form action
2714
+		$hidden_fields = array(
2715
+				'action' => array('type' => 'hidden', 'value' => $route),
2716
+		);
2717
+		// merge arrays
2718
+		$hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2719
+		// generate form fields
2720
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2721
+		// add fields to form
2722
+		foreach ((array)$form_fields as $field_name => $form_field) {
2723
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2724
+		}
2725
+		// close form
2726
+		$this->_template_args['after_admin_page_content'] = '</form>';
2727
+	}
2728
+
2729
+
2730
+
2731
+	/**
2732
+	 * Public Wrapper for _redirect_after_action() method since its
2733
+	 * discovered it would be useful for external code to have access.
2734
+	 *
2735
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
2736
+	 * @since 4.5.0
2737
+	 */
2738
+	public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2739
+	{
2740
+		$this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2741
+	}
2742
+
2743
+
2744
+
2745
+	/**
2746
+	 *    _redirect_after_action
2747
+	 *
2748
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
2749
+	 * @param string $what               - what the action was performed on
2750
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
2751
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2752
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2753
+	 * @access protected
2754
+	 * @return void
2755
+	 */
2756
+	protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2757
+	{
2758
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2759
+		//class name for actions/filters.
2760
+		$classname = get_class($this);
2761
+		//set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
2762
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2763
+		$notices = EE_Error::get_notices(false);
2764
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
2765
+		if ( ! $override_overwrite || ! empty($notices['errors'])) {
2766
+			EE_Error::overwrite_success();
2767
+		}
2768
+		if ( ! empty($what) && ! empty($action_desc)) {
2769
+			// how many records affected ? more than one record ? or just one ?
2770
+			if ($success > 1 && empty($notices['errors'])) {
2771
+				// set plural msg
2772
+				EE_Error::add_success(
2773
+						sprintf(
2774
+								__('The "%s" have been successfully %s.', 'event_espresso'),
2775
+								$what,
2776
+								$action_desc
2777
+						),
2778
+						__FILE__, __FUNCTION__, __LINE__
2779
+				);
2780
+			} else if ($success == 1 && empty($notices['errors'])) {
2781
+				// set singular msg
2782
+				EE_Error::add_success(
2783
+						sprintf(
2784
+								__('The "%s" has been successfully %s.', 'event_espresso'),
2785
+								$what,
2786
+								$action_desc
2787
+						),
2788
+						__FILE__, __FUNCTION__, __LINE__
2789
+				);
2790
+			}
2791
+		}
2792
+		// check that $query_args isn't something crazy
2793
+		if ( ! is_array($query_args)) {
2794
+			$query_args = array();
2795
+		}
2796
+		/**
2797
+		 * Allow injecting actions before the query_args are modified for possible different
2798
+		 * redirections on save and close actions
2799
+		 *
2800
+		 * @since 4.2.0
2801
+		 * @param array $query_args       The original query_args array coming into the
2802
+		 *                                method.
2803
+		 */
2804
+		do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2805
+		//calculate where we're going (if we have a "save and close" button pushed)
2806
+		if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2807
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2808
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2809
+			// regenerate query args array from referrer URL
2810
+			parse_str($parsed_url['query'], $query_args);
2811
+			// correct page and action will be in the query args now
2812
+			$redirect_url = admin_url('admin.php');
2813
+		}
2814
+		//merge any default query_args set in _default_route_query_args property
2815
+		if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2816
+			$args_to_merge = array();
2817
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
2818
+				//is there a wp_referer array in our _default_route_query_args property?
2819
+				if ($query_param == 'wp_referer') {
2820
+					$query_value = (array)$query_value;
2821
+					foreach ($query_value as $reference => $value) {
2822
+						if (strpos($reference, 'nonce') !== false) {
2823
+							continue;
2824
+						}
2825
+						//finally we will override any arguments in the referer with
2826
+						//what might be set on the _default_route_query_args array.
2827
+						if (isset($this->_default_route_query_args[$reference])) {
2828
+							$args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2829
+						} else {
2830
+							$args_to_merge[$reference] = urlencode($value);
2831
+						}
2832
+					}
2833
+					continue;
2834
+				}
2835
+				$args_to_merge[$query_param] = $query_value;
2836
+			}
2837
+			//now let's merge these arguments but override with what was specifically sent in to the
2838
+			//redirect.
2839
+			$query_args = array_merge($args_to_merge, $query_args);
2840
+		}
2841
+		$this->_process_notices($query_args);
2842
+		// generate redirect url
2843
+		// if redirecting to anything other than the main page, add a nonce
2844
+		if (isset($query_args['action'])) {
2845
+			// manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2846
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2847
+		}
2848
+		//we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2849
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2850
+		$redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2851
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2852
+		if (defined('DOING_AJAX')) {
2853
+			$default_data = array(
2854
+					'close'        => true,
2855
+					'redirect_url' => $redirect_url,
2856
+					'where'        => 'main',
2857
+					'what'         => 'append',
2858
+			);
2859
+			$this->_template_args['success'] = $success;
2860
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2861
+			$this->_return_json();
2862
+		}
2863
+		wp_safe_redirect($redirect_url);
2864
+		exit();
2865
+	}
2866
+
2867
+
2868
+
2869
+	/**
2870
+	 * process any notices before redirecting (or returning ajax request)
2871
+	 * This method sets the $this->_template_args['notices'] attribute;
2872
+	 *
2873
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
2874
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2875
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
2876
+	 * @return void
2877
+	 */
2878
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2879
+	{
2880
+		//first let's set individual error properties if doing_ajax and the properties aren't already set.
2881
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2882
+			$notices = EE_Error::get_notices(false);
2883
+			if (empty($this->_template_args['success'])) {
2884
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2885
+			}
2886
+			if (empty($this->_template_args['errors'])) {
2887
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2888
+			}
2889
+			if (empty($this->_template_args['attention'])) {
2890
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2891
+			}
2892
+		}
2893
+		$this->_template_args['notices'] = EE_Error::get_notices();
2894
+		//IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2895
+		if ( ! defined('DOING_AJAX') || $sticky_notices) {
2896
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
2897
+			$this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2898
+		}
2899
+	}
2900
+
2901
+
2902
+
2903
+	/**
2904
+	 * get_action_link_or_button
2905
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
2906
+	 *
2907
+	 * @param string $action        use this to indicate which action the url is generated with.
2908
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2909
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2910
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2911
+	 * @param string $base_url      If this is not provided
2912
+	 *                              the _admin_base_url will be used as the default for the button base_url.
2913
+	 *                              Otherwise this value will be used.
2914
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2915
+	 * @return string
2916
+	 * @throws \EE_Error
2917
+	 */
2918
+	public function get_action_link_or_button(
2919
+			$action,
2920
+			$type = 'add',
2921
+			$extra_request = array(),
2922
+			$class = 'button-primary',
2923
+			$base_url = '',
2924
+			$exclude_nonce = false
2925
+	) {
2926
+		//first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2927
+		if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2928
+			throw new EE_Error(
2929
+					sprintf(
2930
+							__(
2931
+									'There is no page route for given action for the button.  This action was given: %s',
2932
+									'event_espresso'
2933
+							),
2934
+							$action
2935
+					)
2936
+			);
2937
+		}
2938
+		if ( ! isset($this->_labels['buttons'][$type])) {
2939
+			throw new EE_Error(
2940
+					sprintf(
2941
+							__(
2942
+									'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2943
+									'event_espresso'
2944
+							),
2945
+							$type
2946
+					)
2947
+			);
2948
+		}
2949
+		//finally check user access for this button.
2950
+		$has_access = $this->check_user_access($action, true);
2951
+		if ( ! $has_access) {
2952
+			return '';
2953
+		}
2954
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2955
+		$query_args = array(
2956
+				'action' => $action,
2957
+		);
2958
+		//merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2959
+		if ( ! empty($extra_request)) {
2960
+			$query_args = array_merge($extra_request, $query_args);
2961
+		}
2962
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2963
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2964
+	}
2965
+
2966
+
2967
+
2968
+	/**
2969
+	 * _per_page_screen_option
2970
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
2971
+	 *
2972
+	 * @return void
2973
+	 */
2974
+	protected function _per_page_screen_option()
2975
+	{
2976
+		$option = 'per_page';
2977
+		$args = array(
2978
+				'label'   => $this->_admin_page_title,
2979
+				'default' => 10,
2980
+				'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2981
+		);
2982
+		//ONLY add the screen option if the user has access to it.
2983
+		if ($this->check_user_access($this->_current_view, true)) {
2984
+			add_screen_option($option, $args);
2985
+		}
2986
+	}
2987
+
2988
+
2989
+
2990
+	/**
2991
+	 * set_per_page_screen_option
2992
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
2993
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
2994
+	 *
2995
+	 * @access private
2996
+	 * @return void
2997
+	 */
2998
+	private function _set_per_page_screen_options()
2999
+	{
3000
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3001
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3002
+			if ( ! $user = wp_get_current_user()) {
3003
+				return;
3004
+			}
3005
+			$option = $_POST['wp_screen_options']['option'];
3006
+			$value = $_POST['wp_screen_options']['value'];
3007
+			if ($option != sanitize_key($option)) {
3008
+				return;
3009
+			}
3010
+			$map_option = $option;
3011
+			$option = str_replace('-', '_', $option);
3012
+			switch ($map_option) {
3013
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3014
+					$value = (int)$value;
3015
+					if ($value < 1 || $value > 999) {
3016
+						return;
3017
+					}
3018
+					break;
3019
+				default:
3020
+					$value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3021
+					if (false === $value) {
3022
+						return;
3023
+					}
3024
+					break;
3025
+			}
3026
+			update_user_meta($user->ID, $option, $value);
3027
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3028
+			exit;
3029
+		}
3030
+	}
3031
+
3032
+
3033
+
3034
+	/**
3035
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3036
+	 *
3037
+	 * @param array $data array that will be assigned to template args.
3038
+	 */
3039
+	public function set_template_args($data)
3040
+	{
3041
+		$this->_template_args = array_merge($this->_template_args, (array)$data);
3042
+	}
3043
+
3044
+
3045
+
3046
+	/**
3047
+	 * This makes available the WP transient system for temporarily moving data between routes
3048
+	 *
3049
+	 * @access protected
3050
+	 * @param string $route             the route that should receive the transient
3051
+	 * @param array  $data              the data that gets sent
3052
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3053
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used when we are adding a transient before page_routes have been defined.
3054
+	 * @return void
3055
+	 */
3056
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3057
+	{
3058
+		$user_id = get_current_user_id();
3059
+		if ( ! $skip_route_verify) {
3060
+			$this->_verify_route($route);
3061
+		}
3062
+		//now let's set the string for what kind of transient we're setting
3063
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3064
+		$data = $notices ? array('notices' => $data) : $data;
3065
+		//is there already a transient for this route?  If there is then let's ADD to that transient
3066
+		$existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3067
+		if ($existing) {
3068
+			$data = array_merge((array)$data, (array)$existing);
3069
+		}
3070
+		if (is_multisite() && is_network_admin()) {
3071
+			set_site_transient($transient, $data, 8);
3072
+		} else {
3073
+			set_transient($transient, $data, 8);
3074
+		}
3075
+	}
3076
+
3077
+
3078
+
3079
+	/**
3080
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3081
+	 *
3082
+	 * @param bool $notices true we get notices transient. False we just return normal route transient
3083
+	 * @return mixed data
3084
+	 */
3085
+	protected function _get_transient($notices = false, $route = false)
3086
+	{
3087
+		$user_id = get_current_user_id();
3088
+		$route = ! $route ? $this->_req_action : $route;
3089
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3090
+		$data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3091
+		//delete transient after retrieval (just in case it hasn't expired);
3092
+		if (is_multisite() && is_network_admin()) {
3093
+			delete_site_transient($transient);
3094
+		} else {
3095
+			delete_transient($transient);
3096
+		}
3097
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3098
+	}
3099
+
3100
+
3101
+
3102
+	/**
3103
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later.
3104
+	 * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.)
3105
+	 *
3106
+	 * @return void
3107
+	 */
3108
+	protected function _transient_garbage_collection()
3109
+	{
3110
+		global $wpdb;
3111
+		//retrieve all existing transients
3112
+		$query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3113
+		if ($results = $wpdb->get_results($query)) {
3114
+			foreach ($results as $result) {
3115
+				$transient = str_replace('_transient_', '', $result->option_name);
3116
+				get_transient($transient);
3117
+				if (is_multisite() && is_network_admin()) {
3118
+					get_site_transient($transient);
3119
+				}
3120
+			}
3121
+		}
3122
+	}
3123
+
3124
+
3125
+
3126
+	/**
3127
+	 * get_view
3128
+	 *
3129
+	 * @access public
3130
+	 * @return string content of _view property
3131
+	 */
3132
+	public function get_view()
3133
+	{
3134
+		return $this->_view;
3135
+	}
3136
+
3137
+
3138
+
3139
+	/**
3140
+	 * getter for the protected $_views property
3141
+	 *
3142
+	 * @return array
3143
+	 */
3144
+	public function get_views()
3145
+	{
3146
+		return $this->_views;
3147
+	}
3148
+
3149
+
3150
+
3151
+	/**
3152
+	 * get_current_page
3153
+	 *
3154
+	 * @access public
3155
+	 * @return string _current_page property value
3156
+	 */
3157
+	public function get_current_page()
3158
+	{
3159
+		return $this->_current_page;
3160
+	}
3161
+
3162
+
3163
+
3164
+	/**
3165
+	 * get_current_view
3166
+	 *
3167
+	 * @access public
3168
+	 * @return string _current_view property value
3169
+	 */
3170
+	public function get_current_view()
3171
+	{
3172
+		return $this->_current_view;
3173
+	}
3174
+
3175
+
3176
+
3177
+	/**
3178
+	 * get_current_screen
3179
+	 *
3180
+	 * @access public
3181
+	 * @return object The current WP_Screen object
3182
+	 */
3183
+	public function get_current_screen()
3184
+	{
3185
+		return $this->_current_screen;
3186
+	}
3187
+
3188
+
3189
+
3190
+	/**
3191
+	 * get_current_page_view_url
3192
+	 *
3193
+	 * @access public
3194
+	 * @return string This returns the url for the current_page_view.
3195
+	 */
3196
+	public function get_current_page_view_url()
3197
+	{
3198
+		return $this->_current_page_view_url;
3199
+	}
3200
+
3201
+
3202
+
3203
+	/**
3204
+	 * just returns the _req_data property
3205
+	 *
3206
+	 * @return array
3207
+	 */
3208
+	public function get_request_data()
3209
+	{
3210
+		return $this->_req_data;
3211
+	}
3212
+
3213
+
3214
+
3215
+	/**
3216
+	 * returns the _req_data protected property
3217
+	 *
3218
+	 * @return string
3219
+	 */
3220
+	public function get_req_action()
3221
+	{
3222
+		return $this->_req_action;
3223
+	}
3224
+
3225
+
3226
+
3227
+	/**
3228
+	 * @return bool  value of $_is_caf property
3229
+	 */
3230
+	public function is_caf()
3231
+	{
3232
+		return $this->_is_caf;
3233
+	}
3234
+
3235
+
3236
+
3237
+	/**
3238
+	 * @return mixed
3239
+	 */
3240
+	public function default_espresso_metaboxes()
3241
+	{
3242
+		return $this->_default_espresso_metaboxes;
3243
+	}
3244
+
3245
+
3246
+
3247
+	/**
3248
+	 * @return mixed
3249
+	 */
3250
+	public function admin_base_url()
3251
+	{
3252
+		return $this->_admin_base_url;
3253
+	}
3254
+
3255
+
3256
+
3257
+	/**
3258
+	 * @return mixed
3259
+	 */
3260
+	public function wp_page_slug()
3261
+	{
3262
+		return $this->_wp_page_slug;
3263
+	}
3264
+
3265
+
3266
+
3267
+	/**
3268
+	 * updates  espresso configuration settings
3269
+	 *
3270
+	 * @access    protected
3271
+	 * @param string                   $tab
3272
+	 * @param EE_Config_Base|EE_Config $config
3273
+	 * @param string                   $file file where error occurred
3274
+	 * @param string                   $func function  where error occurred
3275
+	 * @param string                   $line line no where error occurred
3276
+	 * @return boolean
3277
+	 */
3278
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3279
+	{
3280
+		//remove any options that are NOT going to be saved with the config settings.
3281
+		if (isset($config->core->ee_ueip_optin)) {
3282
+			$config->core->ee_ueip_has_notified = true;
3283
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3284
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3285
+			update_option('ee_ueip_has_notified', true);
3286
+		}
3287
+		// and save it (note we're also doing the network save here)
3288
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3289
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3290
+		if ($config_saved && $net_saved) {
3291
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3292
+			return true;
3293
+		} else {
3294
+			EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3295
+			return false;
3296
+		}
3297
+	}
3298
+
3299
+
3300
+
3301
+	/**
3302
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3303
+	 *
3304
+	 * @return array
3305
+	 */
3306
+	public function get_yes_no_values()
3307
+	{
3308
+		return $this->_yes_no_values;
3309
+	}
3310
+
3311
+
3312
+
3313
+	protected function _get_dir()
3314
+	{
3315
+		$reflector = new ReflectionClass(get_class($this));
3316
+		return dirname($reflector->getFileName());
3317
+	}
3318
+
3319
+
3320
+
3321
+	/**
3322
+	 * A helper for getting a "next link".
3323
+	 *
3324
+	 * @param string $url   The url to link to
3325
+	 * @param string $class The class to use.
3326
+	 * @return string
3327
+	 */
3328
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3329
+	{
3330
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3331
+	}
3332
+
3333
+
3334
+
3335
+	/**
3336
+	 * A helper for getting a "previous link".
3337
+	 *
3338
+	 * @param string $url   The url to link to
3339
+	 * @param string $class The class to use.
3340
+	 * @return string
3341
+	 */
3342
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3343
+	{
3344
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3345
+	}
3346
+
3347
+
3348
+
3349
+
3350
+
3351
+
3352
+
3353
+	//below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3354
+	/**
3355
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data
3356
+	 * array.
3357
+	 *
3358
+	 * @return bool success/fail
3359
+	 */
3360
+	protected function _process_resend_registration()
3361
+	{
3362
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3363
+		do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3364
+		return $this->_template_args['success'];
3365
+	}
3366
+
3367
+
3368
+
3369
+	/**
3370
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3371
+	 *
3372
+	 * @access protected
3373
+	 * @param \EE_Payment $payment
3374
+	 * @return bool success/fail
3375
+	 */
3376
+	protected function _process_payment_notification(EE_Payment $payment)
3377
+	{
3378
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3379
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3380
+		$this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3381
+		return $this->_template_args['success'];
3382
+	}
3383 3383
 
3384 3384
 
3385 3385
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Enum_Integer_Field.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 require_once(EE_MODELS . 'fields/EE_Integer_Field.php');
5 5
 
@@ -13,89 +13,89 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class EE_Enum_Integer_Field extends EE_Integer_Field
15 15
 {
16
-    /**
17
-     * @var array $_allowed_enum_values
18
-     */
19
-    public $_allowed_enum_values;
16
+	/**
17
+	 * @var array $_allowed_enum_values
18
+	 */
19
+	public $_allowed_enum_values;
20 20
 
21
-    /**
22
-     * @param string  $table_column
23
-     * @param string  $nicename
24
-     * @param boolean $nullable
25
-     * @param int     $default_value
26
-     * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
27
-     */
28
-    public function __construct($table_column, $nicename, $nullable, $default_value, $allowed_enum_values)
29
-    {
30
-        $this->_allowed_enum_values = $allowed_enum_values;
31
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
32
-    }
21
+	/**
22
+	 * @param string  $table_column
23
+	 * @param string  $nicename
24
+	 * @param boolean $nullable
25
+	 * @param int     $default_value
26
+	 * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
27
+	 */
28
+	public function __construct($table_column, $nicename, $nullable, $default_value, $allowed_enum_values)
29
+	{
30
+		$this->_allowed_enum_values = $allowed_enum_values;
31
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
32
+	}
33 33
 
34
-    /**
35
-     * Returns the list of allowed enum options, but filterable.
36
-     * This is used internally
37
-     *
38
-     * @return array
39
-     */
40
-    protected function _allowed_enum_values()
41
-    {
42
-        return (array)apply_filters(
43
-            'FHEE__EE_Enum_Integer_Field___allowed_enum_options',
44
-            $this->_allowed_enum_values,
45
-            $this
46
-        );
47
-    }
34
+	/**
35
+	 * Returns the list of allowed enum options, but filterable.
36
+	 * This is used internally
37
+	 *
38
+	 * @return array
39
+	 */
40
+	protected function _allowed_enum_values()
41
+	{
42
+		return (array)apply_filters(
43
+			'FHEE__EE_Enum_Integer_Field___allowed_enum_options',
44
+			$this->_allowed_enum_values,
45
+			$this
46
+		);
47
+	}
48 48
 
49
-    /**
50
-     * When setting, just verify that the value being used matches what we've defined as allowable enum values.
51
-     * If not, throw an error (but if WP_DEBUG is false, just set the value to default)
52
-     *
53
-     * @param int $value_inputted_for_field_on_model_object
54
-     * @return int
55
-     * @throws EE_Error
56
-     */
57
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
58
-    {
59
-        $allowed_enum_values = $this->_allowed_enum_values();
60
-        if (
61
-            $value_inputted_for_field_on_model_object !== null
62
-            && ! array_key_exists($value_inputted_for_field_on_model_object, $allowed_enum_values)
63
-        ) {
64
-            if (defined('WP_DEBUG') && WP_DEBUG) {
65
-                $msg = sprintf(
66
-                    __('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
67
-                    $value_inputted_for_field_on_model_object,
68
-                    $this->_name
69
-                );
70
-                $msg2 = sprintf(
71
-                    __('Allowed values for "%1$s" are "%2$s". You provided "%3$s"', 'event_espresso'),
72
-                    $this->_name,
73
-                    implode(', ', array_keys($allowed_enum_values)),
74
-                    $value_inputted_for_field_on_model_object
75
-                );
76
-                EE_Error::add_error("{$msg}||{$msg2}", __FILE__, __FUNCTION__, __LINE__);
77
-            }
78
-            return $this->get_default_value();
79
-        }
80
-        return (int)$value_inputted_for_field_on_model_object;
81
-    }
49
+	/**
50
+	 * When setting, just verify that the value being used matches what we've defined as allowable enum values.
51
+	 * If not, throw an error (but if WP_DEBUG is false, just set the value to default)
52
+	 *
53
+	 * @param int $value_inputted_for_field_on_model_object
54
+	 * @return int
55
+	 * @throws EE_Error
56
+	 */
57
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
58
+	{
59
+		$allowed_enum_values = $this->_allowed_enum_values();
60
+		if (
61
+			$value_inputted_for_field_on_model_object !== null
62
+			&& ! array_key_exists($value_inputted_for_field_on_model_object, $allowed_enum_values)
63
+		) {
64
+			if (defined('WP_DEBUG') && WP_DEBUG) {
65
+				$msg = sprintf(
66
+					__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
67
+					$value_inputted_for_field_on_model_object,
68
+					$this->_name
69
+				);
70
+				$msg2 = sprintf(
71
+					__('Allowed values for "%1$s" are "%2$s". You provided "%3$s"', 'event_espresso'),
72
+					$this->_name,
73
+					implode(', ', array_keys($allowed_enum_values)),
74
+					$value_inputted_for_field_on_model_object
75
+				);
76
+				EE_Error::add_error("{$msg}||{$msg2}", __FILE__, __FUNCTION__, __LINE__);
77
+			}
78
+			return $this->get_default_value();
79
+		}
80
+		return (int)$value_inputted_for_field_on_model_object;
81
+	}
82 82
 
83 83
 
84 84
 
85
-    /**
86
-     * Gets the pretty version of the enum's value.
87
-     *
88
-     * @param int | string $value_on_field_to_be_outputted
89
-     * @param null         $schema
90
-     * @return string
91
-     */
92
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
93
-    {
94
-        $options = $this->_allowed_enum_values();
95
-        if (isset($options[$value_on_field_to_be_outputted])) {
96
-            return $options[$value_on_field_to_be_outputted];
97
-        } else {
98
-            return $value_on_field_to_be_outputted;
99
-        }
100
-    }
85
+	/**
86
+	 * Gets the pretty version of the enum's value.
87
+	 *
88
+	 * @param int | string $value_on_field_to_be_outputted
89
+	 * @param null         $schema
90
+	 * @return string
91
+	 */
92
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
93
+	{
94
+		$options = $this->_allowed_enum_values();
95
+		if (isset($options[$value_on_field_to_be_outputted])) {
96
+			return $options[$value_on_field_to_be_outputted];
97
+		} else {
98
+			return $value_on_field_to_be_outputted;
99
+		}
100
+	}
101 101
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4
-require_once(EE_MODELS . 'fields/EE_Integer_Field.php');
4
+require_once(EE_MODELS.'fields/EE_Integer_Field.php');
5 5
 
6 6
 /**
7 7
  * Class EE_Enum_Integer_Field
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     protected function _allowed_enum_values()
41 41
     {
42
-        return (array)apply_filters(
42
+        return (array) apply_filters(
43 43
             'FHEE__EE_Enum_Integer_Field___allowed_enum_options',
44 44
             $this->_allowed_enum_values,
45 45
             $this
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             }
78 78
             return $this->get_default_value();
79 79
         }
80
-        return (int)$value_inputted_for_field_on_model_object;
80
+        return (int) $value_inputted_for_field_on_model_object;
81 81
     }
82 82
 
83 83
 
Please login to merge, or discard this patch.
core/db_models/fields/EE_Enum_Text_Field.php 2 patches
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -12,108 +12,108 @@
 block discarded – undo
12 12
 class EE_Enum_Text_Field extends EE_Text_Field_Base
13 13
 {
14 14
 
15
-    /**
16
-     * @var array $_allowed_enum_values
17
-     */
18
-    public $_allowed_enum_values;
19
-
20
-
21
-
22
-    /**
23
-     * @param string  $table_column
24
-     * @param string  $nice_name
25
-     * @param boolean $nullable
26
-     * @param mixed   $default_value
27
-     * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
28
-     */
29
-    function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values)
30
-    {
31
-        $this->_allowed_enum_values = $allowed_enum_values;
32
-        parent::__construct($table_column, $nice_name, $nullable, $default_value);
33
-    }
34
-
35
-
36
-
37
-    /**
38
-     * Returns the list of allowed enum options, but filterable.
39
-     * This is used internally
40
-     *
41
-     * @return array
42
-     */
43
-    protected function _allowed_enum_values()
44
-    {
45
-        return apply_filters(
46
-            'FHEE__EE_Enum_Text_Field___allowed_enum_options',
47
-            $this->_allowed_enum_values,
48
-            $this
49
-        );
50
-    }
51
-
52
-
53
-
54
-    /**
55
-     * When setting, just verify that the value being used matches what we've defined as allowable enum values.
56
-     * If not, throw an error (but if WP_DEBUG is false, just set the value to default).
57
-     *
58
-     * @param string $value_inputted_for_field_on_model_object
59
-     * @return string
60
-     * @throws EE_Error
61
-     */
62
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
63
-    {
64
-        if (
65
-            $value_inputted_for_field_on_model_object !== null
66
-            && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values())
67
-        ) {
68
-            if (defined('WP_DEBUG') && WP_DEBUG) {
69
-                $msg = sprintf(
70
-                    __('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
71
-                    $value_inputted_for_field_on_model_object,
72
-                    $this->_name
73
-                );
74
-                $msg2 = sprintf(
75
-                    __('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'),
76
-                    $this->_name,
77
-                    implode(', ', array_keys($this->_allowed_enum_values())),
78
-                    $value_inputted_for_field_on_model_object
79
-                );
80
-                EE_Error::add_error("{$msg}||{$msg2}", __FILE__, __FUNCTION__, __LINE__);
81
-            }
82
-            return $this->get_default_value();
83
-        }
84
-        return $value_inputted_for_field_on_model_object;
85
-    }
86
-
87
-
88
-    /**
89
-     * Gets the pretty version of the enum's value.
90
-     *
91
-     * @param     int |string $value_on_field_to_be_outputted
92
-     * @param    null         $schema
93
-     * @return    string
94
-     */
95
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
96
-    {
97
-        $options = $this->_allowed_enum_values();
98
-        if (isset($options[$value_on_field_to_be_outputted])) {
99
-            return $options[$value_on_field_to_be_outputted];
100
-        } else {
101
-            return $value_on_field_to_be_outputted;
102
-        }
103
-    }
104
-
105
-
106
-
107
-    /**
108
-     * When retrieving something from the DB, don't enforce the enum's options. If it's in the DB, we just have to live
109
-     * with that. Note also: when we're saving to the DB again, we also don't enforce the enum options. It's ONLY
110
-     * when we're receiving USER input from prepare_for_set() that we enforce the enum options.
111
-     *
112
-     * @param mixed $value_in_db
113
-     * @return mixed
114
-     */
115
-    public function prepare_for_set_from_db($value_in_db)
116
-    {
117
-        return $value_in_db;
118
-    }
15
+	/**
16
+	 * @var array $_allowed_enum_values
17
+	 */
18
+	public $_allowed_enum_values;
19
+
20
+
21
+
22
+	/**
23
+	 * @param string  $table_column
24
+	 * @param string  $nice_name
25
+	 * @param boolean $nullable
26
+	 * @param mixed   $default_value
27
+	 * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
28
+	 */
29
+	function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values)
30
+	{
31
+		$this->_allowed_enum_values = $allowed_enum_values;
32
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
33
+	}
34
+
35
+
36
+
37
+	/**
38
+	 * Returns the list of allowed enum options, but filterable.
39
+	 * This is used internally
40
+	 *
41
+	 * @return array
42
+	 */
43
+	protected function _allowed_enum_values()
44
+	{
45
+		return apply_filters(
46
+			'FHEE__EE_Enum_Text_Field___allowed_enum_options',
47
+			$this->_allowed_enum_values,
48
+			$this
49
+		);
50
+	}
51
+
52
+
53
+
54
+	/**
55
+	 * When setting, just verify that the value being used matches what we've defined as allowable enum values.
56
+	 * If not, throw an error (but if WP_DEBUG is false, just set the value to default).
57
+	 *
58
+	 * @param string $value_inputted_for_field_on_model_object
59
+	 * @return string
60
+	 * @throws EE_Error
61
+	 */
62
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
63
+	{
64
+		if (
65
+			$value_inputted_for_field_on_model_object !== null
66
+			&& ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values())
67
+		) {
68
+			if (defined('WP_DEBUG') && WP_DEBUG) {
69
+				$msg = sprintf(
70
+					__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
71
+					$value_inputted_for_field_on_model_object,
72
+					$this->_name
73
+				);
74
+				$msg2 = sprintf(
75
+					__('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'),
76
+					$this->_name,
77
+					implode(', ', array_keys($this->_allowed_enum_values())),
78
+					$value_inputted_for_field_on_model_object
79
+				);
80
+				EE_Error::add_error("{$msg}||{$msg2}", __FILE__, __FUNCTION__, __LINE__);
81
+			}
82
+			return $this->get_default_value();
83
+		}
84
+		return $value_inputted_for_field_on_model_object;
85
+	}
86
+
87
+
88
+	/**
89
+	 * Gets the pretty version of the enum's value.
90
+	 *
91
+	 * @param     int |string $value_on_field_to_be_outputted
92
+	 * @param    null         $schema
93
+	 * @return    string
94
+	 */
95
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
96
+	{
97
+		$options = $this->_allowed_enum_values();
98
+		if (isset($options[$value_on_field_to_be_outputted])) {
99
+			return $options[$value_on_field_to_be_outputted];
100
+		} else {
101
+			return $value_on_field_to_be_outputted;
102
+		}
103
+	}
104
+
105
+
106
+
107
+	/**
108
+	 * When retrieving something from the DB, don't enforce the enum's options. If it's in the DB, we just have to live
109
+	 * with that. Note also: when we're saving to the DB again, we also don't enforce the enum options. It's ONLY
110
+	 * when we're receiving USER input from prepare_for_set() that we enforce the enum options.
111
+	 *
112
+	 * @param mixed $value_in_db
113
+	 * @return mixed
114
+	 */
115
+	public function prepare_for_set_from_db($value_in_db)
116
+	{
117
+		return $value_in_db;
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-require_once(EE_MODELS . 'fields/EE_Text_Field_Base.php');
2
+require_once(EE_MODELS.'fields/EE_Text_Field_Base.php');
3 3
 
4 4
 class EE_Plain_Text_Field extends EE_Text_Field_Base
5 5
 {
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,239 +40,239 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.24.rc.023');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.24.rc.023');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        /**
197
-         *    espresso_plugin_activation
198
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
199
-         */
200
-        function espresso_plugin_activation()
201
-        {
202
-            update_option('ee_espresso_activation', true);
203
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		/**
197
+		 *    espresso_plugin_activation
198
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
199
+		 */
200
+		function espresso_plugin_activation()
201
+		{
202
+			update_option('ee_espresso_activation', true);
203
+		}
204 204
 
205
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
206
-        /**
207
-         *    espresso_load_error_handling
208
-         *    this function loads EE's class for handling exceptions and errors
209
-         */
210
-        function espresso_load_error_handling()
211
-        {
212
-            // load debugging tools
213
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
214
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
215
-                EEH_Debug_Tools::instance();
216
-            }
217
-            // load error handling
218
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
219
-                require_once(EE_CORE . 'EE_Error.core.php');
220
-            } else {
221
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
222
-            }
223
-        }
205
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
206
+		/**
207
+		 *    espresso_load_error_handling
208
+		 *    this function loads EE's class for handling exceptions and errors
209
+		 */
210
+		function espresso_load_error_handling()
211
+		{
212
+			// load debugging tools
213
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
214
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
215
+				EEH_Debug_Tools::instance();
216
+			}
217
+			// load error handling
218
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
219
+				require_once(EE_CORE . 'EE_Error.core.php');
220
+			} else {
221
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
222
+			}
223
+		}
224 224
 
225
-        /**
226
-         *    espresso_load_required
227
-         *    given a class name and path, this function will load that file or throw an exception
228
-         *
229
-         * @param    string $classname
230
-         * @param    string $full_path_to_file
231
-         * @throws    EE_Error
232
-         */
233
-        function espresso_load_required($classname, $full_path_to_file)
234
-        {
235
-            static $error_handling_loaded = false;
236
-            if ( ! $error_handling_loaded) {
237
-                espresso_load_error_handling();
238
-                $error_handling_loaded = true;
239
-            }
240
-            if (is_readable($full_path_to_file)) {
241
-                require_once($full_path_to_file);
242
-            } else {
243
-                throw new EE_Error (
244
-                        sprintf(
245
-                                esc_html__(
246
-                                        'The %s class file could not be located or is not readable due to file permissions.',
247
-                                        'event_espresso'
248
-                                ),
249
-                                $classname
250
-                        )
251
-                );
252
-            }
253
-        }
225
+		/**
226
+		 *    espresso_load_required
227
+		 *    given a class name and path, this function will load that file or throw an exception
228
+		 *
229
+		 * @param    string $classname
230
+		 * @param    string $full_path_to_file
231
+		 * @throws    EE_Error
232
+		 */
233
+		function espresso_load_required($classname, $full_path_to_file)
234
+		{
235
+			static $error_handling_loaded = false;
236
+			if ( ! $error_handling_loaded) {
237
+				espresso_load_error_handling();
238
+				$error_handling_loaded = true;
239
+			}
240
+			if (is_readable($full_path_to_file)) {
241
+				require_once($full_path_to_file);
242
+			} else {
243
+				throw new EE_Error (
244
+						sprintf(
245
+								esc_html__(
246
+										'The %s class file could not be located or is not readable due to file permissions.',
247
+										'event_espresso'
248
+								),
249
+								$classname
250
+						)
251
+				);
252
+			}
253
+		}
254 254
 
255
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
256
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
257
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
258
-        new EE_Bootstrap();
259
-    }
255
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
256
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
257
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
258
+		new EE_Bootstrap();
259
+	}
260 260
 }
261 261
 if ( ! function_exists('espresso_deactivate_plugin')) {
262
-    /**
263
-     *    deactivate_plugin
264
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
265
-     *
266
-     * @access public
267
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
268
-     * @return    void
269
-     */
270
-    function espresso_deactivate_plugin($plugin_basename = '')
271
-    {
272
-        if ( ! function_exists('deactivate_plugins')) {
273
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
274
-        }
275
-        unset($_GET['activate'], $_REQUEST['activate']);
276
-        deactivate_plugins($plugin_basename);
277
-    }
262
+	/**
263
+	 *    deactivate_plugin
264
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
265
+	 *
266
+	 * @access public
267
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
268
+	 * @return    void
269
+	 */
270
+	function espresso_deactivate_plugin($plugin_basename = '')
271
+	{
272
+		if ( ! function_exists('deactivate_plugins')) {
273
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
274
+		}
275
+		unset($_GET['activate'], $_REQUEST['activate']);
276
+		deactivate_plugins($plugin_basename);
277
+	}
278 278
 }
Please login to merge, or discard this patch.