@@ -7,6 +7,7 @@ |
||
7 | 7 | * |
8 | 8 | * @param string $table_column |
9 | 9 | * @param string $nicename |
10 | + * @param integer|null $default |
|
10 | 11 | */ |
11 | 12 | public function __construct($table_column, $nicename, $default) |
12 | 13 | { |
@@ -2,24 +2,24 @@ |
||
2 | 2 | |
3 | 3 | abstract class EE_Primary_Key_Field_Base extends EE_Field_With_Model_Name |
4 | 4 | { |
5 | - /** |
|
6 | - * Overrides parent so it doesn't need to provide so many non-applicable fields |
|
7 | - * |
|
8 | - * @param string $table_column |
|
9 | - * @param string $nicename |
|
10 | - */ |
|
11 | - public function __construct($table_column, $nicename, $default) |
|
12 | - { |
|
13 | - parent::__construct($table_column, $nicename, false, $default, null); |
|
14 | - } |
|
5 | + /** |
|
6 | + * Overrides parent so it doesn't need to provide so many non-applicable fields |
|
7 | + * |
|
8 | + * @param string $table_column |
|
9 | + * @param string $nicename |
|
10 | + */ |
|
11 | + public function __construct($table_column, $nicename, $default) |
|
12 | + { |
|
13 | + parent::__construct($table_column, $nicename, false, $default, null); |
|
14 | + } |
|
15 | 15 | |
16 | - /** |
|
17 | - * @param $table_alias |
|
18 | - * @param $name |
|
19 | - */ |
|
20 | - function _construct_finalize($table_alias, $name, $model_name) |
|
21 | - { |
|
22 | - $this->_model_name_pointed_to = $model_name; |
|
23 | - parent::_construct_finalize($table_alias, $name, $model_name); |
|
24 | - } |
|
16 | + /** |
|
17 | + * @param $table_alias |
|
18 | + * @param $name |
|
19 | + */ |
|
20 | + function _construct_finalize($table_alias, $name, $model_name) |
|
21 | + { |
|
22 | + $this->_model_name_pointed_to = $model_name; |
|
23 | + parent::_construct_finalize($table_alias, $name, $model_name); |
|
24 | + } |
|
25 | 25 | } |
@@ -33,8 +33,6 @@ |
||
33 | 33 | * ) |
34 | 34 | * ) |
35 | 35 | * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
36 | - * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is |
|
37 | - * set to true, it will be stored as an INT |
|
38 | 36 | */ |
39 | 37 | function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) |
40 | 38 | { |
@@ -4,116 +4,116 @@ |
||
4 | 4 | class EE_WP_Post_Status_Field extends EE_Enum_Text_Field |
5 | 5 | { |
6 | 6 | |
7 | - protected $_wp_post_stati; |
|
8 | - |
|
9 | - |
|
10 | - /** |
|
11 | - * constructor |
|
12 | - * |
|
13 | - * @param string $table_column column on table |
|
14 | - * @param string $nicename nice name for column(field) |
|
15 | - * @param bool $nullable is this field nullable |
|
16 | - * @param string $default_value default status |
|
17 | - * @param array $new_stati If additional stati are to be used other than the default WP statuses then |
|
18 | - * they can be registered via this property. The format of the array should be |
|
19 | - * as follows: array( |
|
20 | - * 'status_reference' => array( |
|
21 | - * 'label' => __('Status Reference Label', 'event_espresso') |
|
22 | - * 'public' => true, //'Whether posts of this status should be shown on the |
|
23 | - * frontend of the site' |
|
24 | - * 'exclude_from_search' => false, //'Whether posts of this status should be |
|
25 | - * excluded from wp searches' |
|
26 | - * 'show_in_admin_all_list' => true, //whether posts of this status are included |
|
27 | - * in queries for the admin "all" view in list table views. |
|
28 | - * 'show_in_admin_status_list' => true, //Show in the list of statuses with post |
|
29 | - * counts at the top of the admin list tables (i.e. Status Reference(2) ) |
|
30 | - * 'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>', |
|
31 | - * 'Status References <span class="count">(%s)</span>' ), //the text to display |
|
32 | - * on the admin screen( or you won't see your status count ). |
|
33 | - * ) |
|
34 | - * ) |
|
35 | - * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
36 | - * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is |
|
37 | - * set to true, it will be stored as an INT |
|
38 | - */ |
|
39 | - function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) |
|
40 | - { |
|
41 | - $this->_register_new_stati($new_stati); |
|
42 | - $this->_set_allowed_enum_values(); |
|
43 | - parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values); |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * This registers any new statuses sent via the $new_stati array on construct |
|
49 | - * |
|
50 | - * @access protected |
|
51 | - * @param array $new_stati statuses |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - protected function _register_new_stati($new_stati) |
|
55 | - { |
|
56 | - |
|
57 | - foreach ((array)$new_stati as $status_key => $status_args) { |
|
58 | - $args = array( |
|
59 | - 'label' => isset($status_args['label']) ? $status_args['label'] : $status_key, |
|
60 | - 'public' => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true, |
|
61 | - 'exclude_from_search' => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false, |
|
62 | - 'show_in_admin_all_list' => isset($status_args['show_in_admin_all_list']) && is_bool($status_args['show_in_admin_all_list']) ? $status_args['show_in_admin_all_list'] : false, |
|
63 | - 'show_in_admin_status_list' => isset($status_args['show_in_admin_status_list']) && is_bool($status_args['show_in_admin_status_list']) ? $status_args['show_in_admin_status_list'] : true, |
|
64 | - 'label_count' => isset($status_args['label_count']) ? $status_args['label_count'] : '', |
|
65 | - ); |
|
66 | - register_post_status($status_key, $status_args); |
|
67 | - } |
|
68 | - |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * This sets the _allowed_enum_values property using the $wp_post_stati array |
|
74 | - * |
|
75 | - * @access protected |
|
76 | - * @regurn void |
|
77 | - */ |
|
78 | - protected function _set_allowed_enum_values() |
|
79 | - { |
|
80 | - //first let's get the post_statuses |
|
81 | - global $wp_post_statuses; |
|
82 | - $this->_wp_post_stati = $wp_post_statuses; |
|
83 | - |
|
84 | - foreach ($this->_wp_post_stati as $post_status => $args_object) { |
|
85 | - $this->_allowed_enum_values[$post_status] = $args_object->label; |
|
86 | - } |
|
87 | - |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Before calling parent, first double-checks our list of acceptable post |
|
92 | - * types is up-to-date |
|
93 | - * |
|
94 | - * @param string $value_inputted_for_field_on_model_object |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
98 | - { |
|
99 | - $this->_set_allowed_enum_values(); |
|
100 | - return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - //helper methods for getting various $wp_post_statuses stuff. |
|
106 | - |
|
107 | - /** |
|
108 | - * This just returns the status object for the given status |
|
109 | - * |
|
110 | - * @access public |
|
111 | - * @see wp_register_post_status in wp-includes/post.php for a list of properties of the status object |
|
112 | - * @param string $status What status object you want |
|
113 | - * @return std_object the status object or FALSE if it doesn't exist. |
|
114 | - */ |
|
115 | - public function get_status_object($status) |
|
116 | - { |
|
117 | - return isset($this->_wp_post_stati[$status]) ? $this->_wp_post_stati[$status] : false; |
|
118 | - } |
|
7 | + protected $_wp_post_stati; |
|
8 | + |
|
9 | + |
|
10 | + /** |
|
11 | + * constructor |
|
12 | + * |
|
13 | + * @param string $table_column column on table |
|
14 | + * @param string $nicename nice name for column(field) |
|
15 | + * @param bool $nullable is this field nullable |
|
16 | + * @param string $default_value default status |
|
17 | + * @param array $new_stati If additional stati are to be used other than the default WP statuses then |
|
18 | + * they can be registered via this property. The format of the array should be |
|
19 | + * as follows: array( |
|
20 | + * 'status_reference' => array( |
|
21 | + * 'label' => __('Status Reference Label', 'event_espresso') |
|
22 | + * 'public' => true, //'Whether posts of this status should be shown on the |
|
23 | + * frontend of the site' |
|
24 | + * 'exclude_from_search' => false, //'Whether posts of this status should be |
|
25 | + * excluded from wp searches' |
|
26 | + * 'show_in_admin_all_list' => true, //whether posts of this status are included |
|
27 | + * in queries for the admin "all" view in list table views. |
|
28 | + * 'show_in_admin_status_list' => true, //Show in the list of statuses with post |
|
29 | + * counts at the top of the admin list tables (i.e. Status Reference(2) ) |
|
30 | + * 'label_count' => _n_noop( 'Status Reference <span class="count">(%s)</span>', |
|
31 | + * 'Status References <span class="count">(%s)</span>' ), //the text to display |
|
32 | + * on the admin screen( or you won't see your status count ). |
|
33 | + * ) |
|
34 | + * ) |
|
35 | + * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
36 | + * @param boolean $store_in_db_as_int By default, enums are stored as STRINGS in the DB. However, if this var is |
|
37 | + * set to true, it will be stored as an INT |
|
38 | + */ |
|
39 | + function __construct($table_column, $nicename, $nullable, $default_value, $new_stati = array()) |
|
40 | + { |
|
41 | + $this->_register_new_stati($new_stati); |
|
42 | + $this->_set_allowed_enum_values(); |
|
43 | + parent::__construct($table_column, $nicename, $nullable, $default_value, $this->_allowed_enum_values); |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * This registers any new statuses sent via the $new_stati array on construct |
|
49 | + * |
|
50 | + * @access protected |
|
51 | + * @param array $new_stati statuses |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + protected function _register_new_stati($new_stati) |
|
55 | + { |
|
56 | + |
|
57 | + foreach ((array)$new_stati as $status_key => $status_args) { |
|
58 | + $args = array( |
|
59 | + 'label' => isset($status_args['label']) ? $status_args['label'] : $status_key, |
|
60 | + 'public' => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true, |
|
61 | + 'exclude_from_search' => isset($status_args['exclude_from_search']) && is_bool($status_args['exclude_from_search']) ? $status_args['exclude_from_search'] : false, |
|
62 | + 'show_in_admin_all_list' => isset($status_args['show_in_admin_all_list']) && is_bool($status_args['show_in_admin_all_list']) ? $status_args['show_in_admin_all_list'] : false, |
|
63 | + 'show_in_admin_status_list' => isset($status_args['show_in_admin_status_list']) && is_bool($status_args['show_in_admin_status_list']) ? $status_args['show_in_admin_status_list'] : true, |
|
64 | + 'label_count' => isset($status_args['label_count']) ? $status_args['label_count'] : '', |
|
65 | + ); |
|
66 | + register_post_status($status_key, $status_args); |
|
67 | + } |
|
68 | + |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * This sets the _allowed_enum_values property using the $wp_post_stati array |
|
74 | + * |
|
75 | + * @access protected |
|
76 | + * @regurn void |
|
77 | + */ |
|
78 | + protected function _set_allowed_enum_values() |
|
79 | + { |
|
80 | + //first let's get the post_statuses |
|
81 | + global $wp_post_statuses; |
|
82 | + $this->_wp_post_stati = $wp_post_statuses; |
|
83 | + |
|
84 | + foreach ($this->_wp_post_stati as $post_status => $args_object) { |
|
85 | + $this->_allowed_enum_values[$post_status] = $args_object->label; |
|
86 | + } |
|
87 | + |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Before calling parent, first double-checks our list of acceptable post |
|
92 | + * types is up-to-date |
|
93 | + * |
|
94 | + * @param string $value_inputted_for_field_on_model_object |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
98 | + { |
|
99 | + $this->_set_allowed_enum_values(); |
|
100 | + return parent::prepare_for_set($value_inputted_for_field_on_model_object); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + //helper methods for getting various $wp_post_statuses stuff. |
|
106 | + |
|
107 | + /** |
|
108 | + * This just returns the status object for the given status |
|
109 | + * |
|
110 | + * @access public |
|
111 | + * @see wp_register_post_status in wp-includes/post.php for a list of properties of the status object |
|
112 | + * @param string $status What status object you want |
|
113 | + * @return std_object the status object or FALSE if it doesn't exist. |
|
114 | + */ |
|
115 | + public function get_status_object($status) |
|
116 | + { |
|
117 | + return isset($this->_wp_post_stati[$status]) ? $this->_wp_post_stati[$status] : false; |
|
118 | + } |
|
119 | 119 | } |
120 | 120 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_Enum_Text_Field.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_Enum_Text_Field.php'); |
|
3 | 3 | |
4 | 4 | class EE_WP_Post_Status_Field extends EE_Enum_Text_Field |
5 | 5 | { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | protected function _register_new_stati($new_stati) |
55 | 55 | { |
56 | 56 | |
57 | - foreach ((array)$new_stati as $status_key => $status_args) { |
|
57 | + foreach ((array) $new_stati as $status_key => $status_args) { |
|
58 | 58 | $args = array( |
59 | 59 | 'label' => isset($status_args['label']) ? $status_args['label'] : $status_key, |
60 | 60 | 'public' => isset($status_args['public']) && is_bool($status_args['public']) ? $status_args['public'] : true, |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_Foreign_Key_Field_Base.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_Foreign_Key_Field_Base.php'); |
|
3 | 3 | |
4 | 4 | class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base |
5 | 5 | { |
@@ -4,17 +4,17 @@ |
||
4 | 4 | class EE_Foreign_Key_String_Field extends EE_Foreign_Key_Field_Base |
5 | 5 | { |
6 | 6 | |
7 | - /** |
|
8 | - * removes all tags when setting |
|
9 | - * |
|
10 | - * @param string $value_inputted_for_field_on_model_object |
|
11 | - * @return string |
|
12 | - */ |
|
13 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
14 | - { |
|
15 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
16 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
17 | - } |
|
18 | - return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
19 | - } |
|
7 | + /** |
|
8 | + * removes all tags when setting |
|
9 | + * |
|
10 | + * @param string $value_inputted_for_field_on_model_object |
|
11 | + * @return string |
|
12 | + */ |
|
13 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
14 | + { |
|
15 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
16 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
17 | + } |
|
18 | + return strtoupper(wp_strip_all_tags($value_inputted_for_field_on_model_object)); |
|
19 | + } |
|
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -3,6 +3,6 @@ |
||
3 | 3 | |
4 | 4 | class EE_Trashed_Flag_Field extends EE_Boolean_Field |
5 | 5 | { |
6 | - //note: some client code simply checks if a field IS an EE_Trashed_Flag_Field |
|
7 | - //...otherwise, these fields are mostly the same as boolean fields |
|
6 | + //note: some client code simply checks if a field IS an EE_Trashed_Flag_Field |
|
7 | + //...otherwise, these fields are mostly the same as boolean fields |
|
8 | 8 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_Boolean_Field.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_Boolean_Field.php'); |
|
3 | 3 | |
4 | 4 | class EE_Trashed_Flag_Field extends EE_Boolean_Field |
5 | 5 | { |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -require_once(EE_MODELS . 'fields/EE_DB_Only_Field_Base.php'); |
|
2 | +require_once(EE_MODELS.'fields/EE_DB_Only_Field_Base.php'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Used by EE_Belongs_To_Any_Relations and EE_Has_Many_Any_Relations to identify the model the foreign key points to. |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -24,34 +24,34 @@ discard block |
||
24 | 24 | */ |
25 | 25 | class EE_WP_User_Field extends EE_Foreign_Key_Int_Field |
26 | 26 | { |
27 | - /** |
|
28 | - * No need to provide a default or the model pointed to- the default is |
|
29 | - * always get_current_user_id() and the model pointed to is always WP_User |
|
30 | - * |
|
31 | - * @param string $table_column name fo column for field |
|
32 | - * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
33 | - * @param boolean $nullable |
|
34 | - */ |
|
35 | - function __construct($table_column, $nicename, $nullable) |
|
36 | - { |
|
37 | - parent::__construct($table_column, $nicename, $nullable, null, 'WP_User'); |
|
38 | - } |
|
27 | + /** |
|
28 | + * No need to provide a default or the model pointed to- the default is |
|
29 | + * always get_current_user_id() and the model pointed to is always WP_User |
|
30 | + * |
|
31 | + * @param string $table_column name fo column for field |
|
32 | + * @param string $nicename should eb internationalized with __('blah','event_espresso') |
|
33 | + * @param boolean $nullable |
|
34 | + */ |
|
35 | + function __construct($table_column, $nicename, $nullable) |
|
36 | + { |
|
37 | + parent::__construct($table_column, $nicename, $nullable, null, 'WP_User'); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Gets the default which is always the current user. This can't be set when initially |
|
42 | - * constructing the model field because that's done before $current_user is set |
|
43 | - * |
|
44 | - * @return mixed |
|
45 | - */ |
|
46 | - function get_default_value() |
|
47 | - { |
|
48 | - if (did_action('init')) { |
|
49 | - return get_current_user_id(); |
|
50 | - } else { |
|
51 | - EE_Error::doing_it_wrong('EE_WP_User_Field::get_default_value', |
|
52 | - __('You cant get a default value for a wp_User_Field because the "init" action is called, because current_user global hasnt yet been setup. Consider doing your business logic on the "init" hook or later.', |
|
53 | - 'event_espresso'), '4.6.20'); |
|
54 | - return 1; |
|
55 | - } |
|
56 | - } |
|
40 | + /** |
|
41 | + * Gets the default which is always the current user. This can't be set when initially |
|
42 | + * constructing the model field because that's done before $current_user is set |
|
43 | + * |
|
44 | + * @return mixed |
|
45 | + */ |
|
46 | + function get_default_value() |
|
47 | + { |
|
48 | + if (did_action('init')) { |
|
49 | + return get_current_user_id(); |
|
50 | + } else { |
|
51 | + EE_Error::doing_it_wrong('EE_WP_User_Field::get_default_value', |
|
52 | + __('You cant get a default value for a wp_User_Field because the "init" action is called, because current_user global hasnt yet been setup. Consider doing your business logic on the "init" hook or later.', |
|
53 | + 'event_espresso'), '4.6.20'); |
|
54 | + return 1; |
|
55 | + } |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -14,56 +14,56 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field |
16 | 16 | { |
17 | - /** |
|
18 | - * removes all non-basic tags when setting |
|
19 | - * |
|
20 | - * @param string $value_inputted_for_field_on_model_object |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
24 | - { |
|
25 | - return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
26 | - } |
|
17 | + /** |
|
18 | + * removes all non-basic tags when setting |
|
19 | + * |
|
20 | + * @param string $value_inputted_for_field_on_model_object |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
24 | + { |
|
25 | + return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Remove any non-"simple" html tags. @see EE_Simple_HTML_Field |
|
30 | - * |
|
31 | - * @param array|string $value |
|
32 | - * @return array|string |
|
33 | - */ |
|
34 | - protected function _remove_tags($value) |
|
35 | - { |
|
36 | - if (is_array($value)) { |
|
37 | - foreach ($value as $key => $v) { |
|
38 | - $value[$key] = $this->_remove_tags($v); |
|
39 | - } |
|
40 | - } elseif (is_string($value)) { |
|
41 | - $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
42 | - } |
|
43 | - return $value; |
|
44 | - } |
|
28 | + /** |
|
29 | + * Remove any non-"simple" html tags. @see EE_Simple_HTML_Field |
|
30 | + * |
|
31 | + * @param array|string $value |
|
32 | + * @return array|string |
|
33 | + */ |
|
34 | + protected function _remove_tags($value) |
|
35 | + { |
|
36 | + if (is_array($value)) { |
|
37 | + foreach ($value as $key => $v) { |
|
38 | + $value[$key] = $this->_remove_tags($v); |
|
39 | + } |
|
40 | + } elseif (is_string($value)) { |
|
41 | + $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
42 | + } |
|
43 | + return $value; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * In case unsafe data somehow got inserted into the database, we want to remove tags again |
|
48 | - * |
|
49 | - * @param array|string $value_found_in_db_for_model_object |
|
50 | - * @return array|string |
|
51 | - */ |
|
52 | - function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
53 | - { |
|
54 | - return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
55 | - } |
|
46 | + /** |
|
47 | + * In case unsafe data somehow got inserted into the database, we want to remove tags again |
|
48 | + * |
|
49 | + * @param array|string $value_found_in_db_for_model_object |
|
50 | + * @return array|string |
|
51 | + */ |
|
52 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
53 | + { |
|
54 | + return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * Determines what tags to allow in this model field |
|
60 | - * |
|
61 | - * @global array $allowedtags |
|
62 | - * @return array |
|
63 | - */ |
|
64 | - function _get_allowed_tags() |
|
65 | - { |
|
66 | - return apply_filters('FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', |
|
67 | - EEH_HTML::get_simple_tags(), $this); |
|
68 | - } |
|
58 | + /** |
|
59 | + * Determines what tags to allow in this model field |
|
60 | + * |
|
61 | + * @global array $allowedtags |
|
62 | + * @return array |
|
63 | + */ |
|
64 | + function _get_allowed_tags() |
|
65 | + { |
|
66 | + return apply_filters('FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', |
|
67 | + EEH_HTML::get_simple_tags(), $this); |
|
68 | + } |
|
69 | 69 | } |
@@ -1,4 +1,4 @@ |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 |
@@ -1,5 +1,5 @@ |
||
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 | /** |
5 | 5 | * Only allows a select, small number of html tags: |
@@ -11,14 +11,14 @@ |
||
11 | 11 | |
12 | 12 | |
13 | 13 | |
14 | - /** |
|
15 | - * removes all tags which a WP Post wouldn't allow in its content normally |
|
16 | - * |
|
17 | - * @param string $value |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - public function prepare_for_set($value) |
|
21 | - { |
|
22 | - return parent::prepare_for_set(wp_kses("$value", EEH_HTML::get_simple_tags())); |
|
23 | - } |
|
14 | + /** |
|
15 | + * removes all tags which a WP Post wouldn't allow in its content normally |
|
16 | + * |
|
17 | + * @param string $value |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + public function prepare_for_set($value) |
|
21 | + { |
|
22 | + return parent::prepare_for_set(wp_kses("$value", EEH_HTML::get_simple_tags())); |
|
23 | + } |
|
24 | 24 | } |
@@ -3,15 +3,15 @@ |
||
3 | 3 | |
4 | 4 | class EE_Slug_Field extends EE_Text_Field_Base |
5 | 5 | { |
6 | - /** |
|
7 | - * ensures string is usable in URLs |
|
8 | - * |
|
9 | - * @param string $value_inputted_for_field_on_model_object |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | - { |
|
14 | - //reminder: function prepares for use in URLs, not making human-readable. |
|
15 | - return sanitize_title($value_inputted_for_field_on_model_object); |
|
16 | - } |
|
6 | + /** |
|
7 | + * ensures string is usable in URLs |
|
8 | + * |
|
9 | + * @param string $value_inputted_for_field_on_model_object |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | + { |
|
14 | + //reminder: function prepares for use in URLs, not making human-readable. |
|
15 | + return sanitize_title($value_inputted_for_field_on_model_object); |
|
16 | + } |
|
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -1,5 +1,5 @@ |
||
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_Slug_Field extends EE_Text_Field_Base |
5 | 5 | { |