@@ -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 | { |
@@ -8,36 +8,36 @@ |
||
8 | 8 | |
9 | 9 | class EE_Maybe_Serialized_Text_Field extends EE_Serialized_Text_Field |
10 | 10 | { |
11 | - /** |
|
12 | - * Value could be an array or a string. If its an array, serialize it. Otherwise, leave it as a string |
|
13 | - * |
|
14 | - * @param array|string $value_of_field_on_model_object |
|
15 | - * @return string (possibly serialized) |
|
16 | - */ |
|
17 | - function prepare_for_use_in_db($value_of_field_on_model_object) |
|
18 | - { |
|
19 | - if (is_array($value_of_field_on_model_object)) { |
|
20 | - return parent::prepare_for_use_in_db($value_of_field_on_model_object); |
|
21 | - } else { |
|
22 | - return $value_of_field_on_model_object; |
|
23 | - } |
|
24 | - } |
|
11 | + /** |
|
12 | + * Value could be an array or a string. If its an array, serialize it. Otherwise, leave it as a string |
|
13 | + * |
|
14 | + * @param array|string $value_of_field_on_model_object |
|
15 | + * @return string (possibly serialized) |
|
16 | + */ |
|
17 | + function prepare_for_use_in_db($value_of_field_on_model_object) |
|
18 | + { |
|
19 | + if (is_array($value_of_field_on_model_object)) { |
|
20 | + return parent::prepare_for_use_in_db($value_of_field_on_model_object); |
|
21 | + } else { |
|
22 | + return $value_of_field_on_model_object; |
|
23 | + } |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Formats the array (or string) according to $schema. Right now, just implode with commas |
|
28 | - * |
|
29 | - * @param type $value_on_field_to_be_outputted |
|
30 | - * @param type $schema |
|
31 | - * @return strubg |
|
32 | - */ |
|
33 | - function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
34 | - { |
|
35 | - $pretty_value = null; |
|
36 | - if (is_array($value_on_field_to_be_outputted)) { |
|
37 | - $pretty_value = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
38 | - } else { |
|
39 | - $pretty_value = $value_on_field_to_be_outputted; |
|
40 | - } |
|
41 | - return $pretty_value; |
|
42 | - } |
|
26 | + /** |
|
27 | + * Formats the array (or string) according to $schema. Right now, just implode with commas |
|
28 | + * |
|
29 | + * @param type $value_on_field_to_be_outputted |
|
30 | + * @param type $schema |
|
31 | + * @return strubg |
|
32 | + */ |
|
33 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
34 | + { |
|
35 | + $pretty_value = null; |
|
36 | + if (is_array($value_on_field_to_be_outputted)) { |
|
37 | + $pretty_value = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
|
38 | + } else { |
|
39 | + $pretty_value = $value_on_field_to_be_outputted; |
|
40 | + } |
|
41 | + return $pretty_value; |
|
42 | + } |
|
43 | 43 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | /** |
5 | 5 | * For a db text column, which can either be an array in PHP code or a string. |
6 | 6 | */ |
7 | -require_once(EE_MODELS . 'fields/EE_Text_Field_Base.php'); |
|
7 | +require_once(EE_MODELS.'fields/EE_Text_Field_Base.php'); |
|
8 | 8 | |
9 | 9 | class EE_Maybe_Serialized_Text_Field extends EE_Serialized_Text_Field |
10 | 10 | { |
@@ -5,12 +5,12 @@ |
||
5 | 5 | */ |
6 | 6 | class EE_WP_Post_Type_Field extends EE_DB_Only_Text_Field |
7 | 7 | { |
8 | - /** |
|
9 | - * @param string $post_type the exact string to be used for the post type |
|
10 | - * of all these post type model objects/rows |
|
11 | - */ |
|
12 | - function __construct($post_type) |
|
13 | - { |
|
14 | - parent::__construct('post_type', __("Post Type", 'event_espresso'), false, $post_type); |
|
15 | - } |
|
8 | + /** |
|
9 | + * @param string $post_type the exact string to be used for the post type |
|
10 | + * of all these post type model objects/rows |
|
11 | + */ |
|
12 | + function __construct($post_type) |
|
13 | + { |
|
14 | + parent::__construct('post_type', __("Post Type", 'event_espresso'), false, $post_type); |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -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 | class EE_DB_Only_Text_Field extends EE_DB_Only_Field_Base |
5 | 5 | { |
@@ -3,14 +3,14 @@ |
||
3 | 3 | |
4 | 4 | class EE_Plain_Text_Field extends EE_Text_Field_Base |
5 | 5 | { |
6 | - /** |
|
7 | - * removes all tags when setting |
|
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 | - return wp_strip_all_tags(parent::prepare_for_set($value_inputted_for_field_on_model_object)); |
|
15 | - } |
|
6 | + /** |
|
7 | + * removes all tags when setting |
|
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 | + return wp_strip_all_tags(parent::prepare_for_set($value_inputted_for_field_on_model_object)); |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | \ 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_Plain_Text_Field extends EE_Text_Field_Base |
5 | 5 | { |